Revert button margins from theme drawing code and move into NSButtonCell which is more correct (still not quite right)

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@38906 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Marcian Lytwyn 2015-08-17 22:12:56 +00:00
parent db87c49163
commit ad0dc75094
2 changed files with 41 additions and 44 deletions

View file

@ -122,16 +122,6 @@
}
}
- (NSRect)insetFrame:(NSRect)frame withMargins:(GSThemeMargins)margins
{
NSRect result = frame;
result.origin.x += margins.left;
result.origin.y += margins.top;
result.size.width -= (margins.left + margins.right);
result.size.height -= (margins.top + margins.bottom);
return(result);
}
- (void) drawButton: (NSRect)frame
in: (NSCell*)cell
view: (NSView*)view
@ -176,9 +166,6 @@
tiles = [self tilesNamed: @"NSButton" state: state];
}
GSThemeMargins margins = [self buttonMarginsForCell: cell style: style state: state];
NSRect drawFrame = [self insetFrame:frame withMargins:margins];
if (tiles == nil)
{
switch (style)
@ -186,36 +173,36 @@
case NSRoundRectBezelStyle:
case NSTexturedRoundedBezelStyle:
case NSRoundedBezelStyle:
[self drawRoundBezel: drawFrame withColor: color];
[self drawRoundBezel: frame withColor: color];
break;
case NSTexturedSquareBezelStyle:
frame = NSInsetRect(drawFrame, 0, 1);
frame = NSInsetRect(frame, 0, 1);
case NSSmallSquareBezelStyle:
case NSRegularSquareBezelStyle:
case NSShadowlessSquareBezelStyle:
[color set];
NSRectFill(drawFrame);
NSRectFill(frame);
[[NSColor controlShadowColor] set];
NSFrameRectWithWidth(drawFrame, 1);
NSFrameRectWithWidth(frame, 1);
break;
case NSThickSquareBezelStyle:
[color set];
NSRectFill(drawFrame);
NSRectFill(frame);
[[NSColor controlShadowColor] set];
NSFrameRectWithWidth(drawFrame, 1.5);
NSFrameRectWithWidth(frame, 1.5);
break;
case NSThickerSquareBezelStyle:
[color set];
NSRectFill(drawFrame);
NSRectFill(frame);
[[NSColor controlShadowColor] set];
NSFrameRectWithWidth(drawFrame, 2);
NSFrameRectWithWidth(frame, 2);
break;
case NSCircularBezelStyle:
frame = NSInsetRect(drawFrame, 3, 3);
[self drawCircularBezel: drawFrame withColor: color];
frame = NSInsetRect(frame, 3, 3);
[self drawCircularBezel: frame withColor: color];
break;
case NSHelpButtonBezelStyle:
[self drawCircularBezel: drawFrame withColor: color];
[self drawCircularBezel: frame withColor: color];
{
NSDictionary *attributes = [NSDictionary dictionaryWithObject: [NSFont controlContentFontOfSize: 0]
forKey: NSFontAttributeName];
@ -225,8 +212,8 @@
NSRect textRect;
textRect.size = [questionMark size];
textRect.origin.x = NSMidX(drawFrame) - (textRect.size.width / 2);
textRect.origin.y = NSMidY(drawFrame) - (textRect.size.height / 2);
textRect.origin.x = NSMidX(frame) - (textRect.size.width / 2);
textRect.origin.y = NSMidY(frame) - (textRect.size.height / 2);
[questionMark drawInRect: textRect];
}
@ -238,19 +225,19 @@
break;
default:
[color set];
NSRectFill(drawFrame);
NSRectFill(frame);
if (state == GSThemeNormalState || state == GSThemeHighlightedState)
{
[self drawButton: drawFrame withClip: NSZeroRect];
[self drawButton: frame withClip: NSZeroRect];
}
else if (state == GSThemeSelectedState || state == GSThemeSelectedFirstResponderState)
{
[self drawGrayBezel: drawFrame withClip: NSZeroRect];
[self drawGrayBezel: frame withClip: NSZeroRect];
}
else
{
[self drawButton: drawFrame withClip: NSZeroRect];
[self drawButton: frame withClip: NSZeroRect];
}
}
}
@ -258,7 +245,7 @@
{
/* Use tiles to draw button border with central part filled with color
*/
[self fillRect: drawFrame
[self fillRect: frame
withTiles: tiles
background: color];
}
@ -339,15 +326,15 @@
{
if ([cell controlSize] == NSRegularControlSize)
{
margins.left = 10; margins.top = 9; margins.right = 10; margins.bottom = 9;
margins.left = 8; margins.top = 7; margins.right = 8; margins.bottom = 7;
}
else if ([cell controlSize] == NSSmallControlSize)
{
margins.left = 8; margins.top = 7; margins.right = 8; margins.bottom = 7;
margins.left = 6; margins.top = 5; margins.right = 6; margins.bottom = 5;
}
else if ([cell controlSize] == NSMiniControlSize)
{
margins.left = 7; margins.top = 6; margins.right = 7; margins.bottom = 6;
margins.left = 5; margins.top = 4; margins.right = 5; margins.bottom = 4;
}
}
break;

View file

@ -1122,6 +1122,7 @@ typedef struct _GSButtonCellFlags
|| [controlView mouse: [[controlView window] mouseLocationOutsideOfEventStream]
inRect: cellFrame]))
{
cellFrame = [self drawingRectForBounds:cellFrame];
[self drawBezelWithFrame: cellFrame inView: controlView];
}
}
@ -1514,6 +1515,17 @@ typedef struct _GSButtonCellFlags
return s;
}
- (NSRect)insetFrame:(NSRect)frame withMargins:(GSThemeMargins)margins
{
NSRect result = frame;
result.origin.x += margins.left;
result.origin.y += ([_control_view isFlipped] ?
margins.top : margins.bottom);
result.size.width -= (margins.left + margins.right);
result.size.height -= (margins.top + margins.bottom);
return(result);
}
- (NSRect) drawingRectForBounds: (NSRect)theRect
{
if (_cell.is_bordered)
@ -1550,15 +1562,9 @@ typedef struct _GSButtonCellFlags
}
border = [[GSTheme theme] buttonMarginsForCell: self
style: _bezel_style
state: buttonState];
interiorFrame = theRect;
interiorFrame.origin.x += border.left;
interiorFrame.size.width -= border.left + border.right;
interiorFrame.origin.y += ([_control_view isFlipped] ?
border.top : border.bottom);
interiorFrame.size.height -= border.bottom + border.top;
style: _bezel_style
state: buttonState];
interiorFrame = [self insetFrame:theRect withMargins:border];
/* Pushed in buttons contents are displaced to the bottom right 1px. */
if (mask & NSPushInCellMask)
@ -1570,7 +1576,11 @@ typedef struct _GSButtonCellFlags
}
else
{
return theRect;
GSThemeMargins margins = [[GSTheme theme] buttonMarginsForCell: self
style: _bezel_style
state: GSThemeNormalState];
NSRect frame = [self insetFrame:theRect withMargins:margins];
return frame;
}
}