From: Paul Davis Date: Mon, 8 Jan 2007 17:12:29 +0000 (+0000) Subject: save and restore clock modes X-Git-Tag: 2.0beta11~32 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=57bafcd1f4277ba9805bfb4ed05b8eaffaa7a5ce;hp=caa89c121d8c133d679047d9c21adbb7d139d9a3;p=ardour.git save and restore clock modes git-svn-id: svn://localhost/ardour2/trunk@1283 d708f5d6-7413-0410-9779-e7cbd77b26cf --- diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index e47acd1e2f..8d7e48bc1b 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -93,10 +93,10 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile) : Gtkmm2ext::UI ("ardour", argcp, argvp, rcfile), - primary_clock (X_("TransportClockDisplay"), true, false, true), - secondary_clock (X_("SecondaryClockDisplay"), true, false, true), - preroll_clock (X_("PreRollClock"), true, true), - postroll_clock (X_("PostRollClock"), true, true), + primary_clock (X_("primary"), false, X_("TransportClockDisplay"), true, false, true), + secondary_clock (X_("secondary"), false, X_("SecondaryClockDisplay"), true, false, true), + preroll_clock (X_("preroll"), false, X_("PreRollClock"), true, true), + postroll_clock (X_("postroll"), false, X_("PostRollClock"), true, true), /* adjuster table */ @@ -109,7 +109,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile) /* big clock */ - big_clock ("BigClockNonRecording", true, false, true), + big_clock (X_("bigclock"), false, "BigClockNonRecording", true, false, true), /* transport */ @@ -248,6 +248,10 @@ ARDOUR_UI::set_engine (AudioEngine& e) throw failed_constructor(); } + /* listen to clock mode changes */ + + AudioClock::ModeChanged.connect (mem_fun (*this, &ARDOUR_UI::store_clock_modes)); + /* start the time-of-day-clock */ update_wall_clock (); @@ -1803,9 +1807,8 @@ ARDOUR_UI::load_session (const string & path, const string & snap_name, string* /* if it already exists, we must have write access */ if (::access (path.c_str(), F_OK) == 0 && ::access (path.c_str(), W_OK)) { - MessageDialog msg (*editor, _("\ -You do not have write access to this session.\n\ -This prevents the session from being loaded.")); + MessageDialog msg (*editor, _("You do not have write access to this session.\n" + "This prevents the session from being loaded.")); msg.run (); return -1; } @@ -2436,30 +2439,13 @@ ARDOUR_UI::store_clock_modes () { XMLNode* node = new XMLNode(X_("ClockModes")); - node->add_property (X_("primary"), enum_2_string (primary_clock.mode())); - node->add_property (X_("secondary"), enum_2_string (secondary_clock.mode())); + for (vector::iterator x = AudioClock::clocks.begin(); x != AudioClock::clocks.end(); ++x) { + node->add_property ((*x)->name().c_str(), enum_2_string ((*x)->mode())); + } session->add_extra_xml (*node); session->set_dirty (); } -void -ARDOUR_UI::restore_clock_modes () -{ - XMLProperty* prop; - XMLNode * node = session->extra_xml (X_("ClockModes")); - AudioClock::Mode mode; - - if (node) { - if ((prop = node->property ("primary")) != 0) { - mode = AudioClock::Mode (string_2_enum (prop->value(), mode)); - primary_clock.set_mode (mode); - } - if ((prop = node->property ("secondary")) != 0) { - mode = AudioClock::Mode (string_2_enum (prop->value(), mode)); - secondary_clock.set_mode (mode); - } - } -} diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 39af8bee7d..7ad7e4df65 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -22,6 +22,7 @@ #include #include +#include #include @@ -40,10 +41,14 @@ using namespace ARDOUR; using namespace PBD; using namespace sigc; using namespace Gtk; +using namespace std; using PBD::atoi; using PBD::atof; +sigc::signal AudioClock::ModeChanged; +vector AudioClock::clocks; + const uint32_t AudioClock::field_length[(int) AudioClock::AudioFrames+1] = { 2, /* SMPTE_Hours */ 2, /* SMPTE_Minutes */ @@ -58,8 +63,10 @@ const uint32_t AudioClock::field_length[(int) AudioClock::AudioFrames+1] = { 10 /* Audio Frame */ }; -AudioClock::AudioClock (std::string name, bool allow_edit, bool duration, bool with_info) - : is_duration (duration), +AudioClock::AudioClock (std::string clock_name, bool transient, std::string widget_name, bool allow_edit, bool duration, bool with_info) + : _name (clock_name), + is_transient (transient), + is_duration (duration), editable (allow_edit), colon1 (":"), colon2 (":"), @@ -177,7 +184,7 @@ AudioClock::AudioClock (std::string name, bool allow_edit, bool duration, bool w clock_frame.add (clock_base); - set_name (name); + set_widget_name (widget_name); _mode = BBT; /* lie to force mode switch */ set_mode (SMPTE); @@ -205,10 +212,14 @@ AudioClock::AudioClock (std::string name, bool allow_edit, bool duration, bool w } set (last_when, true); + + if (!is_transient) { + clocks.push_back (this); + } } void -AudioClock::set_name (string name) +AudioClock::set_widget_name (string name) { Widget::set_name (name); @@ -533,10 +544,10 @@ AudioClock::set_smpte (nframes_t when, bool force) } if (smpte_upper_info_label) { - float smpte_frames = session->smpte_frames_per_second(); + double smpte_frames = session->smpte_frames_per_second(); if ( fmod(smpte_frames, 1.0) == 0.0) { - sprintf (buf, "%u", int (smpte_frames)); + sprintf (buf, "%u", int (smpte_frames)); } else { sprintf (buf, "%.2f", smpte_frames); } @@ -582,6 +593,18 @@ AudioClock::set_session (Session *s) session = s; if (s) { + + XMLProperty* prop; + XMLNode* node = session->extra_xml (X_("ClockModes")); + AudioClock::Mode amode; + + if (node) { + if ((prop = node->property (_name.c_str())) != 0) { + amode = AudioClock::Mode (string_2_enum (prop->value(), amode)); + set_mode (amode); + } + } + set (last_when, true); } } @@ -1861,6 +1884,10 @@ AudioClock::set_mode (Mode m) set (last_when, true); clock_base.show_all (); key_entry_state = 0; + + if (!is_transient) { + ModeChanged (); /* EMIT SIGNAL */ + } } void diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h index cef5a1b524..662cb949e6 100644 --- a/gtk2_ardour/audio_clock.h +++ b/gtk2_ardour/audio_clock.h @@ -43,25 +43,32 @@ class AudioClock : public Gtk::HBox Off }; - AudioClock (std::string name, bool editable, bool is_duration = false, bool with_info = false); + AudioClock (std::string clock_name, bool transient, std::string widget_name, bool editable, bool is_duration = false, bool with_info = false); Mode mode() const { return _mode; } void set (nframes_t, bool force = false); void set_mode (Mode); - void set_name (std::string); + void set_widget_name (std::string); + + std::string name() const { return _name; } nframes_t current_time (nframes_t position = 0) const; nframes_t current_duration (nframes_t position = 0) const; void set_session (ARDOUR::Session *s); sigc::signal ValueChanged; - + + static sigc::signal ModeChanged; + static std::vector clocks; + private: ARDOUR::Session *session; Mode _mode; uint32_t key_entry_state; + std::string _name; + bool is_transient; bool is_duration; bool editable; diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc index 3ce8c76d2e..b7106a0796 100644 --- a/gtk2_ardour/audio_region_editor.cc +++ b/gtk2_ardour/audio_region_editor.cc @@ -47,10 +47,10 @@ AudioRegionEditor::AudioRegionEditor (Session& s, boost::shared_ptr name_label (_("NAME:")), audition_button (_("play")), time_table (3, 2), - start_clock ("AudioRegionEditorClock", true), - end_clock ("AudioRegionEditorClock", true), - length_clock ("AudioRegionEditorClock", true, true), - sync_offset_clock ("AudioRegionEditorClock", true, true) + start_clock (X_("regionstart"), true, X_("AudioRegionEditorClock"), true), + end_clock (X_("regionend"), true, X_("AudioRegionEditorClock"), true), + length_clock (X_("regionlength"), true, X_("AudioRegionEditorClock"), true, true), + sync_offset_clock (X_("regionsyncoffset"), true, X_("AudioRegionEditorClock"), true, true) { start_clock.set_session (&_session); diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 1f3b9910a0..5c2acc8a2a 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -196,8 +196,8 @@ Editor::Editor (AudioEngine& eng) /* tool bar related */ - edit_cursor_clock (X_("EditCursorClock"), true), - zoom_range_clock (X_("ZoomRangeClock"), true, true), + edit_cursor_clock (X_("editcursor"), false, X_("EditCursorClock"), true), + zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true), toolbar_selection_clock_table (2,3), @@ -210,7 +210,7 @@ Editor::Editor (AudioEngine& eng) /* nudge */ - nudge_clock (X_("NudgeClock"), true, true) + nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true) { constructed = false; @@ -283,6 +283,7 @@ Editor::Editor (AudioEngine& eng) route_list_menu = 0; region_list_menu = 0; marker_menu = 0; + start_end_marker_menu = 0; range_marker_menu = 0; marker_menu_item = 0; tm_marker_menu = 0; diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index e64ccf461d..68b5bd256e 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -982,6 +982,8 @@ class Editor : public PublicEditor void clear_markers (); void clear_ranges (); void clear_locations (); + void unhide_markers (); + void unhide_ranges (); void jump_forward_to_mark (); void jump_backward_to_mark (); void cursor_align (bool playhead_to_edit); @@ -1218,14 +1220,14 @@ class Editor : public PublicEditor void tm_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*); void transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*); void new_transport_marker_context_menu (GdkEventButton*, ArdourCanvas::Item*); - void build_range_marker_menu (); - void build_marker_menu (); + void build_range_marker_menu (bool loop_or_punch); + void build_marker_menu (bool start_or_end); void build_tm_marker_menu (); - void build_transport_marker_menu (); void build_new_transport_marker_menu (); Gtk::Menu* tm_marker_menu; Gtk::Menu* marker_menu; + Gtk::Menu* start_end_marker_menu; Gtk::Menu* range_marker_menu; Gtk::Menu* transport_marker_menu; Gtk::Menu* new_transport_marker_menu; diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index ed49235a40..5415ffa9cf 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -333,7 +333,7 @@ Editor::track_canvas_idle () if (playhead_cursor) playhead_cursor->set_length (canvas_height); if (marker_drag_line) { - marker_drag_line_points.back().set_x(canvas_height); + marker_drag_line_points.back().set_y(canvas_height); marker_drag_line->property_points() = marker_drag_line_points; } diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 29b57e449a..238a45c4d1 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -288,8 +288,10 @@ Editor::LocationMarkers::set_color_rgba (uint32_t rgba) void Editor::mouse_add_new_marker (nframes_t where) { + string markername; if (session) { - Location *location = new Location (where, where, "mark", Location::IsMark); + session->locations()->next_available_name(markername,"mark"); + Location *location = new Location (where, where, markername, Location::IsMark); session->begin_reversible_command (_("add marker")); XMLNode &before = session->locations()->get_state(); session->locations()->add (location, true); @@ -313,17 +315,7 @@ Editor::remove_marker (ArdourCanvas::Item& item, GdkEvent* event) Location* loc = find_location_from_marker (marker, is_start); if (session && loc) { - if (loc->is_end()) { - /* you can't hide or delete this marker */ - return; - } - if (loc->is_auto_loop() || loc->is_auto_punch()) { - // just hide them - loc->set_hidden (true, this); - } - else { - Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::really_remove_marker), loc)); - } + Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::really_remove_marker), loc)); } } @@ -388,16 +380,24 @@ Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item) Location * loc = find_location_from_marker (marker, is_start); if (loc == transport_loop_location() || loc == transport_punch_location()) { if (transport_marker_menu == 0) { - build_transport_marker_menu (); + build_range_marker_menu (true); } marker_menu_item = item; transport_marker_menu->popup (1, ev->time); } else { if (loc->is_mark()) { - if (marker_menu == 0) { - build_marker_menu (); - } + bool start_or_end = loc->is_start() || loc->is_end(); + Menu *markerMenu; + if (start_or_end) { + if (start_end_marker_menu == 0) + build_marker_menu (true); + markerMenu = start_end_marker_menu; + } else { + if (marker_menu == 0) + build_marker_menu (false); + markerMenu = marker_menu; + } // GTK2FIX use action group sensitivity @@ -415,12 +415,12 @@ Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item) } #endif marker_menu_item = item; - marker_menu->popup (1, ev->time); + markerMenu->popup (1, ev->time); } if (loc->is_range_marker()) { if (range_marker_menu == 0){ - build_range_marker_menu (); + build_range_marker_menu (false); } marker_menu_item = item; range_marker_menu->popup (1, ev->time); @@ -443,20 +443,25 @@ void Editor::transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item) { if (transport_marker_menu == 0) { - build_transport_marker_menu (); + build_range_marker_menu (true); } transport_marker_menu->popup (1, ev->time); } void -Editor::build_marker_menu () +Editor::build_marker_menu (bool start_or_end) { using namespace Menu_Helpers; - marker_menu = new Menu; - MenuList& items = marker_menu->items(); - marker_menu->set_name ("ArdourContextMenu"); + Menu *markerMenu = new Menu; + if (start_or_end) { + start_end_marker_menu = markerMenu; + } else { + marker_menu = markerMenu; + } + MenuList& items = markerMenu->items(); + markerMenu->set_name ("ArdourContextMenu"); items.push_back (MenuElem (_("Locate to Mark"), mem_fun(*this, &Editor::marker_menu_set_playhead))); items.push_back (MenuElem (_("Play from Mark"), mem_fun(*this, &Editor::marker_menu_play_from))); @@ -464,33 +469,43 @@ Editor::build_marker_menu () items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Rename Mark"), mem_fun(*this, &Editor::marker_menu_rename))); items.push_back (MenuElem (_("Hide Mark"), mem_fun(*this, &Editor::marker_menu_hide))); + if (start_or_end) return; + items.push_back (MenuElem (_("Rename Mark"), mem_fun(*this, &Editor::marker_menu_rename))); items.push_back (MenuElem (_("Remove Mark"), mem_fun(*this, &Editor::marker_menu_remove))); } void -Editor::build_range_marker_menu () +Editor::build_range_marker_menu (bool loop_or_punch) { using namespace Menu_Helpers; - range_marker_menu = new Menu; - MenuList& items = range_marker_menu->items(); - range_marker_menu->set_name ("ArdourContextMenu"); + Menu *markerMenu = new Menu; + if (loop_or_punch) { + transport_marker_menu = markerMenu; + } else { + range_marker_menu = markerMenu; + } + MenuList& items = markerMenu->items(); + markerMenu->set_name ("ArdourContextMenu"); items.push_back (MenuElem (_("Locate to Range Mark"), mem_fun(*this, &Editor::marker_menu_set_playhead))); items.push_back (MenuElem (_("Play from Range Mark"), mem_fun(*this, &Editor::marker_menu_play_from))); - items.push_back (MenuElem (_("Play Range"), mem_fun(*this, &Editor::marker_menu_play_range))); - items.push_back (MenuElem (_("Loop Range"), mem_fun(*this, &Editor::marker_menu_loop_range))); + if (! loop_or_punch) { + items.push_back (MenuElem (_("Play Range"), mem_fun(*this, &Editor::marker_menu_play_range))); + items.push_back (MenuElem (_("Loop Range"), mem_fun(*this, &Editor::marker_menu_loop_range))); + } items.push_back (MenuElem (_("Set Range Mark from Playhead"), mem_fun(*this, &Editor::marker_menu_set_from_playhead))); items.push_back (MenuElem (_("Set Range from Range Selection"), mem_fun(*this, &Editor::marker_menu_set_from_selection))); items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Rename Range"), mem_fun(*this, &Editor::marker_menu_rename))); items.push_back (MenuElem (_("Hide Range"), mem_fun(*this, &Editor::marker_menu_hide))); - items.push_back (MenuElem (_("Remove Range"), mem_fun(*this, &Editor::marker_menu_remove))); + if (! loop_or_punch) { + items.push_back (MenuElem (_("Rename Range"), mem_fun(*this, &Editor::marker_menu_rename))); + items.push_back (MenuElem (_("Remove Range"), mem_fun(*this, &Editor::marker_menu_remove))); + } items.push_back (SeparatorElem()); @@ -527,26 +542,6 @@ Editor::build_new_transport_marker_menu () new_transport_marker_menu->signal_unmap_event().connect ( mem_fun(*this, &Editor::new_transport_marker_menu_popdown)); } -void -Editor::build_transport_marker_menu () -{ - using namespace Menu_Helpers; - - transport_marker_menu = new Menu; - MenuList& items = transport_marker_menu->items(); - transport_marker_menu->set_name ("ArdourContextMenu"); - - items.push_back (MenuElem (_("Locate to Range Mark"), mem_fun(*this, &Editor::marker_menu_set_playhead))); - items.push_back (MenuElem (_("Play from Range Mark"), mem_fun(*this, &Editor::marker_menu_play_from))); - items.push_back (MenuElem (_("Set Range Mark from Playhead"), mem_fun(*this, &Editor::marker_menu_set_from_playhead))); - items.push_back (MenuElem (_("Set Range from Range Selection"), mem_fun(*this, &Editor::marker_menu_set_from_selection))); - items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Hide Range"), mem_fun(*this, &Editor::marker_menu_hide))); - items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Separate Regions in Range"), mem_fun(*this, &Editor::marker_menu_separate_regions_using_location))); - items.push_back (MenuElem (_("Select All in Range"), mem_fun(*this, &Editor::marker_menu_select_all_selectables_using_range))); -} - void Editor::marker_menu_hide () { diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 78867bba25..61a0fdd420 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -4472,6 +4472,7 @@ void Editor::end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event) { Location * newloc = 0; + string rangename; if (!drag_info.first_move) { drag_range_markerbar_op (item, event); @@ -4481,7 +4482,8 @@ Editor::end_range_markerbar_op (ArdourCanvas::Item* item, GdkEvent* event) { begin_reversible_command (_("new range marker")); XMLNode &before = session->locations()->get_state(); - newloc = new Location(temp_location->start(), temp_location->end(), "unnamed", Location::IsRangeMarker); + session->locations()->next_available_name(rangename,"unnamed"); + newloc = new Location(temp_location->start(), temp_location->end(), rangename, Location::IsRangeMarker); session->locations()->add (newloc, true); XMLNode &after = session->locations()->get_state(); session->add_command(new MementoCommand(*(session->locations()), &before, &after)); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index ddcf02911a..e4de1c1e2e 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1197,6 +1197,8 @@ Editor::temporal_zoom_to_frame (bool coarser, nframes_t frame) void Editor::add_location_from_selection () { + string rangename; + if (selection->time.empty()) { return; } @@ -1208,7 +1210,8 @@ Editor::add_location_from_selection () nframes_t start = selection->time[clicked_selection].start; nframes_t end = selection->time[clicked_selection].end; - Location *location = new Location (start, end, "selection", Location::IsRangeMarker); + session->locations()->next_available_name(rangename,"selection"); + Location *location = new Location (start, end, rangename, Location::IsRangeMarker); session->begin_reversible_command (_("add marker")); XMLNode &before = session->locations()->get_state(); @@ -1221,9 +1224,12 @@ Editor::add_location_from_selection () void Editor::add_location_from_playhead_cursor () { + string markername; + nframes_t where = session->audible_frame(); - Location *location = new Location (where, where, "mark", Location::IsMark); + session->locations()->next_available_name(markername,"mark"); + Location *location = new Location (where, where, markername, Location::IsMark); session->begin_reversible_command (_("add marker")); XMLNode &before = session->locations()->get_state(); session->locations()->add (location, true); @@ -1649,6 +1655,7 @@ Editor::set_mark () nframes_t pos; float prefix; bool was_floating; + string markername; if (get_prefix (prefix, was_floating)) { pos = session->audible_frame (); @@ -1660,7 +1667,8 @@ Editor::set_mark () } } - session->locations()->add (new Location (pos, 0, "mark", Location::IsMark), true); + session->locations()->next_available_name(markername,"mark"); + session->locations()->add (new Location (pos, 0, markername, Location::IsMark), true); } void @@ -1709,6 +1717,28 @@ Editor::clear_locations () session->locations()->clear (); } +void +Editor::unhide_markers () +{ + for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) { + Location *l = (*i).first; + if (l->is_hidden() && l->is_mark()) { + l->set_hidden(false, this); + } + } +} + +void +Editor::unhide_ranges () +{ + for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) { + Location *l = (*i).first; + if (l->is_hidden() && l->is_range_marker()) { + l->set_hidden(false, this); + } + } +} + /* INSERT/REPLACE */ void diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc index 8e1a65b856..7f6ac56d5b 100644 --- a/gtk2_ardour/editor_rulers.cc +++ b/gtk2_ardour/editor_rulers.cc @@ -337,11 +337,13 @@ Editor::popup_ruler_menu (nframes_t where, ItemType t) case MarkerBarItem: ruler_items.push_back (MenuElem (_("New location marker"), bind ( mem_fun(*this, &Editor::mouse_add_new_marker), where))); ruler_items.push_back (MenuElem (_("Clear all locations"), mem_fun(*this, &Editor::clear_markers))); + ruler_items.push_back (MenuElem (_("Unhide locations"), mem_fun(*this, &Editor::unhide_markers))); ruler_items.push_back (SeparatorElem ()); break; case RangeMarkerBarItem: //ruler_items.push_back (MenuElem (_("New Range"))); ruler_items.push_back (MenuElem (_("Clear all ranges"), mem_fun(*this, &Editor::clear_ranges))); + ruler_items.push_back (MenuElem (_("Unhide ranges"), mem_fun(*this, &Editor::unhide_ranges))); ruler_items.push_back (SeparatorElem ()); break; diff --git a/gtk2_ardour/location_ui.cc b/gtk2_ardour/location_ui.cc index 4eea862ea4..b77c3a5561 100644 --- a/gtk2_ardour/location_ui.cc +++ b/gtk2_ardour/location_ui.cc @@ -48,11 +48,11 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num) item_table (1, 7, false), start_set_button (_("Set")), start_go_button (_("Go")), - start_clock (X_("LocationEditRowClock"), true), + start_clock (X_("locationstart"), true, X_("LocationEditRowClock"), true), end_set_button (_("Set")), end_go_button (_("Go")), - end_clock (X_("LocationEditRowClock"), true), - length_clock (X_("LocationEditRowClock"), true, true), + end_clock (X_("locationend"), true, X_("LocationEditRowClock"), true), + length_clock (X_("locationlength"), true, X_("LocationEditRowClock"), true, true), cd_check_button (_("CD")), hide_check_button (_("Hidden")), remove_button (_("Remove")), @@ -215,7 +215,7 @@ LocationEditRow::set_location (Location *loc) } hide_check_button.set_active (location->is_hidden()); - if (location->is_auto_loop() || location->is_auto_punch()) { + if (location->is_auto_loop() || location-> is_auto_punch()) { // use label instead of entry name_label.set_text (location->name()); @@ -770,9 +770,12 @@ LocationUI::map_locations (Locations::LocationList& locations) void LocationUI::add_new_location() { + string markername; + if (session) { nframes_t where = session->audible_frame(); - Location *location = new Location (where, where, "mark", Location::IsMark); + session->locations()->next_available_name(markername,"mark"); + Location *location = new Location (where, where, markername, Location::IsMark); session->begin_reversible_command (_("add marker")); XMLNode &before = session->locations()->get_state(); session->locations()->add (location, true); @@ -786,10 +789,12 @@ LocationUI::add_new_location() void LocationUI::add_new_range() { + string rangename; + if (session) { nframes_t where = session->audible_frame(); - Location *location = new Location (where, where, "unnamed", - Location::IsRangeMarker); + session->locations()->next_available_name(rangename,"unnamed"); + Location *location = new Location (where, where, rangename, Location::IsRangeMarker); session->begin_reversible_command (_("add range marker")); XMLNode &before = session->locations()->get_state(); session->locations()->add (location, true); diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index 78be61231c..9977dab79f 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -320,8 +320,9 @@ maybe_load_session () /* Loading a session, but the session doesn't exist */ if (isnew) { - error << string_compose (_("\n\nNo session named \"%1\" exists.\n\ -To create it from the command line, start ardour as \"ardour --new %1"), path) << endmsg; + error << string_compose (_("\n\nNo session named \"%1\" exists.\n" + "To create it from the command line, start ardour as \"ardour --new %1"), path) + << endmsg; return false; } @@ -362,14 +363,15 @@ int main (int argc, char *argv[]) ARDOUR::AudioEngine *engine; vector null_file_list; + Glib::thread_init(); gtk_set_locale (); - (void) bindtextdomain (PACKAGE, LOCALEDIR); + (void) bindtextdomain (PACKAGE, LOCALEDIR); (void) textdomain (PACKAGE); pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0); - // catch_signals (); + // catch error message system signals (); text_receiver.listen_to (error); text_receiver.listen_to (info); @@ -409,9 +411,6 @@ int main (int argc, char *argv[]) << endl; } - // needs a better home. - Glib::thread_init(); - try { ui = new ARDOUR_UI (&argc, &argv, which_ui_rcfile()); } catch (failed_constructor& err) { diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc index 811c37937c..1c76f8079b 100644 --- a/gtk2_ardour/option_editor.cc +++ b/gtk2_ardour/option_editor.cc @@ -69,7 +69,7 @@ OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui) /* Sync */ - smpte_offset_clock (X_("SMPTEOffsetClock"), true, true), + smpte_offset_clock (X_("smpteoffset"), false, X_("SMPTEOffsetClock"), true, true), smpte_offset_negative_button (_("SMPTE offset is negative")), /* MIDI */ diff --git a/libs/ardour/ardour/location.h b/libs/ardour/ardour/location.h index b0a7d11ef2..57e13de5af 100644 --- a/libs/ardour/ardour/location.h +++ b/libs/ardour/ardour/location.h @@ -153,6 +153,7 @@ class Locations : public PBD::StatefulDestructible Location* end_location() const; Location* start_location() const; + int next_available_name(string& result,string base); uint32_t num_range_markers() const; int set_current (Location *, bool want_lock = true); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index e550575ab1..ae4a64802f 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -392,6 +392,7 @@ class Session : public PBD::StatefulDestructible void set_auto_punch_location (Location *); void set_auto_loop_location (Location *); + int location_name(string& result, string base = string("")); void reset_input_monitor_state (); diff --git a/libs/ardour/location.cc b/libs/ardour/location.cc index 5a75c2bc16..bec87e5dd6 100644 --- a/libs/ardour/location.cc +++ b/libs/ardour/location.cc @@ -36,6 +36,8 @@ #include "i18n.h" +#define SUFFIX_MAX 32 + using namespace std; using namespace ARDOUR; using namespace sigc; @@ -401,6 +403,40 @@ Locations::set_current (Location *loc, bool want_lock) return ret; } +int +Locations::next_available_name(string& result,string base) +{ + LocationList::iterator i; + Location* location; + string temp; + string::size_type l; + int suffix; + char buf[32]; + bool available[SUFFIX_MAX+1]; + + result = base; + for (int k=1; kname(); + if (l && !temp.find(base,0)) { + suffix = atoi(temp.substr(l,3)); + if (suffix) available[suffix] = false; + } + } + for (int k=1; k<=SUFFIX_MAX; k++) { + if (available[k]) { + snprintf (buf, 31, "%d", k); + result += buf; + return 1; + } + } + return 0; +} + int Locations::set_current_unlocked (Location *loc) {