mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 07:51:19 +02:00
Shadow: try to optimize shadow areas
* cleanup inner part of box on round corners, frames considered * adopt implementations in some gui classes * some debug lines removed * test menu adopted * try to fix corner caluculation to avoid transparent holes
This commit is contained in:
@@ -74,42 +74,53 @@ void CComponentsItem::paintInit(bool do_save_bg)
|
|||||||
|
|
||||||
//calculate current needed frame thickeness and color, if item selected or not
|
//calculate current needed frame thickeness and color, if item selected or not
|
||||||
fb_pixel_t col_frame_cur = col_frame;
|
fb_pixel_t col_frame_cur = col_frame;
|
||||||
int th = fr_thickness;
|
int th = cc_enable_frame ? fr_thickness : 0;
|
||||||
|
|
||||||
if (v_fbdata.empty()){
|
if (v_fbdata.empty()){
|
||||||
//calculate current needed corner radius for body box, depends of frame thickness
|
//set current position and dimensions
|
||||||
int rad = (th) ? corner_rad-th : corner_rad;
|
int ix = x, iy = y, dx = width, dy = height;
|
||||||
//and ensure max radius < dimensions
|
|
||||||
rad = min(min(rad, corner_rad), min(width, height));
|
|
||||||
|
|
||||||
int sw = (shadow) ? shadow_w : 0;
|
//and ensure sw is not larger than body dimensions, max x%
|
||||||
|
int sw = (shadow) ? min(shadow_w, min(dx, dy)*50/100) : 0;
|
||||||
|
|
||||||
|
//set current needed corner main box radius
|
||||||
|
int box_rad = corner_rad;
|
||||||
|
|
||||||
|
//and ensure max main box radius < dimensions
|
||||||
|
if (2*box_rad > dy)
|
||||||
|
box_rad -= max(0, 2*box_rad-dy);
|
||||||
|
if (2*box_rad > dx)
|
||||||
|
box_rad -= max(0, 2*box_rad-dy);
|
||||||
|
|
||||||
|
//Workaround: ensure radius values >= 0, framebuffer methode paintBoxRel() gets confused
|
||||||
|
box_rad = max(box_rad-th, 0);
|
||||||
|
|
||||||
//if item is bound on a parent form,...
|
|
||||||
int ix = x, iy = y;
|
|
||||||
fb_pixel_t col_shadow_clean = 0;
|
fb_pixel_t col_shadow_clean = 0;
|
||||||
|
//if item is bound on a parent form,...
|
||||||
if (cc_parent){
|
if (cc_parent){
|
||||||
//we must use real x/y values and from parent form as reference
|
//...we must use real x/y values and from parent form as reference
|
||||||
ix = cc_xr;
|
ix = cc_xr;
|
||||||
iy = cc_yr;
|
iy = cc_yr;
|
||||||
//we must use color of parent body instead screen background
|
//...we must use color of parent body instead screen background
|
||||||
col_shadow_clean = cc_parent->getColorBody();
|
col_shadow_clean = cc_parent->getColorBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
// //handle shadow width
|
///evaluate shadow layer parts
|
||||||
// if (width <= sw || height <= sw){ //don't use shadow, if item dimensions too small
|
//handle general shadow corner dimensions
|
||||||
// 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);
|
int sh_cdx = box_rad+sw+th; //width
|
||||||
// shadow = CC_SHADOW_OFF;
|
int sh_cdy = box_rad+sw+th; //height
|
||||||
// sw = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//evaluate shadow layer parts
|
//adapt shadow corner dimensions if body dimensions are too small, use an offset if required
|
||||||
//handle shadow corner dimensions
|
int sh_cdx_size_offset, sh_cdy_size_offset = 0;
|
||||||
int sh_cdx = rad+sw, sh_cdy = rad+sw;
|
if (sh_cdy*2 > dy)
|
||||||
|
sh_cdy_size_offset = sh_cdy*2-dy;
|
||||||
|
if (sh_cdx*2 > dx)
|
||||||
|
sh_cdx_size_offset = sh_cdx*2-dx;
|
||||||
|
|
||||||
//handle shadow positions
|
//handle shadow positions
|
||||||
//...corner bottom right
|
//...corner bottom right
|
||||||
int sh_cbr_x = ix+width-sh_cdx+sw;
|
int sh_cbr_x = ix+dx-sh_cdx+sw;
|
||||||
int sh_cbr_y = iy+height-sh_cdy+sw;
|
int sh_cbr_y = iy+dy-sh_cdy+sw;
|
||||||
|
|
||||||
//...corner top right
|
//...corner top right
|
||||||
int sh_ctr_x = sh_cbr_x;
|
int sh_ctr_x = sh_cbr_x;
|
||||||
@@ -119,75 +130,64 @@ void CComponentsItem::paintInit(bool do_save_bg)
|
|||||||
int sh_cbl_x = ix+sw;
|
int sh_cbl_x = ix+sw;
|
||||||
int sh_cbl_y = sh_cbr_y;
|
int sh_cbl_y = sh_cbr_y;
|
||||||
|
|
||||||
|
//handle general shadow bar dimensions
|
||||||
|
int sh_bdx = dx-sh_cdx-sh_cdx;
|
||||||
|
int sh_rdy = dy-sh_cdy-sh_cdy;
|
||||||
|
|
||||||
//...bar bottom
|
//...bar bottom
|
||||||
int sh_bx = sh_cbl_x+sh_cdx;
|
int sh_bx = sh_cbl_x+sh_cdx;
|
||||||
int sh_by = iy+height;
|
int sh_by = iy+dy;
|
||||||
int sh_bdx = width-sh_cdx-sh_cdx;
|
|
||||||
|
|
||||||
//...bar right
|
//...bar right
|
||||||
int sh_rx = ix+width;
|
int sh_rx = ix+dx;
|
||||||
int sh_ry = sh_ctr_y+sh_cdy;
|
int sh_ry = sh_ctr_y+sh_cdy;
|
||||||
int sh_rdy = height-sh_cdy-sh_cdy;
|
|
||||||
|
|
||||||
//corners
|
//corners
|
||||||
bool sh_ctr = (shadow & CC_SHADOW_CORNER_TOP_RIGHT);
|
bool sh_ctr = (shadow & CC_SHADOW_CORNER_TOP_RIGHT);
|
||||||
bool sh_cbr = (shadow & CC_SHADOW_CORNER_BOTTOM_RIGHT);
|
bool sh_cbr = (shadow & CC_SHADOW_CORNER_BOTTOM_RIGHT);
|
||||||
bool sh_cbl = (shadow & CC_SHADOW_CORNER_BOTTOM_LEFT);
|
bool sh_cbl = (shadow & CC_SHADOW_CORNER_BOTTOM_LEFT);
|
||||||
|
|
||||||
//...bars
|
//...shadow bar right
|
||||||
bool sh_br = (shadow & CC_SHADOW_RIGHT);
|
bool sh_br = (shadow & CC_SHADOW_RIGHT);
|
||||||
printf("<<<<<<<<<<<sh_rdy<<<<<<<<<<< %d\n", sh_rdy );
|
|
||||||
if (sh_rdy < 1)
|
if (sh_rdy < 1)
|
||||||
sh_br = false;
|
sh_br = false;
|
||||||
|
//...shadow bar bottom
|
||||||
bool sh_bb = (shadow & CC_SHADOW_BOTTOM);
|
bool sh_bb = (shadow & CC_SHADOW_BOTTOM);
|
||||||
printf("<<<<<<<<<<<sh_bdx<<<<<<<<<<< %d\n", sh_bdx );
|
|
||||||
if (sh_bdx < 1)
|
if (sh_bdx < 1)
|
||||||
sh_bx = false;
|
sh_bx = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// int sh_ry = sh_tr ? iy+2*sw+rad : iy+sw;
|
|
||||||
// int sh_rdy = sh_tr ? height-2*rad-2*sw : height-rad-sw;
|
|
||||||
//
|
|
||||||
// int sh_bx = sh_bl ? ix+2*sw+rad : ix+sw;
|
|
||||||
// int sh_bdx = sh_bl ? width-2*rad-2*sw : width-rad-sw;
|
|
||||||
|
|
||||||
// if (!(corner_type & CORNER_BOTTOM_RIGHT)){
|
|
||||||
// sh_rdy += rad;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
//init paint layers
|
//init paint layers
|
||||||
cc_fbdata_t fbdata[] =
|
cc_fbdata_t fbdata[] =
|
||||||
{
|
{
|
||||||
//buffered bg
|
//buffered bg
|
||||||
{true, CC_FBDATA_TYPE_BGSCREEN, ix, iy, width+sw, height+sw, 0, 0, 0, 0, NULL, NULL, NULL, false},
|
{true, CC_FBDATA_TYPE_BGSCREEN, ix, iy, dx+sw, dy+sw, 0, 0, 0, 0, NULL, NULL, NULL, false},
|
||||||
|
|
||||||
//shadow corner bottom left
|
//shadow corner bottom left
|
||||||
{sh_cbl, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbl_x, sh_cbl_y, sh_cdx, sh_cdy, COL_GREEN, rad+th, CORNER_BOTTOM_LEFT, 0, NULL, NULL, NULL, false},
|
{sh_cbl, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbl_x, sh_cbl_y, sh_cdx, sh_cdy, col_shadow, box_rad, corner_type & CORNER_BOTTOM_LEFT, 0, NULL, NULL, NULL, false},
|
||||||
//clean up inside body
|
//clean up inside body
|
||||||
{sh_cbl, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbl_x-sw, sh_cbl_y-sw, sh_cdx+sw, sh_cdy, col_shadow_clean, rad+th, CORNER_BOTTOM_LEFT, 0, NULL, NULL, NULL, false},
|
{sh_cbl, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbl_x-sw+th, sh_cbl_y-sw, sh_cdx+sw, sh_cdy, col_shadow_clean, box_rad, corner_type & CORNER_BOTTOM_LEFT, 0, NULL, NULL, NULL, false},
|
||||||
|
|
||||||
//shadow corner bottom right
|
|
||||||
{sh_cbr, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbr_x, sh_cbr_y, sh_cdx, sh_cdy, COL_GREEN, rad+th, corner_type & CORNER_BOTTOM_RIGHT, 0, NULL, NULL, NULL, false},
|
|
||||||
//clean up inside body
|
|
||||||
{sh_cbr, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbr_x-sw, sh_cbr_y-sw, sh_cdx, sh_cdy, col_shadow_clean, rad+th, corner_type & CORNER_BOTTOM_RIGHT, 0, NULL, NULL, NULL, false},
|
|
||||||
|
|
||||||
//shadow corner top right
|
|
||||||
{sh_ctr, CC_FBDATA_TYPE_SHADOW_BOX, sh_ctr_x, sh_ctr_y, sh_cdx, sh_cdy, COL_GREEN, rad+th, corner_type & CORNER_TOP_RIGHT, 0, NULL, NULL, NULL, false},
|
|
||||||
//clean up inside body
|
|
||||||
{sh_ctr, CC_FBDATA_TYPE_SHADOW_BOX, sh_ctr_x-sw, sh_ctr_y-sw, sh_cdx, sh_cdy+sw, col_shadow_clean, rad+th, corner_type & CORNER_TOP_RIGHT, 0, NULL, NULL, NULL, false},
|
|
||||||
|
|
||||||
//shadow bar bottom
|
//shadow bar bottom
|
||||||
{sh_bb, CC_FBDATA_TYPE_SHADOW_BOX, sh_bx, sh_by, sh_bdx, sw, COL_RED, 0, CORNER_NONE, 0, NULL, NULL, NULL, false},
|
{sh_bb, CC_FBDATA_TYPE_SHADOW_BOX, sh_bx, sh_by, sh_bdx, sw, col_shadow, 0, CORNER_NONE, 0, NULL, NULL, NULL, false},
|
||||||
//shadow bar right
|
|
||||||
{sh_br, CC_FBDATA_TYPE_SHADOW_BOX, sh_rx, sh_ry, sw, sh_rdy, COL_BLUE, 0, CORNER_NONE, 0, NULL, NULL, NULL, false},
|
|
||||||
|
|
||||||
//body box
|
//shadow corner bottom right
|
||||||
{true, CC_FBDATA_TYPE_BOX, ix+th, iy+th, width-2*th, height-2*th, col_body, rad-th, corner_type, 0, NULL, NULL, NULL, false},
|
{sh_cbr, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbr_x, sh_cbr_y, sh_cdx, sh_cdy, col_shadow, box_rad, corner_type & CORNER_BOTTOM_RIGHT, 0, NULL, NULL, NULL, false},
|
||||||
|
//clean up inside body
|
||||||
|
{sh_cbr, CC_FBDATA_TYPE_SHADOW_BOX, sh_cbr_x-sw-th, sh_cbr_y-sw-th, sh_cdx, sh_cdy, col_shadow_clean, box_rad, corner_type & CORNER_BOTTOM_RIGHT, 0, NULL, NULL, NULL, false},
|
||||||
|
|
||||||
|
//shadow bar right
|
||||||
|
{sh_br, CC_FBDATA_TYPE_SHADOW_BOX, sh_rx, sh_ry, sw, sh_rdy, col_shadow, 0, CORNER_NONE, 0, NULL, NULL, NULL, false},
|
||||||
|
|
||||||
|
//shadow corner top right
|
||||||
|
{sh_ctr, CC_FBDATA_TYPE_SHADOW_BOX, sh_ctr_x, sh_ctr_y, sh_cdx, sh_cdy-sh_cdy_size_offset, col_shadow, box_rad, corner_type & CORNER_TOP_RIGHT, 0, NULL, NULL, NULL, false},
|
||||||
|
//clean up inside body
|
||||||
|
{sh_ctr, CC_FBDATA_TYPE_SHADOW_BOX, sh_ctr_x-sw, sh_ctr_y-sw+th, sh_cdx, sh_cdy-sh_cdy_size_offset+sw, col_shadow_clean, box_rad, corner_type & CORNER_TOP_RIGHT, 0, NULL, NULL, NULL, false},
|
||||||
|
|
||||||
|
//main box
|
||||||
|
{true, CC_FBDATA_TYPE_BOX, ix+th, iy+th, dx-2*th, dy-2*th, col_body, box_rad, corner_type, 0, NULL, NULL, NULL, false},
|
||||||
|
|
||||||
//frame
|
//frame
|
||||||
{true, CC_FBDATA_TYPE_FRAME, ix, iy, width, height, col_frame_cur, rad, corner_type, th, NULL, NULL, NULL, false}
|
{true, CC_FBDATA_TYPE_FRAME, ix, iy, dx, dy, col_frame_cur, box_rad+th, corner_type, th, NULL, NULL, NULL, false}
|
||||||
};
|
};
|
||||||
|
|
||||||
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++) {
|
for(size_t i =0; i< (sizeof(fbdata) / sizeof(fbdata[0])) ;i++) {
|
||||||
@@ -195,7 +195,6 @@ void CComponentsItem::paintInit(bool do_save_bg)
|
|||||||
continue;
|
continue;
|
||||||
v_fbdata.push_back(fbdata[i]);
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//handle frame color for slected/not selected item
|
//handle frame color for slected/not selected item
|
||||||
|
@@ -429,7 +429,7 @@ void CInfoViewer::paintHead()
|
|||||||
int head_x = BoxStartX+ChanWidth -1; /*Ugly: -1 to avoid background shine through round borders*/
|
int head_x = BoxStartX+ChanWidth -1; /*Ugly: -1 to avoid background shine through round borders*/
|
||||||
int head_w = BoxEndX-head_x;
|
int head_w = BoxEndX-head_x;
|
||||||
if (header == NULL){
|
if (header == NULL){
|
||||||
header = new CComponentsShapeSquare(head_x, ChanNameY, head_w, time_height, NULL, CC_SHADOW_RIGHT);
|
header = new CComponentsShapeSquare(head_x, ChanNameY, head_w, time_height, NULL, CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT);
|
||||||
header->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT);
|
header->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT);
|
||||||
}else
|
}else
|
||||||
header->setDimensionsAll(head_x, ChanNameY, head_w, time_height);
|
header->setDimensionsAll(head_x, ChanNameY, head_w, time_height);
|
||||||
@@ -470,7 +470,7 @@ void CInfoViewer::paintBody()
|
|||||||
|
|
||||||
//set corner and shadow modes, consider virtual zap mode
|
//set corner and shadow modes, consider virtual zap mode
|
||||||
body->setCorner(RADIUS_LARGE, (zap_mode) ? CORNER_BOTTOM : CORNER_NONE);
|
body->setCorner(RADIUS_LARGE, (zap_mode) ? CORNER_BOTTOM : CORNER_NONE);
|
||||||
body->enableShadow(zap_mode ? CC_SHADOW_ON : CC_SHADOW_RIGHT);
|
body->enableShadow(zap_mode ? CC_SHADOW_ON : CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT);
|
||||||
|
|
||||||
body->setColorBody(g_settings.theme.infobar_gradient_body ? COL_MENUHEAD_PLUS_0 : COL_INFOBAR_PLUS_0);
|
body->setColorBody(g_settings.theme.infobar_gradient_body ? COL_MENUHEAD_PLUS_0 : COL_INFOBAR_PLUS_0);
|
||||||
body->enableColBodyGradient(g_settings.theme.infobar_gradient_body, COL_INFOBAR_PLUS_0, g_settings.theme.infobar_gradient_body_direction);
|
body->enableColBodyGradient(g_settings.theme.infobar_gradient_body, COL_INFOBAR_PLUS_0, g_settings.theme.infobar_gradient_body_direction);
|
||||||
|
@@ -398,8 +398,8 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
}
|
}
|
||||||
else if (actionKey == "square"){
|
else if (actionKey == "square"){
|
||||||
if (sq == NULL){
|
if (sq == NULL){
|
||||||
sq = new CComponentsShapeSquare (100, 220, 100, 100, NULL, CC_SHADOW_ON, COL_MENUCONTENT_PLUS_6, COL_LIGHT_GRAY, COL_RED);
|
sq = new CComponentsShapeSquare (0, 0, 100, 100, NULL, CC_SHADOW_ON, COL_OLIVE, COL_LIGHT_GRAY, COL_RED);
|
||||||
sq->setCorner(11, CORNER_BOTTOM_LEFT);
|
sq->enableFrame(true,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sq->isPainted())
|
if (!sq->isPainted())
|
||||||
|
@@ -989,7 +989,7 @@ void CUpnpBrowserGui::paintDevices()
|
|||||||
|
|
||||||
// Head
|
// Head
|
||||||
CComponentsHeaderLocalized header(m_x, m_header_y, m_width, m_header_height, LOCALE_UPNPBROWSER_HEAD, NEUTRINO_ICON_UPNP);
|
CComponentsHeaderLocalized header(m_x, m_header_y, m_width, m_header_height, LOCALE_UPNPBROWSER_HEAD, NEUTRINO_ICON_UPNP);
|
||||||
header.enableShadow(CC_SHADOW_RIGHT, -1, true);
|
header.enableShadow( CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT, -1, true);
|
||||||
if (CNeutrinoApp::getInstance()->isMuted()) //TODO: consider mute mode on runtime
|
if (CNeutrinoApp::getInstance()->isMuted()) //TODO: consider mute mode on runtime
|
||||||
header.addContextButton(NEUTRINO_ICON_BUTTON_MUTE_SMALL);
|
header.addContextButton(NEUTRINO_ICON_BUTTON_MUTE_SMALL);
|
||||||
else
|
else
|
||||||
|
@@ -1240,7 +1240,7 @@ void CMenuWidget::paint()
|
|||||||
// paint head
|
// paint head
|
||||||
if (header == NULL){
|
if (header == NULL){
|
||||||
header = new CComponentsHeader(x, y, width + sb_width, hheight, getName(), iconfile);
|
header = new CComponentsHeader(x, y, width + sb_width, hheight, getName(), iconfile);
|
||||||
header->enableShadow(CC_SHADOW_RIGHT);
|
header->enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT);
|
||||||
header->setOffset(10);
|
header->setOffset(10);
|
||||||
}
|
}
|
||||||
header->setColorAll(COL_FRAME_PLUS_0, COL_MENUHEAD_PLUS_0, COL_SHADOW_PLUS_0);
|
header->setColorAll(COL_FRAME_PLUS_0, COL_MENUHEAD_PLUS_0, COL_SHADOW_PLUS_0);
|
||||||
|
Reference in New Issue
Block a user