Keep track of active widgets inside the Window

This commit is contained in:
hippoz 2022-03-21 21:51:51 +02:00
parent 9c267cc87b
commit 24c139b917
Signed by: hippoz
GPG key ID: 7C52899193467641
2 changed files with 7 additions and 0 deletions

View file

@ -119,6 +119,9 @@ void Widget::handle_mouse_button_event(MouseButtonEvent &event) {
on_mouse_button(event); on_mouse_button(event);
if (m_is_active && m_window)
m_window->set_active_widget(this);
if (m_consumes_hits) if (m_consumes_hits)
event.accept(); event.accept();
} }

View file

@ -11,6 +11,7 @@ namespace Raven {
class Window { class Window {
private: private:
Widget *m_focused_widget { nullptr }; Widget *m_focused_widget { nullptr };
Widget *m_active_widget { nullptr };
Widget *m_main_widget { nullptr }; Widget *m_main_widget { nullptr };
Box m_current_geometry { 0, 0, 800, 600 }; Box m_current_geometry { 0, 0, 800, 600 };
Painter m_painter {}; Painter m_painter {};
@ -26,6 +27,9 @@ public:
Widget *get_focused_widget() { return m_focused_widget; } Widget *get_focused_widget() { return m_focused_widget; }
void set_focused_widget(Widget *focused_widget) { m_focused_widget = focused_widget; } void set_focused_widget(Widget *focused_widget) { m_focused_widget = focused_widget; }
Widget *get_active_widget() { return m_active_widget; }
void set_active_widget(Widget *active_widget) { m_active_widget = active_widget; }
Widget *get_main_widget() { return m_main_widget; } Widget *get_main_widget() { return m_main_widget; }
void set_main_widget(Widget *main_widget); void set_main_widget(Widget *main_widget);