Resizing Groups

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Re: Resizing Groups

Post by odysseus » Thu Nov 26, 2020 12:54 am

Richard, I have been using Toolbook Openscript. In Toolbook groups are just collections of objects (and nested groups) and don’t have a ‘wrapper’. They behave just like single objects inasmuch as they can be resized by dragging or in codeas if they were one object. Another advantage is that you can change the background color of a group and all items in the group individually adopt that color, so you can color a group of objects in one instruction and turn one back, leaving the others colored. In LC objects in a group have both a common color and an individual color. That one caught me out!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9837
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Resizing Groups

Post by FourthWorld » Thu Nov 26, 2020 1:15 am

It's been a while since I worked with Toolbook, but I sure enjoyed it. I really miss Viewers.

This group behaviors you describe are very close to home LC handles them. I didn't recall that if it group an object in TB you can no longer set individual colors, but in LC if you clear the color setting of a control in a group it'll inherit the group color.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Resizing Groups

Post by dunbarx » Thu Nov 26, 2020 5:35 am

Hi.

LC is not a CAD program, though I have made it into one for a project of mine.

As Richard points out, a group is simply a control that contains other controls. It has no overarching, er, control, over its children.

Do this. Make three buttons on a new card. Place two of them close to each other near the center of the card and group them.Set the 3D of the group to "false" so you can see its border. Now in the outlier button script:

Code: Select all

on mouseUp
   breakpoint
   set the width of grp 1 to the width of grp 1 * 1.2
   repeat with y = 1 to the number of btns
      if the owner of btn y = the name of grp 1 then set the width of btn y to the width of btn y * 1.5
   end repeat
end mouseUp

Click the button a couple of times. Step through the handler. The children will grow in width in step with the group that contains them. But these properties have to be set individually. They do not follow from any "umbrella of control" between the group and its kids.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9387
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Resizing Groups

Post by richmond62 » Thu Nov 26, 2020 8:06 am

I did some in-house program development using ToolBook in 1999 and found that after HyperCard itwas
not a great improvement (far from it in fact). Of course in the last 21 years it may nave improved, although
looking at its website it simply seems to have been dumbed down.

Finding MetaCard, and then RunRev (now called LiveCode) in 2001 was a breath of fresh air.

As to resizing objects . . .

My inclination is to resize them individually and not bother anent groups.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9387
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Resizing Groups

Post by richmond62 » Thu Nov 26, 2020 8:48 am

I enjoyed it . . . 8)

Code: Select all

on resizeStack nLR, nUD, oLR, oUD
   --------
   put (nLR/oLR) into LRprop
   put (nUD/oUD) into UDprop
   --------
   set the width of grc "RP" to ((the width of grc "RP") * LRprop)
   set the height of grc "RP" to ((the height of grc "RP") * UDprop)
   set the left of grc "RP" to ((the left of grc "RP") * LRprop)
   set the top of grc "RP" to ((the top of grc "RP") * UDprop)
   --------
   set the width of grc "REK" to ((the width of grc "REK") * LRprop)
   set the height of grc "REK" to ((the height of grc "REK") * UDprop)
   set the left of grc "REK" to ((the left of grc "REK") * LRprop)
   set the top of grc "REK" to ((the top of grc "REK") * UDprop)
   ---------
   set the width of fld "TF" to ((the width of fld "TF") * LRprop)
   set the height of fld "TF" to ((the height of fld "TF") * UDprop)
   set the left of fld "TF" to ((the left of fld "TF") * LRprop)
   set the top of fld "TF" to ((the top of fld "TF") * UDprop)
   ---------
end resizeStack
-
Screenshot 2020-11-26 at 9.44.28.png
-
Screenshot 2020-11-26 at 9.44.59.png
-
Screenshot 2020-11-26 at 9.45.12.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9387
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Resizing Groups

Post by richmond62 » Thu Nov 26, 2020 8:49 am

And here's the stack . . . :D

Enjoy yourself.
Attachments
Resize Headache.livecode.zip
(1.13 KiB) Downloaded 183 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9387
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Resizing Groups

Post by richmond62 » Thu Nov 26, 2020 9:33 am

Some clever type can probably avoid doing 'everything' 3 times by using something like

first control

OK, OK: I'll pretend to be clever just this once. 8)

Code: Select all

on resizeStack nLR, nUD, oLR, oUD
   --------
   put (nLR/oLR) into LRprop
   put (nUD/oUD) into UDprop
   --------
   put 1 into KONTROL
   repeat 3 times
      --------
      put the name of control KONTROL into XXX
      --------
      set the width of XXX to ((the width of XXX) * LRprop)
      set the height of XXX to ((the height of XXX) * UDprop)
      set the left of XXX to ((the left of XXX) * LRprop)
      set the top of XXX to ((the top of XXX) * UDprop)
      --------
      add 1 to KONTROL
   end repeat
   --------
end resizeStack
Attachments
Resize Headache 2.livecode.zip
Here's the stack.
(1.13 KiB) Downloaded 165 times

odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Re: Resizing Groups

Post by odysseus » Thu Nov 26, 2020 12:12 pm

Thats fine for 3 objects - now try it with 75 objects of various types including 12 nested groups. One line of code in Toolbook.

Anyway thanks everyone for your help, at least I know I haven’t missed something simple. Back to my coding cave!

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9387
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Resizing Groups

Post by richmond62 » Thu Nov 26, 2020 2:06 pm

One line of code in Toolbook.
Well, go back to Toolbook if it's so marvellous.

Of course all that means is that, behind the scene, the Toolbook engineers have done
a lot of the heavy lifting already.

However, I've never liked driving automatic cars, much prefering manual ('stick' USA) as I feel
I have more control over the thing.

I can never quite understand remarks like that (One line of code in Toolbook) in the context
of LiveCode. Toolbook is a different beast (it used to be similar but has gone off on a different
trajectory) to LiveCode. Both have undoubted advantages in differing contexts, although I would
like to think that LiveCode is far, far more flexible than Toolbook currently is.

The fact that Toolbook can scale everything on-screen with "the flick of a switch" may, indeed be jolly useful.
I would ask whether one can be selective about components on-screen that are and aren't scaled.
Last edited by richmond62 on Thu Nov 26, 2020 2:27 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9387
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Resizing Groups

Post by richmond62 » Thu Nov 26, 2020 2:10 pm

now try it with 75 objects of various types including 12 nested groups.
If you paid close attention to the code in my second version you would see that the number of objects was immaterial,
and, frankly, de-group the groups as all they may serve to do is muck up the scaling..

stam
Posts: 2682
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Resizing Groups

Post by stam » Thu Nov 26, 2020 2:56 pm

odysseus wrote:
Thu Nov 26, 2020 12:12 pm
Thats fine for 3 objects - now try it with 75 objects of various types including 12 nested groups. One line of code in Toolbook.

Anyway thanks everyone for your help, at least I know I haven’t missed something simple. Back to my coding cave!
Yeh resizing groups is probably not the way to cater for the entire user interface. As Richard mentioned:
FourthWorld wrote:
Wed Nov 25, 2020 8:53 pm
From your description here it sounds like your app may be a good fit for fullScreenMode - you can learn more about using it here:
https://lessons.livecode.com/m/15262/l/ ... ll-devices
is probably the way to go for that.

Personally i wish the geometry manager worked more reliably, that may have been a good way to do this - but so far i really i can't get it to do what i want it to do. It does seem like a lot of complexity has been crammed into it where a simpler variation (like with FileMaker Pro) would have been more usable, but that's just me...

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Resizing Groups

Post by jacque » Thu Nov 26, 2020 8:01 pm

Well, go back to Toolbook if it's so marvellous.
Too much snark, Richmond. Not necessary.

Groups are convenient containers that can be useful in many ways, including acting as single objects for custom controls. They also get specific messages intended to help with problems like scaling and positioning. I wouldn't denegrate the use of groups. In this case they are an advantage.

Scaling the contents does have to be done by script if the app doesn't use fullscreenmode. The scaling can be done inside an openControl or preOpenControl handler in the group. This would allow independent scaling per group as needed. These messages also are sent to nested groups, see the dictionary entries. The example mentions scaling as one reason to use these messages.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Re: Resizing Groups

Post by odysseus » Sat Nov 28, 2020 7:47 pm

I had to move from Toolbook as it is no longer supported and development has stopped. In fact I was surprised not by the differences between Toolbook and LC, but by the similarities. Both share the concepts of books/stacks, pages/cards, Openscript/script, the ‘it’ variable, programmable graphical objects, groups (!), etc. etc.

In most cases I have been able to copy and paste pages of script, then just run through and change it to suit LC, ending up with a similar amount of code.

Obviously coming from a different program I expect some hiccups, I just have to adapt. LC has the great advantage of being multi-platform, but I still think Toolbook scores visually and has some features LC could learn from. But then nothing in life is perfect!

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”