mirror of
https://github.com/fadden/6502bench.git
synced 2024-09-10 13:54:52 +00:00
Make visualization edit window resizable
The preview window changes size to match, providing an easy way to get a "zoomed in" view of the image.
This commit is contained in:
parent
b56bdb7743
commit
4696132dfa
@ -198,7 +198,7 @@ namespace RuntimeData.Apple {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lastOffset = offset + itemByteWidth * itemHeight - 1;
|
int lastOffset = offset + itemByteWidth * itemHeight * count - 1;
|
||||||
if (lastOffset >= mFileData.Length) {
|
if (lastOffset >= mFileData.Length) {
|
||||||
mAppRef.ReportError("Bitmap runs off end of file (last offset +" +
|
mAppRef.ReportError("Bitmap runs off end of file (last offset +" +
|
||||||
lastOffset.ToString("x6") + ")");
|
lastOffset.ToString("x6") + ")");
|
||||||
|
@ -23,8 +23,9 @@ limitations under the License.
|
|||||||
xmlns:local="clr-namespace:SourceGen.WpfGui"
|
xmlns:local="clr-namespace:SourceGen.WpfGui"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Edit Visualization"
|
Title="Edit Visualization"
|
||||||
Width="460" SizeToContent="Height" ResizeMode="NoResize"
|
SizeToContent="WidthAndHeight" ResizeMode="CanResizeWithGrip"
|
||||||
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
|
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
|
||||||
|
Loaded="Window_Loaded"
|
||||||
Closed="Window_Closed">
|
Closed="Window_Closed">
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
@ -91,7 +92,7 @@ limitations under the License.
|
|||||||
<Grid Margin="8">
|
<Grid Margin="8">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
@ -110,30 +111,30 @@ limitations under the License.
|
|||||||
|
|
||||||
<TextBlock Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" Margin="0,3,4,0"
|
<TextBlock Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" Margin="0,3,4,0"
|
||||||
Text="Visualizer:"/>
|
Text="Visualizer:"/>
|
||||||
<ComboBox Name="visComboBox" Grid.Column="1" Grid.Row="0" Margin="0,0,0,4"
|
<ComboBox Name="visComboBox" Grid.Column="1" Grid.Row="0" Width="250" Margin="0,0,0,4"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
ItemsSource="{Binding VisualizationList}" DisplayMemberPath="VisDescriptor.UiName"
|
ItemsSource="{Binding VisualizationList}" DisplayMemberPath="VisDescriptor.UiName"
|
||||||
SelectionChanged="VisComboBox_SelectionChanged"/>
|
SelectionChanged="VisComboBox_SelectionChanged"/>
|
||||||
|
|
||||||
<TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" Margin="0,0,4,0"
|
<TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" Margin="0,0,4,0"
|
||||||
Text="Tag:" Foreground="{Binding TagLabelBrush}"/>
|
Text="Tag:" Foreground="{Binding TagLabelBrush}"/>
|
||||||
<TextBox Grid.Column="1" Grid.Row="1" Margin="0,1,0,0"
|
<TextBox Grid.Column="1" Grid.Row="1" Width="250" Margin="0,1,0,0" HorizontalAlignment="Left"
|
||||||
Text="{Binding TagString, UpdateSourceTrigger=PropertyChanged}"
|
Text="{Binding TagString, UpdateSourceTrigger=PropertyChanged}"
|
||||||
FontFamily="{StaticResource GeneralMonoFont}"/>
|
FontFamily="{StaticResource GeneralMonoFont}"/>
|
||||||
|
|
||||||
<TextBlock Grid.Column="1" Grid.Row="2" Text="• Must be unique, 2+ chars"/>
|
<TextBlock Grid.Column="1" Grid.Row="2" Text="• Must be unique, 2+ chars"/>
|
||||||
|
|
||||||
<TextBlock Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Margin="0,20,0,4" Text="Preview:"/>
|
<TextBlock Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Margin="0,10,0,4" Text="Preview:"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Border Grid.Row="1" BorderThickness="1" HorizontalAlignment="Center"
|
<Border Grid.Row="1" BorderThickness="1" HorizontalAlignment="Stretch"
|
||||||
BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}"
|
BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}"
|
||||||
Background="{StaticResource CheckerBackground}">
|
Background="{StaticResource CheckerBackground}">
|
||||||
<Image Name="previewImage" Width="320" Height="320" Source="/Res/RedX.png"
|
<Image Name="previewImage" Width="400" Height="400" Source="/Res/RedX.png"
|
||||||
RenderOptions.BitmapScalingMode="NearestNeighbor"/>
|
RenderOptions.BitmapScalingMode="NearestNeighbor"/>
|
||||||
<!--<Button Width="400" Height="400" Content="Test"/>-->
|
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<Grid Grid.Row="2">
|
<Grid Grid.Row="2" HorizontalAlignment="Left">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
@ -148,7 +149,7 @@ limitations under the License.
|
|||||||
<TextBlock Grid.Row="1" Text="Parameters:" Margin="0,0,0,4"/>
|
<TextBlock Grid.Row="1" Text="Parameters:" Margin="0,0,0,4"/>
|
||||||
|
|
||||||
<!-- generated controls are placed here -->
|
<!-- generated controls are placed here -->
|
||||||
<ItemsControl Grid.Row="2"
|
<ItemsControl Grid.Row="2" Width="400"
|
||||||
ItemsSource="{Binding ParameterList}"
|
ItemsSource="{Binding ParameterList}"
|
||||||
ItemTemplateSelector="{StaticResource ParameterTemplateSelector}">
|
ItemTemplateSelector="{StaticResource ParameterTemplateSelector}">
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
@ -40,6 +40,7 @@ namespace SourceGen.WpfGui {
|
|||||||
private Formatter mFormatter;
|
private Formatter mFormatter;
|
||||||
private int mSetOffset;
|
private int mSetOffset;
|
||||||
private Visualization mOrigVis;
|
private Visualization mOrigVis;
|
||||||
|
private string mOrigTag;
|
||||||
|
|
||||||
private Brush mDefaultLabelColor = SystemColors.WindowTextBrush;
|
private Brush mDefaultLabelColor = SystemColors.WindowTextBrush;
|
||||||
private Brush mErrorLabelColor = Brushes.Red;
|
private Brush mErrorLabelColor = Brushes.Red;
|
||||||
@ -167,6 +168,7 @@ namespace SourceGen.WpfGui {
|
|||||||
mFormatter = formatter;
|
mFormatter = formatter;
|
||||||
mSetOffset = setOffset;
|
mSetOffset = setOffset;
|
||||||
mOrigVis = vis;
|
mOrigVis = vis;
|
||||||
|
mOrigTag = vis.Tag;
|
||||||
|
|
||||||
mScriptSupport = new ScriptSupport(this);
|
mScriptSupport = new ScriptSupport(this);
|
||||||
mProject.PrepareScripts(mScriptSupport);
|
mProject.PrepareScripts(mScriptSupport);
|
||||||
@ -251,6 +253,24 @@ namespace SourceGen.WpfGui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||||
|
// https://stackoverflow.com/a/31407415/294248
|
||||||
|
// After the window's size has been established to minimally wrap the elements,
|
||||||
|
// we set the minimum width to the current width, and un-freeze the preview image
|
||||||
|
// control so it changes size with the window. This allows the window to resize
|
||||||
|
// without clipping any of the controls.
|
||||||
|
//
|
||||||
|
// This isn't quite right of course -- if the user changes the combo box setting
|
||||||
|
// the number of parameter controls will change -- but that just means the preview
|
||||||
|
// window will shrink or grow. So long as this isn't taken to extremes we won't
|
||||||
|
// clip controls.
|
||||||
|
ClearValue(SizeToContentProperty);
|
||||||
|
SetValue(MinWidthProperty, this.Width);
|
||||||
|
SetValue(MinHeightProperty, this.Height);
|
||||||
|
previewImage.ClearValue(WidthProperty);
|
||||||
|
previewImage.ClearValue(HeightProperty);
|
||||||
|
}
|
||||||
|
|
||||||
private void Window_Closed(object sender, EventArgs e) {
|
private void Window_Closed(object sender, EventArgs e) {
|
||||||
mProject.UnprepareScripts();
|
mProject.UnprepareScripts();
|
||||||
}
|
}
|
||||||
@ -406,6 +426,7 @@ namespace SourceGen.WpfGui {
|
|||||||
// Report the last message we got as an error.
|
// Report the last message we got as an error.
|
||||||
PluginErrMessage = LastPluginMessage;
|
PluginErrMessage = LastPluginMessage;
|
||||||
}
|
}
|
||||||
|
IsValid = false;
|
||||||
} else {
|
} else {
|
||||||
previewImage.Source = Visualization.ConvertToBitmapSource(vis2d);
|
previewImage.Source = Visualization.ConvertToBitmapSource(vis2d);
|
||||||
}
|
}
|
||||||
@ -413,8 +434,15 @@ namespace SourceGen.WpfGui {
|
|||||||
|
|
||||||
string trimTag = Visualization.TrimAndValidateTag(TagString, out bool tagOk);
|
string trimTag = Visualization.TrimAndValidateTag(TagString, out bool tagOk);
|
||||||
Visualization match = FindVisualizationByTag(trimTag);
|
Visualization match = FindVisualizationByTag(trimTag);
|
||||||
if (match != null && match != mOrigVis) {
|
if (match != null && trimTag != mOrigTag) {
|
||||||
// Another vis already has this tag.
|
// Another vis already has this tag.
|
||||||
|
//
|
||||||
|
// TODO: this is wrong. If I edit the set, edit a Vis, change it's tag, then
|
||||||
|
// immediately edit it again, I can't change the tag back to what it originally
|
||||||
|
// was, because the original version of the Vis is in the VisSet and I no longer
|
||||||
|
// have a way to know that that Vis and this Vis are the same. To make this work
|
||||||
|
// correctly we need to track renames, which I think we may want to do later on
|
||||||
|
// for animations, so not dealing with this yet.
|
||||||
tagOk = false;
|
tagOk = false;
|
||||||
}
|
}
|
||||||
if (!tagOk) {
|
if (!tagOk) {
|
||||||
|
Loading…
Reference in New Issue
Block a user