exit confirmation changes
This commit is contained in:
@@ -528,12 +528,16 @@ IMGUI_ITEM_ATLAS_FUNCTION(_imgui_atlas_selectable, _imgui_selectable(self, imgui
|
||||
IMGUI_ITEM_ATLAS_VALUE_FUNCTION(_imgui_atlas_selectable_input_int, s32, _imgui_selectable_input_int(self, imgui, value));
|
||||
IMGUI_ITEM_ATLAS_VALUE_FUNCTION(_imgui_atlas_selectable_input_text, std::string, _imgui_selectable_input_text(self, imgui, value));
|
||||
|
||||
static bool _imgui_option_popup(ImguiItem self, Imgui* imgui)
|
||||
static bool _imgui_option_popup(ImguiItem self, Imgui* imgui, ImguiPopupState* state = nullptr)
|
||||
{
|
||||
ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||
|
||||
if (state) *state = IMGUI_POPUP_STATE_CLOSED;
|
||||
|
||||
if (imgui_begin_popup_modal(self.label_get(), imgui))
|
||||
{
|
||||
if (state) *state = IMGUI_POPUP_STATE_OPEN;
|
||||
|
||||
ImGui::Text(self.text_get());
|
||||
ImGui::Separator();
|
||||
|
||||
@@ -541,13 +545,17 @@ static bool _imgui_option_popup(ImguiItem self, Imgui* imgui)
|
||||
{
|
||||
imgui_close_current_popup(imgui);
|
||||
imgui_end_popup(imgui);
|
||||
if (state) *state = IMGUI_POPUP_STATE_CONFIRM;
|
||||
return true;
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (_imgui_button(IMGUI_POPUP_CANCEL, imgui))
|
||||
{
|
||||
imgui_close_current_popup(imgui);
|
||||
if (state) *state = IMGUI_POPUP_STATE_CANCEL;
|
||||
}
|
||||
|
||||
imgui_end_popup(imgui);
|
||||
}
|
||||
@@ -1240,6 +1248,8 @@ static void _imgui_timeline(Imgui* self)
|
||||
|
||||
static void _imgui_taskbar(Imgui* self)
|
||||
{
|
||||
static ImguiPopupState exitConfirmState = IMGUI_POPUP_STATE_CLOSED;
|
||||
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
ImguiItem taskbar = IMGUI_TASKBAR;
|
||||
ImGui::SetNextWindowSize({viewport->Size.x, IMGUI_TASKBAR.size.y});
|
||||
@@ -1278,10 +1288,15 @@ static void _imgui_taskbar(Imgui* self)
|
||||
|
||||
if (self->isTryQuit) imgui_open_popup(IMGUI_EXIT_CONFIRMATION.label);
|
||||
|
||||
if (_imgui_option_popup(IMGUI_EXIT_CONFIRMATION, self))
|
||||
self->isQuit = true;
|
||||
else
|
||||
self->isTryQuit = false;
|
||||
_imgui_option_popup(IMGUI_EXIT_CONFIRMATION, self, &exitConfirmState);
|
||||
|
||||
switch (exitConfirmState)
|
||||
{
|
||||
case IMGUI_POPUP_STATE_CLOSED: self->isTryQuit = false; break;
|
||||
case IMGUI_POPUP_STATE_OPEN: self->isTryQuit = true; break;
|
||||
case IMGUI_POPUP_STATE_CONFIRM: self->isQuit = true; break;
|
||||
case IMGUI_POPUP_STATE_CANCEL: self->isTryQuit = false; break;
|
||||
}
|
||||
|
||||
_imgui_selectable(IMGUI_WIZARD.copy({}), self);
|
||||
|
||||
|
10
src/imgui.h
10
src/imgui.h
@@ -146,6 +146,14 @@ enum ImguiPopupType
|
||||
IMGUI_POPUP_CENTER_WINDOW
|
||||
};
|
||||
|
||||
enum ImguiPopupState
|
||||
{
|
||||
IMGUI_POPUP_STATE_CLOSED,
|
||||
IMGUI_POPUP_STATE_OPEN,
|
||||
IMGUI_POPUP_STATE_CONFIRM,
|
||||
IMGUI_POPUP_STATE_CANCEL
|
||||
};
|
||||
|
||||
struct ImguiColorSet
|
||||
{
|
||||
ImVec4 normal{};
|
||||
@@ -603,7 +611,7 @@ IMGUI_ITEM(IMGUI_FOOTER_CHILD,
|
||||
);
|
||||
|
||||
IMGUI_ITEM(IMGUI_TASKBAR,
|
||||
self.label = "## Taskbar",
|
||||
self.label = "Taskbar",
|
||||
self.size = {0, 32},
|
||||
self.flags = ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoResize |
|
||||
|
Reference in New Issue
Block a user