diff options
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/browser_history.c | 126 | ||||
-rw-r--r-- | desktop/browser_private.h | 3 | ||||
-rw-r--r-- | desktop/font_haru.h | 1 | ||||
-rw-r--r-- | desktop/knockout.c | 2 | ||||
-rw-r--r-- | desktop/options.h | 2 | ||||
-rw-r--r-- | desktop/plot_style.c | 15 | ||||
-rw-r--r-- | desktop/plot_style.h | 207 | ||||
-rw-r--r-- | desktop/scrollbar.c | 6 | ||||
-rw-r--r-- | desktop/system_colour.h | 2 | ||||
-rw-r--r-- | desktop/textarea.h | 3 |
10 files changed, 108 insertions, 259 deletions
diff --git a/desktop/browser_history.c b/desktop/browser_history.c index 5cd98cde6..d21c5bc25 100644 --- a/desktop/browser_history.c +++ b/desktop/browser_history.c @@ -37,6 +37,7 @@ #include "content/urldb.h" #include "netsurf/bitmap.h" +#include "desktop/system_colour.h" #include "desktop/gui_internal.h" #include "desktop/browser_history.h" #include "desktop/browser_private.h" @@ -235,6 +236,45 @@ static void browser_window_history__layout(struct history *history) history->height += BOTTOM_MARGIN / 2; } +/** plot style for drawing lines between nodes */ +static plot_style_t pstyle_line = { + .stroke_type = PLOT_OP_TYPE_SOLID, + .stroke_width = 2, +}; + +/** plot style for drawing background */ +static plot_style_t pstyle_bg = { + .fill_type = PLOT_OP_TYPE_SOLID, +}; + +/** plot style for drawing rectangle round unselected nodes */ +static plot_style_t pstyle_rect = { + .stroke_type = PLOT_OP_TYPE_SOLID, + .stroke_width = 1, +}; + +/** plot style for drawing rectangle round selected nodes */ +static plot_style_t pstyle_rect_sel = { + .stroke_type = PLOT_OP_TYPE_SOLID, + .stroke_width = 3, +}; + +/** plot style for font on unselected nodes */ +static plot_font_style_t pfstyle_node = { + .family = PLOT_FONT_FAMILY_SANS_SERIF, + .size = 8 * FONT_SIZE_SCALE, + .weight = 400, + .flags = FONTF_NONE, +}; + +/** plot style for font on unselected nodes */ +static plot_font_style_t pfstyle_node_sel = { + .family = PLOT_FONT_FAMILY_SANS_SERIF, + .size = 8 * FONT_SIZE_SCALE, + .weight = 900, + .flags = FONTF_NONE, +}; + /** * Recursively redraw a history_entry. * @@ -260,19 +300,25 @@ browser_window_history__redraw_entry(struct history *history, size_t char_offset; int actual_x; struct history_entry *child; - colour c = entry == history->current ? - HISTORY_COLOUR_SELECTED : HISTORY_COLOUR_FOREGROUND; int tailsize = 5; int xoffset = x - x0; int yoffset = y - y0; - plot_style_t pstyle_history_rect = { - .stroke_type = PLOT_OP_TYPE_SOLID, - .stroke_colour = c, - .stroke_width = entry == history->current ? 3 : 1, - }; - plot_font_style_t fstyle = *plot_style_font; + + plot_style_t *pstyle; + plot_font_style_t *pfstyle; + nserror res; + /* setup plot styles */ + if (entry == history->current) { + pstyle = &pstyle_rect_sel; + pfstyle = &pfstyle_node_sel; + } else { + pstyle = &pstyle_rect; + pfstyle = &pfstyle_node; + } + + /* setup clip area */ if (clip) { struct rect rect; rect.x0 = x0 + xoffset; @@ -289,14 +335,16 @@ browser_window_history__redraw_entry(struct history *history, plot->bitmap(entry->x + xoffset, entry->y + yoffset, WIDTH, HEIGHT, - entry->bitmap, 0xffffff, 0); + entry->bitmap, + 0xffffff, + 0); } if (!plot->rectangle(entry->x - 1 + xoffset, - entry->y - 1 + yoffset, - entry->x + xoffset + WIDTH, - entry->y + yoffset + HEIGHT, - &pstyle_history_rect)) { + entry->y - 1 + yoffset, + entry->x + xoffset + WIDTH, + entry->y + yoffset + HEIGHT, + pstyle)) { return false; } @@ -307,36 +355,42 @@ browser_window_history__redraw_entry(struct history *history, return false; } - fstyle.background = HISTORY_COLOUR_BACKGROUND; - fstyle.foreground = c; - fstyle.weight = entry == history->current ? 900 : 400; - if (!plot->text(entry->x + xoffset, entry->y + HEIGHT + 12 + yoffset, - entry->page.title, char_offset, &fstyle)) + if (!plot->text(entry->x + xoffset, + entry->y + HEIGHT + 12 + yoffset, + entry->page.title, + char_offset, + pfstyle)) { return false; + } + /* for each child node draw a line and recurse redraw into it */ for (child = entry->forward; child; child = child->next) { if (!plot->line(entry->x + WIDTH + xoffset, entry->y + HEIGHT / 2 + yoffset, - entry->x + WIDTH + tailsize + xoffset, - entry->y + HEIGHT / 2 + yoffset, - plot_style_stroke_history)) + entry->x + WIDTH + tailsize + xoffset, + entry->y + HEIGHT / 2 + yoffset, + &pstyle_line)) { return false; + } if (!plot->line(entry->x + WIDTH + tailsize + xoffset, - entry->y + HEIGHT / 2 + yoffset, - child->x - tailsize +xoffset, - child->y + HEIGHT / 2 + yoffset, - plot_style_stroke_history)) + entry->y + HEIGHT / 2 + yoffset, + child->x - tailsize +xoffset, + child->y + HEIGHT / 2 + yoffset, + &pstyle_line)) { return false; + } if (!plot->line(child->x - tailsize + xoffset, - child->y + HEIGHT / 2 + yoffset, - child->x + xoffset, child->y + + child->y + HEIGHT / 2 + yoffset, + child->x + xoffset, child->y + HEIGHT / 2 + yoffset, - plot_style_stroke_history)) + &pstyle_line)) { return false; + } if (!browser_window_history__redraw_entry(history, child, - x0, y0, x1, y1, x, y, clip, ctx)) + x0, y0, x1, y1, x, y, clip, ctx)) { return false; + } } return true; @@ -415,6 +469,17 @@ nserror browser_window_history_create(struct browser_window *bw) { struct history *history; + pstyle_bg.fill_colour = ns_system_colour_char("Window"); + pfstyle_node.background = pstyle_bg.fill_colour; + pfstyle_node_sel.background = pstyle_bg.fill_colour; + + pstyle_line.stroke_colour = ns_system_colour_char("GrayText"); + pstyle_rect.stroke_colour = pstyle_line.stroke_colour; + pfstyle_node.foreground = pstyle_line.stroke_colour; + + pstyle_rect_sel.stroke_colour = ns_system_colour_char("Highlight"); + pfstyle_node_sel.foreground = pstyle_rect_sel.stroke_colour; + bw->history = NULL; history = calloc(1, sizeof *history); @@ -426,6 +491,7 @@ nserror browser_window_history_create(struct browser_window *bw) history->height = BOTTOM_MARGIN / 2; bw->history = history; + return NSERROR_OK; } @@ -709,6 +775,7 @@ bool browser_window_history_redraw(struct browser_window *bw, if (!history->start) return true; + return browser_window_history__redraw_entry(history, history->start, 0, 0, 0, 0, 0, 0, false, ctx); } @@ -726,6 +793,7 @@ bool browser_window_history_redraw_rectangle(struct browser_window *bw, if (!history->start) return true; + return browser_window_history__redraw_entry(history, history->start, x0, y0, x1, y1, x, y, true, ctx); } diff --git a/desktop/browser_private.h b/desktop/browser_private.h index 64c698beb..072a894d6 100644 --- a/desktop/browser_private.h +++ b/desktop/browser_private.h @@ -26,9 +26,10 @@ #include <libwapcaplet/libwapcaplet.h> +#include "netsurf/types.h" #include "netsurf/browser_window.h" + #include "desktop/frame_types.h" -#include "desktop/plot_style.h" struct box; struct hlcache_handle; diff --git a/desktop/font_haru.h b/desktop/font_haru.h index 479f7deb0..988b9ba0a 100644 --- a/desktop/font_haru.h +++ b/desktop/font_haru.h @@ -26,7 +26,6 @@ #include <hpdf.h> -#include "desktop/plot_style.h" #include "desktop/font.h" bool haru_nsfont_apply_style(const plot_font_style_t *fstyle, diff --git a/desktop/knockout.c b/desktop/knockout.c index b930ef673..bcfc272eb 100644 --- a/desktop/knockout.c +++ b/desktop/knockout.c @@ -71,10 +71,10 @@ #include "utils/errors.h" #include "netsurf/bitmap.h" #include "content/content.h" +#include "netsurf/plotters.h" #include "desktop/gui_internal.h" #include "desktop/knockout.h" -#include "netsurf/plotters.h" /* Define to enable knockout debug */ #undef KNOCKOUT_DEBUG diff --git a/desktop/options.h b/desktop/options.h index 437d104e9..d91898c6e 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -30,7 +30,7 @@ #ifndef _NETSURF_DESKTOP_OPTIONS_H_ #define _NETSURF_DESKTOP_OPTIONS_H_ -#include "desktop/plot_style.h" +#include "netsurf/types.h" /* defines for system colour table */ #define NSOPTION_SYS_COLOUR_START NSOPTION_sys_colour_ActiveBorder diff --git a/desktop/plot_style.c b/desktop/plot_style.c index f9ba4bcbf..1f0ac39cf 100644 --- a/desktop/plot_style.c +++ b/desktop/plot_style.c @@ -16,14 +16,14 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/** - * \file desktop/plot_style.c +/** + * \file * \brief Plotter global styles. * * These plot styles are globaly available and used in many places. */ -#include "netsurf/plotters.h" +#include "netsurf/plot_style.h" static plot_style_t plot_style_fill_white_static = { .fill_type = PLOT_OP_TYPE_SOLID, @@ -152,15 +152,6 @@ static plot_style_t plot_style_stroke_lightwbasec_static = { }; plot_style_t *plot_style_stroke_lightwbasec = &plot_style_stroke_lightwbasec_static; -/* history styles */ - -/** stroke style for history core. */ -static plot_style_t plot_style_stroke_history_static = { - .stroke_type = PLOT_OP_TYPE_SOLID, - .stroke_colour = HISTORY_COLOUR_LINES, - .stroke_width = 2, -}; -plot_style_t *plot_style_stroke_history = &plot_style_stroke_history_static; /* Generic font style */ static const plot_font_style_t plot_style_font_static = { diff --git a/desktop/plot_style.h b/desktop/plot_style.h deleted file mode 100644 index 347c6e836..000000000 --- a/desktop/plot_style.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright 2004 James Bursa <bursa@users.sourceforge.net> - * - * This file is part of NetSurf, http://www.netsurf-browser.org/ - * - * NetSurf is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * NetSurf is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/** \file - * Plotter styles. - */ - -#ifndef _NETSURF_DESKTOP_PLOT_STYLE_H_ -#define _NETSURF_DESKTOP_PLOT_STYLE_H_ - -#include <stdint.h> - -/* html widget colours */ -#define WIDGET_BASEC 0xd9d9d9 -#define WIDGET_BLOBC 0x000000 - -/* Darken a colour by taking three quarters of each channel's intensity */ -#define darken_colour(c1) \ - ((((3 * (c1 & 0xff00ff)) >> 2) & 0xff00ff) | \ - (((3 * (c1 & 0x00ff00)) >> 2) & 0x00ff00)) - -/* Darken a colour by taking nine sixteenths of each channel's intensity */ -#define double_darken_colour(c1) \ - ((((9 * (c1 & 0xff00ff)) >> 4) & 0xff00ff) | \ - (((9 * (c1 & 0x00ff00)) >> 4) & 0x00ff00)) - -/* Lighten a colour by taking 12/16ths of each channel's intensity - * and adding a full 4/16ths intensity */ -#define lighten_colour(c1) \ - (((((3 * (c1 & 0xff00ff)) >> 2) + 0x400040) & 0xff00ff) | \ - ((((3 * (c1 & 0x00ff00)) >> 2) + 0x004000) & 0x00ff00)) - -/* Lighten a colour by taking 9/16ths of each channel's intensity - * and adding a full 7/16ths intensity */ -#define double_lighten_colour(c1) \ - (((((9 * (c1 & 0xff00ff)) >> 4) + 0x700070) & 0xff00ff) | \ - ((((9 * (c1 & 0x00ff00)) >> 4) + 0x007000) & 0x00ff00)) - -/* Blend two colours by taking half the intensity of each channel in the first - * colour and adding them to half the intensity of each channel in the second - * colour */ -#define blend_colour(c0, c1) \ - (((((c0 & 0xff00ff) + (c1 & 0xff00ff)) >> 1) & 0xff00ff) | \ - ((((c0 & 0x00ff00) + (c1 & 0x00ff00)) >> 1) & 0x00ff00)) - -/* Choose either black or white, depending on which is furthest from the - * percieved lightness of the supplied colour, c0. */ -#define colour_to_bw_furthest(c0) \ - ((((((c0 & 0x0000ff) * 77) >> 8) + \ - (((c0 & 0x00ff00) * 151) >> 16) + \ - (((c0 & 0xff0000) * 28) >> 24)) > \ - (0xff / 2)) ? 0x000000 : 0xffffff) - -/* Mix two colours according to the proportion given by p, where 0 <= p <= 255 - * p = 0 gives result ==> c1, p = 255 gives result ==> c0 */ -#define mix_colour(c0, c1, p) \ - ((((((c1 & 0xff00ff) * (255 - p)) + \ - ((c0 & 0xff00ff) * ( p)) ) >> 8) & 0xff00ff) | \ - (((((c1 & 0x00ff00) * (255 - p)) + \ - ((c0 & 0x00ff00) * ( p)) ) >> 8) & 0x00ff00)) - -/* get a bitmap pixel (image/bitmap.h) into a plot colour */ -#define pixel_to_colour(b) \ - b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24) - -/* Get the red channel from a colour */ -#define red_from_colour(c) \ - ((c ) & 0xff) - -/* Get the green channel from a colour */ -#define green_from_colour(c) \ - ((c >> 8) & 0xff) - -/* Get the blue channel from a colour */ -#define blue_from_colour(c) \ - ((c >> 16) & 0xff) - -/** - * Colour type: XBGR - */ -typedef uint32_t colour; - -/** - * Magical transparent value - */ -#define NS_TRANSPARENT 0x01000000 - -/** - * Type of plot operation - */ -typedef enum { - PLOT_OP_TYPE_NONE = 0, /**< No operation */ - PLOT_OP_TYPE_SOLID, /**< Solid colour */ - PLOT_OP_TYPE_DOT, /**< Dotted plot */ - PLOT_OP_TYPE_DASH, /**< Dashed plot */ -} plot_operation_type_t; - -/** - * Plot style for stroke/fill plotters - */ -typedef struct plot_style_s { - plot_operation_type_t stroke_type; /**< Stroke plot type */ - int stroke_width; /**< Width of stroke, in pixels */ - colour stroke_colour; /**< Colour of stroke */ - plot_operation_type_t fill_type; /**< Fill plot type */ - colour fill_colour; /**< Colour of fill */ -} plot_style_t; - -/** - * Generic font family type - */ -typedef enum { - PLOT_FONT_FAMILY_SANS_SERIF = 0, - PLOT_FONT_FAMILY_SERIF, - PLOT_FONT_FAMILY_MONOSPACE, - PLOT_FONT_FAMILY_CURSIVE, - PLOT_FONT_FAMILY_FANTASY, - PLOT_FONT_FAMILY_COUNT /**< Number of generic families */ -} plot_font_generic_family_t; - -/** - * Font plot flags - */ -typedef unsigned long plot_font_flags_t; -#define FONTF_NONE 0 -#define FONTF_ITALIC 1 -#define FONTF_OBLIQUE 2 -#define FONTF_SMALLCAPS 4 - -/** - * Scaling factor for font sizes - */ -#define FONT_SIZE_SCALE 1024 - -/** - * Font style for plotting - */ -typedef struct plot_font_style { - plot_font_generic_family_t family; /**< Generic family to plot with */ - int size; /**< Font size, in points * FONT_SIZE_SCALE */ - int weight; /**< Font weight: value in range [100,900] as per CSS */ - plot_font_flags_t flags; /**< Font flags */ - colour background; /**< Background colour to blend to, if appropriate */ - colour foreground; /**< Colour of text */ -} plot_font_style_t; - -/* global fill styles */ -extern plot_style_t *plot_style_fill_white; -extern plot_style_t *plot_style_fill_red; -extern plot_style_t *plot_style_fill_black; - -/* Box model debug outline styles for content, padding and margin edges */ -extern plot_style_t const * const plot_style_content_edge; -extern plot_style_t const * const plot_style_padding_edge; -extern plot_style_t const * const plot_style_margin_edge; - -/* Broken object replacement styles */ -extern plot_style_t const * const plot_style_broken_object; -extern plot_font_style_t const * const plot_fstyle_broken_object; - - -/* other styles */ -extern plot_style_t *plot_style_caret; -extern plot_style_t *plot_style_stroke_history; -extern plot_style_t *plot_style_fill_wbasec; -extern plot_style_t *plot_style_fill_darkwbasec; -extern plot_style_t *plot_style_fill_lightwbasec; -extern plot_style_t *plot_style_fill_wblobc; -extern plot_style_t *plot_style_stroke_wblobc; -extern plot_style_t *plot_style_stroke_darkwbasec; -extern plot_style_t *plot_style_stroke_lightwbasec; - -/* Default font style */ -extern plot_font_style_t const * const plot_style_font; - -#ifndef HISTORY_COLOUR_SELECTED -#define HISTORY_COLOUR_SELECTED 0xFF0000 -#endif - -#ifndef HISTORY_COLOUR_FOREGROUND -#define HISTORY_COLOUR_FOREGROUND 0x333333 -#endif - -#ifndef HISTORY_COLOUR_BACKGROUND -#define HISTORY_COLOUR_BACKGROUND 0xFFFFFF -#endif - -#ifndef HISTORY_COLOUR_LINES -#define HISTORY_COLOUR_LINES HISTORY_COLOUR_FOREGROUND -#endif - -#endif diff --git a/desktop/scrollbar.c b/desktop/scrollbar.c index b9e963a26..9a4d70fe4 100644 --- a/desktop/scrollbar.c +++ b/desktop/scrollbar.c @@ -29,14 +29,12 @@ #include "utils/messages.h" #include "utils/utils.h" #include "utils/nsoption.h" - #include "netsurf/browser_window.h" -#include "desktop/system_colour.h" #include "netsurf/mouse.h" -#include "desktop/scrollbar.h" #include "netsurf/plotters.h" -#include "desktop/plot_style.h" +#include "desktop/system_colour.h" +#include "desktop/scrollbar.h" struct scrollbar { bool horizontal; /* Horizontal scrollbar if true, else vertical diff --git a/desktop/system_colour.h b/desktop/system_colour.h index b5d4baad4..8e82818aa 100644 --- a/desktop/system_colour.h +++ b/desktop/system_colour.h @@ -26,7 +26,7 @@ #include <libcss/libcss.h> #include "utils/errors.h" -#include "desktop/plot_style.h" +#include "netsurf/types.h" /** css callback to obtain named system colours. */ css_error ns_system_colour(void *pw, lwc_string *name, css_color *color); diff --git a/desktop/textarea.h b/desktop/textarea.h index 74652f3a1..19162ff1b 100644 --- a/desktop/textarea.h +++ b/desktop/textarea.h @@ -28,8 +28,7 @@ #include <stdbool.h> #include "utils/utils.h" - -#include "desktop/plot_style.h" +#include "netsurf/plot_style.h" #include "netsurf/mouse.h" struct textarea; |