better matching of the menu titles/separators to the theme

This commit is contained in:
Dana Jansens 2007-04-22 03:54:43 +00:00
parent 5a3a7668d9
commit 8612fcfb99
4 changed files with 47 additions and 26 deletions

View file

@ -163,6 +163,8 @@ static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
RrAppearanceCopy(ob_rr_theme->a_menu_text_disabled); RrAppearanceCopy(ob_rr_theme->a_menu_text_disabled);
self->a_text_selected = self->a_text_selected =
RrAppearanceCopy(ob_rr_theme->a_menu_text_selected); RrAppearanceCopy(ob_rr_theme->a_menu_text_selected);
self->a_text_title =
RrAppearanceCopy(ob_rr_theme->a_menu_text_title);
return self; return self;
} }
@ -193,6 +195,7 @@ static void menu_entry_frame_free(ObMenuEntryFrame *self)
RrAppearanceFree(self->a_text_normal); RrAppearanceFree(self->a_text_normal);
RrAppearanceFree(self->a_text_disabled); RrAppearanceFree(self->a_text_disabled);
RrAppearanceFree(self->a_text_selected); RrAppearanceFree(self->a_text_selected);
RrAppearanceFree(self->a_text_title);
RrAppearanceFree(self->a_bullet_normal); RrAppearanceFree(self->a_bullet_normal);
RrAppearanceFree(self->a_bullet_selected); RrAppearanceFree(self->a_bullet_selected);
@ -290,9 +293,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
case OB_MENU_ENTRY_TYPE_SEPARATOR: case OB_MENU_ENTRY_TYPE_SEPARATOR:
if (self->entry->data.separator.label) { if (self->entry->data.separator.label) {
item_a = self->frame->a_title; item_a = self->frame->a_title;
item_a->texture[0].data.text.string = th = ob_rr_theme->menu_title_height;
self->entry->data.separator.label;
th = self->frame->title_h;
} else { } else {
item_a = self->a_normal; item_a = self->a_normal;
th = SEPARATOR_HEIGHT + 2*PADDING; th = SEPARATOR_HEIGHT + 2*PADDING;
@ -326,6 +327,9 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
text_a->texture[0].data.text.string = sub ? sub->title : ""; text_a->texture[0].data.text.string = sub ? sub->title : "";
break; break;
case OB_MENU_ENTRY_TYPE_SEPARATOR: case OB_MENU_ENTRY_TYPE_SEPARATOR:
if (self->entry->data.separator.label != NULL)
text_a = self->a_text_title;
else
text_a = self->a_text_normal; text_a = self->a_text_normal;
break; break;
} }
@ -354,7 +358,22 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
self->frame->item_h - 2*PADDING); self->frame->item_h - 2*PADDING);
break; break;
case OB_MENU_ENTRY_TYPE_SEPARATOR: case OB_MENU_ENTRY_TYPE_SEPARATOR:
if (self->entry->data.separator.label == NULL) { if (self->entry->data.separator.label != NULL) {
/* labeled separator */
XMoveResizeWindow(ob_display, self->text,
ob_rr_theme->paddingx, ob_rr_theme->paddingy,
self->area.width - 2*ob_rr_theme->paddingx,
ob_rr_theme->menu_title_height -
2*ob_rr_theme->paddingy);
text_a->surface.parent = item_a;
text_a->surface.parentx = ob_rr_theme->paddingx;
text_a->surface.parenty = ob_rr_theme->paddingy;
RrPaint(text_a, self->text,
self->area.width - 2*ob_rr_theme->paddingx,
ob_rr_theme->menu_title_height -
2*ob_rr_theme->paddingy);
} else {
/* unlabeled separaator */
XMoveResizeWindow(ob_display, self->text, PADDING, PADDING, XMoveResizeWindow(ob_display, self->text, PADDING, PADDING,
self->area.width - 2*PADDING, SEPARATOR_HEIGHT); self->area.width - 2*PADDING, SEPARATOR_HEIGHT);
self->a_separator->surface.parent = item_a; self->a_separator->surface.parent = item_a;
@ -483,12 +502,6 @@ static void menu_frame_render(ObMenuFrame *self)
th += 2*PADDING; th += 2*PADDING;
self->item_h = th; self->item_h = th;
self->a_title->texture[0].data.text.string = "";
RrMinsize(self->a_title, &tw, &th);
tw += 2*PADDING;
th += 2*PADDING;
self->title_h = th;
RrMargins(e->a_normal, &l, &t, &r, &b); RrMargins(e->a_normal, &l, &t, &r, &b);
STRUT_SET(self->item_margin, STRUT_SET(self->item_margin,
MAX(self->item_margin.left, l), MAX(self->item_margin.left, l),
@ -567,11 +580,12 @@ static void menu_frame_render(ObMenuFrame *self)
break; break;
case OB_MENU_ENTRY_TYPE_SEPARATOR: case OB_MENU_ENTRY_TYPE_SEPARATOR:
if (e->entry->data.separator.label != NULL) { if (e->entry->data.separator.label != NULL) {
self->a_title->texture[0].data.text.string = e->a_text_title->texture[0].data.text.string =
e->entry->data.separator.label; e->entry->data.separator.label;
RrMinsize(self->a_title, &tw, &th); RrMinsize(e->a_text_title, &tw, &th);
tw = MIN(tw, MAX_MENU_WIDTH); tw = MIN(tw, MAX_MENU_WIDTH);
th += ob_rr_theme->mbwidth * 2; th = ob_rr_theme->menu_title_height +
(ob_rr_theme->mbwidth - PADDING) *2;
} else { } else {
tw = 0; tw = 0;
th = SEPARATOR_HEIGHT; th = SEPARATOR_HEIGHT;

View file

@ -99,6 +99,7 @@ struct _ObMenuEntryFrame
RrAppearance *a_text_normal; RrAppearance *a_text_normal;
RrAppearance *a_text_disabled; RrAppearance *a_text_disabled;
RrAppearance *a_text_selected; RrAppearance *a_text_selected;
RrAppearance *a_text_title;
}; };
extern GHashTable *menu_frame_map; extern GHashTable *menu_frame_map;

View file

@ -115,7 +115,8 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
theme->a_focused_handle = RrAppearanceNew(inst, 0); theme->a_focused_handle = RrAppearanceNew(inst, 0);
theme->a_unfocused_handle = RrAppearanceNew(inst, 0); theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
theme->a_menu = RrAppearanceNew(inst, 0); theme->a_menu = RrAppearanceNew(inst, 0);
theme->a_menu_title = RrAppearanceNew(inst, 1); theme->a_menu_title = RrAppearanceNew(inst, 0);
theme->a_menu_text_title = RrAppearanceNew(inst, 1);
theme->a_menu_normal = RrAppearanceNew(inst, 0); theme->a_menu_normal = RrAppearanceNew(inst, 0);
theme->a_menu_disabled = RrAppearanceNew(inst, 0); theme->a_menu_disabled = RrAppearanceNew(inst, 0);
theme->a_menu_selected = RrAppearanceNew(inst, 0); theme->a_menu_selected = RrAppearanceNew(inst, 0);
@ -567,7 +568,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
set_default_appearance(theme->a_unfocused_grip); set_default_appearance(theme->a_unfocused_grip);
if (!FIND(appearance, L("menu","entries"), theme->a_menu, FALSE)) if (!FIND(appearance, L("menu","entries"), theme->a_menu, FALSE))
set_default_appearance(theme->a_menu); set_default_appearance(theme->a_menu);
if (!FIND(appearance, L("menu","title"), theme->a_menu_title, FALSE)) if (!FIND(appearance, L("menu","title"), theme->a_menu_title, TRUE))
set_default_appearance(theme->a_menu_title); set_default_appearance(theme->a_menu_title);
if (!FIND(appearance, L("menu", "active"), theme->a_menu_selected, TRUE)) if (!FIND(appearance, L("menu", "active"), theme->a_menu_selected, TRUE))
set_default_appearance(theme->a_menu_selected); set_default_appearance(theme->a_menu_selected);
@ -752,6 +753,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
theme->a_icon->surface.grad = theme->a_icon->surface.grad =
theme->a_clear->surface.grad = theme->a_clear->surface.grad =
theme->a_clear_tex->surface.grad = theme->a_clear_tex->surface.grad =
theme->a_menu_text_title->surface.grad =
theme->a_menu_normal->surface.grad = theme->a_menu_normal->surface.grad =
theme->a_menu_disabled->surface.grad = theme->a_menu_disabled->surface.grad =
theme->a_menu_text_normal->surface.grad = theme->a_menu_text_normal->surface.grad =
@ -811,18 +813,20 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
theme->a_unfocused_label->texture[0].data.text.shadow_alpha = theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
theme->title_unfocused_shadow_alpha; theme->title_unfocused_shadow_alpha;
theme->a_menu_title->texture[0].type = RR_TEXTURE_TEXT; theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
theme->a_menu_title->texture[0].data.text.justify = mtitlejust; theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
theme->a_menu_title->texture[0].data.text.font = theme->menu_title_font; theme->a_menu_text_title->texture[0].data.text.font =
theme->a_menu_title->texture[0].data.text.color = theme->menu_title_color; theme->menu_title_font;
theme->a_menu_text_title->texture[0].data.text.color =
theme->menu_title_color;
if (!FIND(shadow, L("menu","title","text","shadow","offset"), if (!FIND(shadow, L("menu","title","text","shadow","offset"),
theme->a_menu_title)) theme->a_menu_text_title))
theme->a_menu_title->texture[0].data.text.shadow_offset_x = theme->a_menu_text_title->texture[0].data.text.shadow_offset_x =
theme->a_menu_title->texture[0].data.text.shadow_offset_y = 0; theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = 0;
theme->a_menu_title->texture[0].data.text.shadow_color = theme->a_menu_text_title->texture[0].data.text.shadow_color =
theme->menu_title_shadow_color; theme->menu_title_shadow_color;
theme->a_menu_title->texture[0].data.text.shadow_alpha = theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
theme->menu_title_shadow_alpha; theme->menu_title_shadow_alpha;
theme->a_menu_text_normal->texture[0].type = theme->a_menu_text_normal->texture[0].type =
@ -1117,7 +1121,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
MAX(theme->win_font_height, MAX(theme->win_font_height,
RrFontHeight(theme->win_font_unfocused, RrFontHeight(theme->win_font_unfocused,
a->texture[0].data.text.shadow_offset_y)); a->texture[0].data.text.shadow_offset_y));
a = theme->a_menu_title; a = theme->a_menu_text_title;
theme->menu_title_font_height = theme->menu_title_font_height =
RrFontHeight(theme->menu_title_font, RrFontHeight(theme->menu_title_font,
a->texture[0].data.text.shadow_offset_y); a->texture[0].data.text.shadow_offset_y);
@ -1294,6 +1298,7 @@ void RrThemeFree(RrTheme *theme)
RrAppearanceFree(theme->a_unfocused_handle); RrAppearanceFree(theme->a_unfocused_handle);
RrAppearanceFree(theme->a_menu); RrAppearanceFree(theme->a_menu);
RrAppearanceFree(theme->a_menu_title); RrAppearanceFree(theme->a_menu_title);
RrAppearanceFree(theme->a_menu_text_title);
RrAppearanceFree(theme->a_menu_normal); RrAppearanceFree(theme->a_menu_normal);
RrAppearanceFree(theme->a_menu_disabled); RrAppearanceFree(theme->a_menu_disabled);
RrAppearanceFree(theme->a_menu_selected); RrAppearanceFree(theme->a_menu_selected);

View file

@ -201,6 +201,7 @@ struct _RrTheme {
RrAppearance *a_icon; RrAppearance *a_icon;
RrAppearance *a_focused_handle; RrAppearance *a_focused_handle;
RrAppearance *a_unfocused_handle; RrAppearance *a_unfocused_handle;
RrAppearance *a_menu_text_title;
RrAppearance *a_menu_title; RrAppearance *a_menu_title;
RrAppearance *a_menu; RrAppearance *a_menu;
RrAppearance *a_menu_normal; RrAppearance *a_menu_normal;