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

[Python] Fix xbmcgui.Window methods to get the actual size of a Window #12279

Merged
merged 3 commits into from Jun 14, 2017

Conversation

Projects
None yet
6 participants
@romanvm
Copy link
Contributor

romanvm commented Jun 9, 2017

Description

This PR fixes xbmcgui.Window.getWidth() and xbmcgui.Window.getHeight() methods so that they return the actual pixel size of a Window instance instead of the current display resolution.
Display resolution can now be obtained using xbmcgui.getScreenWidth() and xbmcgui.getScreenHeight() free functions.
Also this PR adds deprecation information to Window.getResolution() and Window.setCoordinateResolution() methods because currently they are practically useless.

Motivation and Context

xbmcgui Controls are placed using pixel coordinates from the top left corner. However, currently there is no way to determine the the actual pixel size of the visible area (pixel coordinate grid) of a Window instance. Existing getWidth and getHeight methods return the current display resolution which is not the same as Window's coordinate grid resolution. The fixed methods will help to correctly place Controls on the screen, especially if the Controls are placed in a Window with existing ID, e.g. over a fullscreen video, and display resolution can still be obtained using the new free functions.

How Has This Been Tested?

I compiled the code in Vusial Studio 2015 on Windows 10. Then I built a Windows installer and installed Kodi from it. After that I ran a simple testing addon and checked if those fixed methods and new functions actually work using an interactive Python debugger.

Screenshots (if appropriate):

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the Code guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document
  • I have added tests to cover my change
  • All new and existing tests passed
@xhaggi

This comment has been minimized.

Copy link
Member

xhaggi commented Jun 10, 2017

A window should normally return it's actually width and height not the display resolution. If that's the case we should change the implementation of GetWidth and GetHeight and do not introduce new methods. Not sure if there is another way to get the current display resolution, if not that should be addressed too.

@romanvm

This comment has been minimized.

Copy link
Contributor Author

romanvm commented Jun 10, 2017

I agree with you but since this my very first PR to the Kodi core code, I didn't feel right to change the existing code. But yes, logically, a Window instance should return its coordinate grid resolution and the display resolution, if needed, should be returned by free functions, because it is a property of Kodi itself.

Also methods xbmcgui::Window::getResolution () and xbmcgui::Window::setCoordinateResolution (...) are basically useless because they operate with some arcane numeric constants that are meaningless from addon developer's perspective. For example, on my Win 10 machine with 1680x1050 display getResolution() returns 16 or RES_DESKTOP: https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Resolution.h#L33.

@@ -319,7 +319,7 @@ namespace XBMCAddon
break;
case CGUIControl::GUICONTROL_SLIDER:
pControl = new ControlSlider();
break;
break;

This comment has been minimized.

@DaveTBlake

DaveTBlake Jun 11, 2017

Member

Remove trailing blanks please

@romanvm romanvm changed the title [Python] Add methods to get the actual size of xbmcgui.Window [Python] Fix xbmcgui.Window methods to get the actual size of a Window Jun 12, 2017

@romanvm

This comment has been minimized.

Copy link
Contributor Author

romanvm commented Jun 12, 2017

I have updated this PR. Please see the new title and description.

@xhaggi

This comment has been minimized.

Copy link
Member

xhaggi commented Jun 12, 2017

@romanvm thank you. Some minor things to do before we are ready to merge.

Please fixup/squash commit 9206e87 into 4fdd5be and c46e7ff into 266f75c.
We don't need the history for that.

@romanvm

This comment has been minimized.

Copy link
Contributor Author

romanvm commented Jun 13, 2017

Done

@xhaggi

This comment has been minimized.

Copy link
Member

xhaggi commented Jun 13, 2017

Thanks looks good.

@xhaggi

This comment has been minimized.

Copy link
Member

xhaggi commented Jun 13, 2017

@phil65 or @ronie any objections?

/// Returns the height of this screen.
///
/// @return Screen height
///

This comment has been minimized.

@MartijnKaijser

MartijnKaijser Jun 13, 2017

Member

Shouldn't the @python_v18 be added here as wel?

This comment has been minimized.

@romanvm

romanvm Jun 13, 2017

Author Contributor

Yes, I forgot about that

Roman Miroshnychenko and others added some commits Jun 12, 2017

Roman Miroshnychenko Roman Miroshnychenko
Add deprecation notice for Window.getResolution/setCoordinateResoluti…
…on methods

Those methods operate with some arcane numeric constants that bear no useful information or functionality. They seem to be remnants from Xbox times with its fixed set of resolutions and are useless with modern videochips/displays.
@romanvm

This comment has been minimized.

Copy link
Contributor Author

romanvm commented Jun 13, 2017

@phil65

phil65 approved these changes Jun 14, 2017

@xhaggi xhaggi merged commit 673ad31 into xbmc:master Jun 14, 2017

1 check passed

default You're awesome. Have a cookie
Details

@Rechi Rechi added this to the L 18.0-alpha1 milestone Jun 14, 2017

@romanvm romanvm deleted the romanvm:pixel_size branch Jun 14, 2017

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