[nostalgia/gfx/studio/palette] Make RGB key shortcuts work when color channel inputs are focused
All checks were successful
Build / build (push) Successful in 1m17s

This commit is contained in:
Gary Talent 2025-06-08 16:44:24 -05:00
parent c3e75bdb55
commit f2bfb05a44

View File

@ -302,11 +302,12 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
int const a = alpha16(c); int const a = alpha16(c);
auto const newName = ig::InputText<50>( auto const newName = ig::InputText<50>(
"Name", m_pal.colorNames[m_selectedColorRow]); "Name", m_pal.colorNames[m_selectedColorRow]);
bool inputFocused = ImGui::IsItemFocused(); auto nameInputFocused = ImGui::IsItemFocused();
ImGui::Separator(); ImGui::Separator();
colorInput("Red", r, inputFocused, FocusCmd::Red); bool colorInFocused{};
colorInput("Green", g, inputFocused, FocusCmd::Green); colorInput("Red", r, colorInFocused, FocusCmd::Red);
colorInput("Blue", b, inputFocused, FocusCmd::Blue); colorInput("Green", g, colorInFocused, FocusCmd::Green);
colorInput("Blue", b, colorInFocused, FocusCmd::Blue);
// color preview // color preview
{ {
ImGui::PushStyleColor( ImGui::PushStyleColor(
@ -320,12 +321,15 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
std::ignore = pushCommand<ApplyColorAllPagesCommand>( std::ignore = pushCommand<ApplyColorAllPagesCommand>(
m_pal, m_page, m_selectedColorRow); m_pal, m_page, m_selectedColorRow);
} }
if (ig::mainWinHasFocus() && !inputFocused && !ImGui::IsKeyDown(ImGuiKey_ModCtrl)) { if (ig::mainWinHasFocus() && !ImGui::IsKeyDown(ImGuiKey_ModCtrl)) {
if (!ImGui::IsKeyDown(ImGuiKey_ModAlt)) { if (!ImGui::IsKeyDown(ImGuiKey_ModAlt)) {
if (!nameInputFocused && !colorInFocused) {
numShortcuts(m_selectedColorRow, largestPage(m_pal)); numShortcuts(m_selectedColorRow, largestPage(m_pal));
}
} else { } else {
numShortcuts(m_page, m_pal.pages.size()); numShortcuts(m_page, m_pal.pages.size());
} }
if (!nameInputFocused) {
if (ImGui::IsKeyDown(ImGuiKey_R)) { if (ImGui::IsKeyDown(ImGuiKey_R)) {
m_focusCmd = FocusCmd::Red; m_focusCmd = FocusCmd::Red;
} }
@ -336,6 +340,7 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
m_focusCmd = FocusCmd::Blue; m_focusCmd = FocusCmd::Blue;
} }
} }
}
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);