[nostalgia/core/studio] Remove unnecessary netsting level in PaletteEditor

This commit is contained in:
2023-07-15 13:16:05 -05:00
parent ddcb53a535
commit 9ceb1df49e

View File

@ -42,13 +42,10 @@ const ox::String &PaletteEditorImGui::itemDisplayName() const noexcept {
void PaletteEditorImGui::draw(turbine::Context*) noexcept { void PaletteEditorImGui::draw(turbine::Context*) noexcept {
static constexpr auto flags = ImGuiTableFlags_RowBg; static constexpr auto flags = ImGuiTableFlags_RowBg;
const auto paneSize = ImGui::GetContentRegionAvail(); const auto paneSize = ImGui::GetContentRegionAvail();
ImGui::BeginChild("PaletteEditor"); ImGui::BeginChild("Colors", ImVec2(paneSize.x - 208, paneSize.y), true);
{
ImGui::BeginChild("Colors", ImVec2(paneSize.x - 200, paneSize.y), false);
{ {
const auto colorsSz = ImGui::GetContentRegionAvail(); const auto colorsSz = ImGui::GetContentRegionAvail();
static constexpr auto toolbarHeight = 40; static constexpr auto toolbarHeight = 40;
ImGui::BeginChild("Toolbar", ImVec2(colorsSz.x, toolbarHeight), true);
{ {
const auto sz = ImVec2(70, 24); const auto sz = ImVec2(70, 24);
if (ImGui::Button("Add", sz)) { if (ImGui::Button("Add", sz)) {
@ -60,7 +57,11 @@ void PaletteEditorImGui::draw(turbine::Context*) noexcept {
ImGui::BeginDisabled(m_selectedRow >= m_pal.colors.size()); ImGui::BeginDisabled(m_selectedRow >= m_pal.colors.size());
{ {
if (ImGui::Button("Remove", sz)) { if (ImGui::Button("Remove", sz)) {
undoStack()->push(ox::make<RemoveColorCommand>(&m_pal, m_pal.colors[static_cast<std::size_t>(m_selectedRow)], static_cast<int>(m_selectedRow))); undoStack()->push(
ox::make<RemoveColorCommand>(
&m_pal,
m_pal.colors[static_cast<std::size_t>(m_selectedRow)],
static_cast<int>(m_selectedRow)));
m_selectedRow = ox::min(m_pal.colors.size() - 1, m_selectedRow); m_selectedRow = ox::min(m_pal.colors.size() - 1, m_selectedRow);
} }
ImGui::SameLine(); ImGui::SameLine();
@ -84,7 +85,6 @@ void PaletteEditorImGui::draw(turbine::Context*) noexcept {
} }
ImGui::EndDisabled(); ImGui::EndDisabled();
} }
ImGui::EndChild();
ImGui::BeginTable("Colors", 5, flags, ImVec2(colorsSz.x, colorsSz.y - (toolbarHeight + 5))); ImGui::BeginTable("Colors", 5, flags, ImVec2(colorsSz.x, colorsSz.y - (toolbarHeight + 5)));
{ {
ImGui::TableSetupColumn("Idx", ImGuiTableColumnFlags_WidthFixed, 25); ImGui::TableSetupColumn("Idx", ImGuiTableColumnFlags_WidthFixed, 25);
@ -142,8 +142,6 @@ void PaletteEditorImGui::draw(turbine::Context*) noexcept {
ImGui::EndChild(); ImGui::EndChild();
} }
} }
ImGui::EndChild();
}
ox::Error PaletteEditorImGui::saveItem() noexcept { ox::Error PaletteEditorImGui::saveItem() noexcept {
const auto sctx = applicationData<studio::StudioContext>(*m_ctx); const auto sctx = applicationData<studio::StudioContext>(*m_ctx);