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:
1 parent
c891e1a873
commit
7bacfe0cd6
17 files changed
+60
-32
No files matched your search
+3
-4
@@ -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();
|
||||
|
||||
+1
-1
@@ -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&);
|
||||
};
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
+4
-3
@@ -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<void()>& 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;
|
||||
|
||||
+16
-2
@@ -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&);
|
||||
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_panel_draw(Panel&, Actions&, const Footer&, const std::function<void()>&, 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<void()>&, 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<void()>&);
|
||||
|
||||
+2
-2
@@ -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();
|
||||
|
||||
+1
-1
@@ -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())
|
||||
{
|
||||
|
||||
+1
-1
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
+2
-2
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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<Reference> item_references_for_current_get();
|
||||
std::set<Reference> copy_frame_references_get();
|
||||
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 frame_insert();
|
||||
void frames_delete_action();
|
||||
@@ -242,7 +255,7 @@ struct TimelineContext : TimelineState
|
||||
void item_group();
|
||||
void rows_move_to_row(std::vector<TimelineRow> 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<Reference>& selectedFrames);
|
||||
void copy();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user