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

Fix right-to-left layout direction issues #12181

Merged
merged 17 commits into from Mar 18, 2021
Merged

Fix right-to-left layout direction issues #12181

merged 17 commits into from Mar 18, 2021

Conversation

seanbudd
Copy link
Member

@seanbudd seanbudd commented Mar 16, 2021

Link to issue number:

Closes #8859, #638

Summary of the issue:

#8859

Right to left layouts caused several GUI elements to not render, or not render correctly.

A ticket was raised on wxWidgets, where support was removed for the behaviour we were using, and a work around was suggested.

Adding controls to the wx.StaticBoxSizer by adding them to the same parent causes undefined behaviour, specifically with Right-To-Left layouts. wxWidgets now requires that these items be added as children.

#638

wxWidgets did not respect the layout out of language when setting the language via NVDA as opposed through the system/Windows. This means languages with a right-to-left layout would render left-to-right unless the system locale also used a right-to-left layout

Description of how this pull request fixes the issue:

#8859

The suggested and implemented workaround is as follows:

Before:

sizer = new wx.StaticBoxSizer(wx.VERTICAL, self, "Test")
sizer.Add(wx.StaticText(self, wx.ID_ANY, "Where am I?"))
sizer.Add(wx.Button(self, wx.ID_ADD))

After:

sizer = new wx.StaticBoxSizer(wx.VERTICAL, self, "Test")
sizer.Add(wx.StaticText(sizer.GetStaticBox(), wx.ID_ANY, "Where am I?"))
sizer.Add(wx.Button(sizer.GetStaticBox(), wx.ID_ADD))

#638

The layout for the wx.App main frame is manually set using wx.Locale information.

Testing strategy:

Visually compare GUI features outlined in #8859 between an LTR language such as English and an RTL language such as Farsi.

Known issues with pull request:

Some GUI features still display differently for right-to-left languages

  • the right border of groupings clips with labels/controls.

Change log entry:

Bug fixes

- Fix graphical bugs such as missing elements when using NVDA with a right-to-left layout. (#12181)
   - known issue for right-to-left languages: the right border of groupings clips with labels/controls. 
- Respect the GUI layout direction based on the NVDA language, not the system locale. (#12181)

Code Review Checklist:

  • Pull Request description is up to date.
  • Unit tests.
  • System (end to end) tests.
  • Manual tests.
  • User Documentation.
  • Change log entry.
  • Context sensitive help for GUI changes.

standardize LTRStaticBoxSizer usage

standardize LTRStaticBoxSizer usage

test wx RTL workaround

use wxWidgets workaround

commit c59e874
Author: buddsean <sean@nvaccess.org>
Date:   Tue Mar 16 14:09:26 2021 +1100

    try parent instead of sibling method

commit 11017de
Author: buddsean <sean@nvaccess.org>
Date:   Tue Mar 16 13:25:59 2021 +1100

    remove LTRStaticBoxSizer workaround

commit e17de62
Author: buddsean <sean@nvaccess.org>
Date:   Tue Mar 16 13:14:39 2021 +1100

    try parent instead of sibling method

commit 45514f2
Author: buddsean <sean@nvaccess.org>
Date:   Tue Mar 16 11:48:24 2021 +1100

    try parent instead of sibling method

commit 9575740
Author: buddsean <sean@nvaccess.org>
Date:   Tue Mar 16 11:23:59 2021 +1100

    try parent instead of sibling method

commit 608fb66
Author: buddsean <sean@nvaccess.org>
Date:   Mon Mar 15 14:38:37 2021 +1100

    test wx RTL workaround

commit f1189bf
Author: buddsean <sean@nvaccess.org>
Date:   Mon Mar 15 14:03:20 2021 +1100

    test wx RTL workaround
@seanbudd seanbudd added this to the 2021.1 milestone Mar 16, 2021
@seanbudd seanbudd self-assigned this Mar 16, 2021
@AppVeyorBot
Copy link

See test results for failed build of commit de830fa79b

@AppVeyorBot
Copy link

See test results for failed build of commit e773d661f1

@CyrilleB79
Copy link
Collaborator

Testing strategy:

Visually compare GUI features outlined in #8859 between an LTR language such as English and an RTL language such as Farsi. This must be done by changing the system locale, so using a VM is suggested.

Why can't it just be checked by changing NVDA language to an RTL language?

@seanbudd
Copy link
Member Author

seanbudd commented Mar 16, 2021

Hi @CyrilleB79,

Currently this issue #638, but I think it's worth fixing in this PR just to make testing this easier. I think a major factor blocking #638 was the GUI issues fixed in this PR.

Going to investigate a fix for this and hopefully close out both tickets.

@seanbudd seanbudd marked this pull request as draft March 16, 2021 22:46
@seanbudd seanbudd changed the title move to standard usage of wx.StaticBoxSizer Fix right-to-left layout direction issues Mar 16, 2021
@seanbudd seanbudd marked this pull request as ready for review March 16, 2021 23:52
@AppVeyorBot
Copy link

See test results for failed build of commit d668aae5e6

Copy link
Contributor

@feerrenrut feerrenrut left a comment

Choose a reason for hiding this comment

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

In the changes entry for #638 I think it would be good to mention Right to Left languages.

Overall this looks good. Testing this myself I noticed that the right side of the static box outline is missing where there are labels or controls. It's still an improvement, but it might be worth mentioning this is known in the change log.

I tried "Arabic":
image

source/gui/__init__.py Outdated Show resolved Hide resolved
source/core.py Outdated Show resolved Hide resolved
source/core.py Outdated Show resolved Hide resolved
source/core.py Outdated Show resolved Hide resolved
source/gui/__init__.py Outdated Show resolved Hide resolved
source/core.py Outdated Show resolved Hide resolved
@AppVeyorBot
Copy link

See test results for failed build of commit bd9f0f3e61

@AppVeyorBot
Copy link

See test results for failed build of commit 6a62962912

source/core.py Outdated Show resolved Hide resolved
Copy link
Contributor

@feerrenrut feerrenrut left a comment

Choose a reason for hiding this comment

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

Looks good, just a reminder in my previous review I mentioned some considerations for the change log entries, happy for you to go ahead and merge.

@seanbudd seanbudd merged commit 073826a into master Mar 18, 2021
@seanbudd seanbudd deleted the fix-8859 branch March 18, 2021 04:02
@CyrilleB79
Copy link
Collaborator

Hi @seanbudd

You have merged this branch in master, but you did not select "Squash merge", which is the usual way to do in NVDA project. This result in many commits just for this PR in the commit history of master. It seems it was not intended.
Please think to it next time.
Cc @feerrenrut FYI.

@feerrenrut
Copy link
Contributor

I see what has happened. @CyrilleB79 it was actually squash merged, but the commit message includes the details of all the commits.

I suspect @seanbudd used the gh tool (GitHub-cli) to merge. Older versions of this did not let you override the squash commit message. Newer versions do, but it must be done carefully and the title can not yet be written

@seanbudd
Copy link
Member Author

Ah no @feerrenrut , I did not see the convention that was used in commit messages, is it the changelog? I have just been using the default in previous squash merges.

Thanks @CyrilleB79 for raising this

seanbudd added a commit that referenced this pull request Mar 23, 2021
Summary of the issue:
The standard installation process crashes with the following traceback, caused by #12181

Description of how this pull request fixes the issue:
Fix various crashing GUI bugs introduced to the installation process in #12181
Add smoke tests for the installation process
seanbudd added a commit that referenced this pull request Apr 20, 2021
In #12181, the setting "Report formatting changes after the cursor" in "Document Formatting" was incorrectly moved to the wrong parent, the static box grouping above it, making it invisible to the user. It was readable using NVDA but not graphically visible to the user. This has been corrected.
seanbudd added a commit that referenced this pull request Apr 21, 2021
Navigating through settings using tabbing does not visually scroll to the focused control.

wxPython ScrolledPanels calculate the position to scroll to based on the relative position to a focus elements parent, rather than the relative position to the ScrolledPanel itself.

When fixing right-to-left issues in #12181, another layer of nesting was introduced for controls in our settings panels, which caused the controls to no longer get scrolled to.

A patched version of ScrolledPanel is created, which calculates relative position to the ScrolledPanel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants