2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
9 #include <exec/types.h>
10 #include <graphics/clip.h>
11 #include <proto/graphics.h>
12 #include <proto/layers.h>
13 #include "basicfuncs.h"
14 #include "layers_intern.h"
16 int _MoveLayerBehind(struct Layer
*l
,
18 LIBBASETYPEPTR LayersBase
)
20 struct Layer
* lbackold
, *_l
, *first
;
21 struct Region
* hide
= NewRegion(), show
;
24 first
= GetFirstFamilyMember(l
);
29 * Take the family out of its old place.
31 if (NULL
!= first
->front
)
32 first
->front
->back
= lbackold
;
34 l
->LayerInfo
->top_layer
= lbackold
;
36 lbackold
->front
= first
->front
;
40 * Collect the additional parts that have to be hidden
41 * on the layers that are to be moved. I need only
42 * collect those parts of layers that have the same
43 * parent as the layer l. Stop when I found lfront.
48 * Must not add my own shape to the hide region...
54 * Must add EVERY shape since it will be subtracted from
57 if (l
->parent
== _l
->parent
&& IS_VISIBLE(_l
))
58 OrRegionRegion(_l
->visibleshape
, hide
);
66 SetRegion(first
->VisibleRegion
, &show
);
69 * First back up the family ... this is like moving them behind the
76 if (IS_VISIBLE(_l
) && DO_OVERLAP(&_l
->visibleshape
->bounds
, &hide
->bounds
))
77 _BackupPartsOfLayer(_l
, hide
, 0, FALSE
, LayersBase
);
79 ClearRegionRegion(hide
, _l
->VisibleRegion
);
89 * Show the layers that appear now.
90 * Start with the layer that is behind the layer l.
96 if (IS_VISIBLE(_l
) && DO_OVERLAP(&_l
->visibleshape
->bounds
, &show
.bounds
))
98 ClearRegion(_l
->VisibleRegion
);
99 _ShowPartsOfLayer(_l
, &show
, LayersBase
);
102 SetRegion(&show
, _l
->VisibleRegion
);
108 ClearRegionRegion(_l
->visibleshape
, &show
);
116 * Link the family into its new place.
119 lfront
->back
->front
= l
;
120 l
->back
= lfront
->back
;
122 first
->front
= lfront
;
123 lfront
->back
= first
;
128 int _MoveLayerToFront(struct Layer
* l
,
129 struct Layer
* lbehind
,
130 LIBBASETYPEPTR LayersBase
)
132 struct Layer
* lfront
, * first
, * _l
;
133 struct Region r
, * backupr
= NULL
;
134 int backupr_allocated
= FALSE
;
138 first
= GetFirstFamilyMember(l
);
140 lfront
= lbehind
->front
;
143 * Unlink the family of layers from its old place.
145 first
->front
->back
= l
->back
;
146 l
->back
->front
= first
->front
;
149 * I need exactly that layers visible region later on.
152 SetRegion(lbehind
->VisibleRegion
,&r
);
155 * if the layer l is visible then I will have to backup
156 * its visible region in all layers behind it. Otherwise
157 * I will have to collect the visible shape of its whole
161 backupr
= l
->visibleshape
;
171 backupr
= NewRegion();
172 backupr_allocated
= TRUE
;
175 OrRegionRegion(_l
->visibleshape
, backupr
);
190 * Now I have to move the layer family in front of layer lbehind.
191 * Nothing changes for the layers in front of layer lbehind, but on
192 * the layers behind (including first->front) I must back up some of
193 * their parts that the new family might be hiding no.
194 * Once I step on the layer that was behind the layer l
195 * I can stop because those layers are already hidden well
200 if (IS_VISIBLE(_l
) && DO_OVERLAP(&backupr
->bounds
, &_l
->visibleshape
->bounds
))
201 _BackupPartsOfLayer(_l
, backupr
, 0, FALSE
, LayersBase
);
203 ClearRegionRegion(backupr
, _l
->VisibleRegion
);
207 while (_l
!= l
->back
/* this is l->back now since the family has
208 been unlinked already!*/ );
210 if (TRUE
== backupr_allocated
)
211 DisposeRegion(backupr
);
214 * Now I must make the layer family of l visible
215 * (lfirst to and including l)
221 if (IS_VISIBLE(_l
) && DO_OVERLAP(&_l
->visibleshape
->bounds
, &r
.bounds
))
223 ClearRegion(_l
->VisibleRegion
);
224 _ShowPartsOfLayer(_l
, &r
, LayersBase
);
227 SetRegion(&r
, _l
->VisibleRegion
);
233 ClearRegionRegion(_l
->visibleshape
, &r
);
241 * Link the family into its new place.
242 * First the frontmost kid and then l.
245 lfront
->back
= first
;
247 l
->LayerInfo
->top_layer
= first
;
249 first
->front
= lfront
;