-
Notifications
You must be signed in to change notification settings - Fork 635
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
Make styling.slint resources accessable #3687
Comments
Ideally we should find a way to expose the color palette (see also #116 ) Currently, some variable are accessible through the StyleMetrics, but it's undocumented. So yes, we should do something about this. |
I think all resources of a style should be provided not only the |
Yes, of course, it is more than just the Palette. So what we need to do is to find a good interface and export all of that (palette, metrics, typography, ...) And I don't think we want user to write
|
It can make sense, because depending on design guidelines you maybe forced to provide different variants per style, because there are to different in look and feel. An import like this could be difficult: import { Palette } from "std-widgets.slint";
export component MyFancyWidget {
Rectangle {
background: Palette.accent;
}
}
|
Yes, our job here is to find a good set of roles for both palette and typography that are common to all styles.
I agree it also make sense to expose style-specific widgets or globals.. So in other words, i think it is really important to expose the palette and the font in a way common to all style because you can't do cross platform apps without that. (and i think this is what #3685 asks for ) But I also understand the need to have platform-specific (style-specific) things exposed. These are two different things. |
Ok then we have two different use cases here.
import { StyleMetrics } from "std-widgets.slint;
export component MyFancyWidget {
in property <string> text <=> i-text.text;
Rectangle {
background: StyleMetrics.accent;
i-text := Text {
font-size: StyleMetrics.default-font-size;
}
}
}
import { Palette, Typography } from "cupertino-style.slint";
export component MyFancyCupertinoWidget {
in property <string> text <=> i-text.text;
Rectangle {
background: Palette.accent;
i-text := Text {
font-size: Typography.body.font-size;
}
}
} import { Palette, Typography } from "fluent-style.slint";
export component MyFancyCupertinoWidget {
in property <string> text <=> i-text.text;
Rectangle {
background: Palette.accent;
i-text := Text {
font-size: Typography.body.font-size;
}
}
} For the second you case wee will need different imports per style, because the |
Yes, and not just custom widget, but interface in general. |
ProposalThe following solution could be implemented with little effort and would fulfill the requirements of both use cases. The use case to implement custom controls that works with the all styles, what means providing a generic access to the styling resources like brushes but everything that can be generalized between all styles. And the second solution where a user want to create a custom widget that is close as possible to the corresponding design guidelines, what means to give the user access to the complete resources of the corresponding style. ColorScheme
Exampleexport enum ColorScheme {
Dark,
Light,
// Can be expended in the future e.g. with HighContrast
} {StyleName}PaletteEach style would provide its own palette like Exampleexport global CupertinoPalette {
out property <brush> background;
out property <brush> accent;
out property <brush> accent-secondary;
out property <brush> foreground;
out property <brush> border;
out property <brush> surface;
out property <brush> on-surfe;
out property <brush> selection;
out property <brush> focus;
in-out property <ColorScheme> color-scheme;
} {StyleName}TypographySame as {StyleName}Palette but with the typography settings of the styles like font sizes and weights. Palette
Exampleexport global Palette {
out property <brush> background CupertinoPalette.background;
out property <brush> accent: CupertinoPalette.accent;
out property <brush> foreground: CupertinoPalette.foreground;
out property <brush> border: CupertinoPalette.border;
out property <brush> surface: CupertinoPalette.surface;
out property <brush> on-surface: CupertinoPalette.on-surface;
out property <brush> selection: CupertinoPalette.selection ;
out property <brush> focus: CupertinoPalette.focus;
in-out property <ColorScheme> color-scheme <=> CupertinoPalette.color-scheme;
} TypographySame as Palette but with the typography settings of the styles like font sizes and weights. StyleMetrics
Usage exampleimport { Palette, Typography } from "std-widgets.slint";
export component MyFancyWidget {
in property <string> text <=> i-text.text;
Rectangle {
background: Palette.surface;
i-text := Text {
color: Palette.on-surface;
font-size: Typography.default.font-size;
}
}
} import { CupertinoPalette, CupertinoTypography, FluentPalette, FluentTypography } from "std-widgets.slint";
export component MyFancyFluentWidget {
in property <string> text <=> i-text.text;
Rectangle {
background: FluentPalette.surface;
i-text := Text {
color: FluentPalette.on-surface;
font-size: FluentTypography.default.font-size;
}
}
}
export component MyFancyCupertinoWidget {
in property <string> text <=> i-text.text;
Rectangle {
background: CupertinoPalette.surface;
i-text := Text {
color: CupertinoPalette.on-surface;
font-size: CupertinoTypography.default.font-size;
}
}
} Last wordsLater more resources could be provided like spaces, radius, animation settings, ... |
Does that mean that regardless of the currently selected style, I can always Regarding the names: I think That aside, I'm very much in favor of this approach (and its incremental nature). |
Thanks a lot for the concreate proposal. We could offer them from
But anyway, we have here two different issues. And I think we all agree we need a One thing is that Qt allow for different palette for enabled and disabled widgets, and for active and inactive window. For example, we need to have color roles for text selection (background and foreground), and maybe some extra background for button, listview, lineedit and co. |
Yes that was my intention. I used this way because it would already work without providing more import paths. But I saw @ogoffart has also a suggestion.
I have started with |
This way also my first idea to do it with separate imports. I choose the std-widgets way in my proposal because it would work now. But yeah we should provide with dedicated imports. That would make it later also possible to provide more stuff that is specific to a style, maybe a widget that is only available in a specific style. I think the important part is that a user has always the possibility to access that stuff of all styles, so he can also create custom widget libraries that providing widgets that are specific for all styles. So maybe someone wants to create widgets that looks native to macOS and Windows. But with that imports it would be the case 🙂. I like the idea with
Yes it really an important topic. And I think we need to provide in |
I'm also want to take care of that topic and do an proposal PR with all the stuff to which we agree. As soon there is the time to start with that topic ;-). I think it will be really useful. |
Hi, can we change color of specific word in sentence ?? |
That's not supported at the moment. We're tracking this in #2723 |
For each style (expect qt) we have a
styling.slint
file with all styling resources that are relevant for the specific style such as brushes and typography. That works well internal for ourstd-widgets
but it's difficult at the moment to create a custom that is consistent with that style or to create a custom style that is based of on that style. What you can do at the moment is to copy paste thestyling.sling
file in your custom widget library or you have to create your own based on the corresponding design guidelines.But we could make it easier, if we make the resources of
styling.slint
accessible per style through a public api.Example
The text was updated successfully, but these errors were encountered: