All dialogs and windows of NVDA should be centered on the screen #3148

Closed
nvaccessAuto opened this Issue Apr 12, 2013 · 26 comments

Projects

None yet

1 participant

@nvaccessAuto

Reported by k_kolev1985 on 2013-04-12 15:11
At present, most dialogs and windows of NVDA seam to be scattered around the screen. Some of them are in the center and are fully visible, but some of them begin from the center and due to their wideness or height, are partially hidden on the right or bottom. The low screen resolution (on my screen is 800x600) also helps for that issue to occur. I see that on the left and top of the screen there is enough space for those dialogs and windows to fit fully in the screen horizontally or vertically (even with 800x600 screen resolution), but it seams that those dialogs and windows are set to have a specific offset (in pixels maybe) from the top and left, witch in some cases is too much.

I have a program for manage of windows witch has a command to position a window in the center of the screen. When I execute that command for those problematic NVDA windows and dialogs, they fit perfectly in the screen (even with my low resolution). So basically, I think that the NVDA windows and dialogs should have a position attribute with a "center" value, so they are centered on the screen when spawned from NVDA (if that is possible to implement).
Blocking #2192

@nvaccessAuto

Comment 1 by jteh on 2013-04-13 00:11
wx's sizer model is supposed to handle correct sizing regardless of the screen resolution.

It'd be good if you can give an example of one dialog that is centred and displays correctly and one that doesn't. That way, we might have a chance of figuring this out. Note that Mick and I are both totally blind, so someone else with sight would be much better suited to look at this if possible.

@nvaccessAuto

Comment 3 by k_kolev1985 on 2013-04-13 07:24
Well, the "About NVDA" dialog and the one witch informs us that the update is downloaded and now will be installed are good examples of centered dialogs witch fit in the screen. The dialogs for NVDA's settings (all I think) are good example of non-centered dialogs. As far as I can see, they all start at a specific offset from the top and left side of the screen (1/3 from the left and about 1/5 from the top). And if such dialogs are too high or too wide, their bottom or right side respectively will be hidden on the bottom or right side of the screen.

Yes, WX may have the ability to handle such situations, but it seams not to work as it should. For example, it seams not to be able to split labels of controls on 2 or more lines if necessary and if the labels in question are too long, the width of the dialog gets too long, causing its right side to be partially hidden.

Well, it is not easy to explain for me, unfortunately. To understand it, the person probably have to be able to see it. Hope that someone at least partially sighted can help in this situation.

@nvaccessAuto

Comment 4 by nvdakor on 2013-05-06 22:21
Hi,
You can sort of work on this: move Navigator Object to the dialog window itself, press NvDA+Numpad Delete to get dimensions and this should help us figure out what's going on.
I'll come up with a list of non-centered windows this week and report back on that.

@nvaccessAuto

Comment 5 by nvdakor on 2013-05-06 22:44
Hi,
Here's a list of NvDA dialogs which are not centered:

  • Welcome dialog: Skewed up.
    From Preferences:
  • General Settings: Skewed up.
  • Synthesizer: Skewed to left and to top.
  • Voice Settings: Skewed left.
  • Braille Settings: Skewed left and towards top.
  • Keyboard Settings: Skewed left and to top.
  • Mouse Settings: Skewed to left and to top.
  • Review Cursor: Skewed too much to left and to top.
  • Input Composition: Skewed to top.
  • Object Presentation: Skewed to top and left.
  • Browse Mode: Skewed to top and to left.
  • Document Formatting: Skewed a little bit to left and to bottom.
    From Tools:
  • Addons Manager: Skewed a bit to the right and to bottom.
    At least these are ones I have. Thanks.
@nvaccessAuto

Comment 6 by nvdakor on 2013-05-06 22:52
STR:

  1. Open any NvDA dialog.
  2. Press NvDA+Numpad 8 once or twice (or three times) until you hear name window.
  3. Press NvDA+Numpad Delete to find out window dimensions.
    On my system with resolution of 1280X800 (under Win8), the dialog windows have:
  • Left edge: 34.4 percent.
  • Top edge: 18.4 percent.
    These readings are consistent across all dialogs I've opened so far, so it seems WX is not positioning the windows at the center as the ticket reporter says (and confirmed at my end). Ideally, the centered window should have the following readings:
  • Window width = 100.0 - 2 times (left edge).
  • Window height = 100.0 - 2 times (top edge).
    Any readings above 100.0 means the window is taking the entire width or height.
    Thanks.
@nvaccessAuto

Comment 7 by nishimotz on 2013-10-06 15:35
A patch regarding the issue is as follows:

diff --git source/gui/settingsDialogs.py source/gui/settingsDialogs.py
index 534532d..63d3553 100644
--- source/gui/settingsDialogs.py
+++ source/gui/settingsDialogs.py
@@ -76,6 +76,12 @@ class SettingsDialog(wx.Dialog):
                self.Bind(wx.EVT_BUTTON,self.onOk,id=wx.ID_OK)
                self.Bind(wx.EVT_BUTTON,self.onCancel,id=wx.ID_CANCEL)
                self.postInit()
+               dw, dh = self.GetSizeTuple()
+               import api
+               left, top, width, height = api.getDesktopObject().location
+               x = (width - dw) / 2
+               y = (height - dh) / 2
+               self.SetPosition((x, y))

        def __del__(self):
                SettingsDialog._hasInstance=False
@nvaccessAuto

Comment 8 by k_kolev1985 on 2014-09-11 17:29
Hello,

If I'm not mistaking, current "next" snapshots are using WX Python 3.0.1, witch is newer than the version used before (maybe it was 2.7.x). I don't know if from that or from some other change, but now the placement of the NVDA dialogs and windows is more ordered. The dialogs for download and update/installation progress of NVDA are centered on the screen. The ones with the settings, for updates notifications and donation prompt are not however - they are (maybe intentionally) top-left aligned, with a small offset from the top and left edges of the screen. Although from my point of view (I think all dialogs should be centered) this is not the best solution, it is much better than it was before (when I did the report). So, it is an improvement.

@nvaccessAuto

Comment 9 by driemer.riemer@... on 2014-09-11 20:13
Why don't we just use dialog.Center() for this? I was looking at the code, and we use our own methods to do this.

@nvaccessAuto

Comment 10 by nvdakor (in reply to comment 8) on 2014-10-01 03:46
Replying to k_kolev1985:

Hello,

If I'm not mistaking, current "next" snapshots are using WX Python 3.0.1, witch is newer than the version used before (maybe it was 2.7.x). I don't know if from that or from some other change, but now the placement of the NVDA dialogs and windows is more ordered. The dialogs for download and update/installation progress of NVDA are centered on the screen. The ones with the settings, for updates notifications and donation prompt are not however - they are (maybe intentionally) top-left aligned, with a small offset from the top and left edges of the screen. Although from my point of view (I think all dialogs should be centered) this is not the best solution, it is much better than it was before (when I did the report). So, it is an improvement.

I can confirm this- all dialogs except a few standard WX dialogs are aligned more towards top left of the screen (observed in next branch with WXPython 3.0.1 installed, not to be confused with actual Python which is still 2.7.x). To confirm this, try:

  1. Open any dialog you know that is aligned towards top left corner of the screen.
  2. Open Python Console and type:
api.getDesktopObject().location
fg.location

The desktop object, being the top shell object, returns the actual screen resolution of the screen you are using (in my case, 1600x1200). The second line returns the coordinates of the foreground (top-level) window in pixels. As I described in a previous comment, a centered window should have differing readings to make it appear centered. I think our next order of business is to go through the list of skewed dialogs (see comment 6) and see what's causing this behavior (and I think a completely blind developer can come up with a solution, given if he or she can keep track of pixel coordinate readings).
Also, is someone going to review a patch submitted in comment 7, and does this patch work in WXPython 3.0.1?
Thanks.

@nvaccessAuto

Comment 11 by nvdakor (in reply to comment 7) on 2014-10-01 03:56
Replying to nishimotz:

A patch regarding the issue is as follows:

diff --git source/gui/settingsDialogs.py source/gui/settingsDialogs.py
index 534532d..63d3553 100644
--- source/gui/settingsDialogs.py
+++ source/gui/settingsDialogs.py
@@ -76,6 +76,12 @@ class SettingsDialog(wx.Dialog):
                self.Bind(wx.EVT_BUTTON,self.onOk,id=wx.ID_OK)
                self.Bind(wx.EVT_BUTTON,self.onCancel,id=wx.ID_CANCEL)
                self.postInit()
+               dw, dh = self.GetSizeTuple()
+               import api
+               left, top, width, height = api.getDesktopObject().location
+               x = (width - dw) / 2
+               y = (height - dh) / 2
+               self.SetPosition((x, y))

        def __del__(self):
                SettingsDialog._hasInstance=False

@nishimotz]: Can you see if your patch works in t3763 branch in source code form, and do you know if WXPython provides a more convenient method to center the settings dialog (itself inheriting WX.Dialog) without going through the hack described above?
Thanks.

@nvaccessAuto

Comment 12 by nvdakor (in reply to comment 9) on 2014-10-01 04:43
Replying to driemer.riemer@…:

Why don't we just use dialog.Center() for this? I was looking at the code, and we use our own methods to do this.

From source code testing, self.Center() doesn't help if you use it with WXPython 3.0.1. If I add:

self.Center()

in gui.settingsDialogs, the result becomes a dialog that is positioned at the top left corner of the screen. The patch submitted in comment 7 is a hack that indeed works, but it works only in source code form, but as soon as I install the official next snapshot, settings dialogs are again skewed to the top left corner of the screen, which isn't really ideal.
Technical: the dialogs that are skewed are inherited from WX.Window, whereas properly centered ones come from WX.MessageBox. It isn't enough to just center it - one needs a point source from which the dialogs should be centered, thus the patch submitted in comment 7 is a workaround for this ticket. But for whatever reason, installed copies breaks this. Although it may help touchscreen users find dialog controls easily, a skewed dialog isn't a good thing in terms of user experience, particularly for sighted developers tweaking various settings in NVDA or working with GUI components. This applies to any dialog in NVDA which inherits from WX.Window, including preferences, Add-ons Manager and so on.
Thanks.

@nvaccessAuto

Comment 13 by jteh on 2014-10-01 04:43
I'd prefer to use wx.Dialog.Center() if possible. Because the parent window doesn't actually cover the screen, we need to use .Center(wx.BOTH | wx.CENTER_ON_SCREEN). This seems to work for me in SettingsDialog, but anything that subclasses wx.Dialog needs this too. It'd be great if someone is willing to implement and test this. It's not difficult, but it's very tedious and time consuming. :)

To find the dialogs that need this, just search for wx.Dialog. These can be found in all of these files:

  • appModules/outlook.py
  • appModules/powerpnt.py
  • gui/addonGui.py
  • gui/configProfiles.py
  • gui/installerGui.py
  • gui/settingsDialogs.py
  • gui/upgradeAlerts.py
  • gui/__init__.py
  • updateCheck.py
  • virtualBuffers/__init__.py
@nvaccessAuto

Comment 14 by nishimotz on 2014-10-01 08:16
I don't remember the reason I have to work around SetPosition() method rather than simply using Center() method, however, I should invesitgate again with wxPython 3.0.x.

@nvaccessAuto

Comment 15 by nishimotz on 2014-10-02 13:58
Branch t3148v2 of the repository

git@bitbucket.org:nishimotz/nvda.git

is a fork from the next (i.e. wxPython 3.0-based) branch.

Most of the dialogs which @jteh mentioned were fixed and confirmed.

I have just added

self.Center(wx.BOTH | wx.CENTER_ON_SCREEN)

at the end of their init methods.

@nvaccessAuto

Comment 16 by jteh (in reply to comment 15) on 2014-10-02 22:30
Replying to nishimotz:

is a fork from the next (i.e. wxPython 3.0-based) branch.

For future reference, branches should never be based on next, as next can never be merged into master. It's okay to base a branch on another topic branch if it depends on that code; e.g. this could be based on t3763 which is the wxPython 3 upgrade. Don't worry about it for this case; I should be able to cherry-pick/rebase your branch.

@nvaccessAuto

Comment 17 by nishimotz on 2014-10-30 13:59
Just for reviewer's convenience, branch t3148v3 of the repository

git@bitbucket.org:nishimotz/nvda.git

is based on master branch revision 1c590c2, manually cherry-picked from previous work.

Thank you.

@nvaccessAuto

Comment 18 by James Teh <jamie@... on 2014-11-06 06:53
In [2d74a7d]:

All NVDA dialogs are now centered on the screen.

Re #3148.

@nvaccessAuto

Comment 19 by James Teh <jamie@... on 2014-11-06 06:53
In [dbe5849]:

Merge branch 't3148' into next

Incubates #3148.

Changes:
Added labels: incubating

@nvaccessAuto

Comment 20 by jteh on 2014-11-07 02:35
Thanks @nishimotz!

@nvaccessAuto

Comment 21 by k_kolev1985 on 2014-11-10 11:12
Yes, all of the NBDA dialogs are now centered, except for the one witch prompts for donation - it is still aligned top left.

@nvaccessAuto

Comment 22 by James Teh <jamie@... on 2014-11-11 03:59
In [42a9c56]:

Center the donate request dialog, which was previously missed.

Incubates #3148.

@nvaccessAuto

Comment 23 by nishimotz on 2014-11-11 11:22
I think new Exit dialog should also need self.Center() as follows:

diff --git a/source/gui/__init__.py b/source/gui/__init__.py
index 8e56de1..be2830f 100644
--- a/source/gui/__init__.py
+++ b/source/gui/__init__.py
@@ -724,6 +724,7 @@ class ExitDialog(wx.Dialog):
                self.Bind(wx.EVT_BUTTON, self.onOk, id=wx.ID_OK)
                self.Bind(wx.EVT_BUTTON, self.onCancel, id=wx.ID_CANCEL)
                mainSizer.Fit(self)
+               self.Center(wx.BOTH | wx.CENTER_ON_SCREEN)
                self.Sizer = mainSizer
                self.actionsList.SetFocus()
@nvaccessAuto

Comment 24 by jteh on 2014-11-11 12:19
Which branch were you looking at? I made this change in my initial commit to t3148. (I cherry-picked your commit and added that as well as changing the log message.)

@nvaccessAuto

Comment 25 by nishimotz on 2014-11-11 12:38
Sorry for my misunderstanding.
Confirmed that t3148 of nvaccess repository was already fixed.

@nvaccessAuto

Comment 26 by Michael Curran <mick@... on 2014-12-02 01:23
In [6a507e2]:

Merge branch 't3148'. Fixes #3148

Changes:
Removed labels: incubating
State: closed

@nvaccessAuto

Comment 27 by mdcurran on 2014-12-02 01:23
Changes:
Milestone changed from None to 2015.1

@nvaccessAuto nvaccessAuto added this to the 2015.1 milestone Nov 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment