2 Copyright © 1995-2007, 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 *****************************************************************************/
58 struct Layer
* _l
, * lparent
;
62 if (l
->visible
== visible
)
65 LockLayers(l
->LayerInfo
);
72 * Make the layer visible
73 * Back up all layers behind this layer.
79 if (IS_VISIBLE(_l
) && DO_OVERLAP(&l
->visibleshape
->bounds
, &_l
->shape
->bounds
))
80 _BackupPartsOfLayer(_l
, l
->visibleshape
, 0, FALSE
, LayersBase
);
82 ClearRegionRegion(l
->visibleshape
, _l
->VisibleRegion
);
86 if (IS_VISIBLE(_l
) || (NULL
== lparent
->parent
))
89 lparent
= lparent
->parent
;
95 * For the layer to become visible I must recalculate its
96 * visible area. Search the first visible layer in front of
97 * it and used that one's VisbleRegion minus its visibleshape.
99 ClearRegion(l
->VisibleRegion
);
106 * It's like the top layer since all others are invisible
108 SetRegion(l
->LayerInfo
->check_lp
->shape
, &r
);
114 SetRegion(_l
->VisibleRegion
, &r
);
115 ClearRegionRegion(_l
->visibleshape
, &r
);
124 * Let me show the layer in its full beauty...
126 _ShowPartsOfLayer(l
, &r
, LayersBase
);
128 if (IS_SIMPLEREFRESH(l
))
131 * Add the whole visible area of the layer to the
132 * damage list since for those kind of layers
133 * nothing was backed up.
135 SetRegion(l
->shape
, l
->DamageList
);
136 AndRegionRegion(l
->VisibleRegion
, l
->DamageList
);
138 * Since the Damagelist is relative to the layer I have to make
139 * some adjustments to the coordinates here.
141 _TranslateRect(&l
->DamageList
->bounds
,
144 l
->Flags
|= LAYERREFRESH
;
150 * Make the layer invisible
152 struct Region clearr
;
155 l
->Flags
&= ~LAYERREFRESH
;
156 ClearRegion(l
->DamageList
);
158 SetRegion(l
->VisibleRegion
, &r
);
160 SetRegion(l
->visibleshape
, &clearr
);
161 _BackupPartsOfLayer(l
, &clearr
, 0, FALSE
, LayersBase
);
164 * Walk through all the layers behind this layer and
165 * make them (more) visible...
171 if (IS_VISIBLE(_l
) && DO_OVERLAP(&l
->visibleshape
->bounds
, &_l
->visibleshape
->bounds
))
173 ClearRegion(_l
->VisibleRegion
);
174 _ShowPartsOfLayer(_l
, &r
, LayersBase
);
177 SetRegion(&r
, _l
->VisibleRegion
);
179 if (IS_VISIBLE(_l
) || IS_ROOTLAYER(_l
))
180 AndRegionRegion(_l
->VisibleRegion
, &clearr
);
184 if (IS_VISIBLE(_l
) || (NULL
== lparent
->parent
))
187 lparent
= lparent
->parent
;
191 * Take the shape of the current layer out of
192 * the visible region that will be applied to the
193 * layer behind this one.
196 ClearRegionRegion(_l
->visibleshape
, &r
);
201 if (!IS_EMPTYREGION(&clearr
))
204 (IS_SIMPLEREFRESH(lparent
) || IS_ROOTLAYER(lparent
)))
205 _BackFillRegion(lparent
, &clearr
, FALSE
, LayersBase
);
209 ClearRegion(&clearr
);
213 UnlockLayers(l
->LayerInfo
);
218 } /* ChangeLayerVisibility */