mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 10:01:14 +00:00
theming cleanups
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29024 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
73f0d0ca88
commit
09c902f201
5 changed files with 55 additions and 41 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2009-11-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSMenuItemCell.m:
|
||||
* Source/GSThemeDrawing.m:
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
Removed duplicate theming methods...
|
||||
The ([-arrowImageForMenuItemCell]) method seems to have duplicated the
|
||||
([-imageNamed:]) method (for the @"NSMenuItem" image) and the
|
||||
([-backgroundColorForMenuItemCell:state:]) method seemed to have
|
||||
duplicated the ([colorNamed:state:cache]) method.
|
||||
We must not introduce extra APIs for getting images and colors or
|
||||
things will get unmaintainable.
|
||||
|
||||
2009-11-16 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSSlider.m: Clean up.
|
||||
|
|
|
@ -701,10 +701,7 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
position: (NSPoint) position;
|
||||
|
||||
|
||||
// menu item cell drawing methods
|
||||
- (NSImage *) arrowImageForMenuItemCell;
|
||||
- (NSColor *) backgroundColorForMenuItemCell: (NSMenuItemCell *)cell
|
||||
state: (GSThemeControlState)state;
|
||||
// menu item cell drawing method
|
||||
- (void) drawBorderAndBackgroundForMenuItemCell: (NSMenuItemCell *)cell
|
||||
withFrame: (NSRect)cellFrame
|
||||
inView: (NSView *)controlView
|
||||
|
|
|
@ -395,7 +395,7 @@ typedef struct {
|
|||
if (old == nil)
|
||||
{
|
||||
/* This could potentially be a real problem ... if the
|
||||
* image form the current theme with this name is used
|
||||
* image from the current theme with this name is used
|
||||
* and the theme is unloaded, what happens when the
|
||||
* app tries to draw using the proxy to the unloaded
|
||||
* image?
|
||||
|
|
|
@ -682,33 +682,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (NSImage *) arrowImageForMenuItemCell
|
||||
{
|
||||
return [NSImage imageNamed: @"NSMenuArrow"];
|
||||
}
|
||||
|
||||
// menu item cell drawing methods
|
||||
- (NSColor *) backgroundColorForMenuItemCell: (NSMenuItemCell *)cell
|
||||
state: (GSThemeControlState)state
|
||||
{
|
||||
if ((state == GSThemeHighlightedState) || (state == GSThemeSelectedState))
|
||||
{
|
||||
return [NSColor selectedMenuItemColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [NSColor controlBackgroundColor];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawBorderAndBackgroundForMenuItemCell: (NSMenuItemCell *)cell
|
||||
withFrame: (NSRect)cellFrame
|
||||
inView: (NSView *)controlView
|
||||
state: (GSThemeControlState)state
|
||||
isHorizontal: (BOOL)isHorizontal
|
||||
{
|
||||
NSColor *backgroundColor = [self backgroundColorForMenuItemCell: cell
|
||||
state: state];
|
||||
NSColor *backgroundColor = [cell backgroundColor];
|
||||
|
||||
if (isHorizontal)
|
||||
{
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
|
||||
- (NSColor *)textColor
|
||||
{
|
||||
if(_cell.is_highlighted && [self isEnabled])
|
||||
if (_cell.is_highlighted && [self isEnabled])
|
||||
{
|
||||
return [NSColor selectedMenuItemTextColor];
|
||||
}
|
||||
|
@ -104,8 +104,9 @@
|
|||
|
||||
- (NSColor *) backgroundColor
|
||||
{
|
||||
unsigned mask;
|
||||
GSThemeControlState menuState = GSThemeNormalState;
|
||||
unsigned mask;
|
||||
NSColor *color;
|
||||
GSThemeControlState state = GSThemeNormalState;
|
||||
|
||||
if (_cell.is_highlighted)
|
||||
{
|
||||
|
@ -122,16 +123,28 @@
|
|||
// Determine the background color
|
||||
if (mask & (NSChangeGrayCellMask | NSChangeBackgroundCellMask))
|
||||
{
|
||||
menuState = GSThemeHighlightedState;
|
||||
state = GSThemeHighlightedState;
|
||||
}
|
||||
|
||||
if (mask & NSPushInCellMask)
|
||||
{
|
||||
menuState = GSThemeSelectedState;
|
||||
state = GSThemeSelectedState;
|
||||
}
|
||||
|
||||
return [[GSTheme theme] backgroundColorForMenuItemCell: self
|
||||
state: menuState];
|
||||
color = [[GSTheme theme] colorNamed: @"NSMenuItem" state: state cache: YES];
|
||||
if (color == nil)
|
||||
{
|
||||
if ((state == GSThemeHighlightedState) || (state == GSThemeSelectedState))
|
||||
{
|
||||
color = [NSColor selectedMenuItemColor];
|
||||
}
|
||||
else
|
||||
{
|
||||
color = [NSColor controlBackgroundColor];
|
||||
}
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
- (void) setMenuItem: (NSMenuItem *)item
|
||||
|
@ -294,7 +307,16 @@
|
|||
// Submenu Arrow
|
||||
if ([_menuItem hasSubmenu])
|
||||
{
|
||||
componentSize = [[[GSTheme theme] arrowImageForMenuItemCell] size];
|
||||
NSImage *arrow = [NSImage imageNamed: @"NSMenuArrow"];
|
||||
|
||||
if (arrow != nil)
|
||||
{
|
||||
componentSize = [arrow size];
|
||||
}
|
||||
else
|
||||
{
|
||||
componentSize = NSMakeSize(0, 0);
|
||||
}
|
||||
_keyEquivalentWidth = componentSize.width;
|
||||
if (componentSize.height > neededMenuItemHeight)
|
||||
neededMenuItemHeight = componentSize.height;
|
||||
|
@ -607,7 +629,7 @@
|
|||
inView: (NSView *)controlView
|
||||
{
|
||||
unsigned mask;
|
||||
GSThemeControlState menuState = GSThemeNormalState;
|
||||
GSThemeControlState state = GSThemeNormalState;
|
||||
|
||||
// set the mask
|
||||
if (_cell.is_highlighted)
|
||||
|
@ -629,19 +651,19 @@
|
|||
as required by our nextstep-like look and feel. */
|
||||
if (mask & (NSChangeGrayCellMask | NSChangeBackgroundCellMask))
|
||||
{
|
||||
menuState = GSThemeHighlightedState;
|
||||
state = GSThemeHighlightedState;
|
||||
}
|
||||
|
||||
/* Pushed in buttons contents are displaced to the bottom right 1px. */
|
||||
if (mask & NSPushInCellMask)
|
||||
{
|
||||
menuState = GSThemeSelectedState;
|
||||
state = GSThemeSelectedState;
|
||||
}
|
||||
|
||||
[[GSTheme theme] drawBorderAndBackgroundForMenuItemCell: self
|
||||
withFrame: cellFrame
|
||||
inView: controlView
|
||||
state: menuState
|
||||
state: state
|
||||
isHorizontal: [_menuView isHorizontal]];
|
||||
}
|
||||
|
||||
|
@ -655,14 +677,16 @@
|
|||
- (void) drawKeyEquivalentWithFrame: (NSRect)cellFrame
|
||||
inView: (NSView *)controlView
|
||||
{
|
||||
NSImage *arrow = [NSImage imageNamed: @"NSMenuArrow"];
|
||||
|
||||
cellFrame = [self keyEquivalentRectForBounds: cellFrame];
|
||||
|
||||
if ([_menuItem hasSubmenu] && [[GSTheme theme] arrowImageForMenuItemCell] != nil)
|
||||
if ([_menuItem hasSubmenu] && arrow != nil)
|
||||
{
|
||||
NSSize size;
|
||||
NSPoint position;
|
||||
|
||||
size = [[[GSTheme theme] arrowImageForMenuItemCell] size];
|
||||
size = [arrow size];
|
||||
position.x = cellFrame.origin.x + cellFrame.size.width - size.width;
|
||||
position.y = MAX(NSMidY(cellFrame) - (size.height/2.), 0.);
|
||||
/*
|
||||
|
@ -672,7 +696,7 @@
|
|||
if ([controlView isFlipped])
|
||||
position.y += size.height;
|
||||
|
||||
[[[GSTheme theme] arrowImageForMenuItemCell] compositeToPoint: position operation: NSCompositeSourceOver];
|
||||
[arrow compositeToPoint: position operation: NSCompositeSourceOver];
|
||||
}
|
||||
/* FIXME/TODO here - decide a consistent policy for images.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue