summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2007-04-22 03:54:43 +0000
committerDana Jansens <danakj@orodu.net>2007-04-22 03:54:43 +0000
commit8612fcfb99f4ed97f49c3617fd2ae291877c8c8e (patch)
tree405af8a7c0d90a218b63d90d6fc1dda144cb3a2f
parent5a3a7668d9e3ebe995603fadd2da22cbe1c31c83 (diff)
better matching of the menu titles/separators to the theme
-rw-r--r--openbox/menuframe.c42
-rw-r--r--openbox/menuframe.h1
-rw-r--r--render/theme.c29
-rw-r--r--render/theme.h1
4 files changed, 47 insertions, 26 deletions
diff --git a/openbox/menuframe.c b/openbox/menuframe.c
index d065881d..6a8b2c4e 100644
--- a/openbox/menuframe.c
+++ b/openbox/menuframe.c
@@ -163,6 +163,8 @@ static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
RrAppearanceCopy(ob_rr_theme->a_menu_text_disabled);
self->a_text_selected =
RrAppearanceCopy(ob_rr_theme->a_menu_text_selected);
+ self->a_text_title =
+ RrAppearanceCopy(ob_rr_theme->a_menu_text_title);
return self;
}
@@ -193,6 +195,7 @@ static void menu_entry_frame_free(ObMenuEntryFrame *self)
RrAppearanceFree(self->a_text_normal);
RrAppearanceFree(self->a_text_disabled);
RrAppearanceFree(self->a_text_selected);
+ RrAppearanceFree(self->a_text_title);
RrAppearanceFree(self->a_bullet_normal);
RrAppearanceFree(self->a_bullet_selected);
@@ -290,9 +293,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
case OB_MENU_ENTRY_TYPE_SEPARATOR:
if (self->entry->data.separator.label) {
item_a = self->frame->a_title;
- item_a->texture[0].data.text.string =
- self->entry->data.separator.label;
- th = self->frame->title_h;
+ th = ob_rr_theme->menu_title_height;
} else {
item_a = self->a_normal;
th = SEPARATOR_HEIGHT + 2*PADDING;
@@ -326,7 +327,10 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
text_a->texture[0].data.text.string = sub ? sub->title : "";
break;
case OB_MENU_ENTRY_TYPE_SEPARATOR:
- text_a = self->a_text_normal;
+ if (self->entry->data.separator.label != NULL)
+ text_a = self->a_text_title;
+ else
+ text_a = self->a_text_normal;
break;
}
@@ -354,7 +358,22 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
self->frame->item_h - 2*PADDING);
break;
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,
self->area.width - 2*PADDING, SEPARATOR_HEIGHT);
self->a_separator->surface.parent = item_a;
@@ -483,12 +502,6 @@ static void menu_frame_render(ObMenuFrame *self)
th += 2*PADDING;
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);
STRUT_SET(self->item_margin,
MAX(self->item_margin.left, l),
@@ -567,11 +580,12 @@ static void menu_frame_render(ObMenuFrame *self)
break;
case OB_MENU_ENTRY_TYPE_SEPARATOR:
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;
- RrMinsize(self->a_title, &tw, &th);
+ RrMinsize(e->a_text_title, &tw, &th);
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 {
tw = 0;
th = SEPARATOR_HEIGHT;
diff --git a/openbox/menuframe.h b/openbox/menuframe.h
index 26f44b1b..016700a7 100644
--- a/openbox/menuframe.h
+++ b/openbox/menuframe.h
@@ -99,6 +99,7 @@ struct _ObMenuEntryFrame
RrAppearance *a_text_normal;
RrAppearance *a_text_disabled;
RrAppearance *a_text_selected;
+ RrAppearance *a_text_title;
};
extern GHashTable *menu_frame_map;
diff --git a/render/theme.c b/render/theme.c
index cf483977..ade6f6c5 100644
--- a/render/theme.c
+++ b/render/theme.c
@@ -115,7 +115,8 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
theme->a_focused_handle = RrAppearanceNew(inst, 0);
theme->a_unfocused_handle = 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_disabled = 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);
if (!FIND(appearance, L("menu","entries"), theme->a_menu, FALSE))
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);
if (!FIND(appearance, L("menu", "active"), theme->a_menu_selected, TRUE))
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_clear->surface.grad =
theme->a_clear_tex->surface.grad =
+ theme->a_menu_text_title->surface.grad =
theme->a_menu_normal->surface.grad =
theme->a_menu_disabled->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->title_unfocused_shadow_alpha;
- theme->a_menu_title->texture[0].type = RR_TEXTURE_TEXT;
- theme->a_menu_title->texture[0].data.text.justify = mtitlejust;
- theme->a_menu_title->texture[0].data.text.font = theme->menu_title_font;
- theme->a_menu_title->texture[0].data.text.color = theme->menu_title_color;
+ theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
+ theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
+ theme->a_menu_text_title->texture[0].data.text.font =
+ 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"),
- theme->a_menu_title))
- theme->a_menu_title->texture[0].data.text.shadow_offset_x =
- theme->a_menu_title->texture[0].data.text.shadow_offset_y = 0;
- theme->a_menu_title->texture[0].data.text.shadow_color =
+ theme->a_menu_text_title))
+ theme->a_menu_text_title->texture[0].data.text.shadow_offset_x =
+ theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = 0;
+ theme->a_menu_text_title->texture[0].data.text.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->a_menu_text_normal->texture[0].type =
@@ -1117,7 +1121,7 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name,
MAX(theme->win_font_height,
RrFontHeight(theme->win_font_unfocused,
a->texture[0].data.text.shadow_offset_y));
- a = theme->a_menu_title;
+ a = theme->a_menu_text_title;
theme->menu_title_font_height =
RrFontHeight(theme->menu_title_font,
a->texture[0].data.text.shadow_offset_y);
@@ -1294,6 +1298,7 @@ void RrThemeFree(RrTheme *theme)
RrAppearanceFree(theme->a_unfocused_handle);
RrAppearanceFree(theme->a_menu);
RrAppearanceFree(theme->a_menu_title);
+ RrAppearanceFree(theme->a_menu_text_title);
RrAppearanceFree(theme->a_menu_normal);
RrAppearanceFree(theme->a_menu_disabled);
RrAppearanceFree(theme->a_menu_selected);
diff --git a/render/theme.h b/render/theme.h
index c3b375c6..62ff87dd 100644
--- a/render/theme.h
+++ b/render/theme.h
@@ -201,6 +201,7 @@ struct _RrTheme {
RrAppearance *a_icon;
RrAppearance *a_focused_handle;
RrAppearance *a_unfocused_handle;
+ RrAppearance *a_menu_text_title;
RrAppearance *a_menu_title;
RrAppearance *a_menu;
RrAppearance *a_menu_normal;