X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_regions.cc;h=fc946abe5da2b660d9553f2bec00eaad96d4a36a;hb=3c1bc99df936a2ea1ea11ef6c884b9eecaef5c09;hp=1d6ac8c16cb62e74885e8fa0723cb2ae8eee09e8;hpb=ced4378d0914bcfb926267772c45d1d23f3bed38;p=ardour.git diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc index 1d6ac8c16c..fc946abe5d 100644 --- a/gtk2_ardour/editor_regions.cc +++ b/gtk2_ardour/editor_regions.cc @@ -35,6 +35,7 @@ #include "gtkmm2ext/choice.h" #include "gtkmm2ext/treeutils.h" +#include "gtkmm2ext/utils.h" #include "audio_clock.h" #include "editor.h" @@ -48,6 +49,8 @@ #include "editor_regions.h" #include "editor_drag.h" #include "main_clock.h" +#include "tooltips.h" +#include "ui_config.h" #include "i18n.h" @@ -81,6 +84,7 @@ EditorRegions::EditorRegions (Editor* e) _display.set_size_request (100, -1); _display.set_rules_hint (true); _display.set_name ("EditGroupList"); + _display.set_fixed_height_mode (true); /* Try to prevent single mouse presses from initiating edits. This relies on a hack in gtktreeview.c:gtk_treeview_button_press() @@ -91,19 +95,62 @@ EditorRegions::EditorRegions (Editor* e) _model->set_sort_func (0, sigc::mem_fun (*this, &EditorRegions::sorter)); _model->set_sort_column (0, SORT_ASCENDING); - _display.set_model (_model); - - _display.append_column ("", _columns.name); - _display.append_column ("", _columns.position); - _display.append_column ("", _columns.end); - _display.append_column ("", _columns.length); - _display.append_column ("", _columns.sync); - _display.append_column ("", _columns.fadein); - _display.append_column ("", _columns.fadeout); - _display.append_column ("", _columns.locked); - _display.append_column ("", _columns.glued); - _display.append_column ("", _columns.muted); - _display.append_column ("", _columns.opaque); + /* column widths */ + int bbt_width, sync_width, check_width, height; + + Glib::RefPtr layout = _display.create_pango_layout (X_("000|000|000")); + Gtkmm2ext::get_pixel_size (layout, bbt_width, height); + + layout = _display.create_pango_layout (X_("Start ")); + Gtkmm2ext::get_pixel_size (layout, sync_width, height); + + check_width = 20; + + TreeViewColumn* col_name = manage (new TreeViewColumn ("", _columns.name)); + col_name->set_fixed_width (120); + col_name->set_sizing (TREE_VIEW_COLUMN_FIXED); + TreeViewColumn* col_position = manage (new TreeViewColumn ("", _columns.position)); + col_position->set_fixed_width (bbt_width); + col_position->set_sizing (TREE_VIEW_COLUMN_FIXED); + TreeViewColumn* col_end = manage (new TreeViewColumn ("", _columns.end)); + col_end->set_fixed_width (bbt_width); + col_end->set_sizing (TREE_VIEW_COLUMN_FIXED); + TreeViewColumn* col_length = manage (new TreeViewColumn ("", _columns.length)); + col_length->set_fixed_width (bbt_width); + col_length->set_sizing (TREE_VIEW_COLUMN_FIXED); + TreeViewColumn* col_sync = manage (new TreeViewColumn ("", _columns.sync)); + col_sync->set_fixed_width (sync_width); + col_sync->set_sizing (TREE_VIEW_COLUMN_FIXED); + TreeViewColumn* col_fadein = manage (new TreeViewColumn ("", _columns.fadein)); + col_fadein->set_fixed_width (bbt_width); + col_fadein->set_sizing (TREE_VIEW_COLUMN_FIXED); + TreeViewColumn* col_fadeout = manage (new TreeViewColumn ("", _columns.fadeout)); + col_fadeout->set_fixed_width (bbt_width); + col_fadeout->set_sizing (TREE_VIEW_COLUMN_FIXED); + TreeViewColumn* col_locked = manage (new TreeViewColumn ("", _columns.locked)); + col_locked->set_fixed_width (check_width); + col_locked->set_sizing (TREE_VIEW_COLUMN_FIXED); + TreeViewColumn* col_glued = manage (new TreeViewColumn ("", _columns.glued)); + col_glued->set_fixed_width (check_width); + col_glued->set_sizing (TREE_VIEW_COLUMN_FIXED); + TreeViewColumn* col_muted = manage (new TreeViewColumn ("", _columns.muted)); + col_muted->set_fixed_width (check_width); + col_muted->set_sizing (TREE_VIEW_COLUMN_FIXED); + TreeViewColumn* col_opaque = manage (new TreeViewColumn ("", _columns.opaque)); + col_opaque->set_fixed_width (check_width); + col_opaque->set_sizing (TREE_VIEW_COLUMN_FIXED); + + _display.append_column (*col_name); + _display.append_column (*col_position); + _display.append_column (*col_end); + _display.append_column (*col_length); + _display.append_column (*col_sync); + _display.append_column (*col_fadein); + _display.append_column (*col_fadeout); + _display.append_column (*col_locked); + _display.append_column (*col_glued); + _display.append_column (*col_muted); + _display.append_column (*col_opaque); TreeViewColumn* col; Gtk::Label* l; @@ -122,19 +169,20 @@ EditorRegions::EditorRegions (Editor* e) { 10, S_("Opaque|O"), _("Region opaque (blocks regions below it from being heard)?") }, { -1, 0, 0 } }; - + for (int i = 0; ci[i].index >= 0; ++i) { col = _display.get_column (ci[i].index); l = manage (new Label (ci[i].label)); - ARDOUR_UI::instance()->set_tip (*l, ci[i].tooltip); + set_tooltip (*l, ci[i].tooltip); col->set_widget (*l); l->show (); if (ci[i].index > 6) { col->set_expand (false); col->set_alignment (ALIGN_CENTER); - } + } } + _display.set_model (_model); _display.set_headers_visible (true); _display.set_rules_hint (); @@ -185,6 +233,7 @@ EditorRegions::EditorRegions (Editor* e) _display.get_selection()->set_mode (SELECTION_MULTIPLE); _display.add_object_drag (_columns.region.index(), "regions"); + _display.set_drag_column (_columns.name.index()); /* setup DnD handling */ @@ -342,14 +391,14 @@ EditorRegions::add_region (boost::shared_ptr region) if (missing_source) { // c.set_rgb(65535,0,0); // FIXME: error color from style - set_color_from_rgba (c, ARDOUR_UI::config()->color ("region list missing source")); + set_color_from_rgba (c, UIConfiguration::instance().color ("region list missing source")); } else if (region->automatic()){ // c.set_rgb(0,65535,0); // FIXME: error color from style - set_color_from_rgba (c, ARDOUR_UI::config()->color ("region list automatic")); + set_color_from_rgba (c, UIConfiguration::instance().color ("region list automatic")); } else { - set_color_from_rgba (c, ARDOUR_UI::config()->color ("region list whole file")); + set_color_from_rgba (c, UIConfiguration::instance().color ("region list whole file")); } row[_columns.color_] = c; @@ -375,27 +424,19 @@ EditorRegions::add_region (boost::shared_ptr region) str = region->name(); } - if (region->n_channels() > 1) { - std::stringstream foo; - foo << region->n_channels (); - str += " ["; - str += foo.str(); - str += "]"; - } - - row[_columns.name] = str; + populate_row_name (region, row); row[_columns.region] = region; row[_columns.property_toggles_visible] = false; if (missing_source) { - row[_columns.path] = _("(MISSING) ") + region->source()->name(); + row[_columns.path] = _("(MISSING) ") + Gtkmm2ext::markup_escape_text (region->source()->name()); } else { boost::shared_ptr fs = boost::dynamic_pointer_cast(region->source()); if (fs) { - row[_columns.path] = fs->path(); + row[_columns.path] = Gtkmm2ext::markup_escape_text (fs->path()); } else { - row[_columns.path] = region->source()->name(); + row[_columns.path] = Gtkmm2ext::markup_escape_text (region->source()->name()); } } @@ -431,7 +472,7 @@ EditorRegions::add_region (boost::shared_ptr region) */ row = *(_model->insert (subrows.end())); - + } else { row = *(_model->append()); } @@ -567,7 +608,7 @@ EditorRegions::selection_changed () _change_connection.block (false); } } - + } } else { _editor->get_selection().clear_regions (); @@ -690,9 +731,15 @@ EditorRegions::format_position (framepos_t pos, char* buf, size_t bufsize, bool Timecode::BBT_Time bbt; Timecode::Time timecode; + if (pos < 0) { + error << string_compose (_("EditorRegions::format_position: negative timecode position: %1"), pos) << endmsg; + snprintf (buf, bufsize, "invalid"); + return; + } + switch (ARDOUR_UI::instance()->secondary_clock->mode ()) { case AudioClock::BBT: - _session->tempo_map().bbt_time (pos, bbt); + bbt = _session->tempo_map().bbt_at_frame (pos); if (onoff) { snprintf (buf, bufsize, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks); } else { @@ -816,10 +863,12 @@ EditorRegions::populate_row_end (boost::shared_ptr region, TreeModel::Ro row[_columns.end] = ""; } else if (used > 1) { row[_columns.end] = _("Mult."); - } else { + } else if (region->last_frame() >= region->first_frame()) { char buf[16]; format_position (region->last_frame(), buf, sizeof (buf)); row[_columns.end] = buf; + } else { + row[_columns.end] = "empty"; } } @@ -939,9 +988,9 @@ void EditorRegions::populate_row_name (boost::shared_ptr region, TreeModel::Row const &row) { if (region->n_channels() > 1) { - row[_columns.name] = string_compose("%1 [%2]", region->name(), region->n_channels()); + row[_columns.name] = string_compose("%1 [%2]", Gtkmm2ext::markup_escape_text (region->name()), region->n_channels()); } else { - row[_columns.name] = region->name(); + row[_columns.name] = Gtkmm2ext::markup_escape_text (region->name()); } } @@ -949,9 +998,9 @@ void EditorRegions::populate_row_source (boost::shared_ptr region, TreeModel::Row const &row) { if (boost::dynamic_pointer_cast(region->source())) { - row[_columns.path] = _("MISSING ") + region->source()->name(); + row[_columns.path] = _("MISSING ") + Gtkmm2ext::markup_escape_text (region->source()->name()); } else { - row[_columns.path] = region->source()->name(); + row[_columns.path] = Gtkmm2ext::markup_escape_text (region->source()->name()); } } @@ -1237,7 +1286,7 @@ EditorRegions::drag_data_received (const RefPtr& context, framepos_t pos = 0; bool copy = ((context->get_actions() & (Gdk::ACTION_COPY | Gdk::ACTION_LINK | Gdk::ACTION_MOVE)) == Gdk::ACTION_COPY); - if (Profile->get_sae() || ARDOUR_UI::config()->get_only_copy_imported_files() || copy) { + if (UIConfiguration::instance().get_only_copy_imported_files() || copy) { _editor->do_import (paths, Editing::ImportDistinctFiles, Editing::ImportAsRegion, SrcBest, pos); } else { _editor->do_embed (paths, Editing::ImportDistinctFiles, ImportAsRegion, pos); @@ -1269,7 +1318,7 @@ EditorRegions::selection_filter (const RefPtr& model, const TreeModel } void -EditorRegions::name_editing_started (CellEditable* ce, const Glib::ustring&) +EditorRegions::name_editing_started (CellEditable* ce, const Glib::ustring& path) { name_editable = ce; @@ -1279,6 +1328,15 @@ EditorRegions::name_editing_started (CellEditable* ce, const Glib::ustring&) if (e) { e->set_name (X_("RegionNameEditorEntry")); + + TreeIter iter; + if ((iter = _model->get_iter (path))) { + boost::shared_ptr region = (*iter)[_columns.region]; + + if(region) { + e->set_text(region->name()); + } + } } } @@ -1288,11 +1346,11 @@ EditorRegions::name_edit (const std::string& path, const std::string& new_text) name_editable = 0; boost::shared_ptr region; - TreeIter iter; + TreeIter row_iter; - if ((iter = _model->get_iter (path))) { - region = (*iter)[_columns.region]; - (*iter)[_columns.name] = new_text; + if ((row_iter = _model->get_iter (path))) { + region = (*row_iter)[_columns.region]; + (*row_iter)[_columns.name] = new_text; } /* now mapover everything */ @@ -1306,8 +1364,9 @@ EditorRegions::name_edit (const std::string& path, const std::string& new_text) (*i)->region()->set_name (new_text); } } - } + populate_row_name (region, (*row_iter)); + } } /** @return Region that has been dragged out of the list, or 0 */