[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);
auto const newName = ig::InputText<50>(
"Name", m_pal.colorNames[m_selectedColorRow]);
bool inputFocused = ImGui::IsItemFocused();
auto nameInputFocused = ImGui::IsItemFocused();
ImGui::Separator();
colorInput("Red", r, inputFocused, FocusCmd::Red);
colorInput("Green", g, inputFocused, FocusCmd::Green);
colorInput("Blue", b, inputFocused, FocusCmd::Blue);
bool colorInFocused{};
colorInput("Red", r, colorInFocused, FocusCmd::Red);
colorInput("Green", g, colorInFocused, FocusCmd::Green);
colorInput("Blue", b, colorInFocused, FocusCmd::Blue);
// color preview
{
ImGui::PushStyleColor(
@ -320,20 +321,24 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
std::ignore = pushCommand<ApplyColorAllPagesCommand>(
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)) {
numShortcuts(m_selectedColorRow, largestPage(m_pal));
if (!nameInputFocused && !colorInFocused) {
numShortcuts(m_selectedColorRow, largestPage(m_pal));
}
} else {
numShortcuts(m_page, m_pal.pages.size());
}
if (ImGui::IsKeyDown(ImGuiKey_R)) {
m_focusCmd = FocusCmd::Red;
}
if (ImGui::IsKeyDown(ImGuiKey_G)) {
m_focusCmd = FocusCmd::Green;
}
if (ImGui::IsKeyDown(ImGuiKey_B)) {
m_focusCmd = FocusCmd::Blue;
if (!nameInputFocused) {
if (ImGui::IsKeyDown(ImGuiKey_R)) {
m_focusCmd = FocusCmd::Red;
}
if (ImGui::IsKeyDown(ImGuiKey_G)) {
m_focusCmd = FocusCmd::Green;
}
if (ImGui::IsKeyDown(ImGuiKey_B)) {
m_focusCmd = FocusCmd::Blue;
}
}
}
auto const newColor = color16(r, g, b, a);