Access to theme colors in custom styling logic #26
wolframhaussig
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My usecase
I have an application with a
StylableDataGridView
where I use theRowPrePaint
event to update the backcolor of each row based on the value in a specific column. My problem is: theStylableDataGridView_RowPrePaint
implementation can get as far asThemeRegistryHolder.ThemeRegistry.Current
to get the theme but it has no access to the colors used.Workarounds
var color = ThemeRegistryHolder.ThemeRegistry.Current.Capabilities.HasFlag(ThemeCapabilities.DarkMode) ? Color.DarkGrey : Color.Grey
, but this does only work for the default themes - when the colors change this would look weird.IThemePlugin
: this works, as we get access to the colors in theApply
method by accessing theAbstractTheme
but it would require the reimplementation of the completeStylableDataGridView
styling logic.AbstractTheme
: We could call the parentApply
method to get the defaultStylableDataGridView
styling and then apply custom styling. The downside is that we would need to do that for each theme that should be supported and it would break when a non-customized theme would be used.The question
Basically, my question is: How can we provide access to the colors of a theme to custom code? The current implementation only provides access to colors for:
Every other caller only has access to the
ITheme
interface which only supports applying it to forms and controls (we do not want to mention casting it to anAbstractTheme
here to access the colors).Possible Solutions
Currently, I am thinking of separating colors from themes (as I already mentioned in #9):
AbstractTheme
toDefaultTheme
and make it non-abstractFileTheme
would be restructured to not be a theme but only a holder for the given colors and would be renamed toThemeDesign
ThemeDesign
could support easy configuration by configuring the main colors only while the other colors woulds be calculated form there(like we do inDefaultLightTheme
for example)ResourceThemeLookup
andFileThemeLookup
would not create aFileTheme
, but aDefaultTheme
with theThemeDesign
loaded from the given resourceITheme
interface would get a property for reading the assignedThemeDesign
object which I could use in my usecase above to do custom styling/cc @Nockiro
Beta Was this translation helpful? Give feedback.
All reactions