[nostalgia/gfx/studio/palette] Add RGB key shortcuts for focusing color channels
All checks were successful
Build / build (push) Successful in 1m15s
All checks were successful
Build / build (push) Successful in 1m15s
This commit is contained in:
parent
56eeb24900
commit
efec6eb3c8
@ -1,3 +1,7 @@
|
|||||||
|
# d2025.06.0
|
||||||
|
|
||||||
|
* PaletteEditor: Add RGB key shortcuts for focusing color channels
|
||||||
|
|
||||||
# d2025.05.0
|
# d2025.05.0
|
||||||
|
|
||||||
* Add app icon for both window and file
|
* Add app icon for both window and file
|
||||||
|
@ -118,12 +118,12 @@ void PaletteEditorImGui::navigateTo(ox::StringViewCR arg) noexcept {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaletteEditorImGui::drawColumnLeftAlign(ox::CStringView txt) noexcept {
|
void PaletteEditorImGui::drawColumnLeftAlign(ox::CStringViewCR txt) noexcept {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("%s", txt.c_str());
|
ImGui::Text("%s", txt.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaletteEditorImGui::drawColumn(ox::CStringView txt) noexcept {
|
void PaletteEditorImGui::drawColumn(ox::CStringViewCR txt) noexcept {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::SetCursorPosX(
|
ImGui::SetCursorPosX(
|
||||||
ImGui::GetCursorPosX() + ImGui::GetColumnWidth() - ImGui::CalcTextSize(txt.data()).x);
|
ImGui::GetCursorPosX() + ImGui::GetColumnWidth() - ImGui::CalcTextSize(txt.data()).x);
|
||||||
@ -143,7 +143,15 @@ void PaletteEditorImGui::numShortcuts(size_t &val, size_t const sizeRange) noexc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaletteEditorImGui::colorInput(ox::CStringView label, int &v, bool &inputFocused) noexcept {
|
void PaletteEditorImGui::colorInput(
|
||||||
|
ox::CStringViewCR label,
|
||||||
|
int &v,
|
||||||
|
bool &inputFocused,
|
||||||
|
FocusCmd const colorChannel) noexcept {
|
||||||
|
if (colorChannel == m_focusCmd) [[unlikely]] {
|
||||||
|
ImGui::SetKeyboardFocusHere();
|
||||||
|
m_focusCmd = FocusCmd::None;
|
||||||
|
}
|
||||||
ImGui::InputInt(label.c_str(), &v, 1, 5);
|
ImGui::InputInt(label.c_str(), &v, 1, 5);
|
||||||
inputFocused = inputFocused || ImGui::IsItemFocused();
|
inputFocused = inputFocused || ImGui::IsItemFocused();
|
||||||
v = ox::max(v, 0);
|
v = ox::max(v, 0);
|
||||||
@ -296,9 +304,9 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
|
|||||||
"Name", m_pal.colorNames[m_selectedColorRow]);
|
"Name", m_pal.colorNames[m_selectedColorRow]);
|
||||||
bool inputFocused = ImGui::IsItemFocused();
|
bool inputFocused = ImGui::IsItemFocused();
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
colorInput("Red", r, inputFocused);
|
colorInput("Red", r, inputFocused, FocusCmd::Red);
|
||||||
colorInput("Green", g, inputFocused);
|
colorInput("Green", g, inputFocused, FocusCmd::Green);
|
||||||
colorInput("Blue", b, inputFocused);
|
colorInput("Blue", b, inputFocused, FocusCmd::Blue);
|
||||||
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);
|
||||||
@ -309,6 +317,15 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
|
|||||||
} else {
|
} else {
|
||||||
numShortcuts(m_page, m_pal.pages.size());
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto const newColor = color16(r, g, b, a);
|
auto const newColor = color16(r, g, b, a);
|
||||||
if (c != newColor) {
|
if (c != newColor) {
|
||||||
@ -320,7 +337,7 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error PaletteEditorImGui::renamePage(ox::StringView name) noexcept {
|
ox::Error PaletteEditorImGui::renamePage(ox::StringViewCR name) noexcept {
|
||||||
return pushCommand<RenamePageCommand>(m_pal, m_page, name);
|
return pushCommand<RenamePageCommand>(m_pal, m_page, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,13 @@ class PaletteEditorImGui: public studio::Editor {
|
|||||||
Palette m_pal;
|
Palette m_pal;
|
||||||
size_t m_selectedColorRow = 0;
|
size_t m_selectedColorRow = 0;
|
||||||
size_t m_page = 0;
|
size_t m_page = 0;
|
||||||
|
enum class FocusCmd {
|
||||||
|
None,
|
||||||
|
Red,
|
||||||
|
Green,
|
||||||
|
Blue,
|
||||||
|
};
|
||||||
|
FocusCmd m_focusCmd;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PaletteEditorImGui(studio::Context &sctx, ox::StringParam path);
|
PaletteEditorImGui(studio::Context &sctx, ox::StringParam path);
|
||||||
@ -48,9 +55,9 @@ class PaletteEditorImGui: public studio::Editor {
|
|||||||
void navigateTo(ox::StringViewCR arg) noexcept override;
|
void navigateTo(ox::StringViewCR arg) noexcept override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void drawColumnLeftAlign(ox::CStringView txt) noexcept;
|
static void drawColumnLeftAlign(ox::CStringViewCR txt) noexcept;
|
||||||
|
|
||||||
static void drawColumn(ox::CStringView txt) noexcept;
|
static void drawColumn(ox::CStringViewCR txt) noexcept;
|
||||||
|
|
||||||
static void drawColumn(ox::Integer_c auto i) noexcept {
|
static void drawColumn(ox::Integer_c auto i) noexcept {
|
||||||
drawColumn(ox::intToStr(i));
|
drawColumn(ox::intToStr(i));
|
||||||
@ -58,7 +65,7 @@ class PaletteEditorImGui: public studio::Editor {
|
|||||||
|
|
||||||
static void numShortcuts(size_t &val, size_t sizeRange) noexcept;
|
static void numShortcuts(size_t &val, size_t sizeRange) noexcept;
|
||||||
|
|
||||||
static void colorInput(ox::CStringView label, int &v, bool &inputFocused) noexcept;
|
void colorInput(ox::CStringViewCR label, int &v, bool &inputFocused, FocusCmd colorChannel) noexcept;
|
||||||
|
|
||||||
void drawColorsEditor() noexcept;
|
void drawColorsEditor() noexcept;
|
||||||
|
|
||||||
@ -66,7 +73,7 @@ class PaletteEditorImGui: public studio::Editor {
|
|||||||
|
|
||||||
void drawColorEditor() noexcept;
|
void drawColorEditor() noexcept;
|
||||||
|
|
||||||
ox::Error renamePage(ox::StringView name) noexcept;
|
ox::Error renamePage(ox::StringViewCR name) noexcept;
|
||||||
|
|
||||||
ox::Error handleCommand(studio::UndoCommand const*) noexcept;
|
ox::Error handleCommand(studio::UndoCommand const*) noexcept;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user