Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 091f4ae

Browse files
authored
Merge pull request #1080 from github/ui/inline-themes
Polish peek view for inline reviews
2 parents 1bc9f9b + 903b958 commit 091f4ae

22 files changed

+3248
-185
lines changed

src/GitHub.InlineReviews/GitHub.InlineReviews.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@
385385
</EmbeddedResource>
386386
</ItemGroup>
387387
<ItemGroup>
388+
<Page Include="Properties\DesignTimeResources.xaml" Condition="'$(DesignTime)'=='true' OR ('$(SolutionPath)'!='' AND Exists('$(SolutionPath)') AND '$(BuildingInsideVisualStudio)'!='true' AND '$(BuildingInsideExpressionBlend)'!='true')">
389+
<Generator>MSBuild:Compile</Generator>
390+
<SubType>Designer</SubType>
391+
<ContainsDesignTimeResources>true</ContainsDesignTimeResources>
392+
</Page>
388393
<Page Include="Views\DiffCommentThreadView.xaml">
389394
<SubType>Designer</SubType>
390395
<Generator>MSBuild:Compile</Generator>

src/GitHub.InlineReviews/InlineCommentMarginProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTex
5656
}
5757

5858
var textView = wpfTextViewHost.TextView;
59-
var editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView);
60-
var glyphFactory = new InlineCommentGlyphFactory(peekService, textView, editorFormatMap);
59+
var glyphFactory = new InlineCommentGlyphFactory(peekService, textView);
6160

6261
Func<Grid> gridFactory = () => new GlyphMarginGrid();
62+
var editorFormatMap = editorFormatMapService.GetEditorFormatMap(textView);
6363
return CreateMargin(glyphFactory, gridFactory, wpfTextViewHost, parent, editorFormatMap);
6464
}
6565

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<ResourceDictionary
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
4+
5+
<ResourceDictionary.MergedDictionaries>
6+
<ResourceDictionary Source="pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/VsColorsBlue.xaml" />
7+
<ResourceDictionary Source="pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/VsBrushesBlue.xaml" />
8+
<ResourceDictionary Source="pack://application:,,,/GitHub.VisualStudio.UI;component/Styles/ThemeBlue.xaml" />
9+
</ResourceDictionary.MergedDictionaries>
10+
11+
</ResourceDictionary>

src/GitHub.InlineReviews/Tags/AddInlineCommentGlyph.xaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:cache="clr-namespace:GitHub.UI.Helpers;assembly=GitHub.UI"
56
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
67
mc:Ignorable="d">
7-
<UserControl.Resources>
8-
<SolidColorBrush x:Key="DiffChangeBackground" Color="DarkSlateGray" />
9-
</UserControl.Resources>
108

11-
<Grid Background="{DynamicResource DiffChangeBackground}">
12-
<Viewbox x:Name="AddViewbox">
13-
<Path Stroke="Black"
14-
Data="M13 2H1c-0.55 0-1 0.45-1 1v8c0 0.55 0.45 1 1 1h2v3.5l3.5-3.5h6.5c0.55 0 1-0.45 1-1V3c0-0.55-0.45-1-1-1z m0 9H6L4 13V11H1V3h12v8z M7,5 L7,9 M5,7 L9,7"/>
9+
<Grid>
10+
<Viewbox x:Name="AddViewbox" Margin="0,1,0,0">
11+
<Canvas Width="14" Height="14">
12+
<Rectangle Width="13" Height="13" Fill="{DynamicResource GitHubDiffGlyphFill.None}"/>
13+
<Rectangle Stroke="#313131" Fill="Transparent" Opacity="0.163" Width="13" Height="13" />
14+
<Path Canvas.Top="-0.5" Canvas.Left="-0.5" Fill="#FFF" Data="M11 8H8v3H6V8H3V6h3V3h2v3h3z"/>
15+
</Canvas>
1516
</Viewbox>
1617
</Grid>
1718
</UserControl>

src/GitHub.InlineReviews/Tags/InlineCommentGlyphFactory.cs

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,54 +16,13 @@ class InlineCommentGlyphFactory : IGlyphFactory<InlineCommentTag>
1616
{
1717
readonly IInlineCommentPeekService peekService;
1818
readonly ITextView textView;
19-
readonly BrushesManager brushesManager;
2019

2120
public InlineCommentGlyphFactory(
2221
IInlineCommentPeekService peekService,
23-
ITextView textView,
24-
IEditorFormatMap editorFormatMap)
22+
ITextView textView)
2523
{
2624
this.peekService = peekService;
2725
this.textView = textView;
28-
29-
brushesManager = new BrushesManager(editorFormatMap);
30-
}
31-
32-
class BrushesManager
33-
{
34-
const string AddPropertiesKey = "deltadiff.add.word";
35-
const string DeletePropertiesKey = "deltadiff.remove.word";
36-
const string NonePropertiesKey = "Indicator Margin";
37-
38-
readonly ResourceDictionary addProperties;
39-
readonly ResourceDictionary deleteProperties;
40-
readonly ResourceDictionary noneProperties;
41-
42-
internal BrushesManager(IEditorFormatMap editorFormatMap)
43-
{
44-
addProperties = editorFormatMap.GetProperties(AddPropertiesKey);
45-
deleteProperties = editorFormatMap.GetProperties(DeletePropertiesKey);
46-
noneProperties = editorFormatMap.GetProperties(NonePropertiesKey);
47-
}
48-
49-
internal Brush GetBackground(DiffChangeType diffChangeType)
50-
{
51-
switch (diffChangeType)
52-
{
53-
case DiffChangeType.Add:
54-
return GetBackground(addProperties);
55-
case DiffChangeType.Delete:
56-
return GetBackground(deleteProperties);
57-
case DiffChangeType.None:
58-
default:
59-
return GetBackground(noneProperties);
60-
}
61-
}
62-
63-
static Brush GetBackground(ResourceDictionary dictionary)
64-
{
65-
return dictionary["Background"] as Brush;
66-
}
6726
}
6827

6928
public UIElement GenerateGlyph(IWpfTextViewLine line, InlineCommentTag tag)
@@ -75,7 +34,6 @@ public UIElement GenerateGlyph(IWpfTextViewLine line, InlineCommentTag tag)
7534
if (OpenThreadView(tag)) e.Handled = true;
7635
};
7736

78-
glyph.Resources["DiffChangeBackground"] = brushesManager.GetBackground(tag.DiffChangeType);
7937
return glyph;
8038
}
8139

src/GitHub.InlineReviews/Tags/ShowInlineCommentGlyph.xaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:cache="clr-namespace:GitHub.UI.Helpers;assembly=GitHub.UI"
67
mc:Ignorable="d">
78

8-
<UserControl.Resources>
9-
<!-- This will be the color of an added/deleted word in the diff view or the indicator margin color -->
10-
<SolidColorBrush x:Key="DiffChangeBackground" Color="DarkSlateGray" />
11-
</UserControl.Resources>
12-
13-
14-
<Grid Background="{DynamicResource DiffChangeBackground}">
15-
<Viewbox>
16-
<Path Stroke="Black"
17-
Data="M13 2H1c-0.55 0-1 0.45-1 1v8c0 0.55 0.45 1 1 1h2v3.5l3.5-3.5h6.5c0.55 0 1-0.45 1-1V3c0-0.55-0.45-1-1-1z m0 9H6L4 13V11H1V3h12v8z"/>
9+
<Grid>
10+
<Viewbox HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,1,0,0">
11+
<Canvas Width="16" Height="15">
12+
<Path Canvas.Top="1" Canvas.Left="0.85"
13+
Data="M1,0 C0.45,0 0,0.45 0,1 L0,9 C0,9.55 0.45,10 1,10 L3,10 L3,13.5 L6.5,10 L13,10 C13.55,10 14,9.55 14,9 L14,1 C14,0.45 13.55,0 13,0 L1,0 Z" />
14+
<Path Canvas.Top="1" Canvas.Left="0.85" Opacity="0.163" Stroke="#313131"
15+
Data="M3.5,12.2928932 L6.29289322,9.5 L13,9.5 C13.2738576,9.5 13.5,9.27385763 13.5,9 L13.5,1 C13.5,0.726142375 13.2738576,0.5 13,0.5 L1,0.5 C0.726142375,0.5 0.5,0.726142375 0.5,1 L0.5,9 C0.5,9.27385763 0.726142375,9.5 1,9.5 L3.5,9.5 L3.5,12.2928932 Z" />
16+
<Canvas.Resources>
17+
<Style TargetType="Path">
18+
<Setter Property="Fill" Value="{DynamicResource GitHubDiffGlyphFill.None}" />
19+
</Style>
20+
</Canvas.Resources>
21+
</Canvas>
1822
</Viewbox>
1923
</Grid>
2024
</UserControl>

src/GitHub.InlineReviews/Views/CommentView.xaml

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
xmlns:views="clr-namespace:GitHub.InlineReviews.Views"
1313
mc:Ignorable="d" d:DesignWidth="300">
1414
<d:DesignProperties.DataContext>
15-
<sample:CommentViewModelDesigner EditState="None">
15+
<sample:CommentViewModelDesigner EditState="Editing">
1616
<sample:CommentViewModelDesigner.Body>
1717
You can use a `CompositeDisposable` type here, it's designed to handle disposables in an optimal way (you can just call `Dispose()` on it and it will handle disposing everything it holds).
1818
</sample:CommentViewModelDesigner.Body>
@@ -34,8 +34,8 @@
3434

3535
<Grid>
3636
<!-- Displays an existing comment-->
37-
<Grid>
38-
<Grid.Style>
37+
<StackPanel Orientation="Vertical" Margin="4">
38+
<StackPanel.Style>
3939
<Style TargetType="FrameworkElement">
4040
<Setter Property="Visibility" Value="Collapsed"/>
4141
<Style.Triggers>
@@ -44,40 +44,26 @@
4444
</DataTrigger>
4545
</Style.Triggers>
4646
</Style>
47-
</Grid.Style>
48-
49-
<Grid.ColumnDefinitions>
50-
<ColumnDefinition Width="Auto"/>
51-
<ColumnDefinition Width="*"/>
52-
</Grid.ColumnDefinitions>
53-
54-
<Grid.RowDefinitions>
55-
<RowDefinition Height="Auto"/>
56-
</Grid.RowDefinitions>
57-
58-
<controls:AccountAvatar Margin="4 4"
59-
Width="28"
60-
Height="28"
61-
VerticalAlignment="Top"
62-
Account="{Binding User}"/>
47+
</StackPanel.Style>
6348

64-
<StackPanel Margin="4 4" Orientation="Vertical" Grid.Column="1">
65-
<Border Background="#FFF6F8FA" Padding="6 5" BorderThickness="1 1 1 0" BorderBrush="#FFD1D5DA" CornerRadius="2 2 0 0">
66-
<StackPanel Orientation="Horizontal">
67-
<TextBlock Margin="2 0" FontWeight="Bold" Text="{Binding User.Login}"/>
68-
<ui:GitHubActionLink Content="{Binding UpdatedAt, Converter={ui:DurationToStringConverter}}"
69-
Command="{Binding OpenOnGitHub}"
70-
Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TextBlock}, AncestorLevel=1}, Path=Foreground}"
71-
Margin="2 0"/>
72-
</StackPanel>
73-
</Border>
49+
<StackPanel Orientation="Horizontal">
50+
<controls:AccountAvatar Width="16"
51+
Height="16"
52+
Account="{Binding User}"/>
7453

75-
<Border Background="White" Padding="6 5" BorderThickness="1" BorderBrush="#FFD1D5DA" CornerRadius="0 0 2 2 ">
76-
<markdig:MarkdownViewer Grid.Column="1" Grid.Row="1"
77-
Markdown="{Binding Body}"/>
78-
</Border>
54+
<TextBlock Foreground="{DynamicResource GitHubVsToolWindowText}" FontWeight="Bold" Text="{Binding User.Login}" Margin="4 0"/>
55+
<ui:GitHubActionLink Content="{Binding UpdatedAt, Converter={ui:DurationToStringConverter}}"
56+
Command="{Binding OpenOnGitHub}"
57+
Foreground="{DynamicResource GitHubVsToolWindowText}"
58+
Opacity="0.75" />
7959
</StackPanel>
80-
</Grid>
60+
61+
62+
<markdig:MarkdownViewer Grid.Column="1" Grid.Row="1"
63+
Margin="0 2 0 0"
64+
Foreground="{DynamicResource VsBrush.WindowText}"
65+
Markdown="{Binding Body}"/>
66+
</StackPanel>
8167

8268
<!-- Displays edit view or a reply placeholder-->
8369
<Grid>
@@ -101,20 +87,18 @@
10187
</Grid.ColumnDefinitions>
10288

10389
<Grid.RowDefinitions>
90+
<RowDefinition Height="Auto"/>
10491
<RowDefinition Height="*"/>
10592
<RowDefinition Height="Auto"/>
10693
<RowDefinition Height="Auto"/>
10794
</Grid.RowDefinitions>
10895

109-
<controls:AccountAvatar Grid.RowSpan="2"
110-
Margin="4"
111-
Width="28"
112-
Height="28"
113-
VerticalAlignment="Top"
114-
Account="{Binding User}"/>
96+
<Separator Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Margin="0 0 0 4"
97+
Background="{DynamicResource GitHubButtonBorderBrush}"/>
11598

11699
<ui:PromptTextBox Name="body"
117100
Grid.Column="1"
101+
Grid.Row="1"
118102
AcceptsReturn="True"
119103
AcceptsTab="True"
120104
IsReadOnly="{Binding IsReadOnly}"
@@ -125,19 +109,29 @@
125109
GotFocus="ReplyPlaceholder_GotFocus">
126110
<ui:PromptTextBox.Style>
127111
<Style TargetType="ui:PromptTextBox" BasedOn="{StaticResource RoundedPromptTextBox}">
112+
<Setter Property="Foreground" Value="{DynamicResource GitHubVsToolWindowText}" />
113+
<Setter Property="Background" Value="{DynamicResource VsBrush.SearchBoxBackground}" />
128114
<Setter Property="Height" Value="28"/>
129115
<Setter Property="PromptText" Value="Reply..."/>
116+
<Setter Property="BorderBrush" Value="{DynamicResource GitHubVsBrandedUIBorder}" />
117+
130118
<Style.Triggers>
131119
<DataTrigger Binding="{Binding EditState}" Value="Editing">
132120
<Setter Property="MinHeight" Value="100"/>
133121
<Setter Property="PromptText" Value="Leave a comment"/>
134122
</DataTrigger>
135123
</Style.Triggers>
124+
125+
<Style.Resources>
126+
<Style TargetType="TextBlock">
127+
<Setter Property="Foreground" Value="{DynamicResource GitHubVsToolWindowText}" />
128+
</Style>
129+
</Style.Resources>
136130
</Style>
137131
</ui:PromptTextBox.Style>
138132
</ui:PromptTextBox>
139133

140-
<DockPanel Grid.Column="1" Grid.Row="1"
134+
<DockPanel Grid.Column="1" Grid.Row="2"
141135
Margin="0 4"
142136
HorizontalAlignment="Left"
143137
TextBlock.Foreground="Red">
@@ -155,8 +149,8 @@
155149
</DockPanel>
156150

157151
<StackPanel Name="buttonPanel"
158-
Grid.Column="1" Grid.Row="2"
159-
Margin="0 4"
152+
Grid.Column="1" Grid.Row="3"
153+
Margin="4 8"
160154
HorizontalAlignment="Left"
161155
Orientation="Horizontal"
162156
IsVisibleChanged="buttonPanel_IsVisibleChanged">

src/GitHub.InlineReviews/Views/GlyphMarginGrid.xaml

Lines changed: 9 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,15 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:GitHub.InlineReviews.Views"
7+
xmlns:cache="clr-namespace:GitHub.UI.Helpers;assembly=GitHub.UI"
78
mc:Ignorable="d"
9+
Background="{DynamicResource VsBrush.Window}"
810
d:DesignHeight="100" Width="17">
9-
10-
<Grid.Background>
11-
12-
<VisualBrush TileMode="Tile" Viewport="0,0,5,5" ViewportUnits="Absolute" Viewbox="0,0,15,15" ViewboxUnits="Absolute">
13-
<VisualBrush.Visual>
14-
<Grid>
15-
<Path Data="M 0 15 L 15 0" Stroke="Black" />
16-
</Grid>
17-
</VisualBrush.Visual>
18-
</VisualBrush>
19-
20-
<!-- NOTE: We should really use a DrawingBrush not a VisualBrush, e.g. -->
21-
<!--
22-
<DrawingBrush Stretch="UniformToFill" ViewportUnits="Absolute" Viewport="0,0,10,10" TileMode="Tile">
23-
<DrawingBrush.Drawing>
24-
<DrawingGroup>
25-
<DrawingGroup.Children>
26-
<GeometryDrawing Brush="Black">
27-
<GeometryDrawing.Geometry>
28-
<GeometryGroup FillRule="Nonzero">
29-
<PathGeometry>
30-
<PathFigure StartPoint="0,0">
31-
<LineSegment Point="100,0"/>
32-
<LineSegment Point="100,100"/>
33-
<LineSegment Point="0,100"/>
34-
</PathFigure>
35-
</PathGeometry>
36-
</GeometryGroup>
37-
</GeometryDrawing.Geometry>
38-
</GeometryDrawing>
39-
<GeometryDrawing Brush="#FF404040">
40-
<GeometryDrawing.Geometry>
41-
<GeometryGroup FillRule="Nonzero">
42-
<PathGeometry>
43-
<PathFigure StartPoint="0,0">
44-
<LineSegment Point="25,0"/>
45-
<LineSegment Point="100,75"/>
46-
<LineSegment Point="100,100"/>
47-
<LineSegment Point="75,100"/>
48-
<LineSegment Point="0,25"/>
49-
<LineSegment Point="0,0"/>
50-
</PathFigure>
51-
<PathFigure StartPoint="75,0">
52-
<LineSegment Point="100,25"/>
53-
<LineSegment Point="100,0"/>
54-
</PathFigure>
55-
<PathFigure StartPoint="0,75">
56-
<LineSegment Point="25,100"/>
57-
<LineSegment Point="0,100"/>
58-
</PathFigure>
59-
</PathGeometry>
60-
</GeometryGroup>
61-
</GeometryDrawing.Geometry>
62-
</GeometryDrawing>
63-
</DrawingGroup.Children>
64-
</DrawingGroup>
65-
</DrawingBrush.Drawing>
66-
</DrawingBrush>
67-
-->
68-
69-
</Grid.Background>
11+
<Grid.Resources>
12+
<ResourceDictionary>
13+
<ResourceDictionary.MergedDictionaries>
14+
<cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.VisualStudio.UI;component/SharedDictionary.xaml" />
15+
</ResourceDictionary.MergedDictionaries>
16+
</ResourceDictionary>
17+
</Grid.Resources>
7018
</Grid>

0 commit comments

Comments
 (0)