]> git.decadent.org.uk Git - ion3.git/blob - ioncore/resize.h
c56b96406c318f5e4a771a5ed32449a23d25041f
[ion3.git] / ioncore / resize.h
1 /*
2  * ion/ioncore/resize.h
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
5  *
6  * Ion is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  */
11
12 #ifndef ION_IONCORE_RESIZE_H
13 #define ION_IONCORE_RESIZE_H
14
15 #include "common.h"
16 #include "frame.h"
17 #include "infowin.h"
18 #include "rectangle.h"
19 #include "sizehint.h"
20
21
22 /* To make it easier for region_managed_rqgeom handlers, the geom
23  * parameter contain a complete requested geometry for the region that
24  * wants its geometry changed. The REGION_WEAK_* flags are used to
25  * indicate that the respective geometry value has not been changed or
26  * that the requestor doesn't really care what the result is. In any case,
27  * managers are free to give the managed object whatever geometry it wishes.
28  */
29 #define REGION_RQGEOM_WEAK_X    0x0001
30 #define REGION_RQGEOM_WEAK_Y    0x0002
31 #define REGION_RQGEOM_WEAK_W    0x0004
32 #define REGION_RQGEOM_WEAK_H    0x0008
33 #define REGION_RQGEOM_WEAK_ALL  0x000f
34 #define REGION_RQGEOM_TRYONLY   0x0010
35 #define REGION_RQGEOM_ABSOLUTE  0x0020
36 #define REGION_RQGEOM_GRAVITY   0x0040
37
38 #define REGION_RQGEOM_NORMAL    0
39 #define REGION_RQGEOM_VERT_ONLY (REGION_RQGEOM_WEAK_X|REGION_RQGEOM_WEAK_W)
40 #define REGION_RQGEOM_HORIZ_ONLY (REGION_RQGEOM_WEAK_Y|REGION_RQGEOM_WEAK_H)
41 #define REGION_RQGEOM_H_ONLY    (REGION_RQGEOM_VERT_ONLY|REGION_RQGEOM_WEAK_Y)
42 #define REGION_RQGEOM_W_ONLY    (REGION_RQGEOM_HORIZ_ONLY|REGION_RQGEOM_WEAK_X)
43
44 #define REGION_ORIENTATION_NONE 0
45 #define REGION_ORIENTATION_HORIZONTAL 1
46 #define REGION_ORIENTATION_VERTICAL 2
47
48
49 #define RQGEOMPARAMS_INIT {{0, 0, 0, 0}, 0, 0}
50
51
52 DECLSTRUCT(WRQGeomParams){
53     WRectangle geom;
54     int flags;
55     int gravity;
56 };
57
58
59 typedef void WDrawRubberbandFn(WRootWin *rw, const WRectangle *geom);
60
61
62 DECLCLASS(WMoveresMode){
63     Obj obj;
64     WSizeHints hints;
65     int dx1, dx2, dy1, dy2;
66     WRectangle origgeom;
67     WRectangle geom;
68     WRegion *reg;
69     WDrawRubberbandFn *rubfn;
70     int parent_rx, parent_ry;
71     enum {MOVERES_SIZE, MOVERES_POS} mode;
72     bool resize_cumulative;
73     bool snap_enabled;
74     WRectangle snapgeom;
75     int rqflags;
76     WInfoWin *infowin;
77 };
78
79
80 extern WMoveresMode *region_begin_resize(WRegion *reg, 
81                                          WDrawRubberbandFn *rubfn,
82                                          bool cumulative);
83
84 extern WMoveresMode *region_begin_move(WRegion *reg,
85                                        WDrawRubberbandFn *rubfn,
86                                        bool cumulative);
87
88 /* dx1/dx2/dy1/dy2: left/right/top/bottom difference to previous values. 
89  * left/top negative, bottom/right positive increases size.
90  */
91 extern void moveresmode_delta_resize(WMoveresMode *mode, 
92                                      int dx1, int dx2, int dy1, int dy2,
93                                      WRectangle *rret);
94 extern void moveresmode_delta_move(WMoveresMode *mode, 
95                                    int dx, int dy, WRectangle *rret);
96 extern void moveresmode_rqgeom(WMoveresMode *mode, WRQGeomParams *rq, 
97                                WRectangle *rret);
98 extern bool moveresmode_do_end(WMoveresMode *mode, bool apply);
99 extern WRegion *moveresmode_target(WMoveresMode *mode);
100
101 extern WMoveresMode *moveres_mode(WRegion *reg);
102
103
104
105 /* Note: even if REGION_RQGEOM_(X|Y|W|H) are not all specified, the
106  * geom parameter should contain a proper geometry!
107  */
108 DYNFUN void region_managed_rqgeom(WRegion *reg, WRegion *sub, 
109                                   const WRQGeomParams *rqgp,
110                                   WRectangle *geomret);
111 DYNFUN void region_managed_rqgeom_absolute(WRegion *reg, WRegion *sub, 
112                                            const WRQGeomParams *rqgp,
113                                            WRectangle *geomret);
114
115 extern void region_rqgeom(WRegion *reg, const WRQGeomParams *rqgp,
116                           WRectangle *geomret);
117
118 /* Implementation for regions that do not allow subregions to resize
119  * themselves; default is to give the size the region wants.
120  */
121 extern void region_managed_rqgeom_unallow(WRegion *reg, WRegion *sub,
122                                           const WRQGeomParams *rq,
123                                           WRectangle *geomret);
124 /* default */
125 extern void region_managed_rqgeom_allow(WRegion *reg, WRegion *sub,
126                                         const WRQGeomParams *rq,
127                                         WRectangle *geomret);
128
129 extern void region_managed_rqgeom_absolute_default(WRegion *reg, WRegion *sub,
130                                                    const WRQGeomParams *rq,
131                                                    WRectangle *geomret);
132
133
134 DYNFUN void region_size_hints(WRegion *reg, WSizeHints *hints_ret);
135 DYNFUN int region_orientation(WRegion *reg);
136
137 extern void region_size_hints_correct(WRegion *reg, 
138                                       int *wp, int *hp, bool min);
139
140 extern uint region_min_h(WRegion *reg);
141 extern uint region_min_w(WRegion *reg);
142
143 extern void frame_maximize_vert(WFrame *frame);
144 extern void frame_maximize_horiz(WFrame *frame);
145
146 extern void region_convert_root_geom(WRegion *reg, WRectangle *geom);
147
148 extern void region_absolute_geom_to_parent(WRegion *reg, 
149                                            const WRectangle *rgeom,
150                                            WRectangle *pgeom);
151
152 extern void rqgeomparams_from_table(WRQGeomParams *rq, 
153                                     const WRectangle *origg, ExtlTab g);
154
155 #endif /* ION_IONCORE_RESIZE_H */