2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
8 #include <proto/exec.h>
9 #include <exec/types.h>
10 #include <exec/memory.h>
11 #include <layers_intern.h>
12 #include <aros/libcall.h>
13 #include <proto/graphics.h>
14 #include "basicfuncs.h"
16 /*****************************************************************************
19 #include <proto/layers.h>
20 AROS_LH2(LONG
, ChangeLayerVisibility
,
23 AROS_LHA(struct Layer
*, l
, A0
),
24 AROS_LHA(int , visible
, D0
),
27 struct LayersBase
*, LayersBase
, 39, Layers
)
30 Makes the given layer visible or invisible.
31 If it is a simple refresh layer it will loose all its
32 cliprects and therefore rendering will go into the void.
36 visible - TRUE or FALSE
39 TRUE - layer was changed to new state
40 FALSE - layer could not be changed to new state
54 *****************************************************************************/
57 AROS_LIBBASE_EXT_DECL(struct LayersBase
*,LayersBase
)
59 struct Layer
* _l
, * lparent
;
63 if (l
->visible
== visible
)
66 LockLayers(l
->LayerInfo
);
73 * Make the layer visible
74 * Back up all layers behind this layer.
80 if (IS_VISIBLE(_l
) && DO_OVERLAP(&l
->visibleshape
->bounds
, &_l
->shape
->bounds
))
81 _BackupPartsOfLayer(_l
, l
->visibleshape
, 0, FALSE
, LayersBase
);
83 ClearRegionRegion(l
->visibleshape
, _l
->VisibleRegion
);
87 if (IS_VISIBLE(_l
) || (NULL
== lparent
->parent
))
90 lparent
= lparent
->parent
;
96 * For the layer to become visible I must recalculate its
97 * visible area. Search the first visible layer in front of
98 * it and used that one's VisbleRegion minus its visibleshape.
100 ClearRegion(l
->VisibleRegion
);
107 * It's like the top layer since all others are invisible
109 SetRegion(l
->LayerInfo
->check_lp
->shape
, &r
);
115 SetRegion(_l
->VisibleRegion
, &r
);
116 ClearRegionRegion(_l
->visibleshape
, &r
);
125 * Let me show the layer in its full beauty...
127 _ShowPartsOfLayer(l
, &r
, LayersBase
);
129 if (IS_SIMPLEREFRESH(l
))
132 * Add the whole visible area of the layer to the
133 * damage list since for those kind of layers
134 * nothing was backed up.
136 SetRegion(l
->shape
, l
->DamageList
);
137 AndRegionRegion(l
->VisibleRegion
, l
->DamageList
);
139 * Since the Damagelist is relative to the layer I have to make
140 * some adjustments to the coordinates here.
142 _TranslateRect(&l
->DamageList
->bounds
,
145 l
->Flags
|= LAYERREFRESH
;
151 * Make the layer invisible
153 struct Region clearr
;
156 l
->Flags
&= ~LAYERREFRESH
;
157 ClearRegion(l
->DamageList
);
159 SetRegion(l
->VisibleRegion
, &r
);
161 SetRegion(l
->visibleshape
, &clearr
);
162 _BackupPartsOfLayer(l
, &clearr
, 0, FALSE
, LayersBase
);
165 * Walk through all the layers behind this layer and
166 * make them (more) visible...
172 if (IS_VISIBLE(_l
) && DO_OVERLAP(&l
->visibleshape
->bounds
, &_l
->visibleshape
->bounds
))
174 ClearRegion(_l
->VisibleRegion
);
175 _ShowPartsOfLayer(_l
, &r
, LayersBase
);
178 SetRegion(&r
, _l
->VisibleRegion
);
180 if (IS_VISIBLE(_l
) || IS_ROOTLAYER(_l
))
181 AndRegionRegion(_l
->VisibleRegion
, &clearr
);
185 if (IS_VISIBLE(_l
) || (NULL
== lparent
->parent
))
188 lparent
= lparent
->parent
;
192 * Take the shape of the current layer out of
193 * the visible region that will be applied to the
194 * layer behind this one.
197 ClearRegionRegion(_l
->visibleshape
, &r
);
202 if (!IS_EMPTYREGION(&clearr
))
205 (IS_SIMPLEREFRESH(lparent
) || IS_ROOTLAYER(lparent
)))
206 _BackFillRegion(lparent
, &clearr
, FALSE
, LayersBase
);
210 ClearRegion(&clearr
);
214 UnlockLayers(l
->LayerInfo
);
219 } /* ChangeLayerVisibility */