diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2020-11-30 18:50:11 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2020-11-30 18:50:19 +0100 |
| commit | 67bb631bd9d3b32e83fabe254a7a413034a13a96 (patch) | |
| tree | 2a2c419cef687c1d0e8915d30351861fe45468ad | |
| parent | ff372c86d8ef225ce87d1ff5539f2000e1849250 (diff) | |
Scaling for Windows and X11: support rectangular loops.
| -rw-r--r-- | src/Fl_Graphics_Driver.cxx | 18 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 3 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx | 22 |
3 files changed, 27 insertions, 16 deletions
diff --git a/src/Fl_Graphics_Driver.cxx b/src/Fl_Graphics_Driver.cxx index d0b9bf370..e156ae2c4 100644 --- a/src/Fl_Graphics_Driver.cxx +++ b/src/Fl_Graphics_Driver.cxx @@ -713,7 +713,23 @@ void Fl_Scalable_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, i } void Fl_Scalable_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) { - loop_unscaled(x0*scale(), y0*scale(), x1*scale(), y1*scale(), x2*scale(), y2*scale(), x3*scale(), y3*scale()); + int X, Y, W, H; + if (x0 == x3 && x1 == x2 && y0 == y1 && y3 == y2) { // rectangular loop + X = x0 > x1 ? x1 : x0; + Y = y0 > y3 ? y3 : y0; + W = abs(x0 - x1); + H = abs(y0 - y3); + rect(X, Y, W + 1, H + 1); + } else if (x0 == x1 && y1 == y2 && x2 == x3 && y3 == y0) { // rectangular loop also + X = x0 > x3 ? x3 : x0; + Y = y0 > y1 ? y1 : y0; + W = abs(x0 - x3); + H = abs(y0 - y1); + rect(X, Y, W + 1, H + 1); + } else { + float s = scale(); + loop_unscaled(x0*s, y0*s, x1*s, y1*s, x2*s, y2*s, x3*s, y3*s); + } } void Fl_Scalable_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2) { diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H index 36750f7d7..01014f49b 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H @@ -96,9 +96,8 @@ public: protected: void transformed_vertex0(float x, float y); void fixloop(); - // --- implementation is in src/fl_rect.cxx which includes src/cfg_gfx/gdi_rect.cxx virtual void point_unscaled(float x, float y); - void rect_unscaled(float x, float y, float w, float h); + virtual void rect(int x, int y, int w, int h); void focus_rect(int x, int y, int w, int h); void rectf_unscaled(float x, float y, float w, float h); virtual void line_unscaled(float x, float y, float x1, float y1); diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx index 6bb526b6c..fba77eb17 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx @@ -46,16 +46,15 @@ void Fl_GDI_Graphics_Driver::overlay_rect(int x, int y, int w , int h) { loop(x, y, x+w-1, y, x+w-1, y+h-1, x, y+h-1); } -void Fl_GDI_Graphics_Driver::rect_unscaled(float x, float y, float w, float h) { - if (w<=0 || h<=0) return; - int line_delta_ = (scale() > 1.9 ? 1 : 0); - x += line_delta_; y += line_delta_; - int tw = line_width_ ? line_width_ : 1; // true line width - MoveToEx(gc_, x, y, 0L); - LineTo(gc_, x+w-tw, y); - LineTo(gc_, x+w-tw, y+h-tw); - LineTo(gc_, x, y+h-tw); - LineTo(gc_, x, y); +void Fl_GDI_Graphics_Driver::rect(int x, int y, int w, int h) +{ + if (w > 0 && h > 0) { + float s = scale(); + xyline_unscaled(x*s, y*s, (x+w-1)*s); + yxline_unscaled(x*s, y*s, (y+h-1)*s); + yxline_unscaled((x+w-1)*s, y*s, (y+h-1)*s); + xyline_unscaled(x*s, (y+h-1)*s, (x+w-1)*s); + } } void Fl_GDI_Graphics_Driver::focus_rect(int x, int y, int w, int h) { @@ -132,9 +131,6 @@ void Fl_GDI_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, } void Fl_GDI_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3) { - if (x==x3 && x1==x2 && y==y1 && y3==y2) { // rectangular loop - if (scale() > 1.9) { x += 1; y += 1; x1 += 1; y1 += 1; x2 += 1; y2 += 1; x3 += 1; y3 += 1;} - } MoveToEx(gc_, x, y, 0L); LineTo(gc_, x1, y1); LineTo(gc_, x2, y2); |
