NodeView::NodeView(Gtk::Window* window, Ganv::Canvas& canvas, SPtr<machina::client::ClientObject> node, double x, double y) : Ganv::Circle(canvas, "", x, y) , _window(window) , _node(node) , _default_border_color(get_border_color()) , _default_fill_color(get_fill_color()) { set_fit_label(false); set_radius_ems(1.25); signal_event().connect(sigc::mem_fun(this, &NodeView::on_event)); MachinaCanvas* mcanvas = dynamic_cast<MachinaCanvas*>(&canvas); if (is(mcanvas->app()->forge(), URIs::instance().machina_initial)) { set_border_width(4.0); set_is_source(true); const uint8_t alpha[] = { 0xCE, 0xB1, 0 }; set_label((const char*)alpha); } node->signal_property.connect(sigc::mem_fun(this, &NodeView::on_property)); for (const auto& p : node->properties()) { on_property(p.first, p.second); } }
void NodeView::on_property(machina::URIInt key, const Atom& value) { static const uint32_t active_color = 0x408040FF; static const uint32_t active_border_color = 0x00FF00FF; if (key == URIs::instance().machina_selector) { if (value.get<int32_t>()) { set_dash_length(4.0); } else { set_dash_length(0.0); } } else if (key == URIs::instance().machina_initial) { set_border_width(value.get<int32_t>() ? 4.0 : 1.0); set_is_source(value.get<int32_t>()); } else if (key == URIs::instance().machina_active) { if (value.get<int32_t>()) { if (get_fill_color() != active_color) { set_fill_color(active_color); set_border_color(active_border_color); } } else if (get_fill_color() == active_color) { set_default_colors(); } } else if (key == URIs::instance().machina_enter_action) { const uint64_t action_id = value.get<int32_t>(); MachinaCanvas* canvas = dynamic_cast<MachinaCanvas*>(this->canvas()); _enter_action_connection.disconnect(); _enter_action = canvas->app()->client_model()->find(action_id); if (_enter_action) { _enter_action_connection = _enter_action->signal_property.connect( sigc::mem_fun(this, &NodeView::on_action_property)); for (auto i : _enter_action->properties()) { on_action_property(i.first, i.second); } } } }
static HRESULT get_color(uxgtk_theme_t *theme, int part_id, int state_id, int prop_id, GdkRGBA *rgba) { switch (prop_id) { case TMT_FILLCOLOR: return get_fill_color(theme, part_id, state_id, rgba); case TMT_TEXTCOLOR: return get_text_color(theme, part_id, state_id, rgba); default: FIXME("Unsupported property %d.\n", prop_id); return E_FAIL; } return S_OK; }