mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
ux: subject length tooltip font size and color
This commit is contained in:
parent
ee6c360dc9
commit
907e009275
3 changed files with 19 additions and 21 deletions
|
@ -19,7 +19,10 @@ namespace SourceGit.Converters
|
||||||
public static readonly FuncValueConverter<int, bool> IsNotOne =
|
public static readonly FuncValueConverter<int, bool> IsNotOne =
|
||||||
new FuncValueConverter<int, bool>(v => v != 1);
|
new FuncValueConverter<int, bool>(v => v != 1);
|
||||||
|
|
||||||
public static readonly FuncValueConverter<int, bool> IsBadSubjectLength =
|
public static readonly FuncValueConverter<int, bool> IsSubjectLengthBad =
|
||||||
new FuncValueConverter<int, bool>(v => v > ViewModels.Preference.Instance.SubjectGuideLength);
|
new FuncValueConverter<int, bool>(v => v > ViewModels.Preference.Instance.SubjectGuideLength);
|
||||||
|
|
||||||
|
public static readonly FuncValueConverter<int, bool> IsSubjectLengthGood =
|
||||||
|
new FuncValueConverter<int, bool>(v => v <= ViewModels.Preference.Instance.SubjectGuideLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,15 +42,19 @@
|
||||||
|
|
||||||
<Border Grid.Row="1" CornerRadius="0,0,4,4" BorderThickness="0,1,0,0" BorderBrush="{DynamicResource Brush.Border2}" Background="{DynamicResource Brush.Window}" ClipToBounds="True">
|
<Border Grid.Row="1" CornerRadius="0,0,4,4" BorderThickness="0,1,0,0" BorderBrush="{DynamicResource Brush.Border2}" Background="{DynamicResource Brush.Window}" ClipToBounds="True">
|
||||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
<Grid ColumnDefinitions="Auto,*,Auto">
|
||||||
<Path Grid.Column="0" Height="12" Width="12" Margin="4,0,0,0" Data="{DynamicResource Icons.Info}" ToolTip.Tip="{DynamicResource Text.CommitMessageTextBox.Tip}"/>
|
<Border Grid.Column="0" Background="Transparent" Width="16" Height="16" ToolTip.Tip="{DynamicResource Text.CommitMessageTextBox.Tip}">
|
||||||
|
<Path Height="12" Width="12" Margin="4,0,0,0" Data="{DynamicResource Icons.Info}"/>
|
||||||
|
</Border>
|
||||||
|
|
||||||
<StackPanel Grid.Column="2" Orientation="Horizontal" Margin="4,2">
|
<StackPanel Grid.Column="2" Orientation="Horizontal" Margin="4,2">
|
||||||
<TextBlock Text="Subject:" FontSize="10" Foreground="{DynamicResource Brush.FG2}"/>
|
<TextBlock Text="Subject:" FontSize="10" Foreground="{DynamicResource Brush.FG2}"/>
|
||||||
<TextBlock Classes="monospace" Margin="2,0,0,0" FontSize="10" Text="{Binding #ThisControl.SubjectLength}"/>
|
<TextBlock Classes="monospace" Margin="2,0,0,0" FontSize="11" Text="{Binding #ThisControl.SubjectLength}" IsVisible="{Binding #ThisControl.SubjectLength, Converter={x:Static c:IntConverters.IsSubjectLengthGood}}"/>
|
||||||
<TextBlock Classes="monospace" FontSize="10" Text="/"/>
|
<TextBlock Classes="monospace" Margin="2,0,0,0" FontSize="11" Foreground="DarkGoldenrod" Text="{Binding #ThisControl.SubjectLength}" IsVisible="{Binding #ThisControl.SubjectLength, Converter={x:Static c:IntConverters.IsSubjectLengthBad}}"/>
|
||||||
<TextBlock Classes="monospace" FontSize="10" Text="{Binding Source={x:Static vm:Preference.Instance}, Path=SubjectGuideLength}"/>
|
<TextBlock Classes="monospace" FontSize="11" Text="/"/>
|
||||||
<Path Width="10" Height="10" Margin="4,0,0,0" Data="{StaticResource Icons.Error}" Fill="DarkGoldenrod" IsVisible="{Binding #ThisControl.SubjectLength, Converter={x:Static c:IntConverters.IsBadSubjectLength}}"/>
|
<TextBlock Classes="monospace" FontSize="11" Text="{Binding Source={x:Static vm:Preference.Instance}, Path=SubjectGuideLength}"/>
|
||||||
<TextBlock Margin="8,0,0,0" Text="Total:" FontSize="10" Foreground="{DynamicResource Brush.FG2}"/>
|
<Path Width="10" Height="10" Margin="4,0,0,0" Data="{StaticResource Icons.Error}" Fill="DarkGoldenrod" IsVisible="{Binding #ThisControl.SubjectLength, Converter={x:Static c:IntConverters.IsSubjectLengthBad}}"/>
|
||||||
<TextBlock Classes="monospace" Margin="2,0,0,0" FontSize="10" Text="{Binding #ThisControl.Text.Length}"/>
|
<TextBlock Margin="8,0,0,0" Text="Total:" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
|
||||||
|
<TextBlock Classes="monospace" Margin="2,0,0,0" FontSize="11" Text="{Binding #ThisControl.Text.Length}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
|
@ -31,7 +31,6 @@ namespace SourceGit.Views
|
||||||
public TextDocument Document
|
public TextDocument Document
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommitMessageTextBox()
|
public CommitMessageTextBox()
|
||||||
|
@ -44,12 +43,9 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
base.OnPropertyChanged(change);
|
base.OnPropertyChanged(change);
|
||||||
|
|
||||||
if (change.Property == TextProperty)
|
if (change.Property == TextProperty && !_isDocumentTextChanging)
|
||||||
{
|
|
||||||
if (!_isDocumentTextChanging)
|
|
||||||
Document.Text = Text;
|
Document.Text = Text;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void OnTextEditorLayoutUpdated(object sender, EventArgs e)
|
private void OnTextEditorLayoutUpdated(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -85,24 +81,19 @@ namespace SourceGit.Views
|
||||||
SetCurrentValue(TextProperty, Document.Text);
|
SetCurrentValue(TextProperty, Document.Text);
|
||||||
_isDocumentTextChanging = false;
|
_isDocumentTextChanging = false;
|
||||||
|
|
||||||
var setSubject = false;
|
for (var i = 0; i < Document.LineCount; i++)
|
||||||
for (int i = 0; i < Document.LineCount; i++)
|
|
||||||
{
|
{
|
||||||
var line = Document.Lines[i];
|
var line = Document.Lines[i];
|
||||||
if (line.LineNumber > 1 && line.Length == 0)
|
if (line.LineNumber > 1 && line.Length == 0)
|
||||||
{
|
{
|
||||||
var subject = Text.Substring(0, line.Offset).ReplaceLineEndings(" ").Trim();
|
var subject = Text[..line.Offset].ReplaceLineEndings(" ").Trim();
|
||||||
SetCurrentValue(SubjectLengthProperty, subject.Length);
|
SetCurrentValue(SubjectLengthProperty, subject.Length);
|
||||||
setSubject = true;
|
return;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_subjectEndLineNumber = line.LineNumber;
|
_subjectEndLineNumber = line.LineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setSubject)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SetCurrentValue(SubjectLengthProperty, Text.ReplaceLineEndings(" ").Trim().Length);
|
SetCurrentValue(SubjectLengthProperty, Text.ReplaceLineEndings(" ").Trim().Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue