X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=obrender%2Frender.h;h=59e77660cc1d237590c52938b2e926969339b217;hb=4e6c0086a657399d989f2e4849f7b397d7d4efbc;hp=7bea1b54bc75b7b639383676e2463a843edead0a;hpb=7aae8cc5262c1b36e3196845d62489b76af9063f;p=chaz%2Fopenbox diff --git a/obrender/render.h b/obrender/render.h index 7bea1b54..59e77660 100644 --- a/obrender/render.h +++ b/obrender/render.h @@ -44,22 +44,26 @@ typedef struct _RrPixmapMask RrPixmapMask; typedef struct _RrInstance RrInstance; typedef struct _RrColor RrColor; typedef struct _RrImage RrImage; +typedef struct _RrImageSet RrImageSet; typedef struct _RrImagePic RrImagePic; typedef struct _RrImageCache RrImageCache; +typedef struct _RrButton RrButton; -typedef guint32 RrPixel32; +typedef guint32 RrPixel32; /* ARGB format, not premultiplied alpha */ typedef guint16 RrPixel16; typedef guchar RrPixel8; typedef enum { RR_RELIEF_FLAT, RR_RELIEF_RAISED, - RR_RELIEF_SUNKEN + RR_RELIEF_SUNKEN, + RR_RELIEF_NUM_TYPES } RrReliefType; typedef enum { RR_BEVEL_1, - RR_BEVEL_2 + RR_BEVEL_2, + RR_BEVEL_NUM_TYPES } RrBevelType; typedef enum { @@ -72,7 +76,8 @@ typedef enum { RR_SURFACE_DIAGONAL, RR_SURFACE_CROSS_DIAGONAL, RR_SURFACE_PYRAMID, - RR_SURFACE_MIRROR_HORIZONTAL + RR_SURFACE_MIRROR_HORIZONTAL, + RR_SURFACE_NUM_TYPES } RrSurfaceColorType; typedef enum { @@ -81,13 +86,15 @@ typedef enum { RR_TEXTURE_TEXT, RR_TEXTURE_LINE_ART, RR_TEXTURE_RGBA, - RR_TEXTURE_IMAGE + RR_TEXTURE_IMAGE, + RR_TEXTURE_NUM_TYPES } RrTextureType; typedef enum { RR_JUSTIFY_LEFT, RR_JUSTIFY_CENTER, - RR_JUSTIFY_RIGHT + RR_JUSTIFY_RIGHT, + RR_JUSTIFY_NUM_TYPES } RrJustify; /* Put middle first so it's the default */ @@ -95,7 +102,8 @@ typedef enum { RR_ELLIPSIZE_MIDDLE, RR_ELLIPSIZE_NONE, RR_ELLIPSIZE_START, - RR_ELLIPSIZE_END + RR_ELLIPSIZE_END, + RR_ELLIPSIZE_NUM_TYPES } RrEllipsizeMode; typedef enum { @@ -103,13 +111,15 @@ typedef enum { RR_FONTWEIGHT_NORMAL, RR_FONTWEIGHT_SEMIBOLD, RR_FONTWEIGHT_BOLD, - RR_FONTWEIGHT_ULTRABOLD + RR_FONTWEIGHT_ULTRABOLD, + RR_FONTWEIGHT_NUM_TYPES } RrFontWeight; typedef enum { RR_FONTSLANT_NORMAL, RR_FONTSLANT_ITALIC, - RR_FONTSLANT_OBLIQUE + RR_FONTSLANT_OBLIQUE, + RR_FONTSLANT_NUM_TYPES } RrFontSlant; struct _RrSurface { @@ -212,7 +222,7 @@ struct _RrTexture { struct _RrAppearance { const RrInstance *inst; - + RrSurface surface; gint textures; RrTexture *texture; @@ -232,16 +242,41 @@ struct _RrImagePic { gint sum; }; -/*! An RrImage is a sort of meta-image. It can contain multiple versions of - an image at different sizes, which may or may not be completely different - pictures */ +typedef void (*RrImageDestroyFunc)(RrImage *image, gpointer data); + +/*! An RrImage refers to a RrImageSet. If multiple RrImageSets end up + holding the same image data, they will be marged and the RrImages that + point to them would be updated. */ struct _RrImage { gint ref; + RrImageSet *set; + + /* This function (if not NULL) will be called just before destroying + RrImage. */ + RrImageDestroyFunc destroy_func; + gpointer destroy_data; +}; + +/*! An RrImage is a sort of meta-image. It can contain multiple versions + of an image at different sizes, which may or may not be completely different + pictures */ +struct _RrImageSet +{ RrImageCache *cache; + /*! If a picture is loaded by a name, then it has a name attached to it. + This contains a list of strings, containing all names that have ever + been associated with the RrImageSet. A name in the RrImageCache can + only be associated with a single RrImageSet. */ + GSList *names; + + /*! RrImages that point at this RrImageSet. If this is empty, then there + are no images using the set and it can be freed. */ + GSList *images; + /*! An array of "originals", that is of RrPictures that have been added to the image in various sizes, and that have not been resized. These - are explicitly added to the RrImage. */ + are explicitly added to the RrImageSet. */ RrImagePic **original; gint n_original; /*! An array of "resized" pictures. When an "original" RrPicture @@ -252,6 +287,52 @@ struct _RrImage { gint n_resized; }; +struct _RrButton { + const RrInstance *inst; + + /* colors */ + RrColor *focused_unpressed_color; + RrColor *unfocused_unpressed_color; + RrColor *focused_pressed_color; + RrColor *unfocused_pressed_color; + RrColor *disabled_focused_color; + RrColor *disabled_unfocused_color; + RrColor *hover_focused_color; + RrColor *hover_unfocused_color; + RrColor *toggled_hover_focused_color; + RrColor *toggled_hover_unfocused_color; + RrColor *toggled_focused_pressed_color; + RrColor *toggled_unfocused_pressed_color; + RrColor *toggled_focused_unpressed_color; + RrColor *toggled_unfocused_unpressed_color; + + /* masks */ + RrPixmapMask *mask; + RrPixmapMask *pressed_mask; + RrPixmapMask *disabled_mask; + RrPixmapMask *hover_mask; + RrPixmapMask *toggled_mask; + RrPixmapMask *toggled_hover_mask; + RrPixmapMask *toggled_pressed_mask; + + /* textures */ + RrAppearance *a_focused_unpressed; + RrAppearance *a_unfocused_unpressed; + RrAppearance *a_focused_pressed; + RrAppearance *a_unfocused_pressed; + RrAppearance *a_disabled_focused; + RrAppearance *a_disabled_unfocused; + RrAppearance *a_hover_focused; + RrAppearance *a_hover_unfocused; + RrAppearance *a_toggled_focused_unpressed; + RrAppearance *a_toggled_unfocused_unpressed; + RrAppearance *a_toggled_focused_pressed; + RrAppearance *a_toggled_unfocused_pressed; + RrAppearance *a_toggled_hover_focused; + RrAppearance *a_toggled_hover_unfocused; + +}; + /* these are the same on all endian machines because it seems to be dependant on the endianness of the gfx card, not the cpu. */ #define RrDefaultAlphaOffset 24 @@ -284,6 +365,7 @@ gint RrGreenMask (const RrInstance *inst); gint RrBlueMask (const RrInstance *inst); RrColor *RrColorNew (const RrInstance *inst, gint r, gint g, gint b); +RrColor *RrColorCopy (RrColor *c); RrColor *RrColorParse (const RrInstance *inst, gchar *colorname); void RrColorFree (RrColor *in); @@ -301,10 +383,15 @@ void RrAppearanceAddTextures(RrAppearance *a, gint numtex); /*! Always call this when changing the type of a texture in an appearance */ void RrAppearanceClearTextures(RrAppearance *a); +RrButton *RrButtonNew (const RrInstance *inst); +void RrButtonFree(RrButton *b); + RrFont *RrFontOpen (const RrInstance *inst, const gchar *name, gint size, RrFontWeight weight, RrFontSlant slant); RrFont *RrFontOpenDefault (const RrInstance *inst); void RrFontClose (RrFont *f); +/*! Returns an RrSize, that was allocated with g_slice_new(). Use g_slice_free() to + free it. */ RrSize *RrFontMeasureString (const RrFont *f, const gchar *str, gint shadow_offset_x, gint shadow_offset_y, gboolean flow, gint maxwidth); @@ -334,16 +421,41 @@ RrImageCache* RrImageCacheNew(gint max_resized_saved); void RrImageCacheRef(RrImageCache *self); void RrImageCacheUnref(RrImageCache *self); -/*! Finds an image in the cache, if it is already in there */ -RrImage* RrImageCacheFind(RrImageCache *self, - RrPixel32 *data, gint w, gint h); - -RrImage* RrImageNew(RrImageCache *cache); -void RrImageRef(RrImage *im); -void RrImageUnref(RrImage *im); +/*! Create a new image, or return one from the cache that matches. + @param cache The image cache. + @param old The current RrImage, which the new image should be added to. + Use this if loading a different sized version of the same image. + The returned RrImage should replace the one passed in as old. + Pass NULL here if adding an image which is (or may be) entirely new. + @param name The name of the icon to be loaded off disk, or used in the cache + @return Returns NULL if unable to load an image by the name and it is not in + the cache already +*/ +RrImage* RrImageNewFromName(RrImageCache *cache, const gchar *name); + +/*! Create a new image, or return one from the cache that matches. + @param cache The image cache. + @param data The image data in RGBA32 format. There should be @w * @h many + values in the data array. + @param w The width of the image data. + @param h The height of the image data. + @return Returns NULL if unable to load an image by the name and it is not in + the cache already +*/ +RrImage* RrImageNewFromData(RrImageCache *cache, RrPixel32 *data, + gint w, gint h); + +/*! Add a new size of a picture to an image. + If a picture has multiple versions of different sizes (example 16x16, 32x32 + and so on), they should all be under the same RrImage. This adds a new + size to an existing RrImage, associating the newly sized picture with the + others in the RrImage - classifying them as being the same logical image at a + different dimention. +*/ +void RrImageAddFromData(RrImage *image, RrPixel32 *data, gint w, gint h); -void RrImageAddPicture(RrImage *im, RrPixel32 *data, gint w, gint h); -void RrImageRemovePicture(RrImage *im, gint w, gint h); +void RrImageRef(RrImage *im); +void RrImageUnref(RrImage *im); G_END_DECLS