style<*>: flat style without dropshadow effects for toolbar and tabs

This commit is contained in:
leo 2021-04-01 17:31:15 +08:00
parent 1b7630ac87
commit af875b9ed0
6 changed files with 30 additions and 80 deletions

View file

@ -1,38 +0,0 @@
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
namespace SourceGit.Helpers {
/// <summary>
/// Chrome like tab shape
/// </summary>
public class ChromeTabShape : Shape {
protected override Geometry DefiningGeometry => MakeGeometry();
public ChromeTabShape() {
Stretch = Stretch.None;
StrokeThickness = 0;
}
private Geometry MakeGeometry() {
var geo = new StreamGeometry();
var cornerSize = new Size(4, 4);
var cornerAngle = Math.PI / 2;
using (var ctx = geo.Open()) {
ctx.BeginFigure(new Point(-5, ActualHeight), true, true);
ctx.ArcTo(new Point(-1, ActualHeight - 4), cornerSize, cornerAngle, false, SweepDirection.Counterclockwise, false, true);
ctx.LineTo(new Point(-1, 4), false, true);
ctx.ArcTo(new Point(3, 0), cornerSize, cornerAngle, false, SweepDirection.Clockwise, false, true);
ctx.LineTo(new Point(ActualWidth - 4, 0), false, true);
ctx.ArcTo(new Point(ActualWidth, 4), cornerSize, cornerAngle, false, SweepDirection.Clockwise, false, true);
ctx.LineTo(new Point(ActualWidth, ActualHeight - 4), false, true);
ctx.ArcTo(new Point(ActualWidth + 4, ActualHeight), cornerSize, cornerAngle, false, SweepDirection.Counterclockwise, false, true);
}
geo.Freeze();
return geo;
}
}
}

View file

@ -14,11 +14,13 @@
<SolidColorBrush x:Key="Brush.GroupContent" Color="#FF252525"/> <SolidColorBrush x:Key="Brush.GroupContent" Color="#FF252525"/>
<SolidColorBrush x:Key="Brush.Decorator" Color="#FF505050"/> <SolidColorBrush x:Key="Brush.Decorator" Color="#FF505050"/>
<SolidColorBrush x:Key="Brush.Conflict" Color="#FFFAFAD2"/> <SolidColorBrush x:Key="Brush.Conflict" Color="#FFFAFAD2"/>
<SolidColorBrush x:Key="Brush.Border0" Color="#FF121212"/>
<SolidColorBrush x:Key="Brush.Border1" Color="#FF7C7C7C"/> <SolidColorBrush x:Key="Brush.Border1" Color="#FF7C7C7C"/>
<SolidColorBrush x:Key="Brush.Border2" Color="#FF404040"/> <SolidColorBrush x:Key="Brush.Border2" Color="#FF404040"/>
<SolidColorBrush x:Key="Brush.Border3" Color="#FF252525"/> <SolidColorBrush x:Key="Brush.Border3" Color="#FF252525"/>
<SolidColorBrush x:Key="Brush.Border4" Color="#FF252525"/> <SolidColorBrush x:Key="Brush.Border4" Color="#FF252525"/>
<SolidColorBrush x:Key="Brush.FG1" Color="#FFF1F1F1"/> <SolidColorBrush x:Key="Brush.FG1" Color="#FFF1F1F1"/>
<SolidColorBrush x:Key="Brush.FG2" Color="#40F1F1F1"/> <SolidColorBrush x:Key="Brush.FG2" Color="#40F1F1F1"/>
<SolidColorBrush x:Key="Brush.FG3" Color="#FF252525"/> <SolidColorBrush x:Key="Brush.FG3" Color="#FF252525"/>

View file

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="Brush.Logo" Color="#FFF05133"/> <SolidColorBrush x:Key="Brush.Logo" Color="#FFF05133"/>
<SolidColorBrush x:Key="Brush.TitleBar" Color="#FFE9E9E9"/> <SolidColorBrush x:Key="Brush.TitleBar" Color="White"/>
<SolidColorBrush x:Key="Brush.Window" Color="#FFF8F8F8"/> <SolidColorBrush x:Key="Brush.Window" Color="#FFF8F8F8"/>
<SolidColorBrush x:Key="Brush.NewPageHover" Color="#1D000000"/> <SolidColorBrush x:Key="Brush.NewPageHover" Color="#1D000000"/>
<SolidColorBrush x:Key="Brush.Popup" Color="White"/> <SolidColorBrush x:Key="Brush.Popup" Color="White"/>
@ -14,11 +14,13 @@
<SolidColorBrush x:Key="Brush.GroupContent" Color="#FFF8F8F8"/> <SolidColorBrush x:Key="Brush.GroupContent" Color="#FFF8F8F8"/>
<SolidColorBrush x:Key="Brush.Decorator" Color="#FFBDBDBD"/> <SolidColorBrush x:Key="Brush.Decorator" Color="#FFBDBDBD"/>
<SolidColorBrush x:Key="Brush.Conflict" Color="#FF836C2E"/> <SolidColorBrush x:Key="Brush.Conflict" Color="#FF836C2E"/>
<SolidColorBrush x:Key="Brush.Border0" Color="#FFCFCFCF"/>
<SolidColorBrush x:Key="Brush.Border1" Color="#FF898989"/> <SolidColorBrush x:Key="Brush.Border1" Color="#FF898989"/>
<SolidColorBrush x:Key="Brush.Border2" Color="#FFCFCFCF"/> <SolidColorBrush x:Key="Brush.Border2" Color="#FFCFCFCF"/>
<SolidColorBrush x:Key="Brush.Border3" Color="#FFEFEFEF"/> <SolidColorBrush x:Key="Brush.Border3" Color="#FFEFEFEF"/>
<SolidColorBrush x:Key="Brush.Border4" Color="#FFF2F2F2"/> <SolidColorBrush x:Key="Brush.Border4" Color="#FFF2F2F2"/>
<SolidColorBrush x:Key="Brush.FG1" Color="#FF1F1F1F"/> <SolidColorBrush x:Key="Brush.FG1" Color="#FF1F1F1F"/>
<SolidColorBrush x:Key="Brush.FG2" Color="#FF6F6F6F"/> <SolidColorBrush x:Key="Brush.FG2" Color="#FF6F6F6F"/>
<SolidColorBrush x:Key="Brush.FG3" Color="#FFFFFFFF"/> <SolidColorBrush x:Key="Brush.FG3" Color="#FFFFFFFF"/>

View file

@ -26,17 +26,12 @@
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="32"/> <RowDefinition Height="32"/>
<RowDefinition Height="1"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Toolbar --> <!-- Toolbar -->
<Grid Grid.Row="0" Panel.ZIndex="100"> <Grid Grid.Row="0" Panel.ZIndex="100">
<Border Background="{StaticResource Brush.Window}" Margin="0,4,0,0">
<Border.Effect>
<DropShadowEffect ShadowDepth="2" Direction="270" Opacity=".5" Color="Black"/>
</Border.Effect>
</Border>
<Grid Background="{StaticResource Brush.Window}"> <Grid Background="{StaticResource Brush.Window}">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
@ -112,9 +107,11 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
</Grid> </Grid>
<Rectangle Grid.Row="1" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="1" Fill="{StaticResource Brush.Border0}"/>
<!-- Main body --> <!-- Main body -->
<Grid Grid.Row="1"> <Grid Grid.Row="2">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="200" MinWidth="200" MaxWidth="300"/> <ColumnDefinition Width="200" MinWidth="200" MaxWidth="300"/>
<ColumnDefinition Width="1"/> <ColumnDefinition Width="1"/>
@ -533,6 +530,6 @@
</Grid> </Grid>
<!-- Popups --> <!-- Popups -->
<local:PopupManager x:Name="popupManager" Grid.Row="1"/> <local:PopupManager x:Name="popupManager" Grid.Row="2"/>
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -53,11 +53,10 @@
<ColumnDefinition Width="200"/> <ColumnDefinition Width="200"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Grid.Column="0" Grid.ColumnSpan="3" Height="4" VerticalAlignment="Bottom" Margin="0,0,0,-4" Background="{StaticResource Brush.TitleBar}"> <Rectangle Grid.Column="0" Grid.ColumnSpan="3"
<Border.Effect> Height="1"
<DropShadowEffect ShadowDepth="1" Direction="90" Opacity=".5" Color="Black"/> VerticalAlignment="Bottom"
</Border.Effect> Fill="{StaticResource Brush.Border0}"/>
</Border>
<!-- Tabs --> <!-- Tabs -->
<ScrollViewer x:Name="openedTabsScroller" Grid.Column="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" CanContentScroll="True"> <ScrollViewer x:Name="openedTabsScroller" Grid.Column="0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" CanContentScroll="True">
@ -67,7 +66,7 @@
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type TabControl}"> <ControlTemplate TargetType="{x:Type TabControl}">
<StackPanel Orientation="Horizontal" Margin="8,6,4,0"> <StackPanel Orientation="Horizontal" Margin="4,6,4,0">
<StackPanel Orientation="Horizontal" IsItemsHost="True" SnapsToDevicePixels="True" KeyboardNavigation.TabIndex="1"/> <StackPanel Orientation="Horizontal" IsItemsHost="True" SnapsToDevicePixels="True" KeyboardNavigation.TabIndex="1"/>
<Button Margin="4,0,0,0" Click="NewTab" ToolTip="{StaticResource Text.Launcher.NewPageButton}" WindowChrome.IsHitTestVisibleInChrome="True"> <Button Margin="4,0,0,0" Click="NewTab" ToolTip="{StaticResource Text.Launcher.NewPageButton}" WindowChrome.IsHitTestVisibleInChrome="True">
<Button.Style> <Button.Style>
@ -169,24 +168,17 @@
<Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}"/> <Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}"/>
<Setter Property="Margin" Value="0"/> <Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/> <Setter Property="Padding" Value="0"/>
<Setter Property="ClipToBounds" Value="False"/>
<Setter Property="Template"> <Setter Property="Template">
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}"> <ControlTemplate TargetType="{x:Type TabItem}">
<Grid x:Name="Container" SnapsToDevicePixels="True" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="{Binding Tooltip}"> <Grid x:Name="Container" SnapsToDevicePixels="True" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="{Binding Tooltip}">
<helpers:ChromeTabShape
x:Name="BG"
Width="{Binding ElementName=Container,Path=ActualWidth}"
Height="{Binding ElementName=Container,Path=ActualHeight}"
Fill="Transparent">
<helpers:ChromeTabShape.Effect>
<DropShadowEffect ShadowDepth="1" Direction="90" Opacity=".5" Color="Black"/>
</helpers:ChromeTabShape.Effect>
</helpers:ChromeTabShape>
<Border <Border
x:Name="Hover" x:Name="BG"
Margin="-1,0" BorderThickness="0"
Background="Transparent"/> BorderBrush="{StaticResource Brush.Border0}"
Background="Transparent"
CornerRadius="3,3,0,0"/>
<ContentPresenter <ContentPresenter
x:Name="ContentSite" x:Name="ContentSite"
@ -199,13 +191,14 @@
HorizontalAlignment="Right" HorizontalAlignment="Right"
Margin="0,0,-1,0" Margin="0,0,-1,0"
Width="1" Height="16" Width="1" Height="16"
Fill="{StaticResource Brush.FG2}" Fill="{StaticResource Brush.Border2}"
Visibility="Hidden"/> Visibility="Hidden"/>
</Grid> </Grid>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True"> <Trigger Property="IsSelected" Value="True">
<Setter Property="Panel.ZIndex" Value="2"/> <Setter Property="Panel.ZIndex" Value="2"/>
<Setter TargetName="BG" Property="Fill" Value="{StaticResource Brush.Window}"/> <Setter TargetName="BG" Property="Background" Value="{StaticResource Brush.Window}"/>
<Setter TargetName="BG" Property="BorderThickness" Value="1,1,1,0"/>
</Trigger> </Trigger>
<Trigger Property="IsSelected" Value="False"> <Trigger Property="IsSelected" Value="False">

View file

@ -8,15 +8,9 @@
Visibility="Collapsed"> Visibility="Collapsed">
<Grid ClipToBounds="True"> <Grid ClipToBounds="True">
<Border Background="Transparent" MouseLeftButtonDown="Close"/> <Border Background="Transparent" MouseLeftButtonDown="Close"/>
<Grid HorizontalAlignment="Center" VerticalAlignment="Top" Width="Auto" Height="Auto"> <Grid HorizontalAlignment="Center" VerticalAlignment="Top" Width="Auto" Height="Auto" Background="{StaticResource Brush.Popup}">
<Border Background="{StaticResource Brush.Popup}"> <Border x:Name="popupContent" Padding="8" Width="Auto" Height="Auto" BorderThickness="1,0,1,1" BorderBrush="{StaticResource Brush.Border0}"/>
<Border.Effect>
<DropShadowEffect ShadowDepth="1" Opacity=".5" Direction="270" BlurRadius="16"/>
</Border.Effect>
</Border>
<Border x:Name="popupContent" Padding="8" Width="Auto" Height="Auto"/>
<Border x:Name="status" Visibility="Collapsed" Background="{StaticResource Brush.Popup}" Opacity=".9"> <Border x:Name="status" Visibility="Collapsed" Background="{StaticResource Brush.Popup}" Opacity=".9">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center"> <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">