Proportionally scale entire stack?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Proportionally scale entire stack?

Post by ctflatt » Thu Jan 06, 2011 1:00 am

Hello, all!

I am wondering if it is possible to script an entire stack to proportionally scale down (or up) to a new size?

Thanks!

:Todd

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Proportionally scale entire stack?

Post by richardmac » Thu Jan 06, 2011 7:46 pm

Where you looking at developing for the iPad and the iPhone at the same time? I'm sort of there right now, too. I have an app my friend and I are building, and we're going to release it for OS X, iPad, and iPhone/iPod Touch. It's build for the iPad, but when you open it on the iPhone, you only see a corner of the screen. So the two options I can think of are script the whole thing (if the app detects that it's running on an iPhone, change the stack size, hide and show different graphics, etc.) or just keep two different copies of the stack, and when you make changes, make them to both. I kinda like the idea of having one stack that can be used for OS X, iPad, and iPhone. One code base to maintain.

With most apps, though, I would think you'd want different graphics associated as well as a different layout. But maybe not with all apps?

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Proportionally scale entire stack?

Post by ctflatt » Fri Jan 07, 2011 12:02 am

Exactly.

I am trying to maintain one code base. It would be great to be able to script the stack to perform an overall proportional scale. I am not experienced enough with scripting to know how to accomplish this.

If you have any suggestions, starting points, etc. I would be grateful.

Thanks!

richardmac
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 211
Joined: Sun Oct 24, 2010 12:13 am

Re: Proportionally scale entire stack?

Post by richardmac » Fri Jan 07, 2011 3:12 am

I'm hardly the expert here - but the experts here are extremely helpful. Here are some of my thoughts on how this might be done:

You can have LiveCode run commands before anything is displayed on the screen using "on preOpenStack." And you can also use the environment function to determine if you are running mobile, and "the machine" should tell you what it's running on. Also, someone suggested having the different layouts on different cards.

So something like this concept:

on preOpenStack
if the environment is mobile then
if (the machine is iPhone) or (the machine is iPod Touch) or (the machine is iPhone Simulator) then
-- set the stack height and width to iPhone size, go to card "iPhone Layout", etc
else
-- set the stack height and width to iPad size, go to card "iPad Layout", etc
end if
else
-- set the stack height and width to desktop size, go to card "Desktop Layout," etc
end if
end preOpenStack

Yeah, I know, it's ugly. I need to master CASE statements, obviously. But this is just a concept. I'd love to see some other folk's ideas on how this might best be accomplished.

ctflatt, did you see Apple launched it's App store today? I see that as being another avenue for LiveCode projects.

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Proportionally scale entire stack?

Post by ctflatt » Fri Jan 07, 2011 2:31 pm

Thanks, richardmac...

I'll see what I can manage to screw up next :)

Yes, saw the App Store announcement and visited. Looks promising :)

More soon...

:Todd

hliljegren
Posts: 111
Joined: Sun Aug 23, 2009 7:48 am
Contact:

Re: Proportionally scale entire stack?

Post by hliljegren » Sat Jan 08, 2011 1:09 am

I would do separate stacks for iPhone/iPod, iPhone/iPod retina display, and, one for iPad. By using different stacks you will have an easier way to check your layout. (IMHO) then of course you need to "go to stack" instead of "go to card"...
___________________________________
MacBook Pro M1 MAX 64 Gb,
LiveCode 10.0.1rc3

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Proportionally scale entire stack?

Post by ctflatt » Sat Jan 08, 2011 4:10 pm

Here is my reasoning behind the request:

When designing for print, a page can be designed at a certain size but then output at other sizes based on a percentage of the original.

Is this possible with an entire stack?

I would much rather invest my time designing/coding one stack of cards, let's say for the iPad at 768x1024, and have the option to scale that stack down, by say 20% or 80% of the original, for desktop application use at lower monitor resolutions (unable to display the full 1024 vertical height). This could be done for other targeted devices.

Creating multiple cards and/or stacks for all of these device targets seems like a waste of valuable time, considering the print example mentioned above. The price for development goes up for each iteration.

Is this not possible programmatically? It seems like it would be a big time-saver.

Thoughts? Options?

:Todd

hliljegren
Posts: 111
Joined: Sun Aug 23, 2009 7:48 am
Contact:

Re: Proportionally scale entire stack?

Post by hliljegren » Sat Jan 08, 2011 5:16 pm

ctflatt wrote:Here is my reasoning behind the request:

When designing for print, a page can be designed at a certain size but then output at other sizes based on a percentage of the original.

Thoughts? Options?
The problem we have here is that iPad applications are not just blown-up iPhone applications (If you want that, you can design for iPhone and let the iPad scale the app.) I can see that it would be useful (and possible) to do between iPhone retina display and regular iPhone display, but between iPhone and iPad you will still need to redesign you layout and maybe even the functionality to use the iPads greater display.

I would still welcome better scaling in LiveCode though...

But if you design for retina display i guess it should be possible scale all your controls by dividing every width / height / x and y location with 2, but then you are in fact designing something that's already in the iPhone iOS as the screen is in "points" instead of pixels. Check out the iphoneUseDeviceResolution in the documentation.
___________________________________
MacBook Pro M1 MAX 64 Gb,
LiveCode 10.0.1rc3

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Proportionally scale entire stack?

Post by ctflatt » Sat Jan 08, 2011 6:18 pm

Thanks, but again, the iPhone devices (retina or otherwise) are actually the least of my concerns.

I am wanting to use a portrait iPad-targeted stack scaled down to a more desktop friendly vertical resolution without having to redo every card in the stack. The stack consists of 70+ cards, each with 4-6 clickable regions that trigger sound play/empty and image show/hide events. To manually redo every page would be twice the work, but if that's what I have to do, that's what I have to do.

I appreciate your input, though.

BTW, each card also has a background image. All of my images are referenced, which is keeping the standalone quite small. I could batch process each image in Photoshop for the much smaller sizes for memory efficiency, but redoing each hotspot would be tedious at best. That's my reasoning for the original request.

hliljegren
Posts: 111
Joined: Sun Aug 23, 2009 7:48 am
Contact:

Re: Proportionally scale entire stack?

Post by hliljegren » Sun Jan 09, 2011 1:22 pm

Ok, I've done something similar to handle the layout of controls when the user resizes the stack. Maybe you could put something like this in preOpenCard:

Code: Select all

# First you need to calculate some scale factor to accommodate for the new size.
put the width of this stack / originalWidth into scaleFactor
# Now you can scale your controls
repeat with i = 1 to the number of controls
   put the rect of control i into pRect
   repeat with j = 1 to 4
      multiply item j of pRect by scaleFactor
   end repeat
   set the rect of control i to pRect
end repeat
Maybe you need to do something more intelligent when calculating your scaleFactor and if you are scaling images you need to respect the aspect ratio in some way, fields should reset their fontSize etc, but its certainly doable without to much fuzz.

I would do the layout for the iPad and the layout changes on the desktop, as you have much more computation power on the desktop.

Code: Select all

if the platform is not "iOS" then recalcLayout
___________________________________
MacBook Pro M1 MAX 64 Gb,
LiveCode 10.0.1rc3

ctflatt
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 243
Joined: Sun Dec 06, 2009 12:24 am
Contact:

Re: Proportionally scale entire stack?

Post by ctflatt » Sun Jan 09, 2011 3:47 pm

Many thanks.

I'll see what I can do with what you have graciously provided!

:Todd

Post Reply