Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Quality: Adding ToolbarButton controls #15894

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7ab861b
Initial check in for ToolbarButton controls
mdtauk Jul 30, 2024
ea4132e
Added VisualState constants for ToolbarFlyoutButton
mdtauk Jul 30, 2024
043af93
Changed the placeholders to derive from CommandBar and AppBarButtons
mdtauk Jul 31, 2024
db09bec
Removed the CommandBar and AppBar
mdtauk Aug 1, 2024
43d98b3
Some more framework adding
mdtauk Aug 1, 2024
a6cbd02
Moved Lists to the main Toolbar Folder
mdtauk Aug 1, 2024
d58a3e6
Update ToolbarItemTypes.cs
mdtauk Aug 1, 2024
56873bb
Filling in more Properties and framework events
mdtauk Aug 3, 2024
e123178
Replaced Toolbar.Items with ItemsSource
mdtauk Aug 3, 2024
cc39610
Added basic ToolbarToggleButton template
mdtauk Aug 3, 2024
046572d
Beginnings of Toolbar Items property, and ItemsRepeater showing items
mdtauk Aug 3, 2024
c4426f3
Formatted Xaml
mdtauk Aug 3, 2024
337574e
Started adding barebones code for Toolbar Items sorting
mdtauk Aug 3, 2024
c0b9209
Added SubItems property to ToolbarItem
mdtauk Aug 4, 2024
ac8f527
Added ToolbarSeparator and moved some sub folders
mdtauk Aug 4, 2024
3f7c5f3
added muxc xml namespace to ThemeResource files
mdtauk Aug 4, 2024
5906f20
Starting work on fixing Tabbing issues
mdtauk Aug 4, 2024
1333811
Merge remote-tracking branch 'upstream/main' into mdta-ToolbarButtons
mdtauk Aug 4, 2024
1e92f5c
Update App.xaml.cs
mdtauk Aug 4, 2024
ef9a4b9
Merge remote-tracking branch 'upstream/main' into mdta-ToolbarButtons
mdtauk Aug 4, 2024
df838bb
Merge remote-tracking branch 'upstream/main' into mdta-ToolbarButtons
mdtauk Aug 4, 2024
0328429
Basic Populating of ItemsRepeater from code and Private List
mdtauk Aug 4, 2024
7dc6176
Formatted
mdtauk Aug 4, 2024
a5e6954
Updated Toolbar Button and Toggle Button visuals
mdtauk Aug 5, 2024
536beed
Merge remote-tracking branch 'upstream/main' into mdta-ToolbarButtons
mdtauk Aug 7, 2024
73141d4
Merge remote-tracking branch 'upstream/main' into mdta-ToolbarButtons
mdtauk Aug 14, 2024
5fd3328
Updated Toolbar examples to Page
mdtauk Aug 14, 2024
96460ac
Formatted XAML/C#
0x5bfa Aug 15, 2024
4cfa419
Update
0x5bfa Aug 15, 2024
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
2 changes: 1 addition & 1 deletion src/Files.App.Controls/Files.App.Controls.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Copyright (c) 2024 Files Community. Licensed under the MIT License. See the LICENSE. -->
<!-- Copyright (c) 2024 Files Community. Licensed under the MIT License. See the LICENSE. -->
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
Expand Down
24 changes: 24 additions & 0 deletions src/Files.App.Controls/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

// System
global using global::System;
global using global::System.Collections;
global using global::System.Collections.Generic;
global using global::System.Collections.ObjectModel;
global using global::System.Linq;
global using global::System.Threading;
global using global::System.Threading.Tasks;
global using global::System.ComponentModel;
global using global::System.Diagnostics;
global using global::System.Text.Json;
global using global::System.Text.Json.Serialization;
global using SystemIO = global::System.IO;

// Microsoft.UI
global using global::Microsoft.UI.Xaml;
global using global::Microsoft.UI.Xaml.Controls;
global using global::Microsoft.UI.Xaml.Controls.Primitives;

// Files.App.Controls
global using global::Files.App.Controls.Primitives;
83 changes: 83 additions & 0 deletions src/Files.App.Controls/ThemedIcon/ThemedIcon.ThemeResources.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Files.App.Controls">

<ResourceDictionary.ThemeDictionaries>

<ResourceDictionary x:Key="Default">
<Color x:Key="ThemedIconBaseColor">#DBF0F0F0</Color>
<Color x:Key="ThemedIconAltColor">#66161616</Color>

<StaticResource x:Key="ThemedIconBaseBrush" ResourceKey="ThemedIconBaseColor" />
<StaticResource x:Key="ThemedIconAltBrush" ResourceKey="ThemedIconAltColor" />
<StaticResource x:Key="ThemedIconAccentBrush" ResourceKey="AccentFillColorDefaultBrush" />
<StaticResource x:Key="ThemedIconAccentContrastBrush" ResourceKey="TextOnAccentFillColorPrimaryBrush" />
<StaticResource x:Key="ThemedIconDisabledBrush" ResourceKey="TextFillColorDisabledBrush" />
<StaticResource x:Key="ThemedIconDisabledToggleBrush" ResourceKey="TextOnAccentFillColorDisabledBrush" />

<StaticResource x:Key="ThemedIconCriticalBrush" ResourceKey="SystemFillColorCritical" />
<StaticResource x:Key="ThemedIconCautionBrush" ResourceKey="SystemFillColorCaution" />
<StaticResource x:Key="ThemedIconSuccessBrush" ResourceKey="SystemFillColorSuccess" />
<StaticResource x:Key="ThemedIconNeutralBrush" ResourceKey="SystemFillColorSolidNeutral" />

<StaticResource x:Key="ThemedIconCriticalBackgroundBrush" ResourceKey="SystemFillColorCriticalBackgroundBrush" />
<StaticResource x:Key="ThemedIconCautionBackgroundBrush" ResourceKey="SystemFillColorCautionBackgroundBrush" />
<StaticResource x:Key="ThemedIconSuccessBackgroundBrush" ResourceKey="SystemFillColorSuccessBackgroundBrush" />
<StaticResource x:Key="ThemedIconNeutralBackgroundBrush" ResourceKey="SystemFillColorNeutralBackgroundBrush" />

<x:Boolean x:Key="ThemedIconHighContrast">False</x:Boolean>
</ResourceDictionary>

<ResourceDictionary x:Key="Light">
<Color x:Key="ThemedIconBaseColor">#DB161616</Color>
<Color x:Key="ThemedIconAltColor">#66F0F0F0</Color>

<StaticResource x:Key="ThemedIconBaseBrush" ResourceKey="ThemedIconBaseColor" />
<StaticResource x:Key="ThemedIconAltBrush" ResourceKey="ThemedIconAltColor" />
<StaticResource x:Key="ThemedIconAccentBrush" ResourceKey="AccentFillColorDefaultBrush" />
<StaticResource x:Key="ThemedIconAccentContrastBrush" ResourceKey="TextOnAccentFillColorPrimaryBrush" />
<StaticResource x:Key="ThemedIconDisabledBrush" ResourceKey="TextFillColorDisabledBrush" />
<StaticResource x:Key="ThemedIconDisabledToggleBrush" ResourceKey="TextOnAccentFillColorDisabledBrush" />

<StaticResource x:Key="ThemedIconCriticalBrush" ResourceKey="SystemFillColorCritical" />
<StaticResource x:Key="ThemedIconCautionBrush" ResourceKey="SystemFillColorCaution" />
<StaticResource x:Key="ThemedIconSuccessBrush" ResourceKey="SystemFillColorSuccess" />
<StaticResource x:Key="ThemedIconNeutralBrush" ResourceKey="SystemFillColorSolidNeutral" />

<StaticResource x:Key="ThemedIconCriticalBackgroundBrush" ResourceKey="SystemFillColorCriticalBackgroundBrush" />
<StaticResource x:Key="ThemedIconCautionBackgroundBrush" ResourceKey="SystemFillColorCautionBackgroundBrush" />
<StaticResource x:Key="ThemedIconSuccessBackgroundBrush" ResourceKey="SystemFillColorSuccessBackgroundBrush" />
<StaticResource x:Key="ThemedIconNeutralBackgroundBrush" ResourceKey="SystemFillColorNeutralBackgroundBrush" />

<x:Boolean x:Key="ThemedIconHighContrast">False</x:Boolean>
</ResourceDictionary>

<ResourceDictionary x:Key="HighContrast">
<Color x:Key="ThemedIconBaseColor">#FF000000</Color>
<Color x:Key="ThemedIconAltColor">#00000000</Color>

<StaticResource x:Key="ThemedIconBaseBrush" ResourceKey="SystemColorButtonTextColorBrush" />
<StaticResource x:Key="ThemedIconAltBrush" ResourceKey="SystemColorButtonFaceColorBrush" />
<StaticResource x:Key="ThemedIconAccentBrush" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="ThemedIconAccentContrastBrush" ResourceKey="SystemColorHighlightTextColorBrush" />
<StaticResource x:Key="ThemedIconDisabledBrush" ResourceKey="SystemColorGrayTextColorBrush" />
<StaticResource x:Key="ThemedIconDisabledToggleBrush" ResourceKey="SystemColorHighlightTextColorBrush" />

<StaticResource x:Key="ThemedIconCriticalBrush" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="ThemedIconCautionBrush" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="ThemedIconSuccessBrush" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="ThemedIconNeutralBrush" ResourceKey="SystemColorHighlightColorBrush" />

<StaticResource x:Key="ThemedIconCriticalBackgroundBrush" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="ThemedIconCautionBackgroundBrush" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="ThemedIconSuccessBackgroundBrush" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="ThemedIconNeutralBackgroundBrush" ResourceKey="SystemColorWindowColorBrush" />

<x:Boolean x:Key="ThemedIconHighContrast">True</x:Boolean>
</ResourceDictionary>

</ResourceDictionary.ThemeDictionaries>

</ResourceDictionary>
97 changes: 20 additions & 77 deletions src/Files.App.Controls/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,88 +4,31 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Files.App.Controls">

<ResourceDictionary.ThemeDictionaries>

<ResourceDictionary x:Key="Default">
<Color x:Key="ThemedIconBaseColor">#DBF0F0F0</Color>
<Color x:Key="ThemedIconAltColor">#66161616</Color>

<StaticResource x:Key="ThemedIconBaseBrush" ResourceKey="ThemedIconBaseColor" />
<StaticResource x:Key="ThemedIconAltBrush" ResourceKey="ThemedIconAltColor" />
<StaticResource x:Key="ThemedIconAccentBrush" ResourceKey="AccentFillColorDefaultBrush" />
<StaticResource x:Key="ThemedIconAccentContrastBrush" ResourceKey="TextOnAccentFillColorPrimaryBrush" />
<StaticResource x:Key="ThemedIconDisabledBrush" ResourceKey="TextFillColorDisabledBrush" />
<StaticResource x:Key="ThemedIconDisabledToggleBrush" ResourceKey="TextOnAccentFillColorDisabledBrush" />

<StaticResource x:Key="ThemedIconCriticalBrush" ResourceKey="SystemFillColorCritical" />
<StaticResource x:Key="ThemedIconCautionBrush" ResourceKey="SystemFillColorCaution" />
<StaticResource x:Key="ThemedIconSuccessBrush" ResourceKey="SystemFillColorSuccess" />
<StaticResource x:Key="ThemedIconNeutralBrush" ResourceKey="SystemFillColorSolidNeutral" />

<StaticResource x:Key="ThemedIconCriticalBackgroundBrush" ResourceKey="SystemFillColorCriticalBackgroundBrush" />
<StaticResource x:Key="ThemedIconCautionBackgroundBrush" ResourceKey="SystemFillColorCautionBackgroundBrush" />
<StaticResource x:Key="ThemedIconSuccessBackgroundBrush" ResourceKey="SystemFillColorSuccessBackgroundBrush" />
<StaticResource x:Key="ThemedIconNeutralBackgroundBrush" ResourceKey="SystemFillColorNeutralBackgroundBrush" />

<x:Boolean x:Key="ThemedIconHighContrast">False</x:Boolean>
</ResourceDictionary>

<ResourceDictionary x:Key="Light">
<Color x:Key="ThemedIconBaseColor">#DB161616</Color>
<Color x:Key="ThemedIconAltColor">#66F0F0F0</Color>

<StaticResource x:Key="ThemedIconBaseBrush" ResourceKey="ThemedIconBaseColor" />
<StaticResource x:Key="ThemedIconAltBrush" ResourceKey="ThemedIconAltColor" />
<StaticResource x:Key="ThemedIconAccentBrush" ResourceKey="AccentFillColorDefaultBrush" />
<StaticResource x:Key="ThemedIconAccentContrastBrush" ResourceKey="TextOnAccentFillColorPrimaryBrush" />
<StaticResource x:Key="ThemedIconDisabledBrush" ResourceKey="TextFillColorDisabledBrush" />
<StaticResource x:Key="ThemedIconDisabledToggleBrush" ResourceKey="TextOnAccentFillColorDisabledBrush" />

<StaticResource x:Key="ThemedIconCriticalBrush" ResourceKey="SystemFillColorCritical" />
<StaticResource x:Key="ThemedIconCautionBrush" ResourceKey="SystemFillColorCaution" />
<StaticResource x:Key="ThemedIconSuccessBrush" ResourceKey="SystemFillColorSuccess" />
<StaticResource x:Key="ThemedIconNeutralBrush" ResourceKey="SystemFillColorSolidNeutral" />

<StaticResource x:Key="ThemedIconCriticalBackgroundBrush" ResourceKey="SystemFillColorCriticalBackgroundBrush" />
<StaticResource x:Key="ThemedIconCautionBackgroundBrush" ResourceKey="SystemFillColorCautionBackgroundBrush" />
<StaticResource x:Key="ThemedIconSuccessBackgroundBrush" ResourceKey="SystemFillColorSuccessBackgroundBrush" />
<StaticResource x:Key="ThemedIconNeutralBackgroundBrush" ResourceKey="SystemFillColorNeutralBackgroundBrush" />

<x:Boolean x:Key="ThemedIconHighContrast">False</x:Boolean>
</ResourceDictionary>

<ResourceDictionary x:Key="HighContrast">
<Color x:Key="ThemedIconBaseColor">#FF000000</Color>
<Color x:Key="ThemedIconAltColor">#00000000</Color>

<StaticResource x:Key="ThemedIconBaseBrush" ResourceKey="SystemColorButtonTextColorBrush" />
<StaticResource x:Key="ThemedIconAltBrush" ResourceKey="SystemColorButtonFaceColorBrush" />
<StaticResource x:Key="ThemedIconAccentBrush" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="ThemedIconAccentContrastBrush" ResourceKey="SystemColorHighlightTextColorBrush" />
<StaticResource x:Key="ThemedIconDisabledBrush" ResourceKey="SystemColorGrayTextColorBrush" />
<StaticResource x:Key="ThemedIconDisabledToggleBrush" ResourceKey="SystemColorHighlightTextColorBrush" />

<StaticResource x:Key="ThemedIconCriticalBrush" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="ThemedIconCautionBrush" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="ThemedIconSuccessBrush" ResourceKey="SystemColorHighlightColorBrush" />
<StaticResource x:Key="ThemedIconNeutralBrush" ResourceKey="SystemColorHighlightColorBrush" />

<StaticResource x:Key="ThemedIconCriticalBackgroundBrush" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="ThemedIconCautionBackgroundBrush" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="ThemedIconSuccessBackgroundBrush" ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="ThemedIconNeutralBackgroundBrush" ResourceKey="SystemColorWindowColorBrush" />
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />

<x:Boolean x:Key="ThemedIconHighContrast">True</x:Boolean>
</ResourceDictionary>
<!--#region Theme Dictionaries-->
<ResourceDictionary Source="ms-appx:///Files.App.Controls/ThemedIcon/ThemedIcon.ThemeResources.xaml" />

</ResourceDictionary.ThemeDictionaries>
<ResourceDictionary Source="ms-appx:///Files.App.Controls/Toolbar/Toolbar.ThemeResources.xaml" />
<ResourceDictionary Source="ms-appx:///Files.App.Controls/Toolbar/ToolbarSeparator/ToolbarSeparator.ThemeResources.xaml" />
<ResourceDictionary Source="ms-appx:///Files.App.Controls/Toolbar/ToolbarButton/ToolbarButton.ThemeResources.xaml" />
<ResourceDictionary Source="ms-appx:///Files.App.Controls/Toolbar/ToolbarToggleButton/ToolbarToggleButton.ThemeResources.xaml" />
<!--#endregion-->

<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!--#region ThemedIconStyles-->
<!--#region ThemedIcon-->
<ResourceDictionary Source="ms-appx:///Files.App.Controls/ThemedIcon/ThemedIcon.xaml" />
<ResourceDictionary Source="ms-appx:///Files.App.Controls/ThemedIcon/ThemedIconLayer/ThemedIconLayer.xaml" />
<!-- Icon Style Sets -->
<!--#endregion-->

<!--#region ToolbarButtons-->
<ResourceDictionary Source="ms-appx:///Files.App.Controls/Toolbar/Toolbar.xaml" />
<ResourceDictionary Source="ms-appx:///Files.App.Controls/Toolbar/ToolbarSeparator/ToolbarSeparator.xaml" />
<ResourceDictionary Source="ms-appx:///Files.App.Controls/Toolbar/ToolbarButton/ToolbarButton.xaml" />
<ResourceDictionary Source="ms-appx:///Files.App.Controls/Toolbar/ToolbarToggleButton/ToolbarToggleButton.xaml" />
<!--#endregion-->

<!--#region ThemedIcon Styles-->
<ResourceDictionary Source="ms-appx:///Files.App.Controls/ThemedIcon/Styles/Icons.Common.xaml" />
<ResourceDictionary Source="ms-appx:///Files.App.Controls/ThemedIcon/Styles/Icons.New.xaml" />
<ResourceDictionary Source="ms-appx:///Files.App.Controls/ThemedIcon/Styles/Icons.Open.xaml" />
Expand Down
12 changes: 12 additions & 0 deletions src/Files.App.Controls/Toolbar/Primitives/IToolbarItemSet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.App.Controls
{
/// <summary>
/// Interface to scope allowed items in the Private Item list
/// </summary>
public interface IToolbarItemSet
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.App.Controls
{
/// <summary>
/// Interface to scope allowed items in the Private Overflow list
/// </summary>
public interface IToolbarOverflowItemSet
{
}
}
23 changes: 23 additions & 0 deletions src/Files.App.Controls/Toolbar/Primitives/OverflowBehaviors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.App.Controls.Primitives
{
public enum OverflowBehaviors
{
/// <summary>
/// Item will move to the overflow menu if space available is too small
/// </summary>
Auto,

/// <summary>
/// Item will always appear in the overflow menu
/// </summary>
Always,

/// <summary>
/// Item will never move to the overflow menu
/// </summary>
Never,
}
}
72 changes: 72 additions & 0 deletions src/Files.App.Controls/Toolbar/Primitives/ToolbarLayout.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Windows.Foundation;

namespace Files.App.Controls.Primitives
{
public partial class ToolbarLayout : NonVirtualizingLayout
{
private Size m_availableSize;

public ToolbarLayout()
{

}

private int GetItemCount(NonVirtualizingLayoutContext context)
{
return context.Children.Count;
}

private UIElement GetElementAt(NonVirtualizingLayoutContext context , int index)
{
return context.Children[index];
}

// Measuring is performed in a single step, every element is measured, including the overflow button
// item, but the total amount of space needed is only composed of the Toolbar Items
protected override Size MeasureOverride(NonVirtualizingLayoutContext context , Size availableSize)
{
m_availableSize = availableSize;

Size accumulatedItemsSize = new(0, 0);

for (int i = 0; i < GetItemCount(context); ++i)
{
//var toolbarItem = (ToolbarItem)GetElementAt(context, i);
//toolbarItem.Measure( availableSize );

if ( i != 0 )
{
//accumulatedItemsSize.Width += toolbarItem.DesiredSize.Width;
//accumulatedItemsSize.Height = Math.Max( accumulatedItemsSize.Height , toolbarItem.DesiredSize.Height );
}
}

if ( accumulatedItemsSize.Width > availableSize.Width )
{

}
else
{

}

return accumulatedItemsSize;
}

private void ArrangeItem(UIElement breadcrumbItem , ref float accumulatedWidths , float maxElementHeight)
{
}

// Arranging is performed in a single step, as many elements are tried to be drawn going from the last element
// towards the first one, if there's not enough space, then the ellipsis button is drawn
protected override Size ArrangeOverride(NonVirtualizingLayoutContext context , Size finalSize)
{
return finalSize;
}
}
}
23 changes: 23 additions & 0 deletions src/Files.App.Controls/Toolbar/Primitives/ToolbarSizes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2024 Files Community
// Licensed under the MIT License. See the LICENSE.

namespace Files.App.Controls.Primitives
{
public enum ToolbarSizes
{
/// <summary>
/// Buttons set to 32 x 32 size
/// </summary>
Small,

/// <summary>
/// Buttons set to 32 x 32 size
/// </summary>
Medium,

/// <summary>
/// Buttons set to 40 x 40 size
/// </summary>
Large,
}
}
Loading