mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 08:30:59 +00:00
* Source/NSSliderCell.m: Support themeing the circular slider
with the image @"common_CircularSlider". Draw the dimple with @"common_Dimple" instead of an NSBezierPath. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37186 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2347347cf9
commit
5cd9dd8b7e
2 changed files with 50 additions and 11 deletions
|
@ -1,3 +1,9 @@
|
|||
2013-10-03 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSSliderCell.m: Support themeing the circular slider
|
||||
with the image @"common_CircularSlider". Draw the dimple
|
||||
with @"common_Dimple" instead of an NSBezierPath.
|
||||
|
||||
2013-10-02 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
|
|
|
@ -356,6 +356,7 @@ float _floatValueForMousePoint (NSPoint point, NSRect knobRect,
|
|||
NSPoint point;
|
||||
NSRect knobRect;
|
||||
float fraction, angle, radius;
|
||||
NSImage *image;
|
||||
|
||||
if (cellFrame.size.width > cellFrame.size.height)
|
||||
{
|
||||
|
@ -373,25 +374,57 @@ float _floatValueForMousePoint (NSPoint point, NSRect knobRect,
|
|||
cellFrame.size.width,
|
||||
cellFrame.size.width);
|
||||
}
|
||||
knobCenter = NSMakePoint(NSMidX(knobRect), NSMidY(knobRect));
|
||||
|
||||
circle = [NSBezierPath bezierPathWithOvalInRect: knobRect];
|
||||
[[NSColor controlBackgroundColor] set];
|
||||
[circle fill];
|
||||
[[NSColor blackColor] set];
|
||||
[circle stroke];
|
||||
if ([self controlView])
|
||||
knobRect = [[self controlView] centerScanRect: knobRect];
|
||||
|
||||
image = [NSImage imageNamed: @"common_CircularSlider"];
|
||||
if (image != nil)
|
||||
{
|
||||
[image drawInRect: knobRect
|
||||
fromRect: NSZeroRect
|
||||
operation: NSCompositeSourceOver
|
||||
fraction: 1.0
|
||||
respectFlipped: YES
|
||||
hints: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
knobRect = NSInsetRect(knobRect, 1, 1);
|
||||
circle = [NSBezierPath bezierPathWithOvalInRect: knobRect];
|
||||
[[NSColor controlBackgroundColor] set];
|
||||
[circle fill];
|
||||
[[NSColor blackColor] set];
|
||||
[circle stroke];
|
||||
}
|
||||
|
||||
knobCenter = NSMakePoint(NSMidX(knobRect), NSMidY(knobRect));
|
||||
|
||||
fraction = ([self floatValue] - [self minValue]) /
|
||||
([self maxValue] - [self minValue]);
|
||||
angle = (fraction * (2.0 * M_PI)) - (M_PI / 2.0);
|
||||
radius = (knobRect.size.height / 2) - 4;
|
||||
radius = (knobRect.size.height / 2) - 6;
|
||||
point = NSMakePoint((radius * cos(angle)) + knobCenter.x,
|
||||
(radius * sin(angle)) + knobCenter.y);
|
||||
|
||||
[[NSBezierPath bezierPathWithOvalInRect: NSMakeRect(point.x - 2,
|
||||
point.y - 2,
|
||||
4,
|
||||
4)] stroke];
|
||||
image = [NSImage imageNamed: @"common_Dimple"];
|
||||
{
|
||||
NSSize size = [image size];
|
||||
NSRect dimpleRect = NSMakeRect(point.x - (size.width / 2.0),
|
||||
point.y - (size.height / 2.0),
|
||||
size.width,
|
||||
size.height);
|
||||
|
||||
if ([self controlView])
|
||||
dimpleRect = [[self controlView] centerScanRect: dimpleRect];
|
||||
|
||||
[image drawInRect: dimpleRect
|
||||
fromRect: NSZeroRect
|
||||
operation: NSCompositeSourceOver
|
||||
fraction: 1.0
|
||||
respectFlipped: YES
|
||||
hints: nil];
|
||||
}
|
||||
}
|
||||
else if (_type == NSLinearSlider)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue