Make ui::progress_bar capable of having any element as a child
This commit is contained in:
parent
ecfda88eac
commit
c706032df5
2 changed files with 14 additions and 4 deletions
|
|
@ -1,19 +1,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <psemek/ui/element.hpp>
|
#include <psemek/ui/single_container.hpp>
|
||||||
#include <psemek/ui/label.hpp>
|
#include <psemek/ui/label.hpp>
|
||||||
|
|
||||||
namespace psemek::ui
|
namespace psemek::ui
|
||||||
{
|
{
|
||||||
|
|
||||||
struct progress_bar
|
struct progress_bar
|
||||||
: element
|
: single_container
|
||||||
{
|
{
|
||||||
virtual float value() const { return value_; }
|
virtual float value() const { return value_; }
|
||||||
virtual void set_value(float value);
|
virtual void set_value(float value);
|
||||||
|
|
||||||
virtual struct label * label() { return nullptr; }
|
virtual struct label * label();
|
||||||
virtual struct label const * label() const { return nullptr; }
|
virtual struct label const * label() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float value_ = 0.f;
|
float value_ = 0.f;
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,14 @@ namespace psemek::ui
|
||||||
value_ = geom::clamp(value, {0.f, 1.f});
|
value_ = geom::clamp(value, {0.f, 1.f});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label * progress_bar::label()
|
||||||
|
{
|
||||||
|
return dynamic_cast<struct label *>(child().get());
|
||||||
|
}
|
||||||
|
|
||||||
|
label const * progress_bar::label() const
|
||||||
|
{
|
||||||
|
return dynamic_cast<struct label const *>(child().get());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue