Handle the scroll wheel changing over scrollbars.
* Extract the scrollbar change based on the mouse wheel delta into a protected method of BView. * Call that method from BScrollBar's MessageReceived. With this change it is now a bit easier to scroll horizontally around the system by putting the mouse cursor over a horizontal scrollbar and using the wheel. Fixes #8631.
This commit is contained in:
@@ -584,6 +584,8 @@ protected:
|
|||||||
|
|
||||||
virtual void LayoutChanged();
|
virtual void LayoutChanged();
|
||||||
|
|
||||||
|
void ScrollWithMouseWheelDelta(BScrollBar*, float);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _Layout(bool force, BLayoutContext* context);
|
void _Layout(bool force, BLayoutContext* context);
|
||||||
void _LayoutLeft(BLayout* deleted);
|
void _LayoutLeft(BLayout* deleted);
|
||||||
|
|||||||
@@ -642,6 +642,22 @@ BScrollBar::MessageReceived(BMessage* message)
|
|||||||
ValueChanged(value);
|
ValueChanged(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case B_MOUSE_WHEEL_CHANGED:
|
||||||
|
{
|
||||||
|
// Must handle this here since BView checks for the existence of
|
||||||
|
// scrollbars, which a scrollbar itself does not have
|
||||||
|
float deltaX = 0.0f, deltaY = 0.0f;
|
||||||
|
message->FindFloat("be:wheel_delta_x", &deltaX);
|
||||||
|
message->FindFloat("be:wheel_delta_y", &deltaY);
|
||||||
|
|
||||||
|
if (deltaX == 0.0f && deltaY == 0.0f)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (deltaX != 0.0f && deltaY == 0.0f)
|
||||||
|
deltaY = deltaX;
|
||||||
|
|
||||||
|
ScrollWithMouseWheelDelta(this, deltaY);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
|
|||||||
+22
-21
@@ -4350,31 +4350,12 @@ BView::MessageReceived(BMessage* msg)
|
|||||||
if (deltaX == 0.0f && deltaY == 0.0f)
|
if (deltaX == 0.0f && deltaY == 0.0f)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
float smallStep, largeStep;
|
|
||||||
if (horizontal != NULL) {
|
if (horizontal != NULL) {
|
||||||
horizontal->GetSteps(&smallStep, &largeStep);
|
ScrollWithMouseWheelDelta(horizontal, deltaX);
|
||||||
|
|
||||||
// pressing the option/command/control key scrolls faster
|
|
||||||
if (modifiers()
|
|
||||||
& (B_OPTION_KEY | B_COMMAND_KEY | B_CONTROL_KEY)) {
|
|
||||||
deltaX *= largeStep;
|
|
||||||
} else
|
|
||||||
deltaX *= smallStep * 3;
|
|
||||||
|
|
||||||
horizontal->SetValue(horizontal->Value() + deltaX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vertical != NULL) {
|
if (vertical != NULL) {
|
||||||
vertical->GetSteps(&smallStep, &largeStep);
|
ScrollWithMouseWheelDelta(vertical, deltaY);
|
||||||
|
|
||||||
// pressing the option/command/control key scrolls faster
|
|
||||||
if (modifiers()
|
|
||||||
& (B_OPTION_KEY | B_COMMAND_KEY | B_CONTROL_KEY)) {
|
|
||||||
deltaY *= largeStep;
|
|
||||||
} else
|
|
||||||
deltaY *= smallStep * 3;
|
|
||||||
|
|
||||||
vertical->SetValue(vertical->Value() + deltaY);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -5721,6 +5702,26 @@ BView::_SwitchServerCurrentView() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BView::ScrollWithMouseWheelDelta(BScrollBar* scrollBar, float delta)
|
||||||
|
{
|
||||||
|
if (scrollBar == NULL || delta == 0.0f)
|
||||||
|
return;
|
||||||
|
|
||||||
|
float smallStep, largeStep;
|
||||||
|
scrollBar->GetSteps(&smallStep, &largeStep);
|
||||||
|
|
||||||
|
// pressing the option/command/control key scrolls faster
|
||||||
|
if (modifiers()
|
||||||
|
& (B_OPTION_KEY | B_COMMAND_KEY | B_CONTROL_KEY)) {
|
||||||
|
delta *= largeStep;
|
||||||
|
} else
|
||||||
|
delta *= smallStep * 3;
|
||||||
|
|
||||||
|
scrollBar->SetValue(scrollBar->Value() + delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if __GNUC__ == 2
|
#if __GNUC__ == 2
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user