Skip to content

style: add titlebar control#784

Open
United600 wants to merge 15 commits intomainfrom
United600/titlebar
Open

style: add titlebar control#784
United600 wants to merge 15 commits intomainfrom
United600/titlebar

Conversation

@United600
Copy link
Collaborator

@United600 United600 commented Feb 21, 2026

Replaces custom title bars with reusable TitleBar control.

  • Adds a new modular TitleBar control supporting header, content, footer, icon, and title properties, as well as customizable caption button colors and height modes
  • Removes legacy title bar code and updates MainPage and PlayerPage to use the new control
  • Replaces MainPage and PlayerPage drag region and caption button color updates with TitleBar control
  • Removes theme and caption button color handling logic from App initialization
  • Adds NavigationView CompactPaneOverlay visual state
  • Removes TitleBarHelper and related code
  • Makes the media info in the MiniPlayer clickable (returns to the immersive view)

@United600 United600 requested a review from Copilot February 21, 2026 19:10
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Feb 21, 2026
@dosubot
Copy link

dosubot bot commented Feb 21, 2026

Related Documentation

Checked 0 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@dosubot dosubot bot added the enhancement New feature or request label Feb 21, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a comprehensive custom TitleBar control to replace manual title bar management, centralizing customization capabilities and simplifying the codebase. The new control provides extensive customization through dependency properties for caption button colors, content layout (Header/Content/Footer), icon, title, and height modes.

Changes:

  • Added a new TitleBar custom control with full XAML template, dependency properties, automation peer, and supporting types
  • Updated MainPage and PlayerPage to use the new TitleBar control instead of manual title bar handling
  • Removed TitleBarHelper.cs and related theme change handling from App.xaml.cs, as this logic is now encapsulated in the TitleBar control

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Screenbox/Themes/Generic.xaml New generic resource dictionary that references the TitleBar control template
Screenbox/Screenbox.csproj Added TitleBar source files and removed TitleBarHelper.cs
Screenbox/Pages/PlayerPage.xaml.cs Replaced manual title bar setup with TitleBar.SetDragRegion() calls
Screenbox/Pages/PlayerPage.xaml Replaced manual title bar XAML structure with TitleBar control, including Header, Footer, and content
Screenbox/Pages/MainPage.xaml.cs Removed CoreApplicationViewTitleBar handling, replaced with TitleBar.SetDragRegion() and SetCaptionButtonColor()
Screenbox/Pages/MainPage.xaml Replaced manual title bar XAML with TitleBar control
Screenbox/Helpers/TitleBarHelper.cs Removed - functionality moved to TitleBar control
Screenbox/Controls/TitleBar/TitleBarHeightMode.cs New enum defining Standard (32px) and Tall (48px) height modes
Screenbox/Controls/TitleBar/TitleBarAutomationPeer.cs New automation peer for accessibility support
Screenbox/Controls/TitleBar/TitleBar.xaml New control template with theme-aware resources and visual states
Screenbox/Controls/TitleBar/TitleBar.cs Main control implementation with lifecycle management and caption button color handling
Screenbox/Controls/TitleBar/TitleBar.Properties.cs Comprehensive dependency properties for customization
Screenbox/App.xaml.cs Removed theme change handler and TitleBarHelper calls

_rightPaddingColumn = (ColumnDefinition?)GetTemplateChild(RightPaddingColumnName);
_dragRegion = (Grid?)GetTemplateChild(DragRegionName);

SetDragRegion();
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

SetDragRegion is called in OnApplyTemplate before _window is initialized in OnLoaded. This means the first call to SetDragRegion will always return early without doing anything. Consider removing this call from OnApplyTemplate since SetDragRegion will be properly executed when it's called from the page code-behind after the control is loaded, or ensure _window is initialized before calling SetDragRegion.

Suggested change
SetDragRegion();
// Note: SetDragRegion is intentionally not called here because _window is initialized in OnLoaded.
// The drag region will be configured when SetDragRegion is invoked after the control is fully loaded.

Copilot uses AI. Check for mistakes.
@United600
Copy link
Collaborator Author

Should we add the icon during compact overlay mode?

Screenbox playing music in compact mode

Comment on lines +300 to +301
_ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
() => UpdateNavigationViewState(sender.DisplayMode, sender.IsPaneOpen));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe be a bit excessive, but I wanted to avoid adding another event handler (PaneClosed).

What if we just pass the value directly? That way, we can skip using the Dispatcher?

- UpdateNavigationViewState(sender.DisplayMode, sender.IsPaneOpen);
+ UpdateNavigationViewState(sender.DisplayMode, false);

Copy link
Owner

Choose a reason for hiding this comment

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

Did you try this? I think some NavigationView visual state changes must happen first before we can update the state on our end. If this doesn't produce unexpected visual behavior then I am okay.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried it, and it worked well, but it could use a bit more testing.

@huynhsontung
Copy link
Owner

Should we add the icon during compact overlay mode?

I think so. Just checked YouTube and the inbox media player, and they do show their icon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants