Name markers, icon overlays, list layouts and tooltip anchors instead of passing bools

Autosaves are only ever cleared along with their files, so that flag goes.
This commit is contained in:
shweet committed 2026-11-22 19:16:25 -05:00
1 parent c891e1a873
commit 7bacfe0cd6
17 files changed
+58 -30

No files matched your search

+1 -2
View File
@@ -499,9 +499,8 @@ void Manager::autosave_files_write()
path_list_save(autosave_path_get(), autosaveFiles, "autosave files"); path_list_save(autosave_path_get(), autosaveFiles, "autosave files");
} }
void Manager::autosave_files_clear(bool removeFiles) void Manager::autosave_files_clear()
{ {
if (removeFiles)
for (auto& path : autosaveFiles) for (auto& path : autosaveFiles)
autosave_file_remove(path); autosave_file_remove(path);
+1 -1
View File
@@ -111,7 +111,7 @@ public:
void autosave_files_load(); void autosave_files_load();
void autosave_files_open(); void autosave_files_open();
void autosave_files_write(); void autosave_files_write();
void autosave_files_clear(bool removeFiles = false); void autosave_files_clear();
void settings_apply(Settings&); void settings_apply(Settings&);
}; };
+1 -1
View File
@@ -745,7 +745,7 @@ void animations_update(Panel& panel, AnimationsPanel& animations)
list_select_end(panel, selection, focus, rows, arrowKey); list_select_end(panel, selection, focus, rows, arrowKey);
animations_selection_set(document, selection, groupSelection); animations_selection_set(document, selection, groupSelection);
}, },
false, &footerActions); LIST_ROWS, &footerActions);
} }
ImGui::End(); ImGui::End();
+1 -1
View File
@@ -45,7 +45,7 @@ void AutosaveRestore::update(Manager& manager)
if (ImGui::Button(localize.get(BASIC_NO), widgetSize)) if (ImGui::Button(localize.get(BASIC_NO), widgetSize))
{ {
manager.autosave_files_clear(true); manager.autosave_files_clear();
isRestoreAvailable = false; isRestoreAvailable = false;
popup.close(); popup.close();
} }
+1 -1
View File
@@ -98,7 +98,7 @@ void libraries_update(Panel& panel)
.cardLines = LIBRARY_CARD_LINES}; .cardLines = LIBRARY_CARD_LINES};
list_panel_draw( list_panel_draw(
panel, actions, {{ACTION_ADD, ACTION_REMOVE, ACTION_RELOAD, ACTION_OPEN}}, panel, actions, {{ACTION_ADD, ACTION_REMOVE, ACTION_RELOAD, ACTION_OPEN}},
[&]() { content_list_draw(panel, SelectionKind::LIBRARIES, item_ids_get(libraries), rows); }, true); [&]() { content_list_draw(panel, SelectionKind::LIBRARIES, item_ids_get(libraries), rows); }, LIST_CARDS);
} }
ImGui::End(); ImGui::End();
} }
+4 -3
View File
@@ -43,11 +43,11 @@ static void row_scroll_update(PanelState& state, int key, int arrowKey)
} }
// Tooltips keep the window's padding and spacing, which card lists zero out for themselves. // Tooltips keep the window's padding and spacing, which card lists zero out for themselves.
bool tooltip_begin(const PanelState& state, bool isItem) bool tooltip_begin(const PanelState& state, TooltipAnchor anchor)
{ {
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, state.tooltipPadding); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, state.tooltipPadding);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, state.tooltipSpacing); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, state.tooltipSpacing);
if (isItem ? ImGui::BeginItemTooltip() : ImGui::BeginTooltip()) if (anchor == TOOLTIP_ITEM ? ImGui::BeginItemTooltip() : ImGui::BeginTooltip())
return true; return true;
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
return false; return false;
@@ -434,8 +434,9 @@ static void content_remove_popup_draw(Panel& panel)
} }
void list_panel_draw(Panel& panel, Actions& actions, const Footer& footer, const std::function<void()>& list, void list_panel_draw(Panel& panel, Actions& actions, const Footer& footer, const std::function<void()>& list,
bool isCards, Actions* footerActions) ListLayout layout, Actions* footerActions)
{ {
auto isCards = layout == LIST_CARDS;
auto& [manager, settings, resources, dialog, clipboard, document, state] = panel; auto& [manager, settings, resources, dialog, clipboard, document, state] = panel;
state.tooltipPadding = ImGui::GetStyle().WindowPadding; state.tooltipPadding = ImGui::GetStyle().WindowPadding;
state.tooltipSpacing = ImGui::GetStyle().ItemSpacing; state.tooltipSpacing = ImGui::GetStyle().ItemSpacing;
+16 -2
View File
@@ -103,8 +103,22 @@ void list_draw(Panel&, const std::vector<int>&, std::set<int>&, int&, const List
void content_list_draw(Panel&, SelectionKind, const std::vector<int>&, const ListRows&); void content_list_draw(Panel&, SelectionKind, const std::vector<int>&, const ListRows&);
int list_select_begin(Panel&, std::set<int>&, int&, const ListRows&, const std::vector<int>&); int list_select_begin(Panel&, std::set<int>&, int&, const ListRows&, const std::vector<int>&);
void list_select_end(Panel&, std::set<int>&, int&, const ListRows&, int); void list_select_end(Panel&, std::set<int>&, int&, const ListRows&, int);
void list_panel_draw(Panel&, Actions&, const Footer&, const std::function<void()>&, bool = false, Actions* = nullptr); enum ListLayout
bool tooltip_begin(const PanelState&, bool = true); {
LIST_ROWS,
LIST_CARDS
};
// Where a tooltip shows: by the hovered item, or by the mouse.
enum TooltipAnchor
{
TOOLTIP_ITEM,
TOOLTIP_MOUSE
};
void list_panel_draw(Panel&, Actions&, const Footer&, const std::function<void()>&, ListLayout = LIST_ROWS,
Actions* = nullptr);
bool tooltip_begin(const PanelState&, TooltipAnchor = TOOLTIP_ITEM);
void tooltip_end(); void tooltip_end();
void tooltip_name_draw(Resources&, const std::string&); void tooltip_name_draw(Resources&, const std::string&);
void tooltip_image_draw(const CardImage&, const std::function<void()>&); void tooltip_image_draw(const CardImage&, const std::function<void()>&);
+2 -2
View File
@@ -233,7 +233,7 @@ static void region_drag_tooltip_update(Panel& panel)
auto mousePos = ImGui::GetIO().MousePos; auto mousePos = ImGui::GetIO().MousePos;
ImGui::SetNextWindowPos(ImVec2(mousePos.x + DRAG_TOOLTIP_OFFSET.x, mousePos.y + DRAG_TOOLTIP_OFFSET.y)); ImGui::SetNextWindowPos(ImVec2(mousePos.x + DRAG_TOOLTIP_OFFSET.x, mousePos.y + DRAG_TOOLTIP_OFFSET.y));
if (!tooltip_begin(state, false)) if (!tooltip_begin(state, TOOLTIP_MOUSE))
return; return;
for (auto regionId : state.dragIds) for (auto regionId : state.dragIds)
if (auto region = item_get(spritesheet->regions, regionId)) if (auto region = item_get(spritesheet->regions, regionId))
@@ -505,7 +505,7 @@ void regions_update(Panel& panel, RegionsPanel& regions)
content_list_draw(panel, SelectionKind::REGIONS, item_ids_get(spritesheet->regions), rows); content_list_draw(panel, SelectionKind::REGIONS, item_ids_get(spritesheet->regions), rows);
region_drag_tooltip_update(panel); region_drag_tooltip_update(panel);
}, },
true); LIST_CARDS);
} }
} }
ImGui::End(); ImGui::End();
+1 -1
View File
@@ -351,7 +351,7 @@ void shaders_update(Panel& panel, ShadersPanel& shaders)
.cardLines = SHADER_CARD_LINES}; .cardLines = SHADER_CARD_LINES};
list_panel_draw( list_panel_draw(
panel, actions, {{ACTION_ADD, ACTION_REMOVE, ACTION_RELOAD}}, panel, actions, {{ACTION_ADD, ACTION_REMOVE, ACTION_RELOAD}},
[&]() { content_list_draw(panel, SelectionKind::SHADERS, item_ids_get(items), rows); }, true); [&]() { content_list_draw(panel, SelectionKind::SHADERS, item_ids_get(items), rows); }, LIST_CARDS);
if (propertiesPopup.begin()) if (propertiesPopup.begin())
{ {
+1 -1
View File
@@ -108,7 +108,7 @@ void sounds_update(Panel& panel)
.cardLines = SOUND_CARD_LINES}; .cardLines = SOUND_CARD_LINES};
list_panel_draw( list_panel_draw(
panel, actions, {{ACTION_ADD, ACTION_REMOVE, ACTION_RELOAD, ACTION_REPLACE}}, panel, actions, {{ACTION_ADD, ACTION_REMOVE, ACTION_RELOAD, ACTION_REPLACE}},
[&]() { content_list_draw(panel, SelectionKind::SOUNDS, item_ids_get(sounds), rows); }, true); [&]() { content_list_draw(panel, SelectionKind::SOUNDS, item_ids_get(sounds), rows); }, LIST_CARDS);
} }
ImGui::End(); ImGui::End();
} }
+1 -1
View File
@@ -316,7 +316,7 @@ void spritesheets_update(Panel& panel, SpritesheetsPanel& spritesheets)
.cardLines = SPRITESHEET_CARD_LINES}; .cardLines = SPRITESHEET_CARD_LINES};
list_panel_draw( list_panel_draw(
panel, actions, {{ACTION_ADD, ACTION_RELOAD, ACTION_REPLACE}, {ACTION_REMOVE, ACTION_SAVE}}, panel, actions, {{ACTION_ADD, ACTION_RELOAD, ACTION_REPLACE}, {ACTION_REMOVE, ACTION_SAVE}},
[&]() { content_list_draw(panel, SelectionKind::SPRITESHEETS, item_ids_get(items), rows); }, true); [&]() { content_list_draw(panel, SelectionKind::SPRITESHEETS, item_ids_get(items), rows); }, LIST_CARDS);
} }
ImGui::End(); ImGui::End();
+2 -2
View File
@@ -162,9 +162,9 @@ void TimelineContext::shortcuts_update()
if (shortcut(manager.chords[SHORTCUT_PLAY_PAUSE], SCOPE_GLOBAL)) if (shortcut(manager.chords[SHORTCUT_PLAY_PAUSE], SCOPE_GLOBAL))
playback.toggle(); playback.toggle();
if (shortcut(manager.chords[SHORTCUT_START_MARKER], SCOPE_GLOBAL)) if (shortcut(manager.chords[SHORTCUT_START_MARKER], SCOPE_GLOBAL))
marker_set(true, (int)playback.time); marker_set(MARKER_START, (int)playback.time);
if (shortcut(manager.chords[SHORTCUT_END_MARKER], SCOPE_GLOBAL)) if (shortcut(manager.chords[SHORTCUT_END_MARKER], SCOPE_GLOBAL))
marker_set(false, (int)playback.time); marker_set(MARKER_END, (int)playback.time);
if (shortcut(manager.chords[SHORTCUT_MOVE_PLAYHEAD_BACK], SCOPE_GLOBAL)) if (shortcut(manager.chords[SHORTCUT_MOVE_PLAYHEAD_BACK], SCOPE_GLOBAL))
{ {
+15 -2
View File
@@ -124,6 +124,19 @@ inline bool is_trigger_reference(const Reference& reference)
constexpr Icon INTERPOLATION_ICONS[] = {ICON_UNINTERPOLATED, ICON_INTERPOLATED, ICON_EASE_IN, ICON_EASE_OUT, constexpr Icon INTERPOLATION_ICONS[] = {ICON_UNINTERPOLATED, ICON_INTERPOLATED, ICON_EASE_IN, ICON_EASE_OUT,
ICON_EASE_IN_OUT}; ICON_EASE_IN_OUT};
enum MarkerType
{
MARKER_START,
MARKER_END
};
// When an icon gets its tint drawn over it: only in the light theme, or always.
enum IconOverlay
{
OVERLAY_LIGHT_THEME,
OVERLAY_ALWAYS
};
// An icon button that shows whether something is on. // An icon button that shows whether something is on.
struct RowToggle struct RowToggle
{ {
@@ -209,7 +222,7 @@ struct TimelineContext : TimelineState
std::set<Reference> item_references_for_current_get(); std::set<Reference> item_references_for_current_get();
std::set<Reference> copy_frame_references_get(); std::set<Reference> copy_frame_references_get();
void command_push(std::function<void(Manager&, Document&)> run); void command_push(std::function<void(Manager&, Document&)> run);
void overlay_icon(GLuint textureId, ImVec4 tint, bool isForced = false); void overlay_icon(GLuint textureId, ImVec4 tint, IconOverlay = OVERLAY_LIGHT_THEME);
void playback_stop(); void playback_stop();
void frame_insert(); void frame_insert();
void frames_delete_action(); void frames_delete_action();
@@ -242,7 +255,7 @@ struct TimelineContext : TimelineState
void item_group(); void item_group();
void rows_move_to_row(std::vector<TimelineRow> draggedRows, TimelineRow targetRow, DropZone zone); void rows_move_to_row(std::vector<TimelineRow> draggedRows, TimelineRow targetRow, DropZone zone);
void fit_animation_length(); void fit_animation_length();
void marker_set(bool, int); void marker_set(MarkerType, int);
void markers_remove(); void markers_remove();
void frame_references_copy(const std::set<Reference>& selectedFrames); void frame_references_copy(const std::set<Reference>& selectedFrames);
void copy(); void copy();
+2 -1
View File
@@ -320,8 +320,9 @@ void TimelineContext::paste()
} }
// Sets the animation's start or end marker at a time, moving the other one if it would end up on the wrong side. // Sets the animation's start or end marker at a time, moving the other one if it would end up on the wrong side.
void TimelineContext::marker_set(bool isStart, int time) void TimelineContext::marker_set(MarkerType type, int time)
{ {
auto isStart = type == MARKER_START;
if (!animation) if (!animation)
return; return;
edit_push(isStart ? EDIT_START_MARKER : EDIT_END_MARKER, edit_push(isStart ? EDIT_START_MARKER : EDIT_END_MARKER,
+4 -4
View File
@@ -266,11 +266,11 @@ void TimelineContext::frame_child(const TimelineRow& row, int& index, float widt
markerActions.add({.label = LABEL_ADD_START_MARKER, markerActions.add({.label = LABEL_ADD_START_MARKER,
.shortcut = SHORTCUT_START_MARKER, .shortcut = SHORTCUT_START_MARKER,
.isEnabled = isAnimation, .isEnabled = isAnimation,
.run = [&]() { marker_set(true, markerTime); }}); .run = [&]() { marker_set(MARKER_START, markerTime); }});
markerActions.add({.label = LABEL_ADD_END_MARKER, markerActions.add({.label = LABEL_ADD_END_MARKER,
.shortcut = SHORTCUT_END_MARKER, .shortcut = SHORTCUT_END_MARKER,
.isEnabled = isAnimation, .isEnabled = isAnimation,
.run = [&]() { marker_set(false, markerTime); }}); .run = [&]() { marker_set(MARKER_END, markerTime); }});
markerActions.separator(); markerActions.separator();
markerActions.add( markerActions.add(
{.label = LABEL_REMOVE_MARKERS, {.label = LABEL_REMOVE_MARKERS,
@@ -292,7 +292,7 @@ void TimelineContext::frame_child(const TimelineRow& row, int& index, float widt
playheadLineCenterX = (playheadMin.x + playheadMax.x) * 0.5f; playheadLineCenterX = (playheadMin.x + playheadMax.x) * 0.5f;
playheadLineTopY = playheadMax.y; playheadLineTopY = playheadMax.y;
isPlayheadLineSet = true; isPlayheadLineSet = true;
overlay_icon(resources.icon_id_get(ICON_PLAYHEAD), playheadIconTint, true); overlay_icon(resources.icon_id_get(ICON_PLAYHEAD), playheadIconTint, OVERLAY_ALWAYS);
} }
} }
else if (animation) else if (animation)
@@ -520,7 +520,7 @@ void TimelineContext::frame_child(const TimelineRow& row, int& index, float widt
cursorPos.y + (frameSize.y / 2) - (icon_size_get().y / 2)); cursorPos.y + (frameSize.y / 2) - (icon_size_get().y / 2));
ImGui::SetCursorPos(iconPos); ImGui::SetCursorPos(iconPos);
ImGui::Image(resources.icon_id_get(icon), icon_size_get()); ImGui::Image(resources.icon_id_get(icon), icon_size_get());
overlay_icon(resources.icon_id_get(icon), iconTintDefault, false); overlay_icon(resources.icon_id_get(icon), iconTintDefault);
if (type != TRIGGER) if (type != TRIGGER)
frameTime += frame.duration; frameTime += frame.duration;
+2 -2
View File
@@ -25,9 +25,9 @@ void TimelineContext::frame_begin()
itemTextColor = isLightTheme ? ITEM_TEXT_COLOR_LIGHT : ITEM_TEXT_COLOR_DARK; itemTextColor = isLightTheme ? ITEM_TEXT_COLOR_LIGHT : ITEM_TEXT_COLOR_DARK;
} }
void TimelineContext::overlay_icon(GLuint textureId, ImVec4 tint, bool isForced) void TimelineContext::overlay_icon(GLuint textureId, ImVec4 tint, IconOverlay overlay)
{ {
if (!isForced && !isLightTheme) if (overlay == OVERLAY_LIGHT_THEME && !isLightTheme)
return; return;
auto min = ImGui::GetItemRectMin(); auto min = ImGui::GetItemRectMin();
auto max = ImGui::GetItemRectMax(); auto max = ImGui::GetItemRectMax();
+3 -3
View File
@@ -72,7 +72,7 @@ void TimelineContext::item_child(const TimelineRow& row, int index)
ImGui::Image(resources.icon_id_get(folderIcon), icon_size_get()); ImGui::Image(resources.icon_id_get(folderIcon), icon_size_get());
auto iconMin = ImGui::GetItemRectMin(); auto iconMin = ImGui::GetItemRectMin();
auto iconMax = ImGui::GetItemRectMax(); auto iconMax = ImGui::GetItemRectMax();
overlay_icon(resources.icon_id_get(folderIcon), itemIconTint, false); overlay_icon(resources.icon_id_get(folderIcon), itemIconTint);
ImGui::SameLine(); ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, itemTextColor); ImGui::PushStyleColor(ImGuiCol_Text, itemTextColor);
@@ -291,7 +291,7 @@ void TimelineContext::item_child(const TimelineRow& row, int index)
else else
expandedLayerTracks.insert(item->uid); expandedLayerTracks.insert(item->uid);
} }
overlay_icon(resources.icon_id_get(icon), iconTintCurrent, false); overlay_icon(resources.icon_id_get(icon), iconTintCurrent);
ImGui::SameLine(); ImGui::SameLine();
if (isReferenced) if (isReferenced)
ImGui::PushFont(resources.fonts[FONT_ITALICS], FONT_SIZE); ImGui::PushFont(resources.fonts[FONT_ITALICS], FONT_SIZE);
@@ -533,7 +533,7 @@ bool TimelineContext::row_toggle_draw(ImVec2 itemSize, int slot, const RowToggle
ImVec2(itemSize.x - lineHeight * slot - ImGui::GetStyle().ItemSpacing.x, (itemSize.y - lineHeight) / 2)); ImVec2(itemSize.x - lineHeight * slot - ImGui::GetStyle().ItemSpacing.x, (itemSize.y - lineHeight) / 2));
auto texture = resources.icon_id_get(toggle.isOn ? toggle.on : toggle.off); auto texture = resources.icon_id_get(toggle.isOn ? toggle.on : toggle.off);
auto isClicked = ImGui::ImageButton(toggle.id, texture, icon_size_get()); auto isClicked = ImGui::ImageButton(toggle.id, texture, icon_size_get());
overlay_icon(texture, tint, false); overlay_icon(texture, tint);
tooltip_set(toggle.isOn ? toggle.onTooltip : toggle.offTooltip); tooltip_set(toggle.isOn ? toggle.onTooltip : toggle.offTooltip);
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);
ImGui::PopStyleColor(3); ImGui::PopStyleColor(3);