Skip to content

Commit

Permalink
[UX] Global Search UI
Browse files Browse the repository at this point in the history
  • Loading branch information
BAndysc committed Sep 8, 2024
1 parent 83a44a7 commit 960f938
Show file tree
Hide file tree
Showing 66 changed files with 914 additions and 268 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:WDE.SourceCodeIntegrationEditor.VisualStudioIntegration.Views">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<controls:BalloonPopup />
<BalloonPopup Content="Abcdefg" ShowTail="True" />
</Design.PreviewWith>

<Style Selector="controls|BalloonPopup">
<Style Selector="BalloonPopup">
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="Template">
<ControlTemplate>
<Panel Name="PART_RootPanel">
<Border BoxShadow="0 5 20 2 #40000000" Background="{DynamicResource TeachingTipBackground}"
<Border BoxShadow="0 5 10 2 #40000000" Background="{DynamicResource TeachingTipBackground}"
BorderThickness="1"
ClipToBounds="False"
Margin="10,-1,10,10"
CornerRadius="{DynamicResource ControlCornerRadius}"
BorderBrush="{DynamicResource TeachingTipBorderBrush}" Padding="10">
<ContentPresenter x:Name="PART_ContentPresenter"
Expand All @@ -23,21 +24,18 @@
<Path DockPanel.Dock="Top"
IsVisible="{TemplateBinding ShowTail}"
Fill="{DynamicResource TeachingTipBackground}"
HorizontalAlignment="Left"
HorizontalAlignment="{TemplateBinding TailAlignment}"
VerticalAlignment="Top"
Stroke="{DynamicResource TeachingTipBorderBrush}"
StrokeThickness="1"
Data="M0,10 L10,0 L20,10"
Margin="10,-10,0,0" />
Margin="20,-10,20,0" />
<!-- cover the tail -->
<Border Width="18" Height="2" HorizontalAlignment="Left" VerticalAlignment="Top" Background="{DynamicResource TeachingTipBackground}"
IsVisible="{TemplateBinding ShowTail}"
Margin="11,0,0,0" />
</Panel>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="controls|BalloonPopup:showtail /template/ Panel#PART_RootPanel">
<Style Selector="BalloonPopup:showtail /template/ Panel#PART_RootPanel">
<Setter Property="Margin" Value="0,10,0,0"/> <!-- space for the tail -->
</Style>
</Styles>
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Layout;

namespace WDE.SourceCodeIntegrationEditor.VisualStudioIntegration.Views;
namespace AvaloniaStyles.Controls;

public class BalloonPopup : ContentControl
{
public static readonly StyledProperty<bool> ShowTailProperty = AvaloniaProperty.Register<BalloonPopup, bool>(nameof(ShowTail));
public static readonly StyledProperty<HorizontalAlignment> TailAlignmentProperty = AvaloniaProperty.Register<BalloonPopup, HorizontalAlignment>(nameof(TailAlignment));

public bool ShowTail
{
get => GetValue(ShowTailProperty);
set => SetValue(ShowTailProperty, value);
}

public HorizontalAlignment TailAlignment
{
get => GetValue(TailAlignmentProperty);
set => SetValue(TailAlignmentProperty, value);
}

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
Expand Down
11 changes: 10 additions & 1 deletion AvaloniaStyles/Controls/ExtendedWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ public class ExtendedWindow : Window

public static readonly StyledProperty<string> SubTitleProperty =
AvaloniaProperty.Register<ExtendedWindow, string>(nameof(SubTitle));


public static readonly StyledProperty<object?> TitleContentProperty
= AvaloniaProperty.Register<ExtendedWindow, object?>(nameof (TitleContent));

public object? TitleContent
{
get => GetValue(TitleContentProperty);
set => SetValue(TitleContentProperty, value);
}

public IImage ManagedIcon
{
get => GetValue(ManagedIconProperty);
Expand Down
2 changes: 1 addition & 1 deletion AvaloniaStyles/Controls/HamburgerMenuButton.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<Style Selector="controls|HamburgerMenuButton">
<Setter Property="Template">
<ControlTemplate>
<Button Width="34" Height="34"
<Button Width="34" Height="34" Background="{TemplateBinding Background}"
IsVisible="{Binding $parent[TopLevel].(NativeMenu.Menu).Items, FallbackValue=False, Converter={StaticResource ListCountToBoolConverter}}">
<Button.Content>
<Path Fill="{Binding $parent[Button].Foreground}">
Expand Down
70 changes: 70 additions & 0 deletions AvaloniaStyles/Controls/ThreeSidesPanel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using Avalonia;
using Avalonia.Controls;

namespace AvaloniaStyles.Controls;

public class ThreeSidesPanel : Panel
{
protected override Size MeasureOverride(Size availableSize)
{
double totalWidth = 0;
double maxHeight = 0;
foreach (var child in Children)
{
child.Measure(availableSize);
maxHeight = Math.Max(maxHeight, child.DesiredSize.Height);
totalWidth += child.DesiredSize.Width;
}
return new Size(totalWidth, maxHeight);
}

protected override Size ArrangeOverride(Size finalSize)
{
double leftDesiredWidth = 0;
double rightDesiredWidth = 0;
double centerDesiredWidth = 0;
Control? leftChild = null, centerChild = null, rightChild = null;
for (var index = 0; index < Children.Count; index++)
{
var child = Children[index];
var desiredWidth = child.DesiredSize.Width;
if (index == 0)
{
leftDesiredWidth = desiredWidth;
leftChild = child;
}
else if (index == 1)
{
rightDesiredWidth = desiredWidth;
rightChild = child;
}
else if (index == 2)
{
centerDesiredWidth = 400;//desiredWidth;
centerChild = child;
}
}

var totalWidth = finalSize.Width;

var leftSpaceLeft = Math.Max(0, totalWidth / 2 - leftDesiredWidth);
var rightSpaceLeft = Math.Max(0, totalWidth / 2 - rightDesiredWidth);

var spaceLeft = leftSpaceLeft + rightSpaceLeft;
centerDesiredWidth = Math.Min(spaceLeft, centerDesiredWidth);

leftDesiredWidth = Math.Min(totalWidth - rightDesiredWidth, leftDesiredWidth);

leftChild?.Arrange(new Rect(0, 0, leftDesiredWidth, finalSize.Height));
var centerRect = new Rect(Math.Max(leftDesiredWidth, finalSize.Width / 2 - centerDesiredWidth / 2), 0,
centerDesiredWidth, finalSize.Height);
var rightRect = new Rect(finalSize.Width - rightDesiredWidth, 0, rightDesiredWidth, finalSize.Height);
var overflowRight = Math.Max(0, centerRect.Right - rightRect.Left);
centerRect = new Rect(centerRect.X - overflowRight, centerRect.Y, centerRect.Width, centerRect.Height);
centerChild?.Arrange(centerRect);
rightChild?.Arrange(rightRect);

return finalSize;
}
}
1 change: 1 addition & 0 deletions AvaloniaStyles/Styles/BigSur/ColorsDark.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<SolidColorBrush x:Key="ThemeForegroundBrush" Color="White" />
<SolidColorBrush x:Key="MainColorBackground" Color="#303032" />
<SolidColorBrush x:Key="ContentBackground" Color="#1E1E1E" />
<SolidColorBrush x:Key="TitleBarHalfButtonBackground" Opacity="0.5" Color="#1E1E1E" />
<SolidColorBrush Color="#292929" x:Key="SlightlyHighlightedBackground" />
<SolidColorBrush x:Key="ContentAlternateRowBackground" Color="#292929" />
<SolidColorBrush x:Key="MainColorForeground" Color="#EBEBEB" />
Expand Down
1 change: 1 addition & 0 deletions AvaloniaStyles/Styles/BigSur/ColorsLight.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<SolidColorBrush x:Key="ThemeForegroundBrush" Color="#282828" />
<SolidColorBrush x:Key="MainColorBackground" Color="#F6F6F6" />
<SolidColorBrush x:Key="ContentBackground" Color="White" />
<SolidColorBrush x:Key="TitleBarHalfButtonBackground" Opacity="0.5" Color="White" />
<SolidColorBrush Color="#F7F7F7" x:Key="SlightlyHighlightedBackground" />
<SolidColorBrush x:Key="ContentAlternateRowBackground" Color="#F4F5F5" />
<SolidColorBrush x:Key="MainColorForeground" Color="#282828" />
Expand Down
1 change: 1 addition & 0 deletions AvaloniaStyles/Styles/Catalina/ColorsDark.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<SolidColorBrush x:Key="ThemeForegroundBrush" Color="White" />
<SolidColorBrush x:Key="MainColorBackground" Color="#303032" />
<SolidColorBrush x:Key="ContentBackground" Color="#1E1E1E" />
<SolidColorBrush x:Key="TitleBarHalfButtonBackground" Opacity="0.5" Color="#1E1E1E" />
<SolidColorBrush Color="#292929" x:Key="SlightlyHighlightedBackground" />
<SolidColorBrush x:Key="ContentAlternateRowBackground" Color="#292929" />
<SolidColorBrush x:Key="MainColorForeground" Color="#EBEBEB" />
Expand Down
1 change: 1 addition & 0 deletions AvaloniaStyles/Styles/Catalina/ColorsLight.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<SolidColorBrush x:Key="ThemeForegroundBrush" Color="#282828" />
<SolidColorBrush x:Key="MainColorBackground" Color="#ECECEC" />
<SolidColorBrush x:Key="ContentBackground" Color="White" />
<SolidColorBrush x:Key="TitleBarHalfButtonBackground" Opacity="0.5" Color="White" />
<SolidColorBrush Color="#F7F7F7" x:Key="SlightlyHighlightedBackground" />
<SolidColorBrush x:Key="ContentAlternateRowBackground" Color="#F4F5F5" />
<SolidColorBrush x:Key="MainColorForeground" Color="#282828" />
Expand Down
1 change: 1 addition & 0 deletions AvaloniaStyles/Styles/Windows10/ColorsDark.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<SolidColorBrush Color="#3F3F45" x:Key="ContentBorderBrush" />
<SolidColorBrush Color="#252526" x:Key="ContentBackground" />
<SolidColorBrush Color="White" Opacity="0.1" x:Key="TitleBarHalfButtonBackground" />
<SolidColorBrush Color="#171718" x:Key="SlightlyHighlightedBackground" />

<SolidColorBrush Color="#252526" x:Key="ThemeBackgroundBrush" />
Expand Down
1 change: 1 addition & 0 deletions AvaloniaStyles/Styles/Windows10/ColorsLight.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<SolidColorBrush Color="#74747F" x:Key="ContentBorderBrush" />
<SolidColorBrush Color="White" x:Key="ContentBackground" />
<SolidColorBrush Color="White" Opacity="0.5" x:Key="TitleBarHalfButtonBackground" />
<SolidColorBrush Color="White" x:Key="ThemeBackgroundBrush" />
<SolidColorBrush Color="#F7F7F7" x:Key="SlightlyHighlightedBackground" />
<SolidColorBrush Color="#DAD9D8" x:Key="ThemeBorderMidBrush" />
Expand Down
1 change: 1 addition & 0 deletions AvaloniaStyles/Styles/Windows10/Style.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<StyleInclude Source="avares://AvaloniaStyles/Controls/ToolbarControl.axaml" />
<StyleInclude Source="avares://AvaloniaStyles/Controls/SettingItem.axaml" />
<StyleInclude Source="avares://AvaloniaStyles/Controls/InfoBar/InfoBar.axaml" />
<StyleInclude Source="avares://AvaloniaStyles/Controls/BalloonPopup.axaml" />

<!--<StyleInclude Source="avares://AvaloniaStyles/Styles/Windows10/TabStrip.xaml" />-->
<StyleInclude Source="avares://AvaloniaStyles/Styles/Windows10/GridSplitter.axaml" />
Expand Down
Loading

0 comments on commit 960f938

Please sign in to comment.