Skip to content

Commit

Permalink
NSBox: (re-)implement isOpaque (#254)
Browse files Browse the repository at this point in the history
This (re-)implements logic where a box is marked
as opaque if it is a custom box which is not
transparent, but moves the logic to `GSTheme`,
allowing themes to override this loggic.

This fixes the rendering of custom boxes with a
custom fill color; the current implementation
would mark them as non-opaque and hence the fill
color would not be rendered.

- The original implementation (from 1999) always
  returned `YES`
  (53bcb50)
- A more complete implementation was backported
  from the Testplant branch in 2012
  (e85b16b, by
  @fredkiefer, upstream commit
  36e77b9)
- More recently, the a return value of `NO` was
  hardcoded
  (02bc49e, by
  @ericwa)
  • Loading branch information
qmfrederik authored Apr 4, 2024
1 parent 95f3024 commit 892ed48
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Headers/Additions/GNUstepGUI/GSTheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,8 @@ APPKIT_EXPORT_CLASS
clipRect: (NSRect)clipRect
inView: (NSView *)view;

- (BOOL) isBoxOpaque: (NSBox *)box;

- (void) drawBoxInClipRect: (NSRect)clipRect
boxType: (NSBoxType)boxType
borderType: (NSBorderType)borderType
Expand Down
12 changes: 12 additions & 0 deletions Source/GSThemeDrawing.m
Original file line number Diff line number Diff line change
Expand Up @@ -3475,6 +3475,18 @@ - (void) drawTableViewRow: (NSInteger)rowIndex
}
}

- (BOOL) isBoxOpaque: (NSBox *)box
{
if ([box boxType] == NSBoxCustom)
{
return ![box isTransparent];
}
else
{
return YES;
}
}

- (void) drawBoxInClipRect: (NSRect)clipRect
boxType: (NSBoxType)boxType
borderType: (NSBorderType)borderType
Expand Down
13 changes: 1 addition & 12 deletions Source/NSBox.m
Original file line number Diff line number Diff line change
Expand Up @@ -464,18 +464,7 @@ - (void) drawRect: (NSRect)rect

- (BOOL) isOpaque
{
// FIXME: Depends on theme; if always returning NO is a performance hit
// we can check if GSTheme is going to draw an old-style opaque box
// or not.
return NO;
// if (_box_type == NSBoxCustom)
// {
// return !_transparent;
// }
// else
// {
// return YES;
// }
return [[GSTheme theme] isBoxOpaque: self];
}

- (NSColor*) fillColor
Expand Down

0 comments on commit 892ed48

Please sign in to comment.