From 02fb5c50ea76e19e9eeb9b4fd850d6c7f2a02551 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 1 Jan 2020 09:08:22 -0800 Subject: [PATCH] Minor tweaks - Break up long sequences of visualization images in exported HTML to avoid horizontal scrolling. Lines don't fold in "pre" mode, and switching out of "pre" is ugly, so we just break at an arbitrary point. - Use a slightly different filename for animated GIFs. - When moving items up/down in the visualization set editor or bitmap animation editor, scroll the datagrid to keep the selected item in view. - Fix a wayward assert. --- SourceGen/Exporter.cs | 23 +++++++++++++++---- SourceGen/Visualization.cs | 2 +- SourceGen/WpfGui/EditBitmapAnimation.xaml.cs | 2 ++ .../WpfGui/EditInstructionOperand.xaml.cs | 5 ++-- SourceGen/WpfGui/EditVisualizationSet.xaml.cs | 2 ++ 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/SourceGen/Exporter.cs b/SourceGen/Exporter.cs index afeb8ed..6850518 100644 --- a/SourceGen/Exporter.cs +++ b/SourceGen/Exporter.cs @@ -761,6 +761,7 @@ namespace SourceGen { /// String builder for the HTML output. private void OutputVisualizationSet(int offset, StringBuilder sb) { const int IMAGE_SIZE = 64; + const int MAX_WIDTH_PER_LINE = 768; if (!mProject.VisualizationSets.TryGetValue(offset, out VisualizationSet visSet)) { @@ -775,11 +776,10 @@ namespace SourceGen { } string imageDirFileName = Path.GetFileName(mImageDirPath); + int outputWidth = 0; for (int index = 0; index < visSet.Count; index++) { - string fileName = "vis" + offset.ToString("x6") + "_" + index.ToString("d2") + - ".gif"; - string pathName = Path.Combine(mImageDirPath, fileName); + string fileName = "vis" + offset.ToString("x6") + "_" + index.ToString("d2"); int dispWidth, dispHeight; @@ -803,6 +803,7 @@ namespace SourceGen { } #if false + // try feeding the animated GIF into our GIF unpacker using (MemoryStream ms = new MemoryStream()) { encoder.Save(ms); Debug.WriteLine("TESTING"); @@ -812,6 +813,8 @@ namespace SourceGen { #endif // Create new or replace existing image file. + fileName += "_ani.gif"; + string pathName = Path.Combine(mImageDirPath, fileName); try { using (FileStream stream = new FileStream(pathName, FileMode.Create)) { encoder.Save(stream, out dispWidth, out dispHeight); @@ -830,6 +833,8 @@ namespace SourceGen { encoder.Frames.Add(BitmapFrame.Create(vis.CachedImage)); // Create new or replace existing image file. + fileName += ".gif"; + string pathName = Path.Combine(mImageDirPath, fileName); try { using (FileStream stream = new FileStream(pathName, FileMode.Create)) { encoder.Save(stream); @@ -866,9 +871,19 @@ namespace SourceGen { //Debug.WriteLine(dispWidth + "x" + dispHeight + " --> " + // thumbWidth + "x" + thumbHeight + " (" + maxDim + ")"); - if (index != 0) { + if (outputWidth > MAX_WIDTH_PER_LINE) { + // Add a line break. In "pre" mode the bitmaps just run off the right + // edge of the screen. The way we're doing it is imprecise and doesn't + // flow with changes to the browser width, but it'll do for now. + sb.AppendLine("
"); + for (int i = 0; i < mColStart[(int)Col.Label]; i++) { + sb.Append(' '); + } + outputWidth = 0; + } else if (index != 0) { sb.Append(" "); } + outputWidth += thumbWidth; sb.Append("\"vis\"= 0 && oldObj.SerialNumber < sNextSerial); SerialNumber = oldObj.SerialNumber; } - Debug.WriteLine("NEW VIS: Serial=" + SerialNumber); + //Debug.WriteLine("NEW VIS: Serial=" + SerialNumber); } /// diff --git a/SourceGen/WpfGui/EditBitmapAnimation.xaml.cs b/SourceGen/WpfGui/EditBitmapAnimation.xaml.cs index f19046e..7ba3ef5 100644 --- a/SourceGen/WpfGui/EditBitmapAnimation.xaml.cs +++ b/SourceGen/WpfGui/EditBitmapAnimation.xaml.cs @@ -357,6 +357,7 @@ namespace SourceGen.WpfGui { VisAnimItems.Remove(item); VisAnimItems.Insert(index - 1, item); visAnimGrid.SelectedIndex = index - 1; + visAnimGrid.ScrollIntoView(item); //RefreshAnim(); } @@ -371,6 +372,7 @@ namespace SourceGen.WpfGui { VisAnimItems.Remove(item); VisAnimItems.Insert(index + 1, item); visAnimGrid.SelectedIndex = index + 1; + visAnimGrid.ScrollIntoView(item); //RefreshAnim(); } diff --git a/SourceGen/WpfGui/EditInstructionOperand.xaml.cs b/SourceGen/WpfGui/EditInstructionOperand.xaml.cs index 6bce253..4be05d1 100644 --- a/SourceGen/WpfGui/EditInstructionOperand.xaml.cs +++ b/SourceGen/WpfGui/EditInstructionOperand.xaml.cs @@ -392,7 +392,9 @@ namespace SourceGen.WpfGui { mFormatter.NonUniqueLabelPrefix, out bool isValid, out bool unused1, out bool unused2, out bool hasNonUniquePrefix, out Symbol.LabelAnnotation unused3); - if (LookupSymbol(trimLabel, hasNonUniquePrefix, out Symbol sym)) { + if (string.IsNullOrEmpty(trimLabel)) { + sb.Append("?"); + } else if (LookupSymbol(trimLabel, hasNonUniquePrefix, out Symbol sym)) { // Block move is a little weird. "MVN label1,label2" is supposed to use // the bank byte, while "MVN #const1,#const2" uses the entire symbol. // The easiest thing to do is require the user to specify the "bank" @@ -434,7 +436,6 @@ namespace SourceGen.WpfGui { } } else { sb.Append(dfd.SymbolRef.Label + " (?)"); - Debug.Assert(!string.IsNullOrEmpty(dfd.SymbolRef.Label)); //symbolValueLabel.Text = Properties.Resources.MSG_SYMBOL_NOT_FOUND; } break; diff --git a/SourceGen/WpfGui/EditVisualizationSet.xaml.cs b/SourceGen/WpfGui/EditVisualizationSet.xaml.cs index 3aaa987..8a2340b 100644 --- a/SourceGen/WpfGui/EditVisualizationSet.xaml.cs +++ b/SourceGen/WpfGui/EditVisualizationSet.xaml.cs @@ -292,6 +292,7 @@ namespace SourceGen.WpfGui { VisualizationList.RemoveAt(index); VisualizationList.Insert(index - 1, item); visualizationGrid.SelectedIndex = index - 1; + visualizationGrid.ScrollIntoView(item); } private void DownButton_Click(object sender, RoutedEventArgs e) { @@ -301,6 +302,7 @@ namespace SourceGen.WpfGui { VisualizationList.RemoveAt(index); VisualizationList.Insert(index + 1, item); visualizationGrid.SelectedIndex = index + 1; + visualizationGrid.ScrollIntoView(item); } ///