From 6be6fa1b2197ffe6e511c5eff9abe14d883f8478 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 3 Jan 2018 23:58:18 +0000 Subject: CSS utils: Handle new units in length conversion routines. This causes a ripple effect of all the callsites needing information they didn't have. --- desktop/textarea.c | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) (limited to 'desktop/textarea.c') diff --git a/desktop/textarea.c b/desktop/textarea.c index 149ca26b1..3fd4c9804 100644 --- a/desktop/textarea.c +++ b/desktop/textarea.c @@ -1803,6 +1803,10 @@ static void textarea_setup_text_offsets(struct textarea *ta) { int text_y_offset, text_y_offset_baseline; + ta->line_height = FIXTOINT(FMUL(FLTTOFIX(1.3), FDIV(FMUL( + nscss_screen_dpi, FDIV(INTTOFIX(ta->fstyle.size), + INTTOFIX(FONT_SIZE_SCALE))), F_72))); + text_y_offset = text_y_offset_baseline = ta->border_width; if (ta->flags & TEXTAREA_MULTILINE) { /* Multiline textarea */ @@ -1822,6 +1826,27 @@ static void textarea_setup_text_offsets(struct textarea *ta) } +/** + * Set font styles up for a textarea. + * + * \param[in] ta Textarea to update. + * \param[in] fstyle Font style to set in textarea. + * \param[in] selected_text Textarea selected text colour. + * \param[in] selected_bg Textarea selection background colour. + */ +static void textarea_set_text_style( + struct textarea *ta, + const plot_font_style_t *fstyle, + colour selected_text, + colour selected_bg) +{ + ta->fstyle = *fstyle; + + ta->sel_fstyle = *fstyle; + ta->sel_fstyle.foreground = selected_text; + ta->sel_fstyle.background = selected_bg; +} + /* exported interface, documented in textarea.h */ struct textarea *textarea_create(const textarea_flags flags, @@ -1861,11 +1886,10 @@ struct textarea *textarea_create(const textarea_flags flags, ret->border_width = setup->border_width; ret->border_col = setup->border_col; - ret->fstyle = setup->text; - - ret->sel_fstyle = setup->text; - ret->sel_fstyle.foreground = setup->selected_text; - ret->sel_fstyle.background = setup->selected_bg; + textarea_set_text_style(ret, + &setup->text, + setup->selected_text, + setup->selected_bg); ret->scroll_x = 0; ret->scroll_y = 0; @@ -3220,8 +3244,12 @@ void textarea_set_dimensions(struct textarea *ta, int width, int height) /* exported interface, documented in textarea.h */ -void textarea_set_layout(struct textarea *ta, int width, int height, - int top, int right, int bottom, int left) +void textarea_set_layout( + struct textarea *ta, + const plot_font_style_t *fstyle, + int width, int height, + int top, int right, + int bottom, int left) { struct rect r = {0, 0, 0, 0}; @@ -3232,6 +3260,10 @@ void textarea_set_layout(struct textarea *ta, int width, int height, ta->pad_bottom = bottom + ((ta->bar_x == NULL) ? 0 : SCROLLBAR_WIDTH); ta->pad_left = left; + textarea_set_text_style(ta, fstyle, + ta->sel_fstyle.foreground, + ta->sel_fstyle.background); + textarea_setup_text_offsets(ta); if (ta->flags & TEXTAREA_MULTILINE) { -- cgit v1.2.3