GUI2/Canvas: allow text shape to set outline (resolves #8398)

This commit is contained in:
Charles Dang 2024-02-24 18:30:33 -05:00
parent dd4aec0cdb
commit 08fc993c16
3 changed files with 8 additions and 2 deletions

View File

@ -147,6 +147,7 @@
{DEFAULT_KEY "text_link_aware" f_bool false}
{DEFAULT_KEY "text_link_color" string "#ffff00"}
{DEFAULT_KEY "text_wrap_mode" f_unsigned 0}
{DEFAULT_KEY "outline" f_bool false}
{DEFAULT_KEY "h" f_unsigned 0}
{DEFAULT_KEY "w" f_unsigned 0}
{DEFAULT_KEY "x" f_unsigned 0}

View File

@ -412,6 +412,7 @@ text_shape::text_shape(const config& cfg)
, highlight_start_(cfg["highlight_start"], 0)
, highlight_end_(cfg["highlight_end"], 0)
, highlight_color_(cfg["highlight_color"], color_t::from_hex_string("215380"))
, outline_(cfg["outline"], false)
{
if(!font_size_.has_formula()) {
VALIDATE(font_size_(), _("Text has a font size of 0."));
@ -441,7 +442,6 @@ void text_shape::draw(wfl::map_formula_callable& variables)
text_renderer.set_highlight_area(highlight_start_(variables), highlight_end_(variables), highlight_color_(variables));
text_renderer
.set_link_aware(link_aware_(variables))
.set_link_color(link_color_(variables))
@ -457,7 +457,8 @@ void text_shape::draw(wfl::map_formula_callable& variables)
.set_ellipse_mode(variables.has_key("text_wrap_mode")
? static_cast<PangoEllipsizeMode>(variables.query_value("text_wrap_mode").as_int())
: PANGO_ELLIPSIZE_END)
.set_characters_per_line(characters_per_line_);
.set_characters_per_line(characters_per_line_)
.set_add_outline(outline_(variables));
wfl::map_formula_callable local_variables(variables);
const auto [tw, th] = text_renderer.get_size();

View File

@ -451,8 +451,12 @@ private:
/** Start and end offsets for highlight */
typed_formula<int> highlight_start_;
typed_formula<int> highlight_end_;
/** The color to be used for highlighting */
typed_formula<color_t> highlight_color_;
/** Whether to apply a text outline. */
typed_formula<bool> outline_;
};
}