From 6ab53887e7a14d4c48f5fb7e477a23798b81b135 Mon Sep 17 00:00:00 2001 From: ericwa Date: Wed, 10 Feb 2010 07:31:24 +0000 Subject: [PATCH] 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 --- ChangeLog | 5 +++ Source/NSScrollView.m | 72 +++++++++++++++++++++++-------------------- 2 files changed, 43 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50d35e913..042e5117c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-02-10 Eric Wasylishen + + * Source/NSScrollView.m (-scrollWheel:): Respond to horizontal + scrolling. + 2010-01-14 Doug Simons * Source/NSDrawer.m: Make drawers work, including: diff --git a/Source/NSScrollView.m b/Source/NSScrollView.m index 5c1500906..a23db0fc0 100644 --- a/Source/NSScrollView.m +++ b/Source/NSScrollView.m @@ -387,7 +387,8 @@ static float scrollerWidth; - (void) scrollWheel: (NSEvent *)theEvent { NSRect clipViewBounds; - float delta = [theEvent deltaY]; + float deltaY = [theEvent deltaY]; + float deltaX = [theEvent deltaX]; float amount; NSPoint point; @@ -401,46 +402,49 @@ static float scrollerWidth; } point = clipViewBounds.origin; - - if (_hasHorizScroller == YES - && ([theEvent modifierFlags] & NSShiftKeyMask) == NSShiftKeyMask) + // Holding shift converts vertical scrolling to horizontal + if (([theEvent modifierFlags] & NSShiftKeyMask) == NSShiftKeyMask) { - if (([theEvent modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask) - { - amount = - (clipViewBounds.size.width - _hPageScroll) * delta; - } - else - { - amount = - _hLineScroll * delta; - } - NSDebugLLog (@"NSScrollView", - @"increment/decrement: amount = %f, horizontal", amount); + deltaX = -deltaY; + deltaY = 0; + } - point.x = clipViewBounds.origin.x + amount; + // Scroll horizontally + if (([theEvent modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask) + { + amount = (clipViewBounds.size.width - _hPageScroll) * deltaX; } else { - if (([theEvent modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask) - { - amount = - (clipViewBounds.size.height - _vPageScroll) * delta; - } - else - { - amount = - _vLineScroll * delta; - } - - if (_contentView != nil && !_contentView->_rFlags.flipped_view) - { - /* If view is flipped reverse the scroll direction */ - amount = -amount; - } - NSDebugLLog (@"NSScrollView", - @"increment/decrement: amount = %f, flipped = %d", - amount, _contentView ? _contentView->_rFlags.flipped_view : 0); - - point.y = clipViewBounds.origin.y + amount; + amount = _hLineScroll * deltaX; } + NSDebugLLog (@"NSScrollView", + @"increment/decrement: amount = %f, horizontal", amount); + + point.x = clipViewBounds.origin.x + amount; + + // Scroll vertically + if (([theEvent modifierFlags] & NSAlternateKeyMask) == NSAlternateKeyMask) + { + amount = - (clipViewBounds.size.height - _vPageScroll) * deltaY; + } + else + { + amount = - _vLineScroll * deltaY; + } + + if (_contentView != nil && !_contentView->_rFlags.flipped_view) + { + /* If view is flipped reverse the scroll direction */ + amount = -amount; + } + NSDebugLLog (@"NSScrollView", + @"increment/decrement: amount = %f, flipped = %d", + amount, _contentView ? _contentView->_rFlags.flipped_view : 0); + + point.y = clipViewBounds.origin.y + amount; + /* scrollToPoint: will call reflectScrolledClipView:, which will * update rules, headers, and scrollers. */ [_contentView _scrollToPoint: point];