summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-02-09 22:55:31 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2013-02-09 22:55:31 +0000
commitceb1668a8aede4d517a843e89361429a48a636b6 (patch)
treed44dd06aac6ac878466b837378d11fd5248c97ac /render
parent10edbc45bd43f1e6d1a5826f3321b7d0474fa3ff (diff)
downloadnetsurf-ceb1668a8aede4d517a843e89361429a48a636b6.tar.gz
netsurf-ceb1668a8aede4d517a843e89361429a48a636b6.tar.bz2
Choose pretty colours for selection.
Diffstat (limited to 'render')
-rw-r--r--render/box_textarea.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/render/box_textarea.c b/render/box_textarea.c
index 2bbeab31e..7f38ade5e 100644
--- a/render/box_textarea.c
+++ b/render/box_textarea.c
@@ -259,13 +259,21 @@ bool box_textarea_create_textarea(html_content *html,
ta_setup.pad_right = 4;
ta_setup.pad_bottom = 4;
ta_setup.pad_left = 4;
+
+ /* Set remaining data */
ta_setup.border_width = 0;
ta_setup.border_col = 0x000000;
- ta_setup.selected_text = 0xffffff;
- ta_setup.selected_bg = 0x000000;
ta_setup.text = fstyle;
- ta_setup.text.foreground = 0x000000;
ta_setup.text.background = NS_TRANSPARENT;
+ /* Make selected text either black or white, as gives greatest contrast
+ * with background colour. (Calc lightness of background colour and
+ * choose the one the lightness is furthest from.) */
+ ta_setup.selected_text =
+ (((((fstyle.foreground & 0x0000ff) ) * 19) / 64 +
+ (((fstyle.foreground & 0x00ff00) >> 8) * 38) / 64 +
+ (((fstyle.foreground & 0xff0000) >> 16) * 7) / 64) >
+ (0xff / 2)) ? 0x000000 : 0xffffff;
+ ta_setup.selected_bg = fstyle.foreground;
/* Hand reference to dom text over to gadget */
gadget->data.text.initial = dom_text;