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

WinUI TitleBar API Spec #10056

Closed
wants to merge 1 commit into from
Closed

Conversation

karkarl
Copy link
Contributor

@karkarl karkarl commented Oct 11, 2024

This PR adds the dev and functional spec for WinUI TitleBar.

Community members can provide feedback by commenting directly on the PR, or through a code suggestion with Github tools.
Feedback should be constructive and specific, addressing potential use cases, design concerns, and functionality.

This PR will be open for feedback for a month: October 11th – November 11th
For more info on the public api review process: https://aka.ms/winappsdk/api-specs-review

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Oct 11, 2024
@karkarl karkarl mentioned this pull request Oct 11, 2024
@karkarl karkarl self-assigned this Oct 11, 2024
@karkarl karkarl removed the needs-triage Issue needs to be triaged by the area owners label Oct 11, 2024
If TitleBar is in minimal display mode, Title textbox will automatically be collapsed.
If Title string is empty, Title textbox will be collapsed.

## TitleBar.Subtitle event

Choose a reason for hiding this comment

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

Suggested change
## TitleBar.Subtitle event
## TitleBar.Subtitle property

@ghost1372
Copy link
Contributor

Are the following modes considered?

  • Right To Left
  • Dark/Light Theme support for System Context menu (Right Click on TitleBar)
  • Support Fluent (Menu Flyout) Context Menu (Disable System Context menu and using Custom Context menu)

- Punch hole through Header / Content / Footer for drag regions. Calculations needs to be updated on SizeChanged.
- Regions with hole punched through are non-draggable.

- Currently TitleBar treats all custom content as interactable and punches a whole through the drag region.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Currently TitleBar treats all custom content as interactable and punches a whole through the drag region.
- Currently TitleBar treats all custom content as interactable and punches a hole through the drag region.

- Reference Teams forward / backward button. It is draggable when disabled.

- Interactive content in TitleBar must also be capable of keyboard navigation.
They should be treated as a normal elements in the app's visual tree.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
They should be treated as a normal elements in the app's visual tree.
They should be treated as normal elements in the app's visual tree.

It is to be used in lieu of the Shell title bar for when developers want more than the basic shell title bar functionalities.

Current implementations of a custom titlebar involves the developer to fully create a user component from scratch. A notable painpoint in this process is
to manually calculate drag regions for when there are elements in the title bar (ie. AutoSuggestBox - refer to WinUI-Gallery sample). WinUI titleBar is meant
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
to manually calculate drag regions for when there are elements in the title bar (ie. AutoSuggestBox - refer to WinUI-Gallery sample). WinUI titleBar is meant
to manually calculate drag regions for when there are interactive elements in the title bar (ie. AutoSuggestBox - refer to WinUI-Gallery sample). WinUI titleBar is meant


`m_interactableElementsList`
- A list of interactable elements is tracked in the lifetime of the TitleBar.
- The list is updated everytime the specified elements' visibility changes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- The list is updated everytime the specified elements' visibility changes.
- The list is updated every time the specified elements' visibility changes.

`m_interactableElementsList`
- A list of interactable elements is tracked in the lifetime of the TitleBar.
- The list is updated everytime the specified elements' visibility changes.
- eg. `BackButton`, `PaleToggleButton`, `Header`, `Content`, `Footer`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- eg. `BackButton`, `PaleToggleButton`, `Header`, `Content`, `Footer`.
- eg. `BackButton`, `PaneToggleButton`, `Header`, `Content`, `Footer`.


# Sample scenarios

## **Scenario: Default TitleBar**
Copy link
Contributor

Choose a reason for hiding this comment

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

Multiple occasions: By MD guidance, mixing a header with formatting is...not ideal

</Window>
```

**C#**
Copy link
Contributor

Choose a reason for hiding this comment

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

Multiple occasions: the word "XAML" up above is not bold, but "C#" is?

```cs
public UIElement Header { get; set; }
```

Copy link
Contributor

@Jay-o-Way Jay-o-Way Oct 12, 2024

Choose a reason for hiding this comment

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

Colors imply something isn't as it should? Document rendering os good, so maybe it's just GitHub Diff rendering issue?
Screenshot_20241012-133842~2.png

This is typically used to populate controls such as `PersonPicture` and the "More" `AppBarButton`. The default is `null`.

### Remarks
The content property of `Content` can only be set once. Elements are right aligned by default.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The content property of `Content` can only be set once. Elements are right aligned by default.
The content property of `Footer` can only be set once. Elements are right aligned by default.

TitleBarAutomationPeer implements ...

# API Details

Copy link
Contributor

Choose a reason for hiding this comment

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

Same here
Screenshot_20241012-135153~2.png

Copy link
Contributor

Choose a reason for hiding this comment

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

What's that dotted line doing there?


# Design considerations

## AppWindow TitleBar (IXP) vs. WinUI TitleBar
Copy link
Contributor

Choose a reason for hiding this comment

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

  • What does IXP mean?
  • Please don't abbreviate a word like versus when there's no need to.

Copy link
Contributor

@Jay-o-Way Jay-o-Way Oct 15, 2024

Choose a reason for hiding this comment

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

On the left it says Tall = default, but a few images below here, this window buttons show Short even with content elements. That's inconsistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

Missing any mention of Titlebar.Height property in this file.

@Jay-o-Way
Copy link
Contributor

Jay-o-Way commented Oct 15, 2024

TitleBar currently needs to be set explicitly in the grid.row and referenced by Window in codebehind as shown above. Improvements to Window are being considered to avoid this extra grid layout and codebehind.

Yes, this is an inherent and logical result of the whole ExtendsContentIntoTitleBar concept. You're telling the app/window to hide its actual title bar. If you want a control (like this) to be used as a window's title bar, from an app's perspective, this raises the bigger question of "Is this control part of the window's content or not?"

If we could set the window's title bar properties in the following manner, then the ExtendsContentIntoTitleBar part will become unneeded. Just make sure the background of the title bar is transparent so that it show the window background.

Think of it like this:

<Window
    x:Class="App1.MainWindow"
    xmlns:local="using:App1"
    mc:Ignorable="d">

    <TitleBar x:Name="DefaultTitleBar" Title="Default TitleBar" Subtitle="Preview">
        <TitleBar.IconSource>
            <SymbolIconSource Symbol="Home"/>
        </TitleBar.IconSource>
    </TitleBar>

      <!-- App content - in the 100% correct term -->
</Window>


# Functional spec link

[Functional Spec](images/titleBar-functional-spec.md)
Copy link
Contributor

Choose a reason for hiding this comment

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

Dead link

- Custom Height - 32px as default / 48px if content != null
![TitleBar Size Variants](images/titlebar-sizevariant.png)

## Considerations

Choose a reason for hiding this comment

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

The WinUI title bar should meet Windows app design guidelines (see #9907). For example:

A single-click/tap on the icon should show system window menu.
A double-click/tap should close the window.

@aboodic
Copy link

aboodic commented Oct 22, 2024

This PR adds the dev and functional spec for WinUI TitleBar.

Community members can provide feedback by commenting directly on the PR, or through a code suggestion with Github tools.

Feedback should be constructive and specific, addressing potential use cases, design concerns, and functionality.

This PR will be open for feedback for a month: 10/11-11/11

For more info on the public api review process: https://aka.ms/winappsdk/api-specs-review

@mdtauk
Copy link
Contributor

mdtauk commented Oct 22, 2024

a month: 10/11-11/11

This took my UK brain a moment to decipher lol
11th October – 11th November right?

@duncanmacmichael
Copy link
Member

a month: 10/11-11/11

This took my UK brain a moment to decipher lol 11th October – 11th November right?

Correct :)

public class TitleBar : Control
```

## TitleBar.Header property

Choose a reason for hiding this comment

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

I'm surprised nobody has brought this up, after the heated discussions in #9700.
Header and Footer, while being concise terms, can be confusing in this context of a horizontal layout. Other terminology could be:

In the end, it will be hard to objectively decide on what's best. Personally, I prefer StartElement and EndElement here. Before and After imply the center of the title bar would have the actual content, while in most apps the center of the title bar is actually empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand the thought, but don't agree. A head is not a synonym for the top but for the leading part. Animals that are "built horizontally" have their head at the front, not on top.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm with Whiskhub here. Header/Footer is misleading. The only argument I see for keeping the naming is that TabView also got this wrong, but I'd rather you don't continue down the confusing naming and address it here with better names, like Leading and Trailing.

Choose a reason for hiding this comment

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

I'm for header/footer if they're not going to change it everywhere else at the same time.

Copy link
Contributor

Choose a reason for hiding this comment

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

As per the original feedback thread, agree and prefer Before/After #9700 (comment)

@mdtauk
Copy link
Contributor

mdtauk commented Oct 28, 2024

I hope there will be some sample, guidance, or official support for apps which use tabbed navigation within the titlebar area.

Comment on lines +384 to +385
## TitleBarTemplateSettings Class
<!-- TODO -->
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to see information on this class. I had pointed out in #9700 that this was an odd way to set the icon here, rather than just setting the icon directly on the window or titlebar instance. It feels a bit like this is just internal plumbing that is bubbling up into the public API.

@ghost1372
Copy link
Contributor

Today is November 12! 😐

@karkarl
Copy link
Contributor Author

karkarl commented Nov 12, 2024

The feedback period is up! Thank you all very much for your contributions thus far. Closing this PR while we parse through the feedback.

@karkarl karkarl closed this Nov 12, 2024
public class TitleBar : Control
```

## TitleBar.Header property
Copy link
Contributor

Choose a reason for hiding this comment

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

As per the original feedback thread, agree and prefer Before/After #9700 (comment)

Gets or sets the TitleBar's icon.

```cs
public IconSource IconSource { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Make it clear who owns the underlying icon handle here, to avoid common handle leaks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't see any talk about wiring this up to Window.Titlebar.

Comment on lines +270 to +272
## TitleBar.IconSource property

Gets or sets the TitleBar's icon.
Copy link
Contributor

@riverar riverar Nov 13, 2024

Choose a reason for hiding this comment

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

Is this going to be wired up to WM_SETICON for the notification area? (If so, I have a laundry list of things you need to keep in mind...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Spec Closed for Feedback
Development

Successfully merging this pull request may close these issues.