From 13bbd8f9c5f2cb0e17d664d4255f5ea2bdf271d3 Mon Sep 17 00:00:00 2001 From: shweet Date: Sun, 22 Nov 2026 19:09:55 -0500 Subject: [PATCH] Name the id-and-path label for what it is, and drop a duplicate declaration and an unused parameter --- src/document.cpp | 4 ++-- src/localization.h | 2 +- src/ui/libraries.cpp | 2 +- src/ui/panel.cpp | 10 +++++----- src/ui/panel.h | 1 - src/ui/sounds.cpp | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/document.cpp b/src/document.cpp index b5ecf04..68ab016 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -981,9 +981,9 @@ Choices Document::choices_get(SelectionKind kind, int layerId) const if (kind == SelectionKind::SPRITESHEETS) add(content.spritesheets, path_label_get(FORMAT_SPRITESHEET)); if (kind == SelectionKind::SOUNDS) - add(content.sounds, path_label_get(FORMAT_SOUND)); + add(content.sounds, path_label_get(FORMAT_ID_PATH)); if (kind == SelectionKind::LIBRARIES) - add(content.libraries, path_label_get(FORMAT_SOUND)); + add(content.libraries, path_label_get(FORMAT_ID_PATH)); if (kind == SelectionKind::EVENTS) add(content.events, name_get); if (kind == SelectionKind::SHADERS) diff --git a/src/localization.h b/src/localization.h index 1402b1b..1f86e08 100644 --- a/src/localization.h +++ b/src/localization.h @@ -251,7 +251,7 @@ inline constexpr const char* LANGUAGE_STRINGS[LANGUAGE_COUNT] = { X(FORMAT_SIZE, "Size: ({0}, {1})", "Tamaño: ({0}, {1})", "Размер: ({0}, {1})", "大小: ({0}, {1})", "크기: ({0}, {1})") \ X(FORMAT_SPRITESHEET, "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}") \ X(FORMAT_SPRITESHEET_NOT_SAVED, "{0} (Not Saved)", "{0} (No guardado)", "{0} (Не сохранено)", "{0} (未保存)", "{0} (저장되지 않음)") \ - X(FORMAT_SOUND, "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}") \ + X(FORMAT_ID_PATH, "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}") \ X(FORMAT_SHADER, "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}", "#{0} {1}") \ X(FORMAT_TRANSFORM, "Transform: {0}", "Transformar: {0}", "Трансформация: {0}", "变换: {0}", "변환: {0}") \ X(FORMAT_RECT, "Rect: {0}", "Rect: {0}", "Прямоугольник: {0}", "矩形: {0}", "사각형: {0}") \ diff --git a/src/ui/libraries.cpp b/src/ui/libraries.cpp index 9b12821..4c304de 100644 --- a/src/ui/libraries.cpp +++ b/src/ui/libraries.cpp @@ -68,7 +68,7 @@ void libraries_update(Panel& panel) ListRows rows{.label_get = [&](int id) { auto pathString = path_to_utf8(item_get(libraries, id)->path); - return localize_format(FORMAT_SOUND, id, pathString); + return localize_format(FORMAT_ID_PATH, id, pathString); }, .tooltip_draw = [&](int id) { diff --git a/src/ui/panel.cpp b/src/ui/panel.cpp index 28fae97..26f5684 100644 --- a/src/ui/panel.cpp +++ b/src/ui/panel.cpp @@ -26,7 +26,7 @@ void command_push(const Panel& panel, std::function run) {panel.manager.selected, [run = std::move(run)](Manager&, Document& document) { run(document); }}); } -static void row_select(std::set&, int& focus, const ListRows& rows, int key) +static void row_select(int& focus, const ListRows& rows, int key) { focus = key; if (rows.select) @@ -95,7 +95,7 @@ int list_select_begin(Panel& panel, std::set& selection, int& focus, const { storage.clear(); selection.clear(); - row_select(selection, focus, rows, -1); + row_select(focus, rows, -1); } return arrow_key_get(arrowKeys, selection, focus); } @@ -109,7 +109,7 @@ void list_select_end(Panel& panel, std::set& selection, int& focus, const L if (arrowKey != -1) { selection = {arrowKey}; - row_select(selection, focus, rows, arrowKey); + row_select(focus, rows, arrowKey); } if (shortcut(panel.manager.chords[SHORTCUT_CONFIRM], SCOPE_FOCUSED) && selection.size() == 1 && rows.activate) rows.activate(*selection.begin()); @@ -164,7 +164,7 @@ bool row_draw(Panel& panel, std::set& selection, int& focus, const ListRows isActivated = ImGui::Selectable(label.c_str(), isSelected); if (isActivated || ImGui::IsItemClicked(ImGuiMouseButton_Left) || ImGui::IsItemClicked(ImGuiMouseButton_Right)) - row_select(selection, focus, rows, key); + row_select(focus, rows, key); if (isInvalid) ImGui::PopStyleColor(); if (font != FONT_REGULAR) @@ -213,7 +213,7 @@ static void card_draw(Panel& panel, std::set& selection, int& focus, const ImGui::SetKeyboardFocusHere(); if (ImGui::Selectable("##Card Selectable", isSelected, 0, cardSize) || ImGui::IsItemClicked(ImGuiMouseButton_Left) || ImGui::IsItemClicked(ImGuiMouseButton_Right)) - row_select(selection, focus, rows, key); + row_select(focus, rows, key); if (rows.activate && ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) rows.activate(key); diff --git a/src/ui/panel.h b/src/ui/panel.h index 2864860..f247f50 100644 --- a/src/ui/panel.h +++ b/src/ui/panel.h @@ -169,7 +169,6 @@ void events_update(Panel&); void sounds_update(Panel&); std::string layer_label_get(const Layer&); void layer_source_tooltip_draw(const Document&, const Layer&); -void layer_source_tooltip_draw(const Document&, const Layer&); Layer item_edit_layer_get(const Manager::ItemEdit&); Null item_edit_null_get(const Manager::ItemEdit&); void layer_source_draw(Document&, Manager::ItemEdit&); diff --git a/src/ui/sounds.cpp b/src/ui/sounds.cpp index 8c5bde0..80978d5 100644 --- a/src/ui/sounds.cpp +++ b/src/ui/sounds.cpp @@ -83,7 +83,7 @@ void sounds_update(Panel& panel) ListRows rows{.label_get = [&](int id) { auto pathString = path_to_utf8(item_get(sounds, id)->path); - return localize_format(FORMAT_SOUND, id, pathString); + return localize_format(FORMAT_ID_PATH, id, pathString); }, .tooltip_draw = [&](int id) {