mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
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:
parent
7883a8d446
commit
ecfb4c514b
2 changed files with 43 additions and 34 deletions
|
@ -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>
|
||||
|
||||
* Source/NSDrawer.m: Make drawers work, including:
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue