Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Mar 21, 2024
2 parents 37cdf20 + 1c9e875 commit 5fa9d9e
Show file tree
Hide file tree
Showing 51 changed files with 387 additions and 334 deletions.
2 changes: 1 addition & 1 deletion .build/.build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="7.0.2" />
<PackageReference Include="Nuke.Common" Version="7.0.6" />
<PackageDownload Include="GitVersion.Tool" Version="[5.12.0]" />
</ItemGroup>

Expand Down
20 changes: 20 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog for Fluent.Ribbon

## 10.1.0

- ### Bug fixes

- Simplified state was not updated when items changed
- [#1165](../../issues/1165) - ScreenTip is not DPI aware
- [#1183](../../issues/1183) - MenuItems, having a submenu, do not stay highlighted when MenuItem from the submenu is highlighted
- [#1185](../../issues/1185) - LauncherIcon not rendered correctly and items in QAT can be removed from QAT in it's popup
- [#1191](../../issues/1191) - Popup of DropDownButton/SplitButton has unwanted MinHeight

- ### Enhancements/Features

- Performance of measuring (and thus rendering) of `RibbonTabItem` (and it's contents) was improved by reducing the amount of measures required.
Most of the time there should only be one or two measure calls when switching tabs, compared to six or eight in case of the showcase application.
This is mostly achieved by getting rid of internal caching. The caching turned out to be more expensive than not caching at all.
- Added `RibbonProperties.CustomIconSize` as an attached property. This is used inside control templates to set `CustomSize` of `IconPresenter`.
- Default value of `IsHitTestVisible` is now `false` on `IconPresenter`.
- [#1177](../../issues/1177) - RibbonComboBox cannot be customized based on the original RibbonComboBox style (thanks @nishy2000)
- [#1180](../../issues/1180) - Padding and BorderBrush of the gallery control do not work (thanks @nishy2000)

## 10.0.4

- ### Bug fixes
Expand Down
4 changes: 2 additions & 2 deletions Directory.packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ItemGroup>

<ItemGroup Label="Test">
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />

<PackageVersion Include="NUnit" version="3.13.3" />
Expand All @@ -23,7 +23,7 @@
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.2.229-beta" />
<PackageVersion Include="XAMLTools.MSBuild" version="1.0.0-alpha0143" />

<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" version="4.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" version="4.7.0" />
<PackageVersion Include="StyleCop.Analyzers" version="1.2.0-beta.507" />
<PackageVersion Include="WpfAnalyzers" version="4.1.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Fluent.Ribbon.Showcase/MinimalWindowSample.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:fluent="urn:fluent-ribbon"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="window"
Title="{Binding WindowTitle, ElementName=TestContent}"
Title="MinimalWindowSample"
Width="1024"
Height="768"
MinWidth="80"
Expand Down
24 changes: 19 additions & 5 deletions Fluent.Ribbon.Showcase/TestContent.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2111,7 +2111,15 @@
<Fluent:Button Header="Refresh (Galleries)"
Command="{Binding GalleryViewModel.RefreshCommand}"
Icon="Images\Green.png"
SizeDefinition="Middle"
LargeIcon="Images\GreenLarge.png" />

<Fluent:ToggleButton x:Name="ShowHideGalleries"
Header="Show/Hide (Galleries)"
IsChecked="True"
Icon="Images\Red.png"
SizeDefinition="Middle"
LargeIcon="Images\GreenLarge.png" />

<!-- Though, you may set children of the Gallery explicitly -->
<Fluent:DropDownButton Header="Pink"
Expand Down Expand Up @@ -2165,7 +2173,8 @@
KeyTip="GG"
MaxItemsInRow="5"
MinItemsInRow="1"
ResizeMode="Both">
ResizeMode="Both"
Visibility="{Binding IsChecked, ElementName=ShowHideGalleries, Converter={StaticResource Fluent.Ribbon.Converters.BoolToVisibilityConverter}}">
<Fluent:InRibbonGallery.Filters>
<Fluent:GalleryGroupFilter x:Name="galleryFilterAll"
Title="All"
Expand Down Expand Up @@ -3528,6 +3537,11 @@
Size="Middle">
Add tab
</Fluent:Button>
<Fluent:Button Click="AddButton_OnClick"
Size="Middle"
ToolTip="Adds button to current tabs last group">
Add button
</Fluent:Button>
</WrapPanel>
</GroupBox>
<GroupBox Header="Interop">
Expand Down Expand Up @@ -3591,7 +3605,7 @@
<GroupBox Header="Issue repros">
<WrapPanel>
<WrapPanel.Resources>
<Fluent:ObjectToImageConverter x:Key="StringToImageConvert"/>
<Fluent:ObjectToImageConverter x:Key="StringToImageConvert" />
</WrapPanel.Resources>
<Fluent:Button x:Name="SleepButton"
VerticalAlignment="Top"
Expand All @@ -3608,9 +3622,9 @@
</Fluent:Button>

<Fluent:Button VerticalAlignment="Top"
Tag="/Images/Blue.png"
Icon="{Binding Path=Tag,RelativeSource={RelativeSource Self},Converter={StaticResource StringToImageConvert}}"
Size="Middle">
Icon="{Binding Path=Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource StringToImageConvert}}"
Size="Middle"
Tag="/Images/Blue.png">
ObjectToImageConverter for issue #1152
</Fluent:Button>

Expand Down
34 changes: 34 additions & 0 deletions Fluent.Ribbon.Showcase/TestContent.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace FluentTest;
using Fluent;
using Fluent.Localization;
using FluentTest.Adorners;
using FluentTest.Commanding;
using FluentTest.Helpers;
using FluentTest.ViewModels;
#if MahApps_Metro
Expand Down Expand Up @@ -51,6 +52,20 @@ public TestContent()
ColorGallery.RecentColors.Add(((SolidColorBrush)Application.Current.Resources["Fluent.Ribbon.Brushes.AccentBase"]).Color);

this.Loaded += this.TestContent_Loaded;

this.InputBindings.Add(new InputBinding(new RelayCommand(() =>
{
this.Backstage.IsOpen = !this.Backstage.IsOpen;
if (this.Backstage.IsOpen
&& this.Backstage.Content is BackstageTabControl backstageTabControl)
{
var recentTabItem = backstageTabControl.Items.OfType<BackstageTabItem>().FirstOrDefault(x => x.Header is "Recent");
if (recentTabItem is not null)
{
recentTabItem.IsSelected = true;
}
}
}), new KeyGesture(Key.F11, ModifierKeys.Control)));
}

public string WindowTitle => this.windowTitle ?? (this.windowTitle = GetVersionText(Window.GetWindow(this).GetType().BaseType));
Expand Down Expand Up @@ -389,6 +404,25 @@ private void AddRibbonTab_OnClick(object sender, RoutedEventArgs e)
this.ribbon.Tabs.Add(tab);
}

private void AddButton_OnClick(object sender, RoutedEventArgs e)
{
var group = this.ribbon.SelectedTabItem.Groups.Last();

if (group.ItemsSource is not null)
{
return;
}

var button = new Button
{
Header = "Foo",
Icon = new BitmapImage(new Uri("pack://application:,,,/Fluent.Ribbon.Showcase;component/Images/Green.png", UriKind.Absolute)),
LargeIcon = new BitmapImage(new Uri("pack://application:,,,/Fluent.Ribbon.Showcase;component/Images/GreenLarge.png", UriKind.Absolute)),
SizeDefinition = new RibbonControlSizeDefinition(RibbonControlSize.Middle, RibbonControlSize.Middle, RibbonControlSize.Middle)
};
group.Items.Add(button);
}

private async void HandleSaveAsClick(object sender, RoutedEventArgs e)
{
var progressAdornerChild = new Border
Expand Down
1 change: 1 addition & 0 deletions Fluent.Ribbon.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/PreferQualifiedReference/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/QualifiedUsingAtNestedScope/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=QAT/@EntryIndexedValue">QAT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=UI/@EntryIndexedValue">UI</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
Expand Down
29 changes: 28 additions & 1 deletion Fluent.Ribbon/AttachedProperties/RibbonProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public static bool GetIsElementInQuickAccessToolBar(DependencyObject element)

#endregion IsElementInQuickAccessToolBarProperty

#region DesiredIconSize
#region IconSize

#pragma warning disable WPF0010
/// <summary>
Expand All @@ -352,4 +352,31 @@ public static IconSize GetIconSize(DependencyObject element)
}

#endregion

#region CustomIconSize

#pragma warning disable WPF0010
/// <summary>
/// Defines the custom icon size for the element.
/// </summary>
public static readonly DependencyProperty CustomIconSizeProperty = DependencyProperty.RegisterAttached(
"CustomIconSize", typeof(Size), typeof(RibbonProperties), new PropertyMetadata(default(Size)));
#pragma warning restore WPF0010

/// <summary>Helper for setting <see cref="CustomIconSizeProperty"/> on <paramref name="element"/>.</summary>
public static void SetCustomIconSize(DependencyObject element, Size value)
{
element.SetValue(CustomIconSizeProperty, value);
}

/// <summary>Helper for getting <see cref="CustomIconSizeProperty"/> from <paramref name="element"/>.</summary>
[AttachedPropertyBrowsableForType(typeof(IRibbonControl))]
[AttachedPropertyBrowsableForType(typeof(IMediumIconProvider))]
[AttachedPropertyBrowsableForType(typeof(ILargeIconProvider))]
public static Size GetCustomIconSize(DependencyObject element)
{
return (Size)element.GetValue(CustomIconSizeProperty);
}

#endregion
}
2 changes: 1 addition & 1 deletion Fluent.Ribbon/Controls/ComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Fluent;
[TemplatePart(Name = "PART_ContentSite", Type = typeof(ContentPresenter))]
[TemplatePart(Name = "PART_ContentBorder", Type = typeof(Border))]
[TemplatePart(Name = "PART_ScrollViewer", Type = typeof(ScrollViewer))]
[DebuggerDisplay("class{GetType().FullName}: Header = {Header}, Items.Count = {Items.Count}, Size = {Size}, IsSimplified = {IsSimplified}")]
[DebuggerDisplay("{GetType().FullName}: Header = {Header}, Items.Count = {Items.Count}, Size = {Size}, IsSimplified = {IsSimplified}")]
public class ComboBox : System.Windows.Controls.ComboBox, IQuickAccessItemProvider, IRibbonControl, IDropDownControl, IMediumIconProvider, ISimplifiedRibbonControl
{
#region Fields
Expand Down
2 changes: 1 addition & 1 deletion Fluent.Ribbon/Controls/DropDownButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Fluent;
[TemplatePart(Name = "PART_Popup", Type = typeof(Popup))]
[TemplatePart(Name = "PART_PopupContentControl", Type = typeof(ResizeableContentControl))]
[TemplatePart(Name = "PART_ButtonBorder", Type = typeof(UIElement))]
[DebuggerDisplay("class{GetType().FullName}: Header = {Header}, Items.Count = {Items.Count}, Size = {Size}, IsSimplified = {IsSimplified}")]
[DebuggerDisplay("{GetType().FullName}: Header = {Header}, Items.Count = {Items.Count}, Size = {Size}, IsSimplified = {IsSimplified}")]
public class DropDownButton : ItemsControl, IQuickAccessItemProvider, IRibbonControl, IDropDownControl, ILargeIconProvider, IMediumIconProvider, ISimplifiedRibbonControl
{
#region Fields
Expand Down
13 changes: 12 additions & 1 deletion Fluent.Ribbon/Controls/GalleryPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,16 @@ public GalleryPanel()
this.visualCollection = new VisualCollection(this);

this.Loaded += this.HandleGalleryPanel_Loaded;
this.IsVisibleChanged += this.OnIsVisibleChanged;
}

private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue is true)
{
this.Loaded -= this.HandleGalleryPanel_Loaded;
this.Refresh();
}
}

private void HandleGalleryPanel_Loaded(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -299,7 +309,8 @@ public void ResumeUpdatesRefresh()
private void RefreshAsync()
{
if (this.needsRefresh
|| this.areUpdatesSuspsended)
|| this.areUpdatesSuspsended
|| this.IsLoaded is false)
{
return;
}
Expand Down
2 changes: 2 additions & 0 deletions Fluent.Ribbon/Controls/IconPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ static IconPresenter()
IsEnabledProperty.OverrideMetadata(typeof(IconPresenter), new UIPropertyMetadata(OnIsEnabledChanged));

FocusableProperty.OverrideMetadata(typeof(IconPresenter), new FrameworkPropertyMetadata(BooleanBoxes.FalseBox));

IsHitTestVisibleProperty.OverrideMetadata(typeof(IconPresenter), new UIPropertyMetadata(BooleanBoxes.FalseBox));
}

public IconPresenter()
Expand Down
37 changes: 17 additions & 20 deletions Fluent.Ribbon/Controls/InRibbonGallery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,6 @@ public InRibbonGallery()
{
ContextMenuService.Coerce(this);

this.IsVisibleChanged += this.OnIsVisibleChanged;
this.Unloaded += this.OnUnloaded;
}

Expand Down Expand Up @@ -1239,19 +1238,6 @@ public override void OnApplyTemplate()
this.popupControlPresenter = this.GetTemplateChild("PART_PopupContentPresenter") as ContentControl;
}

private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
var groupBox = UIHelper.GetParent<RibbonGroupBox>(this);

// Only notify the parent groupbox if we are not currently being shown in the collapsed popup.
// Otherwise we will cause application freezes as we would be constantly flipped between being visible and not visible.
// See https://github.com/fluentribbon/Fluent.Ribbon/issues/900 for reference
if (groupBox?.IsDropDownOpen == false)
{
groupBox.TryClearCacheAndResetStateAndScaleAndNotifyParentRibbonGroupsContainer();
}
}

private void OnPopupPreviewMouseUp(object sender, MouseButtonEventArgs e)
{
// Ignore mouse up when mouse donw is on expand button
Expand All @@ -1275,7 +1261,7 @@ private void OnExpandClick(object sender, RoutedEventArgs e)
/// <inheritdoc />
public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize current)
{
if (this.CanCollapseToButton)
if (this.CanAutomaticallyChangeIsCollapsed())
{
if (current == RibbonControlSize.Large
&& this.galleryPanel?.MinItemsInRow > this.MinItemsInRow)
Expand All @@ -1289,6 +1275,18 @@ public void OnSizePropertyChanged(RibbonControlSize previous, RibbonControlSize
}
}

private bool CanAutomaticallyChangeIsCollapsed()
{
if (this.CanCollapseToButton is false)
{
return false;
}

var valueSource = DependencyPropertyHelper.GetValueSource(this, IsCollapsedProperty);
return valueSource.BaseValueSource is BaseValueSource.Default
|| (valueSource.BaseValueSource is BaseValueSource.Local && valueSource.IsCurrent);
}

/// <inheritdoc />
protected override DependencyObject GetContainerForItemOverride()
{
Expand Down Expand Up @@ -1497,11 +1495,10 @@ public bool CanAddToQuickAccessToolBar
/// <inheritdoc />
public void ResetScale()
{
if (this.CanCollapseToButton
&& this.IsCollapsed
if (this.CanAutomaticallyChangeIsCollapsed()
&& RibbonProperties.GetSize(this) == RibbonControlSize.Large)
{
this.SetCurrentValue(IsCollapsedProperty, BooleanBoxes.FalseBox);
this.ClearValue(IsCollapsedProperty);
}

if (this.galleryPanel is not null
Expand All @@ -1516,7 +1513,7 @@ public void ResetScale()
/// <inheritdoc />
public void Enlarge()
{
if (this.CanCollapseToButton
if (this.CanAutomaticallyChangeIsCollapsed()
&& this.IsCollapsed
&& RibbonProperties.GetSize(this) == RibbonControlSize.Large)
{
Expand Down Expand Up @@ -1545,7 +1542,7 @@ public void Reduce()
{
this.galleryPanel.MaxItemsInRow = Math.Max(this.galleryPanel.MaxItemsInRow - 1, 0);
}
else if (this.CanCollapseToButton
else if (this.CanAutomaticallyChangeIsCollapsed()
&& this.IsCollapsed == false)
{
this.SetCurrentValue(IsCollapsedProperty, BooleanBoxes.TrueBox);
Expand Down
Loading

0 comments on commit 5fa9d9e

Please sign in to comment.