mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 16:31:05 +02:00
CComponents: add new class CComponentsFrmChain
CComponentsFrmChain provides a form for chained cc-items with
optional dynamic arrangement or direction parameters
Origin commit data
------------------
Branch: ni/coolstream
Commit: eb16ea3ac6
Author: Thilo Graf <dbt@novatux.de>
Date: 2013-12-23 (Mon, 23 Dec 2013)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -28,6 +28,7 @@ libneutrino_gui_components_a_SOURCES = \
|
||||
cc_detailsline.cpp \
|
||||
cc_frm_button.cpp \
|
||||
cc_frm.cpp \
|
||||
cc_frm_chain.cpp \
|
||||
cc_frm_clock.cpp \
|
||||
cc_frm_footer.cpp \
|
||||
cc_frm_header.cpp \
|
||||
|
@@ -44,6 +44,7 @@ Basic attributes and member functions for component sub classes
|
||||
|
||||
#include "cc_frm.h"
|
||||
#include "cc_frm_button.h"
|
||||
#include "cc_frm_chain.h"
|
||||
#include "cc_frm_clock.h"
|
||||
#include "cc_frm_signalbars.h"
|
||||
#include "cc_frm_slider.h"
|
||||
|
@@ -151,6 +151,12 @@ void CComponentsForm::addCCItem(CComponentsItem* cc_Item)
|
||||
#endif
|
||||
}
|
||||
|
||||
void CComponentsForm::addCCItem(const std::vector<CComponentsItem*> cc_Items)
|
||||
{
|
||||
for (size_t i= 0; i< cc_Items.size(); i++)
|
||||
addCCItem(cc_Items[i]);
|
||||
}
|
||||
|
||||
int CComponentsForm::getCCItemId(CComponentsItem* cc_Item)
|
||||
{
|
||||
if (cc_Item){
|
||||
@@ -297,6 +303,15 @@ void CComponentsForm::paintCCItems()
|
||||
int xpos = cc_item->getXPos();
|
||||
int ypos = cc_item->getYPos();
|
||||
|
||||
//check item for corrupt position, skip current item if found problems
|
||||
//TODO: need a solution with possibility for scrolling
|
||||
if (ypos > height || xpos > width){
|
||||
printf("[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] WARNING: item position is out of form size:\ndefinied x=%d, defined width=%d \ndefinied y=%d, defined height=%d \n",
|
||||
__func__, cc_item_index, cc_item->getIndex(), cc_item->getItemType(), xpos, width, ypos, height);
|
||||
if (this->cc_item_type != CC_ITEMTYPE_FRM_CHAIN)
|
||||
continue;
|
||||
}
|
||||
|
||||
//set required x-position to item:
|
||||
//append vertical
|
||||
if (xpos == CC_APPEND){
|
||||
|
@@ -57,6 +57,7 @@ class CComponentsForm : public CComponentsItem
|
||||
void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
|
||||
void hide(bool no_restore = false);
|
||||
virtual void addCCItem(CComponentsItem* cc_Item);
|
||||
virtual void addCCItem(const std::vector<CComponentsItem*> cc_items);
|
||||
virtual void insertCCItem(const uint& cc_item_id, CComponentsItem* cc_Item);
|
||||
virtual void removeCCItem(const uint& cc_item_id);
|
||||
virtual void removeCCItem(CComponentsItem* cc_Item);
|
||||
|
126
src/gui/components/cc_frm_chain.cpp
Normal file
126
src/gui/components/cc_frm_chain.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Classes for generic GUI-related components.
|
||||
Copyright (C) 2013, 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/>.
|
||||
*/
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
#include "cc_frm_chain.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
//sub class CComponentsFrmChain
|
||||
CComponentsFrmChain::CComponentsFrmChain( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||
const std::vector<CComponentsItem*> *v_items,
|
||||
bool horizontal,
|
||||
bool dynamic_width,
|
||||
bool dynamic_height,
|
||||
bool has_shadow,
|
||||
fb_pixel_t& color_frame,
|
||||
fb_pixel_t& color_body,
|
||||
fb_pixel_t& color_shadow)
|
||||
{
|
||||
initVarChain(x_pos, y_pos, w, h, v_items, horizontal, dynamic_width, dynamic_height, has_shadow, color_frame, color_body, color_shadow);
|
||||
}
|
||||
|
||||
|
||||
void CComponentsFrmChain::initVarChain( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||
const std::vector<CComponentsItem*> *v_items,
|
||||
bool horizontal,
|
||||
bool dynamic_width,
|
||||
bool dynamic_height,
|
||||
bool has_shadow,
|
||||
fb_pixel_t& color_frame,
|
||||
fb_pixel_t& color_body,
|
||||
fb_pixel_t& color_shadow)
|
||||
{
|
||||
cc_item_type = CC_ITEMTYPE_FRM_CHAIN;
|
||||
corner_rad = 0;
|
||||
|
||||
x = x_pos;
|
||||
y = y_pos;
|
||||
width = w;
|
||||
height = h;
|
||||
|
||||
shadow = has_shadow;
|
||||
col_frame = color_frame;
|
||||
col_body = color_body;
|
||||
col_shadow = color_shadow;
|
||||
|
||||
chn_horizontal = horizontal;
|
||||
chn_dyn_height = dynamic_height;
|
||||
chn_dyn_width = dynamic_width;
|
||||
|
||||
if (v_items){
|
||||
addCCItem(*v_items);
|
||||
initCChainItems();
|
||||
}
|
||||
}
|
||||
|
||||
void CComponentsFrmChain::initCChainItems()
|
||||
{
|
||||
if (!v_cc_items.empty()){
|
||||
if (chn_dyn_height)
|
||||
height = 0;
|
||||
if (chn_dyn_width)
|
||||
width = 0;
|
||||
}
|
||||
|
||||
for (size_t i= 0; i< v_cc_items.size(); i++){
|
||||
//set general start position for all items
|
||||
if (i == 0)
|
||||
v_cc_items[i]->setPos(0, 0);
|
||||
|
||||
//set arrangement with required direction
|
||||
if (chn_horizontal){
|
||||
if (i > 0)
|
||||
v_cc_items[i]->setPos(CC_APPEND, 0);
|
||||
}
|
||||
else{
|
||||
if (i > 0)
|
||||
v_cc_items[i]->setPos(0, CC_APPEND);
|
||||
}
|
||||
|
||||
//assign size
|
||||
if (chn_horizontal){
|
||||
//assign dynamic width
|
||||
if (chn_dyn_width)
|
||||
width += v_cc_items[i]->getWidth();
|
||||
//assign dynamic height
|
||||
if (chn_dyn_height)
|
||||
height = max(v_cc_items[i]->getHeight(), height);
|
||||
else
|
||||
v_cc_items[i]->setHeight(height);
|
||||
}
|
||||
else{
|
||||
//assign dynamic height
|
||||
if (chn_dyn_height)
|
||||
height += v_cc_items[i]->getHeight();
|
||||
//assign dynamic width
|
||||
if (chn_dyn_width)
|
||||
width = max(v_cc_items[i]->getWidth(), width);
|
||||
else
|
||||
v_cc_items[i]->setWidth(width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
78
src/gui/components/cc_frm_chain.h
Normal file
78
src/gui/components/cc_frm_chain.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Based up Neutrino-GUI - Tuxbox-Project
|
||||
Copyright (C) 2001 by Steffen Hehn 'McClean'
|
||||
|
||||
Classes for generic GUI-related components.
|
||||
Copyright (C) 2013, 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 __CC_FORM_CHAIN_H__
|
||||
#define __CC_FORM_CHAIN_H__
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "cc_frm.h"
|
||||
|
||||
|
||||
//! Sub class of CComponentsForm. Creates a dynamic form with chained items.
|
||||
/*!
|
||||
Paint chained cc-items on screen.
|
||||
You can set default form parameters like position, size, colors etc. and additional values
|
||||
to display with defined direction.
|
||||
*/
|
||||
|
||||
class CComponentsFrmChain : public CComponentsForm
|
||||
{
|
||||
private:
|
||||
///property: defined arrangement mode of items, can be vertical or horizontal
|
||||
int chn_horizontal;
|
||||
|
||||
///property: defines height from sum of all contained items
|
||||
bool chn_dyn_height;
|
||||
///property: defines width from sum of all contained items
|
||||
bool chn_dyn_width;
|
||||
|
||||
///init all required variables
|
||||
void initVarChain( const int& x_pos, const int& y_pos, const int& w, const int& h,
|
||||
const std::vector<CComponentsItem*> *v_items,
|
||||
bool horizontal,
|
||||
bool dynamic_width,
|
||||
bool dynamic_height,
|
||||
bool has_shadow,
|
||||
fb_pixel_t& color_frame,
|
||||
fb_pixel_t& color_body,
|
||||
fb_pixel_t& color_shadow);
|
||||
|
||||
void initCChainItems();
|
||||
protected:
|
||||
|
||||
|
||||
public:
|
||||
CComponentsFrmChain( const int& x_pos = 1, const int& y_pos = 1, const int& w = 720, const int& h = 32,
|
||||
const std::vector<CComponentsItem*> *v_items = NULL,
|
||||
bool horizontal = true,
|
||||
bool dynamic_width = false,
|
||||
bool dynamic_height = false,
|
||||
bool has_shadow = CC_SHADOW_OFF,
|
||||
fb_pixel_t& color_frame = COL_MENUCONTENT_PLUS_6,
|
||||
fb_pixel_t& color_body = COL_MENUHEAD_PLUS_0,
|
||||
fb_pixel_t& color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
||||
// ~CComponentsSlider(); //inherited from CComponentsForm
|
||||
};
|
||||
|
||||
#endif
|
@@ -43,6 +43,7 @@ typedef enum
|
||||
CC_ITEMTYPE_SHAPE_CIRCLE,
|
||||
CC_ITEMTYPE_PIP,
|
||||
CC_ITEMTYPE_FRM,
|
||||
CC_ITEMTYPE_FRM_CHAIN,
|
||||
CC_ITEMTYPE_FRM_CLOCK,
|
||||
CC_ITEMTYPE_FRM_HEADER,
|
||||
CC_ITEMTYPE_FOOTER,
|
||||
|
Reference in New Issue
Block a user