Skip to content

Commit

Permalink
Indicate selected preset in the presets menu
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbradsmith committed Oct 14, 2024
1 parent 319aede commit dbbb195
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions BinxelviewForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ enum PaletteMode
bool disable_pixel_redraw = false; // used to temporarily block redraws during repeated updates
Font posfont_regular, posfont_bold;
Random random = new Random();
int preset_menu_fixed_items;
int main_w, main_h; // used to restore size during split_view switch
int fixed_w, fixed_h;

Expand Down Expand Up @@ -1229,9 +1230,9 @@ bool openFile(string path)
void reloadPresets()
{
// remove everything but Reload, Set Directory and separator
while (presetToolStripMenuItem.DropDownItems.Count > 3)
while (presetToolStripMenuItem.DropDownItems.Count > preset_menu_fixed_items)
{
presetToolStripMenuItem.DropDownItems.RemoveAt(3);
presetToolStripMenuItem.DropDownItems.RemoveAt(preset_menu_fixed_items);
}
presets = new List<Preset>();

Expand Down Expand Up @@ -1586,6 +1587,13 @@ void redrawPreset()
twiddleZAdvancedMenuItem.Checked = preset.twiddle == 1;
twiddleNAdvancedMenuItem.Checked = preset.twiddle == 2;

// check the preset menu item corresponding to the current preset
for (int i=preset_menu_fixed_items; i < presetToolStripMenuItem.DropDownItems.Count; ++i)
{
ToolStripMenuItem t = (ToolStripMenuItem)presetToolStripMenuItem.DropDownItems[i];
t.Checked = (preset.name == t.Name);
}

disable_pixel_redraw = old_disable_pixel_redraw; // restore pixel redraw
}

Expand Down Expand Up @@ -1738,6 +1746,7 @@ private void exitFileMenuItem_Click(object sender, EventArgs e)
private void reloadPresetMenuItem_Click(object sender, EventArgs e)
{
reloadPresets();
redrawPreset();
}

private void setDirectoryPresetMenuItem_Click(object sender, EventArgs e)
Expand All @@ -1757,6 +1766,7 @@ private void setDirectoryPresetMenuItem_Click(object sender, EventArgs e)
{
preset_dir = Path.GetDirectoryName(d.FileName);
reloadPresets();
redrawPreset();
}
}

Expand Down Expand Up @@ -2175,6 +2185,7 @@ private void buttonSavePreset_Click(object sender, EventArgs e)
{
preset.name = Path.GetFileNameWithoutExtension(d.FileName); // update name for saved options
reloadPresets();
redrawPreset();
}
}
}
Expand Down Expand Up @@ -2647,6 +2658,7 @@ private void BinxelviewForm_Load(object sender, EventArgs e)
comboBoxPalette.SelectedIndex = (int)PaletteMode.PALETTE_RGB - 1;
numericZoom.Minimum = 1;
numericZoom.Maximum = ZOOM_MAX;
preset_menu_fixed_items = presetToolStripMenuItem.DropDownItems.Count;
fixed_w = this.Width; // default width is fixed width
fixed_h = this.Height - (pixelScroll.Height + 0); // fixed height should cut off pixel view entirely
main_w = this.Width;
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ Changes
- Use byte/bit for default chunky table instead of just bit.
- Genesis/MegaDrive 8px preset.
- Fix bug when loading version 3 presets.
- Indicate selected preset in the presets menu.

1.6.1.0 (2024-10-13)
- Option persistence, INI file save and load.
Expand Down

0 comments on commit dbbb195

Please sign in to comment.