Changes to let updates happen less frequently:
* _ContrainPoint() was broken as it could never change the point it was supposed to contrain. * MouseDown() no longer sends a notification message automatically (only if it changed something) * MouseMoved() and synchronous MouseDown() will now only send modification messages if something actually changed (not for every mouse update). * After key presses, the invokation message is only sent when the value changed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19697 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
efe7244436
commit
fb29f5b0fb
@ -148,7 +148,7 @@ class BSlider : public BControl {
|
||||
|
||||
float _MinPosition() const;
|
||||
float _MaxPosition() const;
|
||||
bool _ConstrainPoint(BPoint point, BPoint compare) const;
|
||||
bool _ConstrainPoint(BPoint& point, BPoint compare) const;
|
||||
|
||||
virtual void _ReservedSlider5();
|
||||
virtual void _ReservedSlider6();
|
||||
|
@ -407,14 +407,20 @@ BSlider::KeyDown(const char *bytes, int32 numBytes)
|
||||
switch (bytes[0]) {
|
||||
case B_LEFT_ARROW:
|
||||
case B_DOWN_ARROW: {
|
||||
int32 oldValue = Value();
|
||||
|
||||
SetValue(Value() - KeyIncrementValue());
|
||||
Invoke();
|
||||
if (oldValue != Value())
|
||||
Invoke();
|
||||
break;
|
||||
}
|
||||
case B_RIGHT_ARROW:
|
||||
case B_UP_ARROW: {
|
||||
int32 oldValue = Value();
|
||||
|
||||
SetValue(Value() + KeyIncrementValue());
|
||||
Invoke();
|
||||
if (oldValue != Value())
|
||||
Invoke();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -423,8 +429,13 @@ BSlider::KeyDown(const char *bytes, int32 numBytes)
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Makes sure the \a point is within valid bounds.
|
||||
Returns \c true if the relevant coordinate (depending on the orientation
|
||||
of the slider) differs from \a comparePoint.
|
||||
*/
|
||||
bool
|
||||
BSlider::_ConstrainPoint(BPoint point, BPoint comparePoint) const
|
||||
BSlider::_ConstrainPoint(BPoint& point, BPoint comparePoint) const
|
||||
{
|
||||
if (fOrientation == B_HORIZONTAL) {
|
||||
if (point.x != comparePoint.x) {
|
||||
@ -465,7 +476,8 @@ BSlider::MouseDown(BPoint point)
|
||||
_ConstrainPoint(point, fInitialLocation);
|
||||
SetValue(ValueForPoint(point));
|
||||
|
||||
InvokeNotify(ModificationMessage(), B_CONTROL_MODIFIED);
|
||||
if (_Location() != fInitialLocation)
|
||||
InvokeNotify(ModificationMessage(), B_CONTROL_MODIFIED);
|
||||
|
||||
if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) {
|
||||
SetTracking(true);
|
||||
@ -481,8 +493,11 @@ BSlider::MouseDown(BPoint point)
|
||||
GetMouse(&point, &buttons, true);
|
||||
|
||||
if (_ConstrainPoint(point, prevPoint)) {
|
||||
SetValue(ValueForPoint(point));
|
||||
InvokeNotify(ModificationMessage(), B_CONTROL_MODIFIED);
|
||||
int32 value = ValueForPoint(point);
|
||||
if (value != Value()) {
|
||||
SetValue(value);
|
||||
InvokeNotify(ModificationMessage(), B_CONTROL_MODIFIED);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_Location() != fInitialLocation)
|
||||
@ -509,8 +524,11 @@ BSlider::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
|
||||
{
|
||||
if (IsTracking()) {
|
||||
if (_ConstrainPoint(point, _Location())) {
|
||||
SetValue(ValueForPoint(point));
|
||||
InvokeNotify(ModificationMessage(), B_CONTROL_MODIFIED);
|
||||
int32 value = ValueForPoint(point);
|
||||
if (value != Value()) {
|
||||
SetValue(value);
|
||||
InvokeNotify(ModificationMessage(), B_CONTROL_MODIFIED);
|
||||
}
|
||||
}
|
||||
} else
|
||||
BControl::MouseMoved(point, transit, message);
|
||||
|
Loading…
Reference in New Issue
Block a user