GUI2/Label: properly overload update_canvas

Previously, I was handling updating the label alpha in the set_text_alpha function, which meant it needed
to be called from the builder in order for that variable to be properly set on a newly constructed label.
This properly adds it to the update_canvas and changes set_text_alpha to match the other setter formats
that require canvas updates.
This commit is contained in:
Charles Dang 2020-12-12 02:23:50 +11:00
parent 2a152a6f66
commit 22647c388a
2 changed files with 14 additions and 4 deletions

View file

@ -61,15 +61,23 @@ label::label(const implementation::builder_label& builder)
std::bind(&label::signal_handler_mouse_leave, this, std::placeholders::_3));
}
void label::set_text_alpha(unsigned short alpha)
void label::update_canvas()
{
text_alpha_ = alpha;
// Inherit.
styled_widget::update_canvas();
for(auto& tmp : get_canvases()) {
tmp.set_variable("text_alpha", wfl::variant(text_alpha_));
}
}
set_is_dirty(true);
void label::set_text_alpha(unsigned short alpha)
{
if(alpha != text_alpha_) {
text_alpha_ = alpha;
update_canvas();
set_is_dirty(true);
}
}
void label::set_active(const bool active)
@ -331,7 +339,6 @@ widget* builder_label::build() const
assert(conf);
lbl->set_text_alignment(text_alignment);
lbl->set_text_alpha(ALPHA_OPAQUE);
lbl->set_link_aware(conf->link_aware);
lbl->set_link_color(conf->link_color);

View file

@ -87,6 +87,9 @@ public:
return !tooltip().empty() || get_link_aware();
}
/** See @ref styled_widget::update_canvas. */
virtual void update_canvas() override;
/***** ***** ***** setters / getters for members ***** ****** *****/
void set_can_wrap(const bool wrap)