rich_label: allow width key to be a wfl formula

This commit is contained in:
Subhraman Sarkar 2024-09-04 12:09:25 +05:30 committed by Celtic Minstrel
parent 570d358110
commit e1c87a24a8
3 changed files with 7 additions and 4 deletions

View file

@ -192,7 +192,7 @@
super="$generic/widget_instance"
{DEFAULT_KEY "text_alignment" h_align "left"}
{DEFAULT_KEY "link_aware" bool false}
{DEFAULT_KEY "width" unsigned 500}
{DEFAULT_KEY "width" f_unsigned 500}
[/tag]
[tag]

View file

@ -887,7 +887,7 @@ builder_rich_label::builder_rich_label(const config& cfg)
: builder_styled_widget(cfg)
, text_alignment(decode_text_alignment(cfg["text_alignment"]))
, link_aware(cfg["link_aware"].to_bool(true))
, width(cfg["width"].to_int(500))
, width(cfg["width"], 500)
{
}
@ -898,10 +898,13 @@ std::unique_ptr<widget> builder_rich_label::build() const
const auto conf = lbl->cast_config_to<rich_label_definition>();
assert(conf);
const wfl::map_formula_callable& size = get_screen_size_variables();
const unsigned w = width(size);
lbl->set_text_alignment(text_alignment);
lbl->set_link_aware(link_aware);
lbl->set_link_color(conf->link_color);
lbl->set_width(width);
lbl->set_width(w);
DBG_GUI_G << "Window builder: placed rich_label '" << id << "' with definition '"
<< definition << "'.";

View file

@ -316,7 +316,7 @@ struct builder_rich_label : public builder_styled_widget
PangoAlignment text_alignment;
bool link_aware;
unsigned width;
typed_formula<unsigned> width;
};
} // namespace implementation