Comments (3)
Could you please explain a bit what you mean by this requirement that you state here? There already is a method
- (void) drawButton: (NSRect)frame
in: (NSCell*)cell
view: (NSView*)view
style: (int)style
state: (GSThemeControlState)state
On GSTheme and by overriding this method in your own theme you should be able to produce about any fancy button that you can think of. Most likely you don't want to do that but would prefer another method to change the appearance of a button without overriding this method. Is this correct? And if so, what is it that you are expecting?
For your specific case NSRecessedBezelStyle this method is actually missing specific code as we were not aware how such a button should look like. If you have suggestions on how to style this sort of button within the GNUstep default style, I am willing to put such code in. And if you make this new code configurable it might also help with your advanced requirements.
In the current code the colour is only influenced by the state of the button not by the style. You will need convincing arguments to get that changed.
from libs-gui.
The source code of my theme (in development)
https://github.com/optimisme/GNUStep-Theme
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];
Is this the way to color background and text from button cells while doing a theme?
from libs-gui.
Closing the issue, it is possible to style the text in each custom style:
NSMutableParagraphStyle *paragraphStyle;
NSDictionary *attributes;
NSAttributedString *coloredTitle;
NSButtonCell *buttonCell = nil;
if ([cell isKindOfClass:[NSButtonCell class]]) {
buttonCell = (NSButtonCell *) cell;
}
if (buttonCell != nil) {
bezelColor = GVThemeColorRGB(111, 111, 111, 1.0);
paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setAlignment:NSTextAlignmentCenter];
attributes = @{
NSForegroundColorAttributeName: bezelColor,
NSParagraphStyleAttributeName: paragraphStyle,
};
coloredTitle = [[NSAttributedString alloc] initWithString:[cell title] attributes:attributes];
[buttonCell setAttributedTitle:coloredTitle];
}
from libs-gui.
Related Issues (20)
- theming does not allow to define the text color of the overed menu item HOT 2
- theming does not allow to define border radius of menu popover HOT 1
- NSCircularBezelStyle should cut text HOT 5
- NSRoundedDisclosure ... not reporting an appropiate state HOT 1
- Theming should be able to define 'accept button' style HOT 4
- NSBezierPath does not clip gradients HOT 6
- Support NIBArchive format HOT 3
- CTButtonTypeSwitch does not show mixed state
- Segmentation Fault with autohidesScrollers = YES HOT 5
- Images disappear after Display Resolution Change HOT 2
- hasHorizontalScroller = NO; ignored if autohidesScrollers = YES; HOT 2
- Allow multiple selection on NSSegmentedControl
- Wrong size for NSSegmentedControl sizeToFit
- Add setBezelColor for NSButton
- NSTextView can cause a crash if its delegate has been deallocated earlier HOT 4
- bitmap format big & little endian in image representations HOT 3
- NSToolbar is off by default in GNUstep and on by default on macOS
- Refactor NSStoryboard loading...
- Changes to NSMenuItem breaks nib loading... HOT 20
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libs-gui.