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

Ribbon #546

Merged
merged 9 commits into from
Jul 31, 2024
Merged

Ribbon #546

merged 9 commits into from
Jul 31, 2024

Conversation

vgromfeld
Copy link
Contributor

@vgromfeld vgromfeld commented May 24, 2024

What?

Adding the Ribbon control to the toolkit.

See #544 and #545 for more details.

How?

I'm adding the following components to the toolkit:

  • Ribbon the ribbon control.
  • RibbonGroup an always displayed group container.
  • RibbonCollapsibleGroup a group container which can be collapsed based on a priority order if there is not enough space available to fully display the group.
  • RibbonPanel a custom panel for the Ribbon to automatically expand or collapse the RibbonCollapsibleGroups
  • RibbonStyle.xaml all the custom styles for the Ribbon components.

Usage

<Ribbon>
   <RibbonGroup Label="Selection" />
    <RibbonCollapsibleGroup Label="Edit" Style="{StaticResource RibbonLeftCollapsibleGroupStyle}" Priority="1">
        <!-- group content -->
    </RibbonCollapsibleGroup>
    <RibbonCollapsibleGroup Label="Shapes" Style="{StaticResource RibbonLeftCollapsibleGroupStyle}" Priority="2">
        <!-- group content -->
    </RibbonCollapsibleGroup>
</Ribbon>

Result

image
image

Ribbon

@mdtauk
Copy link

mdtauk commented May 27, 2024

What would be the performance and usability implications to combining this Ribbon with a SelectorBar control, to give you the same functionality of an Office like Ribbon and switching between ribbon sets?

image

@vgromfeld
Copy link
Contributor Author

It should be easy to combine the two. The SelectorBar would provide the "tabs" and the Ribbon the buttons.

@mdtauk
Copy link

mdtauk commented May 30, 2024

It should be easy to combine the two. The SelectorBar would provide the "tabs" and the Ribbon the buttons.

So you would use the Selected SelectorBarItem to load in a Ribbon?
The Ribbon itself contains RibbonGroups which contain RibbonCollapsibleGroups

I guess the Collection of Ribbons should be virtualised, so when switching to the Active Ribbon, doesn't keep them loaded? Or should all Ribbons be loaded by this theoretical Control, to enable smooth switching?

I guess this is the performance aspect I am asking about

@Tartarusome
Copy link

It should be easy to combine the two. The would provide the "tabs" and the the buttons.SelectorBar``Ribbon

So you would use the Selected SelectorBarItem to load in a Ribbon? The Ribbon itself contains RibbonGroups which contain RibbonCollapsibleGroups

I guess the Collection of Ribbons should be virtualised, so when switching to the Active Ribbon, doesn't keep them loaded? Or should all Ribbons be loaded by this theoretical Control, to enable smooth switching?

I guess this is the performance aspect I am asking about

i suppose no, the CPP file in Windows App Sdk source code dosent have a disppose method,but icon and text block resources should be autumatically disposed by XAML frame. I didnt take a test.
If you want a custom control to be visualized, you should make it inherit from IDisposable besides Control and write the dispose method.

@michael-hawker
Copy link
Member

Some build errors:

"D:\a\Labs-Windows\Labs-Windows\components\Ribbon\src\CommunityToolkit.WinUI.Controls.Ribbon.csproj" (default target) (17:93) ->
  D:\a\Labs-Windows\Labs-Windows\components\Ribbon\src\Ribbon.cs(22,21): error CS0260: Missing partial modifier on declaration of type 'Ribbon'; another partial declaration of this type exists [D:\a\Labs-Windows\Labs-Windows\components\Ribbon\src\CommunityToolkit.WinUI.Controls.Ribbon.csproj::TargetFramework=net7.0-android33.0]
  D:\a\Labs-Windows\Labs-Windows\components\Ribbon\src\RibbonCollapsibleGroup.cs(19,14): error CS0260: Missing partial modifier on declaration of type 'RibbonCollapsibleGroup'; another partial declaration of this type exists [D:\a\Labs-Windows\Labs-Windows\components\Ribbon\src\CommunityToolkit.WinUI.Controls.Ribbon.csproj::TargetFramework=net7.0-android33.0]
  D:\a\Labs-Windows\Labs-Windows\components\Ribbon\src\RibbonGroup.cs(12,14): error CS0260: Missing partial modifier on declaration of type 'RibbonGroup'; another partial declaration of this type exists [D:\a\Labs-Windows\Labs-Windows\components\Ribbon\src\CommunityToolkit.WinUI.Controls.Ribbon.csproj::TargetFramework=net7.0-android33.0]
  D:\a\Labs-Windows\Labs-Windows\components\Ribbon\src\RibbonPanel.cs(11,23): error CS0260: Missing partial modifier on declaration of type 'RibbonPanel'; another partial declaration of this type exists [D:\a\Labs-Windows\Labs-Windows\components\Ribbon\src\CommunityToolkit.WinUI.Controls.Ribbon.csproj::TargetFramework=net7.0-android33.0]

Look similar between UWP/WinUI3, looks like something going on with Uno. I think Uno requires all UI classes to be partial for the generators to work, so probably just that?

Copy link
Member

@michael-hawker michael-hawker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments, nothing too critical I don't think, but some suggestions/questions.

Comment on lines +15 to +17
<Page.Resources>
<ResourceDictionary Source="ms-appx:///CommunityToolkit.WinUI.Controls.Ribbon/RibbonStyle.xaml" />
</Page.Resources>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Arlodotexe know what might be going on here, this seems weird as we haven't seen this with other controls?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Generic.xaml file is present and working for the src project, but the Generic.xaml file isn't present in the samples project. It needs to be added.

Copy link
Member

@Arlodotexe Arlodotexe Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to implement these changes myself, didn't seem to help 🤔
No other component is using a Generic.xaml file in the sample project, it seems like something else is happening here. Investigating...

Copy link
Member

@Arlodotexe Arlodotexe Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, all the existing xaml files (resource dictionaries, controls, etc) are backed by a cs file, except for this new one. We might be auto-importing backed xaml/cs files somewhere in our tooling, but not the xaml files alone. Still investigating.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see how it works in a package and we can do a separate fix, if needed. Going to squash and merge this one.

components/Ribbon/samples/Ribbon.md Show resolved Hide resolved
components/Ribbon/samples/Ribbon.md Outdated Show resolved Hide resolved
components/Ribbon/samples/Ribbon.md Outdated Show resolved Hide resolved
components/Ribbon/samples/RibbonCustomSample.xaml Outdated Show resolved Hide resolved
components/Ribbon/src/RibbonCollapsibleGroup.cs Outdated Show resolved Hide resolved
components/Ribbon/src/RibbonCollapsibleGroup.cs Outdated Show resolved Hide resolved
components/Ribbon/src/RibbonGroup.cs Show resolved Hide resolved
components/Ribbon/src/Ribbon.cs Outdated Show resolved Hide resolved
Copy link

@0x5bfa 0x5bfa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • As a reminder, it might be also better to have a small ‘Expand’ button onto the bottom right of the label as Office apps have.

components/Ribbon/samples/RibbonCustomSample.xaml Outdated Show resolved Hide resolved
components/Ribbon/src/RibbonStyle.xaml Show resolved Hide resolved
@michael-hawker michael-hawker merged commit 01e46ab into CommunityToolkit:main Jul 31, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants