summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/mainpage.dox2
-rw-r--r--ganv/Canvas.hpp12
-rw-r--r--ganv/canvas.h4
-rw-r--r--src/Canvas.cpp49
-rw-r--r--src/module.c12
-rw-r--r--src/port.c2
6 files changed, 34 insertions, 47 deletions
diff --git a/doc/mainpage.dox b/doc/mainpage.dox
index 08e04c2..b61dac6 100644
--- a/doc/mainpage.dox
+++ b/doc/mainpage.dox
@@ -2,7 +2,7 @@
@section Overview
-FlowCanvas is a canvas widget for modular/patching/dataflow/graph/etc interfaces.
+Ganv is a canvas widget for modular/patching/dataflow/graph/etc interfaces.
See the class heirarchy for an index of the available functionality.
diff --git a/ganv/Canvas.hpp b/ganv/Canvas.hpp
index 139d5ab..93e0dea 100644
--- a/ganv/Canvas.hpp
+++ b/ganv/Canvas.hpp
@@ -109,17 +109,7 @@ public:
/** Resize the canvas to the given dimensions. */
void resize(double width, double height);
- /** The direction of the "signal flow" on the canvas. */
- enum FlowDirection {
- HORIZONTAL,
- VERTICAL
- };
-
- /** Set the flow direction of the canvas. */
- void set_direction(FlowDirection d);
-
- /** Return the current flow direction of the canvas. */
- FlowDirection direction() const;
+ RW_PROPERTY(GanvDirection, direction);
typedef void (*NodeFunction)(GanvNode* node, void* data);
diff --git a/ganv/canvas.h b/ganv/canvas.h
index a5bb441..a011cff 100644
--- a/ganv/canvas.h
+++ b/ganv/canvas.h
@@ -35,8 +35,8 @@ struct GanvCanvasImpl;
typedef struct _GanvCanvasClass GanvCanvasClass;
typedef enum {
- GANV_VERTICAL,
- GANV_HORIZONTAL
+ GANV_DIRECTION_DOWN,
+ GANV_DIRECTION_RIGHT
} GanvDirection;
struct _GanvCanvas
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
index 704714a..ca2b08a 100644
--- a/src/Canvas.cpp
+++ b/src/Canvas.cpp
@@ -54,6 +54,8 @@
static guint signal_connect;
static guint signal_disconnect;
+static GEnumValue dir_values[3];
+
using std::cerr;
using std::endl;
using std::list;
@@ -142,7 +144,6 @@ struct GanvCanvasImpl {
, _zoom(1.0)
, _font_size(0.0)
, _drag_state(NOT_DRAGGING)
- , _direction(Ganv::Canvas::HORIZONTAL)
{
_wrapper_key = g_quark_from_string("ganvmm");
_move_cursor = gdk_cursor_new(GDK_FLEUR);
@@ -256,8 +257,6 @@ struct GanvCanvasImpl {
GQuark _wrapper_key;
GdkCursor* _move_cursor;
-
- Ganv::Canvas::FlowDirection _direction;
};
static GanvEdge
@@ -465,7 +464,7 @@ GanvCanvasImpl::layout_dot(bool use_length_hints, const std::string& filename)
nodes.gvc = gvc;
nodes.G = G;
- if (_direction == Ganv::Canvas::HORIZONTAL) {
+ if (_gcanvas->direction == GANV_DIRECTION_RIGHT) {
agraphattr(G, (char*)"rankdir", (char*)"LR");
} else {
agraphattr(G, (char*)"rankdir", (char*)"TD");
@@ -1485,27 +1484,6 @@ Canvas::get_zoom()
}
void
-Canvas::set_direction(FlowDirection d)
-{
- impl()->_direction = d;
- std::cerr << "FIXME: set direction" << std::endl;
-#if 0
- FOREACH_ITEM(impl()->_items, i) {
- Module* mod = dynamic_cast<Module*>(*i);
- if (mod) {
- mod->set_show_port_labels(d == Canvas::HORIZONTAL);
- }
- }
-#endif
-}
-
-Canvas::FlowDirection
-Canvas::direction() const
-{
- return impl()->_direction;
-}
-
-void
Canvas::select_all()
{
clear_selection();
@@ -1770,13 +1748,14 @@ enum {
PROP_0,
PROP_WIDTH,
PROP_HEIGHT,
+ PROP_DIRECTION,
PROP_LOCKED
};
static void
ganv_canvas_init(GanvCanvas* canvas)
{
- canvas->direction = GANV_HORIZONTAL;
+ canvas->direction = GANV_DIRECTION_RIGHT;
canvas->impl = new GanvCanvasImpl(canvas);
canvas->impl->_font_size = ganv_canvas_get_default_font_size(canvas);
}
@@ -1866,6 +1845,24 @@ ganv_canvas_class_init(GanvCanvasClass* klass)
600.0,
(GParamFlags)G_PARAM_READWRITE));
+ GEnumValue down_dir = { GANV_DIRECTION_DOWN, "down", "down" };
+ GEnumValue right_dir = { GANV_DIRECTION_RIGHT, "right", "right" };
+ GEnumValue null_dir = { 0, 0, 0 };
+ dir_values[0] = down_dir;
+ dir_values[1] = right_dir;
+ dir_values[2] = null_dir;
+ GType dir_type = g_enum_register_static("GanvDirection",
+ dir_values);
+
+ g_object_class_install_property(
+ gobject_class, PROP_DIRECTION, g_param_spec_enum(
+ "direction",
+ _("direction"),
+ _("direction of the signal flow on the canvas"),
+ dir_type,
+ GANV_DIRECTION_RIGHT,
+ (GParamFlags)G_PARAM_READWRITE));
+
g_object_class_install_property(
gobject_class, PROP_LOCKED, g_param_spec_boolean(
"locked",
diff --git a/src/module.c b/src/module.c
index cc8269e..2f0fa20 100644
--- a/src/module.c
+++ b/src/module.c
@@ -168,7 +168,7 @@ measure(GanvModule* module, Metrics* m)
GanvDirection direction = canvas->direction;
- if (direction == GANV_VERTICAL) {
+ if (direction == GANV_DIRECTION_DOWN) {
static const double PAD = 2.0;
double contents_width = PAD;
@@ -257,7 +257,7 @@ place_title(GanvModule* module, GanvDirection dir)
if (!canvas_title) {
return;
- } else if (dir == GANV_HORIZONTAL) {
+ } else if (dir == GANV_DIRECTION_RIGHT) {
if (module->icon_box) {
gnome_canvas_item_set(GNOME_CANVAS_ITEM(canvas_title),
"x", MODULE_ICON_SIZE + 1.0,
@@ -353,7 +353,7 @@ resize_horiz(GanvModule* module)
ganv_box_set_height(&module->box, height);
- place_title(module, GANV_HORIZONTAL);
+ place_title(module, GANV_DIRECTION_RIGHT);
}
static void
@@ -418,7 +418,7 @@ resize_vert(GanvModule* module)
ganv_box_set_width(GANV_BOX(module), m.width);
ganv_box_set_height(GANV_BOX(module), height);
- place_title(module, GANV_VERTICAL);
+ place_title(module, GANV_DIRECTION_DOWN);
}
static void
@@ -466,10 +466,10 @@ layout(GanvNode* self)
}
switch (canvas->direction) {
- case GANV_HORIZONTAL:
+ case GANV_DIRECTION_RIGHT:
resize_horiz(module);
break;
- case GANV_VERTICAL:
+ case GANV_DIRECTION_DOWN:
resize_vert(module);
break;
}
diff --git a/src/port.c b/src/port.c
index b84613e..c5dcb05 100644
--- a/src/port.c
+++ b/src/port.c
@@ -270,7 +270,7 @@ ganv_port_new(GanvModule* module,
if (!node->label) {
const double depth = ganv_module_get_empty_port_depth(module);
const double breadth = ganv_module_get_empty_port_breadth(module);
- if (canvas->direction == GANV_HORIZONTAL) {
+ if (canvas->direction == GANV_DIRECTION_RIGHT) {
ganv_box_set_width(box, depth);
ganv_box_set_height(box, breadth);
} else {