mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-28 20:27:38 +00:00
rich_label: allow width key to be a wfl formula
This commit is contained in:
parent
570d358110
commit
e1c87a24a8
@ -192,7 +192,7 @@
|
|||||||
super="$generic/widget_instance"
|
super="$generic/widget_instance"
|
||||||
{DEFAULT_KEY "text_alignment" h_align "left"}
|
{DEFAULT_KEY "text_alignment" h_align "left"}
|
||||||
{DEFAULT_KEY "link_aware" bool false}
|
{DEFAULT_KEY "link_aware" bool false}
|
||||||
{DEFAULT_KEY "width" unsigned 500}
|
{DEFAULT_KEY "width" f_unsigned 500}
|
||||||
|
|
||||||
[/tag]
|
[/tag]
|
||||||
[tag]
|
[tag]
|
||||||
|
@ -887,7 +887,7 @@ builder_rich_label::builder_rich_label(const config& cfg)
|
|||||||
: builder_styled_widget(cfg)
|
: builder_styled_widget(cfg)
|
||||||
, text_alignment(decode_text_alignment(cfg["text_alignment"]))
|
, text_alignment(decode_text_alignment(cfg["text_alignment"]))
|
||||||
, link_aware(cfg["link_aware"].to_bool(true))
|
, 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>();
|
const auto conf = lbl->cast_config_to<rich_label_definition>();
|
||||||
assert(conf);
|
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_text_alignment(text_alignment);
|
||||||
lbl->set_link_aware(link_aware);
|
lbl->set_link_aware(link_aware);
|
||||||
lbl->set_link_color(conf->link_color);
|
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 '"
|
DBG_GUI_G << "Window builder: placed rich_label '" << id << "' with definition '"
|
||||||
<< definition << "'.";
|
<< definition << "'.";
|
||||||
|
@ -316,7 +316,7 @@ struct builder_rich_label : public builder_styled_widget
|
|||||||
|
|
||||||
PangoAlignment text_alignment;
|
PangoAlignment text_alignment;
|
||||||
bool link_aware;
|
bool link_aware;
|
||||||
unsigned width;
|
typed_formula<unsigned> width;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace implementation
|
} // namespace implementation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user