Skip to content

Commit 2755932

Browse files
committed
feat: 侧边栏UI
1 parent c43ce07 commit 2755932

File tree

13 files changed

+113
-53
lines changed

13 files changed

+113
-53
lines changed

TuneLab/GUI/Assets.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal static class Assets
1111
{
1212
public static SvgIcon Eye = new("<svg width=\"12\" height=\"10\" viewBox=\"0 0 12 10\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M5.99996 1C3.09724 1 0.675952 2.71772 0.119995 4.99993C0.675887 7.2822 3.09721 9 5.99999 9C8.90271 9 11.324 7.28228 11.88 5.00007C11.3241 2.7178 8.90274 1 5.99996 1ZM6 7C7.10457 7 8 6.10457 8 5C8 3.89543 7.10457 3 6 3C4.89543 3 4 3.89543 4 5C4 6.10457 4.89543 7 6 7Z\" fill=\"white\"/>\r\n</svg>");
1313
public static SvgIcon Part = new("<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<rect x=\"0.5\" y=\"3.5\" width=\"23\" height=\"16\" rx=\"1.5\" stroke=\"white\"/>\r\n<path d=\"M0 5C0 3.89543 0.895431 3 2 3H22C23.1046 3 24 3.89543 24 5V7H0V5Z\" fill=\"white\"/>\r\n<rect x=\"3\" y=\"9\" width=\"6\" height=\"2\" fill=\"white\"/>\r\n<rect x=\"9\" y=\"15\" width=\"6\" height=\"2\" fill=\"white\"/>\r\n<rect x=\"15\" y=\"11\" width=\"6\" height=\"2\" fill=\"white\"/>\r\n</svg>");
14-
public static SvgIcon Properties = new("<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<rect y=\"2\" width=\"16\" height=\"2\" rx=\"1\" fill=\"white\"/>\r\n<rect y=\"7\" width=\"16\" height=\"2\" rx=\"1\" fill=\"white\"/>\r\n<rect y=\"12\" width=\"16\" height=\"2\" rx=\"1\" fill=\"white\"/>\r\n<circle cx=\"12\" cy=\"3\" r=\"2\" fill=\"white\"/>\r\n<circle cx=\"4\" cy=\"8\" r=\"2\" fill=\"white\"/>\r\n<circle cx=\"8\" cy=\"13\" r=\"2\" fill=\"white\"/>\r\n</svg>");
14+
public static SvgIcon Properties = new("<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<path d=\"M2 6C2 5.44772 2.44772 5 3 5H15V7H3C2.44772 7 2 6.55228 2 6V6Z\" fill=\"white\"/>\r\n<path d=\"M2 12C2 11.4477 2.44772 11 3 11H5V13H3C2.44772 13 2 12.5523 2 12V12Z\" fill=\"white\"/>\r\n<path d=\"M2 18C2 17.4477 2.44772 17 3 17H10V19H3C2.44772 19 2 18.5523 2 18V18Z\" fill=\"white\"/>\r\n<path d=\"M19 5H21C21.5523 5 22 5.44772 22 6V6C22 6.55228 21.5523 7 21 7H19V5Z\" fill=\"white\"/>\r\n<path d=\"M9 11H21C21.5523 11 22 11.4477 22 12V12C22 12.5523 21.5523 13 21 13H9V11Z\" fill=\"white\"/>\r\n<path d=\"M14 17H21C21.5523 17 22 17.4477 22 18V18C22 18.5523 21.5523 19 21 19H14V17Z\" fill=\"white\"/>\r\n<rect x=\"16\" y=\"3\" width=\"2\" height=\"6\" rx=\"1\" fill=\"white\"/>\r\n<rect x=\"6\" y=\"9\" width=\"2\" height=\"6\" rx=\"1\" fill=\"white\"/>\r\n<rect x=\"11\" y=\"15\" width=\"2\" height=\"6\" rx=\"1\" fill=\"white\"/>\r\n</svg>\r\n");
1515
public static SvgIcon Track = new("<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<g clip-path=\"url(#clip0_1327_14013)\">\r\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M11 1C11 0.447716 11.4477 0 12 0C12.5523 0 13 0.447715 13 1V5V9V10V14V15V19V23C13 23.5523 12.5523 24 12 24C11.4477 24 11 23.5523 11 23V19V15V14V10V9V5V1ZM10 5H1C0.447715 5 0 5.44772 0 6V8C0 8.55229 0.447715 9 1 9H10V5ZM10 10H9C8.44771 10 8 10.4477 8 11V13C8 13.5523 8.44771 14 9 14H10V10ZM10 15H6C5.44772 15 5 15.4477 5 16V18C5 18.5523 5.44772 19 6 19H10V15ZM14 19H18C18.5523 19 19 18.5523 19 18V16C19 15.4477 18.5523 15 18 15H14V19ZM14 14H23C23.5523 14 24 13.5523 24 13V11C24 10.4477 23.5523 10 23 10H14V14ZM14 9H15C15.5523 9 16 8.55229 16 8V6C16 5.44772 15.5523 5 15 5H14V9Z\" fill=\"white\"/>\r\n</g>\r\n<defs>\r\n<clipPath id=\"clip0_1327_14013\">\r\n<rect width=\"24\" height=\"24\" fill=\"white\"/>\r\n</clipPath>\r\n</defs>\r\n</svg>");
1616
public static SvgIcon Gain = new("<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<path d=\"M14 13V4.41421C14 3.52331 12.9229 3.07714 12.2929 3.70711L3.70711 12.2929C3.07714 12.9229 3.52331 14 4.41421 14H13C13.5523 14 14 13.5523 14 13Z\" fill=\"white\"/>\r\n</svg>");
1717
public static SvgIcon Pan = new("<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<path d=\"M14 11.17V4.83C14 3.34298 14 2.59947 13.7235 2.30969C13.4948 2.06997 13.1622 1.9591 12.8354 2.01364C12.4403 2.07958 11.9942 2.67439 11.102 3.864L8.7245 7.034C8.46197 7.38404 8.3307 7.55906 8.28133 7.75166C8.23956 7.91459 8.23956 8.08541 8.28133 8.24834C8.3307 8.44094 8.46197 8.61596 8.7245 8.966L11.102 12.136C11.9942 13.3256 12.4403 13.9204 12.8354 13.9864C13.1622 14.0409 13.4948 13.93 13.7235 13.6903C14 13.4005 14 12.657 14 11.17Z\" fill=\"white\"/>\r\n<path d=\"M2 11.17V4.83C2 3.34298 2 2.59947 2.27649 2.30969C2.50521 2.06997 2.83781 1.9591 3.16462 2.01364C3.55968 2.07958 4.00579 2.67439 4.898 3.864L7.2755 7.034C7.53803 7.38404 7.6693 7.55906 7.71867 7.75166C7.76044 7.91459 7.76044 8.08541 7.71867 8.24834C7.6693 8.44094 7.53803 8.61596 7.2755 8.966L4.898 12.136C4.00579 13.3256 3.55968 13.9204 3.16462 13.9864C2.83781 14.0409 2.50521 13.93 2.27649 13.6903C2 13.4005 2 12.657 2 11.17Z\" fill=\"white\"/>\r\n</svg>");
@@ -36,6 +36,9 @@ internal static class Assets
3636
public static SvgIcon Pause = new("<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<rect x=\"6\" y=\"4\" width=\"4\" height=\"16\" rx=\"1\" fill=\"white\"/>\r\n<rect x=\"14\" y=\"4\" width=\"4\" height=\"16\" rx=\"1\" fill=\"white\"/>\r\n</svg>");
3737
public static SvgIcon GotoStart = new("<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<g clip-path=\"url(#clip0_2010_563)\">\r\n<path d=\"M8 13.7321C6.66667 12.9623 6.66667 11.0377 8 10.2679L17 5.0718C18.3333 4.302 20 5.26425 20 6.80385V17.1962C20 18.7358 18.3333 19.698 17 18.9282L8 13.7321Z\" fill=\"white\"/>\r\n<rect x=\"4\" y=\"4\" width=\"2\" height=\"16\" rx=\"1\" fill=\"white\"/>\r\n</g>\r\n<defs>\r\n<clipPath id=\"clip0_2010_563\">\r\n<rect width=\"24\" height=\"24\" fill=\"white\"/>\r\n</clipPath>\r\n</defs>\r\n</svg>");
3838
public static SvgIcon GotoEnd = new("<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<g clip-path=\"url(#clip0_2010_562)\">\r\n<path d=\"M16 10.2679C17.3333 11.0377 17.3333 12.9623 16 13.7321L7 18.9282C5.66667 19.698 4 18.7358 4 17.1962L4 6.80385C4 5.26425 5.66667 4.302 7 5.0718L16 10.2679Z\" fill=\"white\"/>\r\n<rect x=\"18\" y=\"4\" width=\"2\" height=\"16\" rx=\"1\" fill=\"white\"/>\r\n</g>\r\n<defs>\r\n<clipPath id=\"clip0_2010_562\">\r\n<rect width=\"24\" height=\"24\" fill=\"white\"/>\r\n</clipPath>\r\n</defs>\r\n</svg>");
39+
public static SvgIcon Extensions = new("<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<g clip-path=\"url(#clip0_2097_605)\">\r\n<rect x=\"3\" y=\"14\" width=\"7\" height=\"7\" rx=\"1\" stroke=\"white\" stroke-width=\"2\"/>\r\n<rect x=\"14\" y=\"14\" width=\"7\" height=\"7\" rx=\"1\" stroke=\"white\" stroke-width=\"2\"/>\r\n<rect x=\"3\" y=\"3\" width=\"7\" height=\"7\" rx=\"1\" stroke=\"white\" stroke-width=\"2\"/>\r\n<rect x=\"17.2189\" y=\"0.718931\" width=\"7\" height=\"7\" rx=\"1\" transform=\"rotate(30 17.2189 0.718931)\" stroke=\"white\" stroke-width=\"2\"/>\r\n</g>\r\n<defs>\r\n<clipPath id=\"clip0_2097_605\">\r\n<rect width=\"24\" height=\"24\" fill=\"white\"/>\r\n</clipPath>\r\n</defs>\r\n</svg>\r\n");
40+
public static SvgIcon Settings = new("<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<circle cx=\"12\" cy=\"12\" r=\"3\" stroke=\"white\" stroke-width=\"1.5\"/>\r\n<path d=\"M13.5 4H10.5L9 7L5.5 6.5L4 9.5L6 12L4 15L5.5 17.5L9 17L10.5 20H13.5L15 17L18.5 17.5L20 15L18 12L20 9.5L18.5 6.5L15 7L13.5 4Z\" stroke=\"white\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/>\r\n</svg>");
41+
public static SvgIcon Export = new("<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<path d=\"M8 10H4V20H20V10H16\" stroke=\"white\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\r\n<path d=\"M12 14V4M12 4L9 7M12 4L15 7\" stroke=\"white\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\r\n</svg>\r\n");
3942
public static SvgIcon None = new("");
4043

4144
public static FontFamily NotoMono = new FontFamily("NotoMono");

TuneLab/GUI/IItem.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ internal class IconItem : IItem
4646
public int PivotAlignment { get; set; } = GUI.Alignment.Center;
4747
public int Alignment { get; set; } = GUI.Alignment.Center;
4848
public Point Offset { get; set; } = new Point();
49+
public double Scale { get; set; } = 1;
4950

5051
public void Paint(DrawingContext context, Rect rect, Color color)
5152
{
@@ -54,6 +55,7 @@ public void Paint(DrawingContext context, Rect rect, Color color)
5455

5556
var image = Icon.GetImage(color);
5657
var size = image.Size;
58+
size *= Scale;
5759
var anchor = Alignment.Offset(rect.Width, rect.Height);
5860
var pivot = Alignment.Offset(size.Width, size.Height);
5961
context.DrawImage(Icon.GetImage(color), new Rect(Offset.X - anchor.Item1 + pivot.Item1, Offset.Y - anchor.Item2 + pivot.Item2, size.Width, size.Height));

TuneLab/UI/MainWindow/Editor/Editor.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,19 @@ public Editor()
6464
mPianoWindow = new(this);// { VerticalAlignment = Avalonia.Layout.VerticalAlignment.Bottom };
6565
mTrackWindow = new(this);
6666
mRightSideTabBar = new();
67-
mRightSideBar = new() { Width = 280 };
67+
mRightSideBar = new() { Width = 280, Margin = new(1, 0, 0, 0) };
6868

69-
this.AddDock(mRightSideBar, Dock.Right);
69+
var panel = new DockPanel() { Background = Style.INTERFACE.ToBrush(), Margin = new(1, 0, 0, 0) };
70+
{
71+
var hoverBack = Colors.White.Opacity(0.05);
72+
var settingsButton = new GUI.Components.Button() { Width = 48, Height = 48 }
73+
.AddContent(new() { Item = new IconItem() { Icon = Assets.Settings, Scale = 4.0 / 3.0 }, ColorSet = new() { Color = Style.LIGHT_WHITE.Opacity(0.5), HoveredColor = Colors.White, PressedColor = Colors.White } });
74+
settingsButton.Clicked += () => new SettingsWindow().Show(this.Window());
75+
panel.AddDock(settingsButton, Dock.Bottom);
76+
panel.AddDock(mRightSideTabBar);
77+
}
78+
this.AddDock(panel, Dock.Right);
79+
this.AddDock(mRightSideBar, Dock.Right); mRightSideBar.IsVisible = false;
7080
this.AddDock(mTrackWindow, Dock.Top);
7181
this.AddDock(mFunctionBar, Dock.Top);
7282
this.AddDock(mPianoWindow);
@@ -105,6 +115,19 @@ public Editor()
105115
ProjectProvider.When(project => project.Tracks.ItemAdded).Subscribe(track => { if (track.Parts.Contains(mEditingPart)) SwitchEditingPart(mEditingPart); });
106116
mPianoWindow.PartProvider.ObjectChanged.Subscribe(() => { mPianoWindow.IsVisible = mPianoWindow.Part != null; mPropertySideBarContentProvider.SetPart(mPianoWindow.Part); }, s);
107117

118+
mRightSideTabBar.SelectedTab.Modified.Subscribe(() =>
119+
{
120+
mRightSideBar.IsVisible = true;
121+
switch (mRightSideTabBar.SelectedTab.Value)
122+
{
123+
case SideBarTab.Properties:
124+
mRightSideBar.SetContent(mPropertySideBarContentProvider.Content);
125+
break;
126+
default:
127+
mRightSideBar.IsVisible = false;
128+
break;
129+
}
130+
});
108131
mRightSideBar.SetContent(mPropertySideBarContentProvider.Content);
109132

110133
AddHandler(DragDrop.DropEvent, OnDrop);

TuneLab/UI/MainWindow/Editor/FunctionBar/FunctionBar.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,9 @@ public FunctionBar(IDependency dependency)
4646
{
4747
var hoverBack = Colors.White.Opacity(0.05);
4848

49-
var collapseTextItem = new TextItem() { Text = "Hide Properties".Tr(this) };
50-
var collapseButton = new Toggle() { Width = 120, Height = 32 };
51-
collapseButton
52-
.AddContent(new() { Item = new BorderItem() { CornerRadius = 4 }, ColorSet = new() { Color = Style.ITEM } })
53-
.AddContent(new() { Item = collapseTextItem, ColorSet = new() { Color = Style.LIGHT_WHITE } });
54-
collapseButton.IsChecked = true;
55-
collapseButton.Switched.Subscribe(() => { collapseTextItem.Text = collapseButton.IsChecked ? "Hide Properties".Tr(this) : "Show Properties".Tr(this); CollapsePropertiesAsked?.Invoke(collapseButton.IsChecked); });
56-
dockPanel.AddDock(collapseButton, Dock.Right);
57-
58-
dockPanel.AddDock(new Border() { Width = 12, Background = Brushes.Transparent, IsHitTestVisible = false }, Dock.Right);
59-
6049
void SetupToolTip(Control toggleButton,string ToolTipText)
6150
{
62-
ToolTip.SetPlacement(toggleButton, PlacementMode.Top);
63-
ToolTip.SetVerticalOffset(toggleButton, -8);
64-
ToolTip.SetShowDelay(toggleButton, 0);
65-
ToolTip.SetTip(toggleButton, ToolTipText);
51+
toggleButton.SetupToolTip(ToolTipText, PlacementMode.Top, verticalOffset: -8);
6652
}
6753

6854
var audioControlPanel = new StackPanel() { Orientation = Avalonia.Layout.Orientation.Horizontal, Spacing = 12, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center, Margin = new(12, 0) };

TuneLab/UI/MainWindow/Editor/PianoWindow/SideBar/SideTabBar.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

TuneLab/UI/MainWindow/Editor/PianoWindow/SideBar/ISideBarContentProvider.cs renamed to TuneLab/UI/MainWindow/Editor/SideBar/ISideBarContentProvider.cs

File renamed without changes.

TuneLab/UI/MainWindow/Editor/PianoWindow/SideBar/MidiPartFixedController.cs renamed to TuneLab/UI/MainWindow/Editor/SideBar/Properties/MidiPartFixedController.cs

File renamed without changes.

TuneLab/UI/MainWindow/Editor/PianoWindow/SideBar/PropertySideBarContentProvider.cs renamed to TuneLab/UI/MainWindow/Editor/SideBar/Properties/PropertySideBarContentProvider.cs

File renamed without changes.

TuneLab/UI/MainWindow/Editor/PianoWindow/SideBar/SideBar.cs renamed to TuneLab/UI/MainWindow/Editor/SideBar/SideBar.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,16 @@ public SideBar()
2626
{
2727
Focusable = true;
2828
IsTabStop = false;
29-
var title = new DockPanel() { Height = 48, Background = Style.INTERFACE.ToBrush(), Margin = new(1, 0), VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top };
29+
var title = new DockPanel() { Height = 48, Background = Style.INTERFACE.ToBrush(), VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top };
3030
{
31-
var border = new Border() { Height = 1, Background = Style.BACK.ToBrush() };
32-
title.Children.Add(border);
33-
DockPanel.SetDock(border, Dock.Bottom);
34-
mIcon = new Image() { Width = 16, Height = 16, Margin = new(24, 16, 16, 16) };
35-
title.Children.Add(mIcon);
36-
DockPanel.SetDock(mIcon, Dock.Left);
31+
mIcon = new Image() { Width = 24, Height = 24, Margin = new(24, 12, 16, 12) };
32+
title.AddDock(mIcon, Dock.Left);
3733
mName = new Label() { FontSize = 16, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center, Foreground = Style.TEXT_LIGHT.ToBrush() };
38-
title.Children.Add(mName);
34+
title.AddDock(mName);
3935
}
40-
Children.Add(title);
41-
DockPanel.SetDock(title, Dock.Top);
42-
43-
mListView.Content.Margin = new Thickness(1, 0);
44-
Children.Add(mListView);
36+
this.AddDock(title, Dock.Top);
37+
this.AddDock(new Border() { Height = 1, Background = Style.BACK.ToBrush() }, Dock.Top);
38+
this.AddDock(mListView);
4539
}
4640

4741
public void SetContent(SideBarContent content)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace TuneLab.UI;
8+
9+
internal enum SideBarTab
10+
{
11+
None,
12+
Extensions,
13+
Properties,
14+
Export,
15+
}

0 commit comments

Comments
 (0)