Thank you so much Simon. Very interesting topic. So I have now solve the problem by scripting some code. It seems to work fine, but it's certainly far to be perfect. I post it here so maybe can be useful to somebody have the same problem.
CARD SCRIPTS
Code: Select all
on preOpenCard
if the environment is "mobile" then
createCardControlsList
scaleControls
end if
end preOpenCard
Code: Select all
on createCardControlsList
put empty into cardControlList
put "106,43,190,66," into cardControlList ["backButton"] -- this list is hardcoded to date (see below)
put "933,258,402,464,14" into cardControlList ["Credits"]
put "325,166,410,120," into cardControlList ["logo"]
end createCardControlsList
STACK SCRIPTS
Code: Select all
on scaleControls
if the environment is mobile then
if iphoneDeviceScale() is "2" then -- Returns 2 on a retina display, 1 otherwise
put "1" into scaleRate
put "@2x" into at2xString -- used to create name of images when dimamically created on scripts
else -- non-retina
put "0.5" into scaleRate
doScaleControls scaleRate -- 0.5 because the stack was created in @2x
put "" into at2xString
-- send "resizeImages" to card "images" of stack "resources" -- used for Android where you want to resize an object to an arbitrary size
send "useNonRetinaImages" to card "images" of stack "resources" -- used for iOS where you use retina or non-retina sizes (e.g. "image@2x" or just "image")
end if
end if
end scaleControls
command doScaleControls pScale
repeat for each key tKey in cardControlList do
set the location of control tKey to item 1 of cardControlList [tKey] * pScale & comma & item 2 of cardControlList[tKey] * pScale
set the width of control tKey to item 3 of cardControlList[tKey] * pScale
set the height of control tKey to item 4 of cardControlList[tKey] * pScale
if item 5 of cardControlList[tKey] <> "" then -- some controls have an item for text sizes
set the textSize of control tKey to item 5 of cardControlList[tKey] * pScale -- scale
end if
end repeat
end doScaleControls
IMAGES SUBSTACK SCRIPTS
global imagesResized, scaleRate
Code: Select all
on resizeImages -- for Android use
if imagesResized = "YES" then exit resizeImages -- to resize just one time
repeat with x = 1 to the number of images of me
put the short name of image x of me into tImageName
put the width of image tImageName of me into tWidth
put the height of image tImageName of me into tHeight
set the width of image tImageName of me to tWidth * scaleRate
set the height of image tImageName of me to tHeight * scaleRate
set the lockLocation of image tImageName to true -- to avoid image backs at it's original size when navigate between cards
end repeat
put "YES" into imagesResized
end resizeImages
Code: Select all
on useNonRetinaImages -- then we will use non-retina images
if imagesResized = "YES" then exit useNonRetinaImages
set the icon of button "myNav" of cd "info" of stack "myStack" to "navBar" -- by default button has "navBar@2x" as icon button, here we set the non-retina one
set the icon of button "backButton" of cd "info" of stack "myStack" to "navBack"
set the icon of button "logo" of cd "info" of stack "myStack" to "Logo"
put "YES" into imagesResized
end useNonRetinaImages
UTILITY BUTTON SCRIPT (to use in each card to create the list of controls) -- should to be replaced with some repeat statements in "createCardControlsList" handler in future versions
Code: Select all
on mouseUp
repeat with x = 1 to the number of controls of the current card
put the short name of the control x into tControl
put the name of the control x of the current card into kindCheck
if the first word of kindCheck <> "group" then -- don't need to resize groups
put "put"&"e & (loc of control tControl) &","& (width of control tControl) &","& (height of control tControl) &","& (textSize of control tControl) "e&& "into cardControlList [""e&tControl"e&"]" &return after controlList
end if
put controlList -- copy this and paste in the createCardControlsList handler
end repeat
end mouseUp
PS
BTW, to dimamically set a button icon, I use a code like this:
Code: Select all
set icon of button "imageAction" of cd "content" to "action" & at2xString
at2xString can contain "@2x" or "" based on the retina or non-retina screen.