2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* E-mail : see the 'copyright' file.
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.
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/>.
21
#ifndef __CAIRO_DOCK_LOAD__
22
#define __CAIRO_DOCK_LOAD__
26
#include "cairo-dock-struct.h"
27
#include "cairo-dock-surface-factory.h"
31
*@file cairo-dock-load.h This class defines a simple image loader interface.
32
* It also handles the main image buffers of the dock.
33
* Use \ref cairo_dock_create_image_buffer to create an immage buffer from a file, or \ref cairo_dock_load_image_buffer to load an image into an existing immage buffer.
34
* Use \ref cairo_dock_free_image_buffer to destroy it or \ref cairo_dock_unload_image_buffer to unload and reset it to 0.
37
/// Definition of a Desktop Background Buffer. It has a reference count so that it can be shared across all the lib.
38
struct _CairoDockDesktopBackground {
39
cairo_surface_t *pSurface;
45
/// Definition of an Image Buffer. It provides an unified interface for a cairo/opengl image buffer.
46
struct _CairoDockImageBuffer {
47
cairo_surface_t *pSurface;
53
void cairo_dock_free_label_description (CairoDockLabelDescription *pTextDescription);
54
void cairo_dock_copy_label_description (CairoDockLabelDescription *pDestTextDescription, CairoDockLabelDescription *pOrigTextDescription);
55
CairoDockLabelDescription *cairo_dock_duplicate_label_description (CairoDockLabelDescription *pOrigTextDescription);
57
/** Say if 2 strings differ, taking into account NULL strings.
59
#define cairo_dock_strings_differ(s1, s2) ((s1 && ! s2) || (! s1 && s2) || (s1 && s2 && strcmp (s1, s2)))
60
/** Say if 2 RGBA colors differ.
62
#define cairo_dock_colors_rvb_differ(c1, c2) ((c1[0] != c2[0]) || (c1[1] != c2[1]) || (c1[2] != c2[2]))
63
/** Say if 2 RGB colors differ.
65
#define cairo_dock_colors_differ(c1, c2) (cairo_dock_colors_rvb_differ (c1, c2) || (c1[3] != c2[3]))
67
/** Generate a complete path from a file name. '~' is handled, and files are supposed to be in the root folder of the current theme.
68
*@param cImageFile a file name or path. If it's already a path, it will just be duplicated.
69
*@return the path of the file.
71
gchar *cairo_dock_generate_file_path (const gchar *cImageFile);
74
void cairo_dock_load_image_buffer_full (CairoDockImageBuffer *pImage, const gchar *cImageFile, int iWidth, int iHeight, CairoDockLoadImageModifier iLoadModifier, double fAlpha);
76
#define cairo_dock_load_image_buffer(pImage, cImageFile, iWidth, iHeight, iLoadModifier) cairo_dock_load_image_buffer_full (pImage, cImageFile, iWidth, iHeight, iLoadModifier, 1.)
78
void cairo_dock_load_image_buffer_from_surface (CairoDockImageBuffer *pImage, cairo_surface_t *pSurface, int iWidth, int iHeight);
80
CairoDockImageBuffer *cairo_dock_create_image_buffer (const gchar *cImageFile, int iWidth, int iHeight, CairoDockLoadImageModifier iLoadModifier);
82
void cairo_dock_unload_image_buffer (CairoDockImageBuffer *pImage);
84
void cairo_dock_free_image_buffer (CairoDockImageBuffer *pImage);
86
/* Cree la surface de reflection d'une icone (pour cairo).
87
*@param pSourceContext le contexte de dessin lie a la surface de l'icone; n'est pas altere par la fonction.
88
*@param pIcon l'icone.
89
*@param pContainer le container de l'icone.
91
void cairo_dock_add_reflection_to_icon (cairo_t *pSourceContext, Icon *pIcon, CairoContainer *pContainer);
93
/**Fill the image buffer (surface & texture) of a given icon, according to its type. Set its size accordingly, and fills the reflection buffer for cairo.
94
*@param icon the icon.
95
*@param pSourceContext a drawing context, not modified.
96
*@param fMaxScale maximum zoom.
97
*@param bIsHorizontal TRUE if the icon will be in a horizontal container (needed for the cairo reflect).
98
*@param bDirectionUp TRUE if the icon will be in a up container (needed for the cairo reflect).
100
void cairo_dock_fill_one_icon_buffer (Icon *icon, cairo_t* pSourceContext, gdouble fMaxScale, gboolean bIsHorizontal, gboolean bDirectionUp);
102
/**Cut an UTF-8 or ASCII string to n characters, and add '...' to the end in cas it was effectively cut. If n is negative, it will remove the last |n| characters. It manages correctly UTF-8 strings.
103
*@param cString the string.
104
*@param iNbCaracters the maximum number of characters wished, or the number of characters to remove if negative.
105
*@return the newly allocated string.
107
gchar *cairo_dock_cut_string (const gchar *cString, int iNbCaracters);
109
/**Fill the label buffer (surface & texture) of a given icon, according to a text description.
110
*@param icon the icon.
111
*@param pSourceContext a drawing context, not modified.
112
*@param pTextDescription desctiption of the text rendering.
114
void cairo_dock_fill_one_text_buffer (Icon *icon, cairo_t* pSourceContext, CairoDockLabelDescription *pTextDescription);
116
/**Fill the quick-info buffer (surface & texture) of a given icon, according to a text description.
117
*@param icon the icon.
118
*@param pSourceContext a drawing context, not modified.
119
*@param pTextDescription desctiption of the text rendering.
120
*@param fMaxScale maximum zoom.
122
void cairo_dock_fill_one_quick_info_buffer (Icon *icon, cairo_t* pSourceContext, CairoDockLabelDescription *pTextDescription, double fMaxScale);
124
void cairo_dock_fill_icon_buffers (Icon *icon, cairo_t *pSourceContext, double fMaxScale, gboolean bIsHorizontal, gboolean bDirectionUp);
125
#define cairo_dock_fill_icon_buffers_for_desklet(pIcon, pSourceContext) cairo_dock_fill_icon_buffers (pIcon, pSourceContext, 1, CAIRO_DOCK_HORIZONTAL, TRUE)
126
#define cairo_dock_fill_icon_buffers_for_dock(pIcon, pSourceContext, pDock) cairo_dock_fill_icon_buffers (pIcon, pSourceContext, 1 + myIcons.fAmplitude, pDock->container.bIsHorizontal, pDock->container.bDirectionUp)
128
/** Fill all the buffers (surfaces & textures) of a given icon, according to its type. Set its size accordingly, and fills the reflection buffer for cairo. Label and quick-info are loaded with the current global text description.
129
*@param pIcon the icon.
130
*@param pContainer its container.
132
void cairo_dock_load_one_icon_from_scratch (Icon *pIcon, CairoContainer *pContainer);
134
void cairo_dock_reload_buffers_in_dock (gchar *cDockName, CairoDock *pDock, gpointer data);
135
#define cairo_dock_load_buffers_in_one_dock(pDock) cairo_dock_reload_buffers_in_dock (NULL, pDock, GINT_TO_POINTER (TRUE))
137
#define cairo_dock_reload_one_icon_buffer_in_dock_full(icon, pDock, pCairoContext) do {\
138
icon->fWidth /= pDock->container.fRatio;\
139
icon->fHeight /= pDock->container.fRatio;\
140
cairo_dock_fill_one_icon_buffer (icon, pCairoContext, 1 + myIcons.fAmplitude, pDock->container.bIsHorizontal, pDock->container.bDirectionUp);\
141
icon->fWidth *= pDock->container.fRatio;\
142
icon->fHeight *= pDock->container.fRatio; } while (0)
144
void cairo_dock_reload_one_icon_buffer_in_dock (Icon *icon, CairoDock *pDock);
148
void cairo_dock_load_visible_zone (CairoDock *pDock, gchar *cVisibleZoneImageFile, int iVisibleZoneWidth, int iVisibleZoneHeight, double fVisibleZoneAlpha);
150
void cairo_dock_update_background_decorations_if_necessary (CairoDock *pDock, int iNewDecorationsWidth, int iNewDecorationsHeight);
152
void cairo_dock_load_background_decorations (CairoDock *pDock);
154
void cairo_dock_load_icons_background_surface (const gchar *cImagePath, double fMaxScale);
156
void cairo_dock_load_box_surface (double fMaxScale);
159
CairoDockDesktopBackground *cairo_dock_get_desktop_background (gboolean bWithTextureToo);
161
void cairo_dock_destroy_desktop_background (CairoDockDesktopBackground *pDesktopBg);
163
cairo_surface_t *cairo_dock_get_desktop_bg_surface (CairoDockDesktopBackground *pDesktopBg);
165
GLuint cairo_dock_get_desktop_bg_texture (CairoDockDesktopBackground *pDesktopBg);
167
void cairo_dock_reload_desktop_background (void);
170
void cairo_dock_load_task_indicator (const gchar *cIndicatorImagePath, double fMaxScale, double fIndicatorRatio);
172
void cairo_dock_load_active_window_indicator (const gchar *cImagePath, double fMaxScale, double fCornerRadius, double fLineWidth, double *fActiveColor);
174
void cairo_dock_load_class_indicator (const gchar *cIndicatorImagePath, double fMaxScale);
177
void cairo_dock_unload_additionnal_textures (void);