galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Popup.cpp
Go to the documentation of this file.
1
7
9
10#include "Popup.hpp"
11
12namespace galaxy
13{
14 Popup::Popup(std::string_view id) noexcept
15 : m_show {false}
16 {
17 m_id = id;
18 }
19
20 Popup::~Popup() noexcept
21 {
22 }
23
24 void Popup::draw_button(const char* text) noexcept
25 {
26 m_show = ImGui::Button(text);
27 }
28
29 void Popup::draw_menuitem(const char* text) noexcept
30 {
31 m_show = ImGui::MenuItem(text);
32 }
33
34 void Popup::draw(std::move_only_function<void(void)>&& func)
35 {
36 if (m_show)
37 {
38 ImGui::OpenPopup(m_id.c_str());
39 m_show = false;
40 }
41
43 if (ImGui::BeginPopup(m_id.c_str()))
44 {
45 func();
46 ImGui::EndPopup();
47 }
48 }
49} // namespace galaxy
std::string m_id
Unique id (name) of the popup.
Definition Popup.hpp:66
bool m_show
Controls state of popup.
Definition Popup.hpp:71
void draw_menuitem(const char *text) noexcept
Draw a menu button to show the popup.
Definition Popup.cpp:29
void draw_button(const char *text) noexcept
Draw the button to show the popup.
Definition Popup.cpp:24
Popup()=delete
Default constructor (deleted).
~Popup() noexcept
Destructor.
Definition Popup.cpp:20
void draw(std::move_only_function< void(void)> &&func)
Show popup.
Definition Popup.cpp:34
void imgui_center_next_window()
Make sure the next window opened is centered on the monitor.
Application.hpp galaxy.