From f849ff2612217fa51b19af4cff93d9a2730fb0f3 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 3 Nov 2012 12:33:52 +0100 Subject: [PATCH] menuewidget: fix menu position code after last uncool merge Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ad959d9e087691145a4cf736122eea28d2730411 Author: Stefan Seyfried Date: 2012-11-03 (Sat, 03 Nov 2012) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/widget/menue.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 30b95e5b2..fc4ed6954 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -889,11 +889,15 @@ void CMenuWidget::calcSize() full_width = /*ConnectLineBox_Width+*/width+sb_width+SHADOW_OFFSET; full_height = height+RADIUS_LARGE+SHADOW_OFFSET*2 /*+hint_height+INFO_BOX_Y_OFFSET*/; - /* 2 times ConnectLineBox_Width for symmetry */ - if (full_width + 2 * ConnectLineBox_Width > (int)frameBuffer->getScreenWidth()) + /* + ConnectLineBox_Width for the hintbox connection line + * + center_offset for symmetry + * + 20 for setMenuPos calculates 10 pixels border left and right */ + int center_offset = (g_settings.menu_pos == MENU_POS_CENTER) ? ConnectLineBox_Width : 0; + int max_possible = (int)frameBuffer->getScreenWidth() - ConnectLineBox_Width - center_offset - 20; + if (full_width > max_possible) { - width = frameBuffer->getScreenWidth() - 2 * ConnectLineBox_Width - sb_width - SHADOW_OFFSET; - full_width = frameBuffer->getScreenWidth() - ConnectLineBox_Width; + width = max_possible - sb_width - SHADOW_OFFSET; + full_width = max_possible + center_offset; /* symmetry in MENU_POS_CENTER case */ } setMenuPos(full_width); @@ -934,17 +938,21 @@ void CMenuWidget::setMenuPos(const int& menu_width) int scr_w = frameBuffer->getScreenWidth(); int scr_h = frameBuffer->getScreenHeight(); + int real_h = full_height + hint_height; + //configured positions switch(g_settings.menu_pos) { case MENU_POS_CENTER: x = offx + scr_x + ((scr_w - menu_width ) >> 1 ); - y = offy + scr_y + ((scr_h - full_height) >> 1 ); + y = offy + scr_y + ((scr_h - real_h) >> 1 ); + x += ConnectLineBox_Width; break; case MENU_POS_TOP_LEFT: y = offy + scr_y + 10; x = offx + scr_x + 10; + x += ConnectLineBox_Width; break; case MENU_POS_TOP_RIGHT: @@ -953,16 +961,16 @@ void CMenuWidget::setMenuPos(const int& menu_width) break; case MENU_POS_BOTTOM_LEFT: - y = /*offy +*/ scr_y + scr_h - full_height - 10; + y = /*offy +*/ scr_y + scr_h - real_h - 10; x = offx + scr_x + 10; + x += ConnectLineBox_Width; break; case MENU_POS_BOTTOM_RIGHT: - y = /*offy +*/ scr_y + scr_h - full_height - 10; + y = /*offy +*/ scr_y + scr_h - real_h - 10; x = /*offx +*/ scr_x + scr_w - menu_width - 10; break; } - x += ConnectLineBox_Width; } void CMenuWidget::paintItems()