Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<!-- Marquee (drag-to-select rectangle) brushes. Accent-tinted to match the Explorer-style
rubber-band; theme-aware via SystemAccentColor, so no per-theme override is required. -->
<SolidColorBrush x:Key="GroupedTileListBoxSelectionRectangleFill"
Color="{DynamicResource SystemAccentColor}" Opacity="0.2" />
<SolidColorBrush x:Key="GroupedTileListBoxSelectionRectangleBorderBrush"
Color="{DynamicResource SystemAccentColor}" Opacity="0.8" />

<ControlTheme x:Key="{x:Type GroupedTileListBox}" TargetType="GroupedTileListBox">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="4" />
Expand Down Expand Up @@ -48,11 +41,7 @@
scrolls with content and never intercepts pointer input.
-->
<Canvas Name="PART_SelectionLayer" IsHitTestVisible="False">
<Border Name="PART_SelectionRectangle"
IsVisible="False"
BorderThickness="1"
Background="{DynamicResource GroupedTileListBoxSelectionRectangleFill}"
BorderBrush="{DynamicResource GroupedTileListBoxSelectionRectangleBorderBrush}" />
<RectangleSelectionMarquee Name="PART_SelectionRectangle" IsVisible="False" />
</Canvas>
</Panel>
</Border>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Devolutions.AvaloniaControls.Controls;
/// Items are displayed in a wrapping grid with uniform tile sizes.
/// </summary>
[TemplatePart("PART_ScrollViewer", typeof(ScrollViewer), IsRequired = true)]
[TemplatePart("PART_SelectionRectangle", typeof(Border))]
[TemplatePart("PART_SelectionRectangle", typeof(RectangleSelectionMarquee))]
[RequiresUnreferencedCode("BindingEvaluator require preserved types")]
public class GroupedTileListBox : TemplatedControl
{
Expand Down Expand Up @@ -112,7 +112,7 @@ public class GroupedTileListBox : TemplatedControl
private ItemsRepeater? itemsRepeater;
private ScrollViewer? scrollViewer;
private Control? content;
private Border? selectionRectangle;
private RectangleSelectionMarquee? selectionRectangle;

// --- Marquee (drag-to-select rectangle) state ---
// Pixels the pointer must travel from the press point before a press becomes a marquee drag
Expand Down Expand Up @@ -362,7 +362,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
this.scrollViewer = e.NameScope.Get<ScrollViewer>("PART_ScrollViewer");

// Optional: templates that omit the marquee overlay simply have no rubber-band visual.
this.selectionRectangle = e.NameScope.Find<Border>("PART_SelectionRectangle");
this.selectionRectangle = e.NameScope.Find<RectangleSelectionMarquee>("PART_SelectionRectangle");
Comment thread
xfortin-devolutions marked this conversation as resolved.

// Always create ItemsRepeater(s) dynamically in UpdateItemsRepeater
this.UpdateItemsRepeater();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<RectangleSelectionMarquee Width="100" Height="100" />
</Design.PreviewWith>

<ControlTheme x:Key="{x:Type RectangleSelectionMarquee}" TargetType="RectangleSelectionMarquee">
<Setter Property="Background" Value="{DynamicResource RectangleSelectionMarqueeFill}" />
<Setter Property="BorderBrush" Value="{DynamicResource RectangleSelectionMarqueeBorderBrush}" />
Comment thread
xfortin-devolutions marked this conversation as resolved.
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Template">
<ControlTemplate>
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" />
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Avalonia.Controls.Primitives;

namespace Devolutions.AvaloniaControls.Controls;

public class RectangleSelectionMarquee : TemplatedControl;
Comment thread
xfortin-devolutions marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<MergeResourceInclude Source="Controls/GroupedComboBox/GroupedComboBoxHeaderItem.axaml" />

<MergeResourceInclude Source="Controls/EnumPicker/EnumPicker.axaml" />

<MergeResourceInclude Source="Controls/RectangleSelectionMarquee.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,12 @@
<converters:CornerRadiusToDoubleConverter x:Key="BottomRightCornerRadiusConverter" Corner="BottomRight" />


<!-- RectangleSelectionMarquee colors -->
<SolidColorBrush x:Key="RectangleSelectionMarqueeFill"
Color="{DynamicResource SystemAccentColor}" Opacity="0.2" />
<SolidColorBrush x:Key="RectangleSelectionMarqueeBorderBrush"
Color="{DynamicResource SystemAccentColor}" Opacity="0.8" />

<!--
TextBox context menu strings. Cut/Copy/Paste come from Avalonia.Themes.Fluent's
InvariantResources.xaml, which also is English-only with no per-culture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@
<converters:CornerRadiusToDoubleConverter x:Key="BottomRightCornerRadiusConverter" Corner="BottomRight" />


<!-- RectangleSelectionMarquee colors -->
<SolidColorBrush x:Key="RectangleSelectionMarqueeFill"
Color="{DynamicResource SystemAccentColor}" Opacity="0.2" />
<SolidColorBrush x:Key="RectangleSelectionMarqueeBorderBrush"
Color="{DynamicResource SystemAccentColor}" Opacity="0.8" />


<!--
TextBox context menu strings. Cut/Copy/Paste come from Avalonia.Themes.Fluent's
InvariantResources.xaml, which also is English-only with no per-culture
Expand Down
12 changes: 12 additions & 0 deletions src/Devolutions.AvaloniaTheme.MacOS/Accents/ThemeResources.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@
<SolidColorBrush x:Key="HyperlinkButtonBorderPointerOverBrush" Color="Transparent" />
<SolidColorBrush x:Key="HyperlinkButtonBorderPressedBrush" Color="Transparent" />
<SolidColorBrush x:Key="HyperlinkButtonBorderDisabledBrush" Color="Transparent" />

<!-- RectangleSelectionMarquee colors -->
<SolidColorBrush x:Key="RectangleSelectionMarqueeFill"
Color="Black" Opacity="0.1" />
<SolidColorBrush x:Key="RectangleSelectionMarqueeBorderBrush"
Color="Black" Opacity="0.3" />

</ResourceDictionary>

Expand Down Expand Up @@ -461,6 +467,12 @@
<SolidColorBrush x:Key="HyperlinkButtonBorderPointerOverBrush" Color="Transparent" />
<SolidColorBrush x:Key="HyperlinkButtonBorderPressedBrush" Color="Transparent" />
<SolidColorBrush x:Key="HyperlinkButtonBorderDisabledBrush" Color="Transparent" />

<!-- RectangleSelectionMarquee colors -->
<SolidColorBrush x:Key="RectangleSelectionMarqueeFill"
Color="White" Opacity="0.1" />
<SolidColorBrush x:Key="RectangleSelectionMarqueeBorderBrush"
Color="White" Opacity="0.3" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,12 @@

<!-- DEVELOPMENT ONLY -->
<SolidColorBrush x:Key="SampleAppBackground" Color="{DynamicResource SystemAltHighColor}" />


<!-- RectangleSelectionMarquee colors -->
<SolidColorBrush x:Key="RectangleSelectionMarqueeFill"
Color="{DynamicResource SystemAccentColor}" Opacity="0.2" />
<SolidColorBrush x:Key="RectangleSelectionMarqueeBorderBrush"
Color="{DynamicResource SystemAccentColor}" Opacity="0.8" />

</ResourceDictionary>