mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
Add theme drawing for toolbar view.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27806 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2c9b33a1a9
commit
71f807b1c7
4 changed files with 74 additions and 80 deletions
|
@ -1,3 +1,11 @@
|
|||
2009-02-07 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h,
|
||||
* Source/GSTheme.m (-drawToobarRect:frame:borderMask:): New method
|
||||
for toolbar view drawing
|
||||
* Source/GSToolbarView.m (-drawRect:): Use new theme method.
|
||||
Clean up use of colours.
|
||||
|
||||
2009-02-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSThemeTools.m: Add a few checks for tile sizes
|
||||
|
|
|
@ -528,6 +528,13 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
|
|||
- (NSCell*) cellForScrollerKnob: (BOOL)horizontal;
|
||||
- (NSCell*) cellForScrollerKnobSlot: (BOOL)horizontal;
|
||||
- (float) defaultScrollerWidth;
|
||||
|
||||
/** Method for toolbar theming.
|
||||
*/
|
||||
- (void) drawToobarRect: (NSRect)aRect
|
||||
frame: (NSRect)viewFrame
|
||||
borderMask: (unsigned int)borderMask;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,10 +27,13 @@
|
|||
*/
|
||||
|
||||
#import "GSThemePrivate.h"
|
||||
#include "AppKit/NSBezierPath.h"
|
||||
#import "AppKit/NSColorList.h"
|
||||
#import "AppKit/NSGraphics.h"
|
||||
#import "AppKit/NSImage.h"
|
||||
|
||||
#include "GNUstepGUI/GSToolbarView.h"
|
||||
|
||||
|
||||
@implementation GSTheme (Drawing)
|
||||
|
||||
|
@ -394,5 +397,40 @@
|
|||
return 18.0;
|
||||
}
|
||||
|
||||
- (void) drawToobarRect: (NSRect)aRect
|
||||
frame: (NSRect)viewFrame
|
||||
borderMask: (unsigned int)borderMask
|
||||
{
|
||||
// We draw the background
|
||||
[[NSColor toolbarBackgroundColor] set];
|
||||
[NSBezierPath fillRect: aRect];
|
||||
|
||||
// We draw the border
|
||||
[[NSColor toolbarBorderColor] set];
|
||||
if (borderMask & GSToolbarViewBottomBorder)
|
||||
{
|
||||
[NSBezierPath strokeLineFromPoint: NSMakePoint(0, 0.5)
|
||||
toPoint: NSMakePoint(viewFrame.size.width, 0.5)];
|
||||
}
|
||||
if (borderMask & GSToolbarViewTopBorder)
|
||||
{
|
||||
[NSBezierPath strokeLineFromPoint: NSMakePoint(0,
|
||||
viewFrame.size.height - 0.5)
|
||||
toPoint: NSMakePoint(viewFrame.size.width,
|
||||
viewFrame.size.height - 0.5)];
|
||||
}
|
||||
if (borderMask & GSToolbarViewLeftBorder)
|
||||
{
|
||||
[NSBezierPath strokeLineFromPoint: NSMakePoint(0.5, 0)
|
||||
toPoint: NSMakePoint(0.5, viewFrame.size.height)];
|
||||
}
|
||||
if (borderMask & GSToolbarViewRightBorder)
|
||||
{
|
||||
[NSBezierPath strokeLineFromPoint: NSMakePoint(viewFrame.size.width - 0.5,0)
|
||||
toPoint: NSMakePoint(viewFrame.size.width - 0.5,
|
||||
viewFrame.size.height)];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@
|
|||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSEnumerator.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include "AppKit/NSBezierPath.h"
|
||||
#include "AppKit/NSButton.h"
|
||||
#include "AppKit/NSClipView.h"
|
||||
#include "AppKit/NSColor.h"
|
||||
|
@ -48,6 +48,8 @@
|
|||
#include "AppKit/NSToolbarItem.h"
|
||||
#include "AppKit/NSView.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
|
||||
#include "GNUstepGUI/GSTheme.h"
|
||||
#include "GNUstepGUI/GSToolbarView.h"
|
||||
|
||||
#include "NSToolbarFrameworkPrivate.h"
|
||||
|
@ -63,10 +65,6 @@ static const int ClippedItemsViewWidth = 28;
|
|||
// Internal
|
||||
static const int current_version = 1;
|
||||
static NSColorList *SystemExtensionsColors;
|
||||
static NSColor *StandardBackgroundColor;
|
||||
static NSColor *BackgroundColor;
|
||||
static NSColor *BorderColor;
|
||||
|
||||
|
||||
// Toolbar color extensions
|
||||
|
||||
|
@ -77,24 +75,18 @@ static void initSystemExtensionsColors(void)
|
|||
NSDictionary *colors;
|
||||
|
||||
/* Set up a dictionary containing the names of all the system extensions
|
||||
colors as keys and with colors in string format as values. */
|
||||
colours as keys and with colours as values. */
|
||||
toolbarBorderColor = [NSColor colorWithCalibratedRed: 0.5
|
||||
green: 0.5
|
||||
blue: 0.5
|
||||
alpha: 1.0];
|
||||
|
||||
// Window background color by tranparency
|
||||
// Window background color by tranparency
|
||||
toolbarBackgroundColor = [NSColor clearColor];
|
||||
|
||||
// Window backgound color hardcoded
|
||||
/* toolbarBackgroundColor = [NSColor colorWithCalibratedRed: 0.8
|
||||
green: 0.8
|
||||
blue: 0.8
|
||||
alpha: 1.0]; */
|
||||
|
||||
colors = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
toolbarBackgroundColor, @"toolbarBackgroundColor",toolbarBorderColor,
|
||||
@"toolbarBorderColor", nil];
|
||||
toolbarBackgroundColor, @"toolbarBackgroundColor",
|
||||
toolbarBorderColor, @"toolbarBorderColor", nil];
|
||||
|
||||
SystemExtensionsColors = [NSColorList colorListNamed: @"System extensions"];
|
||||
if (SystemExtensionsColors == nil)
|
||||
|
@ -126,20 +118,6 @@ static void initSystemExtensionsColors(void)
|
|||
if (changed)
|
||||
[SystemExtensionsColors writeToFile: nil];
|
||||
}
|
||||
|
||||
|
||||
/* Never released, but that's not a problem because the variables are
|
||||
static and then will be deallocated with the class when the application
|
||||
quits. */
|
||||
StandardBackgroundColor =
|
||||
[NSColor colorWithCalibratedRed: 0.8 green: 0.8 blue: 0.8 alpha: 1.0];
|
||||
RETAIN(StandardBackgroundColor);
|
||||
BackgroundColor =
|
||||
[SystemExtensionsColors colorWithKey: @"toolbarBackgroundColor"];
|
||||
BorderColor =
|
||||
[SystemExtensionsColors colorWithKey: @"toolbarBorderColor"];
|
||||
RETAIN(BackgroundColor);
|
||||
RETAIN(BorderColor);
|
||||
}
|
||||
|
||||
@implementation NSColor (GSToolbarViewAdditions)
|
||||
|
@ -309,6 +287,7 @@ static void initSystemExtensionsColors(void)
|
|||
NSMakeRect(0, 0, frame.size.width,
|
||||
_heightFromLayout)];
|
||||
[_clipView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
|
||||
[_clipView setDrawsBackground: NO];
|
||||
[self addSubview: _clipView];
|
||||
// Adjust the clip view frame
|
||||
[self setBorderMask: GSToolbarViewTopBorder | GSToolbarViewBottomBorder
|
||||
|
@ -436,47 +415,14 @@ static void initSystemExtensionsColors(void)
|
|||
|
||||
- (void) drawRect: (NSRect)aRect
|
||||
{
|
||||
NSRect viewFrame = [self frame];
|
||||
|
||||
// We draw the background
|
||||
if (![BackgroundColor isEqual: [NSColor clearColor]])
|
||||
{
|
||||
[BackgroundColor set];
|
||||
[NSBezierPath fillRect: aRect];
|
||||
}
|
||||
|
||||
// We draw the border
|
||||
[BorderColor set];
|
||||
if (_borderMask & GSToolbarViewBottomBorder)
|
||||
{
|
||||
[NSBezierPath strokeLineFromPoint: NSMakePoint(0, 0.5)
|
||||
toPoint: NSMakePoint(viewFrame.size.width, 0.5)];
|
||||
}
|
||||
if (_borderMask & GSToolbarViewTopBorder)
|
||||
{
|
||||
[NSBezierPath strokeLineFromPoint: NSMakePoint(0,
|
||||
viewFrame.size.height - 0.5)
|
||||
toPoint: NSMakePoint(viewFrame.size.width,
|
||||
viewFrame.size.height - 0.5)];
|
||||
}
|
||||
if (_borderMask & GSToolbarViewLeftBorder)
|
||||
{
|
||||
[NSBezierPath strokeLineFromPoint: NSMakePoint(0.5, 0)
|
||||
toPoint: NSMakePoint(0.5, viewFrame.size.height)];
|
||||
}
|
||||
if (_borderMask & GSToolbarViewRightBorder)
|
||||
{
|
||||
[NSBezierPath strokeLineFromPoint: NSMakePoint(viewFrame.size.width - 0.5,0)
|
||||
toPoint: NSMakePoint(viewFrame.size.width - 0.5,
|
||||
viewFrame.size.height)];
|
||||
}
|
||||
|
||||
[super drawRect: aRect];
|
||||
[[GSTheme theme] drawToobarRect: aRect
|
||||
frame: [self frame]
|
||||
borderMask: _borderMask];
|
||||
}
|
||||
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
if ([BackgroundColor isEqual: [NSColor clearColor]])
|
||||
if ([[NSColor toolbarBackgroundColor] alphaComponent] < 1.0)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
@ -576,11 +522,6 @@ static void initSystemExtensionsColors(void)
|
|||
[self _reload];
|
||||
}
|
||||
|
||||
- (NSColor *) standardBackgroundColor
|
||||
{
|
||||
return StandardBackgroundColor;
|
||||
}
|
||||
|
||||
// Private methods
|
||||
|
||||
- (void) _handleBackViewsFrame
|
||||
|
@ -837,21 +778,21 @@ static void initSystemExtensionsColors(void)
|
|||
|
||||
}
|
||||
|
||||
- (NSColor *) standardBackgroundColor
|
||||
{
|
||||
NSLog(@"Use of deprecated method %@", NSStringFromSelector(_cmd));
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL) _usesStandardBackgroundColor
|
||||
{
|
||||
return [BackgroundColor isEqual: [self standardBackgroundColor]];
|
||||
NSLog(@"Use of deprecated method %@", NSStringFromSelector(_cmd));
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) _setUsesStandardBackgroundColor: (BOOL)standard
|
||||
{
|
||||
if (standard)
|
||||
{
|
||||
ASSIGN(BackgroundColor, [self standardBackgroundColor]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSIGN(BackgroundColor, [NSColor clearColor]);
|
||||
}
|
||||
NSLog(@"Use of deprecated method %@", NSStringFromSelector(_cmd));
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue