Pick the CSS system colours from the pens in the screen DrawInfo table, and force

repicking them if the screen changes.
Think these are right - some of the CSS descriptions are a bit ambiguous.

svn path=/trunk/netsurf/; revision=11532
This commit is contained in:
Chris Young 2011-01-30 17:30:32 +00:00
parent 541864d501
commit 2cc738f2f0
2 changed files with 62 additions and 0 deletions

View File

@ -536,6 +536,9 @@ void ami_openscreen(void)
} }
} }
dri = GetScreenDrawInfo(scrn); dri = GetScreenDrawInfo(scrn);
gui_system_colour_finalize();
gui_system_colour_init();
} }
void ami_openscreenfirst(void) void ami_openscreenfirst(void)

View File

@ -21,16 +21,22 @@
* *
*/ */
#include "amiga/gui.h"
#include "utils/utils.h" #include "utils/utils.h"
#include "utils/log.h" #include "utils/log.h"
#include "desktop/gui.h" #include "desktop/gui.h"
#include "desktop/options.h" #include "desktop/options.h"
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <intuition/screens.h>
struct gui_system_colour_ctx { struct gui_system_colour_ctx {
const char *name; const char *name;
int length; int length;
css_color colour; css_color colour;
colour *option_colour; colour *option_colour;
UWORD amiga_pen;
lwc_string *lwcstr; lwc_string *lwcstr;
}; };
@ -40,162 +46,189 @@ static struct gui_system_colour_ctx colour_list[] = {
SLEN("ActiveBorder"), SLEN("ActiveBorder"),
0xff000000, 0xff000000,
&option_sys_colour_ActiveBorder, &option_sys_colour_ActiveBorder,
FILLPEN,
NULL NULL
}, { }, {
"ActiveCaption", "ActiveCaption",
SLEN("ActiveCaption"), SLEN("ActiveCaption"),
0xffdddddd, 0xffdddddd,
&option_sys_colour_ActiveCaption, &option_sys_colour_ActiveCaption,
FILLPEN,
NULL NULL
}, { }, {
"AppWorkspace", "AppWorkspace",
SLEN("AppWorkspace"), SLEN("AppWorkspace"),
0xffeeeeee, 0xffeeeeee,
&option_sys_colour_AppWorkspace, &option_sys_colour_AppWorkspace,
BACKGROUNDPEN,
NULL NULL
}, { }, {
"Background", "Background",
SLEN("Background"), SLEN("Background"),
0xff0000aa, 0xff0000aa,
&option_sys_colour_Background, &option_sys_colour_Background,
BACKGROUNDPEN,
NULL NULL
}, { }, {
"ButtonFace", "ButtonFace",
SLEN("ButtonFace"), SLEN("ButtonFace"),
0xffaaaaaa, 0xffaaaaaa,
&option_sys_colour_ButtonFace, &option_sys_colour_ButtonFace,
FOREGROUNDPEN,
NULL NULL
}, { }, {
"ButtonHighlight", "ButtonHighlight",
SLEN("ButtonHighlight"), SLEN("ButtonHighlight"),
0xffdddddd, 0xffdddddd,
&option_sys_colour_ButtonHighlight, &option_sys_colour_ButtonHighlight,
FORESHINEPEN,
NULL NULL
}, { }, {
"ButtonShadow", "ButtonShadow",
SLEN("ButtonShadow"), SLEN("ButtonShadow"),
0xffbbbbbb, 0xffbbbbbb,
&option_sys_colour_ButtonShadow, &option_sys_colour_ButtonShadow,
FORESHADOWPEN,
NULL NULL
}, { }, {
"ButtonText", "ButtonText",
SLEN("ButtonText"), SLEN("ButtonText"),
0xff000000, 0xff000000,
&option_sys_colour_ButtonText, &option_sys_colour_ButtonText,
TEXTPEN,
NULL NULL
}, { }, {
"CaptionText", "CaptionText",
SLEN("CaptionText"), SLEN("CaptionText"),
0xff000000, 0xff000000,
&option_sys_colour_CaptionText, &option_sys_colour_CaptionText,
FILLTEXTPEN,
NULL NULL
}, { }, {
"GrayText", "GrayText",
SLEN("GrayText"), SLEN("GrayText"),
0xffcccccc, 0xffcccccc,
&option_sys_colour_GrayText, &option_sys_colour_GrayText,
DISABLEDTEXTPEN,
NULL NULL
}, { }, {
"Highlight", "Highlight",
SLEN("Highlight"), SLEN("Highlight"),
0xff0000ee, 0xff0000ee,
&option_sys_colour_Highlight, &option_sys_colour_Highlight,
SELECTPEN,
NULL NULL
}, { }, {
"HighlightText", "HighlightText",
SLEN("HighlightText"), SLEN("HighlightText"),
0xff000000, 0xff000000,
&option_sys_colour_HighlightText, &option_sys_colour_HighlightText,
SELECTTEXTPEN,
NULL NULL
}, { }, {
"InactiveBorder", "InactiveBorder",
SLEN("InactiveBorder"), SLEN("InactiveBorder"),
0xffffffff, 0xffffffff,
&option_sys_colour_InactiveBorder, &option_sys_colour_InactiveBorder,
INACTIVEFILLPEN,
NULL NULL
}, { }, {
"InactiveCaption", "InactiveCaption",
SLEN("InactiveCaption"), SLEN("InactiveCaption"),
0xffffffff, 0xffffffff,
&option_sys_colour_InactiveCaption, &option_sys_colour_InactiveCaption,
INACTIVEFILLPEN,
NULL NULL
}, { }, {
"InactiveCaptionText", "InactiveCaptionText",
SLEN("InactiveCaptionText"), SLEN("InactiveCaptionText"),
0xffcccccc, 0xffcccccc,
&option_sys_colour_InactiveCaptionText, &option_sys_colour_InactiveCaptionText,
INACTIVEFILLTEXTPEN,
NULL NULL
}, { }, {
"InfoBackground", "InfoBackground",
SLEN("InfoBackground"), SLEN("InfoBackground"),
0xffaaaaaa, 0xffaaaaaa,
&option_sys_colour_InfoBackground, &option_sys_colour_InfoBackground,
BACKGROUNDPEN, /* This is wrong, HelpHint backgrounds are pale yellow but doesn't seem to be a DrawInfo pen defined for it. */
NULL NULL
}, { }, {
"InfoText", "InfoText",
SLEN("InfoText"), SLEN("InfoText"),
0xff000000, 0xff000000,
&option_sys_colour_InfoText, &option_sys_colour_InfoText,
TEXTPEN,
NULL NULL
}, { }, {
"Menu", "Menu",
SLEN("Menu"), SLEN("Menu"),
0xffaaaaaa, 0xffaaaaaa,
&option_sys_colour_Menu, &option_sys_colour_Menu,
MENUBACKGROUNDPEN,
NULL NULL
}, { }, {
"MenuText", "MenuText",
SLEN("MenuText"), SLEN("MenuText"),
0xff000000, 0xff000000,
&option_sys_colour_MenuText, &option_sys_colour_MenuText,
MENUTEXTPEN,
NULL NULL
}, { }, {
"Scrollbar", "Scrollbar",
SLEN("Scrollbar"), SLEN("Scrollbar"),
0xffaaaaaa, 0xffaaaaaa,
&option_sys_colour_Scrollbar, &option_sys_colour_Scrollbar,
FOREGROUNDPEN, /* or FILLPEN, see GetGUIAttrs() */
NULL NULL
}, { }, {
"ThreeDDarkShadow", "ThreeDDarkShadow",
SLEN("ThreeDDarkShadow"), SLEN("ThreeDDarkShadow"),
0xff555555, 0xff555555,
&option_sys_colour_ThreeDDarkShadow, &option_sys_colour_ThreeDDarkShadow,
FORESHADOWPEN,
NULL NULL
}, { }, {
"ThreeDFace", "ThreeDFace",
SLEN("ThreeDFace"), SLEN("ThreeDFace"),
0xffdddddd, 0xffdddddd,
&option_sys_colour_ThreeDFace, &option_sys_colour_ThreeDFace,
FOREGROUNDPEN,
NULL NULL
}, { }, {
"ThreeDHighlight", "ThreeDHighlight",
SLEN("ThreeDHighlight"), SLEN("ThreeDHighlight"),
0xffaaaaaa, 0xffaaaaaa,
&option_sys_colour_ThreeDHighlight, &option_sys_colour_ThreeDHighlight,
FORESHINEPEN,
NULL NULL
}, { }, {
"ThreeDLightShadow", "ThreeDLightShadow",
SLEN("ThreeDLightShadow"), SLEN("ThreeDLightShadow"),
0xff999999, 0xff999999,
&option_sys_colour_ThreeDLightShadow, &option_sys_colour_ThreeDLightShadow,
HALFSHINEPEN,
NULL NULL
}, { }, {
"ThreeDShadow", "ThreeDShadow",
SLEN("ThreeDShadow"), SLEN("ThreeDShadow"),
0xff777777, 0xff777777,
&option_sys_colour_ThreeDShadow, &option_sys_colour_ThreeDShadow,
HALFSHADOWPEN,
NULL NULL
}, { }, {
"Window", "Window",
SLEN("Window"), SLEN("Window"),
0xffaaaaaa, 0xffaaaaaa,
&option_sys_colour_Window, &option_sys_colour_Window,
BACKGROUNDPEN,
NULL NULL
}, { }, {
"WindowFrame", "WindowFrame",
SLEN("WindowFrame"), SLEN("WindowFrame"),
0xff000000, 0xff000000,
&option_sys_colour_WindowFrame, &option_sys_colour_WindowFrame,
INACTIVEFILLPEN,
NULL NULL
}, { }, {
@ -203,6 +236,7 @@ static struct gui_system_colour_ctx colour_list[] = {
SLEN("WindowText"), SLEN("WindowText"),
0xff000000, 0xff000000,
&option_sys_colour_WindowText, &option_sys_colour_WindowText,
INACTIVEFILLTEXTPEN,
NULL NULL
}, },
@ -212,6 +246,7 @@ static struct gui_system_colour_ctx colour_list[] = {
static struct gui_system_colour_ctx *gui_system_colour_pw = NULL; static struct gui_system_colour_ctx *gui_system_colour_pw = NULL;
css_color ami_css_colour_from_pen(struct Screen *screen, UWORD pen);
bool gui_system_colour_init(void) bool gui_system_colour_init(void)
{ {
@ -234,6 +269,10 @@ bool gui_system_colour_init(void)
if (*(colour_list[ccount].option_colour) != 0) { if (*(colour_list[ccount].option_colour) != 0) {
colour_list[ccount].colour = *(colour_list[ccount].option_colour); colour_list[ccount].colour = *(colour_list[ccount].option_colour);
} }
else if(scrn) {
colour_list[ccount].colour =
ami_css_colour_from_pen(scrn, colour_list[ccount].amiga_pen);
}
} }
gui_system_colour_pw = colour_list; gui_system_colour_pw = colour_list;
@ -248,6 +287,8 @@ void gui_system_colour_finalize(void)
for (ccount = 0; ccount < colour_list_len; ccount++) { for (ccount = 0; ccount < colour_list_len; ccount++) {
lwc_string_unref(colour_list[ccount].lwcstr); lwc_string_unref(colour_list[ccount].lwcstr);
} }
gui_system_colour_pw = NULL;
} }
colour gui_system_colour_char(char *name) colour gui_system_colour_char(char *name)
@ -282,3 +323,21 @@ css_error gui_system_colour(void *pw, lwc_string *name, css_color *colour)
return CSS_INVALID; return CSS_INVALID;
} }
css_color ami_css_colour_from_pen(struct Screen *screen, UWORD pen)
{
css_color colour = 0x00000000;
struct DrawInfo *drinfo = GetScreenDrawInfo(screen);
if(drinfo == NULL) return 0x00000000;
/* Get the colour of the pen being used for "pen", and force it opaque */
GetRGB32(screen->ViewPort.ColorMap, drinfo->dri_Pens[pen], 1, (ULONG *)&colour);
colour |= 0xff000000;
// printf("Pen %ld\n Palette entry %ld\n Colour %lx\n", pen, drinfo->dri_Pens[pen], colour);
FreeScreenDrawInfo(screen, drinfo);
return colour;
}