Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ Also, as previews that follow the main version: `TKCode.Arc.Graphics3D`, `TKCode
- `ToggleGroup` and `SegmentedControl` (`TKCode.Arc`): `SelectedItemBackground` and `SelectedItemForeground` brush properties set the fill behind the selected option (the gliding fill, or each pressed option's fill in multiple mode; the segmented pill) and its text and icon color, per instance or from a style, for backgrounds where the default selected look is hard to tell from the other options. Null (cleared) keeps the theme's colors (#227).
- `SegmentedItem` (`TKCode.Arc`) is now public (it was internal), so that XAML styles and Rider's checks can address `arc|SegmentedItem` (#231). It has a token of its own, `SegmentedItemToken` (identity `SegmentedControlItem`, because `TKCode.Arc.Mobile` already has a `SegmentedItem` token). `TKCode.Arc.Mobile` also has a `SegmentedItem` in its own namespace; a C# file that imports both namespaces aliases one side.
- `ArcWindow` / `TitleBar` / `WindowCaptionButtons` (`TKCode.Arc`): `CaptionButtonVariant` (`Round` | `Rectangle`, #230) picks the shape of the drawn caption buttons. `Round` is the default and the look is unchanged; `Rectangle` draws Windows-style flat buttons that are as tall as the title bar, 46 wide (`WindowCaptionButtonsToken.RectangleButtonWidth`), touch each other and the window's right edge (`TitleBarToken.RectangleButtonsPadding`), with square corners, and the close button turns solid danger under the pointer. Inherited, so setting it on the `ArcWindow` is enough; it applies only while the bar draws the buttons (`CaptionButtons` `Drawn`, or `Auto` outside macOS). New token entries: `WindowCaptionButtonsTokenKind.RectangleButtonWidth` and `RectangleCloseHoverForeground`, `TitleBarTokenKind.RectangleButtonsPadding`.
- `FieldVariant` (`TKCode.Arc.Core`, `Outline` default | `Ghost`) and a `Variant` property on `Select`, `Combobox`, `MultiSelect` and `DropdownMenu` ([#229](https://github.com/AIDotNet/TKCode.Arc/issues/229)). `Ghost` drops the border, the fill and the minimum width of the trigger at rest (the border keeps its thickness, so nothing shifts) and fills with `SurfaceMuted` on hover, press and open; the keyboard focus ring stays. It has a tighter horizontal padding from the new token property `GhostTriggerPadding` (8, compact 6) on `SelectToken`, `ComboboxToken` and `MultiSelectToken`. On `DropdownMenu` the built-in trigger button uses `ButtonVariant.Ghost` instead of `Secondary`. The defaults are unchanged (`Outline`).
- `DropdownMenu.Size` (`ControlSize`) for the built-in trigger button. Its default is `Small`, not `Medium` as on most controls, because the trigger was always a small button, so the default look does not change.
- The select triggers get the `:ghost` and `:raised` pseudo-classes (`Select.GhostPseudoClass`, `Select.RaisedPseudoClass`, and the same constants on `Combobox`, `MultiSelect`; `DropdownMenu.GhostPseudoClass`).

### Fixed

- `Select`, `Combobox` and `MultiSelect`: the resting fill, border (and padding, chevron margin and chip fill on `MultiSelect`) of the trigger were written as local values on the template, so the hover, pressed, open, focus and `:has-selection` styles of the theme could not override them. They are style setters now and those states show as the theme declares them (a `SurfaceMuted` fill and a stronger border while hovered, pressed or open; room for the clear button on a `MultiSelect` with a selection).
- The `ControlSize` documentation said the heights are 36 / 44 / 50; they depend on the density (36 / 44 / 50, or 28 / 34 / 40 with `ArcDensity.Compact`). Documentation only.

## 1.3.3-preview.2 - 2026-12-01

Expand Down
5 changes: 4 additions & 1 deletion src/TKCode.Arc.Core/Primitives/ControlSize.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
namespace TKCode.Arc;

/// <summary>Arc control sizes: heights 36 / 44 / 50 (ControlSizeSM / MD / LG).</summary>
/// <summary>
/// Arc control sizes (ControlSizeSM / MD / LG). The heights depend on the density: 36 / 44 / 50 by default and
/// 28 / 34 / 40 with <c>ArcDensity.Compact</c>.
/// </summary>
public enum ControlSize
{
Small,
Expand Down
14 changes: 14 additions & 0 deletions src/TKCode.Arc.Core/Primitives/FieldVariant.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace TKCode.Arc;

/// <summary>Chrome of a select-like field's trigger (<c>Select</c>, <c>Combobox</c>, <c>MultiSelect</c>, <c>DropdownMenu</c>).</summary>
public enum FieldVariant
{
/// <summary>A bordered box on the surface color: Arc's look (default).</summary>
Outline,

/// <summary>
/// No border and no fill at rest: the value and the chevron only, as wide as the content needs. Hover, press and open show
/// a muted fill; the keyboard focus ring stays visible.
/// </summary>
Ghost
}
3 changes: 3 additions & 0 deletions src/TKCode.Arc.Core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#nullable enable
TKCode.Arc.FieldVariant
TKCode.Arc.FieldVariant.Ghost = 1 -> TKCode.Arc.FieldVariant
TKCode.Arc.FieldVariant.Outline = 0 -> TKCode.Arc.FieldVariant
49 changes: 47 additions & 2 deletions src/TKCode.Arc/Menus/DropdownMenu/DropdownMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ namespace TKCode.Arc;
/// </summary>
[TemplatePart(TriggerPart, typeof(AvaloniaButton))]
[TemplatePart(TriggerPresenterPart, typeof(ContentPresenter))]
[PseudoClasses(OpenPseudoClass, CustomTriggerPseudoClass)]
[PseudoClasses(OpenPseudoClass, CustomTriggerPseudoClass, GhostPseudoClass)]
public class DropdownMenu : TemplatedControl
{
public const string TriggerPart = "PART_Trigger";
public const string TriggerPresenterPart = "PART_TriggerPresenter";
public const string OpenPseudoClass = ":open";
public const string CustomTriggerPseudoClass = ":custom-trigger";
public const string GhostPseudoClass = ":ghost";

#region 公共属性定义

Expand Down Expand Up @@ -68,6 +69,21 @@ public class DropdownMenu : TemplatedControl
public static readonly StyledProperty<object?> TriggerProperty =
AvaloniaProperty.Register<DropdownMenu, object?>(nameof(Trigger));

/// <summary>
/// Chrome of the built-in trigger button: Outline (default) keeps the bordered <c>ButtonVariant.Secondary</c> look, Ghost
/// uses <c>ButtonVariant.Ghost</c> (no border or fill at rest). A custom <see cref="Trigger"/> is not affected.
/// </summary>
public static readonly StyledProperty<FieldVariant> VariantProperty =
Select.VariantProperty.AddOwner<DropdownMenu>();

/// <summary>
/// Size of the built-in trigger button. The default is <see cref="ControlSize.Small"/> (not Medium as for most controls),
/// which is what the trigger always used, so the look does not change; set Medium or Large for a taller trigger.
/// A custom <see cref="Trigger"/> is not affected.
/// </summary>
public static readonly StyledProperty<ControlSize> SizeProperty =
Field.SizeProperty.AddOwner<DropdownMenu>(new StyledPropertyMetadata<ControlSize>(ControlSize.Small));

/// <summary>Whether the menu is open (two-way).</summary>
public static readonly StyledProperty<bool> IsOpenProperty =
AvaloniaProperty.Register<DropdownMenu, bool>(nameof(IsOpen), defaultBindingMode: BindingMode.TwoWay);
Expand Down Expand Up @@ -131,6 +147,20 @@ public object? Trigger
set => SetValue(TriggerProperty, value);
}

/// <inheritdoc cref="VariantProperty"/>
public FieldVariant Variant
{
get => GetValue(VariantProperty);
set => SetValue(VariantProperty, value);
}

/// <inheritdoc cref="SizeProperty"/>
public ControlSize Size
{
get => GetValue(SizeProperty);
set => SetValue(SizeProperty, value);
}

/// <inheritdoc cref="IsOpenProperty"/>
public bool IsOpen
{
Expand Down Expand Up @@ -274,6 +304,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
SetMenu(_trigger, Menu);
AutomationProperties.SetName(_trigger, Label);
ApplyTriggerVariant();
}
_triggerPresenter?.PropertyChanged += OnTriggerPresenterPropertyChanged;
AttachCustomTrigger(_triggerPresenter?.Child);
Expand All @@ -289,10 +320,24 @@ protected override void OnLoaded(RoutedEventArgs e)
}
}

private void ApplyTriggerVariant()
{
// The built-in trigger is a template part, so its variant is synced here: a style setter would lose to the template's value.
if (_trigger is Button button)
{
button.Variant = Variant == FieldVariant.Ghost ? ButtonVariant.Ghost : ButtonVariant.Secondary;
}
}

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == IsOpenProperty)
if (change.Property == VariantProperty)
{
PseudoClasses.Set(GhostPseudoClass, change.GetNewValue<FieldVariant>() == FieldVariant.Ghost);
ApplyTriggerVariant();
}
else if (change.Property == IsOpenProperty)
{
var open = change.GetNewValue<bool>();
PseudoClasses.Set(OpenPseudoClass, open);
Expand Down
15 changes: 14 additions & 1 deletion src/TKCode.Arc/Menus/DropdownMenu/Themes/DropdownMenuTheme.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Panel>
<arc:Button Name="PART_Trigger"
Variant="Secondary"
Size="Small"
Size="{TemplateBinding Size}"
IsPressScaleEnabled="False"
HorizontalAlignment="Left">
<StackPanel Orientation="Horizontal" Spacing="{arc:DropdownMenuTokenResource TriggerGap}">
Expand Down Expand Up @@ -68,6 +68,19 @@
<Setter Property="RenderTransform" Value="rotate(180deg)" />
</Style>

<!-- Variant=Ghost: DropdownMenu switches the trigger button to ButtonVariant.Ghost; the border stays clear while hovered, pressed or open. -->
<Style Selector="^:ghost">
<Style Selector="^ /template/ arc|Button#PART_Trigger:pointerover">
<Setter Property="BorderBrush" Value="Transparent" />
</Style>
<Style Selector="^ /template/ arc|Button#PART_Trigger:pressed">
<Setter Property="BorderBrush" Value="Transparent" />
</Style>
<Style Selector="^:open /template/ arc|Button#PART_Trigger">
<Setter Property="BorderBrush" Value="Transparent" />
</Style>
</Style>

<Style Selector="^:custom-trigger">
<Style Selector="^ /template/ arc|Button#PART_Trigger">
<Setter Property="IsVisible" Value="False" />
Expand Down
25 changes: 25 additions & 0 deletions src/TKCode.Arc/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,28 @@ TKCode.Arc.ToggleGroup.SelectedItemForeground.get -> Avalonia.Media.IBrush?
TKCode.Arc.ToggleGroup.SelectedItemForeground.set -> void
TKCode.Arc.WindowCaptionButtons.CaptionButtonVariant.get -> TKCode.Arc.CaptionButtonVariant
TKCode.Arc.WindowCaptionButtons.CaptionButtonVariant.set -> void
const TKCode.Arc.Combobox.GhostPseudoClass = ":ghost" -> string!
const TKCode.Arc.Combobox.RaisedPseudoClass = ":raised" -> string!
const TKCode.Arc.DropdownMenu.GhostPseudoClass = ":ghost" -> string!
const TKCode.Arc.MultiSelect.GhostPseudoClass = ":ghost" -> string!
const TKCode.Arc.MultiSelect.RaisedPseudoClass = ":raised" -> string!
const TKCode.Arc.Select.GhostPseudoClass = ":ghost" -> string!
const TKCode.Arc.Select.RaisedPseudoClass = ":raised" -> string!
static readonly TKCode.Arc.Combobox.VariantProperty -> Avalonia.StyledProperty<TKCode.Arc.FieldVariant>!
static readonly TKCode.Arc.DropdownMenu.SizeProperty -> Avalonia.StyledProperty<TKCode.Arc.ControlSize>!
static readonly TKCode.Arc.DropdownMenu.VariantProperty -> Avalonia.StyledProperty<TKCode.Arc.FieldVariant>!
static readonly TKCode.Arc.MultiSelect.VariantProperty -> Avalonia.StyledProperty<TKCode.Arc.FieldVariant>!
static readonly TKCode.Arc.Select.VariantProperty -> Avalonia.StyledProperty<TKCode.Arc.FieldVariant>!
TKCode.Arc.Combobox.Variant.get -> TKCode.Arc.FieldVariant
TKCode.Arc.Combobox.Variant.set -> void
TKCode.Arc.DesignTokens.ComboboxTokenKind.GhostTriggerPadding = 16 -> TKCode.Arc.DesignTokens.ComboboxTokenKind
TKCode.Arc.DesignTokens.MultiSelectTokenKind.GhostTriggerPadding = 22 -> TKCode.Arc.DesignTokens.MultiSelectTokenKind
TKCode.Arc.DesignTokens.SelectTokenKind.GhostTriggerPadding = 14 -> TKCode.Arc.DesignTokens.SelectTokenKind
TKCode.Arc.DropdownMenu.Size.get -> TKCode.Arc.ControlSize
TKCode.Arc.DropdownMenu.Size.set -> void
TKCode.Arc.DropdownMenu.Variant.get -> TKCode.Arc.FieldVariant
TKCode.Arc.DropdownMenu.Variant.set -> void
TKCode.Arc.MultiSelect.Variant.get -> TKCode.Arc.FieldVariant
TKCode.Arc.MultiSelect.Variant.set -> void
TKCode.Arc.Select.Variant.get -> TKCode.Arc.FieldVariant
TKCode.Arc.Select.Variant.set -> void
28 changes: 26 additions & 2 deletions src/TKCode.Arc/Selects/Combobox/Combobox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace TKCode.Arc;
[TemplatePart(OptionsPart, typeof(SelectOptionView))]
[TemplatePart(EmptyHostPart, typeof(PresenceHost))]
[TemplatePart(AnnouncerPart, typeof(TextBlock))]
[PseudoClasses(OpenPseudoClass)]
[PseudoClasses(GhostPseudoClass, RaisedPseudoClass, OpenPseudoClass)]
public class Combobox : SelectingItemsControl, ISelectOptionHost, ISelectFieldAutomation
{
private const string ChevronButtonPart = "PART_ChevronButton";
Expand All @@ -50,6 +50,8 @@ public class Combobox : SelectingItemsControl, ISelectOptionHost, ISelectFieldAu
public const string AnnouncerPart = "PART_Announcer";
public const string DescriptionPart = "PART_Description";
public const string OpenPseudoClass = ":open";
public const string GhostPseudoClass = ":ghost";
public const string RaisedPseudoClass = ":raised";

#region 公共属性定义

Expand Down Expand Up @@ -202,13 +204,27 @@ public string? SelectedText
public static readonly StyledProperty<ControlSize> SizeProperty =
Field.SizeProperty.AddOwner<Combobox>();

/// <summary>
/// Chrome of the box: Outline (default, bordered box) or Ghost (no border or fill at rest, width follows the content,
/// muted fill on hover, press and open). Shared with <see cref="Select"/> and <see cref="MultiSelect"/>.
/// </summary>
public static readonly StyledProperty<FieldVariant> VariantProperty =
Select.VariantProperty.AddOwner<Combobox>();

/// <summary>Trigger height: Small 36, Medium 44 (default), Large 50, as for the text fields.</summary>
public ControlSize Size
{
get => GetValue(SizeProperty);
set => SetValue(SizeProperty, value);
}

/// <inheritdoc cref="VariantProperty"/>
public FieldVariant Variant
{
get => GetValue(VariantProperty);
set => SetValue(VariantProperty, value);
}

static Combobox()
{
SelectionDataValidation.Enable<Combobox>();
Expand Down Expand Up @@ -311,7 +327,15 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == FontWeightProperty)
if (change.Property == VariantProperty)
{
PseudoClasses.Set(GhostPseudoClass, change.GetNewValue<FieldVariant>() == FieldVariant.Ghost);
}
else if (change.Property == ArcSurface.ElevationProperty)
{
PseudoClasses.Set(RaisedPseudoClass, change.GetNewValue<ArcSurfaceElevation>() == ArcSurfaceElevation.Raised);
}
else if (change.Property == FontWeightProperty)
{
_options?.SetValue(SelectOptionView.LabelFontWeightProperty, FontWeight, BindingPriority.Template);
UpdateSurfaceWidth();
Expand Down
5 changes: 5 additions & 0 deletions src/TKCode.Arc/Selects/Combobox/ComboboxToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ internal sealed class ComboboxToken : AbstractControlDesignToken
public CornerRadius ClearRingRadius { get; set; }
public CornerRadius ClearGlyphRadius { get; set; }

/// <summary>Field padding of <c>Variant=Ghost</c> (8, compact 6).</summary>
public Thickness GhostTriggerPadding { get; set; }

public override void CalculateTokenValues(bool isDarkMode)
{
base.CalculateTokenValues(isDarkMode);
GhostTriggerPadding = new Thickness(8, 0);
ClearRingRadius = new CornerRadius(14);
ClearGlyphRadius = new CornerRadius(11);
FieldPadding = new Thickness(12, 0);
Expand All @@ -65,6 +69,7 @@ public override void CalculateTokenValues(bool isDarkMode)
public override void ApplyCompact(bool isDarkMode)
{
base.ApplyCompact(isDarkMode);
GhostTriggerPadding = new Thickness(6, 0);
FieldPadding = new Thickness(10, 0);
FieldGap = 6;
ClearButtonSize = 20;
Expand Down
Loading
Loading