diff --git a/src/AtomUI.Controls/TabControl/BaseTabControl.cs b/src/AtomUI.Controls/TabControl/BaseTabControl.cs index b39048dea..b813fcc7f 100644 --- a/src/AtomUI.Controls/TabControl/BaseTabControl.cs +++ b/src/AtomUI.Controls/TabControl/BaseTabControl.cs @@ -89,17 +89,12 @@ public class BaseTabControl : AvaloniaTabControl, string IControlSharedTokenResourcesHost.TokenId => TabControlToken.ID; #endregion - - private Border? _frame; + private Panel? _alignWrapper; private Point _tabStripBorderStartPoint; private Point _tabStripBorderEndPoint; - private CompositeDisposable? _resourceBindingsDisposable; - CompositeDisposable? IResourceBindingManager.ResourceBindingsDisposable - { - get => _resourceBindingsDisposable; - set => _resourceBindingsDisposable = value; - } + + CompositeDisposable? IResourceBindingManager.ResourceBindingsDisposable { get; set; } static BaseTabControl() { @@ -117,14 +112,7 @@ public class BaseTabControl : AvaloniaTabControl, protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); - _frame = e.NameScope.Find(TabControlThemeConstants.FramePart); _alignWrapper = e.NameScope.Find(TabControlThemeConstants.AlignWrapperPart); - if (_frame is not null) - { - this.AddResourceBindingDisposable(TokenResourceBinder.CreateTokenBinding(this, BorderThicknessProperty, - SharedTokenKey.BorderThickness, BindingPriority.Template, - new RenderScaleAwareThicknessConfigure(this))); - } } protected override void PrepareContainerForItemOverride(Control container, object? item, int index) @@ -139,8 +127,9 @@ public class BaseTabControl : AvaloniaTabControl, protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnAttachedToLogicalTree(e); - this.AddResourceBindingDisposable(TokenResourceBinder.CreateTokenBinding(this, TabAndContentGutterProperty, - TabControlTokenKey.TabAndContentGutter)); + this.AddResourceBindingDisposable(TokenResourceBinder.CreateTokenBinding(this, BorderThicknessProperty, + SharedTokenKey.BorderThickness, BindingPriority.Template, + new RenderScaleAwareThicknessConfigure(this))); } protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) diff --git a/src/AtomUI.Controls/TabControl/BaseTabScrollViewer.cs b/src/AtomUI.Controls/TabControl/BaseTabScrollViewer.cs index ada663967..2bc0185bf 100644 --- a/src/AtomUI.Controls/TabControl/BaseTabScrollViewer.cs +++ b/src/AtomUI.Controls/TabControl/BaseTabScrollViewer.cs @@ -1,9 +1,5 @@ using System.Globalization; -using System.Reactive.Disposables; using AtomUI.Controls.Themes; -using AtomUI.Theme; -using AtomUI.Theme.Data; -using AtomUI.Theme.Styling; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.Converters; @@ -22,8 +18,7 @@ namespace AtomUI.Controls; [TemplatePart(TabScrollViewerThemeConstants.ScrollEndEdgeIndicatorPart, typeof(Control))] [TemplatePart(TabScrollViewerThemeConstants.ScrollMenuIndicatorPart, typeof(IconButton))] [TemplatePart(TabScrollViewerThemeConstants.ScrollViewContentPart, typeof(ScrollContentPresenter))] -internal abstract class BaseTabScrollViewer : ScrollViewer, - IResourceBindingManager +internal abstract class BaseTabScrollViewer : ScrollViewer { private const int EdgeIndicatorZIndex = 1000; @@ -44,8 +39,8 @@ internal abstract class BaseTabScrollViewer : ScrollViewer, o => o.MenuEdgeThickness, (o, v) => o.MenuEdgeThickness = v); - internal static readonly StyledProperty IsMotionEnabledProperty - = MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner(); + internal static readonly StyledProperty IsMotionEnabledProperty = + MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner(); private Dock _tabStripPlacement; @@ -77,19 +72,12 @@ internal abstract class BaseTabScrollViewer : ScrollViewer, set => SetValue(IsMotionEnabledProperty, value); } - CompositeDisposable? IResourceBindingManager.ResourceBindingsDisposable - { - get => _resourceBindingsDisposable; - set => _resourceBindingsDisposable = value; - } - #endregion private protected IconButton? _menuIndicator; private protected Border? _startEdgeIndicator; private protected Border? _endEdgeIndicator; private protected MenuFlyout? _menuFlyout; - private CompositeDisposable? _resourceBindingsDisposable; static BaseTabScrollViewer() { @@ -213,22 +201,6 @@ internal abstract class BaseTabScrollViewer : ScrollViewer, SetupIndicatorsVisibility(); } - protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) - { - base.OnAttachedToVisualTree(e); - _resourceBindingsDisposable = new CompositeDisposable(); - this.AddResourceBindingDisposable(TokenResourceBinder.CreateTokenBinding(this, EdgeShadowStartColorProperty, - SharedTokenKey.ColorFillSecondary)); - this.AddResourceBindingDisposable(TokenResourceBinder.CreateTokenBinding(this, MenuEdgeThicknessProperty, - TabControlTokenKey.MenuEdgeThickness)); - } - - protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) - { - base.OnDetachedFromVisualTree(e); - this.DisposeTokenBindings(); - } - protected override Size MeasureOverride(Size availableSize) { var size = base.MeasureOverride(availableSize); diff --git a/src/AtomUI.Controls/TabControl/TabStrip/BaseTabStrip.cs b/src/AtomUI.Controls/TabControl/TabStrip/BaseTabStrip.cs index 389655b8d..333bf6c9e 100644 --- a/src/AtomUI.Controls/TabControl/TabStrip/BaseTabStrip.cs +++ b/src/AtomUI.Controls/TabControl/TabStrip/BaseTabStrip.cs @@ -1,5 +1,4 @@ using System.Reactive.Disposables; -using AtomUI.Controls.Themes; using AtomUI.Data; using AtomUI.Theme; using AtomUI.Theme.Data; @@ -7,7 +6,6 @@ using AtomUI.Theme.Styling; using AtomUI.Theme.Utils; using Avalonia; using Avalonia.Controls; -using Avalonia.Controls.Primitives; using Avalonia.Controls.Templates; using Avalonia.Data; using Avalonia.LogicalTree; @@ -70,17 +68,10 @@ public abstract class BaseTabStrip : AvaloniaTabStrip, Control IMotionAwareControl.PropertyBindTarget => this; Control IControlSharedTokenResourcesHost.HostControl => this; string IControlSharedTokenResourcesHost.TokenId => TabControlToken.ID; - CompositeDisposable? IResourceBindingManager.ResourceBindingsDisposable - { - get => _resourceBindingsDisposable; - set => _resourceBindingsDisposable = value; - } + CompositeDisposable? IResourceBindingManager.ResourceBindingsDisposable { get; set; } #endregion - private Border? _frame; - private CompositeDisposable? _resourceBindingsDisposable; - static BaseTabStrip() { ItemsPanelProperty.OverrideDefaultValue(DefaultPanel); @@ -94,19 +85,6 @@ public abstract class BaseTabStrip : AvaloniaTabStrip, this.RegisterResources(); } - protected override void OnApplyTemplate(TemplateAppliedEventArgs e) - { - base.OnApplyTemplate(e); - _frame = e.NameScope.Find(TabStripThemeConstants.FramePart); - UpdatePseudoClasses(); - if (_frame is not null) - { - this.AddResourceBindingDisposable(TokenResourceBinder.CreateTokenBinding(this, BorderThicknessProperty, - SharedTokenKey.BorderThickness, BindingPriority.Template, - new RenderScaleAwareThicknessConfigure(this))); - } - } - protected override void PrepareContainerForItemOverride(Control container, object? item, int index) { base.PrepareContainerForItemOverride(container, item, index); @@ -118,6 +96,14 @@ public abstract class BaseTabStrip : AvaloniaTabStrip, } } + protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) + { + base.OnAttachedToLogicalTree(e); + this.AddResourceBindingDisposable(TokenResourceBinder.CreateTokenBinding(this, BorderThicknessProperty, + SharedTokenKey.BorderThickness, BindingPriority.Template, + new RenderScaleAwareThicknessConfigure(this))); + } + protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { base.OnDetachedFromLogicalTree(e); diff --git a/src/AtomUI.Controls/TabControl/Themes/BaseTabControlTheme.axaml b/src/AtomUI.Controls/TabControl/Themes/BaseTabControlTheme.axaml index f6448c2fa..412577fd8 100644 --- a/src/AtomUI.Controls/TabControl/Themes/BaseTabControlTheme.axaml +++ b/src/AtomUI.Controls/TabControl/Themes/BaseTabControlTheme.axaml @@ -8,6 +8,7 @@