components: rework classes

- outsourced some classes cc_item.cpp/h, cc_draw.cpp/h
- added extra methodes for simple use of some basic components extra.cpp/h
- rework clock handling: use timer class, reworked members for
  enable/disable clock with external timer events,
  tryed to fix some display issues related with infoclock and
  time osd clock in moviebrowser, channellist, menuus
- reworked hide/kill handling, removed parameter for hide(), try to use
  cached backgrounds for other constallations, paint cache, image cache (all beta)
- reworked shadow/frame handling, add shadow modes for left/right
  arrangement, TODO: repaint for existant instances required
- reworked color gradient assignment (beta)

... Note: I had a data crash in my local git tree
and i tryed to restore my historie, but most was lost. Therefore here
the commit is large
This commit is contained in:
2015-11-18 18:08:23 +01:00
parent a2171dad4a
commit 0146511f38
68 changed files with 3207 additions and 1682 deletions

View File

@@ -3,7 +3,7 @@
Copyright (C) 2001 by Steffen Hehn 'McClean'
Classes for generic GUI-related components.
Copyright (C) 2012-2014, Thilo Graf 'dbt'
Copyright (C) 2012-2015, Thilo Graf 'dbt'
Copyright (C) 2012, Michael Liebmann 'micha-bbg'
License: GPL
@@ -18,10 +18,8 @@
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., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
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
@@ -30,7 +28,7 @@
#include <global.h>
#include <neutrino.h>
#include "cc_base.h"
#include "cc_item.h"
#include <driver/screen_max.h>
#include <system/debug.h>
#include <cs_api.h>
@@ -46,19 +44,12 @@ using namespace std;
//abstract sub class CComponentsItem from CComponents
CComponentsItem::CComponentsItem(CComponentsForm* parent)
{
cc_item_type = CC_ITEMTYPE_BASE;
cc_item_type = CC_ITEMTYPE_GENERIC;
cc_item_index = CC_NO_INDEX;
cc_item_enabled = true;
cc_item_selected = false;
cc_page_number = 0;
cc_has_focus = true;
cc_gradientData.gradientBuf = NULL;
cc_body_gradient_mode = CColorGradient::gradientLight2Dark;
cc_body_gradient_intensity = CColorGradient::light;
cc_body_gradient_intensity_v_min = 0x40;
cc_body_gradient_intensity_v_max = 0xE0;
cc_body_gradient_saturation = 0xC0;
cc_body_gradient_direction = CFrameBuffer::gradientVertical;
initParent(parent);
}
@@ -69,86 +60,70 @@ void CComponentsItem::initParent(CComponentsForm* parent)
cc_parent->addCCItem(this);
}
// Paint container background in cc-items with shadow, background and frame.
// init container properties in cc-items for shadow, background and frame.
// This member must be called first in all paint() members before paint other items into the container.
// If backround is not required, it's possible to override this with variable paint_bg=false, use doPaintBg(true/false) to set this!
void CComponentsItem::paintInit(bool do_save_bg)
{
//init color gradient
if (col_body_gradient)
initBodyGradient();
if (hasChanges())
clearFbData();
clearFbData();
if (v_fbdata.empty()){
int th = fr_thickness;
fb_pixel_t col_frame_cur = col_frame;
int th = fr_thickness;
fb_pixel_t col_frame_cur = col_frame;
//calculate current needed frame thickeness and color, if item selected or not
if (cc_item_selected){
col_frame_cur = col_frame_sel;
th = max(fr_thickness_sel, fr_thickness);
}
//calculate current needed frame thickeness and color, if item selected or not
if (cc_item_selected){
col_frame_cur = col_frame_sel;
th = max(fr_thickness_sel, fr_thickness);
//calculate current needed corner radius for body box, depends of frame thickness
int rad = (corner_rad>th) ? corner_rad-th : corner_rad;
int sw = (shadow) ? shadow_w : 0;
//evaluate shadow mode
bool sh_r = (shadow & CC_SHADOW_ON) || (shadow & CC_SHADOW_RIGHT);
bool sh_b = (shadow & CC_SHADOW_ON) || (shadow & CC_SHADOW_BOTTOM);
//if item is bound on a parent form, we must use real x/y values and from parent form as reference
int ix = x, iy = y;
if (cc_parent){
ix = cc_xr;
iy = cc_yr;
}
//handle shadow width
if (width <= sw || height <= sw){ //don't use shadow, if item dimensions too small
dprintf(DEBUG_NORMAL, "\033[33m[CComponentsItem]\t[%s - %d] shadow dimensions too small sw=%d, shadow is disabled set dimension to 0\033[0m\n",__func__, __LINE__, sw);
shadow = CC_SHADOW_OFF;
sw = 0;
}
int isw = sw*2;
int ixsr = ix + width - isw/2;
int iysb = iy + height - isw/2;
//init paint layers
cc_fbdata_t fbdata[] =
{
{true, CC_FBDATA_TYPE_BGSCREEN, ix, iy, width+isw/2, height+isw/2, 0, 0, 0, 0, NULL, NULL, NULL, false}, //buffered bg
{sh_r, CC_FBDATA_TYPE_SHADOW_BOX, ixsr, iy+isw/2, isw, height, col_shadow, corner_rad, corner_type & CORNER_RIGHT, 0, NULL, NULL, NULL, false}, //shadow right
{sh_b, CC_FBDATA_TYPE_SHADOW_BOX, ix+isw/2, iysb, width, isw, col_shadow, corner_rad, corner_type & CORNER_BOTTOM, 0, NULL, NULL, NULL, false}, //shadow bottom
{true, CC_FBDATA_TYPE_FRAME, ix, iy, width, height, col_frame_cur, corner_rad, corner_type, th, NULL, NULL, NULL, false}, //frame
{true, CC_FBDATA_TYPE_BOX, ix+th, iy+th, width-2*th, height-2*th, col_body, rad, corner_type, 0, NULL, NULL, NULL, false}, //body
};
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++) {
if ((fbdata[i].fbdata_type == CC_FBDATA_TYPE_FRAME) && !fr_thickness)
continue;
v_fbdata.push_back(fbdata[i]);
}
dprintf(DEBUG_DEBUG, "[CComponentsItem] %s:\ncc_item_type: %d\ncc_item_index = %d\nheight = %d\nwidth = %d\n", __func__, cc_item_type, cc_item_index, height, width);
}
//calculate current needed corner radius for body box, depends of frame thickness
int rad = (corner_rad>th) ? corner_rad-th : corner_rad;
int sw = (shadow) ? shadow_w : 0;
//if item is bound on a parent form, we must use real x/y values and from parent form as reference
int ix = x, iy = y;
if (cc_parent){
ix = cc_xr;
iy = cc_yr;
}
cc_gradientData.mode = CFrameBuffer::pbrg_noFree;
void* gradientData = (cc_gradientData.gradientBuf == NULL) ? NULL : &cc_gradientData;
comp_fbdata_t fbdata[] =
{
{CC_FBDATA_TYPE_BGSCREEN, ix, iy, width+sw, height+sw, 0, 0, 0, NULL, NULL},
{CC_FBDATA_TYPE_SHADOW_BOX, ix+sw, iy+sw, width, height, col_shadow, corner_rad, 0, NULL, NULL},//shadow
{CC_FBDATA_TYPE_FRAME, ix, iy, width, height, col_frame_cur, corner_rad, th, NULL, NULL},//frame
{CC_FBDATA_TYPE_BOX, ix+th, iy+th, width-2*th, height-2*th, col_body, rad, 0, NULL, gradientData},//body
};
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++) {
if (((fbdata[i].fbdata_type == CC_FBDATA_TYPE_SHADOW_BOX) && !shadow) ||
((fbdata[i].fbdata_type == CC_FBDATA_TYPE_FRAME) && !fr_thickness))
continue;
v_fbdata.push_back(fbdata[i]);
}
dprintf(DEBUG_DEBUG, "[CComponentsItem] %s:\ncc_item_type: %d\ncc_item_index = %d\nheight = %d\nwidth = %d\n", __func__, cc_item_type, cc_item_index, height, width);
paintFbItems(do_save_bg);
}
//restore last saved screen behind form box,
//Do use parameter 'no restore' to override the restore funtionality.
//For embedded items is it mostly not required to restore saved screens, so no_resore=true also is default parameter
//for such items.
//This member ensures demage of already existing screen buffer too, if parameter no_restore was changed while runtime.
void CComponentsItem::hideCCItem(bool no_restore)
{
//restore saved screen if available
if (saved_screen.pixbuf) {
frameBuffer->waitForIdle("CComponentsItem::hideCCItem()");
frameBuffer->RestoreScreen(saved_screen.x, saved_screen.y, saved_screen.dx, saved_screen.dy, saved_screen.pixbuf);
if (no_restore) { //on parameter no restore=true delete saved screen if available
delete[] saved_screen.pixbuf;
saved_screen.pixbuf = NULL;
firstPaint = true;
}
}
is_painted = false;
}
void CComponentsItem::hide(bool no_restore)
{
hideCCItem(no_restore);
}
//erase or paint over rendered objects
void CComponentsItem::kill(const fb_pixel_t& bg_color, bool ignore_parent)
{
@@ -194,20 +169,6 @@ bool CComponentsItem::isAdded()
return false;
}
inline void CComponentsItem::setXPos(const int& xpos)
{
x = xpos;
if (cc_parent)
setRealXPos(cc_parent->getRealXPos() + x);
}
inline void CComponentsItem::setYPos(const int& ypos)
{
y = ypos;
if (cc_parent)
setRealYPos(cc_parent->getRealYPos() + y);
}
void CComponentsItem::setXPosP(const uint8_t& xpos_percent)
{
int x_tmp = cc_parent ? xpos_percent*cc_parent->getWidth() : xpos_percent*frameBuffer->getScreenWidth();
@@ -254,28 +215,3 @@ void CComponentsItem::setFocus(bool focus)
}
cc_has_focus = focus;
}
void CComponentsItem::initBodyGradient()
{
if (col_body_gradient && cc_gradientData.gradientBuf && (old_gradient_color != col_body || old_gradient_c2c != g_settings.theme.gradient_c2c)) {
free(cc_gradientData.gradientBuf);
cc_gradientData.gradientBuf = NULL;
if (cc_gradientData.boxBuf) {
cs_free_uncached(cc_gradientData.boxBuf);
cc_gradientData.boxBuf = NULL;
}
}
if (cc_gradientData.gradientBuf == NULL) {
CColorGradient ccGradient;
int gsize = cc_body_gradient_direction == CFrameBuffer::gradientVertical ? height : width;
if (g_settings.theme.gradient_c2c)
cc_gradientData.gradientBuf = ccGradient.gradientColorToColor(col_body, cc_body_gradient_2nd_col, NULL, gsize, cc_body_gradient_mode, cc_body_gradient_intensity);
else
cc_gradientData.gradientBuf = ccGradient.gradientOneColor(col_body, NULL, gsize, cc_body_gradient_mode, cc_body_gradient_intensity, cc_body_gradient_intensity_v_min, cc_body_gradient_intensity_v_max, cc_body_gradient_saturation);
old_gradient_color = col_body;
old_gradient_c2c = g_settings.theme.gradient_c2c;
}
cc_gradientData.direction = cc_body_gradient_direction;
cc_gradientData.mode = CFrameBuffer::pbrg_noOption;
}