Closed optimisme closed 11 months ago
As said in bug: https://github.com/gnustep/libs-gui/issues/225
I've seen that I can change the text color this way:
if ([cell isKindOfClass:[NSButtonCell class]]) {
NSButtonCell *buttonCell = (NSButtonCell *) cell;
NSString *keyEquivalent = [buttonCell keyEquivalent];
if ([keyEquivalent isEqualToString:@"\r"]) {
NSDictionary *attributes = @{NSForegroundColorAttributeName: [NSColor whiteColor]};
NSAttributedString *coloredTitle = [[NSAttributedString alloc] initWithString:[cell title] attributes:attributes];
[buttonCell setAttributedTitle:coloredTitle];
backgroundColor = GVThemeColorRGB(0, 122, 255, 1.0);
}
}
[backgroundColor set];
[bezelPath fill];
[bezelColor setStroke];
[bezelPath setLineWidth:1.0];
[bezelPath stroke];
If this is the way of changing background and text color from a button cell, theming needs a way remove the 'return arrow' for 'accept buttons'.
The image on the left is from GNUStep and the image on the right is the expected theme configuration
(centered text without the arrow)
prevent drawing the line jump symbol
I can see at least two ways of doing this, depending on exactly what it is you want.
To change the image everywhere, you just provide a replacement for the default image in your theme; in this case a transparent image may do what you want.
To change behavior in a specific place (eg for just one control rather than throughput the gui) would require implementing -drawButton:in:view:style:state: so that it would set a nil image if it was called to draw that specific control, and would then call the superclass implementation to do all the normal drawing.
set a nil image NB. a well behaved theme should not simply alter the controls being drawn, but should alter them, perform the drawing, and then restore them to the way they were before the drawing was done. That way, if the user decides to change the theme of a running application, the old theme won't interfere with the functioning of the new one. So the actual code should be more on the lines of:
NSImage *originalImage = AUTORELEASE(RETAIN([cell image])); [cell setImage: imageForThisTheme]; // perform drawing [cell setImage: originalImage];
Looks like [cell setImage: nil]; removes the 'new line' image.
Theming should be able to define 'accept button' style
Like in the picture, theming should be able to define the text color, prevent drawing the line jump symbol and prevent the text movement when clicked (https://github.com/gnustep/libs-gui/issues/219)
Image on the left is GNUStep (background color is not an issue), Right image is the desired themable look and feel (white text, without the line jump, without the text movement)