wip layout correction.
[AROS.git] / rom / hyperlayers / movelayerinfrontof.c
blob8df364e8faa5c2c844df3eb8e2242a6cf7d0fe61
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <aros/libcall.h>
10 #include <proto/layers.h>
11 #include <proto/graphics.h>
12 #include <graphics/clip.h>
13 #include <graphics/layers.h>
15 #include "basicfuncs.h"
16 #include "layers_intern.h"
18 /*****************************************************************************
20 NAME */
21 #include <proto/layers.h>
23 AROS_LH2(LONG, MoveLayerInFrontOf,
25 /* SYNOPSIS */
26 AROS_LHA(struct Layer *, layer_to_move, A0),
27 AROS_LHA(struct Layer *, other_layer, A1),
29 /* LOCATION */
30 struct LayersBase *, LayersBase, 28, Layers)
32 /* FUNCTION
33 Moves layer directly in front of another layer. Other layers
34 might become visible. You cannot move a backdrop layer in front
35 of a non-backdrop layer. You can also not move a layer in front
36 of a layer with different relationship to the root layer. Boot
37 have to be children of grandchildren or grandgrandchildren etc.
38 of the root layer. The root layer is not visible to you and
39 should never be accessed.
40 If parts of a simple layer become visible these areas are added
41 to the damage list.
43 INPUTS
44 layer_to_move - pointer to layer that is to be moved
45 other_layer - pointer to other layer that will be behind the
46 layer_to_move.
48 RESULT
49 TRUE - layer was moved
50 FALSE - layer could not be moved. (probably out of memory)
52 NOTES
54 EXAMPLE
56 BUGS
58 SEE ALSO
60 INTERNALS
62 HISTORY
63 27-11-96 digulla automatically created from
64 layers_lib.fd and clib/layers_protos.h
66 *****************************************************************************/
68 AROS_LIBFUNC_INIT
70 struct Layer *_l;
71 int toback = TRUE;
72 LONG ret;
74 if (layer_to_move->parent != other_layer->parent ||
75 layer_to_move->priority < other_layer->priority)
76 return FALSE;
78 LockLayers(layer_to_move->LayerInfo);
80 _l = layer_to_move->parent->front;
81 while (1)
84 * If I run into the other layer before I find l
85 * then I know I have to move it to the back.
86 */
87 if (_l == other_layer)
88 break;
90 if (_l == layer_to_move)
92 toback = FALSE;
93 break;
95 _l = _l->front;
96 if (NULL == _l)
98 UnlockLayers(layer_to_move->LayerInfo);
99 return FALSE;
103 _l = GetFirstFamilyMember(other_layer);
105 if (TRUE == toback)
108 * If the topmost child of the other layer is
109 * behind my layer I don't have to do anything.
111 if (layer_to_move->back == _l)
113 UnlockLayers(layer_to_move->LayerInfo);
114 return TRUE;
116 ret = _MoveLayerBehind(layer_to_move, _l, LayersBase);
118 else
120 ret = _MoveLayerToFront(layer_to_move, _l, LayersBase);
123 UnlockLayers(layer_to_move->LayerInfo);
124 return ret;
126 AROS_LIBFUNC_EXIT
127 } /* MoveLayerInFrontOf */