diff options
author | David Robillard <d@drobilla.net> | 2011-12-08 02:13:47 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-12-08 02:13:47 +0000 |
commit | 7e11058ba3b1b8339441c9559d36a938f1ecfdc0 (patch) | |
tree | 3d4e815fda7d994ba5093da47875c761bc7dba77 /src | |
parent | 3cd19961949ebcd69172e184f004427cfb59d5bf (diff) | |
download | ganv-7e11058ba3b1b8339441c9559d36a938f1ecfdc0.tar.gz ganv-7e11058ba3b1b8339441c9559d36a938f1ecfdc0.tar.bz2 ganv-7e11058ba3b1b8339441c9559d36a938f1ecfdc0.zip |
Make canvas direction a property.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@3835 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/Canvas.cpp | 49 | ||||
-rw-r--r-- | src/module.c | 12 | ||||
-rw-r--r-- | src/port.c | 2 |
3 files changed, 30 insertions, 33 deletions
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; } @@ -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 { |