Revert "Separate theme options for osd prompt buttons."
authorMikael Magnusson <mikachu@gmail.com>
Tue, 2 Aug 2011 18:52:36 +0000 (20:52 +0200)
committerMikael Magnusson <mikachu@gmail.com>
Tue, 2 Aug 2011 18:52:36 +0000 (20:52 +0200)
This reverts commit 1e427a3358deeadf8abc326e714ee201fddc43d6.

obrender/theme.c
obrender/theme.h
openbox/prompt.c

index 6f93b0b..dfd7998 100644 (file)
@@ -147,9 +147,6 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     theme->osd_hilite_bg = RrAppearanceNew(inst, 0);
     theme->osd_unhilite_label = RrAppearanceNew(inst, 1);
     theme->osd_unhilite_bg = RrAppearanceNew(inst, 0);
-    theme->osd_unpressed_button = RrAppearanceNew(inst, 1);
-    theme->osd_pressed_button = RrAppearanceNew(inst, 5);
-    theme->osd_focused_button = RrAppearanceNew(inst, 5);
 
     /* load the font stuff */
     theme->win_font_focused = get_font(active_window_font,
@@ -440,41 +437,6 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
                                            theme->menu_color->r,
                                            theme->menu_color->g,
                                            theme->menu_color->b);
-    if (!read_color(db, inst, "osd.button.unpressed.text.color",
-                    &theme->osd_unpressed_color))
-        theme->osd_unpressed_color =
-            RrColorNew(inst,
-                       theme->osd_text_active_color->r,
-                       theme->osd_text_active_color->g,
-                       theme->osd_text_active_color->b);
-    if (!read_color(db, inst, "osd.button.pressed.text.color",
-                    &theme->osd_pressed_color))
-        theme->osd_pressed_color =
-            RrColorNew(inst,
-                       theme->osd_text_active_color->r,
-                       theme->osd_text_active_color->g,
-                       theme->osd_text_active_color->b);
-    if (!read_color(db, inst, "osd.button.focused.text.color",
-                    &theme->osd_focused_color))
-        theme->osd_focused_color =
-            RrColorNew(inst,
-                       theme->osd_text_active_color->r,
-                       theme->osd_text_active_color->g,
-                       theme->osd_text_active_color->b);
-    if (!read_color(db, inst, "osd.button.pressed.box.color",
-                    &theme->osd_pressed_lineart))
-        theme->osd_pressed_lineart =
-            RrColorNew(inst,
-                       theme->titlebut_focused_pressed_color->r,
-                       theme->titlebut_focused_pressed_color->g,
-                       theme->titlebut_focused_pressed_color->b);
-    if (!read_color(db, inst, "osd.button.focused.box.color",
-                    &theme->osd_focused_lineart))
-        theme->osd_focused_lineart =
-            RrColorNew(inst,
-                       theme->titlebut_hover_focused_color->r,
-                       theme->titlebut_hover_focused_color->g,
-                       theme->titlebut_hover_focused_color->b);
 
     /* load the image masks */
 
@@ -822,37 +784,6 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
         theme->a_hover_unfocused_max =
             RrAppearanceCopy(theme->a_unfocused_unpressed_max);
     }
-    if (!read_appearance(db, inst,
-                         "osd.button.unpressed.bg",
-                         theme->osd_unpressed_button,
-                         TRUE))
-    {
-        RrAppearanceFree(theme->osd_unpressed_button);
-        theme->osd_unpressed_button =
-            RrAppearanceCopy(theme->a_focused_unpressed_max);
-    }
-    if (!read_appearance(db, inst,
-                         "osd.button.pressed.bg",
-                         theme->osd_pressed_button,
-                         TRUE))
-    {
-        RrAppearanceFree(theme->osd_pressed_button);
-        theme->osd_pressed_button =
-            RrAppearanceCopy(theme->a_focused_pressed_max);
-        RrAppearanceRemoveTextures(theme->osd_pressed_button);
-        RrAppearanceAddTextures(theme->osd_pressed_button, 5);
-    }
-    if (!read_appearance(db, inst,
-                         "osd.button.focused.bg",
-                         theme->osd_focused_button,
-                         TRUE))
-    {
-        RrAppearanceFree(theme->osd_focused_button);
-        theme->osd_focused_button =
-            RrAppearanceCopy(theme->a_hover_focused_max);
-        RrAppearanceRemoveTextures(theme->osd_focused_button);
-        RrAppearanceAddTextures(theme->osd_focused_button, 5);
-    }
 
     theme->a_disabled_focused_close =
         RrAppearanceCopy(theme->a_disabled_focused_max);
@@ -1050,35 +981,6 @@ RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
     theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
         theme->osd_text_active_shadow_alpha;
 
-    theme->osd_unpressed_button->texture[0] =
-    theme->osd_pressed_button->texture[0] =
-    theme->osd_focused_button->texture[0] =
-        theme->osd_hilite_label->texture[0];
-
-    theme->osd_unpressed_button->texture[0].data.text.justify =
-    theme->osd_pressed_button->texture[0].data.text.justify =
-    theme->osd_focused_button->texture[0].data.text.justify =
-        RR_JUSTIFY_CENTER;
-
-    theme->osd_unpressed_button->texture[0].data.text.color =
-        theme->osd_unpressed_color;
-    theme->osd_pressed_button->texture[0].data.text.color =
-        theme->osd_pressed_color;
-    theme->osd_focused_button->texture[0].data.text.color =
-        theme->osd_focused_color;
-
-    theme->osd_pressed_button->texture[1].data.lineart.color =
-    theme->osd_pressed_button->texture[2].data.lineart.color =
-    theme->osd_pressed_button->texture[3].data.lineart.color =
-    theme->osd_pressed_button->texture[4].data.lineart.color =
-        theme->osd_pressed_lineart;
-
-    theme->osd_focused_button->texture[1].data.lineart.color =
-    theme->osd_focused_button->texture[2].data.lineart.color =
-    theme->osd_focused_button->texture[3].data.lineart.color =
-    theme->osd_focused_button->texture[4].data.lineart.color =
-        theme->osd_focused_lineart;
-
     theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
     theme->a_unfocused_label->texture[0].data.text.justify = winjust;
     theme->a_unfocused_label->texture[0].data.text.font =
@@ -1620,11 +1522,6 @@ void RrThemeFree(RrTheme *theme)
         RrColorFree(theme->osd_text_inactive_color);
         RrColorFree(theme->osd_text_active_shadow_color);
         RrColorFree(theme->osd_text_inactive_shadow_color);
-        RrColorFree(theme->osd_pressed_color);
-        RrColorFree(theme->osd_unpressed_color);
-        RrColorFree(theme->osd_focused_color);
-        RrColorFree(theme->osd_pressed_lineart);
-        RrColorFree(theme->osd_focused_lineart);
         RrColorFree(theme->menu_title_shadow_color);
         RrColorFree(theme->menu_text_normal_shadow_color);
         RrColorFree(theme->menu_text_selected_shadow_color);
@@ -1760,9 +1657,6 @@ void RrThemeFree(RrTheme *theme)
         RrAppearanceFree(theme->osd_hilite_label);
         RrAppearanceFree(theme->osd_unhilite_bg);
         RrAppearanceFree(theme->osd_unhilite_label);
-        RrAppearanceFree(theme->osd_pressed_button);
-        RrAppearanceFree(theme->osd_unpressed_button);
-        RrAppearanceFree(theme->osd_focused_button);
 
         g_slice_free(RrTheme, theme);
     }
index 2ffc637..3f9063e 100644 (file)
@@ -103,11 +103,6 @@ struct _RrTheme {
     RrColor *osd_text_inactive_shadow_color;
     gchar    osd_text_active_shadow_alpha;
     gchar    osd_text_inactive_shadow_alpha;
-    RrColor *osd_pressed_color;
-    RrColor *osd_unpressed_color;
-    RrColor *osd_focused_color;
-    RrColor *osd_pressed_lineart;
-    RrColor *osd_focused_lineart;
     RrColor *menu_title_shadow_color;
     gchar    menu_title_shadow_alpha;
     RrColor *menu_text_normal_shadow_color;
@@ -253,9 +248,6 @@ struct _RrTheme {
     RrAppearance *osd_hilite_label; /* can be parent relative */
     RrAppearance *osd_unhilite_bg; /* can never be parent relative */
     RrAppearance *osd_unhilite_label; /* can be parent relative */
-    RrAppearance *osd_pressed_button;
-    RrAppearance *osd_unpressed_button;
-    RrAppearance *osd_focused_button;
 
     gchar *name;
 };
index ebefe0a..0835609 100644 (file)
@@ -34,6 +34,7 @@ static RrAppearance *prompt_a_bg;
 static RrAppearance *prompt_a_button;
 static RrAppearance *prompt_a_focus;
 static RrAppearance *prompt_a_press;
+static RrAppearance *prompt_a_pfocus;
 /* we change the max width which would screw with others */
 static RrAppearance *prompt_a_msg;
 
@@ -53,12 +54,58 @@ static void prompt_run_callback(ObPrompt *self, gint result);
 
 void prompt_startup(gboolean reconfig)
 {
+    RrColor *c_button, *c_focus, *c_press, *c_pfocus;
+
     /* note: this is not a copy, don't free it */
     prompt_a_bg = ob_rr_theme->osd_bg;
 
-    prompt_a_button = RrAppearanceCopy(ob_rr_theme->osd_unpressed_button);
-    prompt_a_focus = RrAppearanceCopy(ob_rr_theme->osd_focused_button);
-    prompt_a_press = RrAppearanceCopy(ob_rr_theme->osd_pressed_button);
+    prompt_a_button = RrAppearanceCopy(ob_rr_theme->a_focused_unpressed_close);
+    prompt_a_focus = RrAppearanceCopy(ob_rr_theme->a_hover_focused_close);
+    prompt_a_press = RrAppearanceCopy(ob_rr_theme->a_focused_pressed_close);
+    prompt_a_pfocus = RrAppearanceCopy(ob_rr_theme->a_focused_pressed_close);
+
+    c_button = prompt_a_button->texture[0].data.mask.color;
+    c_focus = prompt_a_focus->texture[0].data.mask.color;
+    c_press = prompt_a_press->texture[0].data.mask.color;
+    c_pfocus = prompt_a_press->texture[0].data.mask.color;
+
+    RrAppearanceRemoveTextures(prompt_a_button);
+    RrAppearanceRemoveTextures(prompt_a_focus);
+    RrAppearanceRemoveTextures(prompt_a_press);
+    RrAppearanceRemoveTextures(prompt_a_pfocus);
+
+    /* texture[0] is the text and texture[1-4] (for prompt_a_focus and
+       prompt_a_pfocus) is lineart to show where keyboard focus is */
+    RrAppearanceAddTextures(prompt_a_button, 1);
+    RrAppearanceAddTextures(prompt_a_focus, 5);
+    RrAppearanceAddTextures(prompt_a_press, 1);
+    RrAppearanceAddTextures(prompt_a_pfocus, 5);
+
+    /* totally cheating here.. */
+    prompt_a_button->texture[0] = ob_rr_theme->osd_hilite_label->texture[0];
+    prompt_a_focus->texture[0] = ob_rr_theme->osd_hilite_label->texture[0];
+    prompt_a_press->texture[0] = ob_rr_theme->osd_hilite_label->texture[0];
+    prompt_a_pfocus->texture[0] = ob_rr_theme->osd_hilite_label->texture[0];
+
+    prompt_a_button->texture[0].data.text.justify = RR_JUSTIFY_CENTER;
+    prompt_a_focus->texture[0].data.text.justify = RR_JUSTIFY_CENTER;
+    prompt_a_press->texture[0].data.text.justify = RR_JUSTIFY_CENTER;
+    prompt_a_pfocus->texture[0].data.text.justify = RR_JUSTIFY_CENTER;
+
+    prompt_a_button->texture[0].data.text.color = c_button;
+    prompt_a_focus->texture[0].data.text.color = c_focus;
+    prompt_a_press->texture[0].data.text.color = c_press;
+    prompt_a_pfocus->texture[0].data.text.color = c_pfocus;
+
+    prompt_a_focus->texture[1].data.lineart.color = c_focus;
+    prompt_a_focus->texture[2].data.lineart.color = c_focus;
+    prompt_a_focus->texture[3].data.lineart.color = c_focus;
+    prompt_a_focus->texture[4].data.lineart.color = c_focus;
+
+    prompt_a_pfocus->texture[1].data.lineart.color = c_press;
+    prompt_a_pfocus->texture[2].data.lineart.color = c_press;
+    prompt_a_pfocus->texture[3].data.lineart.color = c_press;
+    prompt_a_pfocus->texture[4].data.lineart.color = c_press;
 
     prompt_a_msg = RrAppearanceCopy(ob_rr_theme->osd_hilite_label);
     prompt_a_msg->texture[0].data.text.flow = TRUE;
@@ -89,6 +136,7 @@ void prompt_shutdown(gboolean reconfig)
     RrAppearanceFree(prompt_a_button);
     RrAppearanceFree(prompt_a_focus);
     RrAppearanceFree(prompt_a_press);
+    RrAppearanceFree(prompt_a_pfocus);
     RrAppearanceFree(prompt_a_msg);
 }
 
@@ -233,6 +281,7 @@ static void prompt_layout(ObPrompt *self)
         prompt_a_button->texture[0].data.text.string = self->button[i].text;
         prompt_a_focus->texture[0].data.text.string = self->button[i].text;
         prompt_a_press->texture[0].data.text.string = self->button[i].text;
+        prompt_a_pfocus->texture[0].data.text.string = self->button[i].text;
         RrMinSize(prompt_a_button, &bw, &bh);
         self->button[i].width = bw;
         self->button[i].height = bh;
@@ -242,6 +291,9 @@ static void prompt_layout(ObPrompt *self)
         RrMinSize(prompt_a_press, &bw, &bh);
         self->button[i].width = MAX(self->button[i].width, bw);
         self->button[i].height = MAX(self->button[i].height, bh);
+        RrMinSize(prompt_a_pfocus, &bw, &bh);
+        self->button[i].width = MAX(self->button[i].width, bw);
+        self->button[i].height = MAX(self->button[i].height, bh);
 
         self->button[i].width += BUTTON_HMARGIN * 2;
         self->button[i].height += BUTTON_VMARGIN * 2;
@@ -362,8 +414,9 @@ static void render_button(ObPrompt *self, ObPromptElement *e)
 {
     RrAppearance *a;
 
-    if (e->pressed && e->hover)       a = prompt_a_press;
+    if (e->hover && self->focus == e) a = prompt_a_pfocus;
     else if (self->focus == e)        a = prompt_a_focus;
+    else if (e->pressed)              a = prompt_a_press;
     else                              a = prompt_a_button;
 
     a->surface.parent = prompt_a_bg;
@@ -371,7 +424,7 @@ static void render_button(ObPrompt *self, ObPromptElement *e)
     a->surface.parenty = e->y;
 
     /* draw the keyfocus line */
-    if (self->focus == e)
+    if (a == prompt_a_pfocus || a == prompt_a_focus)
         setup_button_focus_tex(e, a, TRUE);
 
     a->texture[0].data.text.string = e->text;
@@ -379,7 +432,7 @@ static void render_button(ObPrompt *self, ObPromptElement *e)
 
     /* turn off the keyfocus line so that it doesn't affect size calculations
      */
-    if (self->focus == e)
+    if (a == prompt_a_pfocus || a == prompt_a_focus)
         setup_button_focus_tex(e, a, FALSE);
 }