[nostalgia/core/studio] Cleanup
All checks were successful
Build / build (push) Successful in 2m32s

This commit is contained in:
Gary Talent 2024-09-28 21:33:55 -05:00
parent 945a55f94a
commit 84cb03d807
2 changed files with 11 additions and 9 deletions

View File

@ -98,6 +98,12 @@ void PaletteEditorImGui::drawColumn(ox::CStringView txt) noexcept {
ImGui::Text("%s", txt.c_str());
}
void PaletteEditorImGui::colorInput(ox::CStringView label, int &v, bool &inputFocused) noexcept {
ImGui::InputInt(label.c_str(), &v, 1, 5);
inputFocused = inputFocused || ImGui::IsItemFocused();
v = ox::max(v, 0);
}
void PaletteEditorImGui::drawColorsEditor() noexcept {
constexpr auto tableFlags = ImGuiTableFlags_RowBg;
auto const colorsSz = ImGui::GetContentRegionAvail();
@ -240,19 +246,13 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
ImGui::InputText("Name", name.data(), name.cap() + 1);
ImGui::Separator();
bool inputFocused = false;
ImGui::InputInt("Red", &r, 1, 5);
inputFocused |= ImGui::IsItemFocused();
ImGui::InputInt("Green", &g, 1, 5);
inputFocused |= ImGui::IsItemFocused();
ImGui::InputInt("Blue", &b, 1, 5);
inputFocused |= ImGui::IsItemFocused();
colorInput("Red", r, inputFocused);
colorInput("Green", g, inputFocused);
colorInput("Blue", b, inputFocused);
if (ig::PushButton("Apply to all pages", {-1, ig::BtnSz.y})) {
std::ignore = pushCommand<ApplyColorAllPagesCommand>(
m_pal, m_page, m_selectedColorRow);
}
r = ox::max(r, 0);
g = ox::max(g, 0);
b = ox::max(b, 0);
if (!inputFocused) {
for (auto i = 0u; i < ox::min<size_t>(10, largestPage(m_pal)); ++i) {
auto const key = static_cast<ImGuiKey>(ImGuiKey_1 + i);

View File

@ -56,6 +56,8 @@ class PaletteEditorImGui: public studio::Editor {
drawColumn(ox::itoa(i));
}
static void colorInput(ox::CStringView label, int &v, bool &inputFocused) noexcept;
void drawColorsEditor() noexcept;
void drawPagesEditor() noexcept;