some fixes to accented characters
[tangerine.git] / rom / hyperlayers / changelayervisibility.c
blobf6161c1c9e34ddfd937b0b1e160ae86b0a4a2dc9
1 /*
2 Copyright © 1995-2007, 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
58 struct Layer * _l, * lparent;
59 struct Region r;
60 InitRegion(&r);
62 if (l->visible == visible)
63 return TRUE;
65 LockLayers(l->LayerInfo);
67 l->visible = visible;
69 if (TRUE == visible)
72 * Make the layer visible
73 * Back up all layers behind this layer.
75 lparent = l->parent;
76 _l = l->back;
77 while (1)
79 if (IS_VISIBLE(_l) && DO_OVERLAP(&l->visibleshape->bounds, &_l->shape->bounds))
80 _BackupPartsOfLayer(_l, l->visibleshape, 0, FALSE, LayersBase);
81 else
82 ClearRegionRegion(l->visibleshape, _l->VisibleRegion);
84 if (_l == lparent)
86 if (IS_VISIBLE(_l) || (NULL == lparent->parent))
87 break;
88 else
89 lparent = lparent->parent;
91 _l = _l->back;
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);
100 _l = l->front;
101 while (1)
103 if (NULL == _l)
106 * It's like the top layer since all others are invisible
108 SetRegion(l->LayerInfo->check_lp->shape, &r);
109 break;
112 if (IS_VISIBLE(_l))
114 SetRegion(_l->VisibleRegion, &r);
115 ClearRegionRegion(_l->visibleshape, &r);
116 break;
119 _l = _l->front;
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,
142 -l->bounds.MinX,
143 -l->bounds.MinY);
144 l->Flags |= LAYERREFRESH;
147 else
150 * Make the layer invisible
152 struct Region clearr;
153 InitRegion(&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...
167 lparent = l->parent;
168 _l = l->back;
169 while (1)
171 if (IS_VISIBLE(_l) && DO_OVERLAP(&l->visibleshape->bounds, &_l->visibleshape->bounds))
173 ClearRegion(_l->VisibleRegion);
174 _ShowPartsOfLayer(_l, &r, LayersBase);
176 else
177 SetRegion(&r, _l->VisibleRegion);
179 if (IS_VISIBLE(_l) || IS_ROOTLAYER(_l))
180 AndRegionRegion(_l->VisibleRegion, &clearr);
182 if (_l == lparent)
184 if (IS_VISIBLE(_l) || (NULL == lparent->parent))
185 break;
186 else
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.
195 if (IS_VISIBLE(_l))
196 ClearRegionRegion(_l->visibleshape, &r);
198 _l = _l->back;
201 if (!IS_EMPTYREGION(&clearr))
203 if (lparent &&
204 (IS_SIMPLEREFRESH(lparent) || IS_ROOTLAYER(lparent)))
205 _BackFillRegion(lparent, &clearr, FALSE, LayersBase);
209 ClearRegion(&clearr);
212 ClearRegion(&r);
213 UnlockLayers(l->LayerInfo);
215 return TRUE;
217 AROS_LIBFUNC_EXIT
218 } /* ChangeLayerVisibility */