diff --git a/src/gui/buildinfo.cpp b/src/gui/buildinfo.cpp index 45b87a2c6..5bbadcbe5 100644 --- a/src/gui/buildinfo.cpp +++ b/src/gui/buildinfo.cpp @@ -3,7 +3,7 @@ Copyright (C) 2001 by Steffen Hehn 'McClean' Copyright (C) 2013, M. Liebmann 'micha-bbg' - Copyright (C) 2013, Thilo Graf 'dbt' + Copyright (C) 2013-2014, Thilo Graf 'dbt' License: GPL @@ -43,7 +43,7 @@ CBuildInfo::CBuildInfo() : CComponentsWindow(0, 0, 700, 500, LOCALE_BUILDINFO_ME //init all var members void CBuildInfo::initVarBuildInfo() { - doCenter(); + setCenterPos(); font = NULL; setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT); diff --git a/src/gui/components/cc_base.h b/src/gui/components/cc_base.h index 175b30580..f9ecf678b 100644 --- a/src/gui/components/cc_base.h +++ b/src/gui/components/cc_base.h @@ -3,7 +3,7 @@ Copyright (C) 2001 by Steffen Hehn 'McClean' Classes for generic GUI-related components. - Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012-2014, Thilo Graf 'dbt' License: GPL @@ -294,6 +294,9 @@ class CComponentsItem : public CComponents ///set x and y position as percent value from current parent or screen dimensions at once ///Note: position of bound components (items) means position related within parent form, not for screen! virtual void setPosP(const uint8_t& xpos_percent, const uint8_t& ypos_percent); + + ///do center item on screen or within a parent form, parameter along_mode assigns direction of centering + virtual void setCenterPos(int along_mode = CC_ALONG_X | CC_ALONG_Y); }; #endif diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp index f5021d580..629b3386a 100644 --- a/src/gui/components/cc_frm_window.cpp +++ b/src/gui/components/cc_frm_window.cpp @@ -29,7 +29,6 @@ #include #include #include "cc_frm_window.h" -#include using namespace std; @@ -146,11 +145,6 @@ void CComponentsWindow::initWindowPos() y = frameBuffer->getScreenY(); } -void CComponentsWindow::doCenter(){ - 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) { ccw_caption = g_Locale->getText(locale_text); diff --git a/src/gui/components/cc_frm_window.h b/src/gui/components/cc_frm_window.h index d658bd090..de4761f0d 100644 --- a/src/gui/components/cc_frm_window.h +++ b/src/gui/components/cc_frm_window.h @@ -90,8 +90,6 @@ class CComponentsWindow : public CComponentsForm fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, 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 diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp index e9cc06486..fc74d73b0 100644 --- a/src/gui/components/cc_item.cpp +++ b/src/gui/components/cc_item.cpp @@ -182,3 +182,11 @@ void CComponentsItem::setPosP(const uint8_t& xpos_percent, const uint8_t& ypos_p setXPosP(xpos_percent); setYPosP(ypos_percent); } + +void CComponentsItem::setCenterPos(int along_mode) +{ + if (along_mode & CC_ALONG_X) + x = cc_parent ? cc_parent->getWidth() - width/2 : getScreenStartX(width); + if (along_mode & CC_ALONG_Y) + y = cc_parent ? cc_parent->getHeight() - height/2 : getScreenStartY(height); +} diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index 401c3c44d..2d790e669 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -3,7 +3,7 @@ Copyright (C) 2001 by Steffen Hehn 'McClean' Classes for generic GUI-related components. - Copyright (C) 2012, 2013, Thilo Graf 'dbt' + Copyright (C) 2012-2014, Thilo Graf 'dbt' License: GPL @@ -110,6 +110,13 @@ enum CC_ALIGN_VER_CENTER = 32 }; +//item centering modes, see also CComponentsItem::setCenterPos() +enum +{ + CC_ALONG_X = 1, + CC_ALONG_Y = 2 +}; + enum { CC_ITEMBOX_ICON,