X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_markers.cc;h=29a212f2f594e6ad6ecd6c78e7fa7ee0e4735c4c;hb=cd9fdb935f08966cc8c7170a39870e8adcae69d8;hp=54612000d1585b249fcd81d91bde9e98ada9fbe5;hpb=209d967b1bb80a9735d690d8f4f0455ecb9970ca;p=ardour.git diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 54612000d1..29a212f2f5 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -15,30 +15,36 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ -#include +#include #include #include -#include -#include +#include +#include +#include #include +#include #include "editor.h" #include "marker.h" #include "selection.h" #include "editing.h" #include "gui_thread.h" +#include "simplerect.h" +#include "actions.h" +#include "prompter.h" #include "i18n.h" using namespace std; -using namespace SigC; +using namespace sigc; using namespace ARDOUR; +using namespace PBD; using namespace Gtk; +using namespace Gtkmm2ext; void Editor::clear_marker_display () @@ -53,6 +59,8 @@ Editor::clear_marker_display () void Editor::add_new_location (Location *location) { + ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::add_new_location), location)); + LocationMarkers *lam = new LocationMarkers; uint32_t color; @@ -69,31 +77,30 @@ Editor::add_new_location (Location *location) } if (location->is_mark()) { - lam->start = new Marker (*this, GTK_CANVAS_GROUP(marker_group), color, - location->name(), Marker::Mark, PublicEditor::canvas_marker_event, location->start()); + lam->start = new Marker (*this, *marker_group, color, location->name(), Marker::Mark, location->start()); lam->end = 0; } else if (location->is_auto_loop()) { // transport marker - lam->start = new Marker (*this, GTK_CANVAS_GROUP(transport_marker_group), color, - location->name(), Marker::LoopStart, PublicEditor::canvas_marker_event, location->start()); - lam->end = new Marker (*this, GTK_CANVAS_GROUP(transport_marker_group), color, - location->name(), Marker::LoopEnd, PublicEditor::canvas_marker_event, location->end()); + lam->start = new Marker (*this, *transport_marker_group, color, + location->name(), Marker::LoopStart, location->start()); + lam->end = new Marker (*this, *transport_marker_group, color, + location->name(), Marker::LoopEnd, location->end()); } else if (location->is_auto_punch()) { // transport marker - lam->start = new Marker (*this, GTK_CANVAS_GROUP(transport_marker_group), color, - location->name(), Marker::PunchIn, PublicEditor::canvas_marker_event, location->start()); - lam->end = new Marker (*this, GTK_CANVAS_GROUP(transport_marker_group), color, - location->name(), Marker::PunchOut, PublicEditor::canvas_marker_event, location->end()); + lam->start = new Marker (*this, *transport_marker_group, color, + location->name(), Marker::PunchIn, location->start()); + lam->end = new Marker (*this, *transport_marker_group, color, + location->name(), Marker::PunchOut, location->end()); } else { // range marker - lam->start = new Marker (*this, GTK_CANVAS_GROUP(range_marker_group), color, - location->name(), Marker::Start, PublicEditor::canvas_marker_event, location->start()); - lam->end = new Marker (*this, GTK_CANVAS_GROUP(range_marker_group), color, - location->name(), Marker::End, PublicEditor::canvas_marker_event, location->end()); + lam->start = new Marker (*this, *range_marker_group, color, + location->name(), Marker::Start, location->start()); + lam->end = new Marker (*this, *range_marker_group, color, + location->name(), Marker::End, location->end()); } if (location->is_hidden ()) { @@ -102,11 +109,11 @@ Editor::add_new_location (Location *location) lam->show (); } - location->start_changed.connect (slot (*this, &Editor::location_changed)); - location->end_changed.connect (slot (*this, &Editor::location_changed)); - location->changed.connect (slot (*this, &Editor::location_changed)); - location->name_changed.connect (slot (*this, &Editor::location_changed)); - location->FlagsChanged.connect (slot (*this, &Editor::location_flags_changed)); + location->start_changed.connect (mem_fun(*this, &Editor::location_changed)); + location->end_changed.connect (mem_fun(*this, &Editor::location_changed)); + location->changed.connect (mem_fun(*this, &Editor::location_changed)); + location->name_changed.connect (mem_fun(*this, &Editor::location_changed)); + location->FlagsChanged.connect (mem_fun(*this, &Editor::location_flags_changed)); pair newpair; @@ -119,7 +126,7 @@ Editor::add_new_location (Location *location) void Editor::location_changed (Location *location) { - ENSURE_GUI_THREAD (bind (slot (*this, &Editor::location_changed), location)); + ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::location_changed), location)); LocationMarkers *lam = find_location_markers (location); @@ -141,7 +148,7 @@ Editor::location_changed (Location *location) void Editor::location_flags_changed (Location *location, void *src) { - ENSURE_GUI_THREAD(bind (slot (*this, &Editor::location_flags_changed), location, src)); + ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::location_flags_changed), location, src)); LocationMarkers *lam = find_location_markers (location); @@ -226,7 +233,7 @@ Editor::refresh_location_display_internal (Locations::LocationList& locations) void Editor::refresh_location_display () { - ENSURE_GUI_THREAD(slot (*this, &Editor::refresh_location_display)); + ENSURE_GUI_THREAD(mem_fun(*this, &Editor::refresh_location_display)); if (session) { session->locations()->apply (*this, &Editor::refresh_location_display_internal); @@ -236,7 +243,7 @@ Editor::refresh_location_display () void Editor::refresh_location_display_s (Change ignored) { - ENSURE_GUI_THREAD(bind (slot (*this, &Editor::refresh_location_display_s), ignored)); + ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::refresh_location_display_s), ignored)); if (session) { session->locations()->apply (*this, &Editor::refresh_location_display_internal); @@ -265,8 +272,8 @@ Editor::LocationMarkers::set_name (const string& str) } void -Editor::LocationMarkers::set_position (jack_nframes_t startf, - jack_nframes_t endf) +Editor::LocationMarkers::set_position (nframes_t startf, + nframes_t endf) { start->set_position (startf); if (end) { end->set_position (endf); } @@ -280,25 +287,28 @@ Editor::LocationMarkers::set_color_rgba (uint32_t rgba) } void -Editor::mouse_add_new_marker (jack_nframes_t where) +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")); - session->add_undo (session->locations()->get_memento()); + XMLNode &before = session->locations()->get_state(); session->locations()->add (location, true); - session->add_redo_no_execute (session->locations()->get_memento()); + XMLNode &after = session->locations()->get_state(); + session->add_command (new MementoCommand(*(session->locations()), &before, &after)); session->commit_reversible_command (); } } void -Editor::remove_marker (GtkCanvasItem* item, GdkEvent* event) +Editor::remove_marker (ArdourCanvas::Item& item, GdkEvent* event) { Marker* marker; bool is_start; - if ((marker = static_cast (gtk_object_get_data (GTK_OBJECT(item), "marker"))) == 0) { + if ((marker = static_cast (item.get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; /*NOTREACHED*/ } @@ -306,17 +316,7 @@ Editor::remove_marker (GtkCanvasItem* 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 { - Gtk::Main::idle.connect (bind (slot (*this, &Editor::really_remove_marker), loc)); - } + Glib::signal_idle().connect (bind (mem_fun(*this, &Editor::really_remove_marker), loc)); } } @@ -324,9 +324,10 @@ gint Editor::really_remove_marker (Location* loc) { session->begin_reversible_command (_("remove marker")); - session->add_undo (session->locations()->get_memento()); + XMLNode &before = session->locations()->get_state(); session->locations()->remove (loc); - session->add_redo_no_execute (session->locations()->get_memento()); + XMLNode &after = session->locations()->get_state(); + session->add_command (new MementoCommand(*(session->locations()), &before, &after)); session->commit_reversible_command (); return FALSE; } @@ -334,7 +335,7 @@ Editor::really_remove_marker (Location* loc) void Editor::location_gone (Location *location) { - ENSURE_GUI_THREAD(bind (slot (*this, &Editor::location_gone), location)); + ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::location_gone), location)); LocationMarkerMap::iterator i; @@ -356,7 +357,7 @@ Editor::location_gone (Location *location) } void -Editor::tm_marker_context_menu (GdkEventButton* ev, GtkCanvasItem* item) +Editor::tm_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item) { if (tm_marker_menu == 0) { build_tm_marker_menu (); @@ -367,12 +368,11 @@ Editor::tm_marker_context_menu (GdkEventButton* ev, GtkCanvasItem* item) } - void -Editor::marker_context_menu (GdkEventButton* ev, GtkCanvasItem* item) +Editor::marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item) { Marker * marker; - if ((marker = reinterpret_cast (gtk_object_get_data (GTK_OBJECT(item), "marker"))) == 0) { + if ((marker = reinterpret_cast (item->get_data("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; /*NOTREACHED*/ } @@ -381,20 +381,30 @@ Editor::marker_context_menu (GdkEventButton* ev, GtkCanvasItem* 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 (marker_menu == 0) { - build_marker_menu (); - } + } else { + + if (loc->is_mark()) { + 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; + } + - Menu_Helpers::MenuList & children = marker_menu->items(); - // XXX: should really find this some other way + // GTK2FIX use action group sensitivity +#ifdef GTK2FIX if (children.size() >= 3) { - MenuItem * loopitem = children[2]; + MenuItem * loopitem = &children[2]; if (loopitem) { if (loc->is_mark()) { loopitem->set_sensitive(false); @@ -404,15 +414,23 @@ Editor::marker_context_menu (GdkEventButton* ev, GtkCanvasItem* 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 (false); + } + marker_menu_item = item; + range_marker_menu->popup (1, ev->time); + } } } - void -Editor::new_transport_marker_context_menu (GdkEventButton* ev, GtkCanvasItem* item) +Editor::new_transport_marker_context_menu (GdkEventButton* ev, ArdourCanvas::Item* item) { if (new_transport_marker_menu == 0) { build_new_transport_marker_menu (); @@ -423,35 +441,79 @@ Editor::new_transport_marker_context_menu (GdkEventButton* ev, GtkCanvasItem* it } void -Editor::transport_marker_context_menu (GdkEventButton* ev, GtkCanvasItem* item) +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; + + 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))); + items.push_back (MenuElem (_("Set Mark from Playhead"), mem_fun(*this, &Editor::marker_menu_set_from_playhead))); + + items.push_back (SeparatorElem()); + + 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 (bool loop_or_punch) { using namespace Menu_Helpers; - marker_menu = new Menu; - MenuList& items = marker_menu->items(); - 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))); + 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 (_("Locate to"), slot (*this, &Editor::marker_menu_set_playhead))); - items.push_back (MenuElem (_("Play from"), slot (*this, &Editor::marker_menu_play_from))); - items.push_back (MenuElem (_("Loop range"), slot (*this, &Editor::marker_menu_loop_range))); - items.push_back (MenuElem (_("Set from playhead"), slot (*this, &Editor::marker_menu_set_from_playhead))); - items.push_back (MenuElem (_("Set from range"), slot (*this, &Editor::marker_menu_set_from_selection))); + items.push_back (MenuElem (_("Hide Range"), mem_fun(*this, &Editor::marker_menu_hide))); + 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()); - items.push_back (MenuElem (_("Rename"), slot (*this, &Editor::marker_menu_rename))); - items.push_back (MenuElem (_("Hide"), slot (*this, &Editor::marker_menu_hide))); - items.push_back (MenuElem (_("Remove"), slot (*this, &Editor::marker_menu_remove))); + 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))); + items.push_back (MenuElem (_("Select Range"), mem_fun(*this, &Editor::marker_menu_select_using_range))); + } void @@ -463,8 +525,8 @@ Editor::build_tm_marker_menu () MenuList& items = tm_marker_menu->items(); tm_marker_menu->set_name ("ArdourContextMenu"); - items.push_back (MenuElem (_("Edit"), slot (*this, &Editor::marker_menu_edit))); - items.push_back (MenuElem (_("Remove"), slot (*this, &Editor::marker_menu_remove))); + items.push_back (MenuElem (_("Edit"), mem_fun(*this, &Editor::marker_menu_edit))); + items.push_back (MenuElem (_("Remove"), mem_fun(*this, &Editor::marker_menu_remove))); } void @@ -476,53 +538,92 @@ Editor::build_new_transport_marker_menu () MenuList& items = new_transport_marker_menu->items(); new_transport_marker_menu->set_name ("ArdourContextMenu"); - items.push_back (MenuElem (_("Set Loop Range"), slot (*this, &Editor::new_transport_marker_menu_set_loop))); - items.push_back (MenuElem (_("Set Punch Range"), slot (*this, &Editor::new_transport_marker_menu_set_punch))); + items.push_back (MenuElem (_("Set Loop Range"), mem_fun(*this, &Editor::new_transport_marker_menu_set_loop))); + items.push_back (MenuElem (_("Set Punch Range"), mem_fun(*this, &Editor::new_transport_marker_menu_set_punch))); - new_transport_marker_menu->unmap_event.connect ( slot (*this, &Editor::new_transport_marker_menu_popdown)); + new_transport_marker_menu->signal_unmap_event().connect ( mem_fun(*this, &Editor::new_transport_marker_menu_popdown)); } void -Editor::build_transport_marker_menu () +Editor::marker_menu_hide () { - using namespace Menu_Helpers; + Marker* marker; - transport_marker_menu = new Menu; - MenuList& items = transport_marker_menu->items(); - transport_marker_menu->set_name ("ArdourContextMenu"); + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { + fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; + /*NOTREACHED*/ + } - items.push_back (MenuElem (_("Locate to"), slot (*this, &Editor::marker_menu_set_playhead))); - items.push_back (MenuElem (_("Play from"), slot (*this, &Editor::marker_menu_play_from))); - items.push_back (MenuElem (_("Set from playhead"), slot (*this, &Editor::marker_menu_set_from_playhead))); - items.push_back (MenuElem (_("Set from range"), slot (*this, &Editor::marker_menu_set_from_selection))); - items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Hide"), slot (*this, &Editor::marker_menu_hide))); + Location* l; + bool is_start; + + if ((l = find_location_from_marker (marker, is_start)) != 0) { + l->set_hidden (true, this); + } } void -Editor::marker_menu_hide () +Editor::marker_menu_select_using_range () { Marker* marker; - if ((marker = reinterpret_cast (gtk_object_get_data (GTK_OBJECT(marker_menu_item), "marker"))) == 0) { + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; /*NOTREACHED*/ } Location* l; bool is_start; - - if ((l = find_location_from_marker (marker, is_start)) != 0) { - l->set_hidden (true, this); + + if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) { + set_selection_from_range (*l); } } +void +Editor::marker_menu_select_all_selectables_using_range () +{ + Marker* marker; + + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { + fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; + /*NOTREACHED*/ + } + + Location* l; + bool is_start; + + if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) { + select_all_within (l->start(), l->end() - 1, 0, DBL_MAX, track_views, Selection::Set); + } + +} + +void +Editor::marker_menu_separate_regions_using_location () +{ + Marker* marker; + + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { + fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; + /*NOTREACHED*/ + } + + Location* l; + bool is_start; + + if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) { + separate_regions_using_location (*l); + } + +} + void Editor::marker_menu_play_from () { Marker* marker; - if ((marker = reinterpret_cast (gtk_object_get_data (GTK_OBJECT(marker_menu_item), "marker"))) == 0) { + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; /*NOTREACHED*/ } @@ -552,7 +653,7 @@ Editor::marker_menu_set_playhead () { Marker* marker; - if ((marker = reinterpret_cast (gtk_object_get_data (GTK_OBJECT(marker_menu_item), "marker"))) == 0) { + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; /*NOTREACHED*/ } @@ -580,7 +681,7 @@ Editor::marker_menu_set_from_playhead () { Marker* marker; - if ((marker = reinterpret_cast (gtk_object_get_data (GTK_OBJECT(marker_menu_item), "marker"))) == 0) { + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; /*NOTREACHED*/ } @@ -608,7 +709,7 @@ Editor::marker_menu_set_from_selection () { Marker* marker; - if ((marker = reinterpret_cast (gtk_object_get_data (GTK_OBJECT(marker_menu_item), "marker"))) == 0) { + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; /*NOTREACHED*/ } @@ -632,21 +733,47 @@ Editor::marker_menu_set_from_selection () } } else { - if (!selection->audio_regions.empty()) { - l->set_start (selection->audio_regions.start()); - l->set_end (selection->audio_regions.end_frame()); + if (!selection->regions.empty()) { + l->set_start (selection->regions.start()); + l->set_end (selection->regions.end_frame()); } } } } } + +void +Editor::marker_menu_play_range () +{ + Marker* marker; + + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { + fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; + /*NOTREACHED*/ + } + + Location* l; + bool is_start; + + if ((l = find_location_from_marker (marker, is_start)) != 0) { + + if (l->is_mark()) { + session->request_locate (l->start(), true); + } + else { + session->request_bounded_roll (l->start(), l->end()); + + } + } +} + void Editor::marker_menu_loop_range () { Marker* marker; - if ((marker = reinterpret_cast (gtk_object_get_data (GTK_OBJECT(marker_menu_item), "marker"))) == 0) { + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; /*NOTREACHED*/ } @@ -660,7 +787,7 @@ Editor::marker_menu_loop_range () l2->set (l->start(), l->end()); // enable looping, reposition and start rolling - session->request_auto_loop(true); + session->request_play_loop(true); session->request_locate (l2->start(), true); } } @@ -673,7 +800,7 @@ Editor::marker_menu_edit () TempoMarker* tm; Marker* marker; - if ((marker = reinterpret_cast (gtk_object_get_data (GTK_OBJECT(marker_menu_item), "marker"))) == 0) { + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; /*NOTREACHED*/ } @@ -696,7 +823,7 @@ Editor::marker_menu_remove () TempoMarker* tm; Marker* marker; - if ((marker = reinterpret_cast (gtk_object_get_data (GTK_OBJECT(marker_menu_item), "marker"))) == 0) { + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; /*NOTREACHED*/ } @@ -706,7 +833,7 @@ Editor::marker_menu_remove () } else if ((tm = dynamic_cast (marker)) != 0) { remove_tempo_marker (marker_menu_item); } else { - remove_marker (marker_menu_item, (GdkEvent*) 0); + remove_marker (*marker_menu_item, (GdkEvent*) 0); } } @@ -715,7 +842,7 @@ Editor::marker_menu_rename () { Marker* marker; - if ((marker = reinterpret_cast (gtk_object_get_data (GTK_OBJECT(marker_menu_item), "marker"))) == 0) { + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; /*NOTREACHED*/ } @@ -727,59 +854,54 @@ Editor::marker_menu_rename () if (!loc) return; - Dialog dialog; - Entry entry; - Button ok_button (_("OK")); - Button cancel_button (_("Cancel")); - + ArdourPrompter dialog (true); + string txt; + + dialog.set_prompt (_("New Name:")); + + WindowTitle title(Glib::get_application_name()); if (loc->is_mark()) { - dialog.set_title (_("ardour: rename mark")); + title += _("Rename Mark"); } else { - dialog.set_title (_("ardour: rename range")); + title += _("Rename Range"); } - dialog.set_name ("MarkRenameWindow"); - dialog.set_usize (300, -1); - dialog.set_position (GTK_WIN_POS_MOUSE); - dialog.set_modal (true); - - dialog.get_vbox()->set_border_width (10); - dialog.get_vbox()->pack_start (entry); - dialog.get_action_area()->pack_start (ok_button); - dialog.get_action_area()->pack_start (cancel_button); + dialog.set_title(title.get_string()); - entry.set_text (loc->name()); - entry.set_name ("MarkerNameDisplay"); - ok_button.set_name ("EditorGTKButton"); - cancel_button.set_name ("EditorGTKButton"); - - entry.activate.connect (bind (slot (*this, &Editor::finish_sub_event_loop), 1)); - cancel_button.clicked.connect (bind (slot (*this, &Editor::finish_sub_event_loop), -1)); - ok_button.clicked.connect (bind (slot (*this, &Editor::finish_sub_event_loop), 1)); - dialog.delete_event.connect (bind (slot (*this, &Editor::finish_sub_event_loop_on_delete), -1)); + dialog.set_name ("MarkRenameWindow"); + dialog.set_size_request (250, -1); + dialog.set_position (Gtk::WIN_POS_MOUSE); - dialog.show_all (); - entry.grab_focus (); + dialog.add_button (_("Rename"), RESPONSE_ACCEPT); + dialog.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false); + dialog.set_initial_text (loc->name()); - run_sub_event_loop (); + dialog.show (); - if (sub_event_loop_status == 1) { + switch (dialog.run ()) { + case RESPONSE_ACCEPT: + break; + default: + return; + } - Location* l; - bool is_start; + begin_reversible_command ( _("rename marker") ); + XMLNode &before = session->locations()->get_state(); - if ((l = find_location_from_marker (marker, is_start)) != 0) { - l->set_name (entry.get_text()); - } - } + dialog.get_result(txt); + loc->set_name (txt); + + XMLNode &after = session->locations()->get_state(); + session->add_command (new MementoCommand(*(session->locations()), &before, &after)); + commit_reversible_command (); } gint Editor::new_transport_marker_menu_popdown (GdkEventAny *ev) { // hide rects - gtk_canvas_item_hide (transport_bar_drag_rect); - gtk_canvas_item_hide (range_marker_drag_rect); + transport_bar_drag_rect->hide(); + range_marker_drag_rect->hide(); return FALSE; } @@ -795,16 +917,18 @@ Editor::new_transport_marker_menu_set_loop () if ((tll = transport_loop_location()) == 0) { Location* loc = new Location (temp_location->start(), temp_location->end(), _("Loop"), Location::IsAutoLoop); - session->add_undo (session->locations()->get_memento()); + XMLNode &before = session->locations()->get_state(); session->locations()->add (loc, true); session->set_auto_loop_location (loc); - session->add_redo_no_execute (session->locations()->get_memento()); + XMLNode &after = session->locations()->get_state(); + session->add_command (new MementoCommand(*(session->locations()), &before, &after)); } else { - session->add_undo (rettype(bind (slot (*tll, &Location::set), tll->start(), tll->end()))); - session->add_redo (rettype(bind (slot (*tll, &Location::set), temp_location->start(), temp_location->end()))); + XMLNode &before = tll->get_state(); tll->set_hidden (false, this); tll->set (temp_location->start(), temp_location->end()); + XMLNode &after = tll->get_state(); + session->add_command (new MementoCommand(*tll, &before, &after)); } commit_reversible_command (); @@ -821,15 +945,17 @@ Editor::new_transport_marker_menu_set_punch () if ((tpl = transport_punch_location()) == 0) { tpl = new Location (temp_location->start(), temp_location->end(), _("Punch"), Location::IsAutoPunch); - session->add_undo (session->locations()->get_memento()); + XMLNode &before = session->locations()->get_state(); session->locations()->add (tpl, true); session->set_auto_punch_location (tpl); - session->add_redo_no_execute (session->locations()->get_memento()); + XMLNode &after = session->locations()->get_state(); + session->add_command (new MementoCommand(*(session->locations()), &before, &after)); } else { - session->add_undo (rettype(bind (slot (*tpl, &Location::set), tpl->start(), tpl->end()))); - session->add_redo (rettype(bind (slot (*tpl, &Location::set), temp_location->start(), temp_location->end()))); + XMLNode &before = tpl->get_state(); tpl->set_hidden(false, this); tpl->set(temp_location->start(), temp_location->end()); + XMLNode &after = tpl->get_state(); + session->add_command (new MementoCommand(*tpl, &before, &after)); } commit_reversible_command (); @@ -844,19 +970,20 @@ Editor::update_loop_range_view (bool visibility) Location* tll; - if (session->get_auto_loop() && ((tll = transport_loop_location()) != 0)) { + if (session->get_play_loop() && ((tll = transport_loop_location()) != 0)) { double x1 = frame_to_pixel (tll->start()); double x2 = frame_to_pixel (tll->end()); - gtk_canvas_item_set (transport_loop_range_rect, "x1", x1, "x2", x2, NULL); + transport_loop_range_rect->property_x1() = x1; + transport_loop_range_rect->property_x2() = x2; if (visibility) { - gtk_canvas_item_show (transport_loop_range_rect); + transport_loop_range_rect->show(); } - } - else if (visibility) { - gtk_canvas_item_hide (transport_loop_range_rect); + + } else if (visibility) { + transport_loop_range_rect->hide(); } } @@ -869,43 +996,44 @@ Editor::update_punch_range_view (bool visibility) Location* tpl; - if ((session->get_punch_in() || session->get_punch_out()) && ((tpl = transport_punch_location()) != 0)) { + if ((Config->get_punch_in() || Config->get_punch_out()) && ((tpl = transport_punch_location()) != 0)) { double x1 = frame_to_pixel (tpl->start()); double x2 = frame_to_pixel (tpl->end()); - gtk_canvas_item_set (transport_punch_range_rect, "x1", x1, "x2", x2, NULL); + transport_punch_range_rect->property_x1() = x1; + transport_punch_range_rect->property_x2() = x2; if (visibility) { - gtk_canvas_item_show (transport_punch_range_rect); + transport_punch_range_rect->show(); } } else if (visibility) { - gtk_canvas_item_hide (transport_punch_range_rect); + transport_punch_range_rect->hide(); } // if (session->get_punch_in()) { // double x = frame_to_pixel (transport_punch_location->start()); -// gtk_canvas_item_set (transport_punchin_line, "x1", x, "x2", x, NULL); +// gnome_canvas_item_set (transport_punchin_line, "x1", x, "x2", x, NULL); // if (visibility) { -// gtk_canvas_item_show (transport_punchin_line); +// gnome_canvas_item_show (transport_punchin_line); // } // } // else if (visibility) { -// gtk_canvas_item_hide (transport_punchin_line); +// gnome_canvas_item_hide (transport_punchin_line); // } // if (session->get_punch_out()) { // double x = frame_to_pixel (transport_punch_location->end()); -// gtk_canvas_item_set (transport_punchout_line, "x1", x, "x2", x, NULL); +// gnome_canvas_item_set (transport_punchout_line, "x1", x, "x2", x, NULL); // if (visibility) { -// gtk_canvas_item_show (transport_punchout_line); +// gnome_canvas_item_show (transport_punchout_line); // } // } // else if (visibility) { -// gtk_canvas_item_hide (transport_punchout_line); +// gnome_canvas_item_hide (transport_punchout_line); // } }