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/>.
20
#ifndef __CAIRO_DOCK_EMBLEM__
21
#define __CAIRO_DOCK_EMBLEM__
23
#include "cairo-dock-struct.h"
27
*@file cairo-dock-emblem.h This class defines Emblems, that are small images superimposed on the icon at a given place.
29
* The emblem is drawn directly on the icon, so it modifies its surface/texture itself. Thus, to remove an emblem, you have to set the original image on the icon.
31
* Emblems can be placed in the corners of the icon, or in the middle of it.
34
* create an Emblem with \ref cairo_dock_make_emblem
35
* set its position with \ref cairo_dock_set_emblem_position
36
* you can then render the emblem on the icon with \ref cairo_dock_draw_emblem_on_icon.
37
* free the emblem when you're done with \ref cairo_dock_free_emblem
39
* An emblem can be used as many times as you want on any icon. The only limitation is that an emblem uses either Cairo or OpenGL, this is decided at the creation time; so the icons you draw the emblem on must be drawn with the same rendering.
42
/// Available position of the emblem on the icon.
44
CAIRO_DOCK_EMBLEM_UPPER_LEFT = 0,
45
CAIRO_DOCK_EMBLEM_LOWER_RIGHT,
46
CAIRO_DOCK_EMBLEM_LOWER_LEFT,
47
CAIRO_DOCK_EMBLEM_UPPER_RIGHT,
48
CAIRO_DOCK_EMBLEM_MIDDLE,
49
CAIRO_DOCK_EMBLEM_NB_POSITIONS,
50
} CairoEmblemPosition;
52
/// Definition of an Emblem. You shouldn't access any of its fields directly.
54
cairo_surface_t *pSurface;
58
CairoEmblemPosition iPosition;
62
/** Create an emblem from an image, that suits the given icon and container. If the image is given by its sole name, it is searched inside the current theme root folder.
63
*@param cImageFile an image.
64
*@param pIcon an icon.
65
*@param pContainer its container, or NULL if the icon is not yet inside a container.
66
*@return the newly allocated emblem.
68
CairoEmblem *cairo_dock_make_emblem (const gchar *cImageFile, Icon *pIcon, CairoContainer *pContainer);
70
/** Create an emblem from an existing surface. The surface is appropriated by the emblem, so if you free it with \ref cairo_dock_free_emblem, it will also free the surface. Use g_free to destroy the emblem if you don't want the surface to be destroyed with.
71
*@param pSurface a surface.
72
*@param iSurfaceWidth width of the surface, 0 means it has the same width as the icon.
73
*@param iSurfaceHeight height of the surface, 0 means it has the same height as the icon.
74
*@param pIcon an icon.
75
*@param pContainer its container, or NULL if the icon is not yet inside a container.
76
*@return the newly allocated emblem.
78
CairoEmblem *cairo_dock_make_emblem_from_surface (cairo_surface_t *pSurface, int iSurfaceWidth, int iSurfaceHeight, Icon *pIcon, CairoContainer *pContainer);
80
/** Create an emblem from an existing texture. The texture is appropriated by the emblem, so if you free it with \ref cairo_dock_free_emblem, it will also free the texture. Use g_free to destroy the emblem if you don't want the texture to be destroyed with.
81
*@param iTexture a texture.
82
*@param pIcon an icon.
83
*@param pContainer its container, or NULL if the icon is not yet inside a container.
84
*@return the newly allocated emblem.
86
CairoEmblem *cairo_dock_make_emblem_from_texture (GLuint iTexture, Icon *pIcon, CairoContainer *pContainer);
88
/** Set the position of an emblem.
89
*@param pEmblem the emblem
90
*@param pos the position (a \ref CairoEmblemPosition)
92
#define cairo_dock_set_emblem_position(pEmblem, pos) pEmblem->iPosition = pos
94
/** Destroy an emblem and all its allocated ressources.
95
*@param pEmblem the emblem
97
void cairo_dock_free_emblem (CairoEmblem *pEmblem);
100
void _cairo_dock_apply_emblem_texture (CairoEmblem *pEmblem, int w, int h);
101
void _cairo_dock_apply_emblem_surface (CairoEmblem *pEmblem, int w, int h, cairo_t *pCairoContext);
103
/** Permanently draw an emblem on an icon.
104
*@param pEmblem the emblem
105
*@param pIcon an icon
106
*@param pContainer its container, or NULL if the icon is not yet inside a container
108
void cairo_dock_draw_emblem_on_icon (CairoEmblem *pEmblem, Icon *pIcon, CairoContainer *pContainer);