summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2020-09-01 12:33:11 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2020-09-01 12:35:48 +0200
commitb65d3a249d4db1ada6d0bc96031e55459e0d6381 (patch)
treecb2d4c2778263df4245b6cb7122ab0bd8826c5c4 /src
parent95799bd3641ebe43400aa85dd8cf84405f26aac8 (diff)
Customize corner radius for rounded box/frame (#130)
Make maximum box corner radius and shadow width configurable. See Fl::box_border_radius_max() and Fl::box_shadow_width(). Documentation: update image of box types. Fixes #130
Diffstat (limited to 'src')
-rw-r--r--src/fl_boxtype.cxx5
-rw-r--r--src/fl_oval_box.cxx10
-rw-r--r--src/fl_rounded_box.cxx10
-rw-r--r--src/fl_shadow_box.cxx5
4 files changed, 20 insertions, 10 deletions
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);