~ubuntu-branches/ubuntu/maverick/cairo-dock/maverick

« back to all changes in this revision

Viewing changes to src/gldit/cairo-dock-animations.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100809232612-yp4c6ig3jt1bzpdv
Tags: 2.2.0~0beta4-0ubuntu1
* New Upstream Version (LP: #614624)
* Fixed a few bugs on LP:
 - LP: #518453: Dock appears under all windows
                 (Compiz - fullscreen window)
 - LP: #521369: Separator are not removed when closing
                 grouped windows
 - LP: #521762: Some sentences are not correct
 - LP: #526466: Icons of apps with same class shouldn't
                 be stacked by default
 - LP: #535083: Dialogues looks ugly when a lot of them
                 appears at the same time
 - More details on the 'ChangeLog' file
* debian/rules:
 - Autotools has been replaced by CMake
 - Man pages are now included in the source code
* debian/copyright:
 - Updated with the new pathes and new files
* debian/control:
 - Autotools has been replaced by CMake
 - Added libcurl4-gnutls-dev as Build-deps
 - Bump Standard-Version to 3.9.1
* debian/cairo-dock-core.install:
 - Man pages are now included in the source code
 - All sonames are now installed into lib32 or lib64
* debian/cairo-dock-dev.install:
 - pkgconfig is now installed into lib32 or lib64

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#ifndef __CAIRO_DOCK_ANIMATIONS__
 
21
#define  __CAIRO_DOCK_ANIMATIONS__
 
22
 
 
23
#include <glib.h>
 
24
 
 
25
#include "cairo-dock-struct.h"
 
26
#include "cairo-dock-icons.h"
 
27
G_BEGIN_DECLS
 
28
 
 
29
/**
 
30
*@file cairo-dock-animations.h This class handles the icons and containers animations.
 
31
* Each container has a rendering loop. An iteration of this loop is separated in 2 phases : the update of each element of the container and of the container itself, and the redraw of each element and of the container itself.
 
32
* The loop has 2 possible frequencies : fast (~33Hz) and slow (~10Hz), to optimize the CPU load according to the needs of the animation.
 
33
* To be called on each iteration of the loop, you register to the CAIRO_DOCK_UPDATE_X or CAIRO_DOCK_UPDATE_X_SLOW, where X is either ICON, DOCK, DESKLET, DIALOG or FLYING_CONTAINER.
 
34
* If you need to draw things directly on the container, you register to CAIRO_DOCK_RENDER_X, where X is either ICON, DOCK, DESKLET, DIALOG or FLYING_CONTAINER.
 
35
*/
 
36
 
 
37
/// callback to render the icon with libcairo at each step of the Transition.
 
38
typedef gboolean (*CairoDockTransitionRenderFunc) (Icon *pIcon, gpointer pUserData, cairo_t *pIconContext);
 
39
/// callback to render the icon with OpenGL at each step of the Transition.
 
40
typedef gboolean (*CairoDockTransitionGLRenderFunc) (Icon *pIcon, gpointer pUserData);
 
41
 
 
42
/// Transitions are an easy way to set an animation on an Icon to make it change from a state to another.
 
43
struct _CairoDockTransition {
 
44
        /// the cairo rendering function.
 
45
        CairoDockTransitionRenderFunc render;
 
46
        /// the openGL rendering function (can be NULL, in which case the texture mapping from the cairo drawing is done automatically).
 
47
        CairoDockTransitionGLRenderFunc render_opengl;
 
48
        /// data passed to the rendering functions.
 
49
        gpointer pUserData;
 
50
        /// function called to destroy the data when the transition is deleted.
 
51
        GFreeFunc pFreeUserDataFunc;
 
52
        /// TRUE <=> the transition will be in the fast loop (high frequency refresh).
 
53
        gboolean bFastPace;
 
54
        /// TRUE <=> the transition will be destroyed and removed from the icon when finished.
 
55
        gboolean bRemoveWhenFinished;
 
56
        /// duration if the transition, in ms. Can be 0 for an endless transition.
 
57
        gint iDuration;  // en ms.
 
58
        /// elapsed time since the beginning of the transition, in ms.
 
59
        gint iElapsedTime;
 
60
        /// number of setps since the beginning of the transition, in ms.
 
61
        gint iCount;
 
62
        /// cairo context on the Icon.
 
63
        cairo_t *pIconContext;  // attention a bien detruire la transition
 
64
        /// Container of the Icon.
 
65
        CairoContainer *pContainer;  // si l'un de ces 2 parametres change !
 
66
        };
 
67
 
 
68
/// Definition of a Hiding Effect backend (used to provide an animation when the docks hides/shows itself).
 
69
struct _CairoDockHidingEffect {
 
70
        /// translated name of the effect
 
71
        const gchar *cDisplayedName;
 
72
        /// whether the backend can display the dock even when it's hidden
 
73
        gboolean bCanDisplayHiddenDock;
 
74
        /// function called before the icons are drawn (cairo)
 
75
        void (*pre_render) (CairoDock *pDock, double fOffset, cairo_t *pCairoContext);
 
76
        /// function called before the icons are drawn (opengl)
 
77
        void (*pre_render_opengl) (CairoDock *pDock, double fOffset);
 
78
        /// function called afer the icons are drawn (cairo)
 
79
        void (*post_render) (CairoDock *pDock, double fOffset, cairo_t *pCairoContext);
 
80
        /// function called afer the icons are drawn (opengl)
 
81
        void (*post_render_opengl) (CairoDock *pDock, double fOffset);
 
82
        /// function called when the animation is started.
 
83
        void (*init) (CairoDock *pDock);
 
84
        };
 
85
        
 
86
#define CAIRO_DOCK_MIN_SLOW_DELTA_T 90
 
87
 
 
88
/** Say if a container is currently animated.
 
89
*@param pContainer a Container
 
90
*/
 
91
#define cairo_dock_container_is_animating(pContainer) (CAIRO_CONTAINER(pContainer)->iSidGLAnimation != 0)
 
92
 
 
93
/** Say if it's usefull to launch an animation on a Dock (indeed, it's useless to launch it if it will be invisible).
 
94
*@param pDock the Dock to animate.
 
95
*/
 
96
#define cairo_dock_animation_will_be_visible(pDock) ((pDock)->iRefCount != 0 && GTK_WIDGET_VISIBLE ((CAIRO_CONTAINER(pDock)->pWidget)) || ((pDock)->iRefCount == 0 && (! (pDock)->bAutoHide || CAIRO_CONTAINER(pDock)->bInside || (pDock)->fHideOffset < 1)))
 
97
 
 
98
 
 
99
/** Pop up a Dock above other windows, if it is in mode "keep below other windows"; otherwise do nothing.
 
100
*@param pDock the dock.
 
101
*/
 
102
void cairo_dock_pop_up (CairoDock *pDock);
 
103
 
 
104
/** Pop down a Dock below other windows, if it is in mode "keep below other windows"; otherwise do nothing.
 
105
*@param pDock the dock.
 
106
*/
 
107
void cairo_dock_pop_down (CairoDock *pDock);
 
108
 
 
109
 
 
110
gfloat cairo_dock_calculate_magnitude (gint iMagnitudeIndex);
 
111
 
 
112
/** Launch the animation of a Container.
 
113
*@param pContainer the container to animate.
 
114
*/
 
115
void cairo_dock_launch_animation (CairoContainer *pContainer);
 
116
 
 
117
void cairo_dock_start_shrinking (CairoDock *pDock);
 
118
 
 
119
void cairo_dock_start_growing (CairoDock *pDock);
 
120
 
 
121
void cairo_dock_start_hiding (CairoDock *pDock);
 
122
 
 
123
void cairo_dock_start_showing (CairoDock *pDock);
 
124
 
 
125
/** Launch the animation of an Icon. Do nothing if the icon will not be animated or if the icon is at rest.
 
126
*@param icon the icon to animate.
 
127
*@param pDock the dock containing the icon.
 
128
*/
 
129
void cairo_dock_start_icon_animation (Icon *icon, CairoDock *pDock);
 
130
 
 
131
/** Launch a given animation on an Icon. Do nothing if the icon will not be animated or if the animation doesn't exist.
 
132
*@param pIcon the icon to animate.
 
133
*@param pDock the dock containing the icon.
 
134
*@param cAnimation name of the animation.
 
135
*@param iNbRounds number of rounds the animation will be played.
 
136
*/
 
137
void cairo_dock_request_icon_animation (Icon *pIcon, CairoDock *pDock, const gchar *cAnimation, int iNbRounds);
 
138
 
 
139
/** Stop any animation on an Icon, except the disappearance/appearance animation.
 
140
*@param pIcon the icon.
 
141
*/
 
142
#define cairo_dock_stop_icon_animation(pIcon) do { \
 
143
        if (pIcon->iAnimationState != CAIRO_DOCK_STATE_REMOVE_INSERT && pIcon->iAnimationState != CAIRO_DOCK_STATE_REST) {\
 
144
                cairo_dock_notify (CAIRO_DOCK_STOP_ICON, pIcon); \
 
145
                pIcon->iAnimationState = CAIRO_DOCK_STATE_REST; } } while (0)
 
146
 
 
147
void cairo_dock_request_icon_attention (Icon *pIcon, CairoDock *pDock, const gchar *cAnimation, int iNbRounds);
 
148
 
 
149
void cairo_dock_stop_icon_attention (Icon *pIcon, CairoDock *pDock);
 
150
 
 
151
/** Trigger the removal of an Icon from its Dock. The icon will effectively be removed at the end of the animation.
 
152
*If the icon is not inside a dock, nothing happens.
 
153
*@param pIcon the icon to remove
 
154
*/
 
155
void cairo_dock_trigger_icon_removal_from_dock (Icon *pIcon);
 
156
 
 
157
/** Get the interval of time between 2 iterations of the fast loop (in ms).
 
158
*@param pContainer the container.
 
159
*/
 
160
#define cairo_dock_get_animation_delta_t(pContainer) CAIRO_CONTAINER(pContainer)->iAnimationDeltaT
 
161
/** Get the interval of time between 2 iterations of the slow loop (in ms).
 
162
*@param pContainer the container.
 
163
*/
 
164
#define cairo_dock_get_slow_animation_delta_t(pContainer) ((int) ceil (1.*CAIRO_DOCK_MIN_SLOW_DELTA_T / CAIRO_CONTAINER(pContainer)->iAnimationDeltaT) * CAIRO_CONTAINER(pContainer)->iAnimationDeltaT)
 
165
 
 
166
#define cairo_dock_set_default_animation_delta_t(pContainer) CAIRO_CONTAINER(pContainer)->iAnimationDeltaT = (g_bUseOpenGL ? mySystem.iGLAnimationDeltaT : mySystem.iCairoAnimationDeltaT)
 
167
 
 
168
void cairo_dock_mark_icon_animation_as (Icon *pIcon, CairoDockAnimationState iAnimationState);
 
169
void cairo_dock_stop_marking_icon_animation_as (Icon *pIcon, CairoDockAnimationState iAnimationState);
 
170
 
 
171
#define cairo_dock_mark_icon_as_hovered_by_mouse(pIcon) cairo_dock_mark_icon_animation_as (pIcon, CAIRO_DOCK_STATE_MOUSE_HOVERED)
 
172
#define cairo_dock_stop_marking_icon_as_hovered_by_mouse(pIcon) cairo_dock_stop_marking_icon_animation_as (pIcon, CAIRO_DOCK_STATE_MOUSE_HOVERED)
 
173
 
 
174
#define cairo_dock_mark_icon_as_clicked(pIcon) cairo_dock_mark_icon_animation_as (pIcon, CAIRO_DOCK_STATE_CLICKED)
 
175
#define cairo_dock_stop_marking_icon_as_clicked(pIcon) cairo_dock_stop_marking_icon_animation_as (pIcon, CAIRO_DOCK_STATE_CLICKED)
 
176
 
 
177
#define cairo_dock_mark_icon_as_avoiding_mouse(pIcon) cairo_dock_mark_icon_animation_as (pIcon, CAIRO_DOCK_STATE_AVOID_MOUSE)
 
178
#define cairo_dock_stop_marking_icon_as_avoiding_mouse(pIcon) cairo_dock_stop_marking_icon_animation_as (pIcon, CAIRO_DOCK_STATE_AVOID_MOUSE)
 
179
 
 
180
#define cairo_dock_mark_icon_as_following_mouse(pIcon) cairo_dock_mark_icon_animation_as (pIcon, CAIRO_DOCK_STATE_FOLLOW_MOUSE)
 
181
#define cairo_dock_stop_marking_icon_as_following_mouse(pIcon) cairo_dock_stop_marking_icon_animation_as (pIcon, CAIRO_DOCK_STATE_FOLLOW_MOUSE)
 
182
 
 
183
#define cairo_dock_mark_icon_as_inserting_removing(pIcon) cairo_dock_mark_icon_animation_as (pIcon, CAIRO_DOCK_STATE_REMOVE_INSERT)
 
184
#define cairo_dock_stop_marking_icon_as_inserting_removing(pIcon) cairo_dock_stop_marking_icon_animation_as (pIcon, CAIRO_DOCK_STATE_REMOVE_INSERT)
 
185
 
 
186
 
 
187
void cairo_dock_update_removing_inserting_icon_size_default (Icon *icon);
 
188
 
 
189
gboolean cairo_dock_update_inserting_removing_icon_notification (gpointer pUserData, Icon *pIcon, CairoDock *pDock, gboolean *bContinueAnimation);
 
190
gboolean cairo_dock_on_insert_remove_icon_notification (gpointer pUserData, Icon *pIcon, CairoDock *pDock);
 
191
gboolean cairo_dock_stop_inserting_removing_icon_notification (gpointer pUserData, Icon *pIcon);
 
192
 
 
193
 
 
194
/** Set a Transition on an Icon.
 
195
*@param pIcon the icon.
 
196
*@param pContainer the Container of the Icon. It will be shared with the transition.
 
197
*@param pIconContext a cairo context on the Icon for the cairo rendering. It will be shared with the transition.
 
198
*@param render_step_cairo the cairo rendering function.
 
199
*@param render_step_opengl the openGL rendering function (can be NULL, in which case the texture mapping from the cairo drawing is done automatically).
 
200
*@param bFastPace TRUE for a high frequency refresh (this uses of course more CPU).
 
201
*@param iDuration duration if the transition, in ms. Can be 0 for an endless transition, in which case you can stop the transition with #cairo_dock_remove_transition_on_icon.
 
202
*@param bRemoveWhenFinished TRUE to destroy and remove the transition when it is finished.
 
203
*@param pUserData data passed to the rendering functions.
 
204
*@param pFreeUserDataFunc function called to free the user data when the transition is destroyed (optionnal).
 
205
*/
 
206
void cairo_dock_set_transition_on_icon (Icon *pIcon, CairoContainer *pContainer, cairo_t *pIconContext, CairoDockTransitionRenderFunc render_step_cairo, CairoDockTransitionGLRenderFunc render_step_opengl, gboolean bFastPace, gint iDuration, gboolean bRemoveWhenFinished, gpointer pUserData, GFreeFunc pFreeUserDataFunc);
 
207
 
 
208
/** Stop and remove the Transition of an Icon.
 
209
*@param pIcon the icon.
 
210
*/
 
211
void cairo_dock_remove_transition_on_icon (Icon *pIcon);
 
212
 
 
213
/** Say if an Icon has a Transition.
 
214
*@param pIcon the icon.
 
215
*@return TRUE if the icon has a Transition.
 
216
*/
 
217
#define cairo_dock_has_transition(pIcon) ((pIcon)->pTransition != NULL)
 
218
 
 
219
/** Get the the elpased number of steps since the beginning of the transition.
 
220
*@param pIcon the icon.
 
221
*@return the elpased number of steps.
 
222
*/
 
223
#define cairo_dock_get_transition_count(pIcon) (pIcon)->pTransition->iCount
 
224
 
 
225
/** Get the elapsed time (in ms) since the beginning of the transition.
 
226
*@param pIcon the icon.
 
227
*@return the elapsed time.
 
228
*/
 
229
#define cairo_dock_get_transition_elapsed_time(pIcon) (pIcon)->pTransition->iElapsedTime
 
230
 
 
231
/** Get the percentage of the elapsed time (between 0 and 1) since the beginning of the transition, if the transition has a fixed duration (otherwise 0).
 
232
*@param pIcon the icon.
 
233
*@return the elapsed time in [0,1].
 
234
*/
 
235
#define cairo_dock_get_transition_fraction(pIcon) ((pIcon)->pTransition->iDuration ? 1.*(pIcon)->pTransition->iElapsedTime / (pIcon)->pTransition->iDuration : 0)
 
236
 
 
237
 
 
238
G_END_DECLS
 
239
#endif