Respond to horizontal scrolling in NSScrollView

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29531 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ericwa 2010-02-10 07:31:24 +00:00
parent c039b1fb67
commit 6ab53887e7
2 changed files with 43 additions and 34 deletions

View file

@ -1,3 +1,8 @@
2010-02-10 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSScrollView.m (-scrollWheel:): Respond to horizontal
scrolling.
2010-01-14 Doug Simons <doug.simons@testplant.com> 2010-01-14 Doug Simons <doug.simons@testplant.com>
* Source/NSDrawer.m: Make drawers work, including: * Source/NSDrawer.m: Make drawers work, including:

View file

@ -387,7 +387,8 @@ static float scrollerWidth;
- (void) scrollWheel: (NSEvent *)theEvent - (void) scrollWheel: (NSEvent *)theEvent
{ {
NSRect clipViewBounds; NSRect clipViewBounds;
float delta = [theEvent deltaY]; float deltaY = [theEvent deltaY];
float deltaX = [theEvent deltaX];
float amount; float amount;
NSPoint point; NSPoint point;
@ -401,32 +402,36 @@ static float scrollerWidth;
} }
point = clipViewBounds.origin; point = clipViewBounds.origin;
// Holding shift converts vertical scrolling to horizontal
if (_hasHorizScroller == YES if (([theEvent modifierFlags] & NSShiftKeyMask) == NSShiftKeyMask)
&& ([theEvent modifierFlags] & NSShiftKeyMask) == NSShiftKeyMask)
{ {
deltaX = -deltaY;
deltaY = 0;
}
// Scroll horizontally
if (([theEvent modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask) if (([theEvent modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask)
{ {
amount = - (clipViewBounds.size.width - _hPageScroll) * delta; amount = (clipViewBounds.size.width - _hPageScroll) * deltaX;
} }
else else
{ {
amount = - _hLineScroll * delta; amount = _hLineScroll * deltaX;
} }
NSDebugLLog (@"NSScrollView", NSDebugLLog (@"NSScrollView",
@"increment/decrement: amount = %f, horizontal", amount); @"increment/decrement: amount = %f, horizontal", amount);
point.x = clipViewBounds.origin.x + amount; point.x = clipViewBounds.origin.x + amount;
}
else // Scroll vertically
{
if (([theEvent modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask) if (([theEvent modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask)
{ {
amount = - (clipViewBounds.size.height - _vPageScroll) * delta; amount = - (clipViewBounds.size.height - _vPageScroll) * deltaY;
} }
else else
{ {
amount = - _vLineScroll * delta; amount = - _vLineScroll * deltaY;
} }
if (_contentView != nil && !_contentView->_rFlags.flipped_view) if (_contentView != nil && !_contentView->_rFlags.flipped_view)
@ -439,7 +444,6 @@ static float scrollerWidth;
amount, _contentView ? _contentView->_rFlags.flipped_view : 0); amount, _contentView ? _contentView->_rFlags.flipped_view : 0);
point.y = clipViewBounds.origin.y + amount; point.y = clipViewBounds.origin.y + amount;
}
/* scrollToPoint: will call reflectScrolledClipView:, which will /* scrollToPoint: will call reflectScrolledClipView:, which will
* update rules, headers, and scrollers. */ * update rules, headers, and scrollers. */