X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=inline;f=gtk2_ardour%2Feditor_region_list.cc;h=bbcfb09a2902f2121aada484b5a531827c46d78b;hb=ce6c41c060c700489a9ac9fc5080bf2920c17ae2;hp=d610525e07c517cdcc4a25376243ec71fa2cfc5a;hpb=c1b2177d274b6e46202cf0b9ced20d845d21055a;p=ardour.git diff --git a/gtk2_ardour/editor_region_list.cc b/gtk2_ardour/editor_region_list.cc index d610525e07..bbcfb09a29 100644 --- a/gtk2_ardour/editor_region_list.cc +++ b/gtk2_ardour/editor_region_list.cc @@ -35,6 +35,7 @@ #include "ardour_ui.h" #include "gui_thread.h" #include "actions.h" +#include "utils.h" #include "i18n.h" @@ -44,151 +45,18 @@ using namespace Gtk; using namespace Glib; using namespace Editing; -#define wave_cursor_width 43 -#define wave_cursor_height 61 -#define wave_cursor_x_hot 0 -#define wave_cursor_y_hot 25 -static const gchar wave_cursor_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, -0x03, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, -0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, -0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, -0x02, - 0x02, 0x04, 0x00, 0x00, 0x00, 0x02, 0x02, 0x04, 0x00, 0x04, 0x00, -0x02, - 0x02, 0x04, 0x00, 0x04, 0x00, 0x02, 0x02, 0x0c, 0x08, 0x0c, 0x00, -0x02, - 0x02, 0x1c, 0x08, 0x0c, 0x00, 0x02, 0x02, 0x1c, 0x08, 0x0c, 0x04, -0x02, - 0x02, 0x3c, 0x18, 0x0c, 0x04, 0x02, 0x02, 0x7c, 0x18, 0x1c, 0x0c, -0x02, - 0x82, 0xfc, 0x38, 0x1c, 0x0c, 0x02, 0xc2, 0xfc, 0x78, 0x3c, 0x1c, -0x02, - 0xe2, 0xfd, 0xf9, 0x7d, 0x1c, 0x02, 0xf2, 0xff, 0xfb, 0xff, 0x1c, -0x02, - 0xfa, 0xff, 0xfb, 0xff, 0x3f, 0x02, 0xfe, 0xff, 0xff, 0xff, 0xff, -0x03, - 0xfe, 0xff, 0xff, 0xff, 0xff, 0x03, 0xfa, 0xff, 0xff, 0xff, 0x3f, -0x02, - 0xf2, 0xff, 0xfb, 0xfd, 0x3c, 0x02, 0xe2, 0xfd, 0x7b, 0x7c, 0x1c, -0x02, - 0xc2, 0xfc, 0x39, 0x3c, 0x1c, 0x02, 0x82, 0xfc, 0x18, 0x1c, 0x1c, -0x02, - 0x02, 0xfc, 0x18, 0x1c, 0x0c, 0x02, 0x02, 0x7c, 0x18, 0x0c, 0x0c, -0x02, - 0x02, 0x3c, 0x08, 0x0c, 0x04, 0x02, 0x02, 0x1c, 0x08, 0x0c, 0x04, -0x02, - 0x02, 0x1c, 0x08, 0x0c, 0x00, 0x02, 0x02, 0x0c, 0x00, 0x04, 0x00, -0x02, - 0x02, 0x04, 0x00, 0x04, 0x00, 0x02, 0x02, 0x04, 0x00, 0x00, 0x00, -0x02, - 0x02, 0x04, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, -0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, -0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, -0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0xff, 0xff, 0xff, 0xff, -0x03, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -#define wave_cursor_mask_width 43 -#define wave_cursor_mask_height 61 -#define wave_cursor_mask_x_hot 0 -#define wave_cursor_mask_y_hot 25 -static const gchar wave_cursor_mask_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, -0x00, - 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0c, 0x08, 0x0c, 0x00, -0x00, - 0x00, 0x1c, 0x08, 0x0c, 0x00, 0x00, 0x00, 0x1c, 0x08, 0x0c, 0x04, -0x00, - 0x00, 0x3c, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x7c, 0x18, 0x1c, 0x0c, -0x00, - 0x80, 0xfc, 0x38, 0x1c, 0x0c, 0x00, 0xc0, 0xfc, 0x78, 0x3c, 0x1c, -0x00, - 0xe0, 0xfd, 0xf9, 0x7d, 0x1c, 0x00, 0xf0, 0xff, 0xfb, 0xff, 0x1c, -0x00, - 0xf8, 0xff, 0xfb, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, -0x07, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xf8, 0xff, 0xff, 0xff, 0x3f, -0x00, - 0xf0, 0xff, 0xfb, 0xfd, 0x3c, 0x00, 0xe0, 0xfd, 0x7b, 0x7c, 0x1c, -0x00, - 0xc0, 0xfc, 0x39, 0x3c, 0x1c, 0x00, 0x80, 0xfc, 0x18, 0x1c, 0x1c, -0x00, - 0x00, 0xfc, 0x18, 0x1c, 0x0c, 0x00, 0x00, 0x7c, 0x18, 0x0c, 0x0c, -0x00, - 0x00, 0x3c, 0x08, 0x0c, 0x04, 0x00, 0x00, 0x1c, 0x08, 0x0c, 0x04, -0x00, - 0x00, 0x1c, 0x08, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x04, 0x00, -0x00, - 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - -GdkCursor *wave_cursor = 0; - void -Editor::handle_audio_region_removed (AudioRegion* ignored) +Editor::handle_audio_region_removed (AudioRegion* region) { + ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_audio_region_removed), region)); redisplay_regions (); } void Editor::handle_new_audio_region (AudioRegion *region) { + ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_audio_region), region)); + /* don't copy region - the one we are being notified about belongs to the session, and so it will never be edited. @@ -209,6 +77,7 @@ Editor::add_audio_region_to_region_display (AudioRegion *region) { string str; TreeModel::Row row; + Gdk::Color c; if (!show_automatic_regions_in_region_list && region->automatic()) { return; @@ -216,7 +85,7 @@ Editor::add_audio_region_to_region_display (AudioRegion *region) if (region->hidden()) { - TreeModel::iterator iter = region_list_model->get_iter (_("/Hidden")); + TreeModel::iterator iter = region_list_model->get_iter ("0"); TreeModel::Row parent; TreeModel::Row child; @@ -226,21 +95,35 @@ Editor::add_audio_region_to_region_display (AudioRegion *region) parent[region_list_columns.name] = _("Hidden"); parent[region_list_columns.region] = 0; + } else { - parent = *iter; + + if ((*iter)[region_list_columns.name] != _("Hidden")) { + + parent = *(region_list_model->insert(iter)); + parent[region_list_columns.name] = _("Hidden"); + parent[region_list_columns.region] = 0; + + } else { + parent = *iter; + } + } row = *(region_list_model->append (parent.children())); } else if (region->whole_file()) { - TreeModel::Row row = *(region_list_model->append()); + row = *(region_list_model->append()); + set_color(c, rgba_from_style ("RegionListWholeFile", 0xff, 0, 0, 0, "fg", Gtk::STATE_NORMAL, false )); + row[region_list_columns.color_] = c; if (region->source().name()[0] == '/') { // external file if (region->whole_file()) { str = ".../"; str += PBD::basename_nosuffix (region->source().name()); + } else { str = region->name(); } @@ -270,7 +153,6 @@ Editor::add_audio_region_to_region_display (AudioRegion *region) AudioRegion* r = dynamic_cast(rr); if (r && r->whole_file()) { - if (region->source_equivalent (*r)) { row = *(region_list_model->append ((*i).children())); found_parent = true; @@ -316,7 +198,7 @@ Editor::region_list_selection_changed() */ if ((iter = region_list_model->get_iter (*i))) { - set_selected_regionview_from_region_list (*((*iter)[region_list_columns.region]), false); + set_selected_regionview_from_region_list (*((*iter)[region_list_columns.region]), Selection::Set); } } } @@ -369,21 +251,30 @@ Editor::build_region_list_menu () /* now grab specific menu items that we need */ - toggle_full_region_list_action = ActionManager::get_action (X_("RegionList"), X_("rlShowAll")); + Glib::RefPtr act; + + act = ActionManager::get_action (X_("RegionList"), X_("rlShowAll")); + if (act) { + toggle_full_region_list_action = Glib::RefPtr::cast_dynamic (act); + } + + act = ActionManager::get_action (X_("RegionList"), X_("rlShowAuto")); + if (act) { + toggle_show_auto_regions_action = Glib::RefPtr::cast_dynamic (act); + } } void Editor::toggle_show_auto_regions () { - //show_automatic_regions_in_region_list = toggle_auto_regions_item->get_active(); - show_automatic_regions_in_region_list = true; + show_automatic_regions_in_region_list = toggle_show_auto_regions_action->get_active(); redisplay_regions (); } void Editor::toggle_full_region_list () { - if (toggle_full_region_list_item->get_active()) { + if (toggle_full_region_list_action->get_active()) { region_list_display.expand_all (); } else { region_list_display.collapse_all (); @@ -437,8 +328,6 @@ Editor::region_list_display_button_press (GdkEventButton *ev) int cellx; int celly; - cerr << "RL button press\n"; - if (region_list_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) { if ((iter = region_list_model->get_iter (path))) { region = (*iter)[region_list_columns.region]; @@ -491,9 +380,7 @@ Editor::region_list_display_button_release (GdkEventButton *ev) TreeViewColumn* column; int cellx; int celly; - Region* region; - - cerr << "RL button release\n"; + Region* region = 0; if (region_list_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) { if ((iter = region_list_model->get_iter (path))) { @@ -501,24 +388,11 @@ Editor::region_list_display_button_release (GdkEventButton *ev) } } - if (Keyboard::is_delete_event (ev)) { + if (region && Keyboard::is_delete_event (ev)) { session->remove_region_from_region_list (*region); return true; } - switch (ev->button) { - case 1: - return false; - break; - - case 3: - return false; - break; - - default: - break; - } - return false; } @@ -546,11 +420,21 @@ Editor::consider_auditioning (Region& region) int Editor::region_list_sorter (TreeModel::iterator a, TreeModel::iterator b) { - int cmp; + int cmp = 0; Region* r1 = (*a)[region_list_columns.region]; Region* r2 = (*b)[region_list_columns.region]; + /* handle rows without regions, like "Hidden" */ + + if (r1 == 0) { + return -1; + } + + if (r2 == 0) { + return 1; + } + AudioRegion* region1 = dynamic_cast (r1); AudioRegion* region2 = dynamic_cast (r2); @@ -627,14 +511,14 @@ Editor::reset_region_list_sort_type (RegionListSortType type) { if (type != region_list_sort_type) { region_list_sort_type = type; - region_list_sort_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter)); + region_list_model->set_sort_func (0, (mem_fun (*this, &Editor::region_list_sorter))); } } void Editor::reset_region_list_sort_direction (bool up) { - // region_list_display.set_sort_type (up ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING); + region_list_model->set_sort_column (0, up ? SORT_ASCENDING : SORT_DESCENDING); } void @@ -693,10 +577,19 @@ Editor::region_list_display_drag_data_received (const RefPtr& const SelectionData& data, guint info, guint time) { - vector paths; + vector paths; if (convert_drop_to_paths (paths, context, x, y, data, info, time) == 0) { - do_embed_sndfiles (paths, false); + jack_nframes_t pos = 0; + do_embed (paths, false, ImportAsRegion, 0, pos, true); context->drag_finish (true, false, time); } } + +bool +Editor::region_list_selection_filter (const RefPtr& model, const TreeModel::Path& path, bool yn) +{ + /* not possible to select rows that do not represent regions, like "Hidden" */ + + return (*(model->get_iter (path)))[region_list_columns.region] != 0; +}