mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-04 13:40:41 +00:00
Fix bad scrollers and NSButtonCell merge with main branch revision 39484
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@39524 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
952c5714a7
commit
77706afd51
2 changed files with 18 additions and 41 deletions
|
@ -365,7 +365,7 @@
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
margins.left = 3; margins.top = 3; margins.right = 3; margins.bottom = 3;
|
//margins.left = 3; margins.top = 3; margins.right = 3; margins.bottom = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -933,6 +933,14 @@ typedef struct _GSButtonCellFlags
|
||||||
- (void) setBackgroundColor: (NSColor *)color
|
- (void) setBackgroundColor: (NSColor *)color
|
||||||
{
|
{
|
||||||
ASSIGN(_backgroundColor, color);
|
ASSIGN(_backgroundColor, color);
|
||||||
|
|
||||||
|
if (_control_view)
|
||||||
|
{
|
||||||
|
if ([_control_view isKindOfClass: [NSControl class]])
|
||||||
|
{
|
||||||
|
[(NSControl*)_control_view updateCell: self];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (GSThemeControlState) themeControlState
|
- (GSThemeControlState) themeControlState
|
||||||
|
@ -1013,57 +1021,27 @@ typedef struct _GSButtonCellFlags
|
||||||
NSPoint offset;
|
NSPoint offset;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
CGFloat fraction;
|
CGFloat fraction;
|
||||||
NSSize size = [imageToDisplay size];
|
NSSize size = [self _scaleImageWithSize: [imageToDisplay size]
|
||||||
|
|
||||||
// Make sure image does not exceed or touch our frame...
|
|
||||||
// Not the best solution so have at it if you have a better one...
|
|
||||||
if ([self imagePosition] == NSImageOnly)
|
|
||||||
cellFrame = NSInsetRect(cellFrame, 4, 4);
|
|
||||||
|
|
||||||
size = [self _scaleImageWithSize: [imageToDisplay size]
|
|
||||||
toFitInSize: cellFrame.size
|
toFitInSize: cellFrame.size
|
||||||
scalingType: _imageScaling];
|
scalingType: _imageScaling];
|
||||||
|
|
||||||
/* Pixel-align size */
|
|
||||||
|
|
||||||
if (controlView)
|
|
||||||
{
|
|
||||||
NSSize sizeInBase = [controlView convertSizeToBase: size];
|
|
||||||
sizeInBase.width = GSRoundTowardsInfinity(sizeInBase.width);
|
|
||||||
sizeInBase.height = GSRoundTowardsInfinity(sizeInBase.height);
|
|
||||||
size = [controlView convertSizeFromBase: sizeInBase];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Calculate an offset from the cellFrame origin */
|
/* Calculate an offset from the cellFrame origin */
|
||||||
|
|
||||||
offset = NSMakePoint((NSWidth(cellFrame) - size.width) / 2.0,
|
offset = NSMakePoint((NSWidth(cellFrame) - size.width) / 2.0,
|
||||||
(NSHeight(cellFrame) - size.height) / 2.0);
|
(NSHeight(cellFrame) - size.height) / 2.0);
|
||||||
|
|
||||||
/* Pixel-align the offset */
|
|
||||||
|
|
||||||
if (controlView)
|
|
||||||
{
|
|
||||||
NSPoint inBase = [controlView convertPointToBase: offset];
|
|
||||||
|
|
||||||
// By convention we will round down and to the right.
|
|
||||||
// With the standard button design this looks good
|
|
||||||
// because the bottom and right edges of the button look 'heavier'
|
|
||||||
// so if the image's center must be offset from the button's geometric
|
|
||||||
// center, it looks beter if it's closer to the 'heavier' part
|
|
||||||
|
|
||||||
inBase.x = GSRoundTowardsInfinity(inBase.x);
|
|
||||||
inBase.y = ([controlView isFlipped] ? GSRoundTowardsInfinity(inBase.y) :
|
|
||||||
GSRoundTowardsNegativeInfinity(inBase.y));
|
|
||||||
|
|
||||||
offset = [controlView convertPointFromBase: inBase];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Draw the image */
|
|
||||||
|
|
||||||
rect = NSMakeRect(cellFrame.origin.x + offset.x,
|
rect = NSMakeRect(cellFrame.origin.x + offset.x,
|
||||||
cellFrame.origin.y + offset.y,
|
cellFrame.origin.y + offset.y,
|
||||||
size.width,
|
size.width,
|
||||||
size.height);
|
size.height);
|
||||||
|
|
||||||
|
/* Pixel-align */
|
||||||
|
if (nil != controlView)
|
||||||
|
{
|
||||||
|
rect = [controlView centerScanRect: rect];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw the image */
|
||||||
|
|
||||||
fraction = (![self isEnabled] &&
|
fraction = (![self isEnabled] &&
|
||||||
[self imageDimsWhenDisabled]) ? 0.5 : 1.0;
|
[self imageDimsWhenDisabled]) ? 0.5 : 1.0;
|
||||||
|
|
||||||
|
@ -1584,8 +1562,7 @@ typedef struct _GSButtonCellFlags
|
||||||
GSThemeMargins margins = [[GSTheme theme] buttonMarginsForCell: self
|
GSThemeMargins margins = [[GSTheme theme] buttonMarginsForCell: self
|
||||||
style: _bezel_style
|
style: _bezel_style
|
||||||
state: GSThemeNormalState];
|
state: GSThemeNormalState];
|
||||||
NSRect frame = [self insetFrame:theRect withMargins:margins];
|
return [self insetFrame:theRect withMargins:margins];
|
||||||
return frame;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue