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

Custom TitleBar is not work well in RTL #8671

Open
ghost1372 opened this issue Jul 18, 2023 · 10 comments
Open

Custom TitleBar is not work well in RTL #8671

ghost1372 opened this issue Jul 18, 2023 · 10 comments
Assignees
Labels
area-TitleBar Issues related to custom window title bars. bug Something isn't working team-Reach Issue for the Reach team

Comments

@ghost1372
Copy link
Contributor

ghost1372 commented Jul 18, 2023

Describe the bug

Custom title bar doesn't work well in Right To Left layout
I used the code from the documentation

Below you can see the reaction of the title bar when layout is right to left with different methods:

  1. Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "fa-IR";

As you can see, the title does not stick to the right side and is as far as the CaptionButtons

aa

2.FlowDirection="RightToLeft"

As you can see, CaptionButtons and title are placed in each other

bb

  1. using NativeMethods WS_EX_LAYOUTRTL and SetWindowLong(hWnd, GWL_EXSTYLE, exstyle | WS_EX_LAYOUTRTL)

The drag regions are not correct and the title is still on the left side

cc

  1. using NativeMethods WS_EX_LAYOUTRTL and SetWindowLong(hWnd, GWL_EXSTYLE, exstyle | WS_EX_LAYOUTRTL) and FlowDirection="RightToLeft"

01

Steps to reproduce the bug

create a winui 3 project + full titlebar customization
change your app to RTL layout with 3 methods

Expected behavior

Caption buttons should be on the left side, title and icon should be on the right side, Also, the title and icon should be placed on the right without spaces [see first image]

Screenshots

No response

NuGet package version

Windows App SDK 1.3.2: 1.3.230602002

Packaging type

Packaged (MSIX), Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

@Avid29
Copy link

Avid29 commented Jul 18, 2023

I reported it in the wrong repo earlier with a video example: #8559

@DarranRowe
Copy link

DarranRowe commented Jul 18, 2023

Does setting WS_EX_LAYOUTRTL and FlowDirection="RightToLeft" at the same time work?
There is some fun quirkiness here, but WS_EX_LAYOUTRTL means that the frame is mirrored but the content doesn't have to be and FlowDirection="RightToLeft" means that the content is mirrored but the frame doesn't have to be. This is especially true since one of your previous bug reports showed that Xaml wasn't properly working with the underlying window. FrameworkElement.FlowDirection does state that the default is LeftToRight after all.

@ghost1372
Copy link
Contributor Author

ghost1372 commented Jul 18, 2023

@DarranRowe
No, as you can see, title is far from the right side

01

The bug I reported earlier was in a very bad state, The title bar and caption buttons were not working. They fixed that bug .
But here we have a space on the right!

@pratikone
Copy link
Contributor

I would suggest using winappsdk 1.4 preview and see if it covers some of it. RTL in custom titlebar is still a in-progress issue but with merger with appwindow titlebar, 1.4 custom titlebar should be doing most of the heavy lifting of RTL display. can you test it out and let me know the experience ? Thanks

@pratikone pratikone transferred this issue from microsoft/WindowsAppSDK Jul 20, 2023
@Avid29
Copy link

Avid29 commented Jul 21, 2023

@pratikone I gave it a test in my C# project and it no longer mismatches the buttons visible location from their hitboxes, however it behaves as if it were LTR. Is there a way to set the TitleBar layout/flow direction in the C# API?

Also, in 1.2 when you didn't enable ExtendsContentIntoTitleBar the titlebar would match the system language's flow direction. However, in 1.4 that behavior has changed and it will always be LTR.

@ghost1372
Copy link
Contributor Author

ghost1372 commented Jul 21, 2023

@pratikone i tested with 1.4-preview1
First of all, there is no right-to-left functionality with C# code!
In version 1.3, the app can be set to right to left with the following code:
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "fa-IR";
But in 1.4 no code works except p/invoke
Second, I changed app layout to right to left with P/invoke and issue is still exists

@bpulliam bpulliam added the team-Reach Issue for the Reach team label Aug 8, 2023
@pratikone
Copy link
Contributor

Thanks for providing these. It is very useful feedback towards a fully functional RTL. I will start exploring what other gaps here. @Avid29 we didn't change anything in that end for flow direction. Are you following https://learn.microsoft.com/en-us/windows/apps/design/globalizing/manage-language-and-region and have a RTL language in app manifest ? If it doesn't work after all that, I suggest opening a new issue as it is separate from custom titlebar related RTL issue. Would be better for tracking

@ghost1372
Copy link
Contributor Author

Tnx @pratikone
I should also mention that UnPackaged Apps have more issues and only p/invoke code works and no C# code can change the layout. So we need a new API to change the layout for Packaged/UnPackaged

@bpulliam bpulliam added the area-TitleBar Issues related to custom window title bars. label Aug 23, 2023
@duncanmacmichael duncanmacmichael added the bug Something isn't working label Oct 23, 2023
@pratikone
Copy link
Contributor

pratikone commented Dec 11, 2023

we are working on a good api to act as source of truth for RTL. hang tight. meanwhile, calling WS_EX_LAYOUTRTL and FlowDirection="RightToLeft" on XamlRoot.Content is not fixing it entirely ? @ghost1372 I defintely suggest opening a new issue for the gap one so that we can track it separately. what other issues ppl are facing when they do *WS_EX_LAYOUTRTL and FlowDirection="RightToLeft" on XamlRoot.Content *

@ghost1372
Copy link
Contributor Author

ghost1372 commented Dec 12, 2023

we are working on a good api to act as source of truth for RTL. hang tight. meanwhile, calling WS_EX_LAYOUTRTL and FlowDirection="RightToLeft" on XamlRoot.Content is not fixing it entirely ? @ghost1372 I defintely suggest opening a new issue for the gap one so that we can track it separately. what other issues ppl are facing when they do *WS_EX_LAYOUTRTL and FlowDirection="RightToLeft" on XamlRoot.Content *

Excellent, thank you. I hope that the new API will work for packaged and unpackage mode.
i tested with wasdk v1.4.3 (latest titlebar api) and issue still exists.
using WS_EX_LAYOUTRTL with FlowDirection has 2 issues:
image

Screenshot 2023-12-12 195401

i opened i new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-TitleBar Issues related to custom window title bars. bug Something isn't working team-Reach Issue for the Reach team
Projects
None yet
Development

No branches or pull requests

6 participants