Skip to content

Commit

Permalink
[Database Editor] Greatly improvement database editor UX
Browse files Browse the repository at this point in the history
Among many: arrow movements, copy paste, selected row view
  • Loading branch information
BAndysc committed Oct 8, 2021
1 parent 6bb552d commit 531b7bc
Show file tree
Hide file tree
Showing 45 changed files with 1,741 additions and 284 deletions.
7 changes: 5 additions & 2 deletions AvaloniaStyles/Controls/CompletionComboBox.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
IsOpen="{TemplateBinding IsDropDownOpen, Mode=TwoWay}"
WindowManagerAddShadowHint="True"
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
IsLightDismissEnabled="True"
IsLightDismissEnabled="{TemplateBinding IsLightDismissEnabled}"
MaxWidth="700"
MaxHeight="600"
PlacementConstraintAdjustment="SlideY"
PlacementConstraintAdjustment="SlideY,SlideX"
PlacementMode="Bottom"
PlacementGravity="Bottom"
PlacementTarget="PART_Button">
Expand All @@ -59,4 +59,7 @@
</ControlTemplate>
</Setter>
</Style>
<Style Selector="controls1|CompletionComboBox:hideButton ToggleButton">
<Setter Property="Opacity" Value="0" />
</Style>
</Styles>
32 changes: 29 additions & 3 deletions AvaloniaStyles/Controls/CompletionComboBox.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Avalonia.Threading;
using Avalonia.VisualTree;
using AvaloniaStyles.Utils;
using FuzzySharp;
using WDE.MVVM.Utils;

namespace AvaloniaStyles.Controls
Expand Down Expand Up @@ -87,6 +88,18 @@ public IDataTemplate? ButtonItemTemplate
set => SetValue(ButtonItemTemplateProperty, value);
}

public bool HideButton
{
get => GetValue(HideButtonProperty);
set => SetValue(HideButtonProperty, value);
}

public bool IsLightDismissEnabled
{
get => GetValue(IsLightDismissEnabledProperty);
set => SetValue(IsLightDismissEnabledProperty, value);
}

public static readonly StyledProperty<IDataTemplate?> ButtonItemTemplateProperty =
AvaloniaProperty.Register<CompletionComboBox, IDataTemplate?>(nameof(ButtonItemTemplate));

Expand Down Expand Up @@ -123,6 +136,14 @@ public IDataTemplate? ButtonItemTemplate
(o, v) => o.SelectedItem = v,
defaultBindingMode: BindingMode.TwoWay);

public static readonly StyledProperty<bool> IsLightDismissEnabledProperty =
AvaloniaProperty.Register<CompletionComboBox, bool>(nameof (IsLightDismissEnabled), true);

public static readonly StyledProperty<bool> HideButtonProperty =
AvaloniaProperty.Register<CompletionComboBox, bool>(nameof (HideButton));

public event Action? Closed;

public CompletionComboBox()
{
// Default async populator searches in Items (toString) using Fuzzy match or normal match depending on the collection size
Expand All @@ -138,7 +159,7 @@ public CompletionComboBox()
{
if (o.Count < 250)
{
return FuzzySharp.Process.ExtractSorted(s, items.Select(item => item.ToString()), cutoff: 51)
return Process.ExtractSorted(s, items.Select(item => item.ToString()), cutoff: 51)
.Select(item => o[item.Index]!);
}

Expand All @@ -165,7 +186,7 @@ protected override void OnTextInput(TextInputEventArgs e)
if (!e.Handled && e.Text != "\n" && e.Text != "\r")
{
IsDropDownOpen = true;
SearchTextBox.RaiseEvent(new TextInputEventArgs()
SearchTextBox.RaiseEvent(new TextInputEventArgs
{
Device = e.Device,
Handled = false,
Expand All @@ -180,6 +201,10 @@ protected override void OnTextInput(TextInputEventArgs e)

static CompletionComboBox()
{
HideButtonProperty.Changed.AddClassHandler<CompletionComboBox>((box, args) =>
{
box.PseudoClasses.Set(":hideButton", args.NewValue is true);
});
ItemTemplateProperty.Changed.AddClassHandler<CompletionComboBox>((box, args) =>
{
if (box.ButtonItemTemplate == null)
Expand Down Expand Up @@ -308,7 +333,7 @@ private TextBox SearchTextBox
}
else if (args.Key == Key.Tab)
{
SelectionAdapter.HandleKeyDown(new KeyEventArgs()
SelectionAdapter.HandleKeyDown(new KeyEventArgs
{
Device = args.Device,
Key = (args.KeyModifiers & KeyModifiers.Shift) != 0 ? Key.Up : Key.Down,
Expand Down Expand Up @@ -375,6 +400,7 @@ private void Close()
{
IsDropDownOpen = false;
FocusManager.Instance.Focus(ToggleButton, NavigationMethod.Tab);
Closed?.Invoke();
}

/// Filter logic
Expand Down
3 changes: 3 additions & 0 deletions AvaloniaStyles/Styles/Windows10/ColorsDark.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
<SolidColorBrush x:Key="TabItemHeaderBackgroundSelected" Color="#161617" />
<SolidColorBrush x:Key="TabItemHeaderBackgroundSelectedPointerOver" Color="#202021" />
<SolidColorBrush x:Key="TabItemHeaderBackgroundUnselected" Color="#202021" />

<!-- -->
<SolidColorBrush x:Key="GroupingHeaderColor" Color="#2AA0C4" />
</Styles.Resources>

<Style Selector="GridSplitter">
Expand Down
6 changes: 6 additions & 0 deletions AvaloniaStyles/Styles/Windows10/ColorsLight.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,11 @@
<SolidColorBrush x:Key="TabItemHeaderBackgroundSelected" Color="White" />
<SolidColorBrush x:Key="TabItemHeaderBackgroundSelectedPointerOver" Color="White" />
<SolidColorBrush x:Key="TabItemHeaderBackgroundUnselected" Color="#DDDDE2" />

<!-- -->
<SolidColorBrush x:Key="GroupingHeaderColor" Color="#226E8B" />
</Styles.Resources>
<Style Selector="GridSplitter">
<Setter Property="Background" Value="#CCC" />
</Style>
</Styles>
6 changes: 3 additions & 3 deletions AvaloniaStyles/Styles/Windows10/GroupingListBox.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Setter.Value>
<ControlTemplate>
<Grid VerticalAlignment="Center" DockPanel.Dock="Top" ColumnDefinitions="15,Auto,Auto,*">
<Rectangle Fill="#FF226E8B" Height="1" Margin="0,7,0,0"></Rectangle>
<Rectangle Fill="{DynamicResource GroupingHeaderColor}" Height="1" Margin="0,7,0,0"></Rectangle>
<ContentPresenter Content="{TemplateBinding CustomContent}" Grid.Column="1" Padding="3"
Margin="0,5,0,0" />
<ContentPresenter Content="{TemplateBinding GroupName}"
Expand All @@ -16,11 +16,11 @@
<ContentPresenter.Styles>
<Style Selector="TextBlock">
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Foreground" Value="#FF226E8B"/>
<Setter Property="Foreground" Value="{DynamicResource GroupingHeaderColor}"/>
</Style>
</ContentPresenter.Styles>
</ContentPresenter>
<Rectangle Grid.Column="3" Fill="#FF226E8B" Height="1" Margin="0,7,0,0"></Rectangle>
<Rectangle Grid.Column="3" Fill="{DynamicResource GroupingHeaderColor}" Height="1" Margin="0,7,0,0"></Rectangle>
</Grid>
</ControlTemplate>
</Setter.Value>
Expand Down
Loading

0 comments on commit 531b7bc

Please sign in to comment.