summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS5
-rw-r--r--ganv/Box.hpp1
-rw-r--r--src/box.c29
-rw-r--r--src/ganv-private.h1
-rw-r--r--src/port.c18
5 files changed, 41 insertions, 13 deletions
diff --git a/NEWS b/NEWS
index bbd0472..5311901 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-ganv (1.5.2) unstable;
+ganv (1.5.3) unstable;
* Fix positioning of embedded widgets when changing layout.
* Fix unexpected node jumping when dragging new connections.
@@ -10,12 +10,13 @@ ganv (1.5.2) unstable;
* Improve appearance of graphs with circle nodes.
* Improve update performance.
* Add API to specify module port order.
+ * Add support for beveled box corners.
* Fix various minor visual alignment/sizing issues.
* Fix size of vertical flow modules.
* Fix compilation with --no-fdgl (patch from Vlad Glagolev).
* Fix crash when destroying canvas.
- -- David Robillard <d@drobilla.net> Sat, 21 Feb 2015 19:39:35 -0500
+ -- David Robillard <d@drobilla.net> Sat, 14 Mar 2015 21:31:47 -0400
ganv (1.4.2) stable;
diff --git a/ganv/Box.hpp b/ganv/Box.hpp
index aa88f0e..ad5729f 100644
--- a/ganv/Box.hpp
+++ b/ganv/Box.hpp
@@ -29,6 +29,7 @@ public:
{}
RW_PROPERTY(const char*, label);
+ RW_PROPERTY(gboolean, beveled);
METHODRET0(ganv_box, double, get_x1)
METHODRET0(ganv_box, double, get_y1)
diff --git a/src/box.c b/src/box.c
index c5206e1..e883647 100644
--- a/src/box.c
+++ b/src/box.c
@@ -41,7 +41,8 @@ enum {
PROP_RADIUS_TR,
PROP_RADIUS_BR,
PROP_RADIUS_BL,
- PROP_STACKED
+ PROP_STACKED,
+ PROP_BEVELED
};
static void
@@ -58,6 +59,7 @@ ganv_box_init(GanvBox* box)
box->impl->radius_tr = 0.0;
box->impl->radius_br = 0.0;
box->impl->radius_bl = 0.0;
+ box->impl->beveled = FALSE;
}
static void
@@ -94,6 +96,7 @@ ganv_box_set_property(GObject* object,
SET_CASE(RADIUS_BR, double, impl->radius_br);
SET_CASE(RADIUS_BL, double, impl->radius_bl);
SET_CASE(STACKED, boolean, coords->stacked);
+ SET_CASE(BEVELED, boolean, impl->beveled);
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -123,6 +126,7 @@ ganv_box_get_property(GObject* object,
GET_CASE(RADIUS_BR, double, impl->radius_br);
GET_CASE(RADIUS_BL, double, impl->radius_bl);
GET_CASE(STACKED, boolean, impl->coords.stacked);
+ GET_CASE(BEVELED, boolean, impl->beveled);
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -212,6 +216,19 @@ ganv_box_path(GanvBox* box,
&& impl->radius_br == 0.0 && impl->radius_bl == 0.0) {
// Simple rectangle
cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1);
+ } else if (impl->beveled) {
+ // Beveled rectangle
+ cairo_new_sub_path(cr);
+ cairo_move_to(cr, x1 + impl->radius_tl, y1);
+ cairo_line_to(cr, x2 - impl->radius_tr, y1);
+ cairo_line_to(cr, x2, y1 + impl->radius_tr);
+ cairo_line_to(cr, x2, y2 - impl->radius_br);
+ cairo_line_to(cr, x2 - impl->radius_br, y2);
+ cairo_line_to(cr, x1 + impl->radius_bl, y2);
+ cairo_line_to(cr, x1, y2 - impl->radius_bl);
+ cairo_line_to(cr, x1, y2 - impl->radius_bl);
+ cairo_line_to(cr, x1, y1 + impl->radius_tl);
+ cairo_close_path(cr);
} else {
// Rounded rectangle
cairo_new_sub_path(cr);
@@ -449,7 +466,15 @@ ganv_box_class_init(GanvBoxClass* klass)
gobject_class, PROP_STACKED, g_param_spec_boolean(
"stacked",
_("Stacked"),
- _("Whether to show the box with a stacked appearance."),
+ _("Show box with a stacked appearance."),
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_BEVELED, g_param_spec_boolean(
+ "beveled",
+ _("Beveled"),
+ _("Show radiused corners with a sharp bevel."),
FALSE,
G_PARAM_READWRITE));
diff --git a/src/ganv-private.h b/src/ganv-private.h
index 29b2e61..93f286c 100644
--- a/src/ganv-private.h
+++ b/src/ganv-private.h
@@ -45,6 +45,7 @@ struct _GanvBoxImpl {
double radius_tr;
double radius_br;
double radius_bl;
+ gboolean beveled;
};
/* Circle */
diff --git a/src/port.c b/src/port.c
index ecdbe90..99c3283 100644
--- a/src/port.c
+++ b/src/port.c
@@ -25,7 +25,7 @@
#include "./ganv-private.h"
#include "./gettext.h"
-static const double PORT_LABEL_HPAD = 2.0;
+static const double PORT_LABEL_HPAD = 4.0;
static const double PORT_LABEL_VPAD = 1.0;
static void
@@ -475,16 +475,16 @@ ganv_port_set_direction(GanvPort* port,
gboolean is_input = port->impl->is_input;
switch (direction) {
case GANV_DIRECTION_RIGHT:
- box->impl->radius_tl = (is_input ? 0.0 : 4.0);
- box->impl->radius_tr = (is_input ? 4.0 : 0.0);
- box->impl->radius_br = (is_input ? 4.0 : 0.0);
- box->impl->radius_bl = (is_input ? 0.0 : 4.0);
+ box->impl->radius_tl = (is_input ? 0.0 : 5.0);
+ box->impl->radius_tr = (is_input ? 5.0 : 0.0);
+ box->impl->radius_br = (is_input ? 5.0 : 0.0);
+ box->impl->radius_bl = (is_input ? 0.0 : 5.0);
break;
case GANV_DIRECTION_DOWN:
- box->impl->radius_tl = (is_input ? 0.0 : 4.0);
- box->impl->radius_tr = (is_input ? 0.0 : 4.0);
- box->impl->radius_br = (is_input ? 4.0 : 0.0);
- box->impl->radius_bl = (is_input ? 4.0 : 0.0);
+ box->impl->radius_tl = (is_input ? 0.0 : 5.0);
+ box->impl->radius_tr = (is_input ? 0.0 : 5.0);
+ box->impl->radius_br = (is_input ? 5.0 : 0.0);
+ box->impl->radius_bl = (is_input ? 5.0 : 0.0);
break;
}