diff --git a/ChangeLog b/ChangeLog index 66fbbf958..5742e043c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2013-09-29 Eric Wasylishen + + * Headers/Additions/GNUstepGUI/GSTheme.h: + * Source/NSScrollView.m: + * Source/GSThemeDrawing.m: + * Source/GSTheme.m: Add GSScrollViewUseBottomCorner default, + which themes can set to NO to leave a square gap in the bottom- + left (or bottom-right) corner where the horizontal and vertical + scrollers meet. + 2013-09-29 Eric Wasylishen * Source/NSBrowser.m: Fix some position calculations from the last diff --git a/Headers/Additions/GNUstepGUI/GSTheme.h b/Headers/Additions/GNUstepGUI/GSTheme.h index 09c97e62a..d00650f01 100644 --- a/Headers/Additions/GNUstepGUI/GSTheme.h +++ b/Headers/Additions/GNUstepGUI/GSTheme.h @@ -264,6 +264,9 @@ APPKIT_EXPORT NSString *GSScrollerUpArrow; APPKIT_EXPORT NSString *GSScrollerVerticalKnob; APPKIT_EXPORT NSString *GSScrollerVerticalSlot; +/* Scroll view parts */ +APPKIT_EXPORT NSString *GSScrollViewBottomCorner; + /* Names for table view parts */ APPKIT_EXPORT NSString *GSTableHeader; APPKIT_EXPORT NSString *GSTableCorner; @@ -838,6 +841,8 @@ APPKIT_EXPORT NSString *GSThemeWillDeactivateNotification; */ - (float) defaultScrollerWidth; +- (BOOL) scrolViewUseBottomCorner; + /** * Method for toolbar theming. */ diff --git a/Source/GSTheme.m b/Source/GSTheme.m index 093304860..c7cb07dea 100644 --- a/Source/GSTheme.m +++ b/Source/GSTheme.m @@ -77,6 +77,9 @@ NSString *GSScrollerUpArrow = @"GSScrollerUpArrow"; NSString *GSScrollerVerticalKnob = @"GSScrollerVerticalKnob"; NSString *GSScrollerVerticalSlot = @"GSScrollerVerticalSlot"; +// Scroll view parts +NSString *GSScrollViewBottomCorner = @"GSScrollViewBottomCorner"; + // Table view part names NSString *GSTableHeader = @"GSTableHeader"; NSString *GSTableCorner = @"GSTableCorner"; diff --git a/Source/GSThemeDrawing.m b/Source/GSThemeDrawing.m index 3e768ac5e..17fc413c1 100644 --- a/Source/GSThemeDrawing.m +++ b/Source/GSThemeDrawing.m @@ -545,6 +545,16 @@ return defaultScrollerWidth; } +- (BOOL) scrolViewUseBottomCorner +{ + NSUserDefaults *defs = [NSUserDefaults standardUserDefaults]; + if ([defs objectForKey: @"GSScrollViewUseBottomCorner"] != nil) + { + return [defs boolForKey: @"GSScrollViewUseBottomCorner"]; + } + return YES; +} + - (NSColor *) toolbarBackgroundColor { NSColor *color; @@ -2311,6 +2321,26 @@ static NSDictionary *titleTextAttributes[3] = {nil, nil, nil}; DPSstroke(ctxt); } } + + if (![self scrolViewUseBottomCorner] + && [scrollView hasHorizontalScroller] + && [scrollView hasVerticalScroller]) + { + NSScroller *vertScroller = [scrollView verticalScroller]; + NSScroller *horizScroller = [scrollView horizontalScroller]; + + NSRect bottomCornerRect = NSMakeRect([vertScroller frame].origin.x, + [horizScroller frame].origin.y, + NSWidth([vertScroller frame]), + NSHeight([horizScroller frame])); + + GSDrawTiles *tiles = [self tilesNamed: GSScrollViewBottomCorner + state: GSThemeNormalState]; + + [self fillRect: bottomCornerRect + withTiles: tiles + background: [NSColor clearColor]]; + } } - (void) drawBarInside: (NSRect)rect diff --git a/Source/NSScrollView.m b/Source/NSScrollView.m index 1cbf6b2a3..2e08d99d7 100644 --- a/Source/NSScrollView.m +++ b/Source/NSScrollView.m @@ -1075,6 +1075,8 @@ static CGFloat scrollerWidth; CGFloat innerBorderWidth = [[NSUserDefaults standardUserDefaults] boolForKey: @"GSScrollViewNoInnerBorder"] ? 0.0 : 1.0; + BOOL useBottomCorner = [[GSTheme theme] scrolViewUseBottomCorner]; + style = NSInterfaceStyleForKey(@"NSScrollViewInterfaceStyle", nil); if (style == NSMacintoshInterfaceStyle @@ -1140,6 +1142,15 @@ static CGFloat scrollerWidth; NSDivideRect (contentRect, &vertScrollerRect, &contentRect, scrollerWidth, verticalScrollerEdge); + /* If the theme requests it, leave a square gap in the bottom- + * left (or bottom-right) corner where the horizontal and vertical + * scrollers meet. */ + if (_hasHorizScroller && !useBottomCorner) + { + NSDivideRect (vertScrollerRect, NULL, &vertScrollerRect, + scrollerWidth, bottomEdge); + } + [_vertScroller setFrame: vertScrollerRect]; /* Substract 1 for the line that separates the vertical scroller @@ -1288,7 +1299,12 @@ static CGFloat scrollerWidth; - (BOOL) isOpaque { - return [_contentView isOpaque]; + // FIXME: Only needs to be NO in a corner case, + // when [[GSTheme theme] scrolViewUseBottomCorner] is NO + // and the theme tile for the bottom corner is transparent. + // So maybe cache the value of + // [[GSTheme theme] scrolViewUseBottomCorner] and check it here. + return NO; } - (NSBorderType) borderType