[nostalgia/core/studio] Give PaletteEditor keyboard shortcuts

This commit is contained in:
Gary Talent 2024-09-28 21:09:24 -05:00
parent aa970b1fc0
commit 2173b12c67

View File

@ -239,9 +239,13 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
name = currentName; name = currentName;
ImGui::InputText("Name", name.data(), name.cap() + 1); ImGui::InputText("Name", name.data(), name.cap() + 1);
ImGui::Separator(); ImGui::Separator();
bool inputFocused = false;
ImGui::InputInt("Red", &r, 1, 5); ImGui::InputInt("Red", &r, 1, 5);
inputFocused |= ImGui::IsItemFocused();
ImGui::InputInt("Green", &g, 1, 5); ImGui::InputInt("Green", &g, 1, 5);
inputFocused |= ImGui::IsItemFocused();
ImGui::InputInt("Blue", &b, 1, 5); ImGui::InputInt("Blue", &b, 1, 5);
inputFocused |= ImGui::IsItemFocused();
if (ig::PushButton("Apply to all pages", {-1, ig::BtnSz.y})) { if (ig::PushButton("Apply to all pages", {-1, ig::BtnSz.y})) {
std::ignore = pushCommand<ApplyColorAllPagesCommand>( std::ignore = pushCommand<ApplyColorAllPagesCommand>(
m_pal, m_page, m_selectedColorRow); m_pal, m_page, m_selectedColorRow);
@ -249,6 +253,17 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
r = ox::max(r, 0); r = ox::max(r, 0);
g = ox::max(g, 0); g = ox::max(g, 0);
b = ox::max(b, 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);
if (ImGui::IsKeyPressed(key, false)) {
m_selectedColorRow = i;
}
}
if (ImGui::GetIO().KeysDown[ImGuiKey_0]) {
m_selectedColorRow = ox::min<size_t>(9, largestPage(m_pal));
}
}
auto const newColor = color16(r, g, b, a); auto const newColor = color16(r, g, b, a);
if (c != newColor) { if (c != newColor) {
std::ignore = pushCommand<UpdateColorCommand>(m_pal, m_page, m_selectedColorRow, newColor); std::ignore = pushCommand<UpdateColorCommand>(m_pal, m_page, m_selectedColorRow, newColor);