mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 08:30:59 +00:00
* Source/GSTheme.m:
* Source/GSTitleView.m: * Source/GSThemeDrawing.m: * Headers/Additions/GNUstepGUI/GSTheme.h: Add GSMenuTitleBackground theme tile for themeing the background of GSTitleView. NOTE: I removed some code that was in -[GSTitleView drawRect:] for drawing with a different style when the GSTitleView is NOT owned by an NSMenu, but by an NSWindow/NSPanel (_ownedByMenu == NO). If needed, this can be added back, but it doesn't appear to ever be used in gnustep-gui - GSTitleView is only created in one place, with NSMenu as the owner. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37165 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ef5f2cf19f
commit
2fe4c2e708
5 changed files with 80 additions and 59 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2013-09-28 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/GSTheme.m:
|
||||
* Source/GSTitleView.m:
|
||||
* Source/GSThemeDrawing.m:
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h: Add GSMenuTitleBackground
|
||||
theme tile for themeing the background of GSTitleView.
|
||||
|
||||
NOTE: I removed some code that was in -[GSTitleView drawRect:] for
|
||||
drawing with a different style when the GSTitleView is NOT owned
|
||||
by an NSMenu, but by an NSWindow/NSPanel (_ownedByMenu == NO).
|
||||
If needed, this can be added back, but it doesn't appear to ever
|
||||
be used in gnustep-gui - GSTitleView is only created in one place,
|
||||
with NSMenu as the owner.
|
||||
|
||||
2013-09-28 Eric Wasylishen <ewasylishen@gmail.com>
|
||||
|
||||
* Source/NSCell.m (-highlight:withFrame:inView:):
|
||||
|
|
|
@ -243,6 +243,7 @@
|
|||
@class NSTableHeaderCell;
|
||||
@class NSTabViewItem;
|
||||
@class GSDrawTiles;
|
||||
@class GSTitleView;
|
||||
|
||||
APPKIT_EXPORT NSString *GSSwitch;
|
||||
APPKIT_EXPORT NSString *GSRadio;
|
||||
|
@ -277,6 +278,7 @@ APPKIT_EXPORT NSString *GSBrowserHeader;
|
|||
*/
|
||||
APPKIT_EXPORT NSString *GSMenuHorizontalBackground;
|
||||
APPKIT_EXPORT NSString *GSMenuVerticalBackground;
|
||||
APPKIT_EXPORT NSString *GSMenuTitleBackground;
|
||||
APPKIT_EXPORT NSString *GSMenuHorizontalItem;
|
||||
APPKIT_EXPORT NSString *GSMenuVerticalItem;
|
||||
APPKIT_EXPORT NSString *GSMenuSeparatorItem;
|
||||
|
@ -1037,6 +1039,10 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
*/
|
||||
- (Class) titleViewClassForMenuView: (NSMenuView *)aMenuView;
|
||||
|
||||
- (NSRect) drawMenuTitleBackground: (GSTitleView *)aTitleView
|
||||
withBounds: (NSRect)bounds
|
||||
withClip: (NSRect)clipRect;
|
||||
|
||||
// NSColorWell drawing method
|
||||
- (NSRect) drawColorWellBorder: (NSColorWell*)well
|
||||
withBounds: (NSRect)bounds
|
||||
|
|
|
@ -87,6 +87,7 @@ NSString *GSBrowserHeader = @"GSBrowserHeader";
|
|||
// Menu part names
|
||||
NSString *GSMenuHorizontalBackground = @"GSMenuHorizontalBackground";
|
||||
NSString *GSMenuVerticalBackground = @"GSMenuVerticalBackground";
|
||||
NSString *GSMenuTitleBackground = @"GSMenuTitleBackground";
|
||||
NSString *GSMenuHorizontalItem = @"GSMenuHorizontalItem";
|
||||
NSString *GSMenuVerticalItem = @"GSMenuVerticalItem";
|
||||
NSString *GSMenuSeparatorItem = @"GSMenuSeparatorItem";
|
||||
|
|
|
@ -1057,6 +1057,58 @@
|
|||
return [GSTitleView class];
|
||||
}
|
||||
|
||||
- (NSRect) drawMenuTitleBackground: (GSTitleView *)aTitleView
|
||||
withBounds: (NSRect)bounds
|
||||
withClip: (NSRect)clipRect
|
||||
{
|
||||
GSDrawTiles *tiles = [self tilesNamed: GSMenuTitleBackground state: GSThemeNormalState];
|
||||
|
||||
if (tiles == nil)
|
||||
{
|
||||
NSRect workRect = bounds;
|
||||
NSRectEdge top_left[] = {NSMinXEdge, NSMaxYEdge};
|
||||
CGFloat darkGrays[] = {NSDarkGray, NSDarkGray};
|
||||
NSColor *titleColor;
|
||||
|
||||
titleColor = [self colorNamed: @"GSMenuBar" state: GSThemeNormalState];
|
||||
if (titleColor == nil)
|
||||
{
|
||||
titleColor = [NSColor blackColor];
|
||||
}
|
||||
|
||||
// Draw the dark gray upper left lines for menu and black for others.
|
||||
// Rectangle 1
|
||||
workRect = NSDrawTiledRects(workRect, workRect, top_left, darkGrays, 2);
|
||||
|
||||
// Rectangle 2
|
||||
// Draw the title box's button.
|
||||
[self drawButton: workRect withClip: workRect];
|
||||
|
||||
// Overdraw white top and left lines with light gray lines for window title
|
||||
workRect.origin.y += 1;
|
||||
workRect.size.height -= 1;
|
||||
workRect.size.width -= 1;
|
||||
|
||||
// Rectangle 3
|
||||
// Paint background
|
||||
workRect.origin.x += 1;
|
||||
workRect.origin.y += 1;
|
||||
workRect.size.height -= 2;
|
||||
workRect.size.width -= 2;
|
||||
|
||||
[titleColor set];
|
||||
NSRectFill(workRect);
|
||||
|
||||
return workRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
return [self fillRect: bounds
|
||||
withTiles: tiles
|
||||
background: [NSColor clearColor]];
|
||||
}
|
||||
}
|
||||
|
||||
// NSColorWell drawing method
|
||||
- (NSRect) drawColorWellBorder: (NSColorWell*)well
|
||||
withBounds: (NSRect)bounds
|
||||
|
|
|
@ -206,66 +206,13 @@
|
|||
|
||||
- (void) drawRect: (NSRect)rect
|
||||
{
|
||||
GSTheme *theme = [GSTheme theme];
|
||||
NSRect workRect = [self bounds];
|
||||
NSSize titleSize;
|
||||
NSRectEdge top_left[] = {NSMinXEdge, NSMaxYEdge};
|
||||
NSRectEdge bottom_right[] = {NSMaxXEdge, NSMinYEdge};
|
||||
CGFloat blacks[] = {NSBlack, NSBlack};
|
||||
CGFloat grays[] = {NSLightGray, NSLightGray};
|
||||
CGFloat darkGrays[] = {NSDarkGray, NSDarkGray};
|
||||
|
||||
// Draw the dark gray upper left lines for menu and black for others.
|
||||
// Rectangle 1
|
||||
if (_ownedByMenu)
|
||||
workRect = NSDrawTiledRects(workRect, workRect, top_left, darkGrays, 2);
|
||||
else
|
||||
workRect = NSDrawTiledRects(workRect, workRect, top_left, blacks, 2);
|
||||
|
||||
|
||||
// Rectangle 2
|
||||
// Draw the title box's button.
|
||||
[theme drawButton: workRect withClip: workRect];
|
||||
|
||||
// Overdraw white top and left lines with light gray lines for window title
|
||||
workRect.origin.y += 1;
|
||||
workRect.size.height -= 1;
|
||||
workRect.size.width -= 1;
|
||||
if (!_ownedByMenu && (_isKeyWindow || _isMainWindow))
|
||||
{
|
||||
NSDrawTiledRects(workRect, workRect, top_left, grays, 2);
|
||||
}
|
||||
|
||||
// Rectangle 3
|
||||
// Paint background
|
||||
workRect.origin.x += 1;
|
||||
workRect.origin.y += 1;
|
||||
workRect.size.height -= 2;
|
||||
workRect.size.width -= 2;
|
||||
|
||||
[titleColor set];
|
||||
NSRectFill(workRect);
|
||||
|
||||
if (!_ownedByMenu && _isMainWindow && !_isKeyWindow)
|
||||
{
|
||||
NSRect blRect = workRect;
|
||||
|
||||
blRect.origin.y -= 1;
|
||||
blRect.size.width += 1;
|
||||
blRect.size.height += 1;
|
||||
NSDrawTiledRects(blRect, blRect, bottom_right, blacks, 2);
|
||||
}
|
||||
|
||||
NSRect workRect = [[GSTheme theme] drawMenuTitleBackground: self
|
||||
withBounds: [self bounds]
|
||||
withClip: rect];
|
||||
// Draw the title
|
||||
titleSize = [self titleSize];
|
||||
if (_ownedByMenu)
|
||||
{
|
||||
workRect.origin.x += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
workRect.origin.x += NSMidX (workRect) - titleSize.width / 2;
|
||||
}
|
||||
NSSize titleSize = [self titleSize];
|
||||
workRect.origin.x += 4;
|
||||
|
||||
workRect.origin.y = NSMidY (workRect) - titleSize.height / 2;
|
||||
workRect.size.height = titleSize.height;
|
||||
[[_owner title] drawInRect: workRect withAttributes: textAttributes];
|
||||
|
|
Loading…
Reference in a new issue