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

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.
This commit is contained in:
Andy McFadden 2020-01-01 09:08:22 -08:00
parent 8aa4b7736e
commit 02fb5c50ea
5 changed files with 27 additions and 7 deletions

View File

@ -761,6 +761,7 @@ namespace SourceGen {
/// <param name="sb">String builder for the HTML output.</param>
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("<br/>");
for (int i = 0; i < mColStart[(int)Col.Label]; i++) {
sb.Append(' ');
}
outputWidth = 0;
} else if (index != 0) {
sb.Append("&nbsp;");
}
outputWidth += thumbWidth;
sb.Append("<img class=\"vis\" alt=\"vis\" src=\"");
sb.Append(imageDirFileName);

View File

@ -154,7 +154,7 @@ namespace SourceGen {
Debug.Assert(oldObj.SerialNumber >= 0 && oldObj.SerialNumber < sNextSerial);
SerialNumber = oldObj.SerialNumber;
}
Debug.WriteLine("NEW VIS: Serial=" + SerialNumber);
//Debug.WriteLine("NEW VIS: Serial=" + SerialNumber);
}
/// <summary>

View File

@ -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();
}

View File

@ -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;

View File

@ -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);
}
/// <summary>