//------------------------------------------------------------------------------ void ListModelWrapper::handle_popup(const int x, const int y, const int time, GdkEventButton* evb) { Gtk::TreeModel::Path path; Gtk::TreeView::Column *column(0); int cell_x(-1); int cell_y(-1); ListModelWrapper::NodeIdArray list = get_selection(); bool there_is_path_at_pos = false; if (_treeview) there_is_path_at_pos = _treeview->get_path_at_pos(x, y, path, column, cell_x, cell_y); else if (_iconview) { path = _iconview->get_path_at_pos(x, y); there_is_path_at_pos = path.gobj() && !path.empty(); } if ( there_is_path_at_pos ) { // Check that @path is on selection, otherwise add @path to selection bec::NodeId node = get_node_for_path(path); // list stores current selection bool path_at_pos_is_in_selection = false; for (int i = list.size() - 1; i >= 0; --i) { if (node == list[i]) { path_at_pos_is_in_selection = true; break; } } if (!path_at_pos_is_in_selection) { // Add it, if user holds Ctrl while clicking right mouse btn // Otherwise clear selection, and select only @path const bool clear_selection = evb ? (!(evb->state & GDK_CONTROL_MASK)) : false; if (clear_selection) { if (_treeview) _treeview->get_selection()->unselect_all(); if (_iconview) _iconview->unselect_all(); } if (_treeview) _treeview->get_selection()->select(path); if (_iconview) _iconview->select_path(path); list = get_selection(); } } if (!_context_menu) _context_menu = new Gtk::Menu(); run_menu_and_forward_action((*_tm)->get_popup_items_for_nodes(list), x, y, time, *_tm, list, _fe_menu_handler, _context_menu); }
void MidiRuleCtrlTrigger::remove_row() { Gtk::TreeModel::Path cpath; Gtk::TreeViewColumn* col; tree_view.get_cursor(cpath, col); if (!cpath.empty()) tree_view.set_cursor(cpath); Gtk::TreeModel::iterator it = tree_view.get_selection()->get_selected(); if (it) { Gtk::TreePath path = list_store->get_path(it); list_store->erase(it); it = tree_view.get_selection()->get_selected(); if (!it) { int i = path[0]; int n = list_store->children().size(); if (n) { if (i >= n) i = n - 1; path[0] = i; tree_view.get_selection()->select(path); } } } }
void MidiRuleCtrlTrigger::add_row() { Gtk::TreeModel::Path path; Gtk::TreeViewColumn* col; tree_view.get_cursor(path, col); if (!path.empty()) tree_view.set_cursor(path); Gtk::TreeModel::iterator it = list_store->append(); Gtk::TreeModel::Row row = *it; update_model++; row[columns.trigger_point] = 64; row[columns.descending] = false; row[columns.vel_sensitivity] = 50; row[columns.key] = note_str(60); row[columns.note_off] = false; row[columns.switch_logic] = false; row[columns.override_pedal] = false; update_model--; tree_view.get_selection()->select(row); path = list_store->get_path(it); tree_view.scroll_to_row(path); tree_view.set_cursor(path); }
//------------------------------------------------------------------------------ bec::NodeId ListModelWrapper::get_node_for_path(const Gtk::TreeModel::Path& path) const { if (path.empty()) return bec::NodeId(); return bec::NodeId(path.to_string()); }
//------------------------------------------------------------------------------ bec::NodeId TreeModelWrapper::get_node_for_path(const Gtk::TreeModel::Path& path) const { if (path.empty()) return _root_node_path_dot; return bec::NodeId(_root_node_path_dot + path.to_string()); }