diff --git a/src/manager.cpp b/src/manager.cpp index fb12af5..a285462 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -499,11 +499,10 @@ void Manager::autosave_files_write() 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) - autosave_file_remove(path); + for (auto& path : autosaveFiles) + autosave_file_remove(path); autosaveFiles.clear(); autosave_files_write(); diff --git a/src/manager.h b/src/manager.h index 7a393d5..dde4c25 100644 --- a/src/manager.h +++ b/src/manager.h @@ -111,7 +111,7 @@ public: void autosave_files_load(); void autosave_files_open(); void autosave_files_write(); - void autosave_files_clear(bool removeFiles = false); + void autosave_files_clear(); void settings_apply(Settings&); }; diff --git a/src/ui/animations.cpp b/src/ui/animations.cpp index 88cf01d..9bcd6cc 100644 --- a/src/ui/animations.cpp +++ b/src/ui/animations.cpp @@ -745,7 +745,7 @@ void animations_update(Panel& panel, AnimationsPanel& animations) list_select_end(panel, selection, focus, rows, arrowKey); animations_selection_set(document, selection, groupSelection); }, - false, &footerActions); + LIST_ROWS, &footerActions); } ImGui::End(); diff --git a/src/ui/autosave_restore.cpp b/src/ui/autosave_restore.cpp index 9bd82de..a6d28d3 100644 --- a/src/ui/autosave_restore.cpp +++ b/src/ui/autosave_restore.cpp @@ -45,7 +45,7 @@ void AutosaveRestore::update(Manager& manager) if (ImGui::Button(localize.get(BASIC_NO), widgetSize)) { - manager.autosave_files_clear(true); + manager.autosave_files_clear(); isRestoreAvailable = false; popup.close(); } diff --git a/src/ui/libraries.cpp b/src/ui/libraries.cpp index fce4872..1f11635 100644 --- a/src/ui/libraries.cpp +++ b/src/ui/libraries.cpp @@ -98,7 +98,7 @@ void libraries_update(Panel& panel) .cardLines = LIBRARY_CARD_LINES}; list_panel_draw( 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(); } diff --git a/src/ui/panel.cpp b/src/ui/panel.cpp index d80dd55..07326d7 100644 --- a/src/ui/panel.cpp +++ b/src/ui/panel.cpp @@ -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. -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_ItemSpacing, state.tooltipSpacing); - if (isItem ? ImGui::BeginItemTooltip() : ImGui::BeginTooltip()) + if (anchor == TOOLTIP_ITEM ? ImGui::BeginItemTooltip() : ImGui::BeginTooltip()) return true; ImGui::PopStyleVar(2); 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& list, - bool isCards, Actions* footerActions) + ListLayout layout, Actions* footerActions) { + auto isCards = layout == LIST_CARDS; auto& [manager, settings, resources, dialog, clipboard, document, state] = panel; state.tooltipPadding = ImGui::GetStyle().WindowPadding; state.tooltipSpacing = ImGui::GetStyle().ItemSpacing; diff --git a/src/ui/panel.h b/src/ui/panel.h index 62c7aed..7aa9622 100644 --- a/src/ui/panel.h +++ b/src/ui/panel.h @@ -103,8 +103,22 @@ void list_draw(Panel&, const std::vector&, std::set&, int&, const List void content_list_draw(Panel&, SelectionKind, const std::vector&, const ListRows&); int list_select_begin(Panel&, std::set&, int&, const ListRows&, const std::vector&); void list_select_end(Panel&, std::set&, int&, const ListRows&, int); -void list_panel_draw(Panel&, Actions&, const Footer&, const std::function&, bool = false, Actions* = nullptr); -bool tooltip_begin(const PanelState&, bool = true); +enum ListLayout +{ + 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&, ListLayout = LIST_ROWS, + Actions* = nullptr); +bool tooltip_begin(const PanelState&, TooltipAnchor = TOOLTIP_ITEM); void tooltip_end(); void tooltip_name_draw(Resources&, const std::string&); void tooltip_image_draw(const CardImage&, const std::function&); diff --git a/src/ui/regions.cpp b/src/ui/regions.cpp index a266da1..59642e2 100644 --- a/src/ui/regions.cpp +++ b/src/ui/regions.cpp @@ -233,7 +233,7 @@ static void region_drag_tooltip_update(Panel& panel) auto mousePos = ImGui::GetIO().MousePos; 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; for (auto regionId : state.dragIds) 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); region_drag_tooltip_update(panel); }, - true); + LIST_CARDS); } } ImGui::End(); diff --git a/src/ui/shaders.cpp b/src/ui/shaders.cpp index 7d34985..2f0f34c 100644 --- a/src/ui/shaders.cpp +++ b/src/ui/shaders.cpp @@ -351,7 +351,7 @@ void shaders_update(Panel& panel, ShadersPanel& shaders) .cardLines = SHADER_CARD_LINES}; list_panel_draw( 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()) { diff --git a/src/ui/sounds.cpp b/src/ui/sounds.cpp index 5cbad48..0b91e3d 100644 --- a/src/ui/sounds.cpp +++ b/src/ui/sounds.cpp @@ -108,7 +108,7 @@ void sounds_update(Panel& panel) .cardLines = SOUND_CARD_LINES}; list_panel_draw( 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(); } diff --git a/src/ui/spritesheets.cpp b/src/ui/spritesheets.cpp index 3d90e87..25dc9ad 100644 --- a/src/ui/spritesheets.cpp +++ b/src/ui/spritesheets.cpp @@ -316,7 +316,7 @@ void spritesheets_update(Panel& panel, SpritesheetsPanel& spritesheets) .cardLines = SPRITESHEET_CARD_LINES}; list_panel_draw( 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(); diff --git a/src/ui/timeline.cpp b/src/ui/timeline.cpp index fa708ff..92abf91 100644 --- a/src/ui/timeline.cpp +++ b/src/ui/timeline.cpp @@ -162,9 +162,9 @@ void TimelineContext::shortcuts_update() if (shortcut(manager.chords[SHORTCUT_PLAY_PAUSE], SCOPE_GLOBAL)) playback.toggle(); 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)) - marker_set(false, (int)playback.time); + marker_set(MARKER_END, (int)playback.time); if (shortcut(manager.chords[SHORTCUT_MOVE_PLAYHEAD_BACK], SCOPE_GLOBAL)) { diff --git a/src/ui/timeline_context.h b/src/ui/timeline_context.h index 8ac9643..3694a66 100644 --- a/src/ui/timeline_context.h +++ b/src/ui/timeline_context.h @@ -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, 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. struct RowToggle { @@ -209,7 +222,7 @@ struct TimelineContext : TimelineState std::set item_references_for_current_get(); std::set copy_frame_references_get(); void command_push(std::function 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 frame_insert(); void frames_delete_action(); @@ -242,7 +255,7 @@ struct TimelineContext : TimelineState void item_group(); void rows_move_to_row(std::vector draggedRows, TimelineRow targetRow, DropZone zone); void fit_animation_length(); - void marker_set(bool, int); + void marker_set(MarkerType, int); void markers_remove(); void frame_references_copy(const std::set& selectedFrames); void copy(); diff --git a/src/ui/timeline_edit.cpp b/src/ui/timeline_edit.cpp index 284eaf5..ff85b5c 100644 --- a/src/ui/timeline_edit.cpp +++ b/src/ui/timeline_edit.cpp @@ -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. -void TimelineContext::marker_set(bool isStart, int time) +void TimelineContext::marker_set(MarkerType type, int time) { + auto isStart = type == MARKER_START; if (!animation) return; edit_push(isStart ? EDIT_START_MARKER : EDIT_END_MARKER, diff --git a/src/ui/timeline_frames.cpp b/src/ui/timeline_frames.cpp index 0403bde..c7259af 100644 --- a/src/ui/timeline_frames.cpp +++ b/src/ui/timeline_frames.cpp @@ -266,11 +266,11 @@ void TimelineContext::frame_child(const TimelineRow& row, int& index, float widt markerActions.add({.label = LABEL_ADD_START_MARKER, .shortcut = SHORTCUT_START_MARKER, .isEnabled = isAnimation, - .run = [&]() { marker_set(true, markerTime); }}); + .run = [&]() { marker_set(MARKER_START, markerTime); }}); markerActions.add({.label = LABEL_ADD_END_MARKER, .shortcut = SHORTCUT_END_MARKER, .isEnabled = isAnimation, - .run = [&]() { marker_set(false, markerTime); }}); + .run = [&]() { marker_set(MARKER_END, markerTime); }}); markerActions.separator(); markerActions.add( {.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; playheadLineTopY = playheadMax.y; 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) @@ -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)); ImGui::SetCursorPos(iconPos); 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) frameTime += frame.duration; diff --git a/src/ui/timeline_menus.cpp b/src/ui/timeline_menus.cpp index 059767b..de70c87 100644 --- a/src/ui/timeline_menus.cpp +++ b/src/ui/timeline_menus.cpp @@ -25,9 +25,9 @@ void TimelineContext::frame_begin() 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; auto min = ImGui::GetItemRectMin(); auto max = ImGui::GetItemRectMax(); diff --git a/src/ui/timeline_tracks.cpp b/src/ui/timeline_tracks.cpp index 2dbd01f..79f8492 100644 --- a/src/ui/timeline_tracks.cpp +++ b/src/ui/timeline_tracks.cpp @@ -72,7 +72,7 @@ void TimelineContext::item_child(const TimelineRow& row, int index) ImGui::Image(resources.icon_id_get(folderIcon), icon_size_get()); auto iconMin = ImGui::GetItemRectMin(); auto iconMax = ImGui::GetItemRectMax(); - overlay_icon(resources.icon_id_get(folderIcon), itemIconTint, false); + overlay_icon(resources.icon_id_get(folderIcon), itemIconTint); ImGui::SameLine(); ImGui::PushStyleColor(ImGuiCol_Text, itemTextColor); @@ -291,7 +291,7 @@ void TimelineContext::item_child(const TimelineRow& row, int index) else expandedLayerTracks.insert(item->uid); } - overlay_icon(resources.icon_id_get(icon), iconTintCurrent, false); + overlay_icon(resources.icon_id_get(icon), iconTintCurrent); ImGui::SameLine(); if (isReferenced) 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)); auto texture = resources.icon_id_get(toggle.isOn ? toggle.on : toggle.off); 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); ImGui::PopStyleVar(2); ImGui::PopStyleColor(3);