[nostalgia/core/studio] Add key shortcuts for changing the selected color

This commit is contained in:
Gary Talent 2022-05-17 21:24:20 -05:00
parent 1edd72dc7d
commit 5c5f8e748a
2 changed files with 16 additions and 0 deletions

View File

@ -55,6 +55,20 @@ void TileSheetEditorImGui::paste() {
model()->paste();
}
void TileSheetEditorImGui::keyStateChanged(core::Key key, bool down) {
if (!down) {
return;
}
const auto colorCnt = model()->pal().colors.size();
if (key >= core::Key::Num_1 && key <= core::Key::Num_0 + colorCnt) {
auto idx = ox::min<std::size_t>(key - core::Key::Num_1, colorCnt - 1);
m_tileSheetEditor.setPalIdx(idx);
} else if (key == core::Key::Num_0 && colorCnt >= 10) {
auto idx = ox::min<std::size_t>(key - core::Key::Num_1 + 9, colorCnt - 1);
m_tileSheetEditor.setPalIdx(idx);
}
}
void TileSheetEditorImGui::draw(core::Context*) noexcept {
const auto paneSize = ImGui::GetContentRegionAvail();
const auto tileSheetParentSize = ImVec2(paneSize.x - m_palViewWidth, paneSize.y);

View File

@ -70,6 +70,8 @@ class TileSheetEditorImGui: public studio::BaseEditor {
void paste() override;
void keyStateChanged(core::Key key, bool down) override;
void draw(core::Context*) noexcept override;
void drawSubsheetSelector(TileSheet::SubSheet*, TileSheet::SubSheetIdx *path) noexcept;