relayering groups within groups?

Claudi Cornaz claudi at fiberworld.nl
Thu Feb 2 17:54:43 EST 2006


Hi

There is a trick I use to get sub-groups within a master group to the 
top when they get selected.
I have 2 invisible grafics (just  empty small rects) at the top of the 
master group.
Let's call them lowBoundry and highBoundry
Now when the user selects a sub group and I want to bring it to the 
front, I first move the
sub group inbetween the 2 invisible graphics. In this way the sub group
does not become part of the highest sub group. Next I move the the 
lowBoundry graphic
to the top. So now from top to bottom: lowBoundry - highBoundy - the 
sub group that was moved.
So all we need to do now is move the highBoundry again to the top to 
restore there right order.

There is one important little "snag" though. Say the sub group to move 
to the top is on layer 10
and consists of 2 controls. The total of layers in the master group 
(including the 2
invisible graphics) is 16. This means the lowBoundry wil be on layer 15.
The moment you change the layer of a sub group it will first be taken 
out of the stack.
In this case the sub group consists of 2 controls, so the total number 
of layers this sub group
occupies is 3. This means the lowBoundry graphic will first fall down 
to layer 12 (15 - 3). In essence
all the controls above the sub group we move, will fall down by the 
number of layers the moving group occupies.

This trick works very fast and it doesn't matter how many sub groups 
there are. Of course it only
works to bring a sub group to the top, but probably when selecting 
objects, something like this might
just be what you need.

I use it in a slightly more complex way in an application where I have 
many sub groups but the
sub groups are of different specific types. Let's say some have a 
triangular shape, others
a circular shape and the third kind are of square shape. Now when the 
user selects a triangle
it should move to the front of all triangles but always stay behind the 
circles and the squares. The same applies
of course to the circles and the squares. Each should move to the top 
of it's kind but not cross the boundry to other types.
Here I use 3 invisible graphics between the kinds. So above all 
triangles there are 3 invis grc's then come
the circles with also 3 invis grc's and next come the squares and 
finaly again 3 invis grc's (actualy for the top,
2 graphics is enough) In between you need 3 graphics of which the 
topmost never moves, but prevents
the other 2 graphics to become part of a sub group when they are 
switched around.

I hope you can use it or that some one else finds this usefull

Best wishes
Claudi

On 1-feb-06, at 21:16, Jonathan Lynch wrote:

> Hi Terry,
>
> I use this technique to adjust the layer of a subgroup that contains an
> image, which is inside a group that works as a page. A page can contain
> fields and images. All the images are inside groups in order to allow 
> them
> to be reversably cropped.
>
> So, I might have 5 to 10 objects on a page. Doing this, relayering an 
> image
> group takes maybe 1/5 of a second - something like that. The lag is
> definitely noticeable. With 100 objects to relayer, I bet you will 
> notice
> the lag time.
>
> If you manage to figure out a better way, please let me know.
>
> Good luck,
>
> Jonathan
>
>
> On 2/1/06, Terry Judd <tsj at unimelb.edu.au> wrote:
>>
>> Hi Jonathon - I arrived at a similar solution after much stuffing 
>> about
>> last night. My only concern is that I may have to do this with lots of
>> objects (100+?) every time I want to drag one about. Hopefully it's 
>> not
>> too slow.
>>
>> Thanks for the info.
>>
>> Terry...
>>
>>>
>>>
>>> I have a solution to this problem.
>>>
>>> It was a real pain to figure out. The basic problem is in the way
>>> Revolution
>>> orders items inside of a group. To keep a subgroup intact, when you
>>> relayer
>>> it inside of a group, you have to set it's layer to the bottom of the
>>> group.
>>>
>>> So, the question arises, how do you move a subgroup up and down, if
>>> the only
>>> safe method is setting it to the very bottom. The answer is this: 
>>> When
>>> you
>>> are moving a subgroup down one layer or up one layer, what you really
>>> do is
>>> determine when layer the subgroup needs to be at, then move all the
>>> other
>>> subgroups and objects in the group to the bottom, in the correct
>>> order, so
>>> that everything else stays in the order it was in, and the subgroup
>>> winds up
>>> at the layer you want it to be at.
>>>
>>> It's a giant pain, but it works.
>>>
>>> I can send you an example of a stack that does this, if you wish.
>>>
>>> Take care,
>>>
>>> Jonathan
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list