ui colors again
"corvid" <[email protected]>
| Newsgroups | gmane.comp.web.dillo.devel |
|---|---|
| Message-ID | <20121221005838.GA14407@local> |
Today I dug up the old ui colors patch from last September, ripped out the part that used system colors as defaults that was a problem*, and played around with it a little. I really like configurable colors, so, since I haven't heard anyone say anything like feature freeze yet, I'll make another push for this thing. One difference from the previous code is that I'm using inactive() on the images for inactive toolbar buttons because our gray pixmaps tend not to look so good with different UI colors. It might be good to pull it somewhat closer to the background color, but I'm not sure yet. * Under X, FLTK tries to "Read colors that KDE writes to the xrdb database", which may or may not work fine for those people running KDE, but... _______________________________________________ Dillo-dev mailing list [email protected] http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
ui_colors.diff
(text/plain, 10.1 KB)
diff -r 23554f924d39 dillorc
--- a/dillorc Thu Dec 20 19:25:51 2012 +0100
+++ b/dillorc Fri Dec 21 00:38:41 2012 +0000
@@ -165,7 +165,13 @@
# COLORS SECTION
#-------------------------------------------------------------------------
-# Set the background color
+# Override the user interface colors.
+#
+# ui_fg_color=black
+# ui_main_bg_color=silver
+# ui_text_bg_color=white
+
+# Set the page background color
# bg_color=gray
# bg_color=0xd6d6c0
#bg_color=0xdcd1ba
diff -r 23554f924d39 src/dialog.cc
--- a/src/dialog.cc Thu Dec 20 19:25:51 2012 +0100
+++ b/src/dialog.cc Fri Dec 21 00:38:41 2012 +0000
@@ -166,8 +166,6 @@
o->box(FL_THIN_UP_BOX);
o->labelfont(FL_TIMES_BOLD);
o->labelsize(34);
- o->color(FL_WHITE);
- o->labelcolor(FL_BLUE);
o->label("?");
o->show();
@@ -196,7 +194,6 @@
ch->tooltip("Select search engine");
ch->menu(pm);
ch->value(prefs.search_url_idx);
- ch->textcolor(FL_DARK_BLUE);
int xpos = ww-2*(gap+bw), ypos = ih+3*gap;
Fl_Return_Button *rb = new Fl_Return_Button(xpos, ypos, bw, bh, "OK");
diff -r 23554f924d39 src/dillo.cc
--- a/src/dillo.cc Thu Dec 20 19:25:51 2012 +0100
+++ b/src/dillo.cc Fri Dec 21 00:38:41 2012 +0000
@@ -237,6 +237,12 @@
checkFont(prefs.font_fantasy, "fantasy");
}
+static void setColor(int32_t color, void (*fn) (uchar, uchar, uchar))
+{
+ if (color != -1)
+ fn(color >> 16, (color >> 8) & 0xff, color & 0xff);
+}
+
/*
* Given a command line argument, build a DilloUrl for it.
*/
@@ -379,6 +385,14 @@
Fl::scheme(prefs.theme);
+ setColor(prefs.ui_main_bg_color, Fl::background);
+ setColor(prefs.ui_text_bg_color, Fl::background2);
+ setColor(prefs.ui_fg_color, Fl::foreground);
+
+ unsigned rgb = Fl::get_color(fl_contrast(FL_SELECTION_COLOR,
+ FL_BACKGROUND2_COLOR));
+ Fl::set_color(FL_SELECTION_COLOR, rgb);
+
if (!prefs.show_tooltip) {
// turn off UI tooltips
Fl::option(Fl::OPTION_SHOW_TOOLTIPS, false);
diff -r 23554f924d39 src/findbar.cc
--- a/src/findbar.cc Thu Dec 20 19:25:51 2012 +0100
+++ b/src/findbar.cc Fri Dec 21 00:38:41 2012 +0000
@@ -131,7 +131,6 @@
i = new MyInput(x, border, input_width, height);
x += input_width + gap;
resizable(i);
- i->color(206);
i->when(FL_WHEN_NEVER);
add(i);
diff -r 23554f924d39 src/prefs.c
--- a/src/prefs.c Thu Dec 20 19:25:51 2012 +0100
+++ b/src/prefs.c Fri Dec 21 00:38:41 2012 +0000
@@ -100,6 +100,9 @@
prefs.small_icons = FALSE;
prefs.start_page = a_Url_new(PREFS_START_PAGE, NULL);
prefs.theme = dStrdup(PREFS_THEME);
+ prefs.ui_fg_color = -1;
+ prefs.ui_main_bg_color = -1;
+ prefs.ui_text_bg_color = -1;
prefs.w3c_plus_heuristics = TRUE;
prefs.penalty_hyphen = 100;
diff -r 23554f924d39 src/prefs.h
--- a/src/prefs.h Thu Dec 20 19:25:51 2012 +0100
+++ b/src/prefs.h Fri Dec 21 00:38:41 2012 +0000
@@ -44,6 +44,9 @@
DilloUrl *home;
bool_t allow_white_bg;
int32_t bg_color;
+ int32_t ui_fg_color;
+ int32_t ui_main_bg_color;
+ int32_t ui_text_bg_color;
bool_t contrast_visited_color;
bool_t show_tooltip;
char *theme;
diff -r 23554f924d39 src/prefsparser.cc
--- a/src/prefsparser.cc Thu Dec 20 19:25:51 2012 +0100
+++ b/src/prefsparser.cc Fri Dec 21 00:38:41 2012 +0000
@@ -110,6 +110,9 @@
{ "small_icons", &prefs.small_icons, PREFS_BOOL },
{ "start_page", &prefs.start_page, PREFS_URL },
{ "theme", &prefs.theme, PREFS_STRING },
+ { "ui_fg_color", &prefs.ui_fg_color, PREFS_COLOR },
+ { "ui_main_bg_color", &prefs.ui_main_bg_color, PREFS_COLOR },
+ { "ui_text_bg_color", &prefs.ui_text_bg_color, PREFS_COLOR },
{ "w3c_plus_heuristics", &prefs.w3c_plus_heuristics, PREFS_BOOL },
{ "penalty_hyphen", &prefs.penalty_hyphen, PREFS_FRACTION_100 },
{ "penalty_hyphen_2", &prefs.penalty_hyphen_2, PREFS_FRACTION_100 },
diff -r 23554f924d39 src/tipwin.cc
--- a/src/tipwin.cc Thu Dec 20 19:25:51 2012 +0100
+++ b/src/tipwin.cc Fri Dec 21 00:38:41 2012 +0000
@@ -171,7 +171,7 @@
TipWinButton(x,y,w,h,l)
{
norm_color = color();
- light_color = 17; // {17,26,51}
+ light_color = fl_lighter(norm_color);
}
int CustButton::handle(int e)
diff -r 23554f924d39 src/ui.cc
--- a/src/ui.cc Thu Dec 20 19:25:51 2012 +0100
+++ b/src/ui.cc Fri Dec 21 00:38:41 2012 +0000
@@ -51,11 +51,11 @@
new Fl_Pixmap(search_xpm),
new Fl_Pixmap(help_xpm),
new Fl_Pixmap(left_xpm),
- new Fl_Pixmap(left_i_xpm),
+ NULL,
new Fl_Pixmap(right_xpm),
- new Fl_Pixmap(right_i_xpm),
+ NULL,
new Fl_Pixmap(stop_xpm),
- new Fl_Pixmap(stop_i_xpm),
+ NULL,
};
static struct iconset small_icons = {
@@ -70,11 +70,11 @@
standard_icons.ImgSearch,
standard_icons.ImgHelp,
new Fl_Pixmap(left_s_xpm),
- new Fl_Pixmap(left_si_xpm),
+ NULL,
new Fl_Pixmap(right_s_xpm),
- new Fl_Pixmap(right_si_xpm),
+ NULL,
new Fl_Pixmap(stop_s_xpm),
- new Fl_Pixmap(stop_si_xpm),
+ NULL,
};
@@ -222,10 +222,6 @@
if (b == FL_LEFT_MOUSE) {
a_UIcmd_search_dialog(a_UIcmd_get_bw_by_widget(wid));
- } else if (b == FL_MIDDLE_MOUSE) {
- ((UI*)data)->color_change_cb_i();
- } else if (b == FL_RIGHT_MOUSE) {
- // nothing ATM
}
}
@@ -405,6 +401,18 @@
*/
void UI::make_toolbar(int tw, int th)
{
+ if (!icons->ImgLeftIn) {
+ icons->ImgLeftIn = icons->ImgLeft->copy();
+ icons->ImgLeftIn->inactive();
+ }
+ if (!icons->ImgRightIn) {
+ icons->ImgRightIn = icons->ImgRight->copy();
+ icons->ImgRightIn->inactive();
+ }
+ if (!icons->ImgStopIn) {
+ icons->ImgStopIn = icons->ImgStop->copy();
+ icons->ImgStopIn->inactive();
+ }
Back = make_button("Back", icons->ImgLeft, icons->ImgLeftIn, UI_BACK, 1);
Forw = make_button("Forw", icons->ImgRight, icons->ImgRightIn, UI_FORW);
Home = make_button("Home", icons->ImgHome, NULL, UI_HOME);
@@ -441,7 +449,6 @@
CustInput *i = new CustInput(p_xpos,0,ww-p_xpos-32,lh,0);
Location = i;
- i->color(CuteColor);
i->when(FL_WHEN_ENTER_KEY);
i->callback(location_cb, this);
i->set_tooltip("Location");
@@ -474,14 +481,12 @@
IProg = new CustProgressBox(p_xpos,p_ypos,pw,bh);
IProg->labelsize(12);
IProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
- IProg->labelcolor(FL_GRAY_RAMP + 2);
IProg->update_label(wide ? "Images\n0 of 0" : "0 of 0");
p_xpos += pw;
// Page
PProg = new CustProgressBox(p_xpos,p_ypos,pw,bh);
PProg->labelsize(12);
PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
- PProg->labelcolor(FL_GRAY_RAMP + 2);
PProg->update_label(wide ? "Page\n0.0KB" : "0.0KB");
}
@@ -641,14 +646,12 @@
PanelTemporary = false;
if (cur_ui) {
PanelSize = cur_ui->PanelSize;
- CuteColor = cur_ui->CuteColor;
Small_Icons = cur_ui->Small_Icons;
Panelmode = cur_ui->Panelmode;
} else {
// Set some default values
PanelSize = prefs.panel_size;
Small_Icons = prefs.small_icons;
- CuteColor = 206;
Panelmode = (prefs.fullwindow_start) ? UI_HIDDEN : UI_NORMAL;
}
@@ -660,11 +663,9 @@
Main = new Fl_Group(0,0,0,0,"Welcome..."); // size is set by rearrange()
Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
Main->box(FL_FLAT_BOX);
- Main->color(FL_GRAY_RAMP + 3);
Main->labelfont(FL_HELVETICA_BOLD_ITALIC);
Main->labelsize(36);
Main->labeltype(FL_SHADOW_LABEL);
- Main->labelcolor(FL_WHITE);
TopGroup->add(Main);
TopGroup->resizable(Main);
MainIdx = TopGroup->find(Main);
@@ -977,21 +978,6 @@
}
/*
- * On-the-fly color style change
- */
-void UI::color_change_cb_i()
-{
- const int cols[] = {7,17,26,51,140,156,205,206,215,-1};
- static int ncolor = 0;
-
- ncolor = (cols[ncolor+1] < 0) ? 0 : ncolor + 1;
- CuteColor = cols[ncolor];
- MSG("Location color %d\n", CuteColor);
- Location->color(CuteColor);
- Location->redraw();
-}
-
-/*
* Set 'nw' as the main render area widget
*/
void UI::set_render_layout(Fl_Group *nw)
diff -r 23554f924d39 src/ui.hh
--- a/src/ui.hh Thu Dec 20 19:25:51 2012 +0100
+++ b/src/ui.hh Fri Dec 21 00:38:41 2012 +0000
@@ -135,7 +135,7 @@
int MainIdx;
// Panel customization variables
- int PanelSize, CuteColor, Small_Icons;
+ int PanelSize, Small_Icons;
int p_xpos, p_ypos, bw, bh, mh, lh, nh, fh, sh, pw, lbl;
bool PanelTemporary;
diff -r 23554f924d39 src/uicmd.cc
--- a/src/uicmd.cc Thu Dec 20 19:25:51 2012 +0100
+++ b/src/uicmd.cc Fri Dec 21 00:38:41 2012 +0000
@@ -136,7 +136,8 @@
Pack = NULL;
focus_counter = 0;
tab_w = 50, tab_h = th, ctab_h = 1, btn_w = 20, ctl_w = 1*btn_w+2;
- tabcolor_active = 0x87aca700; tabcolor_inactive = 0xb7beb700;
+ tabcolor_active = fl_lighter(FL_BACKGROUND_COLOR);
+ tabcolor_inactive = fl_darker(FL_BACKGROUND_COLOR);
resize(0,0,ww,ctab_h);
/* tab buttons go inside a pack within a scroll */
Scroll = new Fl_Scroll(0,0,ww-ctl_w,ctab_h);
@@ -153,8 +154,6 @@
Control = new Fl_Group(ww-ctl_w,0,ctl_w,ctab_h);
CloseBtn = new CustButton(ww-ctl_w+2,0,btn_w,ctab_h, "X");
CloseBtn->box(FL_THIN_UP_BOX);
- CloseBtn->labelcolor(0x00641000);
- CloseBtn->hl_color(FL_WHITE);
CloseBtn->clear_visible_focus();
CloseBtn->set_tooltip(prefs.right_click_closes_tab ?
"Close current tab.\nor Right-click tab label to close." :
@@ -283,6 +282,8 @@
btn->clear_visible_focus();
btn->box(FL_GTK_THIN_UP_BOX);
btn->color(focus ? tabcolor_active : tabcolor_inactive);
+ btn->labelcolor(fl_contrast(FL_FOREGROUND_COLOR,
+ focus ? tabcolor_active : tabcolor_inactive));
btn->ui(new_ui);
btn->callback(tab_btn_cb, this);
Pack->add(btn); // append
@@ -411,10 +412,12 @@
if ((idx = get_btn_idx(old_ui)) != -1) {
btn = (CustTabButton*)Pack->child(idx);
btn->color(tabcolor_inactive);
+ btn->labelcolor(fl_contrast(FL_FOREGROUND_COLOR, tabcolor_inactive));
btn->redraw();
}
Wizard->value(cbtn->ui());
cbtn->color(tabcolor_active);
+ cbtn->labelcolor(fl_contrast(FL_FOREGROUND_COLOR, tabcolor_active));
cbtn->redraw();
update_pack_offset();