mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 20:51:55 +00:00
Pending knob proportion setting implemented. Handle the case when knob proportion == 1.0
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19643 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7d048ada92
commit
6de723c6ad
1 changed files with 45 additions and 30 deletions
|
@ -417,23 +417,44 @@ static NSColor *scrollBarColor = nil;
|
||||||
/* Most likely our trackKnob method initiated this via NSScrollView */
|
/* Most likely our trackKnob method initiated this via NSScrollView */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ratio < 0)
|
if (ratio < 0)
|
||||||
{
|
{
|
||||||
_knobProportion = 0;
|
_pendingKnobProportion = 0;
|
||||||
}
|
}
|
||||||
else if (ratio > 1)
|
else if (ratio > 1)
|
||||||
{
|
{
|
||||||
_knobProportion = 1;
|
_pendingKnobProportion = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_knobProportion = ratio;
|
_pendingKnobProportion = ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_hitPart == NSScrollerNoPart)
|
||||||
|
{
|
||||||
|
_knobProportion = _pendingKnobProportion;
|
||||||
|
_pendingKnobProportion = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle the case when parts should disappear
|
||||||
|
if (_knobProportion == 1)
|
||||||
|
{
|
||||||
|
[self setEnabled: NO];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self setEnabled: YES];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't set float value if knob is being dragged
|
||||||
|
if (_hitPart != NSScrollerKnobSlot && _hitPart != NSScrollerKnob)
|
||||||
|
{
|
||||||
/* Make sure we mark ourselves as needing redisplay. */
|
/* Make sure we mark ourselves as needing redisplay. */
|
||||||
_floatValue = -1;
|
_floatValue = -1;
|
||||||
|
|
||||||
[self setFloatValue: aFloat];
|
[self setFloatValue: aFloat];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setFrame: (NSRect)frameRect
|
- (void) setFrame: (NSRect)frameRect
|
||||||
|
@ -567,23 +588,6 @@ static NSColor *scrollBarColor = nil;
|
||||||
{
|
{
|
||||||
case NSScrollerIncrementLine:
|
case NSScrollerIncrementLine:
|
||||||
case NSScrollerDecrementLine:
|
case NSScrollerDecrementLine:
|
||||||
/*
|
|
||||||
* A hit on a scroller button should be a page movement
|
|
||||||
* if the alt key is pressed.
|
|
||||||
*/
|
|
||||||
if ([theEvent modifierFlags] & NSAlternateKeyMask)
|
|
||||||
{
|
|
||||||
if (_hitPart == NSScrollerIncrementLine)
|
|
||||||
{
|
|
||||||
_hitPart = NSScrollerIncrementPage;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_hitPart = NSScrollerDecrementPage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Fall through to next case */
|
|
||||||
|
|
||||||
case NSScrollerIncrementPage:
|
case NSScrollerIncrementPage:
|
||||||
case NSScrollerDecrementPage:
|
case NSScrollerDecrementPage:
|
||||||
[self trackScrollButtons: theEvent];
|
[self trackScrollButtons: theEvent];
|
||||||
|
@ -612,6 +616,14 @@ static NSColor *scrollBarColor = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hitPart = NSScrollerNoPart;
|
_hitPart = NSScrollerNoPart;
|
||||||
|
if (_pendingKnobProportion)
|
||||||
|
{
|
||||||
|
[self setFloatValue: _floatValue knobProportion: _pendingKnobProportion];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self setNeedsDisplay:YES];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) trackKnob: (NSEvent*)theEvent
|
- (void) trackKnob: (NSEvent*)theEvent
|
||||||
|
@ -940,7 +952,9 @@ static NSColor *scrollBarColor = nil;
|
||||||
|
|
||||||
if (usableParts == NSNoScrollerParts
|
if (usableParts == NSNoScrollerParts
|
||||||
|| usableParts == NSOnlyScrollerArrows)
|
|| usableParts == NSOnlyScrollerArrows)
|
||||||
|
{
|
||||||
return NSZeroRect;
|
return NSZeroRect;
|
||||||
|
}
|
||||||
|
|
||||||
/* calc the slot Height */
|
/* calc the slot Height */
|
||||||
slotHeight = height - (_arrowsPosition == NSScrollerArrowsNone
|
slotHeight = height - (_arrowsPosition == NSScrollerArrowsNone
|
||||||
|
@ -952,11 +966,12 @@ static NSColor *scrollBarColor = nil;
|
||||||
|
|
||||||
/* calc knob's position */
|
/* calc knob's position */
|
||||||
knobPosition = _floatValue * (slotHeight - knobHeight);
|
knobPosition = _floatValue * (slotHeight - knobHeight);
|
||||||
knobPosition = (float)floor(knobPosition);
|
knobPosition = (float)floorf(knobPosition);
|
||||||
|
|
||||||
|
|
||||||
/* calc actual position */
|
/* calc actual position */
|
||||||
y += knobPosition + (_arrowsPosition == NSScrollerArrowsMaxEnd
|
y += knobPosition + ((_arrowsPosition == NSScrollerArrowsMaxEnd
|
||||||
|| _arrowsPosition == NSScrollerArrowsNone
|
|| _arrowsPosition == NSScrollerArrowsNone)
|
||||||
? 0 : buttonsSize);
|
? 0 : buttonsSize);
|
||||||
height = knobHeight;
|
height = knobHeight;
|
||||||
width = buttonsWidth;
|
width = buttonsWidth;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue