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: 2bd2714770
Author: Thilo Graf <dbt@novatux.de>
Date: 2013-11-11 (Mon, 11 Nov 2013)



------------------
This commit was generated by Migit
This commit is contained in:
2013-11-11 00:13:21 +01:00
parent fbcdc63ee1
commit 28366a01fd
5 changed files with 123 additions and 70 deletions

View File

@@ -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. 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. 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.

View File

@@ -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 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. 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.

View File

@@ -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 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. 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.

View File

@@ -39,7 +39,7 @@
#include <daemonc/remotecontrol.h> #include <daemonc/remotecontrol.h>
#include <system/flashtool.h> #include <system/flashtool.h>
#include "version.h" #include "version.h"
#include <gui/buildinfo.h>
#define LICENSEDIR DATADIR "/neutrino/license/" #define LICENSEDIR DATADIR "/neutrino/license/"
using namespace std; using namespace std;
@@ -58,7 +58,13 @@ void CImageInfo::Init(void)
cc_info = NULL; cc_info = NULL;
cc_tv = NULL; cc_tv = NULL;
cc_lic = NULL; cc_lic = NULL;
cc_sub_caption = NULL;
b_info = NULL;
btn_red = NULL;
item_offset = 10; item_offset = 10;
item_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU];
item_height = item_font->getHeight();
license_txt = ""; license_txt = "";
v_info.clear(); v_info.clear();
config.loadConfig("/.version"); config.loadConfig("/.version");
@@ -81,6 +87,9 @@ void CImageInfo::Clean()
cc_info = NULL; cc_info = NULL;
cc_tv = NULL; cc_tv = NULL;
cc_lic = 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; res = menu_return::RETURN_EXIT_ALL;
break; 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; i<CBuildInfo::BI_TYPE_IDS; i++){
info_txt += g_Locale->getText(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)) { else if((msg == CRCInput::RC_sat) || (msg == CRCInput::RC_favorites)) {
g_RCInput->postMsg (msg, 0); g_RCInput->postMsg (msg, 0);
res = menu_return::RETURN_EXIT_ALL; 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){ if ( msg > CRCInput::RC_MaxRC && msg != CRCInput::RC_timeout){
CNeutrinoApp::getInstance()->handleMsg( msg, data ); CNeutrinoApp::getInstance()->handleMsg( msg, data );
} }
} }
hide(); 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 //contains all actions to init and add the window object and items
void CImageInfo::ShowWindow() void CImageInfo::ShowWindow()
{ {
CComponentsFooter *footer = NULL;
if (cc_win == NULL){ if (cc_win == NULL){
cc_win = new CComponentsWindow(LOCALE_IMAGEINFO_HEAD, NEUTRINO_ICON_INFO); cc_win = new CComponentsWindow(LOCALE_IMAGEINFO_HEAD, NEUTRINO_ICON_INFO);
cc_win->setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT); 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 //prepare minitv
@@ -146,7 +194,10 @@ void CImageInfo::ShowWindow()
//prepare infos //prepare infos
InitInfos(); InitInfos();
//prepare license text //prepare build infos
InitBuildInfos();
//prepare info text
InitInfoText(getLicenseText()); InitInfoText(getLicenseText());
//paint window //paint window
@@ -171,11 +222,19 @@ void CImageInfo::InitMinitv()
cc_tv->setXPos(cc_tv_x); cc_tv->setXPos(cc_tv_x);
//add minitv to container //add minitv to container
cc_win->addWindowItem(cc_tv); if (!cc_tv->isAdded())
cc_win->addWindowItem(cc_tv);
} }
//prepare distribution infos //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(); v_info.clear();
@@ -224,66 +283,52 @@ void CImageInfo::InitInfos()
v_info.push_back(doc); v_info.push_back(doc);
image_info_t forum = {LOCALE_IMAGEINFO_FORUM, config.getString("forum", "http://forum.tuxbox.org")}; image_info_t forum = {LOCALE_IMAGEINFO_FORUM, config.getString("forum", "http://forum.tuxbox.org")};
v_info.push_back(forum); 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 //initialize container for infos
if (cc_info == NULL) if (cc_info == NULL)
cc_info = new CComponentsForm(); 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->setPos(item_offset, item_offset);
cc_info->setWidth((cc_win->getWidth()/3*2)-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 max width of label and info_text
int w_label = 0, w_text = 0, w = 0; //calculate initial height for info form
for (size_t i = 0; i < v_info.size(); i++) { cc_info->setHeight(v_info.size()*item_height);
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);
//create label and text items //create label and text items
int h_tmp = 0; for (size_t i=0; i<v_info.size(); i++) {
size_t i = 0; CComponentsExtTextForm *item = new CComponentsExtTextForm(1, CC_APPEND, cc_info->getWidth(), item_height, g_Locale->getText(v_info[i].caption), v_info[i].info_text);
for (i = 0; i < v_info.size(); i++) { item->setLabelAndTextFont(item_font);
CComponentsLabel *cc_label = new CComponentsLabel(); item->setLabelWidthPercent(20);
cc_label->setDimensionsAll(x_label, y_text, w_label, item_height);
cc_label->setText(v_info[i].caption, CTextBox::NO_AUTO_LINEBREAK, item_font);
//add label object to window body if ((i == 0) && (item->getYPos() == CC_APPEND))
cc_info->addCCItem(cc_label); item->setYPos(1);
CComponentsText *cc_text = new CComponentsText(); //add ext-text object to window body
cc_text->setDimensionsAll(x_text, y_text, w_text, item_height); if (!item->isAdded())
cc_text->setText(v_info[i].info_text.c_str(), CTextBox::NO_AUTO_LINEBREAK, item_font); cc_info->addCCItem(item);
y_text += item_height/*CC_APPEND*/;
//add text object to window body //add an offset before homepage and license and at the end
cc_info->addCCItem(cc_text); 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);
// add an offset before homepage and license //spacer ist not visible!
if (v_info[i].caption == LOCALE_IMAGEINFO_CREATOR|| v_info[i].caption == LOCALE_IMAGEINFO_FORUM){ spacer->allowPaint(false);
h_tmp += item_offset; cc_info->addCCItem(spacer);
y_text += item_offset; //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 //get license
@@ -307,25 +352,21 @@ void CImageInfo::InitInfoText(const std::string& text)
int h_body = winbody->getHeight(); int h_body = winbody->getHeight();
int w_body = winbody->getWidth(); int w_body = winbody->getWidth();
int y_lic = item_offset + cc_info->getHeight() + item_offset; int h_lic = h_body - cc_info->getHeight() - 2*item_offset;
int h_lic = h_body - y_lic - item_offset;
if (cc_lic == NULL) 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 = new CComponentsInfoBox(CC_CENTERED, CC_APPEND, w_body-2*item_offset, h_lic);
cc_lic->setSpaceOffset(0); cc_lic->setSpaceOffset(1);
cc_lic->setText(text, CTextBox::AUTO_WIDTH | CTextBox::SCROLL, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]); cc_lic->setText(text, CTextBox::TOP | CTextBox::AUTO_WIDTH | CTextBox::SCROLL, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]);
#if 0 //add a caption for info contents
//calc y pos of license box to avoid an overlap with pip Font * caption_font = g_Font[SNeutrinoSettings::FONT_TYPE_MENU];
int h_info = cc_info->getHeight(); int caption_height = caption_font->getHeight();
int y_lic = std::max(h_info, cc_tv->getHeight() + 2*item_offset); if (cc_sub_caption == NULL)
CComponentsForm *winbody = cc_win->getBodyObject(); cc_sub_caption = new CComponentsLabel(cc_info->getXPos(), CC_APPEND, cc_info->getWidth(), caption_height,
int h_lic = 0; g_Locale->getText(LOCALE_IMAGEINFO_LICENSE), CTextBox::AUTO_WIDTH, item_font);
if (winbody) if (!cc_sub_caption->isAdded())
h_lic = winbody->getHeight(); cc_win->addWindowItem(cc_sub_caption);
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 text to container //add text to container
if (!cc_lic->isAdded()) if (!cc_lic->isAdded())
@@ -349,8 +390,6 @@ void CImageInfo::ScrollLic(bool scrollDown)
} }
} }
void CImageInfo::hide() void CImageInfo::hide()
{ {
printf("[CImageInfo] [%s - %d] hide...\n", __FUNCTION__, __LINE__); printf("[CImageInfo] [%s - %d] hide...\n", __FUNCTION__, __LINE__);

View File

@@ -33,6 +33,7 @@
#include <gui/widget/menue.h> #include <gui/widget/menue.h>
#include <gui/components/cc.h> #include <gui/components/cc.h>
#include <gui/buildinfo.h>
#include <configfile.h> #include <configfile.h>
typedef struct image_info_t typedef struct image_info_t
@@ -47,13 +48,17 @@ class CImageInfo : public CMenuTarget
private: private:
int item_offset; //distance between items and to boarder int item_offset; //distance between items and to boarder
std::string license_txt; std::string license_txt;
Font* item_font;
int item_height;
std::vector<image_info_t> v_info; std::vector<image_info_t> v_info;
void Clean(); void Clean();
void Init(); void Init();
void InitInfoData();
void InitMinitv(); void InitMinitv();
void InitInfos(); void InitInfos();
void InitBuildInfos();
void InitInfoText(const std::string& text); void InitInfoText(const std::string& text);
std::string getLicenseText(); std::string getLicenseText();
void ShowWindow(); void ShowWindow();
@@ -63,7 +68,10 @@ class CImageInfo : public CMenuTarget
CComponentsForm *cc_info; CComponentsForm *cc_info;
CComponentsPIP *cc_tv; CComponentsPIP *cc_tv;
CComponentsInfoBox *cc_lic; CComponentsInfoBox *cc_lic;
CBuildInfo *b_info;
CConfigFile config; CConfigFile config;
CComponentsButtonRed *btn_red;
CComponentsLabel *cc_sub_caption;
public: public: