|
commit 67bb631bd9d3b32e83fabe254a7a413034a13a96
Author: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Nov 30 18:50:11 2020 +0100
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Nov 30 18:50:19 2020 +0100
Scaling for Windows and X11: support rectangular loops.
src/Fl_Graphics_Driver.cxx | 18 +++++++++++++++++-
src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 3 +--
src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx | 22 +++++++++-------------
3 files changed, 27 insertions(+), 16 deletions(-)
diff --git src/Fl_Graphics_Driver.cxx src/Fl_Graphics_Driver.cxx
index d0b9bf3..e156ae2 100644
--- src/Fl_Graphics_Driver.cxx
+++ 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 src/drivers/GDI/Fl_GDI_Graphics_Driver.H src/drivers/GDI/Fl_GDI_Graphics_Driver.H
index 36750f7..01014f4 100644
--- src/drivers/GDI/Fl_GDI_Graphics_Driver.H
+++ 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 src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx
index 6bb526b..fba77eb 100644
--- src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx
+++ 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);
[ Direct Link to Message ] | |