diff options
author | Vincent Sanders <vince@kyllikki.org> | 2017-03-01 12:50:30 +0000 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2017-03-01 12:50:30 +0000 |
commit | 2f5e5620e218d317d5e853fd4ee9d9123b346610 (patch) | |
tree | 51a288d24f3f84699723ace7aed23eaa1f1d4df2 /desktop/scrollbar.c | |
parent | e72b89ac3d691acb5c306c1565eaa1e559495ec8 (diff) | |
download | netsurf-2f5e5620e218d317d5e853fd4ee9d9123b346610.tar.gz netsurf-2f5e5620e218d317d5e853fd4ee9d9123b346610.tar.bz2 |
Change interface to system colours to allow reporting of errors
Allow system colour interface to report errors instead of silently
failing and propogate the errors. This also fixes teh system colour
documentation.
Diffstat (limited to 'desktop/scrollbar.c')
-rw-r--r-- | desktop/scrollbar.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c index 4f3043416..04326965c 100644 --- a/desktop/scrollbar.c +++ b/desktop/scrollbar.c @@ -228,23 +228,31 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y, struct rect rect; nserror res; - colour bg_fill_colour = ns_system_colour_char("Scrollbar"); - colour fg_fill_colour = ns_system_colour_char("ButtonFace"); - colour arrow_fill_colour = ns_system_colour_char("ButtonText"); - plot_style_t bg_fill_style = { .fill_type = PLOT_OP_TYPE_SOLID, - .fill_colour = bg_fill_colour }; plot_style_t fg_fill_style = { .fill_type = PLOT_OP_TYPE_SOLID, - .fill_colour = fg_fill_colour }; plot_style_t arrow_fill_style = { .fill_type = PLOT_OP_TYPE_SOLID, - .fill_colour = arrow_fill_colour }; + res = ns_system_colour_char("Scrollbar", &bg_fill_style.fill_colour); + if (res != NSERROR_OK) { + return res; + } + + res = ns_system_colour_char("ButtonFace", &fg_fill_style.fill_colour); + if (res != NSERROR_OK) { + return res; + } + + res = ns_system_colour_char("ButtonText", &arrow_fill_style.fill_colour); + if (res != NSERROR_OK) { + return res; + } + area.x0 = x; area.y0 = y; area.x1 = x + (s->horizontal ? s->length : SCROLLBAR_WIDTH) - 1; @@ -277,7 +285,8 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y, /* scrollbar is horizontal */ /* scrollbar outline */ - res = scrollbar_rectangle(ctx, &area, bg_fill_colour, true); + res = scrollbar_rectangle(ctx, &area, + bg_fill_style.fill_colour, true); if (res != NSERROR_OK) { return false; } @@ -287,7 +296,8 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y, rect.y0 = area.y0 + 1; rect.x1 = area.x0 + w - 2; rect.y1 = area.y1 - 1; - res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false); + res = scrollbar_rectangle(ctx, &rect, + fg_fill_style.fill_colour, false); if (res != NSERROR_OK) { return false; } @@ -329,7 +339,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y, rect.y0 = area.y0 + 1; rect.x1 = bar_c1; rect.y1 = area.y1 - 1; - res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false); + res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false); if (res != NSERROR_OK) { return false; } @@ -348,7 +358,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y, rect.y0 = area.y0 + 1; rect.x1 = area.x1 - 1; rect.y1 = area.y1 - 1; - res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false); + res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false); if (res != NSERROR_OK) { return false; } @@ -378,7 +388,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y, /* scrollbar is vertical */ /* outline */ - res = scrollbar_rectangle(ctx, &area, bg_fill_colour, true); + res = scrollbar_rectangle(ctx, &area, bg_fill_style.fill_colour, true); if (res != NSERROR_OK) { return false; } @@ -388,7 +398,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y, rect.y0 = area.y0 + 1; rect.x1 = area.x1 - 1; rect.y1 = area.y0 + w - 2; - res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false); + res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false); if (res != NSERROR_OK) { return false; } @@ -430,7 +440,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y, rect.y0 = bar_c0; rect.x1 = area.x1 - 1; rect.y1 = bar_c1; - res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false); + res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false); if (res != NSERROR_OK) { return false; } @@ -449,7 +459,7 @@ bool scrollbar_redraw(struct scrollbar *s, int x, int y, rect.y0 = area.y1 - w + 2; rect.x1 = area.x1 - 1; rect.y1 = area.y1 - 1; - res = scrollbar_rectangle(ctx, &rect, fg_fill_colour, false); + res = scrollbar_rectangle(ctx, &rect, fg_fill_style.fill_colour, false); if (res != NSERROR_OK) { return false; } |