Skip to content

Commit

Permalink
scrollRange should always be followed by updatePos
Browse files Browse the repository at this point in the history
fix #23
  • Loading branch information
bbbradsmith committed Oct 14, 2024
1 parent 82ed4ac commit 175271c
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions BinxelviewForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1130,26 +1130,6 @@ void autoPalette() // regenerate automatic palettes
// Position and Scroll
//

void scrollRange()
{
if (view_scroll.Value > data.Length) view_scroll.Value = data.Length;
view_scroll.Maximum = data.Length;

next_increment_byte = preset.next_stride_byte * ((preset.height == 1) ? 16 : 1);
next_increment_bit = preset.next_stride_bit * ((preset.height == 1) ? 16 : 1);
int nb = next_increment_bit / 8;
next_increment_byte += nb;
next_increment_bit -= nb * 8;

view_scroll.LargeChange = (next_increment_byte >= 0) ? next_increment_byte : -next_increment_byte;

view_scroll.SmallChange = 1;
if (snap_scroll)
{
view_scroll.SmallChange = view_scroll.LargeChange;
}
}

void updatePos(bool update_scroll = true)
{
numericPosByte.Hexadecimal = (pos_byte >= 0) && !decimal_position;
Expand All @@ -1172,6 +1152,27 @@ void normalizePos()
updatePos();
}

void scrollRange()
{
if (view_scroll.Value > data.Length) view_scroll.Value = data.Length;
view_scroll.Maximum = data.Length;

next_increment_byte = preset.next_stride_byte * ((preset.height == 1) ? 16 : 1);
next_increment_bit = preset.next_stride_bit * ((preset.height == 1) ? 16 : 1);
int nb = next_increment_bit / 8;
next_increment_byte += nb;
next_increment_bit -= nb * 8;

view_scroll.LargeChange = (next_increment_byte >= 0) ? next_increment_byte : -next_increment_byte;
view_scroll.SmallChange = 1;
if (snap_scroll)
{
view_scroll.SmallChange = view_scroll.LargeChange;
}

updatePos();
}

void advanceClick(int inc_byte, int inc_bit)
{
if ((Control.ModifierKeys & Keys.Shift) != 0)
Expand Down Expand Up @@ -1217,7 +1218,6 @@ bool openFile(string path)
pos_byte = 0;
}
pos_bit = 0;
updatePos();
scrollRange();
data_path = path;
data_file = Path.GetFileName(path);
Expand Down

0 comments on commit 175271c

Please sign in to comment.