-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
701 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<ResourceDictionary xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:dmc="clr-namespace:Dock.Model.Controls;assembly=Dock.Model"> | ||
<Design.PreviewWith> | ||
<Border> | ||
<PinnedDockControl /> | ||
</Border> | ||
</Design.PreviewWith> | ||
|
||
<ControlTheme x:Key="{x:Type PinnedDockControl}" TargetType="PinnedDockControl"> | ||
|
||
<Setter Property="PinnedDockAlignment" Value="{CompiledBinding PinnedDock.Alignment}" x:DataType="dmc:IRootDock" /> | ||
|
||
<Setter Property="Template"> | ||
<ControlTemplate> | ||
<Grid Name="PART_PinnedDockGrid" | ||
IsVisible="{Binding !PinnedDock.IsEmpty, FallbackValue=False}" | ||
x:DataType="dmc:IRootDock" | ||
x:CompileBindings="True"> | ||
<ContentControl Content="{Binding PinnedDock}" Name="PART_PinnedDock"> | ||
<ContentControl.Styles> | ||
<Style Selector="ToolDockControl"> | ||
<Setter Property="Background"> | ||
<MultiBinding Converter="{x:Static EitherNotNullConverter.Instance}"> | ||
<CompiledBinding Path="$parent[Window].Background" /> | ||
<CompiledBinding Path="$parent[Window].TransparencyBackgroundFallback" /> | ||
</MultiBinding> | ||
</Setter> | ||
</Style> | ||
<Style Selector="ToolControl"> | ||
<Setter Property="IsHitTestVisible" Value="{CompiledBinding !$parent[DockControl].IsDraggingDock}" /> | ||
</Style> | ||
</ContentControl.Styles> | ||
</ContentControl> | ||
<GridSplitter Grid.Column="1" Grid.Row="1" Background="{CompiledBinding $parent[Window].Background, TargetNullValue={x:Static Brushes.Transparent}}" /> | ||
</Grid> | ||
</ControlTemplate> | ||
</Setter> | ||
</ControlTheme> | ||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.Metadata; | ||
using Avalonia.Controls.Primitives; | ||
using Dock.Model.Core; | ||
|
||
namespace Dock.Avalonia.Controls; | ||
|
||
/// <summary> | ||
/// Interaction logic for <see cref="PinnedDockControl"/> xaml. | ||
/// </summary> | ||
[TemplatePart("PART_PinnedDock", typeof(ContentControl)/*, IsRequired = true*/)] | ||
[TemplatePart("PART_PinnedDockGrid", typeof(Grid)/*, IsRequired = true*/)] | ||
public class PinnedDockControl : TemplatedControl | ||
{ | ||
/// <summary> | ||
/// Define the <see cref="PinnedDockAlignment"/> property. | ||
/// </summary> | ||
public static readonly StyledProperty<Alignment> PinnedDockAlignmentProperty = AvaloniaProperty.Register<PinnedDockControl, Alignment>(nameof(PinnedDockAlignment)); | ||
|
||
/// <summary> | ||
/// Gets or sets pinned dock alignment | ||
/// </summary> | ||
public Alignment PinnedDockAlignment | ||
{ | ||
get => GetValue(PinnedDockAlignmentProperty); | ||
set => SetValue(PinnedDockAlignmentProperty, value); | ||
} | ||
|
||
private Grid? _pinnedDockGrid; | ||
private ContentControl? _pinnedDock; | ||
|
||
static PinnedDockControl() | ||
{ | ||
PinnedDockAlignmentProperty.Changed.AddClassHandler<PinnedDockControl>((control, e) => control.UpdateGrid()); | ||
} | ||
|
||
private void UpdateGrid() | ||
{ | ||
if (_pinnedDockGrid == null || _pinnedDock == null) | ||
return; | ||
|
||
_pinnedDockGrid.RowDefinitions.Clear(); | ||
_pinnedDockGrid.ColumnDefinitions.Clear(); | ||
switch (PinnedDockAlignment) | ||
{ | ||
case Alignment.Unset: | ||
case Alignment.Left: | ||
_pinnedDockGrid.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto) { MinWidth = 50 }); | ||
_pinnedDockGrid.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto)); | ||
_pinnedDockGrid.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Star) { MinWidth = 50 }); | ||
Grid.SetColumn(_pinnedDock, 0); | ||
Grid.SetRow(_pinnedDock, 0); | ||
break; | ||
case Alignment.Bottom: | ||
_pinnedDockGrid.RowDefinitions.Add(new RowDefinition(GridLength.Star) { MinHeight = 50 }); | ||
_pinnedDockGrid.RowDefinitions.Add(new RowDefinition(GridLength.Auto)); | ||
_pinnedDockGrid.RowDefinitions.Add(new RowDefinition(GridLength.Auto) { MinHeight = 50 }); | ||
Grid.SetColumn(_pinnedDock, 0); | ||
Grid.SetRow(_pinnedDock, 2); | ||
break; | ||
case Alignment.Right: | ||
_pinnedDockGrid.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Star) { MinWidth = 50 }); | ||
_pinnedDockGrid.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto)); | ||
_pinnedDockGrid.ColumnDefinitions.Add(new ColumnDefinition(GridLength.Auto) { MinWidth = 50 }); | ||
Grid.SetColumn(_pinnedDock, 2); | ||
Grid.SetRow(_pinnedDock, 0); | ||
break; | ||
case Alignment.Top: | ||
_pinnedDockGrid.RowDefinitions.Add(new RowDefinition(GridLength.Auto) { MinHeight = 50 }); | ||
_pinnedDockGrid.RowDefinitions.Add(new RowDefinition(GridLength.Auto)); | ||
_pinnedDockGrid.RowDefinitions.Add(new RowDefinition(GridLength.Star) { MinHeight = 50 }); | ||
Grid.SetColumn(_pinnedDock, 1); | ||
Grid.SetRow(_pinnedDock, 0); | ||
break; | ||
default: | ||
throw new ArgumentOutOfRangeException(); | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e) | ||
{ | ||
base.OnApplyTemplate(e); | ||
_pinnedDockGrid = e.NameScope.Get<Grid>("PART_PinnedDockGrid"); | ||
_pinnedDock = e.NameScope.Get<ContentControl>("PART_PinnedDock"); | ||
UpdateGrid(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.Metadata; | ||
using Avalonia.Controls.Primitives; | ||
using Avalonia.Interactivity; | ||
using Dock.Model.Controls; | ||
|
||
namespace Dock.Avalonia.Controls; | ||
|
||
/// <summary> | ||
/// Interaction logic for <see cref="RootDockControl"/> xaml. | ||
/// </summary> | ||
[TemplatePart("PART_MainContent", typeof(ContentControl)/*, IsRequired = true*/)] | ||
public class RootDockControl : TemplatedControl | ||
{ | ||
/// <inheritdoc/> | ||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e) | ||
{ | ||
base.OnApplyTemplate(e); | ||
var mainContent = e.NameScope.Get<ContentControl>("PART_MainContent"); | ||
mainContent.AddHandler(PointerPressedEvent, (_, _) => | ||
{ | ||
if (DataContext is IRootDock rootDock) | ||
rootDock.Factory?.HidePreviewingDockables(rootDock); | ||
}, RoutingStrategies.Tunnel); | ||
} | ||
} |
Oops, something went wrong.