From 8d940f3581b2d030926a9541165622af41c025d4 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sat, 26 Apr 2025 17:55:43 +0200 Subject: [PATCH] Put fix for issue #1214 (Windows "solid lines") under ABI guards Original issue title: "Windows: dotted lines may be drawn solid when GUI is rescaled" Unfortunately commit 880636eb120d18a2197b35839105a1aed5c71111 broke the ABI because it added a variable to a public header. This commit uses ABI guards '#if FL_ABI_VERSION >= 10403" for the same fix. Note: The full fix w/o ABI guards is already available in FLTK 1.5. --- FL/Fl_Graphics_Driver.H | 4 +++- src/Fl_Graphics_Driver.cxx | 14 +++++++++++++- src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 7 ++++++- src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx | 7 ++++++- .../GDI/Fl_GDI_Graphics_Driver_line_style.cxx | 7 ++++++- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/FL/Fl_Graphics_Driver.H b/FL/Fl_Graphics_Driver.H index 4b5578f15..1059e12b0 100644 --- a/FL/Fl_Graphics_Driver.H +++ b/FL/Fl_Graphics_Driver.H @@ -2,7 +2,7 @@ // Declaration of classes Fl_Graphics_Driver, Fl_Scalable_Graphics_Driver, // and Fl_Font_Descriptor for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2024 by Bill Spitzak and others. +// Copyright 2010-2025 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -430,7 +430,9 @@ public: inline int floor(int x) { return Fl_Scalable_Graphics_Driver::floor(x, scale()); } protected: int line_width_; +#if FL_ABI_VERSION >= 10403 // Issue #1214 bool is_solid_; +#endif virtual Fl_Region scale_clip(float f); void unscale_clip(Fl_Region r); void point(int x, int y) FL_OVERRIDE; diff --git a/src/Fl_Graphics_Driver.cxx b/src/Fl_Graphics_Driver.cxx index 9ef46f9f3..494d6333c 100644 --- a/src/Fl_Graphics_Driver.cxx +++ b/src/Fl_Graphics_Driver.cxx @@ -1,7 +1,7 @@ // // Fl_Graphics_Driver class for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2023 by Bill Spitzak and others. +// Copyright 2010-2025 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -800,7 +800,9 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize Size) { Fl_Scalable_Graphics_Driver::Fl_Scalable_Graphics_Driver() : Fl_Graphics_Driver() { line_width_ = 0; fontsize_ = -1; +#if FL_ABI_VERSION >= 10403 // Issue #1214 is_solid_ = true; +#endif } void Fl_Scalable_Graphics_Driver::rect(int x, int y, int w, int h) @@ -851,7 +853,11 @@ void Fl_Scalable_Graphics_Driver::xyline(int x, int y, int x1) { int xx1 = (x < x1 ? x1 : x); if (s != s_int && line_width_ <= s_int) { int lwidth = this->floor((y+1)) - this->floor(y); +#if FL_ABI_VERSION >= 10403 // Issue #1214 bool need_change_width = (lwidth != s_int && is_solid_); +#else + bool need_change_width = (lwidth != s_int); +#endif void *data = NULL; if (need_change_width) data = change_pen_width(lwidth); xyline_unscaled(this->floor(xx), this->floor(y) + int(lwidth/2.f), this->floor(xx1+1)-1); @@ -871,7 +877,11 @@ void Fl_Scalable_Graphics_Driver::yxline(int x, int y, int y1) { int yy1 = (y < y1 ? y1 : y); if (s != s_int && line_width_ <= s_int) { int lwidth = (this->floor((x+1)) - this->floor(x)); +#if FL_ABI_VERSION >= 10403 // Issue #1214 bool need_change_width = (lwidth != s_int && is_solid_); +#else + bool need_change_width = (lwidth != s_int); +#endif void *data = NULL; if (need_change_width) data = change_pen_width(lwidth); yxline_unscaled(this->floor(x) + int(lwidth/2.f), this->floor(yy), this->floor(yy1+1) - 1); @@ -1051,7 +1061,9 @@ void Fl_Scalable_Graphics_Driver::draw_circle(int x0, int y0, int d, Fl_Color c) void Fl_Scalable_Graphics_Driver::line_style(int style, int width, char* dashes) { if (width == 0) line_width_ = int(scale() < 2 ? 0 : scale()); else line_width_ = int(width>0 ? width*scale() : -width*scale()); +#if FL_ABI_VERSION >= 10403 // Issue #1214 is_solid_ = ((style & 0xff) == FL_SOLID && (!dashes || !*dashes)); +#endif line_style_unscaled(style, line_width_, dashes); } diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H index 01ecf9531..1f33b0b4c 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H @@ -2,7 +2,7 @@ // Definition of classes Fl_Graphics_Driver, Fl_Surface_Device, Fl_Display_Device // for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2023 by Bill Spitzak and others. +// Copyright 2010-2025 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -60,6 +60,11 @@ protected: uchar *mask_bitmap_; uchar **mask_bitmap() FL_OVERRIDE {return &mask_bitmap_;} POINT *long_point; +#if FL_ABI_VERSION >= 10403 // Issue #1214 + // empty +#else + bool is_solid_; +#endif int style_; public: Fl_GDI_Graphics_Driver(); diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx index 97b3244d1..b7e07f115 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx @@ -1,7 +1,7 @@ // // Rectangle drawing routines for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2022 by Bill Spitzak and others. +// Copyright 1998-2025 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -96,6 +96,11 @@ Fl_GDI_Graphics_Driver::Fl_GDI_Graphics_Driver() { long_point = NULL; depth = -1; origins = NULL; +#if FL_ABI_VERSION >= 10403 // Issue #1214 + // empty +#else + is_solid_ = true; +#endif style_ = FL_SOLID; } diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx index 9d086f353..bd2f0cf4e 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx @@ -1,7 +1,7 @@ // // Line style code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2018 by Bill Spitzak and others. +// Copyright 1998-2025 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -58,6 +58,11 @@ void Fl_GDI_Graphics_Driver::line_style_unscaled(int style, int width, char* das DeleteObject(oldpen); DeleteObject(fl_current_xmap->pen); fl_current_xmap->pen = newpen; +#if FL_ABI_VERSION >= 10403 // Issue #1214 + // empty +#else + is_solid_ = ((style & 0xff) == FL_SOLID && (!dashes || !*dashes)); +#endif style_ = style; }