Debian Codegraph @

src/gldit/cairo-dock-dock-factory.h

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 /*
2 * This file is a part of the Cairo-Dock project
3 *
4 * Copyright : (C) see the 'copyright' file.
5 * E-mail : see the 'copyright' file.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21 #ifndef __CAIRO_DOCK_FACTORY__
22 #define __CAIRO_DOCK_FACTORY__
23
24 #include <glib.h>
25
26 #include "cairo-dock-struct.h"
27 #include "cairo-dock-style-facility.h" // GldiColor
28 #include "cairo-dock-image-buffer.h"
29 #include "cairo-dock-icon-factory.h"
30 #include "cairo-dock-container.h"
31 G_BEGIN_DECLS
32
33 /**
34 *@file cairo-dock-dock-factory.h This class defines the Docks, and gives the way to create, destroy, and fill them.
35 *
36 * A dock is a container that holds a set of icons and a renderer (also known as view).
37 *
38 * It has the ability to be placed anywhere on the screen edges and to resize itself automatically to fit the screen's size.
39 *
40 * It supports internal dragging of its icons with the mouse, and dragging of itself with alt+mouse.
41 *
42 * A dock can be either a main-dock (not linked to any icon) or a sub-dock (linked to an icon of another dock), and there can be as many docks of each sort as you want.
43 */
44
45 typedef enum {
46 CAIRO_DOCK_BOTTOM = 0,
47 CAIRO_DOCK_TOP,
48 CAIRO_DOCK_RIGHT,
49 CAIRO_DOCK_LEFT,
50 CAIRO_DOCK_INSIDE_SCREEN,
51 CAIRO_DOCK_NB_POSITIONS
52 } CairoDockPositionType;
53
54 #define CAIRO_DOCK_ANIMATE_ICON TRUE
55 #define CAIRO_DOCK_INSERT_SEPARATOR TRUE
56
57 typedef void (*CairoDockComputeSizeFunc) (CairoDock *pDock);
58 typedef Icon* (*CairoDockCalculateIconsFunc) (CairoDock *pDock);
59 typedef void (*CairoDockRenderFunc) (cairo_t *pCairoContext, CairoDock *pDock);
60 typedef void (*CairoDockRenderOptimizedFunc) (cairo_t *pCairoContext, CairoDock *pDock, GdkRectangle *pArea);
61 typedef void (*CairoDockSetSubDockPositionFunc) (Icon *pPointedIcon, CairoDock *pParentDock);
62 typedef void (*CairoDockGLRenderFunc) (CairoDock *pDock);
63 typedef void (*CairoDockRenderFreeDataFunc) (CairoDock *pDock);
64 typedef void (*CairoDockSetInputShapeFunc) (CairoDock *pDock);
65 typedef void (*CairoDockSetIconSizeFunc) (Icon *pIcon, CairoDock *pDock);
66
67 /// Dock's renderer, also known as 'view'.
68 struct _CairoDockRenderer {
69 /// function that computes the sizes of a dock.
70 CairoDockComputeSizeFunc compute_size;
71 /// function that computes all the icons' parameters.
72 CairoDockCalculateIconsFunc calculate_icons;
73 /// rendering function (cairo)
74 CairoDockRenderFunc render;
75 /// optimized rendering function (cairo) that only redraw a part of the dock.
76 CairoDockRenderOptimizedFunc render_optimized;
77 /// rendering function (OpenGL, optionnal).
78 CairoDockGLRenderFunc render_opengl;
79 /// function that computes the position of the dock when it's a sub-dock.
80 CairoDockSetSubDockPositionFunc set_subdock_position;
81 /// function called when the renderer is unset from the dock.
82 CairoDockRenderFreeDataFunc free_data;
83 /// function called when the input zones are defined.
84 CairoDockSetInputShapeFunc update_input_shape;
85 /// function called to define the size of an icon, or NULL to let the container handles that.
86 CairoDockSetIconSizeFunc set_icon_size;
87 /// TRUE if the view uses the OpenGL stencil buffer.
88 gboolean bUseStencil;
89 /// TRUE is the view uses reflects.
90 gboolean bUseReflect;
91 /// name displayed in the GUI (translated).
92 const gchar *cDisplayedName;
93 /// path to a readme file that gives a short description of the view.
94 gchar *cReadmeFilePath;
95 /// path to a preview image.
96 gchar *cPreviewFilePath;
97 };
98
99 typedef enum {
100 CAIRO_DOCK_MOUSE_INSIDE,
101 CAIRO_DOCK_MOUSE_ON_THE_EDGE,
102 CAIRO_DOCK_MOUSE_OUTSIDE
103 } CairoDockMousePositionType;
104
105 typedef enum {
106 CAIRO_DOCK_INPUT_ACTIVE,
107 CAIRO_DOCK_INPUT_AT_REST,
108 CAIRO_DOCK_INPUT_HIDDEN
109 } CairoDockInputState;
110
111 typedef enum {
112 CAIRO_DOCK_VISI_KEEP_ABOVE=0,
113 CAIRO_DOCK_VISI_RESERVE,
114 CAIRO_DOCK_VISI_KEEP_BELOW,
115 CAIRO_DOCK_VISI_AUTO_HIDE_ON_OVERLAP,
116 CAIRO_DOCK_VISI_AUTO_HIDE_ON_OVERLAP_ANY,
117 CAIRO_DOCK_VISI_AUTO_HIDE,
118 CAIRO_DOCK_VISI_SHORTKEY,
119 CAIRO_DOCK_NB_VISI
120 } CairoDockVisibility;
121
122 typedef struct _CairoDockAttr CairoDockAttr;
123 struct _CairoDockAttr {
124 // parent attributes
125 GldiContainerAttr cattr;
126 const gchar *cDockName;
127 const gchar *cRendererName;
128 GList *pIconList;
129 gboolean bSubDock;
130 CairoDock *pParentDock;
131 };
132
133 /// Definition of a Dock, which derives from a Container.
134 struct _CairoDock {
135 /// container.
136 GldiContainer container;
137 /// the list of icons.
138 GList* icons;
139 /// Set to TRUE for the main dock (the first to be created, and the one containing the taskbar).
140 gboolean bIsMainDock;
141 /// number of icons pointing on the dock (0 means it is a root dock, >0 a sub-dock).
142 gint iRefCount;
143 /// unique name of the dock
144 gchar *cDockName;
145
146 //\_______________ Config parameters.
147 // position
148 gint iGapX; // ecart de la fenetre par rapport au bord de l'ecran.
149 gint iGapY; // decalage de la fenetre par rapport au point d'alignement sur le bord de l'ecran.
150 gdouble fAlign; // alignment, between 0 and 1, on the screen's edge.
151 /// visibility.
152 CairoDockVisibility iVisibility;
153 /// number of the screen the dock is placed on (-1 <=> all screen, >0 <=> num screen).
154 gint iNumScreen;
155 // icons
156 /// icon size, as specified in the config of the dock
157 gint iIconSize;
158 /// whether the dock should use the global icons size parameters.
159 gboolean bGlobalIconSize;
160 // background
161 /// whether the dock should use the global background parameters.
162 gboolean bGlobalBg;
163 /// path to an image, or NULL
164 gchar *cBgImagePath;
165 /// whether to repeat the image as a pattern, or to stretch it to fill the dock.
166 gboolean bBgImageRepeat;
167 /// first color of the gradation
168 GldiColor fBgColorBright;
169 /// second color of the gradation
170 GldiColor fBgColorDark;
171 /// Background image buffer of the dock.
172 CairoDockImageBuffer backgroundBuffer;
173 gboolean bExtendedMode;
174
175 //\_______________ current state of the dock.
176 gboolean bAutoHide; // auto-hide activated.
177 gint iMagnitudeIndex; // indice de calcul du coef multiplicateur de l'amplitude de la sinusoide (entre 0 et CAIRO_DOCK_NB_MAX_ITERATIONS).
178 /// (un)folding factor, between 0(unfolded) to 1(folded). It's up to the renderer on how to make use of it.
179 gdouble fFoldingFactor;
180 gint iAvoidingMouseIconType;// type d'icone devant eviter la souris, -1 si aucun.
181 gdouble fAvoidingMouseMargin;// marge d'evitement de la souris, en fraction de la largeur d'an icon (entre 0 et 0.5)
182 gdouble fDecorationsOffsetX;// decalage des decorations pour les faire suivre la souris.
183 // counter for the fade out effect.
184 gint iFadeCounter;
185 // direction of the fade out effect.
186 gboolean bFadeInOut;
187 /// counter for auto-hide.
188 gdouble fHideOffset;
189 /// counter for the post-hiding animation for icons always visible.
190 gdouble fPostHideOffset;
191
192 /// Whether the dock is in a popped up state or not.
193 gboolean bIsBelow;
194 /// TRUE if the dock has a modal window (menu, dialog, etc), that will block it.
195 gint bHasModalWindow;
196 /// whether the user is dragging something over the dock.
197 gboolean bIsDragging;
198 /// Backup of the auto-hide state before quick-hide.
199 gboolean bTemporaryHidden;
200 /// whether mouse can't enter into the dock.
201 gboolean bEntranceDisabled;
202 /// whether the dock is shrinking down.
203 gboolean bIsShrinkingDown;
204 /// whether the dock is growing up.
205 gboolean bIsGrowingUp;
206 /// whether the dock is hiding.
207 gboolean bIsHiding;
208 /// whether the dock is showing.
209 gboolean bIsShowing;
210 /// whether an icon is being dragged away from the dock
211 gboolean bIconIsFlyingAway;
212 /// whether icons in the dock can be dragged with the mouse (inside and outside of the dock).
213 gboolean bPreventDraggingIcons;
214 gboolean bWMIconsNeedUpdate;
215
216 /// maximum height of the icons.
217 gdouble iMaxIconHeight;
218 /// width of the dock, only taking into account an alignment of the icons.
219 gdouble fFlatDockWidth;
220 gint iOffsetForExtend;
221 gint iMaxLabelWidth;
222 gint iMinLeftMargin;
223 gint iMinRightMargin;
224 gint iMaxLeftMargin;
225 gint iMaxRightMargin;
226 gint iLeftMargin;
227 gint iRightMargin;
228
229 //\_______________ Source ID of events running on the dock.
230 /// Source ID for window resizing.
231 guint iSidMoveResize;
232 /// Source ID for window popping down to the bottom layer.
233 guint iSidUnhideDelayed;
234 /// Source ID of the timer that delays the "leave" event.
235 guint iSidLeaveDemand;
236 /// Source ID for pending update of WM icons geometry.
237 guint iSidUpdateWMIcons;
238 /// Source ID for hiding back the dock.
239 guint iSidHideBack;
240 /// Source ID for loading the background.
241 guint iSidLoadBg;
242 /// Source ID to destroy an empty main dock.
243 guint iSidDestroyEmptyDock;
244 /// Source ID for shrinking down the dock after a mouse event.
245 guint iSidTestMouseOutside;
246 /// Source ID for updating the dock's size and icons layout.
247 guint iSidUpdateDockSize;
248
249 //\_______________ Renderer and fields set by it.
250 // nom de la vue, utile pour (re)charger les fonctions de rendu posterieurement a la creation du dock.
251 gchar *cRendererName;
252 /// current renderer, never NULL.
253 CairoDockRenderer *pRenderer;
254 /// data that can be used by the renderer.
255 gpointer pRendererData;
256 /// Set to TRUE by the renderer if one can drop between 2 icons.
257 gboolean bCanDrop;
258 /// set by the view to say if the mouse is currently on icons, on the egde, or outside of icons.
259 CairoDockMousePositionType iMousePositionType;
260 /// width of the dock at rest.
261 gint iMinDockWidth;
262 /// height of the dock at rest.
263 gint iMinDockHeight;
264 /// maximum width of the dock.
265 gint iMaxDockWidth;
266 /// maximum height of the dock.
267 gint iMaxDockHeight;
268 /// width of background decorations, set by the renderer.
269 gint iDecorationsWidth;
270 /// height of background decorations, set by the renderer.
271 gint iDecorationsHeight;
272 /// maximal magnitude of the zoom, between 0 and 1.
273 gdouble fMagnitudeMax;
274 /// width of the active zone of the dock.
275 gint iActiveWidth;
276 /// height of the active zone of the dock.
277 gint iActiveHeight;
278
279 //\_______________ input shape.
280 /// state of the input shape (active, at rest, hidden).
281 CairoDockInputState iInputState;
282 /// input shape of the window when the dock is at rest.
283 cairo_region_t* pShapeBitmap;
284 /// input shape of the window when the dock is hidden.
285 cairo_region_t* pHiddenShapeBitmap;
286 /// input shape of the window when the dock is active (NULL to cover all dock).
287 cairo_region_t* pActiveShapeBitmap;
288
289 //\_______________ OpenGL.
290 GLuint iRedirectedTexture;
291 GLuint iFboId;
292
293 gpointer reserved[4];
294 };
295
296
297 /** Say if an object is a Dock.
298 *@param obj the object.
299 *@return TRUE if the object is a Dock.
300 */
301 #define GLDI_OBJECT_IS_DOCK(obj) gldi_object_is_manager_child (GLDI_OBJECT(obj), &myDockObjectMgr)
302 #define CAIRO_DOCK_IS_DOCK GLDI_OBJECT_IS_DOCK
303
304 /** Cast a Container into a Dock.
305 * @param p the container to consider as a dock.
306 * @return the dock.
307 */
308 #define CAIRO_DOCK(p) ((CairoDock *)p)
309
310
311 void cairo_dock_freeze_docks (gboolean bFreeze);
312
313 void gldi_dock_init_internals (CairoDock *pDock);
314
315
316 /** Create a new root dock.
317 *@param cDockName the name that identifies the dock
318 *@return the new dock.
319 */
320 CairoDock *gldi_dock_new (const gchar *cDockName);
321
322 /** Create a new dock of type "sub-dock", and load a given list of icons inside. The list then belongs to the dock, so it must not be freeed after that. The buffers of each icon are loaded, so they just need to have an image filename and a name.
323 * @param cDockName the name that identifies the dock.
324 * @param cRendererName name of a renderer. If NULL, the default renderer will be applied.
325 * @param pParentDock the parent dock.
326 * @param pIconList a list of icons that will be loaded and inserted into the new dock (optional).
327 * @return the new dock.
328 */
329 CairoDock *gldi_subdock_new (const gchar *cDockName, const gchar *cRendererName, CairoDock *pParentDock, GList *pIconList);
330
331
332 /** Remove all icons from a dock (and its sub-docks). If the receiving dock is NULL, the icons are destroyed and removed from the current theme itself.
333 *@param pDock a dock.
334 *@param pReceivingDock the dock that will receive the icons, or NULL to destroy and remove the icons.
335 */
336 void cairo_dock_remove_icons_from_dock (CairoDock *pDock, CairoDock *pReceivingDock);
337
338 void cairo_dock_reload_buffers_in_dock (CairoDock *pDock, gboolean bRecursive, gboolean bUpdateIconSize);
339
340 void cairo_dock_set_icon_size_in_dock (CairoDock *pDock, Icon *icon);
341
342 void cairo_dock_create_redirect_texture_for_dock (CairoDock *pDock);
343
344 G_END_DECLS
345 #endif