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

Use main window theme #16

Open
brmassa opened this issue Feb 12, 2024 · 9 comments
Open

Use main window theme #16

brmassa opened this issue Feb 12, 2024 · 9 comments

Comments

@brmassa
Copy link

brmassa commented Feb 12, 2024

Hello,

started to update my previous code to Avalonia 11 and Unidock.

however, when using a different theme than the white Avalonia, Unidock do not respect it and the result is a mess. Could it respect the app/main windows color scheme?

as a secondary/temporary solution: how to overwrite the default colors?

regards
Bruno Massa

@StefanKoell
Copy link
Collaborator

Can you provide more information on the theme you are using? AFAIK, UniDock templates/theming is based on FluentTheme. If you have a custom theme, you might to use Styles or roll your own ControlThemes in order to make them fit in your UI.

@brmassa
Copy link
Author

brmassa commented Feb 12, 2024

SimpleTheme, default dark colors (variant)

https://docs.avaloniaui.net/docs/basics/user-interface/styling/themes/simple

@cirrusone
Copy link

I agree it would be preferred to have both themes (Simple and Fluent) honour the default brushes to keep look consistent. In the meantime, I used a combination F12 debugger to track elements and these files to find style selectors to override

NP.Ava.Visuals/Themes/TextStyles.axaml
NP.Ava.Visuals/Themes/CustomWindowStyles.axaml
NP.Ava.UniDock/Themes/DockStyles.axaml

This may help with a starting point for theming using <SimpleTheme /> both Light/Dark in App.axaml...

<Application xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:np="https://np.com/visuals"
             x:Class="DataGridAot.App"
             RequestedThemeVariant="Dark">
             <!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

    <Application.Styles>
        <SimpleTheme />

		<StyleInclude Source="avares://NP.Ava.Visuals/Themes/TextStyles.axaml"/>
		<StyleInclude Source="avares://NP.Ava.Visuals/Themes/CustomWindowStyles.axaml"/>
		<StyleInclude Source="avares://NP.Ava.UniDock/Themes/DockStyles.axaml"/>

		<!-- UniDock Styles -->

		<!-- Remove icon from floating window -->
		<Style Selector=":is(np|CustomWindow).PlainFloatingWindow">
			<Setter Property="CustomHeaderIcon" Value="{x:Null}"/>
		</Style>

		<Style Selector="np|TabbedDockGroup">
			<Setter Property="Background" Value="Transparent"/>
		</Style>

		<Style Selector="np|DockItemPresenter">
			<Setter Property="Background" Value="Transparent"/>
		</Style>

		<Style Selector="np|DockTabItem.Dock[IsSelected=False]">
			<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/>
			<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/>
		</Style>

		<Style Selector="np|DockTabItem.Dock[IsSelected=True]">
			<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush}"/>
			<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/>
		</Style>

		<Style Selector="np|DockItemPresenter[IsActive=True]">
			<Setter Property="HeaderBackground" Value="{DynamicResource ThemeAccentBrush}"/>
			<Setter Property="HeaderForeground" Value="{DynamicResource ThemeForegroundBrush}"/>
		</Style>

		<Style Selector="np|DockItemPresenter">
			<Setter Property="HeaderBackground" Value="{DynamicResource ThemeAccentBrush3}"/>
			<Setter Property="HeaderForeground" Value="{DynamicResource ThemeForegroundBrush}"/>
		</Style>

		<Style Selector="np|DockSeparator">
			<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush3}"/>
		</Style>

		<Style Selector="np|TabbedDockGroup[IsFullyActive=True]">
			<Setter Property="TabSeparatorBackground" Value="{DynamicResource ThemeAccentBrush3}"/>
		</Style>

		<!-- UniDock Styles -->

    </Application.Styles>

</Application>

Untitled

@brmassa
Copy link
Author

brmassa commented Feb 12, 2024

@cirrusone , that's what was talking about! It shuold use the default pallete. And when i change the pallet, the dock applies it.

while it's not fixed in the default code, i will use your snippet. It works.

@brmassa
Copy link
Author

brmassa commented Feb 13, 2024

@cirrusone , will these scehem only work on Simple? I'm trying also on Fluent but i only get nulls

@npolyak
Copy link
Owner

npolyak commented Feb 13, 2024

Sorry - too tired now - will take a look on Sunday.

@cirrusone
Copy link

@brmassa - you may need to change the DynamicResource names between FluentTheme and SimpleTheme. See the Avalonia accents for each in source

https://github.com/AvaloniaUI/Avalonia/tree/master/src/Avalonia.Themes.Simple/Accents

https://github.com/AvaloniaUI/Avalonia/tree/master/src/Avalonia.Themes.Fluent/Accents

Also, this project is a good example for switching themes at runtime https://github.com/AvaloniaUI/Citrus.Avalonia

@ramzouza
Copy link

Hey @npolyak any update on this?

@npolyak
Copy link
Owner

npolyak commented Aug 19, 2024

sorry, some colors were hardcoded, but you can take a look DockStyles.axaml file and modify the colors yourself (there are not many places) I have a full time job and also trying to work on Avalonia book, so might not have time at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants