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

Add new setting for theme selection #637

Merged
merged 4 commits into from Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -249,12 +249,15 @@
<DataTrigger Binding="{Binding Owner.IsLoaded, Mode=OneWay}" Value="{sd:False}">
<Setter Property="Foreground" Value="{StaticResource UnloadedColor}"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type sd:TreeViewItem}}, Mode=OneWay}" Value="True">
<Setter Property="Foreground" Value="{StaticResource SelectedTextBrush}"/>
</DataTrigger>
</Style.Triggers>
</Style>
<!-- Loading style -->
<Style x:Key="LoadingStyle" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}" d:DataContext="{d:DesignInstance ehvm:EntityHierarchyElementViewModel}">
<Setter Property="Margin" Value="4,0"/>
<Setter Property="Foreground" Value="#FF00FF70" />
<Setter Property="Foreground" Value="{StaticResource LoadingAssetMessageFromBrush}" />
<Setter Property="Text" Value="{sd:Localize Loading...}" />
<Setter Property="Visibility" Value="{Binding IsLoading, Mode=OneWay, Converter={sd:VisibleOrCollapsed}}" />
<Style.Triggers>
Expand All @@ -264,7 +267,8 @@
<EventTrigger RoutedEvent="TextBlock.Loaded">
<BeginStoryboard>
<Storyboard>
<ColorAnimation From="#FF00FF70" To="White" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" BeginTime="0:0:0.3" Duration="0:0:0.2" AutoReverse="True" RepeatBehavior="Forever"/>
<ColorAnimation From="{StaticResource LoadingAssetMessageFromColor}" To="{StaticResource LoadingAssetMessageToColor}"
Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" BeginTime="0:0:0.3" Duration="0:0:0.2" AutoReverse="True" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
Expand Down Expand Up @@ -746,12 +750,13 @@
ToolTip="{sd:Localize Show or hide selection mask, Context=ToolTip}" sd:ToolTipHelper.Status="{Binding Session.Editor.Status}" ToolTipService.ShowOnDisabled="True" />
<Separator Background="{StaticResource ToggleButtonNormalBackground}"/>
<TextBlock Text="{sd:Localize Loading assets...}" Visibility="{Binding CompilingAssets, Converter={sd:VisibleOrCollapsed}}"
VerticalAlignment="Center" FontWeight="Bold" Foreground="#FF00FF70">
VerticalAlignment="Center" FontWeight="Bold" Foreground="{StaticResource LoadingAssetMessageFromBrush}">
<TextBlock.Triggers>
<EventTrigger RoutedEvent="TextBlock.Loaded">
<BeginStoryboard>
<Storyboard>
<ColorAnimation From="#FF00FF70" To="White" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" BeginTime="0:0:0.3" Duration="0:0:0.2" AutoReverse="True" RepeatBehavior="Forever"/>
<ColorAnimation From="{StaticResource LoadingAssetMessageFromColor}" To="{StaticResource LoadingAssetMessageToColor}"
Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" BeginTime="0:0:0.3" Duration="0:0:0.2" AutoReverse="True" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
Expand Down
Expand Up @@ -22,7 +22,7 @@
<Style TargetType="sd:EditableContentListBox" BasedOn="{StaticResource {x:Type ListBox}}"/>

<DataTemplate DataType="{x:Type vm:SharedRendererOutputSlotViewModel}">
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding Name}" Foreground="{StaticResource GraphicsCompositorNodeTextBrush}"/>
</DataTemplate>

<Style x:Key="AddRenderFeatureComboBox" BasedOn="{StaticResource AddItemComboBox}" TargetType="ComboBox">
Expand Down Expand Up @@ -70,7 +70,7 @@
</Grid.RowDefinitions>

<Border Grid.Row="0" x:Name="PART_vertexTitle" Background="{TemplateBinding TitleBackground}" BorderBrush="{TemplateBinding TitleBorderBrush}" CornerRadius="{TemplateBinding TitleBorderCornerRadius}" Padding="{TemplateBinding TitlePadding}">
<TextBlock x:Name="PART_vertexName" Text="{Binding Block.Title}" HorizontalAlignment="Center" FontWeight="Bold" Padding="10,0,10,0" />
<TextBlock x:Name="PART_vertexName" Text="{Binding Block.Title}" HorizontalAlignment="Center" Foreground="{StaticResource GraphicsCompositorNodeTextBrush}" FontWeight="Bold" Padding="10,0,10,0" />
</Border>

<Border Grid.Row="1" x:Name="PART_vertexContent" Background="{TemplateBinding ContentBackground}" BorderBrush="{TemplateBinding ContentBorderBrush}" CornerRadius="{TemplateBinding ContentBorderCornerRadius}" Padding="{TemplateBinding ContentPadding}">
Expand Down
Expand Up @@ -48,8 +48,6 @@
</Setter>
</Style>

<SolidColorBrush x:Key="CodeEditorBackgroundBrush" Color="#FF1E1E1E" />

<HierarchicalDataTemplate DataType="{x:Type codeFixes:CodeFixCollection}" ItemsSource="{Binding Fixes, Mode=OneTime}">
<TextBlock Text="{Binding Provider, Mode=OneTime}" />
</HierarchicalDataTemplate>
Expand Down Expand Up @@ -201,25 +199,25 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border Name="Bd"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="true">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<!-- Simplified triggers:
we don't want a gray selection background when the ListBox doesn't have focus
-->
we don't want a gray selection background when the ListBox doesn't have focus
-->
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background"
Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Expand All @@ -246,9 +244,9 @@
<Setter TargetName="PART_ListBox" Property="Template">
<Setter.Value>
<ControlTemplate>
<Border CornerRadius="2"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Border CornerRadius="2"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ListBoxItem Style="{StaticResource CompletionListBoxItem}">
<TextBlock Text="{sd:Localize No suggestions}"/>
</ListBoxItem>
Expand Down
Expand Up @@ -10,6 +10,7 @@
using RoslynPad.Roslyn.BraceMatching;
using RoslynPad.Roslyn.Diagnostics;
using RoslynPad.Roslyn.QuickInfo;
using Stride.Core.Presentation.Themes;

namespace Stride.Assets.Presentation.AssetEditors.ScriptEditor
{
Expand Down Expand Up @@ -70,7 +71,7 @@ public void BindSourceTextContainer(RoslynWorkspace workspace, AvalonEditTextCon
TextArea.Caret.PositionChanged += CaretOnPositionChanged;

// Syntax highlighting
var classificationHighlightColors = new ClassificationHighlightColorsDark();
var classificationHighlightColors = ThemeController.CurrentTheme.GetThemeBase() == IconThemeSelector.ThemeBase.Dark ? new ClassificationHighlightColorsDark() : new ClassificationHighlightColors();
syntaxHighlightingColorizer = new RoslynHighlightingColorizer(documentId, workspace.Host, classificationHighlightColors);
TextArea.TextView.LineTransformers.Insert(0, syntaxHighlightingColorizer);

Expand Down
Expand Up @@ -212,7 +212,7 @@
<Slider.Template>
<ControlTemplate TargetType="{x:Type Slider}">
<Grid x:Name="GridRoot" Focusable="False" MinHeight="{TemplateBinding MinHeight}">
<Border Margin="0" x:Name="Border" Height="4" CornerRadius="2" Background="{DynamicResource LightBrush}" BorderBrush="{DynamicResource NormalBorderBrush}" BorderThickness="1,1,1,1" />
<Border Margin="0" x:Name="Border" Height="4" CornerRadius="2" Background="{DynamicResource DropdownButtonBackgroundBrush}" BorderBrush="{DynamicResource NormalBorderBrush}" BorderThickness="1,1,1,1" />
<Track x:Name="PART_Track">
<Track.Thumb>
<Thumb Style="{DynamicResource NuclearSliderThumb}" Foreground="{x:Null}" Width="12" Height="{TemplateBinding ActualHeight}"/>
Expand Down
Expand Up @@ -28,7 +28,7 @@
Command="{Binding SkeletonNodePreserveAll}" CommandParameter="{sd:False}"/>
</UniformGrid>
<!-- Difference from HeaderReadOnlyProperty ends here -->
<ToggleButton DockPanel.Dock="Left" Template="{StaticResource DarkExpanderToggleButton}" Width="16" Height="16"
<ToggleButton DockPanel.Dock="Left" Template="{StaticResource TreeExpanderToggleButton}" Width="16" Height="16"
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType=sd:PropertyViewItem}}"
Visibility="{Binding VisibleChildrenCount, Converter={sd:Chained {sd:NumericToBool}, {sd:VisibleOrCollapsed}}}"/>
<StackPanel Orientation="Horizontal" Margin="8,0,0,0">
Expand Down
Expand Up @@ -124,10 +124,13 @@ static EditorSettings()
public static void Initialize()
{
profile = SettingsContainer.LoadSettingsProfile(EditorPath.EditorConfigPath, true) ?? SettingsContainer.CreateSettingsProfile(true);
Presentation.Themes.ThemesSettings.Initialize();

// Settings that requires a restart must register here:
UseEffectCompilerServer.ChangesValidated += (s, e) => NeedRestart = true;
Language.ChangesValidated += (s, e) => NeedRestart = true;

Presentation.Themes.ThemesSettings.ThemeName.ChangesValidated += (s, e) => NeedRestart = true;
}

public static void Save()
Expand Down
@@ -0,0 +1,29 @@
// Copyright (c) Stride contributors (https://stride3d.net)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using Stride.Core.Assets.Editor.Settings;
using Stride.Core.Settings;
using Stride.Core.Translation;

namespace Stride.Core.Presentation.Themes
{
public static class ThemesSettings
{
// Categories
public static readonly string Themes = Tr._p("Settings", "Themes");

static ThemesSettings()
{
ThemeName = new SettingsKey<ThemeType>("Themes/ThemeName", EditorSettings.SettingsContainer, ThemeType.ExpressionDark)
{
DisplayName = $"{Themes}/{Tr._p("Settings", "Theme Name")}"
};
}

public static SettingsKey<ThemeType> ThemeName { get; }

public static void Initialize()
{
ThemeController.CurrentTheme = ThemeName.GetValue();
}
}
}
Expand Up @@ -20,7 +20,7 @@

<ResourceDictionary.MergedDictionaries>

<ResourceDictionary Source="pack://application:,,,/Stride.Core.Presentation;component/Themes/ExpressionDark/Theme.xaml"/>
<ResourceDictionary Source="pack://application:,,,/Stride.Core.Presentation;component/Themes/ThemeSelector.xaml"/>

<!-- Include the view independant, color-scheme independant, theme resources -->
<ResourceDictionary Source="Resources/ExpressionDark.normalcolor.Resources.xaml" />
Expand Down
12 changes: 12 additions & 0 deletions sources/editor/Stride.Core.Assets.Editor/Themes/ThemeSelector.xaml
@@ -0,0 +1,12 @@
<!--
// ExpressionDark is the default/fallback theme.
// When adding a new theme, ensure all themes:ThemeResourceDictionary in every *.xaml files
// are updated to ensure the theme is correctly applied.
-->
<themes:ThemeResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:themes="clr-namespace:Stride.Core.Presentation.Themes;assembly=Stride.Core.Presentation"
Source="ExpressionDark/TableflowView.ExpressionDark.normalcolor.xaml"
ExpressionDarkSource="ExpressionDark/TableflowView.ExpressionDark.normalcolor.xaml"
DarkSteelSource="ExpressionDark/TableflowView.ExpressionDark.normalcolor.xaml"
LightSteelBlueSource="ExpressionDark/TableflowView.ExpressionDark.normalcolor.xaml">
</themes:ThemeResourceDictionary>
Expand Up @@ -6,7 +6,7 @@
xmlns:diagnostics="clr-namespace:Stride.Core.Assets.Diagnostics;assembly=Stride.Core.Assets">

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Stride.Core.Presentation;component/Themes/ExpressionDark/Theme.xaml"/>
<ResourceDictionary Source="/Stride.Core.Presentation;component/Themes/ThemeSelector.xaml" />
<ResourceDictionary Source="/Stride.Core.Assets.Editor;component/View/CommonResources.xaml" />
</ResourceDictionary.MergedDictionaries>

Expand Down
Expand Up @@ -9,9 +9,9 @@
mc:Ignorable="d">

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Stride.Core.Presentation;component/Themes/ExpressionDark/Theme.xaml"/>
<ResourceDictionary Source="ImageDictionary.xaml"/>
<ResourceDictionary Source="../Themes/ExpressionDark/TableflowView.ExpressionDark.normalcolor.xaml"/>
<ResourceDictionary Source="/Stride.Core.Presentation;component/Themes/ThemeSelector.xaml" />
<ResourceDictionary Source="ImageDictionary.xaml" />
<ResourceDictionary Source="../Themes/ThemeSelector.xaml" />
</ResourceDictionary.MergedDictionaries>

<Style TargetType="view:DataGridEx">
Expand Down
Expand Up @@ -9,7 +9,7 @@
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Stride.Core.Presentation;component/Themes/ExpressionDark/Theme.xaml"/>
<ResourceDictionary Source="/Stride.Core.Presentation;component/Themes/ThemeSelector.xaml"/>
<ResourceDictionary Source="../ImageDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Expand Down
Expand Up @@ -197,7 +197,7 @@
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ToggleButton Grid.Column="1" Template="{StaticResource DarkExpanderToggleButton}" Width="12" Height="12" HorizontalAlignment="Left"
<ToggleButton Grid.Column="1" Template="{StaticResource TreeExpanderToggleButton}" Width="12" Height="12" HorizontalAlignment="Left"
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType=sd:PropertyViewItem}}"
Visibility="{Binding VisibleChildrenCount, Converter={sd:Chained {sd:NumericToBool}, {sd:VisibleOrCollapsed}}}"/>
<TextBlock x:Name="PropertyNameBlock" Grid.Column="2" Text="{Binding DisplayName}" HorizontalAlignment="Stretch" VerticalAlignment="Center"
Expand Down Expand Up @@ -271,7 +271,7 @@
</i:Interaction.Behaviors>
</ComboBox>
</StackPanel>
<ToggleButton DockPanel.Dock="Left" Template="{StaticResource DarkExpanderToggleButton}" Width="16" Height="16"
<ToggleButton DockPanel.Dock="Left" Template="{StaticResource PropertyGridHeaderExpanderToggleButton}" Width="16" Height="16"
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType=sd:PropertyViewItem}}"
Visibility="{Binding VisibleChildrenCount, Converter={sd:Chained {sd:NumericToBool}, {sd:VisibleOrCollapsed}}}"/>
<StackPanel Orientation="Horizontal" Margin="8,0,0,0">
Expand All @@ -282,7 +282,8 @@
<Image Source="{Binding NodeValue, Converter={sd:Chained {sd:ObjectToType}, {cvt:TypeToResource}}}" MaxWidth="16" MaxHeight="16"
RenderOptions.BitmapScalingMode="NearestNeighbor" Margin="0,0,4,0"/>
<TextBlock x:Name="HeaderTextBlock" FontSize="16" TextTrimming="CharacterEllipsis"
Text="{Binding DisplayName, Mode=OneWay}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
Text="{Binding DisplayName, Mode=OneWay}" HorizontalAlignment="Left" VerticalAlignment="Center"
Foreground="{StaticResource SelectedTextBrush}"/>
</StackPanel>
</DockPanel>
<i:Interaction.Behaviors>
Expand Down
Expand Up @@ -9,7 +9,7 @@
<ResourceDictionary>
<!-- MERGED DICTIONARIES: IMAGE DICTIONARY, PROPERTY GRID VIEWS -->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Stride.Core.Presentation;component/Themes/ExpressionDark/Theme.xaml"/>
<ResourceDictionary Source="/Stride.Core.Presentation;component/Themes/ThemeSelector.xaml"/>
</ResourceDictionary.MergedDictionaries>

<Style TargetType="Hyperlink">
Expand Down
Expand Up @@ -57,7 +57,7 @@

<GridSplitter Grid.Column="1" Width="5" ResizeBehavior="PreviousAndNext" VerticalAlignment="Stretch" />

<sd:PropertyView NameColumnSize="310" Grid.Column="2" ItemsSource="{Binding ViewModel.RootNode.Children}" BorderThickness="1" Background="{DynamicResource HoverBrush}" Padding="5">
<sd:PropertyView NameColumnSize="310" Grid.Column="2" ItemsSource="{Binding ViewModel.RootNode.Children}" BorderThickness="1" Background="{DynamicResource BackgroundBrush}" Padding="5">
<sd:PropertyView.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type sd:PropertyViewItem}}" TargetType="sd:PropertyViewItem">
<Setter Property="Background" Value="Transparent"/>
Expand Down