Skip to content

Commit

Permalink
fpga toolchain switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Nov 17, 2023
1 parent 4d454c8 commit 34425a0
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build/props/Base.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Version>0.12.0.5</Version>
<Version>0.12.0.6</Version>
<Authors>Hendrik Mennen</Authors>
<Company>Protop Solutions UG</Company>
<Description>The FPGA Programming Revolution</Description>
Expand Down
10 changes: 8 additions & 2 deletions src/OneWare.Core/Styles/Icons.axaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">



<DrawingImage x:Key="Octicons.KebabVertical">
<GeometryDrawing Brush="{StaticResource ThemeBorderHighBrush}" Geometry="M0,1.846 A1.846,1.846 0 1 0 3.692,1.846 A1.846,1.846 0 0 0 0,1.846 z M0,8 A1.846,1.846 0 1 0 3.692,8 A1.846,1.846 0 0 0 0,8 z M1.846,16 A1.846,1.846 0 1 1 1.846,12.31 A1.846,1.846 0 0 1 1.846,16 z" />
</DrawingImage>

<DrawingImage x:Key="MaterialDesign.KeyboardArrowDown">
<GeometryDrawing Brush="{StaticResource ThemeBorderHighBrush}" Geometry="M1.875,0 L8,6.125 L14.13,0 L16,1.875 L8,9.875 L0,1.875 z" />
</DrawingImage>

<DrawingImage x:Key="BoxIcons.RegularLogOutCircle">
<GeometryDrawing Brush="{StaticResource IconColor}" Geometry="M-3.433E-009,7.2 L4,10.4 L4,8 L11.2,8 L11.2,6.4 L4,6.4 L4,4 z M8.8,1.887E-05 C8.794,1.190E-007 8.787,1.190E-007 8.78,1.190E-007 C6.798,1.190E-007 5.005,0.8064 3.71,2.109 L3.709,2.109 L4.84,3.24 C5.898,2.183 7.304,1.6 8.8,1.6 C10.3,1.6 11.7,2.183 12.76,3.24 C13.82,4.298 14.4,5.704 14.4,7.2 C14.4,8.696 13.82,10.1 12.76,11.16 C11.7,12.22 10.3,12.8 8.8,12.8 C7.304,12.8 5.898,12.22 4.84,11.16 L3.709,12.29 C5.068,13.65 6.876,14.4 8.8,14.4 C10.72,14.4 12.53,13.65 13.89,12.29 C15.25,10.93 16,9.124 16,7.2 C16,5.276 15.25,3.468 13.89,2.109 C12.6,0.8064 10.8,1.190E-007 8.82,1.190E-007 C8.813,1.190E-007 8.806,1.887E-05 8.799,3.762E-05 L8.8,3.762E-05 z" />
</DrawingImage>
Expand Down
53 changes: 44 additions & 9 deletions src/OneWare.Core/Styles/IdeStyles.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,41 @@
</Border>
</Design.PreviewWith>

<Styles.Resources>
<ControlTheme x:Key="FlyoutNoPadding"
TargetType="FlyoutPresenter">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="0" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="Template">
<ControlTemplate>
<Border Name="LayoutRoot"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<ScrollViewer
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ContentPresenter Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter>
</ControlTheme>
</Styles.Resources>

<StyleInclude Source="avares://OneWare.Core/Styles/HostWindow.axaml" />
<StyleInclude Source="avares://OneWare.Core/Styles/Dock.axaml" />
<StyleInclude Source="avares://OneWare.Core/Styles/TreeView.axaml" />
Expand All @@ -18,11 +53,11 @@
<StyleInclude Source="avares://OneWare.Core/Styles/ScrollViewer.axaml" />
<StyleInclude Source="avares://OneWare.Core/Styles/NotificationCard.axaml" />
<StyleInclude Source="avares://OneWare.Core/Styles/DataGrid.axaml" />

<Style Selector=":is(Window)">
<Setter Property="FontFamily" Value="{StaticResource Noto Sans}"/>
<Setter Property="FontFamily" Value="{StaticResource Noto Sans}" />
</Style>

<Style Selector="Button">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
Expand All @@ -36,9 +71,9 @@
<Setter Property="Height" Value="24" />
<Setter Property="Padding" Value="3 1" />
</Style>

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

<Style Selector="ComboBoxItem">
Expand All @@ -60,8 +95,8 @@
</Style>

<Style Selector="TextBox">
<Setter Property="Padding" Value="3 2"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="3 2" />
<Setter Property="Background" Value="Transparent" />
</Style>
<Style Selector="TextBox.ToolBar">
<Setter Property="Height" Value="24" />
Expand Down Expand Up @@ -108,7 +143,7 @@
<Style Selector="Border.RoundToolBar">
<Setter Property="CornerRadius" Value="3" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}" />
<Setter Property="Height" Value="24" />
</Style>

Expand All @@ -134,5 +169,5 @@
<Setter Property="Width" Value="NaN" />
<Setter Property="Padding" Value="5 0" />
</Style>

</Styles>
2 changes: 1 addition & 1 deletion src/OneWare.ImageViewer/ViewModels/ImageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected override void UpdateCurrentFile(IFile? oldFile)
case ".svg":
var svg = new SvgSource();
var picture = svg.Load(FullPath);
if (picture is { })
if (picture is not null)
{
Image = new SvgImage()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using OneWare.Shared.Models;
using OneWare.Shared.Services;
using OneWare.UniversalFpgaProjectSystem.Models;
using OneWare.UniversalFpgaProjectSystem.Services;
using Prism.Ioc;
using Prism.Modularity;
// ReSharper disable StringLiteralTypo
Expand All @@ -23,6 +24,8 @@ public void OnInitialized(IContainerProvider containerProvider)
var settingsService = containerProvider.Resolve<ISettingsService>();
var yosysService = containerProvider.Resolve<YosysService>();

containerProvider.Resolve<FpgaService>().FpgaToolchains.Add(new YosysToolchain());

settingsService.RegisterTitledPath("Tools", "OSS Cad Suite", "OssCadSuite_Path", "OSS CAD Suite Path",
"Sets the path for the Yosys OSS CAD Suite", "", null, null, IsOssPathValid);

Expand Down
8 changes: 8 additions & 0 deletions src/OneWare.OssCadSuiteIntegration/Yosys/YosysToolchain.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using OneWare.UniversalFpgaProjectSystem.Models;

namespace OneWare.OssCadSuiteIntegration.Yosys;

public class YosysToolchain : IFpgaToolchain
{
public string Name => "Yosys";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace OneWare.UniversalFpgaProjectSystem.Models;

public interface IFpgaToolchain
{
public string Name { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public IProjectEntry? TopEntity
}
}

private IFpgaToolchain? _toolchain;

public IFpgaToolchain? Toolchain
{
get => _toolchain;
set => SetProperty(ref _toolchain, value);
}

public UniversalFpgaProjectRoot(string projectFilePath, JsonObject properties) : base(Path.GetDirectoryName(projectFilePath) ?? throw new NullReferenceException("Invalid Project Path"))
{
ProjectFilePath = projectFilePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ namespace OneWare.UniversalFpgaProjectSystem.Services;

public class FpgaService
{
public ObservableCollection<Type> FpgaModels { get; } = new();
private ObservableCollection<Type> FpgaModels { get; } = new();

public ObservableCollection<IFpgaToolchain> FpgaToolchains { get; } = new();

public void AddFpga<T>() where T : FpgaModelBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using CommunityToolkit.Mvvm.ComponentModel;
using OneWare.Shared.Services;
using OneWare.UniversalFpgaProjectSystem.Models;
using OneWare.UniversalFpgaProjectSystem.Services;
using OneWare.UniversalFpgaProjectSystem.Views;
using Prism.Ioc;

namespace OneWare.UniversalFpgaProjectSystem.ViewModels;

public class UniversalFpgaProjectToolBarViewModel : ObservableObject
{
public FpgaService FpgaService { get; }
public IProjectExplorerService ProjectExplorerService { get; }
private readonly IWindowService _windowService;
private readonly IProjectExplorerService _projectExplorerService;

private bool _longTermProgramming;

Expand All @@ -19,15 +21,25 @@ public bool LongTermProgramming
set => SetProperty(ref _longTermProgramming, value);
}

public UniversalFpgaProjectToolBarViewModel(IWindowService windowService, IProjectExplorerService projectExplorerService)
public UniversalFpgaProjectToolBarViewModel(IWindowService windowService, IProjectExplorerService projectExplorerService, FpgaService fpgaService)
{
_windowService = windowService;
_projectExplorerService = projectExplorerService;
ProjectExplorerService = projectExplorerService;
FpgaService = fpgaService;
}

public void ToggleProjectToolchain(IFpgaToolchain toolchain)
{
if (ProjectExplorerService.ActiveProject is UniversalFpgaProjectRoot project)
{
if (project.Toolchain != toolchain) project.Toolchain = toolchain;
else project.Toolchain = null;
}
}

public async Task CompileAsync()
{
if (_projectExplorerService.ActiveProject is UniversalFpgaProjectRoot project)
if (ProjectExplorerService.ActiveProject is UniversalFpgaProjectRoot project)
{
await _windowService.ShowDialogAsync(new UniversalFpgaProjectCompileView()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:OneWare.UniversalFpgaProjectSystem.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
xmlns:models="clr-namespace:OneWare.UniversalFpgaProjectSystem.Models"
xmlns:converters="clr-namespace:OneWare.Shared.Converters;assembly=OneWare.Shared"
mc:Ignorable="d"
x:Class="OneWare.UniversalFpgaProjectSystem.Views.UniversalFpgaProjectToolBarView"
x:DataType="viewModels:UniversalFpgaProjectToolBarViewModel">

Expand All @@ -16,6 +18,33 @@
<TextBlock Text="Compile" />
</StackPanel>
</Button>
<Button>
<Button.Flyout>
<Flyout FlyoutPresenterTheme="{StaticResource FlyoutNoPadding}">
<ItemsControl ItemsSource="{Binding FpgaService.FpgaToolchains}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="models:IFpgaToolchain">
<MenuItem Header="{Binding Name}"
Command="{Binding $parent[UserControl].((viewModels:UniversalFpgaProjectToolBarViewModel)DataContext).ToggleProjectToolchain, FallbackValue={x:Null}}"
CommandParameter="{Binding}">
<MenuItem.Icon>
<CheckBox BorderThickness="0">
<CheckBox.IsChecked>
<MultiBinding Converter="{x:Static converters:SharedConverters.ObjectsEqualConverter}">
<Binding Path="$parent[UserControl].((viewModels:UniversalFpgaProjectToolBarViewModel)DataContext).ProjectExplorerService.((models:UniversalFpgaProjectRoot)ActiveProject).Toolchain, FallbackValue={x:Null}}"/>
<Binding />
</MultiBinding>
</CheckBox.IsChecked>
</CheckBox>
</MenuItem.Icon>
</MenuItem>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Flyout>
</Button.Flyout>
<Image Source="{DynamicResource MaterialDesign.KeyboardArrowDown}" Width="10" Height="10"/>
</Button>
<Separator Margin="0" Width="1" Background="{DynamicResource ThemeBorderLowBrush}" Height="24" />
<Button ToolTip.Tip="Programs FPGA" Command="{Binding DownloadAsync}">
<StackPanel Orientation="Horizontal" Spacing="5">
Expand Down

0 comments on commit 34425a0

Please sign in to comment.