New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / rom / hyperlayers / changelayervisibility.c
blob3b265ea8633f7eec49c63b51107db5648a71b243
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
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 /*****************************************************************************
18 NAME */
19 #include <proto/layers.h>
20 AROS_LH2(LONG, ChangeLayerVisibility,
22 /* SYNOPSIS */
23 AROS_LHA(struct Layer *, l , A0),
24 AROS_LHA(int , visible, D0),
26 /* LOCATION */
27 struct LayersBase *, LayersBase, 39, Layers)
29 /* FUNCTION
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.
34 INPUTS
35 L - pointer to layer
36 visible - TRUE or FALSE
38 RESULT
39 TRUE - layer was changed to new state
40 FALSE - layer could not be changed to new state
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 INTERNALS
52 HISTORY
54 *****************************************************************************/
56 AROS_LIBFUNC_INIT
57 AROS_LIBBASE_EXT_DECL(struct LayersBase *,LayersBase)
59 struct Layer * _l, * lparent;
60 struct Region r;
61 InitRegion(&r);
63 if (l->visible == visible)
64 return TRUE;
66 LockLayers(l->LayerInfo);
68 l->visible = visible;
70 if (TRUE == visible)
73 * Make the layer visible
74 * Back up all layers behind this layer.
76 lparent = l->parent;
77 _l = l->back;
78 while (1)
80 if (IS_VISIBLE(_l) && DO_OVERLAP(&l->visibleshape->bounds, &_l->shape->bounds))
81 _BackupPartsOfLayer(_l, l->visibleshape, 0, FALSE, LayersBase);
82 else
83 ClearRegionRegion(l->visibleshape, _l->VisibleRegion);
85 if (_l == lparent)
87 if (IS_VISIBLE(_l) || (NULL == lparent->parent))
88 break;
89 else
90 lparent = lparent->parent;
92 _l = _l->back;
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);
101 _l = l->front;
102 while (1)
104 if (NULL == _l)
107 * It's like the top layer since all others are invisible
109 SetRegion(l->LayerInfo->check_lp->shape, &r);
110 break;
113 if (IS_VISIBLE(_l))
115 SetRegion(_l->VisibleRegion, &r);
116 ClearRegionRegion(_l->visibleshape, &r);
117 break;
120 _l = _l->front;
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,
143 -l->bounds.MinX,
144 -l->bounds.MinY);
145 l->Flags |= LAYERREFRESH;
148 else
151 * Make the layer invisible
153 struct Region clearr;
154 InitRegion(&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...
168 lparent = l->parent;
169 _l = l->back;
170 while (1)
172 if (IS_VISIBLE(_l) && DO_OVERLAP(&l->visibleshape->bounds, &_l->visibleshape->bounds))
174 ClearRegion(_l->VisibleRegion);
175 _ShowPartsOfLayer(_l, &r, LayersBase);
177 else
178 SetRegion(&r, _l->VisibleRegion);
180 if (IS_VISIBLE(_l) || IS_ROOTLAYER(_l))
181 AndRegionRegion(_l->VisibleRegion, &clearr);
183 if (_l == lparent)
185 if (IS_VISIBLE(_l) || (NULL == lparent->parent))
186 break;
187 else
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.
196 if (IS_VISIBLE(_l))
197 ClearRegionRegion(_l->visibleshape, &r);
199 _l = _l->back;
202 if (!IS_EMPTYREGION(&clearr))
204 if (lparent &&
205 (IS_SIMPLEREFRESH(lparent) || IS_ROOTLAYER(lparent)))
206 _BackFillRegion(lparent, &clearr, FALSE, LayersBase);
210 ClearRegion(&clearr);
213 ClearRegion(&r);
214 UnlockLayers(l->LayerInfo);
216 return TRUE;
218 AROS_LIBFUNC_EXIT
219 } /* ChangeLayerVisibility */