From 8db34d00203fa30257ceedace95c62a26778a41d Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 14 Sep 2017 21:37:44 +0200 Subject: [PATCH 1/5] colorchooser: rework tis gui-element; ... * use OFFSET defines * rename some variables * use paintBoxFrame() instead of background-icon; this avoids scaling issues on higher resolutions; scaled icons are ugly Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/b1f2a1e100212c1f0f43c9272a9b98319ccb462a Author: vanhofen Date: 2017-09-14 (Thu, 14 Sep 2017) Origin message was: ------------------ - colorchooser: rework tis gui-element; ... * use OFFSET defines * rename some variables * use paintBoxFrame() instead of background-icon; this avoids scaling issues on higher resolutions; scaled icons are ugly --- src/gui/widget/colorchooser.cpp | 272 +++++++++++++++++--------------- src/gui/widget/colorchooser.h | 68 ++++---- 2 files changed, 181 insertions(+), 159 deletions(-) diff --git a/src/gui/widget/colorchooser.cpp b/src/gui/widget/colorchooser.cpp index 5eef2d02e..5a4faf130 100644 --- a/src/gui/widget/colorchooser.cpp +++ b/src/gui/widget/colorchooser.cpp @@ -1,32 +1,22 @@ /* - Neutrino-GUI - DBoxII-Project + Based up Neutrino-GUI - Tuxbox-Project Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. - License: GPL - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #ifdef HAVE_CONFIG_H @@ -46,55 +36,67 @@ #include #include - -#define VALUE_R 0 -#define VALUE_G 1 -#define VALUE_B 2 -#define VALUE_ALPHA 3 - -static const char * const iconnames[4] = { +static const char * const icon_names[VALUES] = +{ NEUTRINO_ICON_VOLUMESLIDER2RED, NEUTRINO_ICON_VOLUMESLIDER2GREEN, NEUTRINO_ICON_VOLUMESLIDER2BLUE, NEUTRINO_ICON_VOLUMESLIDER2ALPHA }; -static const neutrino_locale_t colorchooser_names[4] = +static const neutrino_locale_t colorchooser_names[VALUES] = { - LOCALE_COLORCHOOSER_RED , + LOCALE_COLORCHOOSER_RED, LOCALE_COLORCHOOSER_GREEN, - LOCALE_COLORCHOOSER_BLUE , + LOCALE_COLORCHOOSER_BLUE, LOCALE_COLORCHOOSER_ALPHA }; -CColorChooser::CColorChooser(const neutrino_locale_t Name, unsigned char *R, unsigned char *G, unsigned char *B, unsigned char* Alpha, CChangeObserver* Observer) // UTF-8 +CColorChooser::CColorChooser(const neutrino_locale_t Name, unsigned char *R, unsigned char *G, unsigned char *B, unsigned char* A, CChangeObserver* Observer) { frameBuffer = CFrameBuffer::getInstance(); - hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); - mheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - font_info = SNeutrinoSettings::FONT_TYPE_MENU; + header_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + item_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); observer = Observer; name = Name; - //calculate max width of LOCALS - offset = 0; - for (int i = 0; i < 4; i++) { - int tmpoffset = g_Font[font_info]->getRenderWidth(g_Locale->getText(colorchooser_names[i])); - if (tmpoffset > offset) { - offset = tmpoffset; - } + // calculate max width of locals + text_width = 0; + for (int i = 0; i < VALUES; i++) + { + int tmp_text_width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(colorchooser_names[i])); + if (tmp_text_width > text_width) + text_width = tmp_text_width; } - width = w_max((offset + (162 + mheight*4 + 10)), 0); - height = h_max(hheight+ mheight* 4, 0); + // assuming all sliders have same dimensions + int dummy; + frameBuffer->getIconSize(NEUTRINO_ICON_VOLUMESLIDER2ALPHA, &slider_width, &dummy); - x = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth()-width) >> 1); - y = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight()-height)>>1); + bar_width = frameBuffer->scale2Res(150); + /* + We have a half slider_width before and after the bar + to get the middle of the slider at the point of choise + */ + bar_offset = slider_width/2; + bar_full = bar_width + slider_width; - value[VALUE_R] = R; - value[VALUE_G] = G; - value[VALUE_B] = B; - value[VALUE_ALPHA] = Alpha; + preview_w = VALUES*item_height; + preview_h = VALUES*item_height; + + width = w_max((text_width + bar_full + preview_w + 4*OFFSET_INNER_MID), 0); + height = h_max((header_height + VALUES*item_height + 2*OFFSET_INNER_SMALL), 0); + + x = getScreenStartX(width); + y = getScreenStartY(height); + + preview_x = x + text_width + bar_full + 3*OFFSET_INNER_MID; + preview_y = y + header_height + OFFSET_INNER_SMALL; + + value[VALUE_R] = R; + value[VALUE_G] = G; + value[VALUE_B] = B; + value[VALUE_A] = A; chooser_gradient = gradient_none; } @@ -102,13 +104,10 @@ CColorChooser::CColorChooser(const neutrino_locale_t Name, unsigned char *R, uns void CColorChooser::setColor() { fb_pixel_t col = getColor(); - int x_col = x+offset+160; - int y_col = y+hheight+5; - int w_col = mheight*4; - int h_col = mheight*4-10; - if ((g_settings.theme.menu_Head_gradient) && ((chooser_gradient == gradient_head_body) || (chooser_gradient == gradient_head_text))) { - CComponentsHeader header(x_col, y_col+((h_col-hheight)/2), w_col, hheight, "Head"); + if ((g_settings.theme.menu_Head_gradient) && ((chooser_gradient == gradient_head_body) || (chooser_gradient == gradient_head_text))) + { + CComponentsHeader header(preview_x, preview_y+((preview_h-header_height)/2), preview_w, header_height, "Head"); if (chooser_gradient == gradient_head_body) header.setColorBody(col); else if (chooser_gradient == gradient_head_text) @@ -116,15 +115,20 @@ void CColorChooser::setColor() header.paint(CC_SAVE_SCREEN_NO); } else - frameBuffer->paintBoxRel(x_col+2, y_col+2, w_col-4 , h_col-4, col); + { + CComponentsShapeSquare preview(preview_x, preview_y, preview_w, preview_h, NULL, false, COL_FRAME_PLUS_0, col); + preview.setFrameThickness(1); + preview.setCorner(RADIUS_SMALL); + preview.paint(false); + } } fb_pixel_t CColorChooser::getColor() { int color = convertSetupColor2RGB(*(value[VALUE_R]), *(value[VALUE_G]), *(value[VALUE_B])); - int tAlpha = (value[VALUE_ALPHA]) ? (convertSetupAlpha2Alpha(*(value[VALUE_ALPHA]))) : 0xFF; + int alpha = (value[VALUE_A]) ? (convertSetupAlpha2Alpha(*(value[VALUE_A]))) : 0xFF; - return (((tAlpha << 24) & 0xFF000000) | color); + return (((alpha << 24) & 0xFF000000) | color); } int CColorChooser::exec(CMenuTarget* parent, const std::string &) @@ -136,91 +140,94 @@ int CColorChooser::exec(CMenuTarget* parent, const std::string &) if (parent) parent->hide(); - unsigned char r_alt= *value[VALUE_R]; - unsigned char g_alt= *value[VALUE_G]; - unsigned char b_alt= *value[VALUE_B]; + unsigned char r_alt = *value[VALUE_R]; + unsigned char g_alt = *value[VALUE_G]; + unsigned char b_alt = *value[VALUE_B]; unsigned char a_null = 0; - unsigned char a_alt = (value[VALUE_ALPHA]) ? (*(value[VALUE_ALPHA])) : a_null; + unsigned char a_alt = (value[VALUE_A]) ? (*(value[VALUE_A])) : a_null; paint(); setColor(); int selected = 0; - uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings - ::TIMING_MENU]); + uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); bool loop=true; while (loop) { g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true); if ( msg <= CRCInput::RC_MaxRC ) - timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings - ::TIMING_MENU]); + timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); int val = (*value[selected]); switch ( msg ) { case CRCInput::RC_down: + { + if (selected < ((value[VALUE_A]) ? 3 : 2)) { - if (selected < ((value[VALUE_ALPHA]) ? 3 : 2)) - { - paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], false); - selected++; - paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true); - } else { - paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], false); - selected = 0; - paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true); - } - break; - + paintSlider(x, y + header_height + OFFSET_INNER_SMALL + item_height * selected, value[selected], colorchooser_names[selected], icon_names[selected], false); + selected++; + paintSlider(x, y + header_height + OFFSET_INNER_SMALL + item_height * selected, value[selected], colorchooser_names[selected], icon_names[selected], true); } + else + { + paintSlider(x, y + header_height + OFFSET_INNER_SMALL + item_height * selected, value[selected], colorchooser_names[selected], icon_names[selected], false); + selected = 0; + paintSlider(x, y + header_height + OFFSET_INNER_SMALL + item_height * selected, value[selected], colorchooser_names[selected], icon_names[selected], true); + } + break; + + } case CRCInput::RC_up: + { + if (selected > 0) { - if (selected > 0) - { - paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], false); - selected--; - paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true); - } else { - paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], false); - selected = ((value[VALUE_ALPHA]) ? 3 : 2); - paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true); - } - break; + paintSlider(x, y + header_height + OFFSET_INNER_SMALL + item_height * selected, value[selected], colorchooser_names[selected], icon_names[selected], false); + selected--; + paintSlider(x, y + header_height + OFFSET_INNER_SMALL + item_height * selected, value[selected], colorchooser_names[selected], icon_names[selected], true); } + else + { + paintSlider(x, y + header_height + OFFSET_INNER_SMALL + item_height * selected, value[selected], colorchooser_names[selected], icon_names[selected], false); + selected = ((value[VALUE_A]) ? 3 : 2); + paintSlider(x, y + header_height + OFFSET_INNER_SMALL + item_height * selected, value[selected], colorchooser_names[selected], icon_names[selected], true); + } + break; + } case CRCInput::RC_right: + { + if (val < 100) { - if (val < 100) - { - if (val < 98) - val += 2; - else - val = 100; - (*value[selected]) = (uint8_t)val; + if (val < 98) + val += 2; + else + val = 100; + (*value[selected]) = (uint8_t)val; - paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true); - setColor(); - } - break; + paintSlider(x, y + header_height + OFFSET_INNER_SMALL + item_height * selected, value[selected], colorchooser_names[selected], icon_names[selected], true); + setColor(); } + break; + } case CRCInput::RC_left: + { + if (val > 0) { - if (val > 0) - { - if (val > 2) - val -= 2; - else - val = 0; - (*value[selected]) = (uint8_t)val; + if (val > 2) + val -= 2; + else + val = 0; + (*value[selected]) = (uint8_t)val; - paintSlider(x + 10, y + hheight + mheight * selected, value[selected], colorchooser_names[selected], iconnames[selected], true); - setColor(); - } - break; + paintSlider(x, y + header_height + OFFSET_INNER_SMALL + item_height * selected, value[selected], colorchooser_names[selected], icon_names[selected], true); + setColor(); } + break; + } case CRCInput::RC_home: - if (((*value[VALUE_R] != r_alt) || (*value[VALUE_G] != g_alt) || (*value[VALUE_B] != b_alt) || ((value[VALUE_ALPHA]) && (*(value[VALUE_ALPHA]) != a_alt))) && + { + if (((*value[VALUE_R] != r_alt) || (*value[VALUE_G] != g_alt) || (*value[VALUE_B] != b_alt) || ((value[VALUE_A]) && (*(value[VALUE_A]) != a_alt))) && (ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbCancel) == CMsgBox::mbrCancel)) break; @@ -228,15 +235,19 @@ int CColorChooser::exec(CMenuTarget* parent, const std::string &) *value[VALUE_R] = r_alt; *value[VALUE_G] = g_alt; *value[VALUE_B] = b_alt; - if (value[VALUE_ALPHA]) - *value[VALUE_ALPHA] = a_alt; + if (value[VALUE_A]) + *value[VALUE_A] = a_alt; loop = false; break; + } case CRCInput::RC_timeout: case CRCInput::RC_ok: + { loop = false; break; + } default: + { if (CNeutrinoApp::getInstance()->listModeKey(msg)) { break; @@ -246,12 +257,13 @@ int CColorChooser::exec(CMenuTarget* parent, const std::string &) loop = false; res = menu_return::RETURN_EXIT_ALL; } + } } } hide(); - if(observer) + if (observer) observer->changeNotify(name, NULL); return res; @@ -259,33 +271,37 @@ int CColorChooser::exec(CMenuTarget* parent, const std::string &) void CColorChooser::hide() { - frameBuffer->paintBackgroundBoxRel(x,y, width,height); + frameBuffer->paintBackgroundBoxRel(x, y, width, height); } void CColorChooser::paint() { - CComponentsHeader header(x, y, width, hheight, g_Locale->getText(name)); + CComponentsHeader header(x, y, width, header_height, g_Locale->getText(name)); + header.enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT); header.paint(CC_SAVE_SCREEN_NO); - frameBuffer->paintBoxRel(x,y+hheight, width,height-hheight, COL_MENUCONTENT_PLUS_0, RADIUS_MID, CORNER_BOTTOM);//round + PaintBoxRel(x, y + header_height, width, height - header_height, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM, CC_SHADOW_ON); - for (int i = 0; i < 4; i++) - paintSlider(x + 10, y + hheight + mheight * i, value[i], colorchooser_names[i], iconnames[i], (i == 0)); - - if ((!g_settings.theme.menu_Head_gradient) || ((chooser_gradient != gradient_head_body) && (chooser_gradient != gradient_head_text))) { - //color preview - frameBuffer->paintBoxRel(x+offset+160,y+hheight+5, mheight*4, mheight*4-10, COL_MENUHEAD_PLUS_0); - frameBuffer->paintBoxRel(x+offset+162,y+hheight+2+5, mheight*4-4 ,mheight*4-4-10, 254); - } + for (int i = 0; i < VALUES; i++) + paintSlider(x, y + header_height + OFFSET_INNER_SMALL + i*item_height, value[i], colorchooser_names[i], icon_names[i], (i == 0)); } void CColorChooser::paintSlider(int px, int py, unsigned char *spos, const neutrino_locale_t text, const char * const iconname, const bool selected) { if (!spos) return; - frameBuffer->paintBoxRel(px+offset+10,py,120,mheight, COL_MENUCONTENT_PLUS_0); - frameBuffer->paintIcon(NEUTRINO_ICON_VOLUMEBODY,px+offset+10,py+2+mheight/4); - frameBuffer->paintIcon(selected ? iconname : NEUTRINO_ICON_VOLUMESLIDER2,px+offset+13+(*spos),py+mheight/4); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(px,py+mheight, width, g_Locale->getText(text), COL_MENUCONTENT_TEXT); + // clear area + frameBuffer->paintBoxRel(px + text_width + 2*OFFSET_INNER_MID, py, bar_full, item_height, COL_MENUCONTENT_PLUS_0); + // paint bar + /* + NEUTRINO_ICON_VOLUMEBODY should be scaled to bar_width. + So long we paint a simple frame. This is more save on higher resolutions. + */ + //frameBuffer->paintIcon(NEUTRINO_ICON_VOLUMEBODY, px + text_width + 2*OFFSET_INNER_MID + bar_offset, py, item_height); + frameBuffer->paintBoxFrame(px + text_width + 2*OFFSET_INNER_MID + bar_offset, py + item_height/3, bar_width, item_height/3, 1, COL_FRAME_PLUS_0); + // paint slider + frameBuffer->paintIcon(selected ? iconname : NEUTRINO_ICON_VOLUMESLIDER2, px + text_width + 2*OFFSET_INNER_MID + ((*spos)*bar_width / 100), py, item_height); + + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(px + OFFSET_INNER_MID, py + item_height, text_width, g_Locale->getText(text), COL_MENUCONTENT_TEXT); } diff --git a/src/gui/widget/colorchooser.h b/src/gui/widget/colorchooser.h index 1a0503a6e..02c8d9536 100644 --- a/src/gui/widget/colorchooser.h +++ b/src/gui/widget/colorchooser.h @@ -1,32 +1,22 @@ /* - Neutrino-GUI - DBoxII-Project + Based up Neutrino-GUI - Tuxbox-Project Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - Kommentar: - - Diese GUI wurde von Grund auf neu programmiert und sollte nun vom - Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert - auf der Client-Server Idee, diese GUI ist also von der direkten DBox- - Steuerung getrennt. Diese wird dann von Daemons uebernommen. - - + License: GPL - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ @@ -38,21 +28,40 @@ #include +enum { + VALUE_R = 0, // red + VALUE_G = 1, // green + VALUE_B = 2, // blue + VALUE_A = 3, // alpha + + VALUES +}; + class CFrameBuffer; class CColorChooser : public CMenuTarget { private: - CFrameBuffer *frameBuffer; + CFrameBuffer *frameBuffer; int x; int y; int width; int height; - int hheight,mheight; // head/menu font height - int offset; - int font_info; + int header_height; + int item_height; + int text_width; + int bar_width; + int bar_offset; + int bar_full; + int slider_width; + int slider_step; + int preview_x; + int preview_y; + int preview_w; + int preview_h; + int chooser_gradient; - unsigned char * value[4]; // r, g, b, alpha + unsigned char * value[VALUES]; neutrino_locale_t name; @@ -63,8 +72,7 @@ class CColorChooser : public CMenuTarget void paintSlider(int x, int y, unsigned char *spos, const neutrino_locale_t text, const char * const iconname, const bool selected); public: - - CColorChooser(const neutrino_locale_t Name, unsigned char *R, unsigned char *G, unsigned char *B, unsigned char* Alpha, CChangeObserver* Observer = NULL); // UTF-8 + CColorChooser(const neutrino_locale_t Name, unsigned char *R, unsigned char *G, unsigned char *B, unsigned char* A, CChangeObserver* Observer = NULL); void hide(); int exec(CMenuTarget* parent, const std::string & actionKey); @@ -78,6 +86,4 @@ class CColorChooser : public CMenuTarget void setGradient(int gradient = gradient_none) { chooser_gradient = gradient; }; }; - #endif - From eb679c54ec19325a602e461caa8cc546822606ca Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 14 Sep 2017 21:37:44 +0200 Subject: [PATCH 2/5] menu: rework slider; ... * rename some variables * use paintBoxFrame() instead of background-icon; this avoids scaling issues on higher resolutions; scaled icons are ugly Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/5c22aa705869d7b4bfcbea97e1099e4b12ec3bbb Author: vanhofen Date: 2017-09-14 (Thu, 14 Sep 2017) Origin message was: ------------------ - menu: rework slider; ... * rename some variables * use paintBoxFrame() instead of background-icon; this avoids scaling issues on higher resolutions; scaled icons are ugly --- src/gui/widget/menue.cpp | 50 ++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 6d35e918d..16c2c5c53 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -304,25 +304,45 @@ void CMenuItem::prepareItem(const bool select_mode, const int &item_height) void CMenuItem::paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text, const char * right_text) { CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); - int slider_lenght = 0, h = 0; - frameBuffer->getIconSize(NEUTRINO_ICON_VOLUMEBODY, &slider_lenght, &h); - if(slider_lenght == 0 || factor < optionvalue ) - return; - int stringwidth = 0; - if (right_text != NULL) { - stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("U999"); - } - int stringwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text); - int maxspace = dx - stringwidth - icon_frame_w - stringwidth2 - OFFSET_INNER_MID; - if(maxspace < slider_lenght) + // assuming all sliders have same dimensions + int slider_width, dummy; + frameBuffer->getIconSize(NEUTRINO_ICON_VOLUMESLIDER2ALPHA, &slider_width, &dummy); + + int bar_width = frameBuffer->scale2Res(100); + /* + We have a half slider_width before and after the bar + to get the middle of the slider at the point of choise + */ + int bar_offset = slider_width/2; + int bar_full = bar_width + slider_width; + + // avoid division by zero + if (factor < optionvalue || factor < 1) + return; + + int right_needed = 0; + if (right_text != NULL) + { + right_needed = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("U999"); + } + int left_needed = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text); + + int space = dx - right_needed - icon_frame_w - left_needed - OFFSET_INNER_MID; + if (space < bar_full) return ; - int stringstartposOption = x + dx - stringwidth - slider_lenght; + int bar_x = x + dx - right_needed - bar_full; + + // FIXME: negative optionvalues falsifies the slider on the right side int optionV = (optionvalue < 0) ? 0 : optionvalue; - frameBuffer->paintBoxRel(stringstartposOption, y, slider_lenght, item_height, item_bgcolor); - frameBuffer->paintIcon(NEUTRINO_ICON_VOLUMEBODY, stringstartposOption, y+2+item_height/4); - frameBuffer->paintIcon(select_mode ? NEUTRINO_ICON_VOLUMESLIDER2BLUE : NEUTRINO_ICON_VOLUMESLIDER2, (stringstartposOption + (optionV * 100 / factor)), y+item_height/4); + + // clear area + frameBuffer->paintBoxRel(bar_x, y, bar_full, item_height, item_bgcolor); + // paint bar + frameBuffer->paintBoxFrame(bar_x + bar_offset, y + item_height/3, bar_width, item_height/3, 1, COL_MENUCONTENT_TEXT); + // paint slider + frameBuffer->paintIcon(select_mode ? NEUTRINO_ICON_VOLUMESLIDER2ALPHA : NEUTRINO_ICON_VOLUMESLIDER2, bar_x + (optionV*bar_width / factor), y, item_height); } void CMenuItem::paintItemButton(const bool select_mode, int item_height, const char * const icon_Name) From 8d9030f1f43b78d3bd2eac96766ac3de3c335f3a Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 14 Sep 2017 21:37:44 +0200 Subject: [PATCH 3/5] icons: new slider icons with material colors Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/0b09d125fc5337aed3b70e020c7f9195a79c2cf8 Author: vanhofen Date: 2017-09-14 (Thu, 14 Sep 2017) Origin message was: ------------------ - icons: new slider icons with material colors --- data/icons/slider/volumeslider2.png | Bin 209 -> 239 bytes data/icons/slider/volumeslider2alpha.png | Bin 209 -> 238 bytes data/icons/slider/volumeslider2blue.png | Bin 209 -> 256 bytes data/icons/slider/volumeslider2green.png | Bin 209 -> 261 bytes data/icons/slider/volumeslider2red.png | Bin 209 -> 259 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/data/icons/slider/volumeslider2.png b/data/icons/slider/volumeslider2.png index 051915adbdf504a0189ab213ecc3ff912e3ba96b..7e46eaaf1467915bfe03b6f0f9cd6190cb284c7f 100644 GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VTavfC3&Vd9T(EcfWS|IVfk$L9 z0|U1(2s1Lwnj--eWH0gbb!C6Z$;ZVkr?73#W}r}wr;B5V#p$Di-V_eYPop%{HDo!=J4hfG~Z|V?6Y#K+5QPn0tv e=HE-KbNDCh)Se#aWfui>2ZN`ppUXO@geCx*c~Q>* literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!cYsfb>;M1%XU(1E4UOqx2Wy`$aV*Wbs>2dJ#7swzJ}KRYWsEiDbGB`Gl}E+#H2 zA}TB-EI1%o@Uy!(&{*b@AU}}tzsio>15!qwE{-7*;mHXO>^(7e{xCH;DJ@ERBxJM4 zhli(T&77P!XLMwA&b-N)v*wU<6vN@-7Yqz54A}0ol$_20>SpkC^>bP0l+XkKWoSq+ diff --git a/data/icons/slider/volumeslider2alpha.png b/data/icons/slider/volumeslider2alpha.png index 5916c9084cafb744d749ed7407b586a4279cc70d..c311c61e24648ef71aa624a4e2879c745e2bc93d 100644 GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VTavfC3&Vd9T(EcfWS|IVfk$L9 z0|U1(2s1Lwnj--eWH0gbb!C6Z$;ZXWJI!wYd!SIYr;B5V#p$ ze8;QxYWhvZ*D|Yjg}GUXrMz4(py?XgvsT?$e(l!DPk0xcaPr_|2v@88e$U%wO~s;B zN6*Y-Nsts4?Brk!xa4#5?$Nu;AE@Z3H%s4nV1B?Rc-7W(`YM(orIj;Rah;sV7?bvG dPYL6G`;|dDH`s*gx`EDM@O1TaS?83{1OU?NP?P`w literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!cYsfb>;M1%XU(1EQz zwPEvyx%1~voIKIi)^_=-<&&mPYVTkj;uj1ID-77~vy`090P1G&boFyt=akR{0I$wU A@&Et; diff --git a/data/icons/slider/volumeslider2blue.png b/data/icons/slider/volumeslider2blue.png index a8ac4394a8899778696a3d8af933a9dd5907e023..b80a83bdfe5550ecd2b98a12f04ae072611ffc52 100644 GIT binary patch literal 256 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VTavfC3&Vd9T(EcfWS|IVfk$L9 z0|U1(2s1Lwnj--eWH0gbb!C6Z$;ZXabD96`Z;%0=E{-7$L- z3r+8^l+RS)K61l4WA2O;{_=yq*9_i0z4T#%D2tcqm#@V&-;M1%XU(1EgTe~DWM4fu=+<3 diff --git a/data/icons/slider/volumeslider2green.png b/data/icons/slider/volumeslider2green.png index 5c53fc8796d69339ca4b194b85d3a52f97514a1e..56cce35030024d3b351675968a793b6183e60fd3 100644 GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VTavfC3&Vd9T(EcfWS|IVfk$L9 z0|U1(2s1Lwnj--eWH0gbb!C6Z$;ZWH#k$T@87MT#)5S5w;`H0A8+i{ah_GDvZ>eHs z%<$%6lbUu)V}xYWwN~+sb3E?^r0`cWT-y0VNn2r})}vRKFP9!SJhodT^5BLm0-B!~ zA1_>bV%DeIa@TJ@nrNQKQFcc};;e+=#lpEPZK0-5x4fA$Z7)~Ym&YX=nq~j+2V9?W zsAhG%hU+Htb(J&C`<8fIOYk|^r*F`9jQd1_&HkUebv1YIII;M1%XU(1EEak-ar*7mjhu%K1XwRv*Iq4q z`cBLsh3TQ{CI_ds3pQ#qT`QQJ#R8Ulz3e~D#k7>`*VpGCcb_*rroH+d+nFnZVSgnG zKCjso-eAv#cTe@eNOSYHqhQ;#f4a_nR>Kpbg{c>;H zx7IaL-5%dJDLJi)+ROOexMezH@N?D>X1RE=pL#PG5C78zx{blp)z4*}Q$iB}{Ucq* literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!cYsfb>;M1%XU(1E Date: Thu, 14 Sep 2017 22:00:41 +0200 Subject: [PATCH 4/5] rename SLIDER defines Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/978d72ac00d165fe44b4ee8349be5705269eee25 Author: vanhofen Date: 2017-09-14 (Thu, 14 Sep 2017) Origin message was: ------------------ - rename SLIDER defines --- src/gui/components/cc_frm_slider.cpp | 4 ++-- src/gui/widget/colorchooser.cpp | 16 ++++++++-------- src/gui/widget/icons.h | 13 +++++++------ src/gui/widget/menue.cpp | 4 ++-- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/gui/components/cc_frm_slider.cpp b/src/gui/components/cc_frm_slider.cpp index e697f24ba..29f06fefb 100644 --- a/src/gui/components/cc_frm_slider.cpp +++ b/src/gui/components/cc_frm_slider.cpp @@ -59,8 +59,8 @@ CComponentsSlider::CComponentsSlider( const int& x_pos, const int& y_pos, const csl_body_obj = NULL; csl_slider_obj = NULL; - csl_body_icon = NEUTRINO_ICON_VOLUMEBODY; - csl_slider_icon =NEUTRINO_ICON_VOLUMESLIDER2; + csl_body_icon = NEUTRINO_ICON_SLIDER_BODY; + csl_slider_icon =NEUTRINO_ICON_SLIDER_INACTIVE; initCCSlItems(); initParent(parent); diff --git a/src/gui/widget/colorchooser.cpp b/src/gui/widget/colorchooser.cpp index 5a4faf130..bee59edb0 100644 --- a/src/gui/widget/colorchooser.cpp +++ b/src/gui/widget/colorchooser.cpp @@ -38,10 +38,10 @@ static const char * const icon_names[VALUES] = { - NEUTRINO_ICON_VOLUMESLIDER2RED, - NEUTRINO_ICON_VOLUMESLIDER2GREEN, - NEUTRINO_ICON_VOLUMESLIDER2BLUE, - NEUTRINO_ICON_VOLUMESLIDER2ALPHA + NEUTRINO_ICON_SLIDER_RED, + NEUTRINO_ICON_SLIDER_GREEN, + NEUTRINO_ICON_SLIDER_BLUE, + NEUTRINO_ICON_SLIDER_ALPHA }; static const neutrino_locale_t colorchooser_names[VALUES] = @@ -71,7 +71,7 @@ CColorChooser::CColorChooser(const neutrino_locale_t Name, unsigned char *R, uns // assuming all sliders have same dimensions int dummy; - frameBuffer->getIconSize(NEUTRINO_ICON_VOLUMESLIDER2ALPHA, &slider_width, &dummy); + frameBuffer->getIconSize(NEUTRINO_ICON_SLIDER_ALPHA, &slider_width, &dummy); bar_width = frameBuffer->scale2Res(150); /* @@ -295,13 +295,13 @@ void CColorChooser::paintSlider(int px, int py, unsigned char *spos, const neutr frameBuffer->paintBoxRel(px + text_width + 2*OFFSET_INNER_MID, py, bar_full, item_height, COL_MENUCONTENT_PLUS_0); // paint bar /* - NEUTRINO_ICON_VOLUMEBODY should be scaled to bar_width. + NEUTRINO_ICON_SLIDER_BODY should be scaled to bar_width. So long we paint a simple frame. This is more save on higher resolutions. */ - //frameBuffer->paintIcon(NEUTRINO_ICON_VOLUMEBODY, px + text_width + 2*OFFSET_INNER_MID + bar_offset, py, item_height); + //frameBuffer->paintIcon(NEUTRINO_ICON_SLIDER_BODY, px + text_width + 2*OFFSET_INNER_MID + bar_offset, py, item_height); frameBuffer->paintBoxFrame(px + text_width + 2*OFFSET_INNER_MID + bar_offset, py + item_height/3, bar_width, item_height/3, 1, COL_FRAME_PLUS_0); // paint slider - frameBuffer->paintIcon(selected ? iconname : NEUTRINO_ICON_VOLUMESLIDER2, px + text_width + 2*OFFSET_INNER_MID + ((*spos)*bar_width / 100), py, item_height); + frameBuffer->paintIcon(selected ? iconname : NEUTRINO_ICON_SLIDER_INACTIVE, px + text_width + 2*OFFSET_INNER_MID + ((*spos)*bar_width / 100), py, item_height); g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(px + OFFSET_INNER_MID, py + item_height, text_width, g_Locale->getText(text), COL_MENUCONTENT_TEXT); } diff --git a/src/gui/widget/icons.h b/src/gui/widget/icons.h index ab0710545..12e09dfbb 100644 --- a/src/gui/widget/icons.h +++ b/src/gui/widget/icons.h @@ -131,12 +131,6 @@ #define NEUTRINO_ICON_UPDATE "softupdate" #define NEUTRINO_ICON_UPNP "upnp" #define NEUTRINO_ICON_VIDEO "video" -#define NEUTRINO_ICON_VOLUMEBODY "volumebody" -#define NEUTRINO_ICON_VOLUMESLIDER2 "volumeslider2" -#define NEUTRINO_ICON_VOLUMESLIDER2ALPHA "volumeslider2alpha" -#define NEUTRINO_ICON_VOLUMESLIDER2BLUE "volumeslider2blue" -#define NEUTRINO_ICON_VOLUMESLIDER2GREEN "volumeslider2green" -#define NEUTRINO_ICON_VOLUMESLIDER2RED "volumeslider2red" #define NEUTRINO_ICON_VTXT "vtxt" #define NEUTRINO_ICON_VTXT_GREY "vtxt_gray" #define NEUTRINO_ICON_PARTITION "partition" @@ -187,6 +181,13 @@ #define DUMMY_ICON "dummy" +/* sliders */ +#define NEUTRINO_ICON_SLIDER_BODY "volumebody" +#define NEUTRINO_ICON_SLIDER_INACTIVE "volumeslider2" +#define NEUTRINO_ICON_SLIDER_RED "volumeslider2red" +#define NEUTRINO_ICON_SLIDER_GREEN "volumeslider2green" +#define NEUTRINO_ICON_SLIDER_BLUE "volumeslider2blue" +#define NEUTRINO_ICON_SLIDER_ALPHA "volumeslider2alpha" #define NEUTRINO_ICON_BUTTON_MUTE_ZAP_ACTIVE "mute_zap_green" #define NEUTRINO_ICON_BUTTON_MUTE_ZAP_INACTIVE "mute_zap_gray" diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 16c2c5c53..1d8e6d161 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -307,7 +307,7 @@ void CMenuItem::paintItemSlider( const bool select_mode, const int &item_height, // assuming all sliders have same dimensions int slider_width, dummy; - frameBuffer->getIconSize(NEUTRINO_ICON_VOLUMESLIDER2ALPHA, &slider_width, &dummy); + frameBuffer->getIconSize(NEUTRINO_ICON_SLIDER_ALPHA, &slider_width, &dummy); int bar_width = frameBuffer->scale2Res(100); /* @@ -342,7 +342,7 @@ void CMenuItem::paintItemSlider( const bool select_mode, const int &item_height, // paint bar frameBuffer->paintBoxFrame(bar_x + bar_offset, y + item_height/3, bar_width, item_height/3, 1, COL_MENUCONTENT_TEXT); // paint slider - frameBuffer->paintIcon(select_mode ? NEUTRINO_ICON_VOLUMESLIDER2ALPHA : NEUTRINO_ICON_VOLUMESLIDER2, bar_x + (optionV*bar_width / factor), y, item_height); + frameBuffer->paintIcon(select_mode ? NEUTRINO_ICON_SLIDER_ALPHA : NEUTRINO_ICON_SLIDER_INACTIVE, bar_x + (optionV*bar_width / factor), y, item_height); } void CMenuItem::paintItemButton(const bool select_mode, int item_height, const char * const icon_Name) From 0ecc03b4c9ea8e89eb90206d36ae47a618bc8854 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 14 Sep 2017 22:00:41 +0200 Subject: [PATCH 5/5] icons: rename slider icons to more logical names Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/b00caf1c31e25a56b4d85a240fc5d0562e3c5f61 Author: vanhofen Date: 2017-09-14 (Thu, 14 Sep 2017) Origin message was: ------------------ - icons: rename slider icons to more logical names --- data/icons/slider/Makefile.am | 12 ++++++------ .../{volumeslider2alpha.png => slider_alpha.png} | Bin .../{volumeslider2blue.png => slider_blue.png} | Bin .../slider/{volumebody.png => slider_body.png} | Bin .../{volumeslider2green.png => slider_green.png} | Bin .../{volumeslider2.png => slider_inactive.png} | Bin .../slider/{volumeslider2red.png => slider_red.png} | Bin src/gui/widget/icons.h | 12 ++++++------ 8 files changed, 12 insertions(+), 12 deletions(-) rename data/icons/slider/{volumeslider2alpha.png => slider_alpha.png} (100%) rename data/icons/slider/{volumeslider2blue.png => slider_blue.png} (100%) rename data/icons/slider/{volumebody.png => slider_body.png} (100%) rename data/icons/slider/{volumeslider2green.png => slider_green.png} (100%) rename data/icons/slider/{volumeslider2.png => slider_inactive.png} (100%) rename data/icons/slider/{volumeslider2red.png => slider_red.png} (100%) diff --git a/data/icons/slider/Makefile.am b/data/icons/slider/Makefile.am index ad3b0a21f..57d50c0f9 100644 --- a/data/icons/slider/Makefile.am +++ b/data/icons/slider/Makefile.am @@ -1,9 +1,9 @@ installdir = $(ICONSDIR) install_DATA = \ - volumebody.png \ - volumeslider2.png \ - volumeslider2alpha.png \ - volumeslider2blue.png \ - volumeslider2green.png \ - volumeslider2red.png + slider_alpha.png \ + slider_blue.png \ + slider_body.png \ + slider_green.png \ + slider_inactive.png \ + slider_red.png diff --git a/data/icons/slider/volumeslider2alpha.png b/data/icons/slider/slider_alpha.png similarity index 100% rename from data/icons/slider/volumeslider2alpha.png rename to data/icons/slider/slider_alpha.png diff --git a/data/icons/slider/volumeslider2blue.png b/data/icons/slider/slider_blue.png similarity index 100% rename from data/icons/slider/volumeslider2blue.png rename to data/icons/slider/slider_blue.png diff --git a/data/icons/slider/volumebody.png b/data/icons/slider/slider_body.png similarity index 100% rename from data/icons/slider/volumebody.png rename to data/icons/slider/slider_body.png diff --git a/data/icons/slider/volumeslider2green.png b/data/icons/slider/slider_green.png similarity index 100% rename from data/icons/slider/volumeslider2green.png rename to data/icons/slider/slider_green.png diff --git a/data/icons/slider/volumeslider2.png b/data/icons/slider/slider_inactive.png similarity index 100% rename from data/icons/slider/volumeslider2.png rename to data/icons/slider/slider_inactive.png diff --git a/data/icons/slider/volumeslider2red.png b/data/icons/slider/slider_red.png similarity index 100% rename from data/icons/slider/volumeslider2red.png rename to data/icons/slider/slider_red.png diff --git a/src/gui/widget/icons.h b/src/gui/widget/icons.h index 12e09dfbb..f812fab86 100644 --- a/src/gui/widget/icons.h +++ b/src/gui/widget/icons.h @@ -182,12 +182,12 @@ #define DUMMY_ICON "dummy" /* sliders */ -#define NEUTRINO_ICON_SLIDER_BODY "volumebody" -#define NEUTRINO_ICON_SLIDER_INACTIVE "volumeslider2" -#define NEUTRINO_ICON_SLIDER_RED "volumeslider2red" -#define NEUTRINO_ICON_SLIDER_GREEN "volumeslider2green" -#define NEUTRINO_ICON_SLIDER_BLUE "volumeslider2blue" -#define NEUTRINO_ICON_SLIDER_ALPHA "volumeslider2alpha" +#define NEUTRINO_ICON_SLIDER_BODY "slider_body" +#define NEUTRINO_ICON_SLIDER_INACTIVE "slider_inactive" +#define NEUTRINO_ICON_SLIDER_RED "slider_red" +#define NEUTRINO_ICON_SLIDER_GREEN "slider_green" +#define NEUTRINO_ICON_SLIDER_BLUE "slider_blue" +#define NEUTRINO_ICON_SLIDER_ALPHA "slider_alpha" #define NEUTRINO_ICON_BUTTON_MUTE_ZAP_ACTIVE "mute_zap_green" #define NEUTRINO_ICON_BUTTON_MUTE_ZAP_INACTIVE "mute_zap_gray"