X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fimageframe_time_axis.cc;h=b680dbda3a9f37d1de5bb76e3fc4c3df138173df;hb=cb8bc87a542e35794a12e76a23594e63b3bad521;hp=51325ca38fb25496a65cfa6ba06ceac94e15ade6;hpb=209d967b1bb80a9735d690d8f4f0455ecb9970ca;p=ardour.git diff --git a/gtk2_ardour/imageframe_time_axis.cc b/gtk2_ardour/imageframe_time_axis.cc index 51325ca38f..b680dbda3a 100644 --- a/gtk2_ardour/imageframe_time_axis.cc +++ b/gtk2_ardour/imageframe_time_axis.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2003 Paul Davis + Copyright (C) 2003 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,23 +15,24 @@ 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 "pbd/error.h" -#include -#include +#include -#include -#include +#include +#include + +#include "ardour/session.h" +#include "ardour/utils.h" #include "public_editor.h" #include "imageframe_time_axis.h" -#include "canvas-simplerect.h" +#include "simplerect.h" #include "enums.h" #include "imageframe_time_axis_view.h" #include "imageframe_time_axis_group.h" @@ -40,12 +41,13 @@ #include "marker_time_axis.h" #include "marker_view.h" #include "gui_thread.h" +#include "canvas_impl.h" #include "i18n.h" -using namespace ARDOUR ; -using namespace SigC ; -using namespace Gtk ; +using namespace ARDOUR; +using namespace PBD; +using namespace Gtk; /** * Constructs a new ImageFrameTimeAxis. @@ -55,31 +57,32 @@ using namespace Gtk ; * @param sess the current session * @param canvas the parent canvas item */ -ImageFrameTimeAxis::ImageFrameTimeAxis(std::string track_id, PublicEditor& ed, ARDOUR::Session& sess, Widget *canvas) +ImageFrameTimeAxis::ImageFrameTimeAxis(const string & track_id, PublicEditor& ed, ARDOUR::Session* sess, ArdourCanvas::Canvas& canvas) : AxisView(sess), VisualTimeAxis(track_id, ed, sess, canvas) { _color = unique_random_color() ; - - selection_group = gtk_canvas_item_new (GTK_CANVAS_GROUP(canvas_display), gtk_canvas_group_get_type (), NULL) ; - gtk_canvas_item_hide(selection_group) ; + + selection_group = new ArdourCanvas::Group (*canvas_display); + selection_group->hide(); // intialize our data items _marked_for_display = true; y_position = -1 ; - name_prompter = 0 ; /* create our new image frame view */ view = new ImageFrameTimeAxisView(*this) ; - + /* create the Image Frame Edit Menu */ create_imageframe_menu() ; - + // set the initial time axis text label label_view() ; - + // set the initial height of this time axis - set_height(Normal) ; + set_height(hNormal) ; + + TimeAxisView::CatchDeletion.connect (*this, ui_bind (&ImageFrameTimeAxis::remove_time_axis_view, this, _1), gui_context()); } /** @@ -88,55 +91,32 @@ ImageFrameTimeAxis::ImageFrameTimeAxis(std::string track_id, PublicEditor& ed, A */ ImageFrameTimeAxis::~ImageFrameTimeAxis () { - GoingAway() ; /* EMIT_SIGNAL */ - + CatchDeletion (this); + // Destroy all the marker views we may have associaited with this TimeAxis for(MarkerTimeAxisList::iterator iter = marker_time_axis_list.begin(); iter != marker_time_axis_list.end(); ++iter) { MarkerTimeAxis* mta = *iter ; MarkerTimeAxisList::iterator next = iter ; next++ ; - + marker_time_axis_list.erase(iter) ; delete mta ; mta = 0 ; - + iter = next ; } - - if(image_action_menu) - { - delete image_action_menu ; - image_action_menu = 0 ; - } - - for(list::iterator i = free_selection_rects.begin(); i != free_selection_rects.end(); ++i) - { - gtk_object_destroy (GTK_OBJECT((*i)->rect)); - gtk_object_destroy (GTK_OBJECT((*i)->start_trim)); - gtk_object_destroy (GTK_OBJECT((*i)->end_trim)); - } - for(list::iterator i = used_selection_rects.begin(); i != used_selection_rects.end(); ++i) - { - gtk_object_destroy (GTK_OBJECT((*i)->rect)); - gtk_object_destroy (GTK_OBJECT((*i)->start_trim)); - gtk_object_destroy (GTK_OBJECT((*i)->end_trim)); - } - - if (selection_group) - { - gtk_object_destroy (GTK_OBJECT (selection_group)); - selection_group = 0 ; - } - + delete image_action_menu ; + image_action_menu = 0 ; + + delete selection_group; + selection_group = 0 ; + // Destroy our Axis View helper - if(view) - { - delete view ; - view = 0 ; - } + delete view ; + view = 0 ; } //---------------------------------------------------------------------------------------// @@ -145,19 +125,19 @@ ImageFrameTimeAxis::~ImageFrameTimeAxis () /** * Sets the height of this TrackView to one of ths TrackHeghts * - * @param h the TrackHeight value to set + * @param h */ void -ImageFrameTimeAxis::set_height (TrackHeight h) +ImageFrameTimeAxis::set_height (uint32_t h) { VisualTimeAxis::set_height(h) ; - + // tell out view helper of the change too if(view != 0) { view->set_height((double) height) ; } - + // tell those interested that we have had our height changed gui_changed("track_height",(void*)0); /* EMIT_SIGNAL */ } @@ -215,7 +195,7 @@ ImageFrameTimeAxis::popup_imageframe_edit_menu(int button, int32_t time, ImageFr { imageframe_item_menu->set_sensitive(false) ; } - + imageframe_menu->popup(button,time) ; } @@ -242,6 +222,7 @@ void ImageFrameTimeAxis::build_display_menu() { using namespace Menu_Helpers; + using Gtk::Menu; /* get the size menu ready */ @@ -255,18 +236,18 @@ ImageFrameTimeAxis::build_display_menu() MenuList& items = display_menu->items(); - items.push_back (MenuElem (_("Rename"), slot(*this, &ImageFrameTimeAxis::start_time_axis_rename))); + items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &ImageFrameTimeAxis::start_time_axis_rename))); image_action_menu = new Menu() ; image_action_menu->set_name ("ArdourContextMenu"); MenuList image_items = image_action_menu->items() ; - + items.push_back (SeparatorElem()); items.push_back (MenuElem (_("Height"), *size_menu)); - items.push_back (MenuElem (_("Color"), slot(*this, &ImageFrameTimeAxis::select_track_color))); + items.push_back (MenuElem (_("Color"), sigc::mem_fun(*this, &ImageFrameTimeAxis::select_track_color))); items.push_back (SeparatorElem()); - items.push_back (MenuElem (_("Remove"), bind(slot(*this, &VisualTimeAxis::remove_this_time_axis), (void*)this))) ; + items.push_back (MenuElem (_("Remove"), sigc::bind(sigc::mem_fun(*this, &VisualTimeAxis::remove_this_time_axis), (void*)this))) ; } /** @@ -276,11 +257,12 @@ void ImageFrameTimeAxis::create_imageframe_menu() { using namespace Menu_Helpers; + using Gtk::Menu; imageframe_menu = manage(new Menu) ; imageframe_menu->set_name ("ArdourContextMenu"); MenuList& items = imageframe_menu->items(); - + imageframe_item_menu = manage(new Menu) ; imageframe_item_menu->set_name ("ArdourContextMenu"); MenuList& imageframe_sub_items = imageframe_item_menu->items() ; @@ -292,14 +274,14 @@ ImageFrameTimeAxis::create_imageframe_menu() if(view) { - duration_items.push_back(MenuElem (_("0.5 seconds"), bind (slot (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 0.5))) ; - duration_items.push_back(MenuElem (_("1 seconds"), bind (slot (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 1.0))) ; - duration_items.push_back(MenuElem (_("1.5 seconds"), bind (slot (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 1.5))) ; - duration_items.push_back(MenuElem (_("2 seconds"), bind (slot (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 2.0))) ; - duration_items.push_back(MenuElem (_("2.5 seconds"), bind (slot (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 2.5))) ; - duration_items.push_back(MenuElem (_("3 seconds"), bind (slot (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 3.0))) ; + duration_items.push_back(MenuElem (_("0.5 seconds"), sigc::bind (sigc::mem_fun (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 0.5))) ; + duration_items.push_back(MenuElem (_("1 seconds"), sigc::bind (sigc::mem_fun (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 1.0))) ; + duration_items.push_back(MenuElem (_("1.5 seconds"), sigc::bind (sigc::mem_fun (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 1.5))) ; + duration_items.push_back(MenuElem (_("2 seconds"), sigc::bind (sigc::mem_fun (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 2.0))) ; + duration_items.push_back(MenuElem (_("2.5 seconds"), sigc::bind (sigc::mem_fun (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 2.5))) ; + duration_items.push_back(MenuElem (_("3 seconds"), sigc::bind (sigc::mem_fun (view, &ImageFrameTimeAxisView::set_imageframe_duration_sec), 3.0))) ; //duration_items.push_back(SeparatorElem()) ; - //duration_items.push_back(MenuElem (_("custom"), slot (*this, &ImageFrameTimeAxis::set_imageframe_duration_custom))) ; + //duration_items.push_back(MenuElem (_("custom"), sigc::mem_fun(*this, &ImageFrameTimeAxis::set_imageframe_duration_custom))) ; } imageframe_sub_items.push_back(MenuElem(_("Duration (sec)"), *duration_menu)) ; @@ -307,11 +289,11 @@ ImageFrameTimeAxis::create_imageframe_menu() imageframe_sub_items.push_back(SeparatorElem()) ; if(view) { - imageframe_sub_items.push_back(MenuElem (_("Remove Frame"), bind(slot (view, &ImageFrameTimeAxisView::remove_selected_imageframe_item), (void*)this))) ; + imageframe_sub_items.push_back(MenuElem (_("Remove Frame"), sigc::bind(sigc::mem_fun (view, &ImageFrameTimeAxisView::remove_selected_imageframe_item), (void*)this))) ; } - + items.push_back(MenuElem(_("Image Frame"), *imageframe_item_menu)) ; - items.push_back(MenuElem (_("Rename Track"), slot (*this,&ImageFrameTimeAxis::start_time_axis_rename))) ; + items.push_back(MenuElem (_("Rename Track"), sigc::mem_fun(*this,&ImageFrameTimeAxis::start_time_axis_rename))) ; imageframe_menu->show_all() ; } @@ -334,7 +316,7 @@ bool ImageFrameTimeAxis::add_marker_time_axis(MarkerTimeAxis* marker_track, void* src) { bool ret = false ; - + if(get_named_marker_time_axis(marker_track->name()) != 0) { ret = false ; @@ -342,12 +324,10 @@ ImageFrameTimeAxis::add_marker_time_axis(MarkerTimeAxis* marker_track, void* src else { marker_time_axis_list.push_back(marker_track) ; - marker_track->GoingAway.connect(bind(slot(*this, &ImageFrameTimeAxis::remove_time_axis_view), marker_track, (void*)this)); - MarkerTimeAxisAdded(marker_track, src) ; /* EMIT_SIGNAL */ ret = true ; } - + return(ret) ; } @@ -358,10 +338,10 @@ ImageFrameTimeAxis::add_marker_time_axis(MarkerTimeAxis* marker_track, void* src * @return the named markerTimeAxis, or 0 if the named MarkerTimeAxis is not associated with this ImageFrameTimeAxis */ MarkerTimeAxis* -ImageFrameTimeAxis::get_named_marker_time_axis(std::string track_id) +ImageFrameTimeAxis::get_named_marker_time_axis(const string & track_id) { MarkerTimeAxis* mta = 0 ; - + for (MarkerTimeAxisList::iterator i = marker_time_axis_list.begin(); i != marker_time_axis_list.end(); ++i) { if (((MarkerTimeAxis*)*i)->name() == track_id) @@ -381,24 +361,24 @@ ImageFrameTimeAxis::get_named_marker_time_axis(std::string track_id) * @return the removed MarkerTimeAxis */ MarkerTimeAxis* -ImageFrameTimeAxis::remove_named_marker_time_axis(std::string track_id, void* src) +ImageFrameTimeAxis::remove_named_marker_time_axis(const string & track_id, void* src) { MarkerTimeAxis* mta = 0 ; - + for(MarkerTimeAxisList::iterator i = marker_time_axis_list.begin(); i != marker_time_axis_list.end(); ++i) { if (((MarkerTimeAxis*)*i)->name() == track_id) { mta = ((MarkerTimeAxis*)*i) ; - + // the iterator is invalid after this call, so we can no longer use it as is. marker_time_axis_list.erase(i) ; - + MarkerTimeAxisRemoved(mta->name(), src) ; /* EMIT_SIGNAL */ break ; } } - + return(mta) ; } @@ -410,17 +390,20 @@ ImageFrameTimeAxis::remove_named_marker_time_axis(std::string track_id, void* sr * @param src the identity of the object that initiated the change */ void -ImageFrameTimeAxis::remove_time_axis_view(MarkerTimeAxis* mta, void* src) +ImageFrameTimeAxis::remove_time_axis_view (TimeAxisView* tav) { - ENSURE_GUI_THREAD(bind (slot (*this, &ImageFrameTimeAxis::remove_time_axis_view), mta, src)); - + MarkerTimeAxisView* mtav = dynamic_cast (tav); + + if (!mtav) { + return; + } + MarkerTimeAxisList::iterator i; - if((i = find (marker_time_axis_list.begin(), marker_time_axis_list.end(), mta)) != marker_time_axis_list.end()) - { + + if ((i = find (marker_time_axis_list.begin(), marker_time_axis_list.end(), mta)) != marker_time_axis_list.end()) { // note that we dont delete the object itself, we just remove it from our list marker_time_axis_list.erase(i) ; - - MarkerTimeAxisRemoved(mta->name(), src) ; /* EMIT_SIGNAL */ + MarkerTimeAxisRemoved (mta->name(), src) ; /* EMIT_SIGNAL */ } }