Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theming should be able to define 'accept button' style #227

Closed
optimisme opened this issue Dec 22, 2023 · 4 comments
Closed

Theming should be able to define 'accept button' style #227

optimisme opened this issue Dec 22, 2023 · 4 comments
Labels
enhancement An enhancement to existing functionality

Comments

@optimisme
Copy link

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 (#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)

Screenshot 2023-12-22 at 17 38 56
@gcasa gcasa added the enhancement An enhancement to existing functionality label Dec 22, 2023
@optimisme
Copy link
Author

optimisme commented Dec 22, 2023

As said in bug:
#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

Screenshot 2023-12-23 at 00 48 23 (centered text without the arrow)

@rfm
Copy link
Contributor

rfm commented Dec 23, 2023

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.

@rfm
Copy link
Contributor

rfm commented Dec 23, 2023

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];

@optimisme
Copy link
Author

Looks like [cell setImage: nil]; removes the 'new line' image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to existing functionality
Development

No branches or pull requests

3 participants