[nostalgia/core/studio] Give PaletteEditor keyboard shortcuts
This commit is contained in:
parent
aa970b1fc0
commit
2173b12c67
@ -239,9 +239,13 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
|
||||
name = currentName;
|
||||
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();
|
||||
if (ig::PushButton("Apply to all pages", {-1, ig::BtnSz.y})) {
|
||||
std::ignore = pushCommand<ApplyColorAllPagesCommand>(
|
||||
m_pal, m_page, m_selectedColorRow);
|
||||
@ -249,6 +253,17 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
|
||||
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);
|
||||
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);
|
||||
if (c != newColor) {
|
||||
std::ignore = pushCommand<UpdateColorCommand>(m_pal, m_page, m_selectedColorRow, newColor);
|
||||
|
Loading…
Reference in New Issue
Block a user