From 1760218d029892fc9ba3b25e06479cce319f20a0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 3 Dec 2007 04:53:27 +0000 Subject: Use dashed outline for selector nodes. Fix various selector node visual problems. git-svn-id: http://svn.drobilla.net/lad/machina@942 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/MachinaCanvas.cpp | 5 +++-- src/gui/MachinaCanvas.hpp | 6 ++++-- src/gui/NodeView.cpp | 32 ++++++++++++++++++++++++++------ src/gui/NodeView.hpp | 1 + 4 files changed, 34 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp index 3524035..e899a64 100644 --- a/src/gui/MachinaCanvas.cpp +++ b/src/gui/MachinaCanvas.cpp @@ -31,8 +31,9 @@ using namespace FlowCanvas; MachinaCanvas::MachinaCanvas(MachinaGUI* app, int width, int height) -: Canvas(width, height), - _app(app) + : Canvas(width, height) + , _app(app) + , _selector_dash(NULL) { grab_focus(); } diff --git a/src/gui/MachinaCanvas.hpp b/src/gui/MachinaCanvas.hpp index 9e20051..63c88fd 100644 --- a/src/gui/MachinaCanvas.hpp +++ b/src/gui/MachinaCanvas.hpp @@ -42,6 +42,8 @@ public: void build(SharedPtr machine); + ArtVpathDash* selector_dash() { return _selector_dash; } + protected: bool canvas_event(GdkEvent* event); @@ -50,8 +52,8 @@ protected: private: SharedPtr create_node_view(SharedPtr node); - MachinaGUI* _app; - + MachinaGUI* _app; + ArtVpathDash* _selector_dash; WeakPtr _last_clicked; }; diff --git a/src/gui/NodeView.cpp b/src/gui/NodeView.cpp index fc9b0bb..61f1858 100644 --- a/src/gui/NodeView.cpp +++ b/src/gui/NodeView.cpp @@ -22,7 +22,6 @@ using namespace std; - NodeView::NodeView(Gtk::Window* window, SharedPtr canvas, SharedPtr node, @@ -85,6 +84,31 @@ NodeView::show_label(bool show) } +/// Dash style for selector node outlines +static ArtVpathDash* selector_dash() +{ + static ArtVpathDash* selector_dash = NULL; + + if (!selector_dash) { + selector_dash = new ArtVpathDash(); + selector_dash->n_dash = 2; + selector_dash->dash = art_new(double, 2); + selector_dash->dash[0] = 8; + selector_dash->dash[1] = 8; + } + + return selector_dash; +} + +void +NodeView::set_selected(bool selected) +{ + Ellipse::set_selected(selected); + if (!selected) + _ellipse.property_dash() = _node->is_selector() ? selector_dash() : 0; +} + + void NodeView::update_state(bool show_labels) { @@ -102,11 +126,7 @@ NodeView::update_state(bool show_labels) set_border_color(_default_border_color); } - if (_node->is_selector()) - if (_node->is_active()) - set_base_color(0x00FF00FF); - else - set_base_color(0x00A000FF); + _ellipse.property_dash() = _node->is_selector() ? selector_dash() : 0; set_border_width(_node->is_initial() ? 4.0 : 1.0); diff --git a/src/gui/NodeView.hpp b/src/gui/NodeView.hpp index bc94efa..02b34e6 100644 --- a/src/gui/NodeView.hpp +++ b/src/gui/NodeView.hpp @@ -40,6 +40,7 @@ public: private: void handle_click(GdkEventButton* ev); void on_double_click(GdkEventButton* ev); + void set_selected(bool selected); Gtk::Window* _window; SharedPtr _node; -- cgit v1.2.1