Fixed issues with renaming/synchronizing state

This commit is contained in:
2025-11-16 00:11:27 -05:00
parent a968371ac6
commit 131934df1a
7 changed files with 54 additions and 23 deletions
+10 -4
View File
@@ -54,7 +54,7 @@ namespace anm2ed::imgui
auto isDefault = anm2.animations.defaultAnimation == animation.name;
auto isReferenced = reference.animationIndex == (int)i;
auto isNewSelection = newAnimationSelectedIndex == (int)i;
auto isNewAnimation = newAnimationSelectedIndex == (int)i;
auto font = isDefault && isReferenced ? font::BOLD_ITALICS
: isDefault ? font::BOLD
@@ -64,15 +64,21 @@ namespace anm2ed::imgui
ImGui::PushFont(resources.fonts[font].get(), font::SIZE);
ImGui::SetNextItemSelectionUserData((int)i);
if (isNewAnimation) renameState = RENAME_FORCE_EDIT;
if (selectable_input_text(animation.name, std::format("###Document #{} Animation #{}", manager.selected, i),
animation.name, selection.contains((int)i), ImGuiSelectableFlags_None, nullptr,
isNewSelection))
animation.name, selection.contains((int)i), ImGuiSelectableFlags_None, renameState))
{
reference = {(int)i};
document.frames.clear();
if (renameState == RENAME_BEGIN)
document.snapshot("Rename Animation");
else if (renameState == RENAME_FINISHED)
document.change(Document::ANIMATIONS);
}
if (ImGui::IsItemHovered()) hovered = (int)i;
if (isNewSelection)
if (isNewAnimation)
{
ImGui::SetScrollHereY(0.5f);
newAnimationSelectedIndex = -1;
+1
View File
@@ -11,6 +11,7 @@ namespace anm2ed::imgui
{
PopupHelper mergePopup{PopupHelper("Merge Animations")};
int newAnimationSelectedIndex{-1};
RenameState renameState{RENAME_SELECTABLE};
public:
void update(Manager&, Settings&, Resources&, Clipboard&);
+12 -3
View File
@@ -32,12 +32,21 @@ namespace anm2ed::imgui
for (auto& [id, event] : anm2.content.events)
{
auto isNewEvent = (newEventId == id);
ImGui::PushID(id);
ImGui::SetNextItemSelectionUserData(id);
const bool isNewEvent = (newEventId == id);
if (isNewEvent) renameState = RENAME_FORCE_EDIT;
if (selectable_input_text(event.name, std::format("###Document #{} Event #{}", manager.selected, id),
event.name, selection.contains(id), ImGuiSelectableFlags_None, nullptr, isNewEvent))
if (ImGui::IsItemHovered()) hovered = id;
event.name, selection.contains(id), ImGuiSelectableFlags_None, renameState))
{
if (renameState == RENAME_BEGIN)
document.snapshot("Rename Event");
else if (renameState == RENAME_FINISHED)
document.change(Document::EVENTS);
}
if (ImGui::IsItemHovered()) hovered = id;
if (isNewEvent)
{
ImGui::SetScrollHereY(0.5f);
+1
View File
@@ -10,6 +10,7 @@ namespace anm2ed::imgui
class Events
{
int newEventId{-1};
RenameState renameState{RENAME_SELECTABLE};
public:
void update(Manager&, Settings&, Resources&, Clipboard&);