65 lines
1.3 KiB
C++
65 lines
1.3 KiB
C++
/*
|
|
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
|
*/
|
|
|
|
#include <imgui.h>
|
|
|
|
#include <studio/imguiutil.hpp>
|
|
#include "aboutpopup.hpp"
|
|
|
|
namespace olympic {
|
|
extern ox::String appVersion;
|
|
}
|
|
|
|
namespace studio {
|
|
|
|
AboutPopup::AboutPopup(turbine::Context &ctx) noexcept {
|
|
m_text = ox::sfmt("{} - {}", keelCtx(ctx).appName, olympic::appVersion);
|
|
}
|
|
|
|
void AboutPopup::open() noexcept {
|
|
m_stage = Stage::Opening;
|
|
}
|
|
|
|
void AboutPopup::close() noexcept {
|
|
m_stage = Stage::Closed;
|
|
}
|
|
|
|
bool AboutPopup::isOpen() const noexcept {
|
|
return m_stage == Stage::Open;
|
|
}
|
|
|
|
void AboutPopup::draw(StudioContext &sctx) noexcept {
|
|
switch (m_stage) {
|
|
case Stage::Closed:
|
|
break;
|
|
case Stage::Opening:
|
|
ImGui::OpenPopup("About");
|
|
m_stage = Stage::Open;
|
|
[[fallthrough]];
|
|
case Stage::Open: {
|
|
constexpr auto modalFlags =
|
|
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
|
ig::centerNextWindow(sctx.tctx);
|
|
auto open = true;
|
|
if (ImGui::BeginPopupModal("About", &open, modalFlags)) {
|
|
ImGui::Text("%s", m_text.c_str());
|
|
ImGui::NewLine();
|
|
ImGui::Dummy({148.0f, 0.0f});
|
|
ImGui::SameLine();
|
|
if (ig::PushButton("Close")) {
|
|
ImGui::CloseCurrentPopup();
|
|
open = false;
|
|
}
|
|
ImGui::EndPopup();
|
|
}
|
|
if (!open) {
|
|
m_stage = Stage::Closed;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|