wip layout correction.
[AROS.git] / rom / hyperlayers / changelayervisibility.c
blobec6e7112923d1a72fe4e350bb5c5f947c9f80620
1 /*
2 Copyright © 1995-2011, 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 <aros/libcall.h>
12 #include <proto/graphics.h>
14 #include "layers_intern.h"
15 #include "basicfuncs.h"
17 /*****************************************************************************
19 NAME */
20 #include <proto/layers.h>
21 AROS_LH2(LONG, ChangeLayerVisibility,
23 /* SYNOPSIS */
24 AROS_LHA(struct Layer *, l , A0),
25 AROS_LHA(int , visible, D0),
27 /* LOCATION */
28 struct LayersBase *, LayersBase, 41, Layers)
30 /* FUNCTION
31 Makes the given layer visible or invisible.
32 If it is a simple refresh layer it will loose all its
33 cliprects and therefore rendering will go into the void.
35 INPUTS
36 L - pointer to layer
37 visible - TRUE or FALSE
39 RESULT
40 TRUE - layer was changed to new state
41 FALSE - layer could not be changed to new state
43 NOTES
44 This is an AROS private function, providing support
45 for showing/hiding windows in intuition.
47 EXAMPLE
49 BUGS
51 SEE ALSO
53 INTERNALS
55 HISTORY
57 *****************************************************************************/
59 AROS_LIBFUNC_INIT
61 struct Layer * _l, * lparent;
62 struct Region r;
63 InitRegion(&r);
65 if (l->visible == visible)
66 return TRUE;
68 LockLayers(l->LayerInfo);
70 l->visible = visible;
72 if (TRUE == visible)
75 * Make the layer visible
76 * Back up all layers behind this layer.
78 lparent = l->parent;
79 _l = l->back;
80 while (1)
82 if (IS_VISIBLE(_l) && DO_OVERLAP(&l->visibleshape->bounds, &_l->shape->bounds))
83 _BackupPartsOfLayer(_l, l->visibleshape, 0, FALSE, LayersBase);
84 else
85 ClearRegionRegion(l->visibleshape, _l->VisibleRegion);
87 if (_l == lparent)
89 if (IS_VISIBLE(_l) || (NULL == lparent->parent))
90 break;
91 else
92 lparent = lparent->parent;
94 _l = _l->back;
98 * For the layer to become visible I must recalculate its
99 * visible area. Search the first visible layer in front of
100 * it and used that one's VisbleRegion minus its visibleshape.
102 ClearRegion(l->VisibleRegion);
103 _l = l->front;
104 while (1)
106 if (NULL == _l)
109 * It's like the top layer since all others are invisible
111 SetRegion(l->LayerInfo->check_lp->shape, &r);
112 break;
115 if (IS_VISIBLE(_l))
117 SetRegion(_l->VisibleRegion, &r);
118 ClearRegionRegion(_l->visibleshape, &r);
119 break;
122 _l = _l->front;
127 * Let me show the layer in its full beauty...
129 _ShowPartsOfLayer(l, &r, LayersBase);
131 if (IS_SIMPLEREFRESH(l))
134 * Add the whole visible area of the layer to the
135 * damage list since for those kind of layers
136 * nothing was backed up.
138 SetRegion(l->shape, l->DamageList);
139 AndRegionRegion(l->VisibleRegion, l->DamageList);
141 * Since the Damagelist is relative to the layer I have to make
142 * some adjustments to the coordinates here.
144 _TranslateRect(&l->DamageList->bounds,
145 -l->bounds.MinX,
146 -l->bounds.MinY);
147 l->Flags |= LAYERREFRESH;
150 else
153 * Make the layer invisible
155 struct Region clearr;
156 InitRegion(&clearr);
158 l->Flags &= ~LAYERREFRESH;
159 ClearRegion(l->DamageList);
161 SetRegion(l->VisibleRegion, &r);
163 SetRegion(l->visibleshape, &clearr);
164 _BackupPartsOfLayer(l, &clearr, 0, FALSE, LayersBase);
167 * Walk through all the layers behind this layer and
168 * make them (more) visible...
170 lparent = l->parent;
171 _l = l->back;
172 while (1)
174 if (IS_VISIBLE(_l) && DO_OVERLAP(&l->visibleshape->bounds, &_l->visibleshape->bounds))
176 ClearRegion(_l->VisibleRegion);
177 _ShowPartsOfLayer(_l, &r, LayersBase);
179 else
180 SetRegion(&r, _l->VisibleRegion);
182 if (IS_VISIBLE(_l) || IS_ROOTLAYER(_l))
183 AndRegionRegion(_l->VisibleRegion, &clearr);
185 if (_l == lparent)
187 if (IS_VISIBLE(_l) || (NULL == lparent->parent))
188 break;
189 else
190 lparent = lparent->parent;
194 * Take the shape of the current layer out of
195 * the visible region that will be applied to the
196 * layer behind this one.
198 if (IS_VISIBLE(_l))
199 ClearRegionRegion(_l->visibleshape, &r);
201 _l = _l->back;
204 if (!IS_EMPTYREGION(&clearr))
206 if (lparent &&
207 (IS_SIMPLEREFRESH(lparent) || IS_ROOTLAYER(lparent)))
208 _BackFillRegion(lparent, &clearr, FALSE, LayersBase);
212 ClearRegion(&clearr);
215 ClearRegion(&r);
216 UnlockLayers(l->LayerInfo);
218 return TRUE;
220 AROS_LIBFUNC_EXIT
221 } /* ChangeLayerVisibility */