mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
CComponentsWindow: add member doCenter()
Allows centering of window on screen, mostly senseful for window objects without parent
This commit is contained in:
@@ -80,11 +80,13 @@ 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 centering if default values == 0
|
||||
width = w == 0 ? frameBuffer->getScreenWidth(true) : w;
|
||||
height = h == 0 ? frameBuffer->getScreenHeight(true) : h;
|
||||
x = x_pos == (CC_CENTERED || 0) ? getScreenStartX(width)/2 - width/2 : x_pos;
|
||||
y = y_pos == (CC_CENTERED || 0) ? getScreenStartY(height)/2 - height/2 : y_pos;
|
||||
//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;
|
||||
|
||||
ccw_caption = caption;
|
||||
ccw_icon_name = iconname;
|
||||
@@ -108,6 +110,11 @@ void CComponentsWindow::initVarWindow( const int& x_pos, const int& y_pos, const
|
||||
initCCWItems();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode)
|
||||
{
|
||||
ccw_caption = g_Locale->getText(locale_text);
|
||||
|
@@ -89,6 +89,8 @@ 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();
|
||||
|
||||
public:
|
||||
enum
|
||||
|
Reference in New Issue
Block a user