Layer control within 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

Post Reply
SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Layer control within groups

Post by SteveTX » Thu Jul 14, 2011 8:37 am

How you set layers relative to a group?

I have built a tabbed menu. Each tab is a group, and all tabs are in a single group. On mouseDown, I want to set the tab to the top of the group of tabs. This doesn't seem to work, and position "top" is considered absolute to the stack, instead of relative to the group. Setting specific layer numbers won't work as this stack has hundreds of layers.

(grp tab3 of grp tabs)

Code: Select all

on mouseDown
   set the layer of grp me to top
   set the colorOverlay["opacity"] of grp "tab2ContentWindow" to 80
   set the colorOverlay["opacity"] of grp "tab4ContentWindow" to 80
   set the colorOverlay["opacity"] of grp "tab5ContentWindow" to 80
   set the colorOverlay["opacity"] of grp "tab3ContentWindow" to 0
   set the visible of grp "firewallNetwork" to false
   set the visible of grp "connectionNetwork" to false
   set the visible of grp "routerNetwork" to true
end mouseDown

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Layer control within groups

Post by Klaus » Thu Jul 14, 2011 12:13 pm

Hi Steve,
This doesn't seem to work...
So does it work or does it not work? 8)

Every object has a TOP property, so instead of using the absolute TOP (relative to the card)
you could use the TOP of another group as a reference!
...
set the top of grx X to the top of grp Y
...

To "relayer" objects within a group you need to set the "relayergroupedcontrols" to TRUE at first in your script
and set it to FALSE when you are finished.

HANDLE WITH CARE!
Relayering objects within a group can be a dangerous thing! :)

Check "relayergroupedcontrols" in the dictionary for more info!


Best

Klaus

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: Layer control within groups

Post by SteveTX » Thu Jul 14, 2011 4:18 pm

Code: Select all

set the top of grx X to the top of grp Y
There is no mention of this syntax that I found anywhere. And yes, "relayergroupedcontrols" is dangerous.

However, even upon doing that code, it removes grp X out of grp Y. I want to keep grp X inside grp Y while moving grp X to the front layer.

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: Layer control within groups

Post by SteveTX » Fri Jul 15, 2011 5:57 am

bump. Any ideas how to change layer of group X inside group Y without it being removed from group Y via relayergroupedcontrols?

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Layer control within groups

Post by Klaus » Fri Jul 15, 2011 11:43 am

Hi Steve,

1. there is an entry about TOP in the dictionary! This is a property that can be "get" and "set" for any object.
2. Setting "the top" of an object will NOT change its layer, only its location!
SteveTX wrote:Any ideas how to change layer of group X inside group Y without it being removed from group Y via relayergroupedcontrols?
"relayergroupedcontrols" is just a setting that will allow you to relayer objects inside of a group when set to TRUE.
Otherwise you will get an error if you try to relayer object with this set to FALSE.

And of course you will need to manage the correct "new" layers of your objects inside of a group, that's why this is so dangerous!
You ned to calculate new layers from the existing layers, e.g. if group A is the "main" group that contain other groups,
you cannot move groups inside of grp A to any lower layer than the one of group A, or these objets will get removed from group A!
Know what I mean?

Make tests with some dummy groups and you will get a feel for this.


Best

Klaus

SteveTX
Posts: 170
Joined: Sun Jan 17, 2010 9:00 pm

Re: Layer control within groups

Post by SteveTX » Sat Jul 16, 2011 2:37 am

Klaus,

You are correct. Is there a adjective that I can use to refer to relative layers? ex: front/back? The example syntax in the dictionary for "layer" is rather misleading, using "top" and "bottom", when naturally people are going to think this refers to the "front" and "back" regarding layer control. So if I have groups A, B, and C, all inside group Z, how would I say "set the layer of group B to the front of group Z" ?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Layer control within groups

Post by jmburnod » Sat Jul 16, 2011 9:19 am

Hi SteveTX ,
The example syntax in the dictionary for "layer" is rather misleading
yes, you're right

Code: Select all

 So if I have groups A, B, and C, all inside group Z, how would I say "set the layer of group B to the front of group Z" ?
You can see the layer of each objects in the "browser application".

Like Klaus said, it is a dangerous way and i watch setting the layer of a group is not possible with the object inspector.

It is a good question for Bernd but i think he is again on the beach 8)

Best regards

Jean-Marc
https://alternatic.ch

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Layer control within groups

Post by Klaus » Sat Jul 16, 2011 10:28 am

Hi Steve,

TOP and BOTTOM in regard to layers do always mean the (absolute!) HIGHEST (= number of objects on a card) and LOWEST (= 1) layer.
This cannot be used "relatively" like in your example, so yes, the docs are a bit misleading here.


Best

Klaus

Post Reply