Fix close-popup ImGui stack imbalance, stale region hover, shared resize chord state, window properties leak
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c04a685f18
commit
146e5d4ff1
5 files changed
+13
-19
No files matched your search
+7
-15
@@ -300,18 +300,11 @@ namespace anm2ed::imgui
|
||||
shortcut(manager.chords[SHORTCUT_CONFIRM]);
|
||||
if (ImGui::Button(localize.get(BASIC_YES), widgetSize))
|
||||
{
|
||||
bool isSaved = true;
|
||||
if (isDocumentDirty) isSaved = taskbar.save_manual(manager, settings, closeDocumentIndex);
|
||||
|
||||
if (!isSaved)
|
||||
// A failed save keeps the document (and its popup) open.
|
||||
auto isSaved = !isDocumentDirty || taskbar.save_manual(manager, settings, closeDocumentIndex);
|
||||
if (isSaved)
|
||||
{
|
||||
ImGui::EndPopup();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSpritesheetDirty)
|
||||
{
|
||||
{
|
||||
if (isSpritesheetDirty)
|
||||
for (auto& spritesheet : closeDocument.model.content.spritesheets)
|
||||
{
|
||||
auto id = spritesheet.id;
|
||||
@@ -332,11 +325,10 @@ namespace anm2ed::imgui
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
auto index = closeDocumentIndex;
|
||||
manager.command_push({.runManager = [index](Manager& manager) { manager.close(index); }});
|
||||
close();
|
||||
}
|
||||
auto index = closeDocumentIndex;
|
||||
manager.command_push({.runManager = [index](Manager& manager) { manager.close(index); }});
|
||||
close();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
@@ -244,6 +244,7 @@ namespace anm2ed::imgui
|
||||
drawList->AddRectFilled(min, max, ImGui::GetColorU32(to_imvec4(vec4(backgroundColor, 1.0f))));
|
||||
image_premultiplied_draw(this->texture, to_imvec2(size));
|
||||
|
||||
hoveredRegionId = -1;
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
auto input = canvas_input_get(manager, isFocused);
|
||||
@@ -301,7 +302,6 @@ namespace anm2ed::imgui
|
||||
if (tool == tool::DRAW && input.isRightDown) useTool = tool::ERASE;
|
||||
if (tool == tool::ERASE && input.isRightDown) useTool = tool::DRAW;
|
||||
|
||||
hoveredRegionId = -1;
|
||||
if (useTool == tool::PAN && spritesheet && texture && texture->is_valid() && isMouseOverCanvas)
|
||||
for (auto& region : spritesheet->regions)
|
||||
{
|
||||
|
||||
@@ -201,7 +201,6 @@ namespace anm2ed::imgui
|
||||
};
|
||||
constexpr FrameResize FRAME_RESIZES[] = {{SHORTCUT_SHORTEN_FRAME, EDIT_SHORTEN_FRAME, -1},
|
||||
{SHORTCUT_EXTEND_FRAME, EDIT_EXTEND_FRAME, 1}};
|
||||
static bool isResizeChordHeld[std::size(FRAME_RESIZES)]{};
|
||||
for (int i = 0; i < (int)std::size(FRAME_RESIZES); ++i)
|
||||
{
|
||||
auto resize = FRAME_RESIZES[i];
|
||||
@@ -211,7 +210,7 @@ namespace anm2ed::imgui
|
||||
std::erase_if(selectedFrames, is_trigger_reference);
|
||||
if (!selectedFrames.empty())
|
||||
{
|
||||
if (!isResizeChordHeld[i]) edit_begin_push(resize.edit);
|
||||
if (resizeChordTabIds[i] != document.tabId) edit_begin_push(resize.edit);
|
||||
command_push(
|
||||
[=, this](Manager&, Document& document)
|
||||
{
|
||||
@@ -222,7 +221,7 @@ namespace anm2ed::imgui
|
||||
document.change();
|
||||
});
|
||||
}
|
||||
isResizeChordHeld[i] = isPressed;
|
||||
resizeChordTabIds[i] = isPressed ? document.tabId : 0;
|
||||
}
|
||||
|
||||
auto isPreviousFrame = shortcut(manager.chords[SHORTCUT_PREVIOUS_FRAME], shortcut::GLOBAL);
|
||||
|
||||
@@ -146,6 +146,8 @@ namespace anm2ed::imgui
|
||||
float draggedFrameWidth{};
|
||||
bool isDraggedFrameSnapshot{};
|
||||
FrameMoveDrag frameMoveDrag{};
|
||||
// The tab a held shorten/extend chord is editing (0 when released), so a held chord starts one undo entry per document.
|
||||
std::uint64_t resizeChordTabIds[2]{};
|
||||
std::optional<Reference> frameSelectionAnchor{};
|
||||
int animationLengthEditIndex{-1};
|
||||
std::vector<TimelineRow> rowDragReferences{};
|
||||
|
||||
Reference in new issue
Block a user