From: Mikael Magnusson Date: Thu, 7 Feb 2008 14:28:18 +0000 (+0100) Subject: Merge branch 'wip/alttab' X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=f6193ad9e048c5824142d3e7feeb109f91054052;hp=-c;p=chaz%2Fopenbox Merge branch 'wip/alttab' --- f6193ad9e048c5824142d3e7feeb109f91054052 diff --combined render/render.c index 75dead16,7791429a..49485c8a --- a/render/render.c +++ b/render/render.c @@@ -132,10 -132,20 +132,20 @@@ Pixmap RrPaintPixmap(RrAppearance *a, g break; case RR_TEXTURE_RGBA: g_assert(!transferred); - RrImageDraw(a->surface.pixel_data, - &a->texture[i].data.rgba, - a->w, a->h, - &tarea); + { + RrRect narea = tarea; + RrTextureRGBA *rgb = &a->texture[i].data.rgba; + if (rgb->twidth) + narea.width = MIN(tarea.width, rgb->twidth); + if (rgb->theight) + narea.height = MIN(tarea.height, rgb->theight); + narea.x += rgb->tx; + narea.y += rgb->ty; + RrImageDraw(a->surface.pixel_data, + &a->texture[i].data.rgba, + a->w, a->h, + &narea); + } force_transfer = 1; break; } @@@ -178,12 -188,6 +188,12 @@@ RrAppearance *RrAppearanceNew(const RrI return out; } +void RrAppearanceRemoveTextures(RrAppearance *a) +{ + g_free(a->texture); + a->textures = 0; +} + void RrAppearanceAddTextures(RrAppearance *a, gint numtex) { g_assert(a->textures == 0); @@@ -384,9 -388,7 +394,9 @@@ gint RrMinWidth(RrAppearance *a m = RrFontMeasureString(a->texture[i].data.text.font, a->texture[i].data.text.string, a->texture[i].data.text.shadow_offset_x, - a->texture[i].data.text.shadow_offset_y); + a->texture[i].data.text.shadow_offset_y, + a->texture[i].data.text.flow, + a->texture[i].data.text.maxwidth); w = MAX(w, m->width); g_free(m); break; @@@ -412,7 -414,6 +422,7 @@@ gint RrMinHeight(RrAppearance *a { gint i; gint l, t, r, b; + RrSize *m; gint h = 0; for (i = 0; i < a->textures; ++i) { @@@ -423,24 -424,8 +433,24 @@@ h = MAX(h, a->texture[i].data.mask.mask->height); break; case RR_TEXTURE_TEXT: - h += MAX(h, RrFontHeight(a->texture[i].data.text.font, - a->texture[i].data.text.shadow_offset_y)); + if (a->texture[i].data.text.flow) { + g_assert(a->texture[i].data.text.string != NULL); + + m = RrFontMeasureString + (a->texture[i].data.text.font, + a->texture[i].data.text.string, + a->texture[i].data.text.shadow_offset_x, + a->texture[i].data.text.shadow_offset_y, + a->texture[i].data.text.flow, + a->texture[i].data.text.maxwidth); + h += MAX(h, m->height); + g_free(m); + } + else + h += MAX(h, + RrFontHeight + (a->texture[i].data.text.font, + a->texture[i].data.text.shadow_offset_y)); break; case RR_TEXTURE_RGBA: h += MAX(h, a->texture[i].data.rgba.height); diff --combined render/render.h index ad9a0ef1,7b81e2ff..260ebeb0 --- a/render/render.h +++ b/render/render.h @@@ -22,7 -22,7 +22,7 @@@ #define __render_h #include "geom.h" -#include "version.h" +#include "render/version.h" #include /* some platforms dont include this as needed for Xft */ #include @@@ -141,8 -141,6 +141,8 @@@ struct _RrTextureText gboolean shortcut; /*!< Underline a character */ guint shortcut_pos; /*!< Position in bytes of the character to underline */ RrEllipsizeMode ellipsize; + gboolean flow; /* allow multiple lines. must set maxwidth below */ + gint maxwidth; }; struct _RrPixmapMask { @@@ -167,6 -165,11 +167,11 @@@ struct _RrTextureRGBA gint cwidth; gint cheight; RrPixel32 *cache; + /* size and position to draw at */ + gint tx; + gint ty; + gint twidth; + gint theight; }; struct _RrTextureLineArt { @@@ -246,7 -249,6 +251,7 @@@ GC RrColorGC (RrColor *c) RrAppearance *RrAppearanceNew (const RrInstance *inst, gint numtex); RrAppearance *RrAppearanceCopy (RrAppearance *a); void RrAppearanceFree (RrAppearance *a); +void RrAppearanceRemoveTextures(RrAppearance *a); void RrAppearanceAddTextures(RrAppearance *a, gint numtex); RrFont *RrFontOpen (const RrInstance *inst, const gchar *name, @@@ -254,8 -256,7 +259,8 @@@ RrFont *RrFontOpenDefault (const RrInstance *inst); void RrFontClose (RrFont *f); RrSize *RrFontMeasureString (const RrFont *f, const gchar *str, - gint shadow_offset_x, gint shadow_offset_y); + gint shadow_offset_x, gint shadow_offset_y, + gboolean flow, gint maxwidth); gint RrFontHeight (const RrFont *f, gint shadow_offset_y); gint RrFontMaxCharWidth (const RrFont *f); @@@ -266,8 -267,6 +271,8 @@@ Pixmap RrPaintPixmap (RrAppearance *a, void RrPaint (RrAppearance *a, Window win, gint w, gint h); void RrMinSize (RrAppearance *a, gint *w, gint *h); gint RrMinWidth (RrAppearance *a); +/* For text textures, if flow is TRUE, then the string must be set before + calling this, otherwise it doesn't need to be */ gint RrMinHeight (RrAppearance *a); void RrMargins (RrAppearance *a, gint *l, gint *t, gint *r, gint *b); diff --combined render/theme.c index fe200e37,6d87cafb..a6931be6 --- a/render/theme.c +++ b/render/theme.c @@@ -538,6 -538,16 +538,16 @@@ RrTheme* RrThemeNew(const RrInstance *i theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data); } + /* up and down arrows */ + { + guchar data[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 }; + theme->down_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data); + } + { + guchar data[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 }; + theme->up_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data); + } + /* setup the default window icon */ theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH, OB_DEFAULT_ICON_HEIGHT, @@@ -897,9 -907,13 +907,9 @@@ j = (i > 0 ? 0 : 255); i = ABS(i*255/100); - theme->title_focused_shadow_color = RrColorNew(inst, j, j, j); - theme->title_focused_shadow_alpha = i; theme->osd_shadow_color = RrColorNew(inst, j, j, j); theme->osd_shadow_alpha = i; } else { - theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0); - theme->title_focused_shadow_alpha = 50; theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0); theme->osd_shadow_alpha = 50; } @@@ -1446,6 -1460,8 +1456,8 @@@ void RrThemeFree(RrTheme *theme RrPixmapMaskFree(theme->close_hover_mask); RrPixmapMaskFree(theme->close_pressed_mask); RrPixmapMaskFree(theme->menu_bullet_mask); + RrPixmapMaskFree(theme->down_arrow_mask); + RrPixmapMaskFree(theme->up_arrow_mask); RrFontClose(theme->win_font_focused); RrFontClose(theme->win_font_unfocused);