diff options
| -rw-r--r-- | CHANGES.txt | 3 | ||||
| -rw-r--r-- | FL/Fl.H | 30 | ||||
| -rw-r--r-- | documentation/src/boxtypes.png | bin | 6758 -> 17302 bytes | |||
| -rw-r--r-- | src/fl_boxtype.cxx | 5 | ||||
| -rw-r--r-- | src/fl_oval_box.cxx | 10 | ||||
| -rw-r--r-- | src/fl_rounded_box.cxx | 10 | ||||
| -rw-r--r-- | src/fl_shadow_box.cxx | 5 | ||||
| -rw-r--r-- | test/boxtype.cxx | 6 |
8 files changed, 58 insertions, 11 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 97f0a2828..f25859da1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -18,6 +18,9 @@ Changes in FLTK 1.4.0 Released: ??? ?? 2020 New Features and Extensions - (add new items here) + - The border radius of "rounded" box types can be limited and + the shadow width of "shadow" box types can be configured (issue #130). + See Fl::box_border_radius_max() and Fl::box_shadow_width(). - New classes Fl_SVG_File_Surface and Fl_EPS_File_Surface to save any FLTK graphics to SVG or EPS files, respectively. - New fl_putenv() is a cross-platform putenv() wrapper (see docs). @@ -133,6 +133,8 @@ private: static int use_high_res_GL_; static int draw_GL_text_with_textures_; + static int box_shadow_width_; + static int box_border_radius_max_; public: @@ -141,6 +143,34 @@ public: static void reset_marked_text(); // resets marked text static void insertion_point_location(int x, int y, int height); // sets window coordinates & height of insertion point + /** Get the box shadow width of all "shadow" boxtypes in pixels. + \since 1.4.0 + */ + static int box_shadow_width() { return box_shadow_width_; } + /** Set the box shadow width of all "shadow" boxtypes in pixels. + Must be at least 1, default = 3. There is no upper limit. + \since 1.4.0 + */ + static void box_shadow_width(int W) { box_shadow_width_ = W < 1 ? 1 : W; } + + /** Get the maximum border radius of all "rounded" boxtypes in pixels. + \since 1.4.0 + */ + static int box_border_radius_max() { return box_border_radius_max_; } + /** Set the maximum border radius of all "rounded" boxtypes in pixels. + Must be at least 5, default = 15. + + \note This does \b not apply to the "round" boxtypes which have really round sides + (i.e. composed of half circles) as opposed to "rounded" boxtypes that have only + rounded corners with a straight border between corners. + + The box border radius of "rounded" boxtypes is typically calculated as about 2/5 of + the box height or width, whichever is smaller. The upper limit can be set by this + method for all "rounded" boxtypes. + \since 1.4.0 + */ + static void box_border_radius_max(int R) { box_border_radius_max_ = R < 5 ? 5 : R; } + public: // run time information about compile time configuration /** \defgroup cfg_gfx runtime graphics driver configuration */ /** @{ */ diff --git a/documentation/src/boxtypes.png b/documentation/src/boxtypes.png Binary files differindex a64ccaaee..8708f14c1 100644 --- a/documentation/src/boxtypes.png +++ b/documentation/src/boxtypes.png diff --git a/src/fl_boxtype.cxx b/src/fl_boxtype.cxx index 2d30ff421..e5e19d630 100644 --- a/src/fl_boxtype.cxx +++ b/src/fl_boxtype.cxx @@ -1,7 +1,7 @@ // // Box drawing code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2015 by Bill Spitzak and others. +// Copyright 1998-2020 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 @@ -46,6 +46,9 @@ static const uchar inactive_ramp[24] = { 51, 51, 52, 52}; static int draw_it_active = 1; +int Fl::box_border_radius_max_ = 15; +int Fl::box_shadow_width_ = 3; + /** Determines if the currently drawn box is active or inactive. diff --git a/src/fl_oval_box.cxx b/src/fl_oval_box.cxx index c094d7a68..9a0e1968a 100644 --- a/src/fl_oval_box.cxx +++ b/src/fl_oval_box.cxx @@ -1,7 +1,7 @@ // // Oval box drawing code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2011 by Bill Spitzak and others. +// Copyright 1998-2020 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 @@ -14,13 +14,17 @@ // https://www.fltk.org/bugs.php // - // Less-used box types are in separate files so they are not linked // in if not used. #include <FL/Fl.H> #include <FL/fl_draw.H> +// Global parameters for box drawing algorithm: +// +// BW = box shadow width +#define BW (Fl::box_shadow_width()) + static void fl_oval_flat_box(int x, int y, int w, int h, Fl_Color c) { Fl::set_box_color(c); fl_pie(x, y, w, h, 0, 360); @@ -37,7 +41,7 @@ static void fl_oval_box(int x, int y, int w, int h, Fl_Color c) { } static void fl_oval_shadow_box(int x, int y, int w, int h, Fl_Color c) { - fl_oval_flat_box(x+3,y+3,w,h,FL_DARK3); + fl_oval_flat_box(x+BW,y+BW,w,h,FL_DARK3); fl_oval_box(x,y,w,h,c); } diff --git a/src/fl_rounded_box.cxx b/src/fl_rounded_box.cxx index 4c1eb6aae..df41b4f6e 100644 --- a/src/fl_rounded_box.cxx +++ b/src/fl_rounded_box.cxx @@ -1,7 +1,7 @@ // // Rounded box drawing routines for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2020 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 @@ -17,15 +17,15 @@ #include <FL/Fl.H> #include <FL/fl_draw.H> -// Constants for rounded corner drawing algorithm: +// Global parameters for rounded corner drawing algorithm: // // RN = number of segments per corner (must match offset array size) // RS = max. corner radius // BW = box shadow width -#define RN 5 -#define RS 15 -#define BW 3 +#define RN 5 +#define RS (Fl::box_border_radius_max()) +#define BW (Fl::box_shadow_width()) static double offset[RN] = { 0.0, 0.07612, 0.29289, 0.61732, 1.0}; diff --git a/src/fl_shadow_box.cxx b/src/fl_shadow_box.cxx index 1084da3a4..d89d09b68 100644 --- a/src/fl_shadow_box.cxx +++ b/src/fl_shadow_box.cxx @@ -17,7 +17,10 @@ #include <FL/Fl.H> #include <FL/fl_draw.H> -#define BW 3 +// Global parameters for box drawing algorithm: +// +// BW = box shadow width +#define BW (Fl::box_shadow_width()) static void fl_shadow_frame(int x, int y, int w, int h, Fl_Color c) { fl_color(FL_DARK3); diff --git a/test/boxtype.cxx b/test/boxtype.cxx index 8bcd1b0ed..9f67f0784 100644 --- a/test/boxtype.cxx +++ b/test/boxtype.cxx @@ -103,9 +103,13 @@ int main(int argc, char ** argv) { #else // this code uses the nice bright blue background to show box vs. frame types Fl::args(argc, argv); Fl::get_system_colors(); - window->color(12);// light blue + window->color(fl_rgb_color(51, 173, 255)); // light blue (#33adff) #endif + // TEST: set box shadow width and max. border radius (should be commented out) + // Fl::box_border_radius_max(5); // default: 15 (see documentation) + // Fl::box_shadow_width(6); // default: 3 (see documentation) + // set window title to show active scheme Fl::scheme(Fl::scheme()); // init scheme char title[100]; |
