From 28366a01fd6b41f57f85ed76dce82b52c3b64af8 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Mon, 11 Nov 2013 00:13:21 +0100 Subject: [PATCH] CImageInfo: rework some parts of imageinfo -use CComponentsExtTextForm: this combines labels and text to one item -add build informations: this includes some functions of CBuildInfo class to show its informations, user can now use the red button and toggle between license and build infos Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2bd27147705f5e0be7ce56b691bd56eafa699497 Author: Thilo Graf Date: 2013-11-11 (Mon, 11 Nov 2013) ------------------ This commit was generated by Migit --- data/license/deutsch.license | 2 + data/license/english.license | 2 + data/license/slovak.license | 2 + src/gui/imageinfo.cpp | 179 +++++++++++++++++++++-------------- src/gui/imageinfo.h | 8 ++ 5 files changed, 123 insertions(+), 70 deletions(-) diff --git a/data/license/deutsch.license b/data/license/deutsch.license index 3f183d2b5..01d9bfca1 100644 --- a/data/license/deutsch.license +++ b/data/license/deutsch.license @@ -1,3 +1,5 @@ +GPL v2 + Dieses Programm ist freie Software. Sie können es unter den Bedingungen der GNU General Public License, wie von der Free Software Foundation veröffentlicht, weitergeben und/oder modifizieren, gemäß Version 2 der Lizenz. Die Veröffentlichung dieses Programms erfolgt in der Hoffnung, daß es Ihnen von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FÜR EINEN BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License. diff --git a/data/license/english.license b/data/license/english.license index 2a52a4285..939d929a6 100644 --- a/data/license/english.license +++ b/data/license/english.license @@ -1,3 +1,5 @@ +GPL v2 + 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; version 2 of the License. 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. diff --git a/data/license/slovak.license b/data/license/slovak.license index fb94fcc56..ec0d44a44 100644 --- a/data/license/slovak.license +++ b/data/license/slovak.license @@ -1,3 +1,5 @@ +GPL v2 + Tento program je slobodný softvér: môžete ho šíriť a upravovať podľa ustanovení Všeobecnej verejnej licencie GNU (GNU General Public License), vydávanej nadáciou Free Software Foundation, a to buď podľa 2.verzie tejto Licencie, alebo (podľa vášho uváženia) ktorejkoľvek neskoršej verzie. Tento program je šírený v nádeji, že bude užitočný, avšak BEZ AKEJKOĽVEK ZÁRUKY. Neposkytujú sa ani odvodené záruky OBCHODOVATEĽNOSTI alebo VHODNOSTI PRE URČITÝ ÚČEL. Ďalšie podrobnosti hľadajte vo Všeobecnej verejnej licencii GNU. diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp index 7254860ca..edcb265e4 100644 --- a/src/gui/imageinfo.cpp +++ b/src/gui/imageinfo.cpp @@ -39,7 +39,7 @@ #include #include #include "version.h" - +#include #define LICENSEDIR DATADIR "/neutrino/license/" using namespace std; @@ -58,7 +58,13 @@ void CImageInfo::Init(void) cc_info = NULL; cc_tv = NULL; cc_lic = NULL; + cc_sub_caption = NULL; + b_info = NULL; + btn_red = NULL; item_offset = 10; + item_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]; + item_height = item_font->getHeight(); + license_txt = ""; v_info.clear(); config.loadConfig("/.version"); @@ -81,6 +87,9 @@ void CImageInfo::Clean() cc_info = NULL; cc_tv = NULL; cc_lic = NULL; + cc_sub_caption = NULL; + b_info = NULL; + btn_red = NULL; } } @@ -107,6 +116,39 @@ int CImageInfo::exec(CMenuTarget* parent, const std::string &) res = menu_return::RETURN_EXIT_ALL; break; } + else if (msg == CRCInput::RC_red){ + // init temporarly vars + neutrino_locale_t info_cap , new_btn_cap; + info_cap = new_btn_cap = NONEXISTANT_LOCALE; + string info_txt = ""; + neutrino_locale_t btn_cap = btn_red->getCaptionLocale(); + + //toggle caption and info contents + if (btn_cap == LOCALE_BUILDINFO_MENU){ + info_cap = LOCALE_BUILDINFO_MENU; + for (uint i=0; igetText(b_info->getInfo(i).caption); + info_txt += "\n"; + info_txt += b_info->getInfo(i).info_text + "\n\n"; + } + new_btn_cap = LOCALE_IMAGEINFO_LICENSE; + } + if (btn_cap == LOCALE_IMAGEINFO_LICENSE){ + info_cap = LOCALE_IMAGEINFO_LICENSE; + info_txt = getLicenseText(); + new_btn_cap = LOCALE_BUILDINFO_MENU; + } + + //assign new caption and info contents + cc_sub_caption->setText(info_cap, CTextBox::AUTO_WIDTH, item_font); + InitInfoText(info_txt); + btn_red->setCaption(new_btn_cap); + + //paint items + cc_sub_caption->paint(false); + cc_lic->paint(false); + btn_red->paint(false); + } else if((msg == CRCInput::RC_sat) || (msg == CRCInput::RC_favorites)) { g_RCInput->postMsg (msg, 0); res = menu_return::RETURN_EXIT_ALL; @@ -125,6 +167,7 @@ int CImageInfo::exec(CMenuTarget* parent, const std::string &) if ( msg > CRCInput::RC_MaxRC && msg != CRCInput::RC_timeout){ CNeutrinoApp::getInstance()->handleMsg( msg, data ); } + } hide(); @@ -135,9 +178,14 @@ int CImageInfo::exec(CMenuTarget* parent, const std::string &) //contains all actions to init and add the window object and items void CImageInfo::ShowWindow() { + CComponentsFooter *footer = NULL; if (cc_win == NULL){ cc_win = new CComponentsWindow(LOCALE_IMAGEINFO_HEAD, NEUTRINO_ICON_INFO); cc_win->setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT); + footer = cc_win->getFooterObject(); + footer->setColorBody(COL_INFOBAR_SHADOW_PLUS_1); + btn_red = new CComponentsButtonRed(10, CC_CENTERED, 250, footer->getHeight(), LOCALE_BUILDINFO_MENU, false , true, false, footer->getColorBody(), footer->getColorBody()); + footer->addCCItem(btn_red); } //prepare minitv @@ -146,7 +194,10 @@ void CImageInfo::ShowWindow() //prepare infos InitInfos(); - //prepare license text + //prepare build infos + InitBuildInfos(); + + //prepare info text InitInfoText(getLicenseText()); //paint window @@ -171,11 +222,19 @@ void CImageInfo::InitMinitv() cc_tv->setXPos(cc_tv_x); //add minitv to container - cc_win->addWindowItem(cc_tv); + if (!cc_tv->isAdded()) + cc_win->addWindowItem(cc_tv); } //prepare distribution infos -void CImageInfo::InitInfos() +void CImageInfo::InitBuildInfos() +{ + if (b_info == NULL) + b_info = new CBuildInfo(); +} + +//collect required data from environment +void CImageInfo::InitInfoData() { v_info.clear(); @@ -224,66 +283,52 @@ void CImageInfo::InitInfos() v_info.push_back(doc); image_info_t forum = {LOCALE_IMAGEINFO_FORUM, config.getString("forum", "http://forum.tuxbox.org")}; v_info.push_back(forum); - image_info_t license = {LOCALE_IMAGEINFO_LICENSE, "GPL v2"}; - v_info.push_back(license); +} - Font * item_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]; + +//prepare distribution infos +void CImageInfo::InitInfos() +{ + InitInfoData(); //initialize container for infos if (cc_info == NULL) cc_info = new CComponentsForm(); - cc_win->addWindowItem(cc_info); + if (!cc_info->isAdded()) + cc_win->addWindowItem(cc_info); + cc_info->setPos(item_offset, item_offset); - cc_info->setWidth((cc_win->getWidth()/3*2)-2*item_offset); - - - //calculate max width of label and info_text - int w_label = 0, w_text = 0, w = 0; - for (size_t i = 0; i < v_info.size(); i++) { - w = item_font->getRenderWidth(g_Locale->getText(v_info[i].caption), true); - w_label = std::max(w_label, w); - - w = item_font->getRenderWidth(v_info[i].info_text.c_str(), true); - w_text = std::max(w_text, w); - } - - int x_label = 0, y_text = 0; - int x_text = x_label + w_label + item_offset; - int item_height = item_font->getHeight(); - - //recalc w_text to avoid an overlap with pip TODO: calculate within cc_info itself - w_text = std::min(w_text, cc_win->getWidth() - x_text - /*cc_tv->getWidth() - */2*item_offset); - + + //set width, use size between left border and minitv + cc_info->setWidth(cc_win->getWidth() - cc_tv->getWidth() - 2*item_offset); + + //calculate initial height for info form + cc_info->setHeight(v_info.size()*item_height); + //create label and text items - int h_tmp = 0; - size_t i = 0; - for (i = 0; i < v_info.size(); i++) { - CComponentsLabel *cc_label = new CComponentsLabel(); - cc_label->setDimensionsAll(x_label, y_text, w_label, item_height); - cc_label->setText(v_info[i].caption, CTextBox::NO_AUTO_LINEBREAK, item_font); + for (size_t i=0; igetWidth(), item_height, g_Locale->getText(v_info[i].caption), v_info[i].info_text); + item->setLabelAndTextFont(item_font); + item->setLabelWidthPercent(20); - //add label object to window body - cc_info->addCCItem(cc_label); + if ((i == 0) && (item->getYPos() == CC_APPEND)) + item->setYPos(1); - CComponentsText *cc_text = new CComponentsText(); - cc_text->setDimensionsAll(x_text, y_text, w_text, item_height); - cc_text->setText(v_info[i].info_text.c_str(), CTextBox::NO_AUTO_LINEBREAK, item_font); - y_text += item_height/*CC_APPEND*/; + //add ext-text object to window body + if (!item->isAdded()) + cc_info->addCCItem(item); - //add text object to window body - cc_info->addCCItem(cc_text); - - // add an offset before homepage and license - if (v_info[i].caption == LOCALE_IMAGEINFO_CREATOR|| v_info[i].caption == LOCALE_IMAGEINFO_FORUM){ - h_tmp += item_offset; - y_text += item_offset; + //add an offset before homepage and license and at the end + if (v_info[i].caption == LOCALE_IMAGEINFO_CREATOR || v_info[i].caption == LOCALE_IMAGEINFO_FORUM){ + CComponentsShapeSquare *spacer = new CComponentsShapeSquare(1, CC_APPEND, 1, item_offset); + //spacer ist not visible! + spacer->allowPaint(false); + cc_info->addCCItem(spacer); + //increase height of cc_info object with offset + int tmp_h = cc_info->getHeight(); + cc_info->setHeight(tmp_h + item_offset); } - - //set height for info form - h_tmp += item_height; } - //assign height of info form - cc_info->setHeight(h_tmp); } //get license @@ -307,25 +352,21 @@ void CImageInfo::InitInfoText(const std::string& text) int h_body = winbody->getHeight(); int w_body = winbody->getWidth(); - int y_lic = item_offset + cc_info->getHeight() + item_offset; - int h_lic = h_body - y_lic - item_offset; + int h_lic = h_body - cc_info->getHeight() - 2*item_offset; if (cc_lic == NULL) - cc_lic = new CComponentsInfoBox(item_offset, cc_info->getYPos()+cc_info->getHeight()+item_offset, w_body-2*item_offset, h_lic); - cc_lic->setSpaceOffset(0); - cc_lic->setText(text, CTextBox::AUTO_WIDTH | CTextBox::SCROLL, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); + cc_lic = new CComponentsInfoBox(CC_CENTERED, CC_APPEND, w_body-2*item_offset, h_lic); + cc_lic->setSpaceOffset(1); + cc_lic->setText(text, CTextBox::TOP | CTextBox::AUTO_WIDTH | CTextBox::SCROLL, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); -#if 0 - //calc y pos of license box to avoid an overlap with pip - int h_info = cc_info->getHeight(); - int y_lic = std::max(h_info, cc_tv->getHeight() + 2*item_offset); - CComponentsForm *winbody = cc_win->getBodyObject(); - int h_lic = 0; - if (winbody) - h_lic = winbody->getHeight(); - cc_lic = new CComponentsInfoBox(item_offset, /*y_lic*/CC_APPEND, cc_win->getWidth()-2*item_offset, h_lic - h_info -item_offset); - cc_lic->setTextFromFile(file, CTextBox::AUTO_WIDTH | CTextBox::SCROLL, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); -#endif + //add a caption for info contents + Font * caption_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]; + int caption_height = caption_font->getHeight(); + if (cc_sub_caption == NULL) + cc_sub_caption = new CComponentsLabel(cc_info->getXPos(), CC_APPEND, cc_info->getWidth(), caption_height, + g_Locale->getText(LOCALE_IMAGEINFO_LICENSE), CTextBox::AUTO_WIDTH, item_font); + if (!cc_sub_caption->isAdded()) + cc_win->addWindowItem(cc_sub_caption); //add text to container if (!cc_lic->isAdded()) @@ -349,8 +390,6 @@ void CImageInfo::ScrollLic(bool scrollDown) } } - - void CImageInfo::hide() { printf("[CImageInfo] [%s - %d] hide...\n", __FUNCTION__, __LINE__); diff --git a/src/gui/imageinfo.h b/src/gui/imageinfo.h index 2a5b671da..81c588bc2 100644 --- a/src/gui/imageinfo.h +++ b/src/gui/imageinfo.h @@ -33,6 +33,7 @@ #include #include +#include #include typedef struct image_info_t @@ -47,13 +48,17 @@ class CImageInfo : public CMenuTarget private: int item_offset; //distance between items and to boarder std::string license_txt; + Font* item_font; + int item_height; std::vector v_info; void Clean(); void Init(); + void InitInfoData(); void InitMinitv(); void InitInfos(); + void InitBuildInfos(); void InitInfoText(const std::string& text); std::string getLicenseText(); void ShowWindow(); @@ -63,7 +68,10 @@ class CImageInfo : public CMenuTarget CComponentsForm *cc_info; CComponentsPIP *cc_tv; CComponentsInfoBox *cc_lic; + CBuildInfo *b_info; CConfigFile config; + CComponentsButtonRed *btn_red; + CComponentsLabel *cc_sub_caption; public: