perform full repaint when a label changes text

This commit is contained in:
hippoz 2022-03-29 07:00:03 +03:00
parent 596b0e530f
commit e10daab4d0
Signed by: hippoz
GPG key ID: 7C52899193467641
3 changed files with 11 additions and 5 deletions

View file

@ -6,15 +6,17 @@
namespace Raven { namespace Raven {
class Label : public Widget { class Label : public Widget {
DEF_WIDGET_STYLE_PROP(text, std::string, "")
private: private:
std::string m_text;
public: public:
Label(std::string text) Label(std::string text)
: Widget() : Widget()
, m_text(text) {} , m_text(text) {}
~Label() {} ~Label() {}
std::string &get_text() { return m_text; }
void set_text(std::string text) { m_text = text; wants_full_repaint(); }
protected: protected:
void on_paint(); void on_paint();
void on_init(); void on_init();

View file

@ -45,10 +45,14 @@ void Widget::do_generic_paint() {
} }
void Widget::wants_repaint() { void Widget::wants_repaint() {
// TODOO: not necessary // TODO: not necessary?
m_window->widget_repaint(this); m_window->widget_repaint(this);
} }
void Widget::wants_full_repaint() {
m_window->dispatch_full_repaint();
}
void Widget::handle_repaint(WidgetRepaintRequestedEvent &event) { void Widget::handle_repaint(WidgetRepaintRequestedEvent &event) {
// immediately accept the event - we will do our own propagation logic // immediately accept the event - we will do our own propagation logic
event.accept(); event.accept();

View file

@ -46,7 +46,7 @@ public:
void set_window(Window *window); void set_window(Window *window);
std::shared_ptr<TopLevelStyles> get_styles() { return m_styles; } std::shared_ptr<TopLevelStyles> get_styles() { return m_styles; }
void set__styles(std::shared_ptr<TopLevelStyles> styles) { m_styles = styles; wants_repaint(); } void set_styles(std::shared_ptr<TopLevelStyles> styles) { m_styles = styles; wants_repaint(); }
void set_did_init(bool did_init) { m_did_init = did_init; } void set_did_init(bool did_init) { m_did_init = did_init; }
bool get_did_init() { return m_did_init; } bool get_did_init() { return m_did_init; }
@ -61,7 +61,7 @@ public:
void dispatch_event(Event &event); void dispatch_event(Event &event);
void wants_repaint(); void wants_repaint();
void wants_full_repaint();
virtual ~Widget() {}; virtual ~Widget() {};
protected: protected: