[nostalgia] Add NewMenu for creating new files
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/event/signal.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
|
||||
#include <nostalgia/geo/vec.hpp>
|
||||
#include <nostalgia/core/context.hpp>
|
||||
|
||||
#include "imguiuitl.hpp"
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
|
||||
class Popup {
|
||||
private:
|
||||
geo::Vec2 m_size;
|
||||
ox::String m_title;
|
||||
public:
|
||||
// emits path parameter
|
||||
ox::Signal<ox::Error(const ox::String&)> finished;
|
||||
|
||||
virtual ~Popup() noexcept = default;
|
||||
|
||||
virtual void open() noexcept = 0;
|
||||
|
||||
virtual void close() noexcept = 0;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual bool isOpen() const noexcept = 0;
|
||||
|
||||
virtual void draw(core::Context *ctx) noexcept = 0;
|
||||
|
||||
protected:
|
||||
constexpr void setSize(geo::Size sz) noexcept {
|
||||
m_size = {static_cast<float>(sz.width), static_cast<float>(sz.height)};
|
||||
}
|
||||
|
||||
constexpr void setTitle(ox::String title) noexcept {
|
||||
m_title = std::move(title);
|
||||
}
|
||||
|
||||
constexpr const ox::String &title() const noexcept {
|
||||
return m_title;
|
||||
}
|
||||
|
||||
void drawWindow(core::Context *ctx, bool *open, auto drawContents) {
|
||||
studio::ig::centerNextWindow(ctx);
|
||||
ImGui::SetNextWindowSize(static_cast<ImVec2>(m_size));
|
||||
constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
||||
if (ImGui::BeginPopupModal(m_title.c_str(), open, modalFlags)) {
|
||||
drawContents();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user