From cf9a953b59f1cfe15d1d234c4f00c58ba0d0029f Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 3 Mar 2017 09:01:58 +0100 Subject: [PATCH] CComponentsWindow: use negative values for discret percental dimensions Also add possibility to use placeholder for better readability and better compatibilty with previous implementations. See doc in source files for more details --- src/gui/components/cc_frm_window.cpp | 8 ++++---- src/gui/components/cc_frm_window.h | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index ab0663a2d..73a6e23a5 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -169,13 +169,13 @@ void CComponentsWindow::initWindowSize() if (cc_parent) return; - if (width > 0 && width <= 100) //percentage conversion TODO: behavior inside parent - width = frameBuffer->getScreenWidth()*width/100; + if (width < 0 && width >= -100) //percentage conversion TODO: behavior inside parent + width = frameBuffer->getScreenWidth()*abs(width)/100; if (width == 0 || (unsigned)width > frameBuffer->getScreenWidth()) width = frameBuffer->getScreenWidth(); - if (height > 0 && height <= 100) //percentage conversion TODO: behavior inside parent - height = frameBuffer->getScreenHeight()*height/100; + if (height < 0 && height >= -100) //percentage conversion TODO: behavior inside parent + height = frameBuffer->getScreenHeight()*abs(height)/100; if (height == 0 || (unsigned)height > frameBuffer->getScreenHeight()) height = frameBuffer->getScreenHeight(); } diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h index cb1b5288e..2c2b0ae64 100644 --- a/src/gui/components/cc_frm_window.h +++ b/src/gui/components/cc_frm_window.h @@ -29,6 +29,8 @@ #include "cc_frm_header.h" #include "cc_frm_footer.h" +#define CCW_PERCENATL - //placeholder for negative sign '-', used for discret dimensions parameters + //! Sub class of CComponentsForm. Shows a window with prepared items. /*! CComponentsWindow provides prepared items like header, footer and a container for @@ -135,6 +137,7 @@ class CComponentsWindow : public CComponentsForm CC_WINDOW_RIGHT_SIDEBAR = 2 }; + /**simple constructor for CComponentsWindow, this shows a window over full screen * @param[in] parent * @li optional: expects type CComponentsForm * as possible parent object, default = NULL @@ -148,9 +151,9 @@ class CComponentsWindow : public CComponentsForm * @param[in] y_pos * @li expects type const &int, defines y position on screen * @param[in] w - * @li expects type const &int, width of window, Note: value = 0 uses full screen, value > 0 to 100 interpreted as percent value of screen, value > 100 use native lines count on screen + * @li expects type const &int, width of window, Note: value = 0 uses full screen * @param[in] h - * @li expects type const &int, height of window, Note: value = 0 uses full screen, value > 0 to 100 interpreted as percent value of screen, value > 100 use native lines count on screen + * @li expects type const &int, height of window, Note: value = 0 uses full screen * @param[in] caption * @li optional: expects type const std::string&, defines title of window header * @param[in] iconname @@ -158,16 +161,24 @@ class CComponentsWindow : public CComponentsForm * @param[in] parent * @li optional: expects type CComponentsForm * as possible parent object, default = NULL * @param[in] shadow_mode - * @li optional: expects type int as mode, default = CC_SHADOW_OFF - * possible values are - * CC_SHADOW_ON = (CC_SHADOW_RIGHT | CC_SHADOW_BOTTOM | CC_SHADOW_CORNER_BOTTOM_LEFT | CC_SHADOW_CORNER_BOTTOM_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT) - * @see cc_types.h + * @li optional: expects type int as mode, default = CC_SHADOW_OFF \n + * possible values are \n + * CC_SHADOW_ON = (CC_SHADOW_RIGHT | CC_SHADOW_BOTTOM | CC_SHADOW_CORNER_BOTTOM_LEFT | CC_SHADOW_CORNER_BOTTOM_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT) \n + * Take a look into cc_types.h * @param[in] color_frame * @li optional: expects type fb_pixel_t, defines frame color, default = COL_FRAME_PLUS_0 * @param[in] color_body * @li optional: expects type fb_pixel_t, defines color color, default = COL_MENUCONTENT_PLUS_0 * @param[in] color_shadow * @li optional: expects type fb_pixel_t, defines shadow color, default = COL_SHADOW_PLUS_0 + * + * @note Discret dimensions parameters: values < 0 to -100 will be interpreted as percent values related to screen. + * For better readability please use placeholder 'CCW_PERCENATL' as negative sign '-' \n + * Example: \n + * this inits a window with position x100 y100 on screen with dimensions 700px x 800px \n + * CComponentsWindow win(100, 100, 700, 800, "Test window");\n + * this inits a window with position x100 y100 on screen with 50% of screen size assigned with discret percental screen dimensions \n + * CComponentsWindow win(100, 100, CCW_PERCENATL 50, CCW_PERCENATL 50, "Test window"); */ CComponentsWindow( const int& x_pos, const int& y_pos, const int& w, const int& h, const std::string& caption = "",