* Source/NSBrowser.m: Change NSBR_COLUMN_SEP and NSBR_VOFFSET

macros to static floats. Cache the values in +initialize and
when GSThemeDidActivateNotification is sent, by calling the
new GSTheme methods.
* Source/GSThemeDrawing.m:
* Headers/Additions/GNUstepGUI/GSTheme.h: Add
-browserColumnSeparation and -browserVerticalPadding methods
which access user defaults GSBrowserColumnSeparation and
GSBrowserVerticalPadding. These determine the padding between
browser columns, and the vertical padding between the bottom
scroller, contents, and headers.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37171 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Eric Wasylishen 2013-09-29 19:36:08 +00:00
parent 47145c6c46
commit 8b6fffb7fc
4 changed files with 72 additions and 10 deletions

View file

@ -1,3 +1,17 @@
2013-09-29 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSBrowser.m: Change NSBR_COLUMN_SEP and NSBR_VOFFSET
macros to static floats. Cache the values in +initialize and
when GSThemeDidActivateNotification is sent, by calling the
new GSTheme methods.
* Source/GSThemeDrawing.m:
* Headers/Additions/GNUstepGUI/GSTheme.h: Add
-browserColumnSeparation and -browserVerticalPadding methods
which access user defaults GSBrowserColumnSeparation and
GSBrowserVerticalPadding. These determine the padding between
browser columns, and the vertical padding between the bottom
scroller, contents, and headers.
2013-09-29 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSImage.m: Better protection against representation being nil.

View file

@ -1098,6 +1098,10 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification;
withScrollerRect: (NSRect)scrollerRect
columnSize: (NSSize)columnSize;
- (CGFloat) browserColumnSeparation;
- (CGFloat) browserVerticalPadding;
- (void) drawMenuRect: (NSRect)rect
inView: (NSView *)view
isHorizontal: (BOOL)horizontal

View file

@ -2144,6 +2144,34 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil};
}
}
- (CGFloat) browserColumnSeparation
{
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
if ([defs objectForKey: @"GSBrowserColumnSeparation"] != nil)
{
return [defs floatForKey: @"GSBrowserColumnSeparation"];
}
else
{
return 4;
}
}
- (CGFloat) browserVerticalPadding
{
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
if ([defs objectForKey: @"GSBrowserVerticalPadding"] != nil)
{
return [defs floatForKey: @"GSBrowserVerticalPadding"];
}
else
{
return 2;
}
}
- (void) drawMenuRect: (NSRect)rect
inView: (NSView *)view
isHorizontal: (BOOL)horizontal

View file

@ -39,6 +39,7 @@
#import <Foundation/NSArray.h>
#import <Foundation/NSDebug.h>
#import <Foundation/NSException.h>
#import <Foundation/NSNotification.h>
#import <Foundation/NSUserDefaults.h>
#import "AppKit/NSBrowser.h"
#import "AppKit/NSBrowserCell.h"
@ -61,9 +62,9 @@
/* Cache */
static CGFloat scrollerWidth; // == [NSScroller scrollerWidth]
static NSTextFieldCell *titleCell;
static CGFloat browserColumnSeparation;
static CGFloat browserVerticalPadding;
#define NSBR_COLUMN_SEP 4
#define NSBR_VOFFSET 2
#define NSBR_COLUMN_IS_VISIBLE(i) \
(((i)>=_firstVisibleColumn)&&((i)<=_lastVisibleColumn))
@ -1498,7 +1499,7 @@ static NSTextFieldCell *titleCell;
// Calculate origin
if (_separatesColumns)
{
rect.origin.x = nbColumn * (_columnSize.width + NSBR_COLUMN_SEP);
rect.origin.x = nbColumn * (_columnSize.width + browserColumnSeparation);
}
else
{
@ -1780,7 +1781,7 @@ static NSTextFieldCell *titleCell;
if (_separatesColumns)
{
rect.origin.x += n * NSBR_COLUMN_SEP;
rect.origin.x += n * browserColumnSeparation;
}
else
{
@ -1795,7 +1796,7 @@ static NSTextFieldCell *titleCell;
{
if (_separatesColumns)
rect.origin.y = (scrollerWidth - 1) + (2 * bezelBorderSize.height) +
NSBR_VOFFSET;
browserVerticalPadding;
else
rect.origin.y = scrollerWidth + bezelBorderSize.width;
}
@ -1870,7 +1871,7 @@ static NSTextFieldCell *titleCell;
// Titles (there is no real frames to resize)
if (_isTitled)
{
_columnSize.height -= [self titleHeight] + NSBR_VOFFSET;
_columnSize.height -= [self titleHeight] + browserVerticalPadding;
}
// Horizontal scroller
@ -1884,7 +1885,7 @@ static NSTextFieldCell *titleCell;
if (_separatesColumns)
_columnSize.height -= (scrollerWidth - 1) +
(2 * bezelBorderSize.height) + NSBR_VOFFSET;
(2 * bezelBorderSize.height) + browserVerticalPadding;
else
_columnSize.height -= scrollerWidth + (2 * bezelBorderSize.height);
@ -1906,7 +1907,7 @@ static NSTextFieldCell *titleCell;
CGFloat colWidth = _minColumnWidth + scrollerWidth;
if (_separatesColumns)
colWidth += NSBR_COLUMN_SEP;
colWidth += browserColumnSeparation;
if (_frame.size.width > colWidth)
{
@ -1942,7 +1943,7 @@ static NSTextFieldCell *titleCell;
// Columns
if (_separatesColumns)
frameWidth = _frame.size.width - ((columnCount - 1) * NSBR_COLUMN_SEP);
frameWidth = _frame.size.width - ((columnCount - 1) * browserColumnSeparation);
else
frameWidth = _frame.size.width - ((columnCount - 1) +
(2 * bezelBorderSize.width));
@ -2195,18 +2196,33 @@ static NSTextFieldCell *titleCell;
[self sendAction: _doubleAction to: [self target]];
}
+ (void) _themeDidActivate: (NSNotification*)n
{
GSTheme *theme = [GSTheme theme];
scrollerWidth = [NSScroller scrollerWidth];
browserColumnSeparation = [theme browserColumnSeparation];
browserVerticalPadding = [theme browserVerticalPadding];
}
+ (void) initialize
{
if (self == [NSBrowser class])
{
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(_themeDidActivate:)
name: GSThemeDidActivateNotification
object: nil];
// Initial version
[self setVersion: 1];
scrollerWidth = [NSScroller scrollerWidth];
/* Create the shared titleCell if it hasn't been created already. */
if (!titleCell)
{
titleCell = [GSBrowserTitleCell new];
}
[self _themeDidActivate: nil];
}
}