Here is the code (less than 100 lines in the main to build such an interface: not so bad? )
--# Main
-- WindowsSample01
-- Main
displayMode(FULLSCREEN)
function setup()
windows = Windows()
winImage = windows:get("big_image")
winText = windows:get("text")
winThumbs = windows:get("thumbs")
leftButton = WindowButton("<<",shiftToLeft)
windows:get("left"):print("\
\
")
windows:get("left"):print(leftButton)
rightButton = WindowButton(">>",shiftToRight)
windows:get("right"):print("\
\
")
windows:get("right"):print(rightButton)
str = imageNames()
index = 1
-- askImageToInternet(str[1])
updateThumbs()
end
function shiftToLeft()
index = index-4
if index<1 then index=1 end
updateThumbs()
end
function shiftToRight()
index = index+4
if index>5 then index=5 end
updateThumbs()
end
function askImageToInternet(txt)
http.request(txt,function(img) toDoWhenImageIsReceived(img,txt) end)
end
function toDoWhenImageIsReceived(img,txt)
winImage:clear()
winImage:print(img)
winText:clear()
winText:print("this is the mage name:")
winText:print(txt)
winText:print("and this is my comment")
end
function updateThumbs()
local txt
winThumbs:clear()
winThumbs.columns=4
for i=0,3 do
local txt = str[ i + index ]
http.request(txt, function(img) toDoWhenThumbIsReceived(img,txt) end )
end
end
function toDoWhenThumbIsReceived(img,txt)
winThumbs.framePrinter:add(img,function() toDoWhenThumbIsTouched(txt) end)
end
function toDoWhenThumbIsTouched(txt)
askImageToInternet(txt)
end
function imageNames()
local names = {}
for i=1,8 do
names[i] = "http://jmv38.net23.net/house/pano01-".. tostring(i) ..".jpg"
end
return names
end
function draw()
background(109, 109, 109, 255)
-- put your drawing before this line
if windows then windows:draw() end
end
function touched(touch)
if windows then touch = windows:touched(touch) end
if not touch then return end
-- put your touch after this line
end
--# WindowsLoadClass1
-- this is just a starter, you can suppress this tab when the automatic one is created
function Windows:loadAllWindows()
self.autoSaveDisabled = false
local win=Window(
{
disabled=true,
name='message',
height=390,
fontSize=20,
left=330,
Halign='justified',
columns=1,
width=480,
top=150,
Valign='center',
parent = self
}
)
table.insert(self.winList,win)
local win=Window(
{
name='big_image',
height=450,left=90,width=510,top=30,
parent = self
}
)
table.insert(self.winList,win)
local win=Window(
{
name='text',
height=450,left=600,width=330,top=30,
parent = self
}
)
table.insert(self.winList,win)
local win=Window(
{
disabled=true,
name='Tutorial',
parent = self
}
)
table.insert(self.winList,win)
local win=Window(
{
name='right',
height=240,
left=840,
Halign='center',
Valign='center',
columns=1,
width=90,
top=480,
parent = self
}
)
table.insert(self.winList,win)
local win=Window(
{
name='left',
height=240,
left=90,
Halign='center',
Valign='center',
columns=1,
width=90,
top=480,
parent = self
}
)
table.insert(self.winList,win)
local win=Window(
{
name='thumbs',
height=240,
left=180,
Halign='justified',
columns=4,
width=660,
top=480,
parent = self
}
)
table.insert(self.winList,win)
end
--# CorrectionToMyLibrary
-- dont look at this part, it is a modification that has to be made in my lib
-- is made automatically, you heve nothing to do
function WindowPrnObject:create()
local v = self.data
local typ = self:typeOf(v)
self.type = typ
local img
if typ == "string" then img = self:strToImg(v)
elseif typ == "image" then img = self:imgToImg(v)
elseif typ == "button" then img = self:butToImg(v)
else img = self:strToImg(tostring(v))
end
self.img = img
self.height = img.height
self.width = img.width
-- management of touchable objects
local callback = self.callback
if typ == "button" then
self.txt = v.txt
self.imgOn = v.imgOn
self.imgOff = v.imgOff
callback = v.callback
elseif callback then
self.txt = v
self.imgOn = img
self.imgOff = img
self.tintDark = false
end
if typ == "button" or callback then
self.dx = self.width/2
self.dy = self.height/2
self.cx = self.left + self.dx
self.cy = self.top + self.dy
self.name = self.name .. "-" .. tostring(self.txt)
self:registerTouchableObject()
self.callback = function()
self.img = self.imgOn
if self.tintDark~= nil then self.tintDark = true end
self.timers:add(0.3, -- delay so the display can change visibly
function()
callback(self.txt)
self.img = self.imgOff
if self.tintDark~= nil then self.tintDark = false end
end,
self.name)
end
end
if obj~= self then return obj end
end