From c20f723b8bbbb23b09b0e5901af6c1f9c9ab6f8f Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 31 Jan 2014 17:41:29 +0100 Subject: [PATCH] CComponentsWindow: fix handling of window size On some several cases it's possible that full resulution is not visible on SD output or video-out modes like 576i/p. So it's makes more sense to use current osd-settings for max size and position. This fixes also current behavior of Imageinfo. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9d3febd0804eba708e1c8887eeda74684df96cd4 Author: Thilo Graf Date: 2014-01-31 (Fri, 31 Jan 2014) ------------------ This commit was generated by Migit --- src/gui/components/cc_frm_window.cpp | 41 ++++++++++++++++++++++------ src/gui/components/cc_frm_window.h | 10 ++++--- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index cdc596f99..48503b6d7 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -80,13 +80,14 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const //CComponentsForm cc_item_type = CC_ITEMTYPE_FRM_WINDOW; - //using current screen settings for default dimensions, do use full screen if default values for width/height = 0 - int w_tmp = frameBuffer->getScreenWidth(w == 0 ? true : false); - int h_tmp = frameBuffer->getScreenHeight(h == 0 ? true : false); - width = w == 0 ? w_tmp : w; - height = h == 0 ? h_tmp : h; - x = x_pos; - y = y_pos; + //using current screen settings for default dimensions, + //do use full screen (from osd-settings) if default values for width/height = 0 + x = x_pos; + y = y_pos; + width = w; + height = h; + initWindowSize(); + initWindowPos(); ccw_caption = caption; ccw_icon_name = iconname; @@ -110,9 +111,31 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const initCCWItems(); } +void CComponentsWindow::initWindowSize() +{ + if (cc_parent) + return; + + if (width == 0) + width = frameBuffer->getScreenWidth(); + if (height == 0) + height = frameBuffer->getScreenHeight(); +} + +void CComponentsWindow::initWindowPos() +{ + if (cc_parent) + return; + + if (x == 0) + x = frameBuffer->getScreenX(); + if (y == 0) + y = frameBuffer->getScreenY(); +} + void CComponentsWindow::doCenter(){ - x = cc_parent ? cc_parent->getWidth() - width/2 : frameBuffer->getScreenWidth(true)/2 - width/2; - y = cc_parent ? cc_parent->getHeight() - height/2 : frameBuffer->getScreenHeight(true)/2 -height/2; + x = cc_parent ? cc_parent->getWidth() - width/2 : getScreenStartX(width); + y = cc_parent ? cc_parent->getHeight() - height/2 : getScreenStartY(height); } void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode) diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h index 74f26b4d1..b3cd34137 100644 --- a/src/gui/components/cc_frm_window.h +++ b/src/gui/components/cc_frm_window.h @@ -92,6 +92,10 @@ class CComponentsWindow : public CComponentsForm fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); ///allow centering of window on screen, mostly senseful for window object without parent void doCenter(); + ///initialize width and height + void initWindowSize(); + ///initialize position + void initWindowPos(); public: enum @@ -159,12 +163,10 @@ class CComponentsWindow : public CComponentsForm class CComponentsWindowMax : public CComponentsWindow { public: - ///simple constructor for CComponentsWindow, provides parameters for caption as string and icon, position of window is general centered and bound - ///to current screen settings, this shows a window over full screen + ///simple constructor for CComponentsWindow, provides parameters for caption as string and icon, this shows a centered window based up current screen settings CComponentsWindowMax(const std::string& caption, const std::string& iconname = ""); - ///simple constructor for CComponentsWindow, provides parameters for caption from locales and icon, position of window is general centered and bound - ///to current screen settings, this shows a window over full screen + ///simple constructor for CComponentsWindow, provides parameters for caption from locales and icon, this shows a centered window based up current screen settings CComponentsWindowMax(neutrino_locale_t locale_caption, const std::string& iconname = ""); };