mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 05:10:38 +00:00
* Headers/Additions/GNUstepGUI/GSTheme.h:
* Source/GSTheme.m: Declare GSSliderHorizontalTrack and GSSliderVerticalTrack part names for themeing the background of NSSlider * Source/GSThemeDrawing.m: Add new drawSliderBorderAndBackground:frame:inCell:isHorizontal: method to draw the slider border and background. * Source/GSThemePrivate.h: * Source/GSThemeTools.m: Add a -size method on GSDrawTiles which returns the total original size of the tiles, so we can easily compute a rect that scales the tiles in only one dimension. * Source/NSSliderCell.m: Override _drawBorderAndBackgroundWithFrame: to call new GSTheme method. Also, tweak the knob drawing code; the knob is now centered and drawn at its native size. This still looks correct with the default slider sizes create by Gorm. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37185 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d3be1c555f
commit
2347347cf9
7 changed files with 147 additions and 17 deletions
|
@ -2399,6 +2399,54 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
}
|
||||
}
|
||||
|
||||
- (void) drawSliderBorderAndBackground: (NSBorderType)aType
|
||||
frame: (NSRect)cellFrame
|
||||
inCell: (NSCell *)cell
|
||||
isHorizontal: (BOOL)horizontal
|
||||
{
|
||||
NSSliderType type = [(NSSliderCell *)cell sliderType];
|
||||
if (type == NSLinearSlider)
|
||||
{
|
||||
NSString *partName = (horizontal ? GSSliderHorizontalTrack : GSSliderVerticalTrack);
|
||||
GSDrawTiles *tiles = [self tilesNamed: partName
|
||||
state: GSThemeNormalState];
|
||||
|
||||
if (tiles == nil)
|
||||
{
|
||||
[[GSTheme theme] drawBorderType: aType
|
||||
frame: cellFrame
|
||||
view: [cell controlView]];
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: This code could be factored out
|
||||
NSSize tilesNaturalSize = [tiles size];
|
||||
NSRect tilesRect;
|
||||
|
||||
// Only stretch the tiles in one direction
|
||||
if (horizontal)
|
||||
{
|
||||
tilesRect.size = NSMakeSize(cellFrame.size.width, tilesNaturalSize.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
tilesRect.size = NSMakeSize(tilesNaturalSize.width, cellFrame.size.height);
|
||||
}
|
||||
tilesRect.origin = NSMakePoint((cellFrame.size.width - tilesRect.size.width) / 2.0,
|
||||
(cellFrame.size.height - tilesRect.size.height) / 2.0);
|
||||
|
||||
if ([cell controlView] != nil)
|
||||
{
|
||||
tilesRect = [[cell controlView] centerScanRect: tilesRect];
|
||||
}
|
||||
|
||||
[self fillRect: tilesRect
|
||||
withTiles: tiles
|
||||
background: [NSColor clearColor]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawBarInside: (NSRect)rect
|
||||
inCell: (NSCell *)cell
|
||||
flipped: (BOOL)flipped
|
||||
|
@ -2406,8 +2454,18 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
|
|||
NSSliderType type = [(NSSliderCell *)cell sliderType];
|
||||
if (type == NSLinearSlider)
|
||||
{
|
||||
[[NSColor scrollBarColor] set];
|
||||
NSRectFill(rect);
|
||||
BOOL horizontal = (rect.size.width > rect.size.height);
|
||||
NSString *partName = (horizontal ? GSSliderHorizontalTrack : GSSliderVerticalTrack);
|
||||
GSDrawTiles *tiles = [self tilesNamed: partName
|
||||
state: GSThemeNormalState];
|
||||
|
||||
if (tiles == nil)
|
||||
{
|
||||
[[NSColor scrollBarColor] set];
|
||||
NSRectFill(rect);
|
||||
}
|
||||
// Don't draw anything if we have tiles, they are drawn
|
||||
// in -drawSliderBorderAndBackground:...
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue