* Source/GSThemeDrawing.m: Change stepper drawing methods to use

images. The stepper is too small to make decomposing it in to
border + bezel + arrow worthwhile; it's simpler to just use images.
* Images/GNUmakefile:
* Images/common_StepperDown.tiff:
* Images/common_StepperDownHighlighted.tiff:
* Images/common_StepperUp.tiff:
* Images/common_StepperUpHighlighted.tiff: Add stepper images


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37229 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ericwa 2013-10-14 20:52:55 +00:00
parent c8c8f845ce
commit 1c0c80227c
7 changed files with 54 additions and 120 deletions

View file

@ -1,3 +1,14 @@
2013-10-14 Eric Wasylishen <ewasylishen@gmail.com>
* Source/GSThemeDrawing.m: Change stepper drawing methods to use
images. The stepper is too small to make decomposing it in to
border + bezel + arrow worthwhile; it's simpler to just use images.
* Images/GNUmakefile:
* Images/common_StepperDown.tiff:
* Images/common_StepperDownHighlighted.tiff:
* Images/common_StepperUp.tiff:
* Images/common_StepperUpHighlighted.tiff: Add stepper images
2013-10-14 Eric Wasylishen <ewasylishen@gmail.com> 2013-10-14 Eric Wasylishen <ewasylishen@gmail.com>
* Headers/Additions/GNUstepGUI/GSTheme.h: Add three new theme * Headers/Additions/GNUstepGUI/GSTheme.h: Add three new theme

View file

@ -102,6 +102,10 @@ Images_RESOURCE_FILES = \
common_Root_Sparc2.tiff \ common_Root_Sparc2.tiff \
common_SliderHoriz.tiff \ common_SliderHoriz.tiff \
common_SliderVert.tiff \ common_SliderVert.tiff \
common_StepperDown.tiff \
common_StepperDownHighlighted.tiff \
common_StepperUp.tiff \
common_StepperUpHighlighted.tiff \
common_SwitchOff.tiff \ common_SwitchOff.tiff \
common_SwitchOn.tiff \ common_SwitchOn.tiff \
common_TabDownSelectedLeft.tiff \ common_TabDownSelectedLeft.tiff \

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -694,157 +694,79 @@
} }
} }
// NSStepperCell drawing
// Hard coded values for button sizes
#define STEPPER_WIDTH 15
#define STEPPER_HEIGHT 11
- (NSRect) stepperUpButtonRectWithFrame: (NSRect)frame - (NSRect) stepperUpButtonRectWithFrame: (NSRect)frame
{ {
NSSize size = [[NSImage imageNamed: @"common_StepperUp"] size];
NSRect upRect; NSRect upRect;
upRect.size.width = STEPPER_WIDTH; upRect.size = size;
upRect.size.height = STEPPER_HEIGHT; upRect.origin.x = NSMaxX(frame) - size.width;
upRect.origin.x = NSMaxX(frame) - STEPPER_WIDTH - 1;
upRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) + 1; upRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) + 1;
return upRect; return upRect;
} }
- (NSRect) stepperDownButtonRectWithFrame: (NSRect)frame - (NSRect) stepperDownButtonRectWithFrame: (NSRect)frame
{ {
NSSize size = [[NSImage imageNamed: @"common_StepperDown"] size];
NSRect downRect; NSRect downRect;
downRect.size.width = STEPPER_WIDTH; downRect.size = size;
downRect.size.height = STEPPER_HEIGHT; downRect.origin.x = NSMaxX(frame) - size.width;
downRect.origin.x = NSMaxX(frame) - STEPPER_WIDTH - 1; downRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) - size.height + 1;
downRect.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) - STEPPER_HEIGHT + 1;
return downRect; return downRect;
} }
- (void) drawStepperBorder: (NSRect)frame - (void) drawStepperBorder: (NSRect)frame
{ {
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge};
NSColor *black = [NSColor controlDarkShadowColor];
NSColor *grays[] = {black, black};
NSRect twoButtons;
twoButtons.origin.x = NSMaxX(frame) - STEPPER_WIDTH - 1;
twoButtons.origin.y = NSMinY(frame) + ((int)frame.size.height / 2) - STEPPER_HEIGHT;
twoButtons.size.width = STEPPER_WIDTH + 1;
twoButtons.size.height = 2 * STEPPER_HEIGHT + 1;
NSDrawColorTiledRects(twoButtons, NSZeroRect,
up_sides, grays, 2);
} }
- (NSRect) drawStepperLightButton: (NSRect)border : (NSRect)clip - (NSRect) drawStepperLightButton: (NSRect)border : (NSRect)clip
{ {
/* return NSZeroRect;
NSRect highlightRect = NSInsetRect(border, 1., 1.);
[[GSTheme theme] drawButton: border : clip];
return highlightRect;
*/
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge,
NSMinXEdge, NSMaxYEdge};
NSRectEdge dn_sides[] = {NSMaxXEdge, NSMaxYEdge,
NSMinXEdge, NSMinYEdge};
// These names are role names not the actual colours
NSColor *dark = [NSColor controlShadowColor];
NSColor *white = [NSColor controlLightHighlightColor];
NSColor *colors[] = {dark, dark, white, white};
if ([[NSView focusView] isFlipped] == YES)
{
return NSDrawColorTiledRects(border, clip, dn_sides, colors, 4);
}
else
{
return NSDrawColorTiledRects(border, clip, up_sides, colors, 4);
}
} }
- (void) drawStepperUpButton: (NSRect)aRect - (void) drawStepperUpButton: (NSRect)aRect
{ {
NSRect unHighlightRect = [self drawStepperLightButton: aRect : NSZeroRect]; NSImage *image = [NSImage imageNamed: @"common_StepperUp"];
[[NSColor controlBackgroundColor] set]; [image drawInRect: aRect
NSRectFill(unHighlightRect); fromRect: NSZeroRect
operation: NSCompositeSourceOver
PSsetlinewidth(1.0); fraction: 1
[[NSColor controlShadowColor] set]; respectFlipped: YES
PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3); hints: nil];
PSlineto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSlineto(NSMaxX(aRect) - 11, NSMinY(aRect) + 4);
PSstroke();
[[NSColor controlLightHighlightColor] set];
PSmoveto(NSMaxX(aRect) - 11, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSstroke();
} }
- (void) drawStepperHighlightUpButton: (NSRect)aRect - (void) drawStepperHighlightUpButton: (NSRect)aRect
{ {
NSRect highlightRect = [self drawStepperLightButton: aRect : NSZeroRect]; NSImage *image = [NSImage imageNamed: @"common_StepperUpHighlighted"];
[[NSColor selectedControlColor] set]; [image drawInRect: aRect
NSRectFill(highlightRect); fromRect: NSZeroRect
operation: NSCompositeSourceOver
PSsetlinewidth(1.0); fraction: 1
[[NSColor controlHighlightColor] set]; respectFlipped: YES
PSmoveto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3); hints: nil];
PSlineto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMaxX(aRect) - 8, NSMinY(aRect) + 9);
PSlineto(NSMaxX(aRect) - 11, NSMinY(aRect) + 4);
PSstroke();
[[NSColor controlHighlightColor] set];
PSmoveto(NSMaxX(aRect) - 11, NSMinY(aRect) + 3);
PSlineto(NSMaxX(aRect) - 5, NSMinY(aRect) + 3);
PSstroke();
} }
- (void) drawStepperDownButton: (NSRect)aRect - (void) drawStepperDownButton: (NSRect)aRect
{ {
NSRect unHighlightRect = [self drawStepperLightButton: aRect : NSZeroRect]; NSImage *image = [NSImage imageNamed: @"common_StepperDown"];
[[NSColor controlBackgroundColor] set]; [image drawInRect: aRect
NSRectFill(unHighlightRect); fromRect: NSZeroRect
operation: NSCompositeSourceOver
PSsetlinewidth(1.0); fraction: 1
[[NSColor controlShadowColor] set]; respectFlipped: YES
PSmoveto(NSMinX(aRect) + 4, NSMaxY(aRect) - 3); hints: nil];
PSlineto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSstroke();
[[NSColor controlLightHighlightColor] set];
PSmoveto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSlineto(NSMinX(aRect) + 10, NSMaxY(aRect) - 3);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMinX(aRect) + 10, NSMaxY(aRect) - 2);
PSlineto(NSMinX(aRect) + 4, NSMaxY(aRect) - 2);
PSstroke();
} }
- (void) drawStepperHighlightDownButton: (NSRect)aRect - (void) drawStepperHighlightDownButton: (NSRect)aRect
{ {
NSRect highlightRect = [self drawStepperLightButton: aRect : NSZeroRect]; NSImage *image = [NSImage imageNamed: @"common_StepperDownHighlighted"];
[[NSColor selectedControlColor] set]; [image drawInRect: aRect
NSRectFill(highlightRect); fromRect: NSZeroRect
operation: NSCompositeSourceOver
PSsetlinewidth(1.0); fraction: 1
[[NSColor controlHighlightColor] set]; respectFlipped: YES
PSmoveto(NSMinX(aRect) + 4, NSMaxY(aRect) - 3); hints: nil];
PSlineto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSstroke();
[[NSColor controlHighlightColor] set];
PSmoveto(NSMinX(aRect) + 7, NSMaxY(aRect) - 8);
PSlineto(NSMinX(aRect) + 10, NSMaxY(aRect) - 3);
PSstroke();
[[NSColor controlDarkShadowColor] set];
PSmoveto(NSMinX(aRect) + 10, NSMaxY(aRect) - 2);
PSlineto(NSMinX(aRect) + 4, NSMaxY(aRect) - 2);
PSstroke();
} }
- (void) drawStepperCell: (NSCell*)cell - (void) drawStepperCell: (NSCell*)cell
@ -853,19 +775,16 @@
highlightUp: (BOOL)highlightUp highlightUp: (BOOL)highlightUp
highlightDown: (BOOL)highlightDown highlightDown: (BOOL)highlightDown
{ {
NSRect upRect; const NSRect upRect = [self stepperUpButtonRectWithFrame: cellFrame];
NSRect downRect; const NSRect downRect = [self stepperDownButtonRectWithFrame: cellFrame];
[self drawStepperBorder: cellFrame]; [self drawStepperBorder: cellFrame];
upRect = [self stepperUpButtonRectWithFrame: cellFrame];
downRect = [self stepperDownButtonRectWithFrame: cellFrame];
if (highlightUp) if (highlightUp)
[self drawStepperHighlightUpButton: upRect]; [self drawStepperHighlightUpButton: upRect];
else else
[self drawStepperUpButton: upRect]; [self drawStepperUpButton: upRect];
if (highlightDown) if (highlightDown)
[self drawStepperHighlightDownButton: downRect]; [self drawStepperHighlightDownButton: downRect];
else else