mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 10:01:56 +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
d34a33eef0
commit
97d5edec42
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>
|
2013-10-02 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||||
|
|
|
@ -356,6 +356,7 @@ float _floatValueForMousePoint (NSPoint point, NSRect knobRect,
|
||||||
NSPoint point;
|
NSPoint point;
|
||||||
NSRect knobRect;
|
NSRect knobRect;
|
||||||
float fraction, angle, radius;
|
float fraction, angle, radius;
|
||||||
|
NSImage *image;
|
||||||
|
|
||||||
if (cellFrame.size.width > cellFrame.size.height)
|
if (cellFrame.size.width > cellFrame.size.height)
|
||||||
{
|
{
|
||||||
|
@ -373,25 +374,57 @@ float _floatValueForMousePoint (NSPoint point, NSRect knobRect,
|
||||||
cellFrame.size.width,
|
cellFrame.size.width,
|
||||||
cellFrame.size.width);
|
cellFrame.size.width);
|
||||||
}
|
}
|
||||||
knobCenter = NSMakePoint(NSMidX(knobRect), NSMidY(knobRect));
|
|
||||||
|
|
||||||
circle = [NSBezierPath bezierPathWithOvalInRect: knobRect];
|
if ([self controlView])
|
||||||
[[NSColor controlBackgroundColor] set];
|
knobRect = [[self controlView] centerScanRect: knobRect];
|
||||||
[circle fill];
|
|
||||||
[[NSColor blackColor] set];
|
image = [NSImage imageNamed: @"common_CircularSlider"];
|
||||||
[circle stroke];
|
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]) /
|
fraction = ([self floatValue] - [self minValue]) /
|
||||||
([self maxValue] - [self minValue]);
|
([self maxValue] - [self minValue]);
|
||||||
angle = (fraction * (2.0 * M_PI)) - (M_PI / 2.0);
|
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,
|
point = NSMakePoint((radius * cos(angle)) + knobCenter.x,
|
||||||
(radius * sin(angle)) + knobCenter.y);
|
(radius * sin(angle)) + knobCenter.y);
|
||||||
|
|
||||||
[[NSBezierPath bezierPathWithOvalInRect: NSMakeRect(point.x - 2,
|
image = [NSImage imageNamed: @"common_Dimple"];
|
||||||
point.y - 2,
|
{
|
||||||
4,
|
NSSize size = [image size];
|
||||||
4)] stroke];
|
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)
|
else if (_type == NSLinearSlider)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue