Stage 8c: timeline cleanup

- One TimelineRow type for rows, row selection and drag payloads (replaces
  TimelineItemRow + TimelineRowReference).
- Frame/track selection helpers live on Document (frames_select, frame_select,
  frame_toggle, frames_range_select, frame_focus_select, focus_clear,
  track_select) instead of TimelineContext *_for(Document&) wrappers.
- Drop target and frame-move drag carry References; selection anchors are
  optionals; single-use helpers and write-only fields are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-03 17:55:14 -04:00
1 parent 6f7a457f8f
commit dc32483c45
10 files changed
+245 -393

No files matched your search

+88
View File
@@ -747,6 +747,94 @@ namespace anm2ed
return choices;
}
// Selects the frames an edit returned and moves the playhead to the first.
void Document::frames_select(const edit::Uids& uids)
{
auto references = references_get(uids);
if (references.empty()) return;
auto focus = references.front();
editTarget = EditTarget::FRAME;
frame_references_set({references.begin(), references.end()});
reference_set(focus);
if (auto item = model.track_get(focus); item && focus.itemType != TRIGGER)
frameTime = model::frame_time_from_index_get(*item, focus.frameIndex);
}
void Document::frame_select(Reference frameReference)
{
selection.uids[SelectionKind::GROUPS].clear();
editTarget = EditTarget::FRAME;
frame_references_set({frameReference});
reference_set(frameReference);
}
void Document::frame_toggle(Reference frameReference)
{
selection.uids[SelectionKind::GROUPS].clear();
editTarget = EditTarget::FRAME;
auto frames = frame_references_get(FrameReferenceFallback::NONE);
if (!frames.contains(frameReference))
frames.insert(frameReference);
else if (frames.size() > 1)
frames.erase(frameReference);
frame_references_set(frames);
reference_set(frameReference);
}
// Selects frames first..last of one track (added to the selection when additive).
bool Document::frames_range_select(Reference firstReference, Reference lastReference, bool isAdditive)
{
selection.uids[SelectionKind::GROUPS].clear();
editTarget = EditTarget::FRAME;
if (document::item_reference_get(firstReference) != document::item_reference_get(lastReference) ||
firstReference.frameIndex < 0 || lastReference.frameIndex < 0)
return false;
auto item = model.track_get(lastReference);
if (!item || std::max(firstReference.frameIndex, lastReference.frameIndex) >= model::track_frames_count_get(*item))
return false;
auto [firstIndex, lastIndex] = std::minmax(firstReference.frameIndex, lastReference.frameIndex);
auto selectedFrames = isAdditive ? frame_references_get(FrameReferenceFallback::NONE) : std::set<Reference>{};
for (int i = firstIndex; i <= lastIndex; ++i)
{
auto frameReference = lastReference;
frameReference.frameIndex = i;
selectedFrames.insert(frameReference);
}
frame_references_set(selectedFrames);
reference_set(lastReference);
return true;
}
void Document::frame_focus_select()
{
auto targetReference = reference_get();
if (targetReference.frameIndex < 0) return frame_references_clear();
editTarget = EditTarget::FRAME;
frame_references_set({targetReference});
}
void Document::focus_clear()
{
reference_set({reference_get().animationIndex});
frame_references_clear();
selection.uids[SelectionKind::TRACKS].clear();
}
// Selects a track (its layer's spritesheet becomes the focused one).
void Document::track_select(Reference itemReference)
{
itemReference.frameIndex = -1;
if (itemReference.itemType == LAYER)
if (auto layer = model::item_get(model.content.layers, itemReference.itemID))
focused_id_set(SelectionKind::SPRITESHEETS, layer->spritesheetId);
reference_set(itemReference);
frame_references_clear();
selected_set(SelectionKind::TRACKS, {itemReference});
}
std::set<int> Document::animations_selected_get() const
{
std::set<int> indices{};
+7
View File
@@ -157,6 +157,13 @@ namespace anm2ed
void focused_id_set(SelectionKind, int);
void selected_clear(SelectionKind);
Choices choices_get(SelectionKind, int = -1) const;
void frames_select(const edit::Uids&);
void frame_select(Reference);
void frame_toggle(Reference);
bool frames_range_select(Reference, Reference, bool);
void frame_focus_select();
void focus_clear();
void track_select(Reference);
std::set<int> animations_selected_get() const;
void animations_selected_set(const std::set<int>&);
std::set<Reference> item_frame_references_get(Reference) const;
+17 -58
View File
@@ -136,23 +136,8 @@ namespace anm2ed::imgui
resource::icon::EASE_IN, resource::icon::EASE_OUT,
resource::icon::EASE_IN_OUT};
struct TimelineItemRow
{
int type{NONE};
int id{-1};
int index{-1};
int groupId{-1};
int rootGroupType{NONE};
int rootGroupId{-1};
int depth{};
bool isGroup{};
};
struct RootFrameSpan
{
int start{};
int end{};
};
Reference row_item_reference_get(const TimelineRow&);
Reference row_selection_reference_get(const TimelineRow&);
struct TimelineContext : TimelineState
{
@@ -183,12 +168,7 @@ namespace anm2ed::imgui
ImVec4 itemTextColor{};
std::optional<int> frameSplitTimeAtCursor{};
int frameMoveDropType{NONE};
int frameMoveDropItemID{-1};
int frameMoveDropGroupType{NONE};
int frameMoveDropGroupId{-1};
int frameMoveDropIndex{-1};
bool isFrameMoveDropTarget{};
std::optional<Reference> frameMoveDropTarget{};
float playheadLineCenterX{};
float playheadLineTopY{};
bool isPlayheadLineSet{};
@@ -201,8 +181,7 @@ namespace anm2ed::imgui
const model::Track* selected_item_get();
const model::TrackGroup* track_group_get(int type, int groupId);
bool is_track_group_visible(int type, int groupId);
const model::TrackGroup* row_group_get(const TimelineItemRow& row);
const model::Track* command_item_reference_get(Document& document, Reference itemReference);
const model::TrackGroup* row_group_get(const TimelineRow& row);
glm::vec4 color_get(TimelineColor, int);
std::set<Reference> drag_frame_references_get(const Reference&);
// Queues an edit on the document; its result is selected (frames by default).
@@ -213,26 +192,17 @@ namespace anm2ed::imgui
[=, this](Manager&, Document& document) mutable
{
auto uids = document.edit_apply(label, operation);
select ? select(document, uids) : frames_select_for(document, uids);
select ? select(document, uids) : document.frames_select(uids);
});
}
void edit_begin_push(StringType);
void reference_set(Reference);
void frames_select_for(Document&, const edit::Uids&);
const model::Frame* command_frame_get(Document& document, const Reference& targetReference);
Reference item_reference_get(int type, int id, int groupType = NONE, int groupId = -1);
Reference item_reference_from_frame_get(Reference frameReference);
bool is_same_item(const Reference& left, const Reference& right);
void group_selection_reset_for(Document& targetDocument);
std::set<Reference> item_references_for_current_get();
void frame_selection_set_for(Document& targetDocument, Reference frameReference);
void frame_selection_toggle_for(Document& targetDocument, Reference frameReference);
bool frame_selection_range_set_for(Document& targetDocument, Reference firstReference, Reference lastReference,
bool isAdditive);
std::set<Reference> copy_frame_references_get();
void frames_selection_set_reference_for(Document& targetDocument);
void reference_clear_for(Document& targetDocument);
void reference_set_timeline_item_reference_for(Document& targetDocument, Reference itemReference);
void command_push(std::function<void(Manager&, Document&)> run);
void overlay_icon(GLuint textureId, ImVec4 tint, bool isForced = false);
void playback_stop();
@@ -250,27 +220,19 @@ namespace anm2ed::imgui
bool is_bake_into_other_frames_ready();
void bake_into_other_frames();
void frame_split();
std::vector<TimelineItemRow> timeline_item_rows_get();
std::vector<Reference> timeline_item_references_get();
Reference group_reference_get(const TimelineItemRow& row);
TimelineRowReference row_reference_get(const TimelineItemRow& row);
Reference row_item_reference_get(const TimelineRowReference& row);
std::vector<TimelineRowReference> timeline_row_references_get();
bool is_group_selected(const TimelineItemRow& row);
bool is_row_selected(const TimelineItemRow& row);
std::vector<TimelineRow> timeline_item_rows_get();
bool is_row_selected(const TimelineRow& row);
void row_selection_clear();
void row_selection_insert(const TimelineRowReference& row);
void row_selection_erase(const TimelineRowReference& row);
bool is_row_reference_selected(const TimelineRowReference& row);
std::size_t row_selection_count_get();
void row_selection_set(const TimelineItemRow& row);
void row_selection_insert(const TimelineRow& row);
bool is_row_reference_selected(const TimelineRow& row);
void row_selection_set(const TimelineRow& row);
void reference_set_adjacent_item(int direction);
std::vector<TimelineRowReference> selected_row_references_get();
std::vector<TimelineRowReference> row_drag_references_get(const TimelineItemRow& row);
std::vector<TimelineRow> selected_row_references_get();
std::vector<TimelineRow> row_drag_references_get(const TimelineRow& row);
void item_remove();
std::vector<Reference> item_references_groupable_get();
void item_group();
void rows_move_to_row(std::vector<TimelineRowReference> draggedRows, TimelineItemRow targetRow, bool isDropAfter,
void rows_move_to_row(std::vector<TimelineRow> draggedRows, TimelineRow targetRow, bool isDropAfter,
bool isDropIntoGroup = false);
void fit_animation_length();
void frame_references_copy(const std::set<Reference>& selectedFrames);
@@ -279,23 +241,20 @@ namespace anm2ed::imgui
void paste();
void context_menu();
void item_base_properties_open(int type, int id);
void group_properties_close();
void group_properties_open(const TimelineItemRow& row, const model::TrackGroup& group);
void group_properties_open(const TimelineRow& row, const model::TrackGroup& group);
void group_properties_update();
void item_context_menu();
TimelineContext(TimelineState&&, Manager&, Settings&, Resources&, Clipboard&);
void update();
void frame_begin();
void item_child(const TimelineItemRow&, int);
void item_child(const TimelineRow&, int);
void items_child();
void frame_move_drag_clear();
void frames_move_to(int, int, int, int, int);
void frames_move_to(Reference);
ImVec2 frame_box_content_point_get();
ImVec2 frame_box_screen_point_get(ImVec2);
bool is_frame_box_overlapping(ImVec2, ImVec2, ImVec2, ImVec2);
void frame_overlay_draw(ImDrawList*, ImVec2, ImVec2);
void frame_child(const TimelineItemRow&, int&, float);
void frame_child(const TimelineRow&, int&, float);
void frames_child();
void draw();
};
+11 -11
View File
@@ -6,7 +6,7 @@ namespace anm2ed::imgui
{
auto targetReference = reference;
auto time = (int)document.frameTime;
if (!animation || !command_item_reference_get(document, targetReference)) return;
if (!animation || !document.model.track_get(targetReference)) return;
edit_push(EDIT_INSERT_FRAME, [=](model::Model& model) { return edit::frame_insert(model, targetReference, time); });
}
@@ -16,7 +16,7 @@ namespace anm2ed::imgui
if (selectedFrames.empty()) return;
edit_push(
EDIT_DELETE_FRAMES, [=](model::Model& model) { return edit::frames_delete(model, selectedFrames); },
[this](Document& document, const edit::Uids&) { frames_selection_set_reference_for(document); });
[this](Document& document, const edit::Uids&) { document.frame_focus_select(); });
}
void TimelineContext::frames_duplicate()
@@ -133,7 +133,7 @@ namespace anm2ed::imgui
{ return edit::items_remove(model, animationIndex, ids, groupIds); },
[this](Document& document, const edit::Uids&)
{
reference_clear_for(document);
document.focus_clear();
group_selection_reset_for(document);
});
}
@@ -182,8 +182,8 @@ namespace anm2ed::imgui
});
}
void TimelineContext::rows_move_to_row(std::vector<TimelineRowReference> draggedRows, TimelineItemRow targetRow,
bool isDropAfter, bool isDropIntoGroup)
void TimelineContext::rows_move_to_row(std::vector<TimelineRow> draggedRows, TimelineRow targetRow, bool isDropAfter,
bool isDropIntoGroup)
{
if (draggedRows.empty()) return;
auto targetType = draggedRows.front().type;
@@ -198,13 +198,13 @@ namespace anm2ed::imgui
std::set<int> groupIds{};
for (const auto& row : draggedRows)
(row.isGroup ? groupIds : ids).insert(row.id);
edit::RowTarget target{targetRow.isGroup, targetRow.type, targetRow.id, targetRow.groupId};
edit::RowTarget target{targetRow.isGroup, targetRow.type, targetRow.id,
targetRow.type == ROOT ? -1 : targetRow.groupId};
auto animationIndex = reference.animationIndex;
std::set<Reference> tracks{};
std::set<Reference> groups{};
for (const auto& row : draggedRows)
(row.isGroup ? groups : tracks)
.insert(row.isGroup ? Reference{row.animationIndex, row.type, row.id} : row_item_reference_get(row));
(row.isGroup ? groups : tracks).insert(row_selection_reference_get(row));
Selection moved{};
selection_references_set(moved, model, SelectionKind::TRACKS, tracks);
selection_references_set(moved, model, SelectionKind::GROUPS, groups);
@@ -265,14 +265,14 @@ namespace anm2ed::imgui
frame_references_copy(selectedFrames);
edit_push(
EDIT_CUT_FRAMES, [=](model::Model& model) { return edit::frames_delete(model, selectedFrames); },
[this](Document& document, const edit::Uids&) { frames_selection_set_reference_for(document); });
[this](Document& document, const edit::Uids&) { document.frame_focus_select(); });
}
void TimelineContext::paste()
{
auto text = clipboard.get();
if (text.empty()) return;
if (!command_item_reference_get(document, reference))
if (!document.model.track_get(reference))
{
toast_log(Level::WARNING, TOAST_DESERIALIZE_FRAMES_NO_SELECTION);
return;
@@ -287,7 +287,7 @@ namespace anm2ed::imgui
{ return edit::frames_paste(model, targetReference, selectedFrames, text, time, errorString.get()); },
[=, this](Document& document, const edit::Uids& uids)
{
if (errorString->empty()) return frames_select_for(document, uids);
if (errorString->empty()) return document.frames_select(uids);
toasts.push(std::format("{} {}", localize.get(TOAST_DESERIALIZE_FRAMES_FAILED), *errorString));
logger.error(
std::format("{} {}", localize.get(TOAST_DESERIALIZE_FRAMES_FAILED, anm2ed::ENGLISH), *errorString));
+33 -80
View File
@@ -2,43 +2,25 @@
namespace anm2ed::imgui
{
void TimelineContext::frame_move_drag_clear()
{
frameMoveDrag = {};
frameMoveDropType = NONE;
frameMoveDropItemID = -1;
frameMoveDropGroupType = NONE;
frameMoveDropGroupId = -1;
frameMoveDropIndex = -1;
isFrameMoveDropTarget = false;
}
void TimelineContext::frames_move_to(int targetType, int targetID, int targetGroupType, int targetGroupId,
int insertIndex)
// Moves the dragged frames to `target`'s track, before its frame index.
void TimelineContext::frames_move_to(Reference target)
{
if (!frameMoveDrag.isActive || !animation || frameMoveDrag.animationIndex != reference.animationIndex) return;
if (targetType == TRIGGER) return;
if (target.itemType == TRIGGER) return;
auto drag = frameMoveDrag;
std::erase_if(drag.references, [](const Reference& frameReference)
{ return frameReference.itemType == TRIGGER || frameReference.frameIndex < 0; });
if (drag.references.empty() && drag.frameIndex >= 0)
drag.references.push_back(
{drag.animationIndex, drag.type, drag.itemID, drag.frameIndex, drag.groupType, drag.groupId});
std::erase_if(drag.references, [](const Reference& frameReference)
{ return frameReference.itemType == TRIGGER || frameReference.frameIndex < 0; });
if (drag.references.empty()) return;
auto frames = std::set<Reference>(frameMoveDrag.references.begin(), frameMoveDrag.references.end());
std::erase_if(frames, [](const Reference& frame) { return frame.itemType == TRIGGER || frame.frameIndex < 0; });
if (frames.empty()) return;
Reference target{drag.animationIndex, targetType, targetID, -1, targetGroupType, targetGroupId};
auto insertIndex = std::exchange(target.frameIndex, -1);
edit_push(
EDIT_MOVE_FRAMES,
[frames = std::set<Reference>(drag.references.begin(), drag.references.end()), target,
insertIndex](model::Model& model) { return edit::frames_move(model, frames, target, insertIndex); },
EDIT_MOVE_FRAMES, [frames, target, insertIndex](model::Model& model)
{ return edit::frames_move(model, frames, target, insertIndex); },
[=, this](Document& document, const edit::Uids& uids)
{
frames_select_for(document, uids);
if (targetType == LAYER)
if (auto layer = model::item_get(document.model.content.layers, targetID))
document.frames_select(uids);
if (target.itemType == LAYER)
if (auto layer = model::item_get(document.model.content.layers, target.itemID))
document.focused_id_set(SelectionKind::SPRITESHEETS, layer->spritesheetId);
});
}
@@ -54,11 +36,6 @@ namespace anm2ed::imgui
return ImVec2(point.x - scroll.x + frameBoxClipMin.x, point.y - scroll.y + frameBoxClipMin.y);
}
bool TimelineContext::is_frame_box_overlapping(ImVec2 leftMin, ImVec2 leftMax, ImVec2 rightMin, ImVec2 rightMax)
{
return leftMin.x <= rightMax.x && leftMax.x >= rightMin.x && leftMin.y <= rightMax.y && leftMax.y >= rightMin.y;
}
void TimelineContext::frame_overlay_draw(ImDrawList* drawList, ImVec2 clipMin, ImVec2 clipMax)
{
if (isFrameBoxSelecting && isFrameBoxClipSet)
@@ -90,12 +67,12 @@ namespace anm2ed::imgui
}
}
void TimelineContext::frame_child(const TimelineItemRow& row, int& index, float width)
void TimelineContext::frame_child(const TimelineRow& row, int& index, float width)
{
auto type = row.type;
auto id = row.id;
auto row_reference_make = [&](int frameIndex = -1)
{ return Reference{reference.animationIndex, type, id, frameIndex, row.rootGroupType, row.rootGroupId}; };
{ return Reference{reference.animationIndex, type, id, frameIndex, row.groupType, row.groupId}; };
auto childSize = ImVec2(width, rowFrameChildHeight);
if (row.isGroup)
{
@@ -111,12 +88,12 @@ namespace anm2ed::imgui
return;
}
auto item = item_get(type, id, row.rootGroupType, row.rootGroupId);
auto item = item_get(type, id, row.groupType, row.groupId);
if (type != NONE && !item) return;
auto isVisible = item ? item->isVisible && is_track_group_visible(type, row.groupId) : false;
if (item && type == ROOT && row.rootGroupId != -1)
isVisible = item->isVisible && is_track_group_visible(row.rootGroupType, row.rootGroupId);
if (item && type == ROOT && row.groupId != -1)
isVisible = item->isVisible && is_track_group_visible(row.groupType, row.groupId);
auto& isOnlyShowLayers = settings.timelineIsOnlyShowLayers;
if (isOnlyShowLayers && type != LAYER) isVisible = false;
@@ -174,7 +151,8 @@ namespace anm2ed::imgui
auto frameEnd = type == TRIGGER ? frameStart + 1.0f : frameStart + frame.duration;
auto frameContentMin = ImVec2(frameStart * frameSize.x, rowMinY);
auto frameContentMax = ImVec2(frameEnd * frameSize.x, rowMaxY);
if (is_frame_box_overlapping(frameContentMin, frameContentMax, boxMin, boxMax))
if (frameContentMin.x <= boxMax.x && frameContentMax.x >= boxMin.x && frameContentMin.y <= boxMax.y &&
frameContentMax.y >= boxMin.y)
frameBoxSelection.insert(frameReference);
if (type != TRIGGER) selectionFrameTime += frame.duration;
++frameIndex;
@@ -193,7 +171,7 @@ namespace anm2ed::imgui
}
else if (reference.itemType != NONE || reference.itemID != -1)
group_selection_reset_for(document);
reference_clear_for(document);
document.focus_clear();
}
if (type == NONE)
@@ -350,12 +328,7 @@ namespace anm2ed::imgui
++frameIndex;
}
frameMoveDropType = type;
frameMoveDropItemID = id;
frameMoveDropGroupType = row.rootGroupType;
frameMoveDropGroupId = row.rootGroupId;
frameMoveDropIndex = dropIndex;
isFrameMoveDropTarget = true;
frameMoveDropTarget = Reference{reference.animationIndex, type, id, dropIndex, row.groupType, row.groupId};
auto dropX = cursorScreenPos.x + dropFrameTime * frameSize.x;
auto previewWidth = glm::max(frameSize.x, (float)frameMoveDrag.duration * frameSize.x);
@@ -433,25 +406,15 @@ namespace anm2ed::imgui
auto isShiftDown = ImGui::IsKeyDown(ImGuiMod_Shift);
if (isShiftDown)
{
auto isHadAnchor = isFrameSelectionAnchorSet;
auto anchorReference = isHadAnchor ? frameSelectionAnchor : frameReference;
auto isRangeSelected =
frame_selection_range_set_for(document, anchorReference, frameReference, isCtrlDown);
if (!isRangeSelected) frame_selection_set_for(document, frameReference);
if (!isHadAnchor || !isRangeSelected) frameSelectionAnchor = frameReference;
isFrameSelectionAnchorSet = true;
}
else if (isCtrlDown)
{
frame_selection_toggle_for(document, frameReference);
frameSelectionAnchor = frameReference;
isFrameSelectionAnchorSet = true;
auto isRangeSelected = document.frames_range_select(frameSelectionAnchor.value_or(frameReference),
frameReference, isCtrlDown);
if (!isRangeSelected) document.frame_select(frameReference);
if (!frameSelectionAnchor || !isRangeSelected) frameSelectionAnchor = frameReference;
}
else
{
frame_selection_set_for(document, frameReference);
isCtrlDown ? document.frame_toggle(frameReference) : document.frame_select(frameReference);
frameSelectionAnchor = frameReference;
isFrameSelectionAnchorSet = true;
}
reference_set(frameReference);
isReferenced = true;
@@ -470,13 +433,12 @@ namespace anm2ed::imgui
isDraggedFrameActive = true;
draggedFrameReference = frameReference;
draggedFrameType = type;
draggedFrameIndex = frameIndex;
draggedFrameStart = hoveredTime;
if (type != TRIGGER) draggedFrameStartDuration = frame.duration;
draggedFrameStartDurations.clear();
if (type != TRIGGER)
for (auto selectedReference : drag_frame_references_get(frameReference))
if (auto selectedFrame = command_frame_get(document, selectedReference))
if (auto selectedFrame = document.model.frame_get(selectedReference))
draggedFrameStartDurations.push_back({selectedReference, selectedFrame->duration});
draggedFrameStartMouseX = ImGui::GetIO().MousePos.x;
draggedFrameWidth = frameSize.x;
@@ -492,22 +454,14 @@ namespace anm2ed::imgui
auto selectedReferences = drag_frame_references_get(frameReference);
int dragDuration = 0;
for (auto selectedReference : selectedReferences)
if (auto selectedFrame = command_frame_get(document, selectedReference))
if (auto selectedFrame = document.model.frame_get(selectedReference))
dragDuration += selectedFrame->duration;
dragDuration = glm::max(1, dragDuration);
frameMoveDrag = {
.type = type,
.itemID = id,
.animationIndex = reference.animationIndex,
.groupType = row.rootGroupType,
.groupId = row.rootGroupId,
.frameIndex = frameIndex,
.duration = dragDuration,
.indices = {},
.references = {selectedReferences.begin(), selectedReferences.end()},
.isActive = true,
};
frameMoveDrag = {.animationIndex = reference.animationIndex,
.duration = dragDuration,
.references = {selectedReferences.begin(), selectedReferences.end()},
.isActive = true};
}
}
@@ -599,7 +553,6 @@ namespace anm2ed::imgui
isDraggedFrameActive = false;
draggedFrameReference = {};
draggedFrameType = NONE;
draggedFrameIndex = -1;
draggedFrameStart = -1;
draggedFrameStartDuration = -1;
draggedFrameStartDurations.clear();
@@ -722,7 +675,7 @@ namespace anm2ed::imgui
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("##Frames");
auto frames_child_row = [&](const TimelineItemRow& row)
auto frames_child_row = [&](const TimelineRow& row)
{
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
+7 -16
View File
@@ -64,7 +64,7 @@ namespace anm2ed::imgui
command_push(
[=, this](Manager& manager, Document& document)
{
auto frame = command_frame_get(document, targetReference);
auto frame = document.model.frame_get(targetReference);
if (!frame || frame->regionId != -1) return;
auto layer = model::item_get(document.model.content.layers, targetReference.itemID);
if (!layer) return;
@@ -91,7 +91,7 @@ namespace anm2ed::imgui
auto is_region_makeable = [&](const Reference& frameReference)
{
if (frameReference.itemType != LAYER || frameReference.frameIndex < 0) return false;
auto frame = command_frame_get(document, frameReference);
auto frame = document.model.frame_get(frameReference);
auto layer = model::item_get(model.content.layers, frameReference.itemID);
return frame && frame->regionId == -1 && layer &&
model::item_get(model.content.spritesheets, layer->spritesheetId);
@@ -163,16 +163,7 @@ namespace anm2ed::imgui
manager.item_properties_open(type == LAYER ? ElementType::LAYER_ELEMENT : ElementType::NULL_ELEMENT, id);
}
void TimelineContext::group_properties_close()
{
groupName.clear();
groupAnimationIndex = -1;
groupType = NONE;
groupId = -1;
groupPropertiesPopup.close();
}
void TimelineContext::group_properties_open(const TimelineItemRow& row, const model::TrackGroup& group)
void TimelineContext::group_properties_open(const TimelineRow& row, const model::TrackGroup& group)
{
groupName = group.name.empty() ? std::string(localize.get(TEXT_NEW_GROUP)) : group.name;
groupAnimationIndex = reference.animationIndex;
@@ -210,7 +201,7 @@ namespace anm2ed::imgui
group->name = targetName;
});
}
if (result != PopupButton::NONE) group_properties_close();
if (result != PopupButton::NONE) groupPropertiesPopup.close();
ImGui::EndPopup();
}
@@ -229,15 +220,15 @@ namespace anm2ed::imgui
auto selectedRows = selected_row_references_get();
auto selectedGroupableItems = item_references_groupable_get();
auto copyFrames = copy_frame_references_get();
TimelineItemRow selectedGroupRow{};
TimelineRow selectedGroupRow{};
const model::TrackGroup* selectedGroup{};
if (selectedRows.size() == 1 && selectedRows.front().isGroup)
{
auto row = selectedRows.front();
selectedGroupRow = {.type = row.type, .id = row.id, .index = row.index, .isGroup = true};
selectedGroupRow = row;
selectedGroup = row_group_get(selectedGroupRow);
}
auto isRemoveAvailable = std::ranges::any_of(selectedRows, [](const TimelineRowReference& row)
auto isRemoveAvailable = std::ranges::any_of(selectedRows, [](const TimelineRow& row)
{ return row.type == LAYER || row.type == NULL_; });
auto item_cut = [&]()
{
+3 -5
View File
@@ -12,10 +12,8 @@ namespace anm2ed::imgui
frames_child();
if (frameMoveDrag.isActive && ImGui::IsMouseReleased(ImGuiMouseButton_Left))
{
if (isFrameMoveDropTarget)
frames_move_to(frameMoveDropType, frameMoveDropItemID, frameMoveDropGroupType, frameMoveDropGroupId,
frameMoveDropIndex);
frame_move_drag_clear();
if (frameMoveDropTarget) frames_move_to(*frameMoveDropTarget);
frameMoveDrag = {};
}
items_child();
}
@@ -202,7 +200,7 @@ namespace anm2ed::imgui
frameReference.frameIndex = glm::clamp(reference.frameIndex + (int)isNextFrame - (int)isPreviousFrame, 0,
(int)item->frames.size() - 1);
reference_set(frameReference);
frames_selection_set_reference_for(document);
document.frame_focus_select();
document.frameTime = model::frame_time_from_index_get(*item, reference.frameIndex);
}
+51 -189
View File
@@ -19,24 +19,14 @@ namespace anm2ed::imgui
return !group || group->isVisible;
}
const model::TrackGroup* TimelineContext::row_group_get(const TimelineItemRow& row)
const model::TrackGroup* TimelineContext::row_group_get(const TimelineRow& row)
{
return row.isGroup ? track_group_get(row.type, row.id) : nullptr;
}
const model::Track* TimelineContext::command_item_reference_get(Document& document, Reference itemReference)
{
return document.model.track_get(itemReference);
}
const model::Frame* TimelineContext::frame_get() { return document.model.frame_get(reference); }
const model::Frame* TimelineContext::command_frame_get(Document& document, const Reference& targetReference)
{
return document.model.frame_get(targetReference);
}
const model::Frame* TimelineContext::frame_get() { return command_frame_get(document, reference); }
const model::Track* TimelineContext::selected_item_get() { return command_item_reference_get(document, reference); }
const model::Track* TimelineContext::selected_item_get() { return document.model.track_get(reference); }
glm::vec4 TimelineContext::color_get(TimelineColor color, int type)
{
@@ -63,18 +53,6 @@ namespace anm2ed::imgui
document.reference_set(value);
}
void TimelineContext::frames_select_for(Document& targetDocument, const edit::Uids& uids)
{
auto references = targetDocument.references_get(uids);
if (references.empty()) return;
auto focus = references.front();
targetDocument.editTarget = Document::EditTarget::FRAME;
targetDocument.frame_references_set({references.begin(), references.end()});
targetDocument.reference_set(focus);
if (auto item = command_item_reference_get(targetDocument, focus); item && focus.itemType != TRIGGER)
targetDocument.frameTime = model::frame_time_from_index_get(*item, focus.frameIndex);
}
Reference TimelineContext::item_reference_get(int type, int id, int groupType, int groupId)
{
return Reference{reference.animationIndex, type, id, -1, groupType, groupId};
@@ -95,7 +73,7 @@ namespace anm2ed::imgui
void TimelineContext::group_selection_reset_for(Document& targetDocument)
{
targetDocument.selection.uids[SelectionKind::GROUPS].clear();
isRowSelectionAnchorSet = false;
rowSelectionAnchor.reset();
}
std::set<Reference> TimelineContext::item_references_for_current_get()
@@ -105,54 +83,6 @@ namespace anm2ed::imgui
return result;
}
void TimelineContext::frame_selection_set_for(Document& targetDocument, Reference frameReference)
{
group_selection_reset_for(targetDocument);
targetDocument.editTarget = Document::EditTarget::FRAME;
targetDocument.frame_references_set({frameReference});
targetDocument.reference_set(frameReference);
}
void TimelineContext::frame_selection_toggle_for(Document& targetDocument, Reference frameReference)
{
group_selection_reset_for(targetDocument);
targetDocument.editTarget = Document::EditTarget::FRAME;
auto selection = targetDocument.frame_references_get(Document::FrameReferenceFallback::NONE);
if (!selection.contains(frameReference))
selection.insert(frameReference);
else if (selection.size() > 1)
selection.erase(frameReference);
targetDocument.frame_references_set(selection);
targetDocument.reference_set(frameReference);
}
bool TimelineContext::frame_selection_range_set_for(Document& targetDocument, Reference firstReference,
Reference lastReference, bool isAdditive)
{
group_selection_reset_for(targetDocument);
targetDocument.editTarget = Document::EditTarget::FRAME;
if (!is_same_item(firstReference, lastReference) || firstReference.frameIndex < 0 || lastReference.frameIndex < 0)
return false;
auto item = command_item_reference_get(targetDocument, lastReference);
if (!item || std::max(firstReference.frameIndex, lastReference.frameIndex) >= model::track_frames_count_get(*item))
return false;
auto [firstIndex, lastIndex] = std::minmax(firstReference.frameIndex, lastReference.frameIndex);
auto selectedFrames = isAdditive ? targetDocument.frame_references_get(Document::FrameReferenceFallback::NONE)
: std::set<Reference>{};
for (int i = firstIndex; i <= lastIndex; ++i)
{
auto frameReference = lastReference;
frameReference.frameIndex = i;
selectedFrames.insert(frameReference);
}
targetDocument.frame_references_set(selectedFrames);
targetDocument.reference_set(lastReference);
return true;
}
std::set<Reference> TimelineContext::copy_frame_references_get()
{
auto selectedFrames = document.frame_references_get(Document::FrameReferenceFallback::NONE);
@@ -173,41 +103,15 @@ namespace anm2ed::imgui
return result;
}
void TimelineContext::frames_selection_set_reference_for(Document& targetDocument)
{
auto targetReference = targetDocument.reference_get();
if (targetReference.frameIndex < 0) return targetDocument.frame_references_clear();
targetDocument.editTarget = Document::EditTarget::FRAME;
targetDocument.frame_references_set({targetReference});
}
void TimelineContext::reference_clear_for(Document& targetDocument)
{
targetDocument.reference_set({targetDocument.reference_get().animationIndex});
targetDocument.frame_references_clear();
targetDocument.selection.uids[SelectionKind::TRACKS].clear();
}
void TimelineContext::reference_set_timeline_item_reference_for(Document& targetDocument, Reference itemReference)
{
itemReference.frameIndex = -1;
if (itemReference.itemType == LAYER)
if (auto layer = model::item_get(targetDocument.model.content.layers, itemReference.itemID))
targetDocument.focused_id_set(SelectionKind::SPRITESHEETS, layer->spritesheetId);
targetDocument.reference_set(itemReference);
targetDocument.frame_references_clear();
targetDocument.selected_set(SelectionKind::TRACKS, {itemReference});
}
void TimelineContext::command_push(std::function<void(Manager&, Document&)> run)
{
manager.command_push(
{manager.selected, [run](Manager& manager, Document& document) mutable { run(manager, document); }});
}
std::vector<TimelineItemRow> TimelineContext::timeline_item_rows_get()
std::vector<TimelineRow> TimelineContext::timeline_item_rows_get()
{
std::vector<TimelineItemRow> rows{};
std::vector<TimelineRow> rows{};
if (!animation) return rows;
auto is_track_shown = [&](const model::Track& track)
@@ -236,85 +140,50 @@ namespace anm2ed::imgui
auto& group = std::get<model::TrackGroup>(entries[index]);
rows.push_back({.type = type, .id = group.id, .index = index, .isGroup = true});
if (!group.isExpanded) continue;
rows.push_back({.type = ROOT, .id = -1, .rootGroupType = type, .rootGroupId = group.id, .depth = 1});
rows.push_back({.type = ROOT, .groupType = type, .groupId = group.id, .depth = 1});
for (auto trackIndex : order_get((int)group.tracks.size(), isReversed))
if (auto& track = group.tracks[trackIndex]; is_track_shown(track))
rows.push_back({.type = type,
.id = track.id,
.index = trackIndex,
.groupType = type,
.groupId = group.id,
.rootGroupType = type,
.rootGroupId = group.id,
.depth = 1});
}
}
rows.push_back({.type = TRIGGER});
for (auto& row : rows)
{
row.documentIndex = manager.selected;
row.animationIndex = reference.animationIndex;
}
return rows;
}
std::vector<Reference> TimelineContext::timeline_item_references_get()
bool TimelineContext::is_row_selected(const TimelineRow& row)
{
std::vector<Reference> itemReferences;
for (const auto& row : timeline_item_rows_get())
{
if (row.isGroup) continue;
itemReferences.push_back({reference.animationIndex, row.type, row.id, -1, row.rootGroupType, row.rootGroupId});
}
return itemReferences;
}
Reference TimelineContext::group_reference_get(const TimelineItemRow& row)
{
return Reference{reference.animationIndex, row.type, row.id};
}
TimelineRowReference TimelineContext::row_reference_get(const TimelineItemRow& row)
{
return TimelineRowReference{manager.selected, reference.animationIndex, row.type, row.id,
row.index, row.rootGroupType, row.rootGroupId, row.isGroup};
}
Reference TimelineContext::row_item_reference_get(const TimelineRowReference& row)
{
return Reference{row.animationIndex, row.type, row.id, -1, row.groupType, row.groupId};
}
std::vector<TimelineRowReference> TimelineContext::timeline_row_references_get()
{
std::vector<TimelineRowReference> rowReferences;
for (const auto& row : timeline_item_rows_get())
{
if (row.type == NONE) continue;
rowReferences.push_back(row_reference_get(row));
}
return rowReferences;
}
bool TimelineContext::is_group_selected(const TimelineItemRow& row)
{
return document.selected_get(SelectionKind::GROUPS).contains(group_reference_get(row));
}
bool TimelineContext::is_row_selected(const TimelineItemRow& row)
{
if (row.isGroup) return is_group_selected(row);
auto itemReference = item_reference_get(row.type, row.id, row.rootGroupType, row.rootGroupId);
if (row.isGroup) return is_row_reference_selected(row);
auto itemReference = item_reference_get(row.type, row.id, row.groupType, row.groupId);
auto tracks = document.selected_get(SelectionKind::TRACKS);
return tracks.contains(itemReference) ||
(tracks.empty() && document.selection.uids[SelectionKind::GROUPS].empty() &&
is_same_item(reference, itemReference));
}
SelectionKind row_kind_get(const TimelineRowReference& row)
Reference row_item_reference_get(const TimelineRow& row)
{
return row.isGroup ? SelectionKind::GROUPS : SelectionKind::TRACKS;
return Reference{row.animationIndex, row.type, row.id, -1, row.groupType, row.groupId};
}
Reference row_selection_reference_get(const TimelineRowReference& row)
Reference row_selection_reference_get(const TimelineRow& row)
{
return row.isGroup ? Reference{row.animationIndex, row.type, row.id}
: Reference{row.animationIndex, row.type, row.id, -1, row.groupType, row.groupId};
return row.isGroup ? Reference{row.animationIndex, row.type, row.id} : row_item_reference_get(row);
}
SelectionKind row_kind_get(const TimelineRow& row)
{
return row.isGroup ? SelectionKind::GROUPS : SelectionKind::TRACKS;
}
void TimelineContext::row_selection_clear()
@@ -323,34 +192,21 @@ namespace anm2ed::imgui
document.selection.uids[SelectionKind::GROUPS].clear();
}
void TimelineContext::row_selection_insert(const TimelineRowReference& row)
void TimelineContext::row_selection_insert(const TimelineRow& row)
{
auto references = document.selected_get(row_kind_get(row));
references.insert(row_selection_reference_get(row));
document.selected_set(row_kind_get(row), references);
}
void TimelineContext::row_selection_erase(const TimelineRowReference& row)
{
auto references = document.selected_get(row_kind_get(row));
references.erase(row_selection_reference_get(row));
document.selected_set(row_kind_get(row), references);
}
bool TimelineContext::is_row_reference_selected(const TimelineRowReference& row)
bool TimelineContext::is_row_reference_selected(const TimelineRow& row)
{
return document.selected_get(row_kind_get(row)).contains(row_selection_reference_get(row));
}
std::size_t TimelineContext::row_selection_count_get()
void TimelineContext::row_selection_set(const TimelineRow& row)
{
return document.selection.uids[SelectionKind::TRACKS].size() +
document.selection.uids[SelectionKind::GROUPS].size();
}
void TimelineContext::row_selection_set(const TimelineItemRow& row)
{
auto rowReference = row_reference_get(row);
auto rowReference = row;
auto isCtrlDown = ImGui::IsKeyDown(ImGuiMod_Ctrl);
auto isShiftDown = ImGui::IsKeyDown(ImGuiMod_Shift);
@@ -367,8 +223,8 @@ namespace anm2ed::imgui
if (isShiftDown)
{
auto rowSelection = timeline_row_references_get();
auto anchor = isRowSelectionAnchorSet ? rowSelectionAnchor : rowReference;
auto rowSelection = timeline_item_rows_get();
auto anchor = rowSelectionAnchor.value_or(rowReference);
auto first = std::find(rowSelection.begin(), rowSelection.end(), anchor);
auto last = std::find(rowSelection.begin(), rowSelection.end(), rowReference);
if (first == rowSelection.end() || last == rowSelection.end())
@@ -385,13 +241,19 @@ namespace anm2ed::imgui
if (!isCtrlDown) row_selection_clear();
for (int i = firstIndex; i <= lastIndex; ++i)
row_selection_insert(rowSelection[i]);
if (!isRowSelectionAnchorSet) rowSelectionAnchor = rowReference;
if (!rowSelectionAnchor) rowSelectionAnchor = rowReference;
}
}
else if (isCtrlDown)
{
if (is_row_reference_selected(rowReference) && row_selection_count_get() > 1)
row_selection_erase(rowReference);
if (is_row_reference_selected(rowReference) && document.selection.uids[SelectionKind::TRACKS].size() +
document.selection.uids[SelectionKind::GROUPS].size() >
1)
{
auto references = document.selected_get(row_kind_get(rowReference));
references.erase(row_selection_reference_get(rowReference));
document.selected_set(row_kind_get(rowReference), references);
}
else
row_selection_insert(rowReference);
rowSelectionAnchor = rowReference;
@@ -402,13 +264,13 @@ namespace anm2ed::imgui
row_selection_insert(rowReference);
rowSelectionAnchor = rowReference;
}
isRowSelectionAnchorSet = true;
}
void TimelineContext::reference_set_adjacent_item(int direction)
{
auto itemReferences = timeline_item_references_get();
std::vector<Reference> itemReferences{};
for (const auto& row : timeline_item_rows_get())
if (!row.isGroup) itemReferences.push_back(row_item_reference_get(row));
if (itemReferences.empty()) return;
auto it = std::find_if(itemReferences.begin(), itemReferences.end(),
@@ -420,27 +282,27 @@ namespace anm2ed::imgui
auto& itemReference = itemReferences[index];
group_selection_reset_for(document);
reference_set_timeline_item_reference_for(document, itemReference);
document.track_select(itemReference);
}
std::vector<TimelineRowReference> TimelineContext::selected_row_references_get()
std::vector<TimelineRow> TimelineContext::selected_row_references_get()
{
std::vector<TimelineRowReference> result{};
std::vector<TimelineRow> result{};
for (const auto& row : timeline_item_rows_get())
if (is_row_selected(row)) result.push_back(row_reference_get(row));
if (is_row_selected(row)) result.push_back(row);
return result;
}
std::vector<TimelineRowReference> TimelineContext::row_drag_references_get(const TimelineItemRow& row)
std::vector<TimelineRow> TimelineContext::row_drag_references_get(const TimelineRow& row)
{
auto clicked = row_reference_get(row);
if (clicked.type != LAYER && clicked.type != NULL_) return std::vector<TimelineRowReference>{clicked};
auto clicked = row;
if (clicked.type != LAYER && clicked.type != NULL_) return std::vector<TimelineRow>{clicked};
auto rows = selected_row_references_get();
if (!is_row_reference_selected(clicked)) rows = {clicked};
if (rows.empty()) rows = {clicked};
std::erase_if(rows, [&](const TimelineRowReference& rowReference) { return rowReference.type != clicked.type; });
std::erase_if(rows, [&](const TimelineRow& rowReference) { return rowReference.type != clicked.type; });
if (rows.empty()) rows = {clicked};
return rows;
}
+9 -14
View File
@@ -1,6 +1,7 @@
#pragma once
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>
@@ -17,7 +18,9 @@ namespace anm2ed::imgui
{
struct TimelineContext;
struct TimelineRowReference
// A timeline row: a track (in a group or not), a group, or a group's root. groupType/groupId name the group a
// track or group root belongs to.
struct TimelineRow
{
int documentIndex{-1};
int animationIndex{-1};
@@ -26,21 +29,16 @@ namespace anm2ed::imgui
int index{-1};
int groupType{NONE};
int groupId{-1};
int depth{};
bool isGroup{};
auto operator<=>(const TimelineRowReference&) const = default;
auto operator<=>(const TimelineRow&) const = default;
};
struct FrameMoveDrag
{
int type{NONE};
int itemID{-1};
int animationIndex{-1};
int groupType{NONE};
int groupId{-1};
int frameIndex{-1};
int duration{1};
std::vector<int> indices{};
std::vector<Reference> references{};
bool isActive{};
};
@@ -78,8 +76,7 @@ namespace anm2ed::imgui
ImVec2 frameBoxStart{};
ImVec2 frameBoxEnd{};
std::set<Reference> frameBoxSelection{};
TimelineRowReference rowSelectionAnchor{};
bool isRowSelectionAnchorSet{};
std::optional<TimelineRow> rowSelectionAnchor{};
PopupHelper groupPropertiesPopup{PopupHelper(LABEL_GROUP_PROPERTIES, POPUP_SMALL_NO_HEIGHT)};
std::string groupName{};
int groupAnimationIndex{-1};
@@ -88,7 +85,6 @@ namespace anm2ed::imgui
Reference draggedFrameReference{};
bool isDraggedFrameActive{};
int draggedFrameType{};
int draggedFrameIndex{-1};
int draggedFrameStart{-1};
int draggedFrameStartDuration{-1};
std::vector<FrameDurationDrag> draggedFrameStartDurations{};
@@ -96,10 +92,9 @@ namespace anm2ed::imgui
float draggedFrameWidth{};
bool isDraggedFrameSnapshot{};
FrameMoveDrag frameMoveDrag{};
Reference frameSelectionAnchor{};
bool isFrameSelectionAnchorSet{};
std::optional<Reference> frameSelectionAnchor{};
int animationLengthEditIndex{-1};
std::vector<TimelineRowReference> rowDragReferences{};
std::vector<TimelineRow> rowDragReferences{};
glm::vec2 scroll{};
ImGuiStyle style{};
};
+19 -20
View File
@@ -2,14 +2,14 @@
namespace anm2ed::imgui
{
void TimelineContext::item_child(const TimelineItemRow& row, int index)
void TimelineContext::item_child(const TimelineRow& row, int index)
{
ImGui::PushID(index);
auto type = row.type;
auto id = row.id;
auto row_reference_make = [&]()
{ return Reference{reference.animationIndex, type, id, -1, row.rootGroupType, row.rootGroupId}; };
{ return Reference{reference.animationIndex, type, id, -1, row.groupType, row.groupId}; };
if (row.isGroup)
{
auto group = row_group_get(row);
@@ -23,7 +23,7 @@ namespace anm2ed::imgui
auto itemSize = ImVec2(ImGui::GetContentRegionAvail().x, rowFrameChildHeight);
auto isGroupVisible = group->isVisible;
auto colorVec = color_get(COLOR_ITEM_BASE, type);
if (is_group_selected(row)) colorVec = color_get(COLOR_ITEM_SELECTED, type);
if (is_row_reference_selected(row)) colorVec = color_get(COLOR_ITEM_SELECTED, type);
auto color = to_imvec4(isGroupVisible ? colorVec : colorVec * COLOR_HIDDEN_MULTIPLIER);
ImGui::PushStyleColor(ImGuiCol_ChildBg, color);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing);
@@ -74,7 +74,7 @@ namespace anm2ed::imgui
{
rowDragReferences = row_drag_references_get(row);
ImGui::SetDragDropPayload("Timeline Row Drag Drop", rowDragReferences.data(),
(int)rowDragReferences.size() * (int)sizeof(TimelineRowReference));
(int)rowDragReferences.size() * (int)sizeof(TimelineRow));
ImGui::EndDragDropSource();
}
@@ -91,9 +91,9 @@ namespace anm2ed::imgui
else if (mousePos.y >= groupButtonMin.y + groupDropThird)
dropZone = DropZone::INSIDE;
auto isDropAfter = dropZone != DropZone::BEFORE;
auto payloadRows = (TimelineRowReference*)payload->Data;
auto payloadCount = payload->DataSize / sizeof(TimelineRowReference);
std::vector<TimelineRowReference> draggedRows(payloadRows, payloadRows + payloadCount);
auto payloadRows = (TimelineRow*)payload->Data;
auto payloadCount = payload->DataSize / sizeof(TimelineRow);
std::vector<TimelineRow> draggedRows(payloadRows, payloadRows + payloadCount);
auto isDropIntoGroup = dropZone == DropZone::INSIDE && (row.type == LAYER || row.type == NULL_);
for (auto draggedRow : draggedRows)
if (draggedRow.isGroup || draggedRow.type != row.type) isDropIntoGroup = false;
@@ -182,7 +182,7 @@ namespace anm2ed::imgui
return;
}
auto item = item_get(type, id, row.rootGroupType, row.rootGroupId);
auto item = item_get(type, id, row.groupType, row.groupId);
if (type != NONE && !item)
{
ImGui::PopID();
@@ -190,8 +190,8 @@ namespace anm2ed::imgui
}
auto isItemVisible = item ? item->isVisible : false;
auto isVisible = item ? item->isVisible && is_track_group_visible(type, row.groupId) : false;
if (item && type == ROOT && row.rootGroupId != -1)
isVisible = item->isVisible && is_track_group_visible(row.rootGroupType, row.rootGroupId);
if (item && type == ROOT && row.groupId != -1)
isVisible = item->isVisible && is_track_group_visible(row.groupType, row.groupId);
auto& isOnlyShowLayers = settings.timelineIsOnlyShowLayers;
if (isOnlyShowLayers && type != LAYER) isVisible = false;
auto isReferenced = is_same_item(reference, row_reference_make());
@@ -247,7 +247,7 @@ namespace anm2ed::imgui
{
rowDragReferences = row_drag_references_get(row);
ImGui::SetDragDropPayload("Timeline Row Drag Drop", rowDragReferences.data(),
(int)rowDragReferences.size() * (int)sizeof(TimelineRowReference));
(int)rowDragReferences.size() * (int)sizeof(TimelineRow));
ImGui::EndDragDropSource();
}
@@ -260,9 +260,9 @@ namespace anm2ed::imgui
auto isDropAfter = is_drop_after(itemButtonMin, itemButtonMax);
drop_line_draw(ImGui::GetWindowDrawList(), itemChildMin, itemChildMax, isDropAfter);
auto payloadRows = (TimelineRowReference*)payload->Data;
auto payloadCount = payload->DataSize / sizeof(TimelineRowReference);
std::vector<TimelineRowReference> draggedRows(payloadRows, payloadRows + payloadCount);
auto payloadRows = (TimelineRow*)payload->Data;
auto payloadCount = payload->DataSize / sizeof(TimelineRow);
std::vector<TimelineRow> draggedRows(payloadRows, payloadRows + payloadCount);
if (payload->IsDelivery()) rows_move_to_row(draggedRows, row, isDropAfter, false);
}
ImGui::EndDragDropTarget();
@@ -393,8 +393,8 @@ namespace anm2ed::imgui
auto animationIndex = reference.animationIndex;
auto targetType = type;
auto targetID = id;
auto targetGroupType = row.rootGroupType;
auto targetGroupId = row.rootGroupId;
auto targetGroupType = row.groupType;
auto targetGroupId = row.groupId;
edit_push(EDIT_TOGGLE_ITEM_VISIBILITY,
[=](model::Model& model)
{
@@ -510,14 +510,13 @@ namespace anm2ed::imgui
{
if (animation && ImGui::Shortcut(ImGuiMod_Ctrl | ImGuiKey_A, ImGuiInputFlags_RouteFocused))
{
auto rowReferences = timeline_row_references_get();
auto rowReferences = timeline_item_rows_get();
row_selection_clear();
for (auto rowReference : rowReferences)
row_selection_insert(rowReference);
if (!rowReferences.empty())
{
rowSelectionAnchor = rowReferences.front();
isRowSelectionAnchorSet = true;
}
document.frame_references_clear();
}
@@ -536,7 +535,7 @@ namespace anm2ed::imgui
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableSetupColumn("##Items");
auto item_child_row = [&](const TimelineItemRow& row, int index)
auto item_child_row = [&](const TimelineRow& row, int index)
{
ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0);
@@ -578,7 +577,7 @@ namespace anm2ed::imgui
ImGui::SameLine();
auto selectedRows = selected_row_references_get();
auto isRemoveAvailable = std::ranges::any_of(selectedRows, [](const TimelineRowReference& row)
auto isRemoveAvailable = std::ranges::any_of(selectedRows, [](const TimelineRow& row)
{ return row.type == LAYER || row.type == NULL_; });
ImGui::BeginDisabled(!isRemoveAvailable);
shortcut(manager.chords[SHORTCUT_REMOVE]);