mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 23:42:58 +02:00
CNaviBar: add new widget class: CNaviBar
Should help to reduce and unify code in some epg windows.
This commit is contained in:
@@ -27,6 +27,7 @@ libneutrino_gui_widget_a_SOURCES = \
|
||||
menue.cpp \
|
||||
mountchooser.cpp \
|
||||
msgbox.cpp \
|
||||
navibar.cpp \
|
||||
shellwindow.cpp \
|
||||
stringinput.cpp \
|
||||
stringinput_ext.cpp \
|
||||
|
116
src/gui/widget/navibar.cpp
Normal file
116
src/gui/widget/navibar.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Class for epg window navigation bar.
|
||||
Copyright (C) 2017, Thilo Graf 'dbt'
|
||||
|
||||
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 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "navibar.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
CNaviBar::CNaviBar( const int& x,
|
||||
const int& y,
|
||||
const int& dx,
|
||||
const int& dy,
|
||||
CComponentsForm* parent,
|
||||
int shadow_mode,
|
||||
fb_pixel_t& color_frame,
|
||||
fb_pixel_t& color_body,
|
||||
fb_pixel_t& color_shadow)
|
||||
: CComponentsFrmChain( x, y, dx, dy,
|
||||
NULL,
|
||||
CC_DIR_X,
|
||||
parent,
|
||||
shadow_mode,
|
||||
color_frame,
|
||||
color_body,
|
||||
color_shadow)
|
||||
{
|
||||
setCornerType(CORNER_NONE);
|
||||
enableColBodyGradient(g_settings.theme.infobar_gradient_bottom,COL_MENUFOOT_PLUS_0,g_settings.theme.infobar_gradient_bottom_direction);
|
||||
set2ndColor(COL_MENUCONTENT_PLUS_0);
|
||||
|
||||
nb_lpic = nb_rpic = NULL;
|
||||
nb_lText = nb_rText = NULL;
|
||||
nb_font = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE];;
|
||||
nb_lpic_enable = nb_rpic_enable = false;
|
||||
nb_l_text = nb_r_text = string();
|
||||
|
||||
initCCItems();
|
||||
}
|
||||
|
||||
void CNaviBar::initCCItems()
|
||||
{
|
||||
int x_off = OFFSET_INNER_MID;
|
||||
int mid_width = width * 40 / 100; // 40%
|
||||
int side_width = ((width - mid_width) / 2) - (2 * x_off);
|
||||
int h_text = height;
|
||||
|
||||
// init left arrow
|
||||
if (!nb_lpic){
|
||||
nb_lpic = new CComponentsPictureScalable(x_off,CC_CENTERED,NEUTRINO_ICON_BUTTON_LEFT);
|
||||
nb_lpic->doPaintBg(false);
|
||||
this->addCCItem(nb_lpic);
|
||||
nb_lpic->enableSaveBg();
|
||||
}
|
||||
nb_lpic->allowPaint(nb_lpic_enable);
|
||||
|
||||
// init right arrow
|
||||
if (!nb_rpic){
|
||||
nb_rpic = new CComponentsPictureScalable(0,CC_CENTERED,NEUTRINO_ICON_BUTTON_RIGHT);
|
||||
|
||||
nb_rpic->doPaintBg(false);
|
||||
this->addCCItem(nb_rpic);
|
||||
nb_rpic->enableSaveBg();
|
||||
int x_pos = width - nb_rpic->getWidth() - x_off;
|
||||
nb_rpic->setXPos(x_pos);
|
||||
}
|
||||
nb_rpic->allowPaint(nb_rpic_enable);
|
||||
|
||||
// init text left
|
||||
if (!nb_lText){
|
||||
nb_lText = new CComponentsText(x_off + nb_lpic->getWidth() + x_off, CC_CENTERED, side_width, h_text, "", CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, this, CC_SHADOW_OFF, COL_MENUHEAD_TEXT);
|
||||
nb_lText->doPaintBg(false);
|
||||
nb_lText->enableSaveBg();
|
||||
}
|
||||
nb_lText->setText(nb_l_text, CTextBox::NO_AUTO_LINEBREAK, nb_font, COL_MENUHEAD_TEXT, CComponentsText::FONT_STYLE_REGULAR);
|
||||
|
||||
// init text right
|
||||
if (!nb_rText){
|
||||
nb_rText = new CComponentsText(0, CC_CENTERED, side_width, h_text, "", CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE], CComponentsText::FONT_STYLE_REGULAR, this, CC_SHADOW_OFF, COL_MENUHEAD_TEXT);
|
||||
nb_rText->doPaintBg(false);
|
||||
nb_rText->enableSaveBg();
|
||||
}
|
||||
nb_rText->setText(nb_r_text, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, nb_font);
|
||||
nb_rText->setXPos(nb_rpic->getXPos() - x_off - nb_rText->getWidth());
|
||||
}
|
||||
|
||||
|
||||
void CNaviBar::paint(bool do_save_bg)
|
||||
{
|
||||
hideCCItems();
|
||||
CComponentsFrmChain::paint(do_save_bg);
|
||||
}
|
169
src/gui/widget/navibar.h
Normal file
169
src/gui/widget/navibar.h
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Class for epg window navigation bar.
|
||||
Copyright (C) 2017, Thilo Graf 'dbt'
|
||||
|
||||
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 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __C_NAVIBAR__
|
||||
#define __C_NAVIBAR__
|
||||
|
||||
#include <gui/components/cc.h>
|
||||
#include <driver/fontrenderer.h>
|
||||
|
||||
|
||||
/**
|
||||
CNaviBar is sub class of CComponentsFrmChain.
|
||||
Shows a navigation bar with text and navigation icons.
|
||||
You can enable/disable predefined icons and texts
|
||||
on the left and/or right side of bar.
|
||||
*/
|
||||
class CNaviBar : public CComponentsFrmChain
|
||||
{
|
||||
private:
|
||||
CComponentsPictureScalable *nb_lpic, *nb_rpic;
|
||||
CComponentsText *nb_lText, *nb_rText;
|
||||
|
||||
Font *nb_font;
|
||||
|
||||
bool nb_lpic_enable;
|
||||
bool nb_rpic_enable;
|
||||
|
||||
std::string nb_l_text;
|
||||
std::string nb_r_text;
|
||||
|
||||
void initCCItems();
|
||||
|
||||
public:
|
||||
/**CNaviBar Constructor
|
||||
* @param[in] x
|
||||
* @li expects type int, x position
|
||||
* @param[in] y
|
||||
* @li expects type int, y position
|
||||
* @param[in] dx
|
||||
* @li expects type int, width
|
||||
* @param[in] dy
|
||||
* @li expects type int, height
|
||||
* @param[in] parent
|
||||
* @li optional: expects type CComponentsForm or derivates, allows usage as item inside CComponentsForm container, default = NULL
|
||||
* @param[in] shadow_mode
|
||||
* @li optional: expects type fb_pixel_t, defines shadow mode, default CC_SHADOW_OFF
|
||||
* @param[in] color_frame
|
||||
* @li optional: expects type fb_pixel_t, defines frame color, default value = COL_FRAME_PLUS_0
|
||||
* @param[in] color_body
|
||||
* @li optional: expects type fb_pixel_t, defines body color, default value = COL_MENUFOOT_PLUS_0
|
||||
* @param[in] color_shadow
|
||||
* @li optional: expects type fb_pixel_t, defines shadow color, default value = COL_SHADOW_PLUS_0
|
||||
*
|
||||
* @see class CComponentsFrmChain()
|
||||
*/
|
||||
CNaviBar( const int& x,
|
||||
const int& y,
|
||||
const int& dx,
|
||||
const int& dy,
|
||||
CComponentsForm* parent = NULL,
|
||||
int shadow_mode = CC_SHADOW_OFF,
|
||||
fb_pixel_t& color_frame = COL_FRAME_PLUS_0,
|
||||
fb_pixel_t& color_body = COL_MENUFOOT_PLUS_0,
|
||||
fb_pixel_t& color_shadow = COL_SHADOW_PLUS_0);
|
||||
|
||||
//~CNaviBar(); //is inherited
|
||||
|
||||
/**
|
||||
* Enable or disable left icon
|
||||
* @param[in] enable
|
||||
* @li exepts type bool, default = true
|
||||
*/
|
||||
void enableLeftArrow(bool enable = true){nb_lpic_enable = enable; initCCItems();}
|
||||
|
||||
/**
|
||||
* Enable or disable right icon
|
||||
* @param[in] enable
|
||||
* @li exepts type bool, default = true
|
||||
*/
|
||||
void enableRightArrow(bool enable = true){nb_rpic_enable = enable; initCCItems();}
|
||||
|
||||
/**
|
||||
* disable left icon
|
||||
* no parameter
|
||||
*/
|
||||
void disableLeftArrow(){enableLeftArrow(false);}
|
||||
|
||||
/**
|
||||
* disable right icon
|
||||
* no parameter
|
||||
*/
|
||||
void disableRightArrow(){enableRightArrow(false);}
|
||||
|
||||
/**
|
||||
* Enable or disable both icons at once.
|
||||
* @param[in] enable_left
|
||||
* @li exepts type bool, default = true
|
||||
* @param[in] enable_right
|
||||
* @li exepts type bool, default = true
|
||||
*/
|
||||
void enableArrows(bool enable_left = true, bool enable_right = true){enableLeftArrow(enable_left); enableRightArrow(enable_right);}
|
||||
|
||||
/**
|
||||
* Disable all icons.
|
||||
* no parameter
|
||||
*/
|
||||
void disableArrows(){disableLeftArrow(); disableRightArrow();}
|
||||
|
||||
/**
|
||||
* Sets font type for texts.
|
||||
* @param[in] font
|
||||
* @li exepts type Font*
|
||||
*/
|
||||
void setFont(Font *font) {nb_font = font; initCCItems();}
|
||||
|
||||
/**
|
||||
* Sets left text.
|
||||
* @param[in] text
|
||||
* @li exepts type std::string
|
||||
*/
|
||||
void setLeftText(const std::string& text) {nb_l_text = text; initCCItems();}
|
||||
|
||||
/**
|
||||
* Sets right text
|
||||
* @param[in] text
|
||||
* @li exepts type std::string
|
||||
*/
|
||||
void setRightText(const std::string& text) {nb_r_text = text; initCCItems();}
|
||||
|
||||
/**
|
||||
* Sets left and right text at once.
|
||||
* @param[in] left
|
||||
* @li exepts type std::string
|
||||
* @param[in] right
|
||||
* @li exepts type std::string
|
||||
*/
|
||||
void setText(const std::string& left, const std::string& right) {setLeftText(left); setRightText(right);}
|
||||
|
||||
/**
|
||||
* Paint bar on screen.
|
||||
* @param[in] do_save_bg
|
||||
* @li optional: exepts type bool, default = CC_SAVE_SCREEN_YES.
|
||||
*/
|
||||
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user