bool can_overscroll = false;
BPoint last_overscroll;
int last_reported_overscroll_value;
- int max_value;
+ int max_value, real_max_value;
+ int overscroll_start_value;
EmacsScrollBar (int x, int y, int x1, int y1, bool horizontal_p) :
BScrollBar (BRect (x, y, x1, y1), NULL, NULL, 0, 0, horizontal_p ?
portion = msg->GetInt32 ("emacs:portion", 0);
range = msg->GetInt32 ("emacs:range", 0);
dragging = msg->GetInt32 ("emacs:dragging", 0);
- proportion = (float) portion / range;
+ proportion = ((range <= 0 || portion <= 0)
+ ? 1.0f : (float) portion / range);
value = msg->GetInt32 ("emacs:units", 0);
can_overscroll = msg->GetBool ("emacs:overscroll", false);
SetRange (0, range - portion);
SetProportion (proportion);
max_value = range - portion;
+ real_max_value = range;
if (in_overscroll || value > max_value)
value = max_value;
old_value = value;
SetValue (value);
max_value = range - portion;
+ real_max_value = range;
}
}
}
goto allow;
}
- range = max_value;
+ range = real_max_value;
bounds = Bounds ();
bounds.InsetBy (1.0, 1.0);
- value = Value ();
+ value = overscroll_start_value;
trough_size = BE_RECT_HEIGHT (bounds);
trough_size -= BE_RECT_WIDTH (bounds) / 2;
if (info.double_arrows)
trough_size -= BE_RECT_WIDTH (bounds) / 2;
- value += ((double) range / trough_size) * diff * 2;
+ value += ((double) range / trough_size) * diff;
if (value != last_reported_overscroll_value)
{
last_reported_overscroll_value = value;
- last_overscroll = point;
value_event.scroll_bar = this;
value_event.window = Window ();
if (value == Value () && Proportion () < 1.0f)
{
+ overscroll_start_value = value;
in_overscroll = true;
last_overscroll = point;
last_reported_overscroll_value = value;