Squashed 'deps/nostalgia/' changes from 84205879..0c0ccd1a
0c0ccd1a [nostalgia/core/studio] Cleanup scratchpad code 1b629da8 [ox/std] Make Vector::contains always noexcept 32e4702d [ox] Improve hasing and MaybeView 6b47133c [nostalgia] Cleanup StudioModules 0764720f [nostalgia,olympic] Update for Ox changes 78955376 [glutils] Update for Ox changes a00a0bd2 [ox] Rename BString to IString ed4f0e1f [nostalgia,olympic] Replace oxIgnoreError with std::ignore ea1feb72 [ox] Remove oxIgnoreError e9a6a096 [ox] Run liccor d7f30975 Merge commit 'c0baf7efca0e4c3a86a018ad2564d9df7b07c133' eeb2a5a1 [olympic/studio] Add new ImGui util functions 453f2750 [nostalgia/core/studio] Cleanup context types 189ba4c5 [olympic/studio] Make studio::run static 05773808 [olympic] Change TypeId building to use constexpr globals 272eabc7 [nostalgia/core/opengl] Unbind vertex arrays when done with them a0256669 [glutils] Remove trailing whitespace 6808adc8 [ox/std] Replace ox::ignore with std::ignore abc076d6 [ox/std] Cleanup 1b790a34 [ox/std] Fix Signed_c and Unsigned_c 92202716 [nostalgia/core] Update pack transforms to use ModelTypeId_v 7941a514 [ox/model] Add constexpr ModelTypeId_v 0c09c530 [ox/std] Fix sfmt constexpr problems 3ff91af8 [ox/std] Sort of fix custom assert 79b42e1d [ox/std] Fix some Vector constexpr problems 5eec9085 [ox/std] Add nodiscard to some string functions af7c8956 [ox/std] Add ox::ignore git-subtree-dir: deps/nostalgia git-subtree-split: 0c0ccd1a692169d99beb8c238b8b2c466e81a13d
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <ox/std/bit.hpp>
|
||||
|
||||
#include <turbine/context.hpp>
|
||||
#include <studio/context.hpp>
|
||||
|
||||
@@ -15,6 +17,91 @@ namespace studio::ig {
|
||||
|
||||
inline constexpr auto BtnSz = ImVec2{52, 22};
|
||||
|
||||
|
||||
constexpr ImTextureID toImTextureID(ox::Unsigned_c auto id) noexcept
|
||||
requires(sizeof(id) <= sizeof(ox::Uint<sizeof(ImTextureID)*8>)) {
|
||||
return std::bit_cast<ImTextureID>(ox::Uint<sizeof(ImTextureID)*8>{id});
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ox::Result<T> getDragDropPayload(ox::CStringView name) noexcept {
|
||||
auto const payload = ImGui::AcceptDragDropPayload(name.c_str());
|
||||
if (!payload) {
|
||||
return OxError(1, "No drag/drop payload");
|
||||
}
|
||||
return ox::readClaw<T>(
|
||||
reinterpret_cast<char const*>(payload->Data),
|
||||
static_cast<size_t>(payload->DataSize));
|
||||
}
|
||||
|
||||
ox::Error setDragDropPayload(ox::CStringView name, auto const &obj) noexcept {
|
||||
oxRequire(buff, ox::writeClaw(obj, ox::ClawFormat::Metal));
|
||||
ImGui::SetDragDropPayload(name.c_str(), buff.data(), buff.size());
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
class DragDropSource {
|
||||
private:
|
||||
bool const m_active{};
|
||||
public:
|
||||
inline DragDropSource() noexcept:
|
||||
m_active(ImGui::BeginDragDropSource()) {
|
||||
}
|
||||
inline ~DragDropSource() noexcept {
|
||||
if (m_active) {
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
}
|
||||
constexpr operator bool() const noexcept {
|
||||
return m_active;
|
||||
}
|
||||
};
|
||||
|
||||
inline auto dragDropSource(auto const&cb) noexcept {
|
||||
if constexpr(ox::is_same_v<decltype(cb()), ox::Error>) {
|
||||
if (ig::DragDropSource const tgt; tgt) [[unlikely]] {
|
||||
return cb();
|
||||
}
|
||||
} else {
|
||||
if (ig::DragDropSource const tgt; tgt) [[unlikely]] {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DragDropTarget {
|
||||
private:
|
||||
bool const m_active{};
|
||||
public:
|
||||
inline DragDropTarget() noexcept:
|
||||
m_active(ImGui::BeginDragDropTarget()) {
|
||||
}
|
||||
inline ~DragDropTarget() noexcept {
|
||||
if (m_active) {
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
}
|
||||
constexpr operator bool() const noexcept {
|
||||
return m_active;
|
||||
}
|
||||
};
|
||||
|
||||
inline auto dragDropTarget(auto const&cb) noexcept {
|
||||
if constexpr(ox::is_same_v<decltype(cb()), ox::Error>) {
|
||||
if (ig::DragDropTarget const tgt; tgt) [[unlikely]] {
|
||||
return cb();
|
||||
}
|
||||
return ox::Error{};
|
||||
} else {
|
||||
if (ig::DragDropTarget const tgt; tgt) [[unlikely]] {
|
||||
cb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ChildStackItem {
|
||||
public:
|
||||
explicit ChildStackItem(ox::CStringView id, ImVec2 const&sz = {}) noexcept;
|
||||
|
@@ -24,7 +24,7 @@ static ox::Result<ox::String> toResult(nfdresult_t r, NFD::UniquePathN const&pat
|
||||
ox::String out;
|
||||
for (auto i = 0u; path.get()[i]; ++i) {
|
||||
auto const c = static_cast<char>(path.get()[i]);
|
||||
oxIgnoreError(out.append(&c, 1));
|
||||
std::ignore = out.append(&c, 1);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
@@ -9,13 +9,13 @@
|
||||
namespace studio {
|
||||
|
||||
void TaskRunner::update(turbine::Context &ctx) noexcept {
|
||||
oxIgnoreError(m_tasks.erase(std::remove_if(m_tasks.begin(), m_tasks.end(), [&](ox::UPtr<studio::Task> &t) {
|
||||
std::ignore = m_tasks.erase(std::remove_if(m_tasks.begin(), m_tasks.end(), [&](ox::UPtr<studio::Task> &t) {
|
||||
auto const done = t->update(ctx) == TaskState::Done;
|
||||
if (done) {
|
||||
t->finished.emit();
|
||||
}
|
||||
return done;
|
||||
})));
|
||||
}));
|
||||
}
|
||||
|
||||
void TaskRunner::add(Task &task) noexcept {
|
||||
|
@@ -12,7 +12,7 @@ bool UndoCommand::mergeWith(UndoCommand const*) noexcept {
|
||||
|
||||
void UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
|
||||
for (auto const i = m_stackIdx; i < m_stack.size();) {
|
||||
oxIgnoreError(m_stack.erase(i));
|
||||
std::ignore = m_stack.erase(i);
|
||||
}
|
||||
cmd->redo();
|
||||
redoTriggered.emit(cmd.get());
|
||||
|
Reference in New Issue
Block a user