From: Ben Loftis Date: Thu, 15 Nov 2018 15:27:04 +0000 (-0600) Subject: (Source List) Region Tags (gtk2 part) X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=c12a0177287d8a590aad51979055cbc5561cf31e;p=ardour.git (Source List) Region Tags (gtk2 part) --- diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in index 3e46b56008..c083d58427 100644 --- a/gtk2_ardour/ardour.menus.in +++ b/gtk2_ardour/ardour.menus.in @@ -234,6 +234,7 @@ + @@ -293,6 +294,7 @@ + @@ -710,6 +712,7 @@ + diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 71f9968867..753e718fa9 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -1439,6 +1439,11 @@ private: void toggle_skip_playback (); void remove_last_capture (); + + void tag_last_capture (); + void tag_selected_region (); + void tag_regions (ARDOUR::RegionList); + void select_all_selectables_using_time_selection (); void select_all_selectables_using_loop(); void select_all_selectables_using_punch(); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index a96c39f4a4..f984ee7c26 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -330,6 +330,8 @@ Editor::register_actions () /* this is a duplicated action so that the main menu can use a different label */ reg_sens (editor_actions, "main-menu-play-selected-regions", _("Play Selected Regions"), sigc::mem_fun (*this, &Editor::play_selected_region)); + reg_sens (editor_actions, "main-menu-tag-selected-regions", _("Tag Selected Regions"), sigc::mem_fun (*this, &Editor::tag_selected_region)); + reg_sens (editor_actions, "play-from-edit-point", _("Play from Edit Point"), sigc::mem_fun(*this, &Editor::play_from_edit_point)); reg_sens (editor_actions, "play-from-edit-point-and-return", _("Play from Edit Point and Return"), sigc::mem_fun(*this, &Editor::play_from_edit_point_and_return)); @@ -422,6 +424,7 @@ Editor::register_actions () toggle_reg_sens (editor_actions, "toggle-follow-playhead", _("Follow Playhead"), (sigc::mem_fun(*this, &Editor::toggle_follow_playhead))); act = reg_sens (editor_actions, "remove-last-capture", _("Remove Last Capture"), (sigc::mem_fun(*this, &Editor::remove_last_capture))); + act = reg_sens (editor_actions, "tag-last-capture", _("Tag Last Capture"), (sigc::mem_fun(*this, &Editor::tag_last_capture))); ActionManager::register_toggle_action (editor_actions, "toggle-stationary-playhead", _("Stationary Playhead"), (mem_fun(*this, &Editor::toggle_stationary_playhead))); @@ -1512,6 +1515,7 @@ Editor::register_region_actions () register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "show-region-properties", _("Properties..."), sigc::mem_fun (*this, &Editor::show_region_properties)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "play-selected-regions", _("Play selected Regions"), sigc::mem_fun(*this, &Editor::play_selected_region)); + register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "tag-selected-regions", _("Tag selected Regions"), sigc::mem_fun(*this, &Editor::tag_selected_region)); register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "bounce-regions-processed", _("Bounce (with processing)"), (sigc::bind (sigc::mem_fun (*this, &Editor::bounce_region_selection), true))); register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "bounce-regions-unprocessed", _("Bounce (without processing)"), (sigc::bind (sigc::mem_fun (*this, &Editor::bounce_region_selection), false))); diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index 911028ee9d..dc23d69957 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -1169,7 +1169,7 @@ Editor::track_canvas_drag_motion (Glib::RefPtr const& context, return false; } -printf("DRAGGING: track_canvas_drag_motion\n"); +printf("Paul: DRAGGING: track_canvas_drag_motion\n"); event.type = GDK_MOTION_NOTIFY; event.button.x = x; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 1c9df29d3d..aa5c7dfa3e 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -5139,6 +5139,95 @@ Editor::remove_last_capture () } } +void +Editor::tag_regions (RegionList regions) +{ + ArdourDialog d (_("Tag Last Capture"), true, false); + Entry entry; + Label label (_("Tag:")); + HBox hbox; + + hbox.set_spacing (6); + hbox.pack_start (label, false, false); + hbox.pack_start (entry, true, true); + + d.get_vbox()->set_border_width (12); + d.get_vbox()->pack_start (hbox, false, false); + + d.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + d.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK); + + d.set_size_request (300, -1); + + entry.set_text (_("Good")); + entry.select_region (0, -1); + + entry.signal_activate().connect (sigc::bind (sigc::mem_fun (d, &Dialog::response), RESPONSE_OK)); + + d.show_all (); + + entry.grab_focus(); + + int const ret = d.run(); + + d.hide (); + + if (ret != RESPONSE_OK) { + return; + } + + std::string tagstr = entry.get_text(); + strip_whitespace_edges (tagstr); + + if (!tagstr.empty()) { + for (RegionList::iterator r = regions.begin(); r != regions.end(); r++) { + (*r)->set_tags(tagstr); + } + + _regions->redisplay (); + } +} + +void +Editor::tag_selected_region () +{ + std::list > rlist; + + RegionSelection rs = get_regions_from_selection_and_entered (); + for (RegionSelection::iterator r = rs.begin(); r != rs.end(); r++) { + rlist.push_back((*r)->region()); + } + + tag_regions(rlist); +} + +void +Editor::tag_last_capture () +{ + if (!_session) { + return; + } + + std::list > rlist; + + std::list > srcs; + _session->get_last_capture_sources (srcs); + for (std::list >::iterator i = srcs.begin(); i != srcs.end(); ++i) { + boost::shared_ptr source = (*i); + if (source) { + + set > regions; + RegionFactory::get_regions_using_source (source, regions); + for (set >::iterator r = regions.begin(); r != regions.end(); r++) { + rlist.push_back(*r); + } + + } + } + + tag_regions(rlist); +} + void Editor::normalize_region () { diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc index 32e7a67b8c..eaa83bc339 100644 --- a/gtk2_ardour/editor_regions.cc +++ b/gtk2_ardour/editor_regions.cc @@ -79,6 +79,7 @@ EditorRegions::EditorRegions (Editor* e) : EditorComponent (e) , old_focus (0) , name_editable (0) + , tags_editable (0) , _menu (0) , _no_redisplay (false) { @@ -110,9 +111,9 @@ EditorRegions::EditorRegions (Editor* e) TreeViewColumn* col_name = manage (new TreeViewColumn ("", _columns.name)); col_name->set_fixed_width (120); col_name->set_sizing (TREE_VIEW_COLUMN_FIXED); - TreeViewColumn* col_take = manage (new TreeViewColumn ("", _columns.take_id)); - col_take->set_fixed_width (date_width); - col_take->set_sizing (TREE_VIEW_COLUMN_FIXED); + TreeViewColumn* col_tags = manage (new TreeViewColumn ("", _columns.tags)); + col_tags->set_fixed_width (date_width); + col_tags->set_sizing (TREE_VIEW_COLUMN_FIXED); TreeViewColumn* col_start = manage (new TreeViewColumn ("", _columns.start)); col_start->set_fixed_width (bbt_width); col_start->set_sizing (TREE_VIEW_COLUMN_FIXED); @@ -145,7 +146,7 @@ EditorRegions::EditorRegions (Editor* e) col_opaque->set_sizing (TREE_VIEW_COLUMN_FIXED); _display.append_column (*col_name); - _display.append_column (*col_take); + _display.append_column (*col_tags); _display.append_column (*col_start); _display.append_column (*col_locked); _display.append_column (*col_glued); @@ -162,7 +163,7 @@ EditorRegions::EditorRegions (Editor* e) ColumnInfo ci[] = { { 0, 0, ALIGN_LEFT, _("Region"), _("Region name, with number of channels in []'s") }, - { 1, 1, ALIGN_LEFT, _("Take"), _("Take ID (or file creation time)") }, + { 1, 1, ALIGN_LEFT, _("Tags"), _("Tags") }, { 2, 15, ALIGN_RIGHT, _("Start"), _("Position of start of region") }, { 3, -1, ALIGN_CENTER, S_("Lock|L"), _("Region position locked?") }, { 4, -1, ALIGN_CENTER, S_("Gain|G"), _("Region position glued to Bars|Beats time?") }, @@ -212,18 +213,25 @@ EditorRegions::EditorRegions (Editor* e) } _display.get_selection()->set_select_function (sigc::mem_fun (*this, &EditorRegions::selection_filter)); - //Region Name: editable; and color turns red if source is missing. + //Name cell: make editable CellRendererText* region_name_cell = dynamic_cast(_display.get_column_cell_renderer (0)); region_name_cell->property_editable() = true; region_name_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRegions::name_edit)); region_name_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRegions::name_editing_started)); + //Region Name: color turns red if source is missing. TreeViewColumn* tv_col = _display.get_column(0); CellRendererText* renderer = dynamic_cast(_display.get_column_cell_renderer (0)); tv_col->add_attribute(renderer->property_text(), _columns.name); tv_col->add_attribute(renderer->property_foreground_gdk(), _columns.color_); tv_col->set_expand (true); + //Tags cell: make editable + CellRendererText* region_tags_cell = dynamic_cast(_display.get_column_cell_renderer (1)); + region_tags_cell->property_editable() = true; + region_tags_cell->signal_edited().connect (sigc::mem_fun (*this, &EditorRegions::tag_edit)); + region_tags_cell->signal_editing_started().connect (sigc::mem_fun (*this, &EditorRegions::tag_editing_started)); + CellRendererToggle* locked_cell = dynamic_cast (_display.get_column_cell_renderer (3)); locked_cell->property_activatable() = true; locked_cell->signal_toggled().connect (sigc::mem_fun (*this, &EditorRegions::locked_changed)); @@ -286,6 +294,7 @@ EditorRegions::focus_in (GdkEventFocus*) } name_editable = 0; + tags_editable = 0; /* try to do nothing on focus in (doesn't work, hence selection_count nonsense) */ return true; @@ -300,6 +309,7 @@ EditorRegions::focus_out (GdkEventFocus*) } name_editable = 0; + tags_editable = 0; return false; } @@ -307,7 +317,7 @@ EditorRegions::focus_out (GdkEventFocus*) bool EditorRegions::enter_notify (GdkEventCrossing*) { - if (name_editable) { + if (name_editable || tags_editable) { return true; } @@ -639,15 +649,17 @@ EditorRegions::populate_row (boost::shared_ptr region, TreeModel::Row co _editor->mark_region_boundary_cache_dirty(); } - Gdk::Color c; - bool missing_source = boost::dynamic_pointer_cast(region->source()) != NULL; - if (missing_source) { - set_color_from_rgba (c, UIConfiguration::instance().color ("region list missing source")); - } else { - set_color_from_rgba (c, UIConfiguration::instance().color ("region list whole file")); + { + Gdk::Color c; + bool missing_source = boost::dynamic_pointer_cast(region->source()) != NULL; + if (missing_source) { + set_color_from_rgba (c, UIConfiguration::instance().color ("region list missing source")); + } else { + set_color_from_rgba (c, UIConfiguration::instance().color ("region list whole file")); + } + row[_columns.color_] = c; } - row[_columns.color_] = c; - + boost::shared_ptr audioregion = boost::dynamic_pointer_cast(region); PropertyChange c; @@ -684,7 +696,7 @@ EditorRegions::populate_row (boost::shared_ptr region, TreeModel::Row co if (all) { populate_row_source (region, row); } - if (all || what_changed.contains (Properties::name)) { + if (all || what_changed.contains (Properties::name) || what_changed.contains (Properties::tags)) { populate_row_name (region, row); } } @@ -832,6 +844,8 @@ EditorRegions::populate_row_name (boost::shared_ptr region, TreeModel::R } else { row[_columns.name] = Gtkmm2ext::markup_escape_text (region->name()); } + + row[_columns.tags] = region->tags(); } void @@ -842,8 +856,6 @@ EditorRegions::populate_row_source (boost::shared_ptr region, TreeModel: } else { row[_columns.path] = Gtkmm2ext::markup_escape_text (region->source()->name()); } - - row[_columns.take_id] = region->source()->take_id(); //TODO: what if there is no take-id? anything else we can use? } void @@ -876,6 +888,11 @@ EditorRegions::key_press (GdkEventKey* ev) name_editable = 0; } + if (tags_editable) { + tags_editable->editing_done (); + tags_editable = 0; + } + col = _display.get_column (0); // select&focus on name column if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { @@ -1043,17 +1060,53 @@ EditorRegions::name_edit (const std::string& path, const std::string& new_text) (*row_iter)[_columns.name] = new_text; } - /* now mapover everything */ - if (region) { - vector equivalents; - _editor->get_regions_corresponding_to (region, equivalents, false); - for (vector::iterator i = equivalents.begin(); i != equivalents.end(); ++i) { - if (new_text != (*i)->region()->name()) { - (*i)->region()->set_name (new_text); + region->set_name (new_text); + + populate_row_name (region, (*row_iter)); + } +} + + +void +EditorRegions::tag_editing_started (CellEditable* ce, const Glib::ustring& path) +{ + tags_editable = ce; + + /* give it a special name */ + + Gtk::Entry *e = dynamic_cast (ce); + + if (e) { + e->set_name (X_("RegionTagEditorEntry")); + + TreeIter iter; + if ((iter = _model->get_iter (path))) { + boost::shared_ptr region = (*iter)[_columns.region]; + + if(region) { + e->set_text(region->tags()); } } + } +} + +void +EditorRegions::tag_edit (const std::string& path, const std::string& new_text) +{ + tags_editable = 0; + + boost::shared_ptr region; + TreeIter row_iter; + + if ((row_iter = _model->get_iter (path))) { + region = (*row_iter)[_columns.region]; + (*row_iter)[_columns.tags] = new_text; + } + + if (region) { + region->set_tags (new_text); populate_row_name (region, (*row_iter)); } diff --git a/gtk2_ardour/editor_regions.h b/gtk2_ardour/editor_regions.h index 94124e98ad..3f9c756448 100644 --- a/gtk2_ardour/editor_regions.h +++ b/gtk2_ardour/editor_regions.h @@ -76,7 +76,7 @@ private: struct Columns : public Gtk::TreeModel::ColumnRecord { Columns () { add (name); - add (take_id); + add (tags); add (start); add (end); add (length); @@ -94,7 +94,7 @@ private: } Gtk::TreeModelColumn name; - Gtk::TreeModelColumn take_id; + Gtk::TreeModelColumn tags; Gtk::TreeModelColumn position; Gtk::TreeModelColumn start; Gtk::TreeModelColumn end; @@ -125,10 +125,17 @@ private: bool selection_filter (const Glib::RefPtr& model, const Gtk::TreeModel::Path& path, bool yn); Gtk::Widget* old_focus; + Gtk::CellEditable* name_editable; void name_editing_started (Gtk::CellEditable*, const Glib::ustring&); - void name_edit (const std::string&, const std::string&); + + + Gtk::CellEditable* tags_editable; + void tag_editing_started (Gtk::CellEditable*, const Glib::ustring&); + void tag_edit (const std::string&, const std::string&); + + void locked_changed (std::string const &); void glued_changed (std::string const &); void muted_changed (std::string const &);