Pick the CSS system colours from ui_color() and BScreen::DesktopColor(). Update those when they are updated in ZETA. Also update the toolbar and statusbar background.

svn path=/trunk/netsurf/; revision=11535
This commit is contained in:
François Revel 2011-01-30 19:23:42 +00:00
parent cf993628eb
commit e1c11a1d54
6 changed files with 198 additions and 45 deletions

View File

@ -485,6 +485,9 @@ void gui_init(int argc, char** argv)
return;
}
// ui_color() gives hardcoded values before BApplication is created.
nsbeos_update_system_ui_colors();
fetch_rsrc_register();
check_homedir();

View File

@ -21,6 +21,11 @@
#include <Application.h>
#include <FilePanel.h>
#include <Window.h>
#include <BeBuild.h>
#ifndef B_BEOS_VERSION_DANO
#define B_UI_SETTINGS_CHANGED '_UIC'
#endif
#define CALLED() fprintf(stderr, "%s()\n", __FUNCTION__);
@ -64,3 +69,4 @@ void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaf
void nsbeos_gui_view_source(struct hlcache_handle *content, struct selection *selection);
image_id nsbeos_find_app_path(char *path);
void nsbeos_update_system_ui_colors(void);

View File

@ -87,6 +87,8 @@ struct beos_scaffolding {
BDragger *dragger;
BView *tool_bar;
BControl *back_button;
BControl *forward_button;
BControl *stop_button;
@ -360,6 +362,7 @@ NSBaseView::MessageReceived(BMessage *message)
case B_PASTE:
case B_SELECT_ALL:
//case B_MOUSE_WHEEL_CHANGED:
case B_UI_SETTINGS_CHANGED:
// NetPositive messages
case B_NETPOSITIVE_OPEN_URL:
case B_NETPOSITIVE_BACK:
@ -551,6 +554,7 @@ NSBaseView::AllAttached()
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
g->tool_bar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
g->dragger->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
g->status_bar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@ -576,12 +580,27 @@ NSBrowserWindow::~NSBrowserWindow()
}
void
NSBrowserWindow::DispatchMessage(BMessage *message, BHandler *handler)
{
BMessage *msg;
switch (message->what) {
case B_UI_SETTINGS_CHANGED:
msg = new BMessage(*message);
nsbeos_pipe_message_top(msg, this, fScaffolding);
break;
}
BWindow::DispatchMessage(message, handler);
}
void
NSBrowserWindow::MessageReceived(BMessage *message)
{
switch (message->what) {
case B_ARGV_RECEIVED:
case B_REFS_RECEIVED:
case B_UI_SETTINGS_CHANGED:
DetachCurrentMessage();
nsbeos_pipe_message_top(message, this, fScaffolding);
break;
@ -640,6 +659,34 @@ static void nsbeos_window_destroy_event(NSBrowserWindow *window, nsbeos_scaffold
}
void nsbeos_scaffolding_update_colors(nsbeos_scaffolding *g)
{
if (!g->top_view->LockLooper())
return;
rgb_color c = ui_color(B_PANEL_BACKGROUND_COLOR);
g->top_view->SetViewColor(c);
g->tool_bar->SetViewColor(c);
g->back_button->SetViewColor(c);
g->forward_button->SetViewColor(c);
g->stop_button->SetViewColor(c);
g->reload_button->SetViewColor(c);
g->home_button->SetViewColor(c);
g->url_bar->SetViewColor(c);
g->throbber->SetViewColor(c);
g->scroll_view->SetViewColor(c);
g->dragger->SetViewColor(c);
g->status_bar->SetViewColor(c);
g->status_bar->SetLowColor(c);
#if defined(__HAIKU__) || defined(B_DANO_VERSION)
g->status_bar->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
#endif
g->top_view->UnlockLooper();
}
void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *message)
{
int width, height;
@ -715,6 +762,10 @@ void nsbeos_scaffolding_dispatch_event(nsbeos_scaffolding *scaffold, BMessage *m
}
break;
}
case B_UI_SETTINGS_CHANGED:
nsbeos_update_system_ui_colors();
nsbeos_scaffolding_update_colors(scaffold);
break;
case B_NETPOSITIVE_OPEN_URL:
{
int32 i;
@ -1976,22 +2027,22 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
g->dragger->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
g->dragger->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)) ;
// toolbar
// tool_bar
// the toolbar is also the dragger for now
// XXX: try to stuff it in the status bar at the bottom
// (BDragger *must* be a parent, sibiling or direct child of NSBaseView!)
rect = g->top_view->Bounds();
rect.bottom = rect.top + TOOLBAR_HEIGHT - 1;
rect.right = rect.right - DRAGGER_WIDTH;
BView *toolbar = new BView(rect, "Toolbar",
g->tool_bar = new BView(rect, "Toolbar",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW);
g->top_view->AddChild(toolbar);
toolbar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
toolbar->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)) ;
g->top_view->AddChild(g->tool_bar);
g->tool_bar->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
g->tool_bar->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)) ;
// buttons
#warning use BPictureButton
rect = toolbar->Bounds();
rect = g->tool_bar->Bounds();
rect.right = TOOLBAR_HEIGHT;
rect.InsetBySelf(5, 5);
rect.OffsetBySelf(0, -1);
@ -2000,40 +2051,40 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
message = new BMessage('back');
message->AddPointer("scaffolding", g);
g->back_button = new BButton(rect, "back_button", "<", message);
toolbar->AddChild(g->back_button);
g->tool_bar->AddChild(g->back_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('forw');
message->AddPointer("scaffolding", g);
g->forward_button = new BButton(rect, "forward_button", ">", message);
toolbar->AddChild(g->forward_button);
g->tool_bar->AddChild(g->forward_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('stop');
message->AddPointer("scaffolding", g);
g->stop_button = new BButton(rect, "stop_button", "S", message);
toolbar->AddChild(g->stop_button);
g->tool_bar->AddChild(g->stop_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('relo');
message->AddPointer("scaffolding", g);
g->reload_button = new BButton(rect, "reload_button", "R", message);
toolbar->AddChild(g->reload_button);
g->tool_bar->AddChild(g->reload_button);
nButtons++;
rect.OffsetBySelf(TOOLBAR_HEIGHT, 0);
message = new BMessage('home');
message->AddPointer("scaffolding", g);
g->home_button = new BButton(rect, "home_button", "H", message);
toolbar->AddChild(g->home_button);
g->tool_bar->AddChild(g->home_button);
nButtons++;
// url bar
rect = toolbar->Bounds();
rect = g->tool_bar->Bounds();
rect.left += TOOLBAR_HEIGHT * nButtons;
rect.right -= TOOLBAR_HEIGHT * 1;
rect.InsetBySelf(5, 5);
@ -2042,17 +2093,17 @@ nsbeos_scaffolding *nsbeos_new_scaffolding(struct gui_window *toplevel)
g->url_bar = new BTextControl(rect, "url_bar", "url", "", message,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
g->url_bar->SetDivider(g->url_bar->StringWidth("url "));
toolbar->AddChild(g->url_bar);
g->tool_bar->AddChild(g->url_bar);
// throbber
rect.Set(0, 0, 24, 24);
rect.OffsetTo(toolbar->Bounds().right - 24 - (TOOLBAR_HEIGHT - 24) / 2,
rect.OffsetTo(g->tool_bar->Bounds().right - 24 - (TOOLBAR_HEIGHT - 24) / 2,
(TOOLBAR_HEIGHT - 24) / 2);
g->throbber = new NSThrobber(rect);
toolbar->AddChild(g->throbber);
g->throbber->SetViewColor(toolbar->ViewColor());
g->throbber->SetLowColor(toolbar->ViewColor());
g->tool_bar->AddChild(g->throbber);
g->throbber->SetViewColor(g->tool_bar->ViewColor());
g->throbber->SetLowColor(g->tool_bar->ViewColor());
g->throbber->SetDrawingMode(B_OP_ALPHA);
g->throbber->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
/* set up the throbber. */

View File

@ -58,6 +58,7 @@ public:
NSBrowserWindow(BRect frame, struct beos_scaffolding *scaf);
virtual ~NSBrowserWindow();
virtual void DispatchMessage(BMessage *message, BHandler *handler);
virtual void MessageReceived(BMessage *message);
virtual bool QuitRequested(void);

View File

@ -155,6 +155,7 @@ NSBrowserFrameView::MessageReceived(BMessage *message)
case B_PASTE:
case B_SELECT_ALL:
//case B_MOUSE_WHEEL_CHANGED:
case B_UI_SETTINGS_CHANGED:
// NetPositive messages
case B_NETPOSITIVE_OPEN_URL:
case B_NETPOSITIVE_BACK:
@ -887,6 +888,9 @@ void nsbeos_dispatch_event(BMessage *message)
break;
case B_MOUSE_WHEEL_CHANGED:
break;
case B_UI_SETTINGS_CHANGED:
nsbeos_update_system_ui_colors();
break;
case 'nsLO': // login
{
BString url;

View File

@ -27,6 +27,7 @@
#include <stdbool.h>
#include <InterfaceDefs.h>
#include <Screen.h>
extern "C" {
@ -38,12 +39,45 @@ extern "C" {
}
#include "beos/beos_gui.h"
#if !defined(__HAIKU__) && !defined(B_BEOS_VERSION_DANO)
/* more ui_colors, R5 only had a few defined... */
#define B_PANEL_TEXT_COLOR ((color_which)10)
#define B_DOCUMENT_BACKGROUND_COLOR ((color_which)11)
#define B_DOCUMENT_TEXT_COLOR ((color_which)12)
#define B_CONTROL_BACKGROUND_COLOR ((color_which)13)
#define B_CONTROL_TEXT_COLOR ((color_which)14)
#define B_CONTROL_BORDER_COLOR ((color_which)15)
#define B_CONTROL_HIGHLIGHT_COLOR ((color_which)16)
#define B_NAVIGATION_BASE_COLOR ((color_which)4)
#define B_NAVIGATION_PULSE_COLOR ((color_which)17)
#define B_SHINE_COLOR ((color_which)18)
#define B_SHADOW_COLOR ((color_which)19)
#define B_MENU_SELECTED_BORDER_COLOR ((color_which)9)
#define B_TOOLTIP_BACKGROUND_COLOR ((color_which)20)
#define B_TOOLTIP_TEXT_COLOR ((color_which)21)
#define B_SUCCESS_COLOR ((color_which)100)
#define B_FAILURE_COLOR ((color_which)101)
#define B_MENU_SELECTED_BACKGROUND_COLOR B_MENU_SELECTION_BACKGROUND_COLOR
#define B_RANDOM_COLOR ((color_which)0x80000000)
#define B_MICHELANGELO_FAVORITE_COLOR ((color_which)0x80000001)
#define B_DSANDLER_FAVORITE_SKY_COLOR ((color_which)0x80000002)
#define B_DSANDLER_FAVORITE_INK_COLOR ((color_which)0x80000003)
#define B_DSANDLER_FAVORITE_SHOES_COLOR ((color_which)0x80000004)
#define B_DAVE_BROWN_FAVORITE_COLOR ((color_which)0x80000005)
#endif
#define NOCOL ((color_which)0)
struct gui_system_colour_ctx {
const char *name;
int length;
css_color css_colour;
colour *option_colour;
lwc_string *lwcstr;
color_which ui;
};
static struct gui_system_colour_ctx colour_list[] = {
@ -52,170 +86,198 @@ static struct gui_system_colour_ctx colour_list[] = {
SLEN("ActiveBorder"),
0xff000000,
&option_sys_colour_ActiveBorder,
NULL
NULL,
NOCOL
}, {
"ActiveCaption",
SLEN("ActiveCaption"),
0xffdddddd,
&option_sys_colour_ActiveCaption,
NULL
NULL,
B_WINDOW_TAB_COLOR
}, {
"AppWorkspace",
SLEN("AppWorkspace"),
0xffeeeeee,
&option_sys_colour_AppWorkspace,
NULL
NULL,
B_PANEL_BACKGROUND_COLOR
}, {
"Background",
SLEN("Background"),
0xff0000aa,
&option_sys_colour_Background,
NULL
NULL,
B_DESKTOP_COLOR
}, {
"ButtonFace",
SLEN("ButtonFace"),
0xffaaaaaa,
&option_sys_colour_ButtonFace,
NULL
NULL,
B_CONTROL_BACKGROUND_COLOR
}, {
"ButtonHighlight",
SLEN("ButtonHighlight"),
0xffdddddd,
&option_sys_colour_ButtonHighlight,
NULL
NULL,
B_CONTROL_HIGHLIGHT_COLOR
}, {
"ButtonShadow",
SLEN("ButtonShadow"),
0xffbbbbbb,
&option_sys_colour_ButtonShadow,
NULL
NULL,
NOCOL
}, {
"ButtonText",
SLEN("ButtonText"),
0xff000000,
&option_sys_colour_ButtonText,
NULL
NULL,
B_CONTROL_TEXT_COLOR
}, {
"CaptionText",
SLEN("CaptionText"),
0xff000000,
&option_sys_colour_CaptionText,
NULL
NULL,
NOCOL
}, {
"GrayText",
SLEN("GrayText"),
0xffcccccc,
&option_sys_colour_GrayText,
NULL
NULL,
NOCOL
}, {
"Highlight",
SLEN("Highlight"),
0xff0000ee,
&option_sys_colour_Highlight,
NULL
NULL,
NOCOL
}, {
"HighlightText",
SLEN("HighlightText"),
0xff000000,
&option_sys_colour_HighlightText,
NULL
NULL,
NOCOL
}, {
"InactiveBorder",
SLEN("InactiveBorder"),
0xffffffff,
&option_sys_colour_InactiveBorder,
NULL
NULL,
NOCOL
}, {
"InactiveCaption",
SLEN("InactiveCaption"),
0xffffffff,
&option_sys_colour_InactiveCaption,
NULL
NULL,
NOCOL
}, {
"InactiveCaptionText",
SLEN("InactiveCaptionText"),
0xffcccccc,
&option_sys_colour_InactiveCaptionText,
NULL
NULL,
NOCOL
}, {
"InfoBackground",
SLEN("InfoBackground"),
0xffaaaaaa,
&option_sys_colour_InfoBackground,
NULL
NULL,
B_TOOLTIP_BACKGROUND_COLOR
}, {
"InfoText",
SLEN("InfoText"),
0xff000000,
&option_sys_colour_InfoText,
NULL
NULL,
B_TOOLTIP_TEXT_COLOR
}, {
"Menu",
SLEN("Menu"),
0xffaaaaaa,
&option_sys_colour_Menu,
NULL
NULL,
B_MENU_BACKGROUND_COLOR
}, {
"MenuText",
SLEN("MenuText"),
0xff000000,
&option_sys_colour_MenuText,
NULL
NULL,
B_MENU_ITEM_TEXT_COLOR
}, {
"Scrollbar",
SLEN("Scrollbar"),
0xffaaaaaa,
&option_sys_colour_Scrollbar,
NULL
NULL,
NOCOL
}, {
"ThreeDDarkShadow",
SLEN("ThreeDDarkShadow"),
0xff555555,
&option_sys_colour_ThreeDDarkShadow,
NULL
NULL,
NOCOL
}, {
"ThreeDFace",
SLEN("ThreeDFace"),
0xffdddddd,
&option_sys_colour_ThreeDFace,
NULL
NULL,
NOCOL
}, {
"ThreeDHighlight",
SLEN("ThreeDHighlight"),
0xffaaaaaa,
&option_sys_colour_ThreeDHighlight,
NULL
NULL,
NOCOL
}, {
"ThreeDLightShadow",
SLEN("ThreeDLightShadow"),
0xff999999,
&option_sys_colour_ThreeDLightShadow,
NULL
NULL,
NOCOL
}, {
"ThreeDShadow",
SLEN("ThreeDShadow"),
0xff777777,
&option_sys_colour_ThreeDShadow,
NULL
NULL,
NOCOL
}, {
"Window",
SLEN("Window"),
0xffaaaaaa,
&option_sys_colour_Window,
NULL
NULL,
B_DOCUMENT_BACKGROUND_COLOR
}, {
"WindowFrame",
SLEN("WindowFrame"),
0xff000000,
&option_sys_colour_WindowFrame,
NULL
NULL,
NOCOL
}, {
"WindowText",
SLEN("WindowText"),
0xff000000,
&option_sys_colour_WindowText,
NULL
NULL,
B_DOCUMENT_TEXT_COLOR
},
};
@ -248,6 +310,8 @@ bool gui_system_colour_init(void)
}
}
nsbeos_update_system_ui_colors();
gui_system_colour_pw = colour_list;
return true;
@ -294,3 +358,27 @@ css_error gui_system_colour(void *pw, lwc_string *name, css_color *css_colour)
return CSS_INVALID;
}
void nsbeos_update_system_ui_colors(void)
{
unsigned int ccount;
for (ccount = 0; ccount < colour_list_len; ccount++) {
if (colour_list[ccount].ui == NOCOL)
continue;
rgb_color c = ui_color(colour_list[ccount].ui);
if (colour_list[ccount].ui == B_DESKTOP_COLOR) {
BScreen s;
c = s.DesktopColor();
}
//printf("uic[%d] = ui_color(%d) %02x %02x %02x %02x\n", ccount,
// colour_list[ccount].ui, c.red, c.green, c.blue, c.alpha);
colour_list[ccount].css_colour = 0xff000000
| ((((uint32_t)c.red << 16) & 0xff0000)
| ((c.green << 8) & 0x00ff00)
| ((c.blue) & 0x0000ff));
}
}