X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcwindowdraw.C;h=eb35b63e7ca34e2cf0fed664a641e2926d24b187;hp=c81c36963223fa2b91e6ef3faeaaeff3ba71386e;hb=9e3d90a964c0fbe97c0b58235336a47111932d5d;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1 diff --git a/cinelerra-5.1/guicast/bcwindowdraw.C b/cinelerra-5.1/guicast/bcwindowdraw.C index c81c3696..eb35b63e 100644 --- a/cinelerra-5.1/guicast/bcwindowdraw.C +++ b/cinelerra-5.1/guicast/bcwindowdraw.C @@ -178,12 +178,7 @@ void BC_WindowBase::draw_utf8_text(int x, int y, if(top_level->get_xft_struct(top_level->current_font)) { - draw_xft_text(x, - y, - text, - length, - pixmap, - 1); + draw_xft_text(x, y, text, length, pixmap, 1); return; } BT @@ -195,22 +190,15 @@ void BC_WindowBase::draw_utf8_text(int x, int y, { XmbDrawString(top_level->display, pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, - top_level->get_curr_fontset(), - top_level->gc, - x, - y, - &text[j], - i - j); + top_level->get_curr_fontset(), top_level->gc, + x, y, &text[j], i - j); } else { XDrawString(top_level->display, pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, top_level->gc, - x, - y, - &text[j], - i - j); + x, y, &text[j], i - j); } j = i + 1; @@ -223,21 +211,21 @@ void BC_WindowBase::draw_xft_text(int x, int y, const char *text, int length, BC_Pixmap *pixmap, int is_utf8) { int l = length + 1; - wchar_t wide_text[l]; + wchr_t wide_text[l]; length = BC_Resources::encode( is_utf8 ? "UTF8" : BC_Resources::encoding, BC_Resources::wide_encoding, - (char*)text, length, (char*)wide_text, l*sizeof(wchar_t)) / sizeof(wchar_t); + (char*)text, length, (char*)wide_text, l*sizeof(wchr_t)) / sizeof(wchr_t); draw_xft_text(x, y, wide_text, length, pixmap); } void BC_WindowBase::draw_xft_text(int x, int y, - const wchar_t *text, int length, BC_Pixmap *pixmap) + const wchr_t *text, int length, BC_Pixmap *pixmap) { int dy = -1; - const wchar_t *wsp = text, *wep = wsp + length; + const wchr_t *wsp = text, *wep = wsp + length; int font = top_level->current_font; while( wsp < wep ) { - const wchar_t *wcp = wsp; + const wchr_t *wcp = wsp; while( wcp < wep && *wcp != '\n' ) ++wcp; int len = wcp - wsp; if( len > 0 ) @@ -284,16 +272,16 @@ void BC_WindowBase::xft_draw_string(XftColor *xft_color, XftFont *xft_font, } } -int BC_WindowBase::get_single_text_width(int font, const wchar_t *text, int length) +int BC_WindowBase::get_single_text_width(int font, const wchr_t *text, int length) { return draw_single_text(0, font, 0,0, text, length); } int BC_WindowBase::draw_single_text(int draw, int font, - int x, int y, const wchar_t *text, int length, BC_Pixmap *pixmap) + int x, int y, const wchr_t *text, int length, BC_Pixmap *pixmap) { if( length < 0 ) - length = wcslen(text); + length = wstrlen(text); if( !length ) return 0; if( !get_resources()->use_xft ) { @@ -331,7 +319,7 @@ int BC_WindowBase::draw_single_text(int draw, int font, int x0 = x; XftFont *basefont = top_level->get_xft_struct(font); XftFont *curfont = 0, *altfont = 0; - const wchar_t *up = text, *ubp = up, *uep = ubp + length; + const wchr_t *up = text, *ubp = up, *uep = ubp + length; while( up < uep ) { XftFont *xft_font = 0; @@ -392,45 +380,6 @@ int BC_WindowBase::draw_single_text(int draw, int font, return x - x0; } -void BC_WindowBase::truncate_text(char *result, const char *text, int w) -{ - int new_w = get_text_width(current_font, text); - - if(new_w > w) - { - const char* separator = "..."; - int separator_w = get_text_width(current_font, separator); -// can't fit - if(separator_w >= w) - { - strcpy(result, separator); - return; - } - - int text_len = strlen(text); -// widen middle gap until it fits - for(int i = text_len / 2; i > 0; i--) - { - strncpy(result, text, i); - result[i] = 0; - strcat(result, separator); - strncat(result, text + text_len - i, i); - result[i + strlen(separator) + i] = 0; - new_w = get_text_width(current_font, result); -//printf("BC_WindowBase::truncate_text %d %d %d %s\n", __LINE__, new_w, w, result); - if(new_w < w) return; - } - -// Didn't fit - strcpy(result, separator); - return; - } - else - { - strcpy(result, text); - } -} - void BC_WindowBase::draw_center_text(int x, int y, const char *text, int length) { if(length < 0) length = strlen(text); @@ -442,19 +391,13 @@ void BC_WindowBase::draw_center_text(int x, int y, const char *text, int length) void BC_WindowBase::draw_line(int x1, int y1, int x2, int y2, BC_Pixmap *pixmap) { BT // Some X drivers can't draw 0 length lines - if(x1 == x2 && y1 == y2) - { + if( x1 == x2 && y1 == y2 ) { draw_pixel(x1, y1, pixmap); } - else - { + else { XDrawLine(top_level->display, pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, - top_level->gc, - x1, - y1, - x2, - y2); + top_level->gc, x1, y1, x2, y2); } } @@ -463,18 +406,14 @@ void BC_WindowBase::draw_polygon(ArrayList *x, ArrayList *y, BC_Pixmap int npoints = MIN(x->total, y->total); XPoint *points = new XPoint[npoints]; - for(int i = 0; i < npoints; i++) - { + for( int i=0; ivalues[i]; points[i].y = y->values[i]; } XDrawLines(top_level->display, - pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, - top_level->gc, - points, - npoints, - CoordModeOrigin); + pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, + top_level->gc, points, npoints, CoordModeOrigin); delete [] points; } @@ -484,19 +423,14 @@ void BC_WindowBase::fill_polygon(ArrayList *x, ArrayList *y, BC_Pixmap int npoints = MIN(x->total, y->total); XPoint *points = new XPoint[npoints]; - for(int i = 0; i < npoints; i++) - { + for( int i=0; ivalues[i]; points[i].y = y->values[i]; } XFillPolygon(top_level->display, - pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, - top_level->gc, - points, - npoints, - Nonconvex, - CoordModeOrigin); + pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, + top_level->gc, points, npoints, Nonconvex, CoordModeOrigin); delete [] points; } @@ -505,24 +439,13 @@ void BC_WindowBase::fill_polygon(ArrayList *x, ArrayList *y, BC_Pixmap void BC_WindowBase::draw_rectangle(int x, int y, int w, int h) { BT XDrawRectangle(top_level->display, - pixmap->opaque_pixmap, - top_level->gc, - x, - y, - w - 1, - h - 1); + pixmap->opaque_pixmap, top_level->gc, + x, y, w - 1, h - 1); } -void BC_WindowBase::draw_3d_border(int x, - int y, - int w, - int h, - int is_down) +void BC_WindowBase::draw_3d_border(int x, int y, int w, int h, int is_down) { - draw_3d_border(x, - y, - w, - h, + draw_3d_border(x, y, w, h, top_level->get_resources()->border_shadow2, top_level->get_resources()->border_shadow1, top_level->get_resources()->border_light1, @@ -530,14 +453,8 @@ void BC_WindowBase::draw_3d_border(int x, } -void BC_WindowBase::draw_3d_border(int x, - int y, - int w, - int h, - int light1, - int light2, - int shadow1, - int shadow2) +void BC_WindowBase::draw_3d_border(int x, int y, int w, int h, + int light1, int light2, int shadow1, int shadow2) { int lx, ly, ux, uy; @@ -561,15 +478,8 @@ void BC_WindowBase::draw_3d_border(int x, draw_line(x, y + h, x + w, y + h); } -void BC_WindowBase::draw_3d_box(int x, - int y, - int w, - int h, - int light1, - int light2, - int middle, - int shadow1, - int shadow2, +void BC_WindowBase::draw_3d_box(int x, int y, int w, int h, + int light1, int light2, int middle, int shadow1, int shadow2, BC_Pixmap *pixmap) { int lx, ly, ux, uy; @@ -639,7 +549,7 @@ void BC_WindowBase::draw_colored_box(int x, int y, int w, int h, int down, int h void BC_WindowBase::draw_border(char *text, int x, int y, int w, int h) { - int left_indent = 20; + int left_indent = xS(20); int lx, ly, ux, uy; h--; w--; @@ -655,16 +565,16 @@ void BC_WindowBase::draw_border(char *text, int x, int y, int w, int h) } set_color(top_level->get_resources()->button_shadow); - draw_line(x, y, x + left_indent - 5, y); + draw_line(x, y, x + left_indent - xS(5), y); draw_line(x, y, x, uy); - draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), y, ux, y); + draw_line(x + left_indent + xS(5) + get_text_width(MEDIUMFONT, text), y, ux, y); draw_line(x, y, x, uy); draw_line(ux, ly, ux, uy); draw_line(lx, uy, ux, uy); set_color(top_level->get_resources()->button_light); - draw_line(lx, ly, x + left_indent - 5 - 1, ly); + draw_line(lx, ly, x + left_indent - xS(5) - 1, ly); draw_line(lx, ly, lx, uy - 1); - draw_line(x + left_indent + 5 + get_text_width(MEDIUMFONT, text), ly, ux - 1, ly); + draw_line(x + left_indent + xS(5) + get_text_width(MEDIUMFONT, text), ly, ux - 1, ly); draw_line(lx, ly, lx, uy - 1); draw_line(x + w, y, x + w, y + h); draw_line(x, y + h, x + w, y + h); @@ -675,19 +585,16 @@ void BC_WindowBase::draw_triangle_down_flat(int x, int y, int w, int h) int x1, y1, x2, y2, x3; XPoint point[3]; - x1 = x; x2 = x + w / 2; x3 = x + w - 1; - y1 = y; y2 = y + h - 1; + x1 = x+1; x2 = x + w/2; x3 = x+w-1; + y1 = y; y2 = y+h-1; - point[0].x = x2; point[0].y = y2; point[1].x = x3; - point[1].y = y1; point[2].x = x1; point[2].y = y1; + point[0].x = x2; point[0].y = y2; + point[1].x = x3; point[1].y = y1; + point[2].x = x1; point[2].y = y1; - XFillPolygon(top_level->display, - pixmap->opaque_pixmap, - top_level->gc, - (XPoint *)point, - 3, - Nonconvex, - CoordModeOrigin); + XFillPolygon(top_level->display, pixmap->opaque_pixmap, top_level->gc, + (XPoint *)point, 3, Nonconvex, CoordModeOrigin); + draw_line(x1,y1, x3,y1); } void BC_WindowBase::draw_triangle_up(int x, int y, int w, int h, @@ -704,13 +611,8 @@ void BC_WindowBase::draw_triangle_up(int x, int y, int w, int h, point[1].y = y2; point[2].x = x1; point[2].y = y2; set_color(middle); - XFillPolygon(top_level->display, - pixmap->opaque_pixmap, - top_level->gc, - (XPoint *)point, - 3, - Nonconvex, - CoordModeOrigin); + XFillPolygon(top_level->display, pixmap->opaque_pixmap, top_level->gc, + (XPoint *)point, 3, Nonconvex, CoordModeOrigin); // bottom and top right set_color(shadow1); @@ -839,25 +741,25 @@ void BC_WindowBase::draw_triangle_right(int x, int y, int w, int h, void BC_WindowBase::draw_check(int x, int y) { - const int w = 15, h = 15; - draw_line(x + 3, y + h / 2 + 0, x + 6, y + h / 2 + 2); - draw_line(x + 3, y + h / 2 + 1, x + 6, y + h / 2 + 3); - draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3); - draw_line(x + 3, y + h / 2 + 2, x + 6, y + h / 2 + 4); - draw_line(x + 6, y + h / 2 + 2, x + w - 4, y + h / 2 - 3); - draw_line(x + 6, y + h / 2 + 3, x + w - 4, y + h / 2 - 2); - draw_line(x + 6, y + h / 2 + 4, x + w - 4, y + h / 2 - 1); + int xs3 = xS(3), xs4 = xS(4), xs6 = xS(6); + int ys1 = yS(1), ys2 = yS(2), ys3 = yS(3), ys4 = yS(4); + const int w = xS(15), h = yS(15), yh2 = y + h/2; + draw_line(x + xs3, yh2 + 0, x + xs6, yh2 + ys2); + draw_line(x + xs3, yh2 + ys1, x + xs6, yh2 + ys3); + draw_line(x + xs6, yh2 + ys2, x + w - xs4, yh2 - ys3); + draw_line(x + xs3, yh2 + ys2, x + xs6, yh2 + ys4); + draw_line(x + xs6, yh2 + ys2, x + w - xs4, yh2 - ys3); + draw_line(x + xs6, yh2 + ys3, x + w - xs4, yh2 - ys2); + draw_line(x + xs6, yh2 + ys4, x + w - xs4, yh2 - ys1); } void BC_WindowBase::draw_tiles(BC_Pixmap *tile, int origin_x, int origin_y, int x, int y, int w, int h) { BT - if(!tile) - { + if( !tile ) { set_color(bg_color); draw_box(x, y, w, h); } - else - { + else { XSetFillStyle(top_level->display, top_level->gc, FillTiled); // Don't know how slow this is XSetTile(top_level->display, top_level->gc, tile->get_pixmap()); @@ -872,132 +774,77 @@ void BC_WindowBase::draw_top_tiles(BC_WindowBase *parent_window, int x, int y, i Window tempwin; int origin_x, origin_y; XTranslateCoordinates(top_level->display, - parent_window->win, - win, - 0, - 0, - &origin_x, - &origin_y, - &tempwin); - + parent_window->win, win, + 0, 0, &origin_x, &origin_y, &tempwin); draw_tiles(parent_window->bg_pixmap, - origin_x, - origin_y, - x, - y, - w, - h); + origin_x, origin_y, + x, y, w, h); } void BC_WindowBase::draw_top_background(BC_WindowBase *parent_window, - int x, - int y, - int w, - int h, - BC_Pixmap *pixmap) + int x, int y, int w, int h, BC_Pixmap *pixmap) { BT Window tempwin; int top_x, top_y; XLockDisplay(top_level->display); XTranslateCoordinates(top_level->display, - win, - parent_window->win, - x, - y, - &top_x, - &top_y, - &tempwin); + win, parent_window->win, + x, y, &top_x, &top_y, &tempwin); XCopyArea(top_level->display, parent_window->pixmap->opaque_pixmap, pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, - top_level->gc, - top_x, - top_y, - w, - h, - x, - y); + top_level->gc, top_x, top_y, w, h, x, y); XUnlockDisplay(top_level->display); } void BC_WindowBase::draw_background(int x, int y, int w, int h) { - if(bg_pixmap) - { + if( bg_pixmap ) { draw_tiles(bg_pixmap, 0, 0, x, y, w, h); } - else - { + else { clear_box(x, y, w, h); } } -void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap, - int dont_wait, - int dest_x, - int dest_y, - int dest_w, - int dest_h, - int src_x, - int src_y, - int src_w, - int src_h, +void BC_WindowBase::draw_bitmap(BC_Bitmap *bitmap, int dont_wait, + int dest_x, int dest_y, int dest_w, int dest_h, + int src_x, int src_y, int src_w, int src_h, BC_Pixmap *pixmap) { BT // Hide cursor if video enabled update_video_cursor(); //printf("BC_WindowBase::draw_bitmap %d dest_y=%d\n", __LINE__, dest_y); - if(dest_w <= 0 || dest_h <= 0) - { + if( dest_w <= 0 || dest_h <= 0 ) { // Use hardware scaling to canvas dimensions if proper color model. - if(bitmap->get_color_model() == BC_YUV420P) - { + if( bitmap->get_color_model() == BC_YUV420P ) { dest_w = w; dest_h = h; } - else - { + else { dest_w = bitmap->get_w(); dest_h = bitmap->get_h(); } } - if(src_w <= 0 || src_h <= 0) - { + if( src_w <= 0 || src_h <= 0 ) { src_w = bitmap->get_w(); src_h = bitmap->get_h(); } - if(video_on) - { + if( video_on ) { bitmap->write_drawable(win, - top_level->gc, - src_x, - src_y, - src_w, - src_h, - dest_x, - dest_y, - dest_w, - dest_h, - dont_wait); + top_level->gc, src_x, src_y, src_w, src_h, + dest_x, dest_y, dest_w, dest_h, dont_wait); top_level->flush(); } - else - { + else { bitmap->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, - top_level->gc, - dest_x, - dest_y, - src_x, - src_y, - dest_w, - dest_h, - dont_wait); + top_level->gc, dest_x, dest_y, src_x, src_y, dest_w, dest_h, dont_wait); } //printf("BC_WindowBase::draw_bitmap 2\n"); } @@ -1007,40 +854,22 @@ void BC_WindowBase::draw_pixel(int x, int y, BC_Pixmap *pixmap) { BT XDrawPoint(top_level->display, pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, - top_level->gc, - x, - y); + top_level->gc, x, y); } void BC_WindowBase::draw_pixmap(BC_Pixmap *pixmap, - int dest_x, - int dest_y, - int dest_w, - int dest_h, - int src_x, - int src_y, - BC_Pixmap *dst) + int dest_x, int dest_y, int dest_w, int dest_h, + int src_x, int src_y, BC_Pixmap *dst) { BT pixmap->write_drawable(dst ? dst->opaque_pixmap : this->pixmap->opaque_pixmap, - dest_x, - dest_y, - dest_w, - dest_h, - src_x, - src_y); + dest_x, dest_y, dest_w, dest_h, src_x, src_y); } void BC_WindowBase::draw_vframe(VFrame *frame, - int dest_x, - int dest_y, - int dest_w, - int dest_h, - int src_x, - int src_y, - int src_w, - int src_h, - BC_Pixmap *pixmap) + int dest_x, int dest_y, int dest_w, int dest_h, + int src_x, int src_y, int src_w, int src_h, + BC_Pixmap *pixmap) { if(dest_w <= 0) dest_w = frame->get_w() - src_x; if(dest_h <= 0) dest_h = frame->get_h() - src_y; @@ -1051,38 +880,17 @@ void BC_WindowBase::draw_vframe(VFrame *frame, if(src_x + src_w > frame->get_w()) src_w = frame->get_w() - src_x; if(src_y + src_h > frame->get_h()) src_h = frame->get_h() - src_y; - if(!temp_bitmap) temp_bitmap = new BC_Bitmap(this, - dest_w, - dest_h, - get_color_model(), - 0); - - temp_bitmap->match_params(dest_w, - dest_h, - get_color_model(), - 0); + if( !temp_bitmap ) + temp_bitmap = new BC_Bitmap(this, dest_w, dest_h, get_color_model(), 0); + temp_bitmap->match_params(dest_w, dest_h, get_color_model(), 0); temp_bitmap->read_frame(frame, - src_x, - src_y, - src_w, - src_h, - 0, - 0, - dest_w, - dest_h); - - draw_bitmap(temp_bitmap, - 0, - dest_x, - dest_y, - dest_w, - dest_h, - 0, - 0, - -1, - -1, - pixmap); + src_x, src_y, src_w, src_h, + 0, 0, dest_w, dest_h, bg_color); + + draw_bitmap(temp_bitmap, 0, + dest_x, dest_y, dest_w, dest_h, + 0, 0, -1, -1, pixmap); } void BC_WindowBase::draw_tooltip(const char *text) @@ -1125,15 +933,8 @@ void BC_WindowBase::slide_right(int distance) if(distance < w) { XCopyArea(top_level->display, - pixmap->opaque_pixmap, - pixmap->opaque_pixmap, - top_level->gc, - 0, - 0, - w - distance, - h, - distance, - 0); + pixmap->opaque_pixmap, pixmap->opaque_pixmap, top_level->gc, + 0, 0, w - distance, h, distance, 0); } } @@ -1142,23 +943,11 @@ void BC_WindowBase::slide_up(int distance) if(distance < h) { XCopyArea(top_level->display, - pixmap->opaque_pixmap, - pixmap->opaque_pixmap, - top_level->gc, - 0, - distance, - w, - h - distance, - 0, - 0); + pixmap->opaque_pixmap, pixmap->opaque_pixmap, top_level->gc, + 0, distance, w, h - distance, 0, 0); set_color(bg_color); - XFillRectangle(top_level->display, - pixmap->opaque_pixmap, - top_level->gc, - 0, - h - distance, - w, - distance); + XFillRectangle(top_level->display, pixmap->opaque_pixmap, top_level->gc, + 0, h - distance, w, distance); } } @@ -1167,35 +956,19 @@ void BC_WindowBase::slide_down(int distance) if(distance < h) { XCopyArea(top_level->display, - pixmap->opaque_pixmap, - pixmap->opaque_pixmap, - top_level->gc, - 0, - 0, - w, - h - distance, - 0, - distance); + pixmap->opaque_pixmap, pixmap->opaque_pixmap, top_level->gc, + 0, 0, w, h - distance, 0, distance); set_color(bg_color); XFillRectangle(top_level->display, - pixmap->opaque_pixmap, - top_level->gc, - 0, - 0, - w, - distance); + pixmap->opaque_pixmap, top_level->gc, + 0, 0, w, distance); } } // 3 segments in separate pixmaps. Obsolete. -void BC_WindowBase::draw_3segment(int x, - int y, - int w, - int h, - BC_Pixmap *left_image, - BC_Pixmap *mid_image, - BC_Pixmap *right_image, - BC_Pixmap *pixmap) +void BC_WindowBase::draw_3segment(int x, int y, int w, int h, + BC_Pixmap *left_image, BC_Pixmap *mid_image, + BC_Pixmap *right_image, BC_Pixmap *pixmap) { if(w <= 0 || h <= 0) return; int left_boundary = left_image->get_w_fixed(); @@ -1227,25 +1000,14 @@ void BC_WindowBase::draw_3segment(int x, if(i + output_w > w) output_w = w - i; image->write_drawable(pixmap ? pixmap->opaque_pixmap : this->pixmap->opaque_pixmap, - x + i, - y, - output_w, - h, - 0, - 0); - + x + i, y, output_w, h, 0, 0); i += output_w; } } // 3 segments in separate vframes. Obsolete. -void BC_WindowBase::draw_3segment(int x, - int y, - int w, - int h, - VFrame *left_image, - VFrame *mid_image, - VFrame *right_image, - BC_Pixmap *pixmap) +void BC_WindowBase::draw_3segment(int x, int y, int w, int h, + VFrame *left_image, VFrame *mid_image, + VFrame *right_image, BC_Pixmap *pixmap) { if(w <= 0 || h <= 0) return; int left_boundary = left_image->get_w_fixed(); @@ -1279,16 +1041,8 @@ void BC_WindowBase::draw_3segment(int x, if(i + output_w > w) output_w = w - i; if(image) - draw_vframe(image, - x + i, - y, - output_w, - h, - 0, - 0, - 0, - 0, - pixmap); + draw_vframe(image, x + i, y, output_w, h, + 0, 0, 0, 0, pixmap); if(output_w == 0) break; i += output_w; @@ -1309,27 +1063,14 @@ void BC_WindowBase::draw_3segment(int x, // |-------------------|----------------------|------------------| -void BC_WindowBase::draw_3segmenth(int x, - int y, - int w, - VFrame *image, - BC_Pixmap *pixmap) +void BC_WindowBase::draw_3segmenth(int x, int y, int w, + VFrame *image, BC_Pixmap *pixmap) { - draw_3segmenth(x, - y, - w, - x, - w, - image, - pixmap); + draw_3segmenth(x, y, w, x, w, image, pixmap); } -void BC_WindowBase::draw_3segmenth(int x, - int y, - int w, - int total_x, - int total_w, - VFrame *image, +void BC_WindowBase::draw_3segmenth(int x, int y, int w, + int total_x, int total_w, VFrame *image, BC_Pixmap *pixmap) { if(total_w <= 0 || w <= 0 || h <= 0) return; @@ -1392,90 +1133,44 @@ void BC_WindowBase::draw_3segmenth(int x, } if(!temp_bitmap) temp_bitmap = new BC_Bitmap(top_level, - image->get_w(), - image->get_h(), - get_color_model(), - 0); - temp_bitmap->match_params(image->get_w(), - image->get_h(), - get_color_model(), - 0); + image->get_w(), image->get_h(), + get_color_model(), 0); + temp_bitmap->match_params(image->get_w(), image->get_h(), + get_color_model(), 0); temp_bitmap->read_frame(image, - 0, - 0, - image->get_w(), - image->get_h()); - - + 0, 0, image->get_w(), image->get_h(), bg_color); +// src width and height are meaningless in video_off mode //printf("BC_WindowBase::draw_3segment 2 left_out_x=%d left_out_w=%d center_out_x=%d center_out_w=%d right_out_x=%d right_out_w=%d\n", // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w); - if(left_out_w > 0) - { - draw_bitmap(temp_bitmap, - 0, - left_out_x, - y, - left_out_w, - image->get_h(), - left_in_x, - 0, - -1, // src width and height are meaningless in video_off mode - -1, - pixmap); + if(left_out_w > 0) { + draw_bitmap(temp_bitmap, 0, + left_out_x, y, left_out_w, image->get_h(), + left_in_x, 0, -1, -1, pixmap); } - if(right_out_w > 0) - { - draw_bitmap(temp_bitmap, - 0, - right_out_x, - y, - right_out_w, - image->get_h(), - right_in_x, - 0, - -1, // src width and height are meaningless in video_off mode - -1, - pixmap); + if(right_out_w > 0) { + draw_bitmap(temp_bitmap, 0, + right_out_x, y, right_out_w, image->get_h(), + right_in_x, 0, -1, -1, pixmap); } - for(int pixel = center_out_x; - pixel < center_out_x + center_out_w; - pixel += half_image) - { + for( int pixel = center_out_x; + pixel < center_out_x + center_out_w; + pixel += half_image ) { int fragment_w = half_image; if(fragment_w + pixel > center_out_x + center_out_w) fragment_w = (center_out_x + center_out_w) - pixel; //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w); - draw_bitmap(temp_bitmap, - 0, - pixel, - y, - fragment_w, - image->get_h(), - third_image, - 0, - -1, // src width and height are meaningless in video_off mode - -1, - pixmap); + draw_bitmap(temp_bitmap, 0, + pixel, y, fragment_w, image->get_h(), + third_image, 0, -1, -1, pixmap); } } - - - - - - -void BC_WindowBase::draw_3segmenth(int x, - int y, - int w, - int total_x, - int total_w, - BC_Pixmap *src, - BC_Pixmap *dst) +void BC_WindowBase::draw_3segmenth(int x, int y, int w, int total_x, int total_w, + BC_Pixmap *src, BC_Pixmap *dst) { if(w <= 0 || total_w <= 0) return; if(!src) printf("BC_WindowBase::draw_3segmenth src=0\n"); @@ -1541,56 +1236,23 @@ void BC_WindowBase::draw_3segmenth(int x, //printf("BC_WindowBase::draw_3segment 2 left_out_x=%d left_out_w=%d center_out_x=%d center_out_w=%d right_out_x=%d right_out_w=%d\n", // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w); if(left_out_w > 0) - { - draw_pixmap(src, - left_out_x, - y, - left_out_w, - src->get_h(), - left_in_x, - 0, - dst); - } + draw_pixmap(src, left_out_x, y, left_out_w, src->get_h(), left_in_x, 0, dst); if(right_out_w > 0) - { - draw_pixmap(src, - right_out_x, - y, - right_out_w, - src->get_h(), - right_in_x, - 0, - dst); - } + draw_pixmap(src, right_out_x, y, right_out_w, src->get_h(), right_in_x, 0, dst); - for(int pixel = center_out_x; - pixel < center_out_x + center_out_w; - pixel += half_src) - { + for( int pixel = center_out_x; pixel < center_out_x + center_out_w; pixel += half_src) { int fragment_w = half_src; if(fragment_w + pixel > center_out_x + center_out_w) fragment_w = (center_out_x + center_out_w) - pixel; - //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w); - draw_pixmap(src, - pixel, - y, - fragment_w, - src->get_h(), - quarter_src, - 0, - dst); + draw_pixmap(src, pixel, y, fragment_w, src->get_h(), quarter_src, 0, dst); } } -void BC_WindowBase::draw_3segmenth(int x, - int y, - int w, - BC_Pixmap *src, - BC_Pixmap *dst) +void BC_WindowBase::draw_3segmenth(int x, int y, int w, BC_Pixmap *src, BC_Pixmap *dst) { if(w <= 0) return; int third_image = src->get_w() / 3; @@ -1627,61 +1289,23 @@ void BC_WindowBase::draw_3segmenth(int x, //printf("BC_WindowBase::draw_3segment 2 left_out_x=%d left_out_w=%d center_out_x=%d center_out_w=%d right_out_x=%d right_out_w=%d\n", // left_out_x, left_out_w, center_out_x, center_out_w, right_out_x, right_out_w); if(left_out_w > 0) - { - draw_pixmap(src, - left_out_x, - y, - left_out_w, - src->get_h(), - left_in_x, - 0, - dst); - } + draw_pixmap(src, left_out_x, y, left_out_w, src->get_h(), left_in_x, 0, dst); if(right_out_w > 0) - { - draw_pixmap(src, - right_out_x, - y, - right_out_w, - src->get_h(), - right_in_x, - 0, - dst); - } + draw_pixmap(src, right_out_x, y, right_out_w, src->get_h(), right_in_x, 0, dst); - for(int pixel = left_out_x + left_out_w; - pixel < right_out_x; - pixel += third_image) - { + for(int pixel = left_out_x + left_out_w; pixel < right_out_x; pixel += third_image) { int fragment_w = third_image; if(fragment_w + pixel > right_out_x) fragment_w = right_out_x - pixel; //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w); - draw_pixmap(src, - pixel, - y, - fragment_w, - src->get_h(), - third_image, - 0, - dst); + draw_pixmap(src, pixel, y, fragment_w, src->get_h(), third_image, 0, dst); } } - - - - - - -void BC_WindowBase::draw_3segmentv(int x, - int y, - int h, - VFrame *src, - BC_Pixmap *dst) +void BC_WindowBase::draw_3segmentv(int x, int y, int h, VFrame *src, BC_Pixmap *dst) { if(h <= 0) return; int third_image = src->get_h() / 3; @@ -1724,40 +1348,21 @@ void BC_WindowBase::draw_3segmentv(int x, get_color_model(), 0); temp_bitmap->read_frame(src, - 0, - 0, - src->get_w(), - src->get_h()); + 0, 0, src->get_w(), src->get_h(), bg_color); if(left_out_h > 0) { - draw_bitmap(temp_bitmap, - 0, - x, - left_out_y, - src->get_w(), - left_out_h, - 0, - left_in_y, - -1, - -1, - dst); + draw_bitmap(temp_bitmap, 0, x, left_out_y, + src->get_w(), left_out_h, 0, left_in_y, + -1, -1, dst); } if(right_out_h > 0) { - draw_bitmap(temp_bitmap, - 0, - x, - right_out_y, - src->get_w(), - right_out_h, - 0, - right_in_y, - -1, - -1, - dst); + draw_bitmap(temp_bitmap, 0, x, right_out_y, + src->get_w(), right_out_h, 0, right_in_y, + -1, -1, dst); } for(int pixel = left_out_y + left_out_h; @@ -1769,17 +1374,9 @@ void BC_WindowBase::draw_3segmentv(int x, fragment_h = right_out_y - pixel; //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w); - draw_bitmap(temp_bitmap, - 0, - x, - pixel, - src->get_w(), - fragment_h, - 0, - third_image, - -1, - -1, - dst); + draw_bitmap(temp_bitmap, 0, x, pixel, + src->get_w(), fragment_h, 0, third_image, + -1, -1, dst); } } @@ -1820,56 +1417,27 @@ void BC_WindowBase::draw_3segmentv(int x, } if(left_out_h > 0) - { - draw_pixmap(src, - x, - left_out_y, - src->get_w(), - left_out_h, - 0, - left_in_y, - dst); - } + draw_pixmap(src, x, left_out_y, src->get_w(), left_out_h, + 0, left_in_y, dst); if(right_out_h > 0) - { - draw_pixmap(src, - x, - right_out_y, - src->get_w(), - right_out_h, - 0, - right_in_y, - dst); - } + draw_pixmap(src, x, right_out_y, src->get_w(), right_out_h, + 0, right_in_y, dst); - for(int pixel = left_out_y + left_out_h; - pixel < right_out_y; - pixel += third_image) - { + for(int pixel = left_out_y + left_out_h; pixel < right_out_y; pixel += third_image) { int fragment_h = third_image; if(fragment_h + pixel > right_out_y) fragment_h = right_out_y - pixel; //printf("BC_WindowBase::draw_3segment 2 pixel=%d fragment_w=%d\n", pixel, fragment_w); - draw_pixmap(src, - x, - pixel, - src->get_w(), - fragment_h, - 0, - third_image, - dst); + draw_pixmap(src, x, pixel, src->get_w(), fragment_h, + 0, third_image, dst); } } -void BC_WindowBase::draw_9segment(int x, - int y, - int w, - int h, - BC_Pixmap *src, - BC_Pixmap *dst) +void BC_WindowBase::draw_9segment(int x, int y, int w, int h, + BC_Pixmap *src, BC_Pixmap *dst) { if(w <= 0 || h <= 0) return; @@ -1898,48 +1466,21 @@ void BC_WindowBase::draw_9segment(int x, //int in_y4 = src->get_h(); // Segment 1 - draw_pixmap(src, - x + out_x1, - y + out_y1, - out_x2 - out_x1, - out_y2 - out_y1, - in_x1, - in_y1, - dst); - + draw_pixmap(src, x + out_x1, y + out_y1, out_x2 - out_x1, out_y2 - out_y1, + in_x1, in_y1, dst); // Segment 2 * n - for(int i = out_x2; i < out_x3; i += in_x3 - in_x2) - { - if(out_x3 - i > 0) - { + for(int i = out_x2; i < out_x3; i += in_x3 - in_x2) { + if(out_x3 - i > 0) { int w = MIN(in_x3 - in_x2, out_x3 - i); - draw_pixmap(src, - x + i, - y + out_y1, - w, - out_y2 - out_y1, - in_x2, - in_y1, - dst); + draw_pixmap(src, x + i, y + out_y1, w, out_y2 - out_y1, + in_x2, in_y1, dst); } } - - - - // Segment 3 - draw_pixmap(src, - x + out_x3, - y + out_y1, - out_x4 - out_x3, - out_y2 - out_y1, - in_x3, - in_y1, - dst); - - + draw_pixmap(src, x + out_x3, y + out_y1, out_x4 - out_x3, out_y2 - out_y1, + in_x3, in_y1, dst); // Segment 4 * n for(int i = out_y2; i < out_y3; i += in_y3 - in_y2) @@ -1947,18 +1488,11 @@ void BC_WindowBase::draw_9segment(int x, if(out_y3 - i > 0) { int h = MIN(in_y3 - in_y2, out_y3 - i); - draw_pixmap(src, - x + out_x1, - y + i, - out_x2 - out_x1, - h, - in_x1, - in_y2, - dst); + draw_pixmap(src, x + out_x1, y + i, out_x2 - out_x1, h, + in_x1, in_y2, dst); } } - // Segment 5 * n * n for(int i = out_y2; i < out_y3; i += in_y3 - in_y2 /* in_y_third */) { @@ -1971,14 +1505,8 @@ void BC_WindowBase::draw_9segment(int x, { int w = MIN(in_x3 - in_x2 /* in_x_third */, out_x3 - j); if(out_x3 - j > 0) - draw_pixmap(src, - x + j, - y + i, - w, - h, - in_x2, - in_y2, - dst); + draw_pixmap(src, x + j, y + i, w, h, + in_x2, in_y2, dst); } } } @@ -1989,30 +1517,14 @@ void BC_WindowBase::draw_9segment(int x, if(out_y3 - i > 0) { int h = MIN(in_y3 - in_y2, out_y3 - i); - draw_pixmap(src, - x + out_x3, - y + i, - out_x4 - out_x3, - h, - in_x3, - in_y2, - dst); + draw_pixmap(src, x + out_x3, y + i, out_x4 - out_x3, h, + in_x3, in_y2, dst); } } - - - // Segment 7 - draw_pixmap(src, - x + out_x1, - y + out_y3, - out_x2 - out_x1, - out_y4 - out_y3, - in_x1, - in_y3, - dst); - + draw_pixmap(src, x + out_x1, y + out_y3, out_x2 - out_x1, out_y4 - out_y3, + in_x1, in_y3, dst); // Segment 8 * n for(int i = out_x2; i < out_x3; i += in_x3 - in_x2) @@ -2020,37 +1532,19 @@ void BC_WindowBase::draw_9segment(int x, if(out_x3 - i > 0) { int w = MIN(in_x3 - in_y2, out_x3 - i); - draw_pixmap(src, - x + i, - y + out_y3, - w, - out_y4 - out_y3, - in_x2, - in_y3, - dst); + draw_pixmap(src, x + i, y + out_y3, w, out_y4 - out_y3, + in_x2, in_y3, dst); } } - - // Segment 9 - draw_pixmap(src, - x + out_x3, - y + out_y3, - out_x4 - out_x3, - out_y4 - out_y3, - in_x3, - in_y3, - dst); + draw_pixmap(src, x + out_x3, y + out_y3, out_x4 - out_x3, out_y4 - out_y3, + in_x3, in_y3, dst); } -void BC_WindowBase::draw_9segment(int x, - int y, - int w, - int h, - VFrame *src, - BC_Pixmap *dst) +void BC_WindowBase::draw_9segment(int x, int y, int w, int h, + VFrame *src, BC_Pixmap *dst) { if(w <= 0 || h <= 0) return; @@ -2092,190 +1586,90 @@ void BC_WindowBase::draw_9segment(int x, get_color_model(), 0); temp_bitmap->read_frame(src, - 0, - 0, - src->get_w(), - src->get_h()); + 0, 0, src->get_w(), src->get_h(), bg_color); // Segment 1 - draw_bitmap(temp_bitmap, - 0, - x + out_x1, - y + out_y1, - out_x2 - out_x1, - out_y2 - out_y1, - in_x1, - in_y1, - in_x2 - in_x1, - in_y2 - in_y1, + draw_bitmap(temp_bitmap, 0, + x + out_x1, y + out_y1, out_x2 - out_x1, out_y2 - out_y1, + in_x1, in_y1, in_x2 - in_x1, in_y2 - in_y1, dst); - // Segment 2 * n - for(int i = out_x2; i < out_x3; i += in_x3 - in_x2) - { - if(out_x3 - i > 0) - { + for( int i = out_x2; i < out_x3; i += in_x3 - in_x2 ) { + if( out_x3 - i > 0 ) { int w = MIN(in_x3 - in_x2, out_x3 - i); - draw_bitmap(temp_bitmap, - 0, - x + i, - y + out_y1, - w, - out_y2 - out_y1, - in_x2, - in_y1, - w, - in_y2 - in_y1, + draw_bitmap(temp_bitmap, 0, + x + i, y + out_y1, w, out_y2 - out_y1, + in_x2, in_y1, w, in_y2 - in_y1, dst); } } - - - - // Segment 3 - draw_bitmap(temp_bitmap, - 0, - x + out_x3, - y + out_y1, - out_x4 - out_x3, - out_y2 - out_y1, - in_x3, - in_y1, - in_x4 - in_x3, - in_y2 - in_y1, + draw_bitmap(temp_bitmap, 0, + x + out_x3, y + out_y1, out_x4 - out_x3, out_y2 - out_y1, + in_x3, in_y1, in_x4 - in_x3, in_y2 - in_y1, dst); - - // Segment 4 * n - for(int i = out_y2; i < out_y3; i += in_y3 - in_y2) - { - if(out_y3 - i > 0) - { + for( int i = out_y2; i < out_y3; i += in_y3 - in_y2 ) { + if( out_y3 - i > 0 ) { int h = MIN(in_y3 - in_y2, out_y3 - i); - draw_bitmap(temp_bitmap, - 0, - x + out_x1, - y + i, - out_x2 - out_x1, - h, - in_x1, - in_y2, - in_x2 - in_x1, - h, + draw_bitmap(temp_bitmap, 0, + x + out_x1, y + i, out_x2 - out_x1, h, + in_x1, in_y2, in_x2 - in_x1, h, dst); } } - // Segment 5 * n * n - for(int i = out_y2; i < out_y3; i += in_y3 - in_y2) - { - if(out_y3 - i > 0) - { + for( int i = out_y2; i < out_y3; i += in_y3 - in_y2 ) { + if( out_y3 - i > 0 ) { int h = MIN(in_y3 - in_y2, out_y3 - i); - - for(int j = out_x2; j < out_x3; j += in_x3 - in_x2) - { + for( int j = out_x2; j < out_x3; j += in_x3 - in_x2 ) { int w = MIN(in_x3 - in_x2, out_x3 - j); if(out_x3 - j > 0) - draw_bitmap(temp_bitmap, - 0, - x + j, - y + i, - w, - h, - in_x2, - in_y2, - w, - h, + draw_bitmap(temp_bitmap, 0, + x + j, y + i, w, h, + in_x2, in_y2, w, h, dst); } } } // Segment 6 * n - for(int i = out_y2; i < out_y3; i += in_y_third) - { - if(out_y3 - i > 0) - { + for( int i = out_y2; i < out_y3; i += in_y_third ) { + if( out_y3 - i > 0 ) { int h = MIN(in_y_third, out_y3 - i); - draw_bitmap(temp_bitmap, - 0, - x + out_x3, - y + i, - out_x4 - out_x3, - h, - in_x3, - in_y2, - in_x4 - in_x3, - h, + draw_bitmap(temp_bitmap, 0, + x + out_x3, y + i, out_x4 - out_x3, h, + in_x3, in_y2, in_x4 - in_x3, h, dst); } } - - - // Segment 7 - draw_bitmap(temp_bitmap, - 0, - x + out_x1, - y + out_y3, - out_x2 - out_x1, - out_y4 - out_y3, - in_x1, - in_y3, - in_x2 - in_x1, - in_y4 - in_y3, + draw_bitmap(temp_bitmap, 0, + x + out_x1, y + out_y3, out_x2 - out_x1, out_y4 - out_y3, + in_x1, in_y3, in_x2 - in_x1, in_y4 - in_y3, dst); - // Segment 8 * n - for(int i = out_x2; i < out_x3; i += in_x_third) - { - if(out_x3 - i > 0) - { + for( int i = out_x2; i < out_x3; i += in_x_third ) { + if( out_x3 - i > 0 ) { int w = MIN(in_x_third, out_x3 - i); - draw_bitmap(temp_bitmap, - 0, - x + i, - y + out_y3, - w, - out_y4 - out_y3, - in_x2, - in_y3, - w, - in_y4 - in_y3, + draw_bitmap(temp_bitmap, 0, + x + i, y + out_y3, w, out_y4 - out_y3, + in_x2, in_y3, w, in_y4 - in_y3, dst); } } - - // Segment 9 - draw_bitmap(temp_bitmap, - 0, - x + out_x3, - y + out_y3, - out_x4 - out_x3, - out_y4 - out_y3, - in_x3, - in_y3, - in_x4 - in_x3, - in_y4 - in_y3, + draw_bitmap(temp_bitmap, 0, + x + out_x3, y + out_y3, out_x4 - out_x3, out_y4 - out_y3, + in_x3, in_y3, in_x4 - in_x3, in_y4 - in_y3, dst); } - - - - - - - -