Skip to content

Commit

Permalink
Merge pull request #96 from mhbalthasar/Linux-Title-&-Compile-Patch
Browse files Browse the repository at this point in the history
Linux title & compile patch
  • Loading branch information
LiuYunPlayer authored Oct 25, 2024
2 parents 0bee215 + 0b2026e commit 205d21e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions TuneLab/TuneLab.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<LangVersion>latest</LangVersion>
<Version>1.5.6</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 1 addition & 3 deletions TuneLab/UI/MainWindow/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
</Grid.ColumnDefinitions>

<StackPanel Grid.Column="0" x:Name="MenuBar" HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal"/>
<StackPanel Grid.Column="1" IsHitTestVisible="False" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="{Binding $parent[Window].Title}" x:Name="TitleLabel" FontSize="12" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Column="1" x:Name="TitleBar" IsHitTestVisible="False" VerticalAlignment="Center" Orientation="Horizontal"/>
<StackPanel Grid.Column="2" x:Name="WindowControl" HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal"/>
</Grid>

Expand Down
18 changes: 12 additions & 6 deletions TuneLab/UI/MainWindow/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public partial class MainWindow : Window
{
private PlatformID platform;
private bool isCloseConfirm;
private TextBlock TitleLabel;
private Button maximizeButton;
private ButtonContent maximizeIconContent = new() { Item = new IconItem() { Icon = Assets.WindowRestore }, ColorSet = new() { Color = Style.TEXT_LIGHT.Opacity(0.6) } };

Expand All @@ -43,6 +44,9 @@ public MainWindow()
Background = Style.BACK.ToBrush();
Content.Margin = new(1, 0);

TitleLabel = new() { Text="", FontSize=12, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center, Foreground = Style.TEXT_LIGHT.ToBrush()};
TitleLabel.Bind(TextBlock.TextProperty, new Avalonia.Data.Binding{Path="Title",Source=this});

var binimizeButton = new Button() { Width = 48, Height = 40 }
.AddContent(new() { Item = new BorderItem() { CornerRadius = 0 }, ColorSet = new() { HoveredColor = Colors.White.Opacity(0.2), PressedColor = Colors.White.Opacity(0.2) } })
.AddContent(new() { Item = new IconItem() { Icon = Assets.WindowMin }, ColorSet = new() { Color = Style.TEXT_LIGHT.Opacity(0.7) } });
Expand All @@ -58,14 +62,16 @@ public MainWindow()
.AddContent(new() { Item = new IconItem() { Icon = Assets.WindowClose }, ColorSet = new() { Color = Style.TEXT_LIGHT.Opacity(0.7) } });
closeButton.Clicked += () => Close();

WindowControl.Children.Add(binimizeButton);
WindowControl.Children.Add(maximizeButton);
WindowControl.Children.Add(closeButton);

bool UseSystemTitle = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux); //Is Only Linux have double title case X11?
if(!UseSystemTitle){
WindowControl.Children.Add(binimizeButton);
WindowControl.Children.Add(maximizeButton);
WindowControl.Children.Add(closeButton);
TitleBar.Children.Add(TitleLabel);
}

this.AttachWindowStateHandler();

TitleLabel.Foreground = Style.TEXT_LIGHT.ToBrush();

mEditor = new Editor();
mEditor.Document.ProjectNameChanged.Subscribe(UpdateTitle);
mEditor.Document.StatusChanged += UpdateTitle;
Expand Down

0 comments on commit 205d21e

Please sign in to comment.