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

introduce inactive title bar brush #1320

Merged
merged 1 commit into from
Apr 24, 2014
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion MahApps.Metro/Controls/MetroWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ public class MetroWindow : Window
public static readonly DependencyProperty WindowTransitionsEnabledProperty = DependencyProperty.Register("WindowTransitionsEnabled", typeof(bool), typeof(MetroWindow), new PropertyMetadata(true));
public static readonly DependencyProperty MetroDialogOptionsProperty = DependencyProperty.Register("MetroDialogOptions", typeof(MetroDialogSettings), typeof(MetroWindow), new PropertyMetadata(new MetroDialogSettings()));

public static readonly DependencyProperty WindowTitleBrushProperty = DependencyProperty.Register("WindowTitleBrush", typeof(Brush), typeof(MetroWindow), new PropertyMetadata(Brushes.Transparent));
public static readonly DependencyProperty GlowBrushProperty = DependencyProperty.Register("GlowBrush", typeof(SolidColorBrush), typeof(MetroWindow), new PropertyMetadata(null));
public static readonly DependencyProperty NonActiveGlowBrushProperty = DependencyProperty.Register("NonActiveGlowBrush", typeof(SolidColorBrush), typeof(MetroWindow), new PropertyMetadata(new SolidColorBrush(Color.FromRgb(153, 153, 153)))); // #999999
public static readonly DependencyProperty NonActiveBorderBrushProperty = DependencyProperty.Register("NonActiveBorderBrush", typeof(Brush), typeof(MetroWindow), new PropertyMetadata(null));
public static readonly DependencyProperty NonActiveBorderBrushProperty = DependencyProperty.Register("NonActiveBorderBrush", typeof(Brush), typeof(MetroWindow), new PropertyMetadata(Brushes.Gray));
public static readonly DependencyProperty NonActiveWindowTitleBrushProperty = DependencyProperty.Register("NonActiveWindowTitleBrush", typeof(Brush), typeof(MetroWindow), new PropertyMetadata(Brushes.Gray));

public static readonly DependencyProperty IconTemplateProperty = DependencyProperty.Register("IconTemplate", typeof(DataTemplate), typeof(MetroWindow), new PropertyMetadata(null));
public static readonly DependencyProperty TitleTemplateProperty = DependencyProperty.Register("TitleTemplate", typeof(DataTemplate), typeof(MetroWindow), new PropertyMetadata(null));
Expand Down Expand Up @@ -91,6 +93,8 @@ public class MetroWindow : Window
private Storyboard overlayStoryboard;
Rectangle flyoutModal;

private Brush savedTitleBarBrush = null;

public static readonly RoutedEvent FlyoutsStatusChangedEvent = EventManager.RegisterRoutedEvent(
"FlyoutsStatusChanged", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MetroWindow));

Expand Down Expand Up @@ -415,6 +419,15 @@ public bool TitleCaps
set { SetValue(TitleCapsProperty, value); }
}

/// <summary>
/// Gets/sets the brush used for the Window's title bar.
/// </summary>
public Brush WindowTitleBrush
{
get { return (Brush)GetValue(WindowTitleBrushProperty); }
set { SetValue(WindowTitleBrushProperty, value); }
}

/// <summary>
/// Gets/sets the brush used for the Window's glow.
/// </summary>
Expand Down Expand Up @@ -442,6 +455,15 @@ public Brush NonActiveBorderBrush
set { SetValue(NonActiveBorderBrushProperty, value); }
}

/// <summary>
/// Gets/sets the brush used for the Window's non-active title bar.
/// </summary>
public Brush NonActiveWindowTitleBrush
{
get { return (Brush)GetValue(NonActiveWindowTitleBrushProperty); }
set { SetValue(NonActiveWindowTitleBrushProperty, value); }
}

/// <summary>
/// Gets/sets the TitleBar/Window's Text.
/// </summary>
Expand Down Expand Up @@ -552,6 +574,22 @@ public void HideOverlay()
public MetroWindow()
{
Loaded += this.MetroWindow_Loaded;
Activated += MetroWindow_Activated;
Deactivated += MetroWindow_Deactivated;
}

private void MetroWindow_Activated(object sender, EventArgs e)
{
if (savedTitleBarBrush != null)
{
WindowTitleBrush = savedTitleBarBrush;
}
}

private void MetroWindow_Deactivated(object sender, EventArgs e)
{
savedTitleBarBrush = WindowTitleBrush;
WindowTitleBrush = NonActiveWindowTitleBrush;
}

private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
Expand Down
4 changes: 3 additions & 1 deletion MahApps.Metro/Themes/MetroWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</Grid.RowDefinitions>

<Rectangle x:Name="PART_WindowTitleBackground"
Fill="{DynamicResource WindowTitleColorBrush}"
Fill="{TemplateBinding WindowTitleBrush}"
Height="{Binding TitlebarHeight, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}"
Grid.Column="0"
Expand Down Expand Up @@ -222,6 +222,8 @@
</ControlTemplate>

<Style TargetType="{x:Type Controls:MetroWindow}">
<Setter Property="WindowTitleBrush"
Value="{DynamicResource WindowTitleColorBrush}" />
<Setter Property="TextElement.FontSize"
Value="{DynamicResource ContentFontSize}" />
<Setter Property="Background"
Expand Down