Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Python] Add methods to get the actual size of xbmcgui.Window
  • Loading branch information
Roman Miroshnychenko committed Jun 9, 2017
1 parent 4cb835f commit 4fdd5be
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
18 changes: 17 additions & 1 deletion xbmc/interfaces/legacy/Window.cpp
Expand Up @@ -319,7 +319,7 @@ namespace XBMCAddon
break;
case CGUIControl::GUICONTROL_SLIDER:
pControl = new ControlSlider();
break;
break;
case CGUIControl::GUICONTAINER_LIST:
case CGUIControl::GUICONTAINER_WRAPLIST:
case CGUIControl::GUICONTAINER_FIXEDLIST:
Expand Down Expand Up @@ -657,6 +657,22 @@ namespace XBMCAddon
ref(window)->ClearProperties();
}

long Window::getGridWidth()
{
XBMC_TRACE;
SingleLockWithDelayGuard gslock(g_graphicsContext, languageHook);
RESOLUTION_INFO resInfo = ref(window)->GetCoordsRes();
return resInfo.iWidth;
}

long Window::getGridHeight()
{
XBMC_TRACE;
SingleLockWithDelayGuard gslock(g_graphicsContext, languageHook);
RESOLUTION_INFO resInfo = ref(window)->GetCoordsRes();
return resInfo.iHeight;
}

void Window::close()
{
XBMC_TRACE;
Expand Down
62 changes: 62 additions & 0 deletions xbmc/interfaces/legacy/Window.h
Expand Up @@ -850,6 +850,68 @@ namespace XBMCAddon
SWIGHIDDENVIRTUAL void clearProperties();
#endif

#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_xbmcgui_window
/// @brief \python_func{ getGridWidth() }
///-----------------------------------------------------------------------
/// Returns the width of the visible part for the Window coordinate grid
///
/// This value can be used to correctly place Controls inside the Window.
///
/// @return the visible width of the coordinate grid in pixels
///
/// @note This value does not depend on the current display resolution,
/// unlike getWidth() which returns the current display width.
///
///-----------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ..
/// win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
/// height = win.getGridWidth()
/// ..
/// ~~~~~~~~~~~~~
///-----------------------------------------------------------------------
/// @python_v18 New function added.
///
getGridWidth(...);
#else
SWIGHIDDENVIRTUAL long getGridWidth();
#endif

#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_xbmcgui_window
/// @brief \python_func{ getGridHeight() }
///-----------------------------------------------------------------------
/// Returns the height of the visible part for the Window coordinate grid
///
/// This value can be used to correctly place Controls inside the Window.
///
/// @return the visible height of the coordinate grid in pixels
///
/// @note This value does not depend on the current display resolution,
/// unlike getHeight() which returns the current display height.
///
///-----------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ..
/// win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
/// height = win.getGridHeight()
/// ..
/// ~~~~~~~~~~~~~
///-----------------------------------------------------------------------
/// @python_v18 New function added.
///
getGridHeight(...);
#else
SWIGHIDDENVIRTUAL long getGridHeight();
#endif

#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_xbmcgui_window
Expand Down

0 comments on commit 4fdd5be

Please sign in to comment.