bool InternalPortModel::onItemEnterNotify(const Glib::RefPtr<Goocanvas::Item>& item, GdkEventCrossing* event) { parentWindow->get_window()->set_cursor(Gdk::Cursor(Gdk::HAND1)); //this->property_stroke_color().set_value("DodgerBlue3"); if(!bServicePort) poly->property_fill_color().set_value("LightSteelBlue"); else if(type == INPUTD) ellipse->property_fill_color().set_value("LightSteelBlue"); parentWindow->getRootModel()->add_child(tool); Gdk::Point pt = getContactPoint(); if(type == OUTPUTD) { tool->set_property("x", pt.get_x()+5); tool->set_property("y", pt.get_y()-tool->getHeight()/2.0); } else { tool->set_property("x", pt.get_x()-tool->getWidth()-5); tool->set_property("y", pt.get_y()-tool->getHeight()/2.0); } tool->raise(); return true; }
void MidpointModel::updateCoordiantes(void) { if(!arrow) return; Gdk::Point pt = getContactPoint(); arrow->setPoint(point_x, point_y, pt.get_x(), pt.get_y()); point_x = pt.get_x(); point_y = pt.get_y(); arrow->updatLabelCoordiante(); }
shared_ptr<timeline::Track> TimelineLayoutHelper::begin_dragging_track(Gdk::Point const& mouse_point) { shared_ptr<timeline::Track> dragging_track = header_from_point(mouse_point); if(!dragging_track) return shared_ptr<timeline::Track>(); dragPoint = Gdk::Point(mouse_point.get_x(), mouse_point.get_y() + timelineWidget.get_y_scroll_offset()); const Gdk::Rectangle &rect = headerBoxes[dragging_track]; dragStartOffset = Gdk::Point( dragPoint.get_x() - rect.get_x(), dragPoint.get_y() - rect.get_y()); const shared_ptr<model::Track> modelTrack = dragging_track->getModelTrack(); draggingTrackIter = iterator_from_track(modelTrack); dragBranchHeight = measure_branch_height(draggingTrackIter); dropPoint.relation = None; return dragging_track; }
void TimelineLayoutHelper::drag_to_point (Gdk::Point const& mouse_point) { DropPoint drop; drop.relation = None; // begin_dragging_track must have been called before REQUIRE(is_dragging_track()); // Apply the scroll offset const Gdk::Point last_point(dragPoint); dragPoint = Gdk::Point(mouse_point.get_x(), mouse_point.get_y() + timelineWidget.get_y_scroll_offset()); // Get a test-point // We probe on the bottom edge of the dragging branch if the track is // being dragged downward, and on the top edge if it's being dragged // upward. Gdk::Point test_point(dragPoint.get_x(), dragPoint.get_y() - dragStartOffset.get_y()); if(last_point.get_y() > dragPoint.get_y()) test_point.set_y(test_point.get_y()); else test_point.set_y(test_point.get_y() + dragBranchHeight); TrackTree::pre_order_iterator iterator; TrackTree::pre_order_iterator begin = ++layoutTree.begin(); if(test_point.get_y() < 0) { // Find the first header that's not being dragged for(iterator = begin; iterator != layoutTree.end(); iterator++) { if(iterator == draggingTrackIter) iterator.skip_children(); else { drop.relation = Before; drop.target = iterator; break; } } } else if(test_point.get_y() > totalHeight) { // Find the last header that's not being dragged for(iterator = --layoutTree.end(); iterator != begin; iterator--) { if(iterator.is_descendant_of(draggingTrackIter)) iterator.skip_children(); else { drop.relation = After; drop.target = iterator; break; } } } else { // Search the headers for(iterator = ++layoutTree.begin(); iterator != layoutTree.end(); iterator++) { // Skip the dragging branch if(iterator == draggingTrackIter) iterator.skip_children(); else { // Do hit test drop = attempt_drop(iterator, test_point); if(drop.relation != None) break; } } } // Did we get a drop point? if (drop.relation != None) { REQUIRE(*drop.target); shared_ptr<timeline::Track> target_timeline_track = lookup_timeline_track(*drop.target); apply_drop_to_layout_tree(drop); dropPoint = drop; // Expand the branch if the user is hovering to add the track // as a child if((drop.relation == FirstChild || drop.relation == LastChild) && !target_timeline_track->get_expanded()) target_timeline_track->expand_collapse(Track::Expand); } update_layout(); }