Skip to content

ColorPicker Undo - #7769

Merged
mjkkirschner merged 3 commits into
DynamoDS:masterfrom
Gytaco:colorpicker
Apr 26, 2017
Merged

mjkkirschner merged 3 commits into
DynamoDS:masterfrom
Gytaco:colorpicker

Conversation

@Gytaco

@Gytaco Gytaco commented Apr 10, 2017

Copy link
Copy Markdown

Here is the correct branch with the Colorpicker undo functionality

Here is the correct branch with the Colorpicker undo functionality
@Gytaco

Gytaco commented Apr 10, 2017

Copy link
Copy Markdown
Author

Hey Mike here is the colorpicker undo. Please note the reason the colors are setup as RGBA rather then ARGB is due to the setup of the Color.cs class in Dynamo in CoreNodes. Please check the code and you will see the reason why I have to set things to the RGBA for correct coloring and functionality. Also note with the undo if we need the first undo to do 2 undo's we need to add some additional code to manage the additional change. Let me know if your happy with the current setup and I can add the additional functionality.

@gregmarr

Copy link
Copy Markdown
Contributor

The problem isn't that the format is ARGB, the problem is that the Format argument string says to expect R, G, B, A in the remaining arguments:

Alpha = {3}, Red = {0}, Green = {1}, Blue = {2}

but the arguments are in the order A, R, G, B

DsColor.Alpha, DsColor.Red, DsColor.Green, DsColor.Blue

The string should be

Alpha = {0}, Red = {1}, Green = {2}, Blue = {3}

@Gytaco

Gytaco commented Apr 10, 2017

Copy link
Copy Markdown
Author

Sorry Greg, so due to the format when i save to xml and have to reopen on line 85 I have to pull the data back in as RGBA, so the ToString was to standardise that same output since the node actually uses the same DsColor class. However since they both use the same class the ToString is actually not used at all and I have since removed it so thanks for pointing that out!

Since I am using the DsColor class for the node there is no need to have
the override since it's being controlled there anyway and has been
removed.
viewNode = nodeView;
colorPaletteNode = model;
mcolor = Color.FromArgb(model.dsColor.Alpha, model.dsColor.Red, model.dsColor.Green, model.dsColor.Blue);
model.PropertyChanged += Model_PropertyChanged;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you should unsubscribe this handler in the dispose method below.


public event PropertyChangedEventHandler PropertyChanged;

protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

while this is nice, lets try to match all other onPropertyChanged handlers in the repo and just make this the property name string, drop the attribute, and just use the string and raise this directly with the string as an explicit parameter.

using System.Text.RegularExpressions;
using System.Xml;

using System.Runtime.CompilerServices;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shouldn't need this if you remove the callerMember attribute

[OutPortTypes("Color")]
[OutPortDescriptions("Selected Color.")]
public class ColorPalette : NodeModel
public class ColorPalette : NodeModel, INotifyPropertyChanged

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think you need this interface as NodeModel should already implement INotifyPropertyChanged

Update = dscolor;
}
OnNodeModified();
OnPropertyChanged();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

call this with the property name explicitly

set
{
{
if (dscolor.Equals(value))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this logic requires some comments

colorPaletteNode = model;
mcolor = Color.FromArgb(model.dsColor.Alpha, model.dsColor.Red, model.dsColor.Green, model.dsColor.Blue);
model.PropertyChanged += Model_PropertyChanged;
var undoRecorder = viewNode.ViewModel.WorkspaceViewModel.Model.UndoRecorder;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

any reason you are recording the state of the color picker immediately? When the user first selects a color - that should be the time you record the old color. Maybe this has to do with the two first undo bug you are seeing.

@mjkkirschner

Copy link
Copy Markdown
Member

@Gytaco thanks for this work - I have a few comments for you to check out - also - if possible it would be great to add an undo test for this node.

very similar to your other test, except invoke undo and asset the value is correct.

@mjkkirschner

Copy link
Copy Markdown
Member

This fixes the double up of value stores, however it still requires to
do an initial undo twice.
@Gytaco

Gytaco commented Apr 18, 2017

Copy link
Copy Markdown
Author

Hey @mjkkirschner here is the updated version. Are you happy with the type of hack?? I'm not but be interested to here if you have better ideas. Otherwise we can expand on this idea for the undo? Once I've got this sorted I'll write the unit tests.

@mjkkirschner mjkkirschner mentioned this pull request Apr 22, 2017
4 of 7 tasks
@mjkkirschner
mjkkirschner merged commit a746c89 into DynamoDS:master Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants