diff options
| author | Manolo Gouy <Manolo> | 2018-04-19 10:39:46 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2018-04-19 10:39:46 +0000 |
| commit | 54b697cd49d3946ecd1f264c0741f36568822819 (patch) | |
| tree | 399901a93956b7558be6d5e77ba62cb93ee7141d /src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx | |
| parent | d375918a5ea3210d0d148ec215f1494cbfbd927e (diff) | |
Reorganise access to the value of the GUI scaling factor with public getter and protected, virtual setter member functions.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12858 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx')
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx index 7ba5490b5..1d6e2752f 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx @@ -214,8 +214,8 @@ void Fl_Xlib_Graphics_Driver::XDestroyRegion(Fl_Region r) { // called only when scale_ has integer value void Fl_Xlib_Graphics_Driver::rect_unscaled(float fx, float fy, float fw, float fh) { if (fw<=0 || fh<=0) return; - int deltaf = scale_ >= 2 ? scale_-1 : 0; - fx += offset_x_*scale_; fy += offset_y_*scale_; + int deltaf = scale() >= 2 ? scale()-1 : 0; + fx += offset_x_*scale(); fy += offset_y_*scale(); int x = fx; int y = fy; int w = int(fw) - 1 - deltaf; int h = int(fh) - 1 - deltaf; @@ -225,21 +225,21 @@ void Fl_Xlib_Graphics_Driver::rect_unscaled(float fx, float fy, float fw, float void Fl_Xlib_Graphics_Driver::rectf_unscaled(float fx, float fy, float fw, float fh) { if (fw<=0 || fh<=0) return; - int deltaf = scale_ >= 2 ? scale_/2 : 0; - fx += offset_x_*scale_; fy += offset_y_*scale_; + int deltaf = scale() >= 2 ? scale()/2 : 0; + fx += offset_x_*scale(); fy += offset_y_*scale(); int x = fx-deltaf; int y = fy-deltaf; // make sure no unfilled area lies between rectf(x,y,w,h) and rectf(x+w,y,1,h) or rectf(x,y+w,w,1) - int w = int(int(fx/scale_+fw/scale_+0.5)*scale_) - int(fx); - int h = int(int(fy/scale_+fh/scale_+0.5)*scale_) - int(fy); + int w = int(int(fx/scale()+fw/scale()+0.5)*scale()) - int(fx); + int h = int(int(fy/scale()+fh/scale()+0.5)*scale()) - int(fy); if (!clip_rect(x, y, w, h)) XFillRectangle(fl_display, fl_window, gc_, x+line_delta_, y+line_delta_, w, h); } void Fl_Xlib_Graphics_Driver::point_unscaled(float fx, float fy) { - int deltaf = scale_ >= 2 ? scale_/2 : 0; - int x = fx+offset_x_*scale_-deltaf; - int y = fy+offset_y_*scale_-deltaf; - int width = scale_ >= 1 ? scale_ : 1; + int deltaf = scale() >= 2 ? scale()/2 : 0; + int x = fx+offset_x_*scale()-deltaf; + int y = fy+offset_y_*scale()-deltaf; + int width = scale() >= 1 ? scale() : 1; // *FIXME* This needs X coordinate clipping: XFillRectangle(fl_display, fl_window, gc_, x+line_delta_, y+line_delta_, width, width); } @@ -247,75 +247,75 @@ void Fl_Xlib_Graphics_Driver::point_unscaled(float fx, float fy) { void Fl_Xlib_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1) { if (x == x1) yxline_unscaled(x, y, y1); else if (y == y1) xyline_unscaled(x, y, x1); - else draw_clipped_line(x+offset_x_*scale_+line_delta_, y+offset_y_*scale_+line_delta_, x1+offset_x_*scale_+line_delta_, y1+offset_y_*scale_+line_delta_); + else draw_clipped_line(x+offset_x_*scale()+line_delta_, y+offset_y_*scale()+line_delta_, x1+offset_x_*scale()+line_delta_, y1+offset_y_*scale()+line_delta_); } void Fl_Xlib_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1, float x2, float y2) { XPoint p[3]; - p[0].x = x+offset_x_*scale_+line_delta_; p[0].y = y+offset_y_*scale_+line_delta_; - p[1].x = x1+offset_x_*scale_+line_delta_; p[1].y = y1+offset_y_*scale_+line_delta_; - p[2].x = x2+offset_x_*scale_+line_delta_; p[2].y = y2+offset_y_*scale_+line_delta_; + p[0].x = x+offset_x_*scale()+line_delta_; p[0].y = y+offset_y_*scale()+line_delta_; + p[1].x = x1+offset_x_*scale()+line_delta_; p[1].y = y1+offset_y_*scale()+line_delta_; + p[2].x = x2+offset_x_*scale()+line_delta_; p[2].y = y2+offset_y_*scale()+line_delta_; // *FIXME* This needs X coordinate clipping! XDrawLines(fl_display, fl_window, gc_, p, 3, 0); } void Fl_Xlib_Graphics_Driver::xyline_unscaled(float x, float y, float x1) { - x+=offset_x_*scale_; y+=offset_y_*scale_; x1 += offset_x_*scale_; + x+=offset_x_*scale(); y+=offset_y_*scale(); x1 += offset_x_*scale(); int tw = line_width_ ? line_width_ : 1; // true line width if (x > x1) { float exch = x; x = x1; x1 = exch; } - int ix = clip_xy(x+line_delta_); if (scale_ >= 2) ix -= int(scale_/2); + int ix = clip_xy(x+line_delta_); if (scale() >= 2) ix -= int(scale()/2); int iy = clip_xy(y+line_delta_); // make sure that line output by xyline(a,b,c) extends to pixel just at left of where xyline(c+1,b,d) begins - int ix1 = int(x1/scale_+1.5)*scale_-1; - ix1 += line_delta_; if (scale_ >= 4) ix1 -= 1; + int ix1 = int(x1/scale()+1.5)*scale()-1; + ix1 += line_delta_; if (scale() >= 4) ix1 -= 1; draw_clipped_line(ix, iy, ix1, iy); // make sure no unfilled area lies between xyline(x,y,x1) and xyline(x,y+1,x1) - if (y+line_delta_ + scale_ >= iy + tw+1 - 0.001 ) + if (y+line_delta_ + scale() >= iy + tw+1 - 0.001 ) draw_clipped_line(ix, iy+1, ix1, iy+1); } void Fl_Xlib_Graphics_Driver::yxline_unscaled(float x, float y, float y1) { - x+=offset_x_*scale_; y+=offset_y_*scale_; y1 += offset_y_*scale_; + x+=offset_x_*scale(); y+=offset_y_*scale(); y1 += offset_y_*scale(); int tw = line_width_ ? line_width_ : 1; // true line width if (y > y1) { float exch = y; y = y1; y1 = exch; } int ix = clip_xy(x+line_delta_); - int iy = clip_xy(y+line_delta_); if (scale_ >= 2) iy -= int(scale_/2); - int iy1 = int(y1/scale_+1.5)*scale_-1; + int iy = clip_xy(y+line_delta_); if (scale() >= 2) iy -= int(scale()/2); + int iy1 = int(y1/scale()+1.5)*scale()-1; // make sure that line output by yxline(a,b,c) extends to pixel just above where yxline(a,c+1,d) begins - iy1 += line_delta_; if (scale_ >= 4) iy1 -= 1; + iy1 += line_delta_; if (scale() >= 4) iy1 -= 1; draw_clipped_line(ix, iy, ix, iy1); // make sure no unfilled area lies between yxline(x,y,y1) and yxline(x+1,y,y1) - if (x+line_delta_+scale_ >= ix + tw+1 -0.001) + if (x+line_delta_+scale() >= ix + tw+1 -0.001) draw_clipped_line(ix+1, iy, ix+1, iy1); } void Fl_Xlib_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2) { XPoint p[4]; - p[0].x = x +offset_x_*scale_+line_delta_; p[0].y = y +offset_y_*scale_+line_delta_; - p[1].x = x1 +offset_x_*scale_+line_delta_; p[1].y = y1 +offset_y_*scale_+line_delta_; - p[2].x = x2 +offset_x_*scale_+line_delta_; p[2].y = y2 +offset_y_*scale_+line_delta_; - p[3].x = x +offset_x_*scale_+line_delta_; p[3].y = y +offset_y_*scale_+line_delta_; + p[0].x = x +offset_x_*scale()+line_delta_; p[0].y = y +offset_y_*scale()+line_delta_; + p[1].x = x1 +offset_x_*scale()+line_delta_; p[1].y = y1 +offset_y_*scale()+line_delta_; + p[2].x = x2 +offset_x_*scale()+line_delta_; p[2].y = y2 +offset_y_*scale()+line_delta_; + p[3].x = x +offset_x_*scale()+line_delta_; p[3].y = y +offset_y_*scale()+line_delta_; // *FIXME* This needs X coordinate clipping! XDrawLines(fl_display, fl_window, gc_, p, 4, 0); } void Fl_Xlib_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3) { XPoint p[5]; - p[0].x = x+offset_x_*scale_+line_delta_; p[0].y = y+offset_y_*scale_+line_delta_; - p[1].x = x1 +offset_x_*scale_+line_delta_; p[1].y = y1+offset_y_*scale_+line_delta_; - p[2].x = x2+offset_x_*scale_+line_delta_; p[2].y = y2+offset_y_*scale_+line_delta_; - p[3].x = x3+offset_x_*scale_+line_delta_; p[3].y = y3+offset_y_*scale_+line_delta_; - p[4].x = x+offset_x_*scale_+line_delta_; p[4].y = y+offset_y_*scale_+line_delta_; + p[0].x = x+offset_x_*scale()+line_delta_; p[0].y = y+offset_y_*scale()+line_delta_; + p[1].x = x1 +offset_x_*scale()+line_delta_; p[1].y = y1+offset_y_*scale()+line_delta_; + p[2].x = x2+offset_x_*scale()+line_delta_; p[2].y = y2+offset_y_*scale()+line_delta_; + p[3].x = x3+offset_x_*scale()+line_delta_; p[3].y = y3+offset_y_*scale()+line_delta_; + p[4].x = x+offset_x_*scale()+line_delta_; p[4].y = y+offset_y_*scale()+line_delta_; // *FIXME* This needs X coordinate clipping! XDrawLines(fl_display, fl_window, gc_, p, 5, 0); } void Fl_Xlib_Graphics_Driver::polygon_unscaled(float x, float y, float x1, float y1, float x2, float y2) { XPoint p[4]; - p[0].x = x+offset_x_*scale_+line_delta_; p[0].y = y+offset_y_*scale_+line_delta_; - p[1].x = x1+offset_x_*scale_+line_delta_; p[1].y = y1+offset_y_*scale_+line_delta_; - p[2].x = x2+offset_x_*scale_+line_delta_; p[2].y = y2+offset_y_*scale_+line_delta_; - p[3].x = x+offset_x_*scale_+line_delta_; p[3].y = y+offset_y_*scale_+line_delta_; + p[0].x = x+offset_x_*scale()+line_delta_; p[0].y = y+offset_y_*scale()+line_delta_; + p[1].x = x1+offset_x_*scale()+line_delta_; p[1].y = y1+offset_y_*scale()+line_delta_; + p[2].x = x2+offset_x_*scale()+line_delta_; p[2].y = y2+offset_y_*scale()+line_delta_; + p[3].x = x+offset_x_*scale()+line_delta_; p[3].y = y+offset_y_*scale()+line_delta_; // *FIXME* This needs X coordinate clipping! XFillPolygon(fl_display, fl_window, gc_, p, 3, Convex, 0); XDrawLines(fl_display, fl_window, gc_, p, 4, 0); @@ -323,11 +323,11 @@ void Fl_Xlib_Graphics_Driver::polygon_unscaled(float x, float y, float x1, float void Fl_Xlib_Graphics_Driver::polygon_unscaled(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3) { XPoint p[5]; - p[0].x = x+offset_x_*scale_+line_delta_; p[0].y = y+offset_y_*scale_+line_delta_; - p[1].x = x1+offset_x_*scale_+line_delta_; p[1].y = y1+offset_y_*scale_+line_delta_; - p[2].x = x2+offset_x_*scale_+line_delta_; p[2].y = y2+offset_y_*scale_+line_delta_; - p[3].x = x3+offset_x_*scale_+line_delta_; p[3].y = y3+offset_y_*scale_+line_delta_; - p[4].x = x+offset_x_*scale_+line_delta_; p[4].y = y+offset_y_*scale_+line_delta_; + p[0].x = x+offset_x_*scale()+line_delta_; p[0].y = y+offset_y_*scale()+line_delta_; + p[1].x = x1+offset_x_*scale()+line_delta_; p[1].y = y1+offset_y_*scale()+line_delta_; + p[2].x = x2+offset_x_*scale()+line_delta_; p[2].y = y2+offset_y_*scale()+line_delta_; + p[3].x = x3+offset_x_*scale()+line_delta_; p[3].y = y3+offset_y_*scale()+line_delta_; + p[4].x = x+offset_x_*scale()+line_delta_; p[4].y = y+offset_y_*scale()+line_delta_; // *FIXME* This needs X coordinate clipping! XFillPolygon(fl_display, fl_window, gc_, p, 4, Convex, 0); XDrawLines(fl_display, fl_window, gc_, p, 5, 0); @@ -418,7 +418,7 @@ void Fl_Xlib_Graphics_Driver::restore_clip() { if (gc_) { Region r = rstack[rstackptr]; if (r) { - Region r2 = scale_clip(scale_); + Region r2 = scale_clip(scale()); XSetRegion(fl_display, gc_, rstack[rstackptr]); unscale_clip(r2); } |
