diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-20 23:22:51 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-03-20 23:22:51 +0000 |
commit | 1efe681967cc764db3185134e0750349061a6e41 (patch) | |
tree | 7ef9b34d0197a6a97e0de4caec3db3099a76d7b6 /ui | |
parent | Remove unrequired UIShader (diff) | |
download | ilt-1efe681967cc764db3185134e0750349061a6e41.tar.bz2 ilt-1efe681967cc764db3185134e0750349061a6e41.tar.xz ilt-1efe681967cc764db3185134e0750349061a6e41.zip |
Support capturing and reacting to ImGui window closure
Diffstat (limited to 'ui')
-rw-r--r-- | ui/editNetwork.cpp | 4 | ||||
-rw-r--r-- | ui/editNetwork.h | 2 | ||||
-rw-r--r-- | ui/gameMainSelector.cpp | 10 | ||||
-rw-r--r-- | ui/gameMainSelector.h | 4 | ||||
-rw-r--r-- | ui/gameMainWindow.cpp | 2 | ||||
-rw-r--r-- | ui/manualCameraController.cpp | 2 | ||||
-rw-r--r-- | ui/manualCameraController.h | 2 | ||||
-rw-r--r-- | ui/queryTool.cpp | 4 | ||||
-rw-r--r-- | ui/queryTool.h | 2 | ||||
-rw-r--r-- | ui/uiComponent.h | 2 |
10 files changed, 19 insertions, 15 deletions
diff --git a/ui/editNetwork.cpp b/ui/editNetwork.cpp index 3a28af7..a9b041c 100644 --- a/ui/editNetwork.cpp +++ b/ui/editNetwork.cpp @@ -65,9 +65,9 @@ EditNetwork::Builder::setHeightsFor(Network * network, const Link::CCollection & } void -EditNetwork::render() +EditNetwork::render(bool & open) { - ImGui::Begin("Edit Network"); + ImGui::Begin("Edit Network", &open); auto builderChoice = [this]<typename Impl>(const char * name) { if (ImGui::RadioButton(name, dynamic_cast<Impl *>(builder.get()))) { diff --git a/ui/editNetwork.h b/ui/editNetwork.h index aa5676a..a817ddf 100644 --- a/ui/editNetwork.h +++ b/ui/editNetwork.h @@ -17,7 +17,7 @@ public: bool move(const SDL_MouseMotionEvent & e, const Ray<GlobalPosition3D> &) override; bool handleInput(const SDL_Event & e) override; void render(const SceneShader &, const Frustum &) const override; - void render() override; + void render(bool & open) override; using NetworkClickPos = std::variant<GlobalPosition3D, Node::Ptr>; diff --git a/ui/gameMainSelector.cpp b/ui/gameMainSelector.cpp index 55d0ae0..0c40abc 100644 --- a/ui/gameMainSelector.cpp +++ b/ui/gameMainSelector.cpp @@ -13,10 +13,14 @@ GameMainSelector::GameMainSelector(const Camera * c) : camera {c} { } constexpr ScreenAbsCoord TargetPos {5, 45}; void -GameMainSelector::render() const +GameMainSelector::render() { if (target) { - target->render(); + bool open = true; + target->render(open); + if (!open) { + target.reset(); + } } } @@ -86,7 +90,7 @@ GameMainSelector::Component::handleInput(const SDL_Event &) } void -GameMainSelector::Component::render() +GameMainSelector::Component::render(bool &) { } diff --git a/ui/gameMainSelector.h b/ui/gameMainSelector.h index e6a86d2..8c2be4b 100644 --- a/ui/gameMainSelector.h +++ b/ui/gameMainSelector.h @@ -20,13 +20,13 @@ public: virtual bool click(const SDL_MouseButtonEvent &, const Ray<GlobalPosition3D> &); virtual bool move(const SDL_MouseMotionEvent &, const Ray<GlobalPosition3D> &); virtual bool handleInput(const SDL_Event &); - virtual void render(); + virtual void render(bool & open); virtual void render(const SceneShader &, const Frustum &) const; }; GameMainSelector(const Camera * c); - void render() const override; + void render() override; void render(const SceneShader & shader, const Frustum &) const override; bool handleInput(const SDL_Event & e) override; diff --git a/ui/gameMainWindow.cpp b/ui/gameMainWindow.cpp index cfc64e3..322c6e5 100644 --- a/ui/gameMainWindow.cpp +++ b/ui/gameMainWindow.cpp @@ -25,7 +25,7 @@ public: explicit GameMainToolbar(GameMainSelector * gms) : gms {gms} { } void - render() const override + render() override { if (IltGui::BeginToolbar("bottomBar", ImGuiDir_Down, TOOLBAR_HEIGHT)) { if (ImGui::ImageButton("Build rails", *buildRailsIcon, TOOLBAR_ICON_SIZE)) { diff --git a/ui/manualCameraController.cpp b/ui/manualCameraController.cpp index 557945e..553afc1 100644 --- a/ui/manualCameraController.cpp +++ b/ui/manualCameraController.cpp @@ -72,7 +72,7 @@ ManualCameraController::handleInput(const SDL_Event & e) } void -ManualCameraController::render() const +ManualCameraController::render() { } diff --git a/ui/manualCameraController.h b/ui/manualCameraController.h index d3bf0c4..6501762 100644 --- a/ui/manualCameraController.h +++ b/ui/manualCameraController.h @@ -13,7 +13,7 @@ public: explicit ManualCameraController(GlobalPosition2D f) : focus {f} { } bool handleInput(const SDL_Event & e) override; - void render() const override; + void render() override; void updateCamera(Camera * camera) const override; diff --git a/ui/queryTool.cpp b/ui/queryTool.cpp index d016afa..0157246 100644 --- a/ui/queryTool.cpp +++ b/ui/queryTool.cpp @@ -31,9 +31,9 @@ QueryTool::click(const SDL_MouseButtonEvent & event, const Ray<GlobalPosition3D> } void -QueryTool::render() +QueryTool::render(bool & open) { - ImGui::Begin("Query Tool"); + ImGui::Begin("Query Tool", &open); ImGui::TextUnformatted(clicked.c_str()); ImGui::End(); } diff --git a/ui/queryTool.h b/ui/queryTool.h index 4d16960..8633118 100644 --- a/ui/queryTool.h +++ b/ui/queryTool.h @@ -7,7 +7,7 @@ protected: using GameMainSelector::Component::render; bool click(const SDL_MouseButtonEvent &, const Ray<GlobalPosition3D> &) override; - void render() override; + void render(bool & open) override; private: std::string clicked; diff --git a/ui/uiComponent.h b/ui/uiComponent.h index 6ee347e..b2c1a8f 100644 --- a/ui/uiComponent.h +++ b/ui/uiComponent.h @@ -13,6 +13,6 @@ public: NO_MOVE(UIComponent); NO_COPY(UIComponent); - virtual void render() const = 0; + virtual void render() = 0; virtual bool handleInput(const SDL_Event &) = 0; }; |