[olympic] Add more ImGui helpers, studio::Editor::pushCommand
This commit is contained in:
@@ -131,6 +131,17 @@ class Editor: public studio::BaseEditor {
|
||||
[[nodiscard]]
|
||||
UndoStack *undoStack() noexcept final;
|
||||
|
||||
void pushCommand(ox::UPtr<UndoCommand> &&cmd) noexcept;
|
||||
|
||||
template<typename UC, typename ...Args>
|
||||
void pushCommand(Args&&... args) noexcept {
|
||||
try {
|
||||
m_undoStack.push(ox::make_unique<UC>(ox::forward<Args>(args)...));
|
||||
} catch (ox::Exception const&ex) {
|
||||
oxLogError(ex.toError());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ox::Error markUnsavedChanges(UndoCommand const*) noexcept;
|
||||
};
|
||||
|
@@ -7,6 +7,7 @@
|
||||
#include <imgui.h>
|
||||
|
||||
#include <turbine/context.hpp>
|
||||
#include <studio/context.hpp>
|
||||
|
||||
namespace studio::ig {
|
||||
|
||||
@@ -52,4 +53,41 @@ bool BeginPopup(turbine::Context &ctx, ox::CStringView popupName, bool &show, Im
|
||||
*/
|
||||
bool ComboBox(ox::CStringView lbl, ox::SpanView<ox::String> list, size_t &selectedIdx) noexcept;
|
||||
|
||||
bool FileComboBox(
|
||||
ox::CStringView lbl,
|
||||
studio::StudioContext &sctx,
|
||||
ox::StringView fileExt,
|
||||
size_t &selectedIdx) noexcept;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @param list
|
||||
* @param selIdx
|
||||
* @return true if new value selected, false otherwise
|
||||
*/
|
||||
bool ListBox(ox::CStringView name, ox::SpanView<ox::String> const&list, size_t &selIdx) noexcept;
|
||||
|
||||
class FilePicker {
|
||||
private:
|
||||
bool m_show{};
|
||||
studio::StudioContext &m_sctx;
|
||||
ox::String const m_title;
|
||||
ox::String const m_fileExt;
|
||||
ImVec2 const m_size;
|
||||
public:
|
||||
ox::Signal<ox::Error(ox::StringView)> filePicked;
|
||||
|
||||
FilePicker(
|
||||
studio::StudioContext &sctx,
|
||||
ox::String title,
|
||||
ox::String fileExt,
|
||||
ImVec2 const&size = {}) noexcept;
|
||||
|
||||
void draw() noexcept;
|
||||
|
||||
void show() noexcept;
|
||||
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user