1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-29 10:50:28 +00:00

Visualization editor UX enhancements

Remember the most recent set of parameters, and use them as defaults
when creating a new visualization.  This is very helpful when
creating visualizations for multiple frames of an animation.

After exiting an editor, focus on the "OK" button in the visualization
set editor.  This allows a quick double-Enter after an edit.
This commit is contained in:
Andy McFadden 2019-12-31 20:39:51 -08:00
parent dbc8c98010
commit 8aa4b7736e
3 changed files with 27 additions and 5 deletions

View File

@ -121,8 +121,8 @@ limitations under the License.
<TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" Margin="0,0,4,0"
Text="Tag:"/>
<TextBox Grid.Column="1" Grid.Row="1" Width="250" Margin="0,1,0,0" HorizontalAlignment="Left"
Text="{Binding TagString, UpdateSourceTrigger=PropertyChanged}"
<TextBox Grid.Column="1" Grid.Row="1" Name="tagTextBox" Width="250" Margin="0,1,0,0"
HorizontalAlignment="Left" Text="{Binding TagString, UpdateSourceTrigger=PropertyChanged}"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBlock Grid.Column="1" Grid.Row="2" Text="• Must be unique, 2+ chars"

View File

@ -49,6 +49,13 @@ namespace SourceGen.WpfGui {
/// </summary>
private static string sLastVisIdent = string.Empty;
/// <summary>
/// Parameters specified for the last thing we saved. Convenient when there's N frames
/// of an animation where everything is the same size / color.
/// </summary>
private static ReadOnlyDictionary<string, object> sLastParams =
new ReadOnlyDictionary<string, object>(new Dictionary<string, object>());
private Brush mDefaultLabelColor = SystemColors.WindowTextBrush;
private Brush mErrorLabelColor = Brushes.Red;
@ -250,9 +257,12 @@ namespace SourceGen.WpfGui {
}
} else {
// New visualization. Use the set's offset as the default value for
// any parameter called "offset".
// any parameter called "offset". Otherwise try to pull a value with
// the same name out of the last thing we edited.
if (vpd.Name.ToLowerInvariant() == "offset") {
defaultVal = mSetOffset;
} else if (sLastParams.TryGetValue(vpd.Name, out object value)) {
defaultVal = value;
}
}
@ -294,6 +304,9 @@ namespace SourceGen.WpfGui {
SetValue(MinHeightProperty, this.Height);
previewImage.ClearValue(WidthProperty);
previewImage.ClearValue(HeightProperty);
tagTextBox.SelectAll();
tagTextBox.Focus();
}
private void Window_Closed(object sender, EventArgs e) {
@ -303,7 +316,7 @@ namespace SourceGen.WpfGui {
private void OkButton_Click(object sender, RoutedEventArgs e) {
VisualizationItem item = (VisualizationItem)visComboBox.SelectedItem;
Debug.Assert(item != null);
ReadOnlyDictionary<string, object> valueDict = CreateVisGenParams();
ReadOnlyDictionary<string, object> valueDict = sLastParams = CreateVisGenParams();
string trimTag = Visualization.TrimAndValidateTag(TagString, out bool isTagValid);
Debug.Assert(isTagValid);
NewVis = new Visualization(trimTag, item.VisDescriptor.Ident, valueDict, mOrigVis);

View File

@ -150,7 +150,12 @@ namespace SourceGen.WpfGui {
}
// Check to see if changes have been made.
VisualizationSet newSet = MakeVisSet();
VisualizationSet newSet;
if (VisualizationList.Count == 0) {
newSet = null;
} else {
newSet = MakeVisSet();
}
if (newSet != mOrigSet) {
string msg = (string)FindResource("str_ConfirmDiscardChanges");
string caption = (string)FindResource("str_ConfirmDiscardChangesCaption");
@ -184,6 +189,8 @@ namespace SourceGen.WpfGui {
}
VisualizationList.Add(dlg.NewVis);
visualizationGrid.SelectedIndex = VisualizationList.Count - 1;
okButton.Focus();
}
private void NewBitmapAnimationButton_Click(object sender, RoutedEventArgs e) {
@ -194,6 +201,8 @@ namespace SourceGen.WpfGui {
}
VisualizationList.Add(dlg.NewAnim);
visualizationGrid.SelectedIndex = VisualizationList.Count - 1;
okButton.Focus();
}
private void EditButton_Click(object sender, RoutedEventArgs e) {