mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
NK-102 - Generic Confirmation Popup
This commit is contained in:
32
Editor/src/Misc/PopupHelper.cpp
Normal file
32
Editor/src/Misc/PopupHelper.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "PopupHelper.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
|
||||
void PopupHelper::Confirmation(const std::string& id)
|
||||
{
|
||||
ImGui::TextWrapped("Test");
|
||||
|
||||
ImGui::OpenPopup(id.c_str());
|
||||
}
|
||||
|
||||
bool PopupHelper::DefineDialog(std::string id, std::string text)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
||||
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
|
||||
|
||||
if (ImGui::BeginPopupModal(id.c_str(), NULL, ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
ImGui::Text((text + "\n\n").c_str());
|
||||
ImGui::Separator();
|
||||
|
||||
if (ImGui::Button("OK", ImVec2(120, 0))) { result = true; ImGui::CloseCurrentPopup(); }
|
||||
ImGui::SetItemDefaultFocus();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); }
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
9
Editor/src/Misc/PopupHelper.h
Normal file
9
Editor/src/Misc/PopupHelper.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
class PopupHelper
|
||||
{
|
||||
public:
|
||||
static void Confirmation(const std::string& id);
|
||||
static bool DefineDialog(std::string id, std::string text);
|
||||
};
|
||||
Reference in New Issue
Block a user