ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
Modal.hpp
Go to the documentation of this file.
1#pragma once
2
13
14#include "Common.hpp"
15#include "Layout.hpp"
16
17namespace ZenitUI::UI
18{
22
31 class Modal : public TLayout<Modal>
32 {
33 public:
34 Modal();
35
42 void show();
43
50 void hide();
51
53 bool isOpen() const { return isOpen_; }
54
58 Layout *contentTarget() override;
59
60 bool closeOnEscape{true};
61
63 std::function<void()> onShow;
65 std::function<void()> onHide;
66
67 protected:
68 void onBuild() override;
69 void onUpdate(float dt) override;
70
71 std::shared_ptr<Layout> content;
72
73 private:
74 bool isOpen_{false};
75 std::weak_ptr<Layout> prevFocus_;
76 };
77
78} // namespace ZenitUI::UI
Centralized standard library includes used throughout ZenitUI.
The node class: tree structure, layout pass, style resolution, input dispatch, render orchestration,...
Layout(LayoutType type=LayoutType::Stack)
Construct a node with the given layout strategy.
Definition Layout.hpp:163
TLayout(Args &&...args)
Definition Layout.hpp:1401
void hide()
Hide the modal: fade out, play the intro animation in reverse.
std::function< void()> onShow
Fired after show().
Definition Modal.hpp:63
bool isOpen() const
true while the modal is open.
Definition Modal.hpp:53
bool closeOnEscape
Close when Escape is pressed while open.
Definition Modal.hpp:60
void show()
Show the modal: enable, fade in, play the intro animation.
void onBuild() override
Hook: called once after create() finishes constructing the object.
void onUpdate(float dt) override
Called every frame from update, after input dispatch.
Layout * contentTarget() override
Return the internal content panel (VStack with class "modal-content").
std::function< void()> onHide
Fired after hide().
Definition Modal.hpp:65