Skip to content

Refactored Undo to correct multiple undos required for some actions#525

Merged
j-medland merged 42 commits into
developfrom
feature/514-multiple-undos-required-for-some-actions
May 4, 2026
Merged

Refactored Undo to correct multiple undos required for some actions#525
j-medland merged 42 commits into
developfrom
feature/514-multiple-undos-required-for-some-actions

Conversation

@crossrulz
Copy link
Copy Markdown
Collaborator

Moved the handling of the undo stack into a class. States are now added to the stack in a single location with the Draw Icon. The handling of the body text was moved to the same location so that it does not cause multiple states from being created. All locations that previously added to the undo stack were updated to set the flag to add to the undo stack. This results in a single state being generated for a single action.

Unit tests were updated to test the History class instead of the Action Engine.
Manual tests were created and performed per 08 Undo Redo.md.

Resolves #514

crossrulz and others added 30 commits April 2, 2026 14:39
Moved calling of Value Change_Body Text.vi to after the Event Structure
Renamed Value Change_Body Text.vi to Apply Body Text.vi
Moved VI into the lv_icon library
Eliminated all calls to Fire Body Text Change.vi as it is not needed anymore with Apply Body Text.vi being called after the Event Structure
Removed Fire Body Text Change.vi
Still need to find other locations using the Body Text Value Change Signaling property
Moved Undo Redo Action.ctl into History class
Cleanup of Body Text:Value Change event
Added History class to Global Data
Created VI to build up the history state from the global data
Updated Classes Initialization.vi to use method
Beginning of replacing FGV_Undo Redo.vi with class methods
Can now Add State, Get Current State, and Check for Changes
Made necessary updates to Add Data to History and other VIs that were broken
Still need to implement the Undo and Redo methods
Renamed class and moved to new folder
Added unit test Test Undo Flag
Renamed Replay Data from History.vi to Set to State.vi
Changed all calls to Add Data to History.vi to Set Undo Flag.vi
Removed setting of the undo flag from ViewLayer.vi and corrected all callers
Required clearing the undo flag even when data not added to the stack
Clear Template layer on Layers tab when performing a Clear All
Development for Issue #514

- Created a History library and class to handle the undo/redo stack. The
class is replacing the FGV_Undo Redo.vi.
- History.lvclass was added to IE Classes.ctl, which is included in
Global Data.ctl. This caused many VI updates purely related to the use
of Global Data.ctl.
- Moved Apply Body Text.vi and Add Data To History.vi to be called in
the case structure with DrawIcon.vi. This makes it so that the icon text
and adding to the undo/redo stack is performed after every action
without the need to call them either directly or by creating an event.
- Replaced all other calls to Add Data To History.vi with Set Undo
Flag.vi. This flag is used by the Add Data To History.vi to see if
actions should be added to the undo stack. The flag is cleared in the
Add Data To History.vi to avoid the flag being persistent.
- Removed all found Value(Signaling) property writes for the Body Text
control. These were used to force the event that would draw the icon
text, which often led to multiple undo states for a single action.
- Fixed bug where Clear All menu item was not clearing out the Icon
Template layer control. Template layer was still being cleared in the
icon data, just not the control.
- Updated unit tests related to the FGV_Undo Redo.vi to use
History.lvclass instead. The tests were renamed accordingly. A unit test
was added for testing the undo flag.
Created a VI Template.vi as a starting point of a VI with a built-in template layer
Set the Front Panel mode to match lv_icon.vi
Removed Deserialize Picture Control Data.vi from SET_UserLayers.vi
Added Apply Transparency.vi to several VIs to accomplish the same goal
Template name in the Template class contained the extension, causing issues when performing an undo
Started Undo Redo manual test. Completed Templates Tab section.
Flattened folder hierarchy
Moved VI Template.vi into Library Template.lvlib to aid testing import of library icon
- Corrected Layers being updated after Undo
- Corrected template name during initialization
- Corrected opacity changes flooding undo stack
- Correct Filter Template value change not adding to the undo stack
- Corrections to lv_icon to enable redraw after certain actions
crossrulz and others added 7 commits April 21, 2026 23:50
Added Layers Tab and Menu Items sections
Bug corrections as well
When nothing is typed from the text tool, the Finalize Text does nothing.
Added setting the Text Marker off when clicking outside of the icon preview
Because Eraser does not act on a temporary icon, the Add To History needs to be skipped on the Mouse Down
The Eraser's actions will be added to the Undo stack on Mouse Up
…' into feature/514-multiple-undos-required-for-some-actions
Added tests for Layers Tab, Menu Items, and Tools.
Corrected bugs involving the eraser tool, pencil tool, and text tool not
properly being added to the undo/redo stack.

All testing performed per 08 Undo Redo.md
@crossrulz crossrulz requested a review from j-medland April 29, 2026 01:48
@crossrulz crossrulz added Issue group: Refactoring Version Increment: Minor Change that requires a minor semantic version increment, including non-breaking features. labels Apr 29, 2026
@j-medland
Copy link
Copy Markdown
Collaborator

Also I noticed that the following files in /resource/plugins/NIIconEditor/Miscellaneous/Load Unload have extra space characters in their name (although they don't seem to show on the github website).

Read Glyphs from  File.vi
Write Glyphs to  File.vi

I know you didn't touch those files but did you want to fix them too?

I think I am good with a static analysis of the code and will go on to run through the test plan tomorrow and report the results in a proper github review.

@crossrulz
Copy link
Copy Markdown
Collaborator Author

crossrulz commented May 3, 2026

Also I noticed that the following files in /resource/plugins/NIIconEditor/Miscellaneous/Load Unload have extra space characters in their name (although they don't seem to show on the github website).

Read Glyphs from  File.vi
Write Glyphs to  File.vi

I know you didn't touch those files but did you want to fix them too?

Since I already need to add another correction, I can go ahead and clean those up.

EDIT: Update is done

crossrulz and others added 2 commits May 2, 2026 21:10
Better error handling in Undo, Redo case of MenuSelection(User).vi
Removed spaces in file names of Read Glyphs from File.vi and Write Glyphs to File.vi
Better error handling in Undo, Redo case of MenuSelection(User).vi
Removed spaces in file names of Read Glyphs from File.vi and Write Glyphs to File.vi
Copy link
Copy Markdown
Collaborator

@j-medland j-medland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look visually fine - I will run through the tests tomorrow as a review.

One additional thing - Can we take the extra space out of resource\plugins\NIIconEditor\Miscellaneous\Load Unload\Read Glyphs from File.vi?

Comment thread resource/plugins/NIIconEditor/History/History/Check for Changes.vi
Comment thread resource/plugins/lv_icon.vi
crossrulz added 2 commits May 3, 2026 23:23
Updated values were not passed out of Finalize Text.vi
Added History.lvlib:Unflatten State.vi
Added a class data in History.lvclass to store flag to store the initial state and the initial state
Updates from comments made in #525 
Corrected global data improperly wired
Compare current and initial states in check change
@j-medland j-medland merged commit 80f52c8 into develop May 4, 2026
12 of 16 checks passed
@j-medland j-medland deleted the feature/514-multiple-undos-required-for-some-actions branch May 4, 2026 18:35
@j-medland
Copy link
Copy Markdown
Collaborator

Fantastic work @crossrulz. Thanks for your hard work on this PR and for putting up with my pedantry.

I have merged this - I have noticed a couple of tiny tweaks for Test 08 Undo Redo.md that can be a non-PR fix.

Firstly it has some typos on "Perform" at various places (eg Prerfom, Perorm)

Section 3 - Glyphs Tab - I think the enabled/disabled options are reversed for 25 and 26 (after two redos, undo should be enabled, redo disabled)

One of us can fix these at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue group: Refactoring Version Increment: Minor Change that requires a minor semantic version increment, including non-breaking features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple Undos Required for some actions

2 participants