Support retrieving buttons from spinbox

This commit is contained in:
Nikita Lisitsa 2022-05-17 23:14:33 +03:00
parent 3f9275b2ad
commit 59de6682ba
2 changed files with 13 additions and 1 deletions

View file

@ -8,6 +8,7 @@ namespace psemek::ui
{
struct label;
struct button;
struct spinbox
: element
@ -28,7 +29,9 @@ namespace psemek::ui
virtual void on_value_changed(on_value_changed_callback callback, bool notify = true);
virtual struct label * label() { return nullptr; }
virtual struct label * label() const { return nullptr; }
virtual button * dec_button() const { return nullptr; }
virtual button * inc_button() const { return nullptr; }
protected:
virtual void post_value_changed();

View file

@ -692,6 +692,9 @@ namespace psemek::ui
child_ = layout;
children_range_[0] = child_.get();
child_->set_parent(this);
inc_button_ = inc_button.get();
dec_button_ = dec_button.get();
}
geom::box<float, 2> size_constraints() const override
@ -717,6 +720,9 @@ namespace psemek::ui
void draw(painter &) const override
{}
button * dec_button() const override { return dec_button_; }
button * inc_button() const override { return inc_button_; }
~spinbox_impl()
{
release_children();
@ -725,6 +731,9 @@ namespace psemek::ui
private:
std::shared_ptr<element> child_;
element * children_range_[1] {nullptr};
button * inc_button_;
button * dec_button_;
};
}