Skip to content

Commit

Permalink
default gitignore & searchcombobox
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Jul 23, 2024
1 parent 13153a9 commit bc6e854
Show file tree
Hide file tree
Showing 17 changed files with 326 additions and 10 deletions.
11 changes: 6 additions & 5 deletions src/OneWare.Core/Styles/IdeStyles.axaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:OneWare.Essentials.Controls;assembly=OneWare.Essentials">
<Design.PreviewWith>
<Border Padding="20">
<!-- Add Controls for Previewer Here -->
Expand Down Expand Up @@ -64,20 +65,20 @@
<Setter Property="BorderThickness" Value="0" />
</Style>

<Style Selector="ComboBox:disabled">
<Style Selector="ComboBox:disabled controls|SearchComboBox">
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" />
</Style>

<Style Selector="ComboBox">
<Style Selector="ComboBox, controls|SearchComboBox">
<Setter Property="Height" Value="24" />
<Setter Property="Padding" Value="3 1" />
</Style>

<Style Selector="ComboBox /template/ Popup > Border">
<Style Selector="ComboBox /template/ Popup > Border, controls|SearchComboBox /template/ Popup > Border">
<Setter Property="CornerRadius" Value="3" />
</Style>

<Style Selector="CheckBox, ComboBox, TextBox">
<Style Selector="CheckBox, ComboBox, TextBox, controls|SearchComboBox">
<Setter Property="CornerRadius" Value="3" />
</Style>

Expand Down
89 changes: 89 additions & 0 deletions src/OneWare.Essentials/Controls/SearchComboBox.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:OneWare.Essentials.Controls">
<Design.PreviewWith>
<controls:SearchComboBox IsDropDownOpen="True" Margin="100 0 100 100">
<ComboBoxItem Content="Test"/>
<ComboBoxItem Content="Test123"></ComboBoxItem>
</controls:SearchComboBox>
</Design.PreviewWith>

<Styles.Resources>
<ControlTheme x:Key="{x:Type controls:SearchComboBox}" TargetType="controls:SearchComboBox"
BasedOn="{StaticResource {x:Type ComboBox}}">
<Setter Property="Template">
<ControlTemplate>
<Border Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Grid ColumnDefinitions="*,Auto">
<TextBlock Name="PlaceholderTextBlock"
Grid.Column="0"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Foreground="{TemplateBinding PlaceholderForeground}"
IsVisible="{TemplateBinding SelectionBoxItem,
Converter={x:Static ObjectConverters.IsNull}}"
Text="{TemplateBinding PlaceholderText}" />
<ContentControl Margin="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}">
</ContentControl>
<ToggleButton Name="toggle"
Grid.Column="1"
Background="Transparent"
BorderThickness="0"
ClickMode="Press"
Focusable="False"
IsChecked="{TemplateBinding IsDropDownOpen,
Mode=TwoWay}">
<Path Width="8"
Height="4"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z"
Fill="{DynamicResource ThemeForegroundBrush}"
Stretch="Uniform" />
</ToggleButton>
<Popup Name="PART_Popup"
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
IsLightDismissEnabled="True"
IsOpen="{TemplateBinding IsDropDownOpen,
Mode=TwoWay}"
PlacementTarget="{TemplateBinding}"
InheritsTransform="True">
<Border Background="{DynamicResource ThemeBackgroundBrush}"
BorderBrush="{DynamicResource ThemeBorderMidBrush}"
BorderThickness="1">
<Grid RowDefinitions="Auto, Auto, Auto">
<Border Padding="2 1">
<DockPanel>
<Image DockPanel.Dock="Left" VerticalAlignment="Center" Height="14" Margin="2 0" Source="{DynamicResource VsImageLib.Search16XMd}"/>
<TextBox DockPanel.Dock="Left" VerticalAlignment="Center" Watermark="Search..." BorderThickness="0" Name="PART_SearchBox"/>
</DockPanel>
</Border>
<Border Grid.Row="1" Height="1" Margin="0 2" Background="{DynamicResource ThemeBorderLowBrush}"/>
<ScrollViewer Grid.Row="2"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
IsDeferredScrollingEnabled="{TemplateBinding (ScrollViewer.IsDeferredScrollingEnabled)}">
<ItemsPresenter Name="PART_ItemsPresenter"
ItemsPanel="{TemplateBinding ItemsPanel}" />
</ScrollViewer>
</Grid>

</Border>
</Popup>
</Grid>
</Border>
</ControlTemplate>
</Setter>
</ControlTheme>
</Styles.Resources>
</Styles>
51 changes: 51 additions & 0 deletions src/OneWare.Essentials/Controls/SearchComboBox.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Threading;

namespace OneWare.Essentials.Controls;

public class SearchComboBox : ComboBox
{
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);

var searchBox = e.NameScope.Find<TextBox>("PART_SearchBox");

searchBox!.TextChanged += (sender, args) =>
{
SelectedItem = Items.FirstOrDefault(x =>
x?.ToString()?.StartsWith(searchBox.Text ?? string.Empty, StringComparison.OrdinalIgnoreCase) ?? false);

searchBox.Focus();
};


this.DropDownOpened += (sender, args) =>
{
searchBox.Focus();
};
}

protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Down)
{
if (SelectedIndex < Items.Count - 1)
SelectedIndex++;
e.Handled = true;
return;
}
if (e.Key == Key.Up)
{
if (SelectedIndex > 0)
SelectedIndex--;
e.Handled = true;
return;
}

base.OnKeyDown(e);
}
}
1 change: 1 addition & 0 deletions src/OneWare.Essentials/Controls/SharedControls.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<ResourceDictionary />
</Styles.Resources>

<StyleInclude Source="avares://OneWare.Essentials/Controls/SearchComboBox.axaml" />
<StyleInclude Source="avares://OneWare.Essentials/Controls/UiExtensionCollection.axaml" />
</Styles>
4 changes: 4 additions & 0 deletions src/OneWare.Essentials/Services/ISettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public void RegisterTitledSlider<T>(string category, string subCategory, string
public void RegisterTitledCombo<T>(string category, string subCategory, string key, string title,
string description,
T defaultValue, params T[] options);

public void RegisterTitledComboSearch<T>(string category, string subCategory, string key, string title,
string description,
T defaultValue, params T[] options);

public T GetSettingValue<T>(string key);

Expand Down
7 changes: 7 additions & 0 deletions src/OneWare.Settings/OneWare.Settings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@
<ProjectReference Include="..\OneWare.Essentials\OneWare.Essentials.csproj"/>
</ItemGroup>

<ItemGroup>
<Compile Update="Views\SettingTypes\ComboBoxSearchSettingView.axaml.cs">
<DependentUpon>ComboBoxSearchSettingView.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>

</Project>
7 changes: 6 additions & 1 deletion src/OneWare.Settings/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,20 @@ public TextBoxSetting(string title, string description, object defaultValue, str

public class ComboBoxSetting : TitledSetting
{
public ComboBoxSetting(string title, string description, object defaultValue, IEnumerable<object> options) : base(
public ComboBoxSetting(string title, string description, object defaultValue, IEnumerable<object> options, bool isSearchable = false) : base(
title, description, defaultValue)
{
Options = options.ToArray();
IsSearchable = isSearchable;
}

public bool IsSearchable { get; }
public object[] Options { get; }
}

public class ComboBoxSearchSetting(string title, string description, object defaultValue, IEnumerable<object> options)
: ComboBoxSetting(title, description, defaultValue, options);

public class SliderSetting : TitledSetting
{
public SliderSetting(string title, string description, object defaultValue, double min, double max, double step) : base(
Expand Down
10 changes: 9 additions & 1 deletion src/OneWare.Settings/SettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,22 @@ public void RegisterTitledSlider<T>(string category, string subCategory, string
if (defaultValue == null) throw new NullReferenceException(nameof(defaultValue));
AddSetting(category, subCategory, key, new SliderSetting(title, description, defaultValue, min, max, step));
}

public void RegisterTitledCombo<T>(string category, string subCategory, string key, string title,
string description, T defaultValue, params T[] options)
{
if (defaultValue == null) throw new NullReferenceException(nameof(defaultValue));
AddSetting(category, subCategory, key,
new ComboBoxSetting(title, description, defaultValue, options.Cast<object>()));
}

public void RegisterTitledComboSearch<T>(string category, string subCategory, string key, string title,
string description, T defaultValue, params T[] options)
{
if (defaultValue == null) throw new NullReferenceException(nameof(defaultValue));
AddSetting(category, subCategory, key,
new ComboBoxSearchSetting(title, description, defaultValue, options.Cast<object>()));
}

public T GetSettingValue<T>(string key)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public ApplicationSettingsViewModel(ISettingsService settingsService, IPaths pat
foreach (var setting in subCategory.Value.Settings)
switch (setting)
{
case ComboBoxSearchSetting csS:
subCategoryModel.SettingModels.Add(new ComboBoxSearchSettingViewModel(csS));
break;
case ComboBoxSetting cS:
subCategoryModel.SettingModels.Add(new ComboBoxSettingViewModel(cS));
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace OneWare.Settings.ViewModels.SettingTypes;

public class ComboBoxSearchSettingViewModel : SettingViewModel
{
public ComboBoxSearchSettingViewModel(ComboBoxSetting setting) : base(setting)
{
Setting = setting;
}

public new ComboBoxSetting Setting { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:settingTypes="clr-namespace:OneWare.Settings.ViewModels.SettingTypes"
xmlns:controls="clr-namespace:OneWare.Essentials.Controls;assembly=OneWare.Essentials"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="OneWare.Settings.Views.SettingTypes.ComboBoxSearchSettingView"
x:DataType="settingTypes:ComboBoxSearchSettingViewModel">
<StackPanel Orientation="Vertical" Spacing="2">
<TextBlock Text="{Binding Setting.Title}"
ToolTip.Tip="{Binding Setting.Description}" />
<controls:SearchComboBox ItemsSource="{Binding Setting.Options}"
SelectedItem="{Binding Setting.Value, Mode=TwoWay}" />
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Avalonia.Controls;

namespace OneWare.Settings.Views.SettingTypes;

public partial class ComboBoxSearchSettingView : UserControl
{
public ComboBoxSearchSettingView()
{
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class UniversalFpgaProjectCreatorViewModel : FlexibleWindowViewModelBase

private readonly TextBoxSetting _nameSetting;
private readonly IProjectExplorerService _projectExplorerService;
private readonly ComboBoxSetting _templateSetting;
private readonly ComboBoxSearchSetting _templateSetting;
private readonly ComboBoxSetting _toolchainSetting;

public UniversalFpgaProjectCreatorViewModel(IPaths paths, IProjectExplorerService projectExplorerService,
Expand All @@ -35,7 +35,7 @@ public UniversalFpgaProjectCreatorViewModel(IPaths paths, IProjectExplorerServic

_nameSetting = new TextBoxSetting("Name", "Set the name for the project", "", "Enter name...");

_templateSetting = new ComboBoxSetting("Template", "Set the template used for this project", "Empty",
_templateSetting = new ComboBoxSearchSetting("Template", "Set the template used for this project", "Empty",
new[] { "Empty" }.Concat(fpgaService.Templates.Select(x => x.Name)));

_folderPathSetting = new FolderPathSetting("Location", "Set the location where the new project is created",
Expand All @@ -57,7 +57,7 @@ public UniversalFpgaProjectCreatorViewModel(IPaths paths, IProjectExplorerServic
.Select(x => x.Name)));

SettingsCollection.SettingModels.Add(new TextBoxSettingViewModel(_nameSetting));
SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_templateSetting));
SettingsCollection.SettingModels.Add(new ComboBoxSearchSettingViewModel(_templateSetting));
SettingsCollection.SettingModels.Add(new PathSettingViewModel(_folderPathSetting));
SettingsCollection.SettingModels.Add(new CheckBoxSettingViewModel(_createNewFolderSetting));
SettingsCollection.SettingModels.Add(new ComboBoxSettingViewModel(_toolchainSetting));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Quartus
output_files/
incremental_db/
db/

# MacOS
.DS_Store

# Python
*__pycache__*

# Clangd
.clangd/
.cache/
obj/
mem_init/
31 changes: 31 additions & 0 deletions src/OneWare.Verilog/Assets/Templates/BlinkVerilog/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Dump
*.vcd
*.fst
*.ghw

# IVerilog
*.vvp

# GHDL
*.cf

# Yosys
build/
*.history

# Quartus
output_files/
incremental_db/
db/

# MacOS
.DS_Store

# Python
*__pycache__*

# Clangd
.clangd/
.cache/
obj/
mem_init/
Loading

0 comments on commit bc6e854

Please sign in to comment.