diff --git a/Userland/DevTools/GMLPlayground/GMLPlaygroundWindow.gml b/Userland/DevTools/GMLPlayground/GMLPlaygroundWindow.gml index 5b1c97e9b0..23d041f4b7 100644 --- a/Userland/DevTools/GMLPlayground/GMLPlaygroundWindow.gml +++ b/Userland/DevTools/GMLPlayground/GMLPlaygroundWindow.gml @@ -20,4 +20,8 @@ name: "preview_frame" } } + + @GUI::Statusbar { + name: "statusbar" + } } diff --git a/Userland/DevTools/GMLPlayground/MainWidget.cpp b/Userland/DevTools/GMLPlayground/MainWidget.cpp index 6b2f748cdd..fc43f5988f 100644 --- a/Userland/DevTools/GMLPlayground/MainWidget.cpp +++ b/Userland/DevTools/GMLPlayground/MainWidget.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,7 @@ void UnregisteredWidget::paint_event(GUI::PaintEvent& event) ErrorOr> MainWidget::try_create(GUI::Icon const& icon) { - auto main_widget = TRY(try_make_ref_counted()); + auto main_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) MainWidget())); TRY(main_widget->load_from_gml(gml_playground_window_gml)); main_widget->m_icon = icon; @@ -70,6 +71,7 @@ ErrorOr> MainWidget::try_create(GUI::Icon const& icon) main_widget->m_splitter = main_widget->find_descendant_of_type_named("splitter"); main_widget->m_editor = main_widget->find_descendant_of_type_named("text_editor"); main_widget->m_preview_frame_widget = main_widget->find_descendant_of_type_named("preview_frame"); + main_widget->m_statusbar = main_widget->find_descendant_of_type_named("statusbar"); main_widget->m_preview_window = TRY(GUI::Window::try_create(main_widget)); main_widget->m_preview_window->set_title("Preview - GML Playground"); @@ -100,6 +102,16 @@ ErrorOr> MainWidget::try_create(GUI::Icon const& icon) return main_widget; } +MainWidget::MainWidget() +{ + GUI::Application::the()->on_action_enter = [this](GUI::Action& action) { + m_statusbar->set_override_text(action.status_tip()); + }; + GUI::Application::the()->on_action_leave = [this](GUI::Action&) { + m_statusbar->set_override_text({}); + }; +} + void MainWidget::update_title() { window()->set_title(DeprecatedString::formatted("{}[*] - GML Playground", m_file_path.is_empty() ? "Untitled"sv : m_file_path.view())); diff --git a/Userland/DevTools/GMLPlayground/MainWidget.h b/Userland/DevTools/GMLPlayground/MainWidget.h index 14b85ef44f..da4d2f28c5 100644 --- a/Userland/DevTools/GMLPlayground/MainWidget.h +++ b/Userland/DevTools/GMLPlayground/MainWidget.h @@ -30,6 +30,7 @@ public: GUI::TextEditor& editor() const { return *m_editor; } private: + MainWidget(); virtual void drag_enter_event(GUI::DragEvent&) override; virtual void drop_event(GUI::DropEvent&) override; @@ -37,6 +38,7 @@ private: RefPtr m_editor; RefPtr m_toolbar; RefPtr m_splitter; + RefPtr m_statusbar; RefPtr m_preview_frame_widget; RefPtr m_preview_window;