X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fimageframe_time_axis_view.cc;h=8df7a9161230ff641fb43e31a56414c37647cd74;hb=d70429a066dfd33cca0b6f64be7014649a9910ca;hp=20ccb7d61f23bf8b719d220336e9bf912ea7cb7f;hpb=209d967b1bb80a9735d690d8f4f0455ecb9970ca;p=ardour.git diff --git a/gtk2_ardour/imageframe_time_axis_view.cc b/gtk2_ardour/imageframe_time_axis_view.cc index 20ccb7d61f..8df7a91612 100644 --- a/gtk2_ardour/imageframe_time_axis_view.cc +++ b/gtk2_ardour/imageframe_time_axis_view.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,14 +15,13 @@ 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 "imageframe_time_axis_view.h" #include "imageframe_time_axis_group.h" @@ -33,6 +32,7 @@ #include "public_editor.h" #include "rgb_macros.h" #include "gui_thread.h" +#include "ardour_ui.h" #include "i18n.h" @@ -41,52 +41,47 @@ using namespace Editing; //---------------------------------------------------------------------------------------// // Constructor / Desctructor - + /** * Constructs a new ImageFrameTimeAxisView. * * @param ifta the parent ImageFrameTimeAxis of this view helper */ ImageFrameTimeAxisView::ImageFrameTimeAxisView (ImageFrameTimeAxis& tv) - : _trackview (tv) + : _trackview (tv), + canvas_group (*_trackview.canvas_display), + canvas_rect (canvas_group, 0.0, 0.0, 1000000.0, tv.current_height()) { region_color = _trackview.color() ; - stream_base_color = color_map[cImageTrackBase] ; - - canvas_group = gtk_canvas_item_new (GTK_CANVAS_GROUP(_trackview.canvas_display), gtk_canvas_group_get_type (), 0) ; + stream_base_color = ARDOUR_UI::config()->canvasvar_ImageTrack.get() ; - canvas_rect = gtk_canvas_item_new (GTK_CANVAS_GROUP(canvas_group), - gtk_canvas_simplerect_get_type(), - "x1", 0.0, - "y1", 0.0, - "x2", 1000000.0, - "y2", (double) tv.height, - "outline_color_rgba", color_map[cImageTrackOutline], - "fill_color_rgba", stream_base_color, - 0) ; + canvas_rect.property_outline_color_rgba() = ARDOUR_UI::config()->canvasvar_ImageTrack.get(); + canvas_rect.property_fill_color_rgba() = stream_base_color; - gtk_signal_connect(GTK_OBJECT(canvas_rect), "event", (GtkSignalFunc) PublicEditor::canvas_imageframe_view_event, &_trackview) ; + canvas_rect.signal_event().connect (sigc::bind (sigc::mem_fun (_trackview.editor, &PublicEditor::canvas_imageframe_view_event), (ArdourCanvas::Item*) &canvas_rect, &tv)); _samples_per_unit = _trackview.editor.get_current_zoom() ; - _trackview.editor.ZoomChanged.connect (slot (*this, &ImageFrameTimeAxisView::reset_samples_per_unit)) ; + _trackview.editor.ZoomChanged.connect (sigc::mem_fun(*this, &ImageFrameTimeAxisView::reset_samples_per_unit)) ; selected_imageframe_group = 0 ; selected_imageframe_view = 0 ; + + ImageFrameTimeAxisGroup::CatchDeletion.connect (*this, boost::bind (&ImageFrameTimeAxisView::remove_imageframe_group, this, _1), gui_context()); } /** - * Destructor + * Destructor * Responsible for destroying all items tat may have been added to this time axis */ ImageFrameTimeAxisView::~ImageFrameTimeAxisView() { // Destroy all the ImageFrameGroups that we have - + for(ImageFrameGroupList::iterator iter = imageframe_groups.begin(); iter != imageframe_groups.end(); ++iter) { ImageFrameTimeAxisGroup* iftag = (*iter) ; - + ImageFrameGroupList::iterator next = iter ; next++ ; @@ -95,28 +90,16 @@ ImageFrameTimeAxisView::~ImageFrameTimeAxisView() delete iftag ; iftag = 0 ; - + iter = next ; } - - // Destroy all our canvas components - if(canvas_rect) - { - gtk_object_destroy(GTK_OBJECT(canvas_rect)) ; - canvas_rect = 0 ; - } - - if(canvas_group) - { - gtk_object_destroy(GTK_OBJECT(canvas_group)); - canvas_group = 0 ; - } + } //---------------------------------------------------------------------------------------// // ui methods & data - + /** * Sets the height of the time axis view and the item upon it * @@ -126,15 +109,12 @@ int ImageFrameTimeAxisView::set_height (gdouble h) { /* limit the values to something sane-ish */ - if (h < 10.0 || h > 1000.0) - { + if (h < 10.0 || h > 1000.0) { return(-1) ; } - - if(canvas_rect != 0) - { - gtk_object_set(GTK_OBJECT(canvas_rect), "y2", h, NULL) ; - } + + canvas_rect.property_y2() = h ; + for(ImageFrameGroupList::const_iterator citer = imageframe_groups.begin(); citer != imageframe_groups.end(); ++citer) { @@ -143,7 +123,7 @@ ImageFrameTimeAxisView::set_height (gdouble h) return(0) ; } - + /** * Sets the position of this view helper on the canvas * @@ -154,17 +134,19 @@ int ImageFrameTimeAxisView::set_position (gdouble x, gdouble y) { - gtk_canvas_item_set (canvas_group, "x", x, "y", y, NULL); + canvas_group.property_x() = x; + canvas_group.property_y() = y; + return 0; } /** * Sets the current samples per unit. * this method tells each item upon the time axis of the change - * + * * @param spu the new samples per canvas unit value */ -int +int ImageFrameTimeAxisView::set_samples_per_unit (gdouble spp) { if (spp < 1.0) { @@ -172,12 +154,12 @@ ImageFrameTimeAxisView::set_samples_per_unit (gdouble spp) } _samples_per_unit = spp; - + for(ImageFrameGroupList::const_iterator citer = imageframe_groups.begin(); citer != imageframe_groups.end(); ++citer) { (*citer)->set_item_samples_per_units(spp) ; } - + return(0) ; } @@ -187,7 +169,7 @@ ImageFrameTimeAxisView::set_samples_per_unit (gdouble spp) * @param color the new base color */ void -ImageFrameTimeAxisView::apply_color(GdkColor& color) +ImageFrameTimeAxisView::apply_color(Gdk::Color& color) { region_color = color ; for(ImageFrameGroupList::const_iterator citer = imageframe_groups.begin(); citer != imageframe_groups.end(); citer++) @@ -210,7 +192,7 @@ ImageFrameTimeAxisView::reset_samples_per_unit () //---------------------------------------------------------------------------------------// // Child ImageFrameTimeAxisGroup Accessors/Mutators - + /** * Adds an ImageFrameTimeAxisGroup to the list of items upon this time axis view helper * the new ImageFrameTimeAxisGroup is returned @@ -222,7 +204,7 @@ ImageFrameTimeAxisGroup* ImageFrameTimeAxisView::add_imageframe_group(std::string group_id, void* src) { ImageFrameTimeAxisGroup* iftag = 0 ; - + //check that there is not already a group with that id if(get_named_imageframe_group(group_id) != 0) { @@ -231,12 +213,8 @@ ImageFrameTimeAxisView::add_imageframe_group(std::string group_id, void* src) else { iftag = new ImageFrameTimeAxisGroup(*this, group_id) ; - imageframe_groups.push_front(iftag) ; - - iftag->GoingAway.connect(bind(slot (*this,&ImageFrameTimeAxisView::remove_imageframe_group), iftag, (void*)this)) ; - - ImageFrameGroupAdded(iftag, src) ; /* EMIT_SIGNAL */ + ImageFrameGroupAdded(iftag, src) ; /* EMIT_SIGNAL */ } return(iftag) ; @@ -252,7 +230,7 @@ ImageFrameTimeAxisGroup* ImageFrameTimeAxisView::get_named_imageframe_group(std::string group_id) { ImageFrameTimeAxisGroup* iftag = 0 ; - + for(ImageFrameGroupList::iterator i = imageframe_groups.begin(); i != imageframe_groups.end(); ++i) { if (((ImageFrameTimeAxisGroup*)*i)->get_group_name() == group_id) @@ -261,7 +239,7 @@ ImageFrameTimeAxisView::get_named_imageframe_group(std::string group_id) break ; } } - + return(iftag) ; } @@ -277,27 +255,27 @@ ImageFrameTimeAxisGroup* ImageFrameTimeAxisView::remove_named_imageframe_group(std::string group_id, void* src) { ImageFrameTimeAxisGroup* removed = 0 ; - + for(ImageFrameGroupList::iterator iter = imageframe_groups.begin(); iter != imageframe_groups.end(); ++iter) { if(((ImageFrameTimeAxisGroup*)*iter)->get_group_name() == group_id) { removed = (*iter) ; imageframe_groups.erase(iter) ; - + if(removed == selected_imageframe_group) { selected_imageframe_group = 0 ; } - + ImageFrameGroupRemoved(removed->get_group_name(), src) ; /* EMIT_SIGNAL */ - + // break from the for loop break ; } iter++ ; } - + return(removed) ; } @@ -310,13 +288,13 @@ ImageFrameTimeAxisView::remove_named_imageframe_group(std::string group_id, void void ImageFrameTimeAxisView::remove_imageframe_group(ImageFrameTimeAxisGroup* iftag, void* src) { - ENSURE_GUI_THREAD(bind (slot (*this, &ImageFrameTimeAxisView::remove_imageframe_group), iftag, src)); + ENSURE_GUI_THREAD (*this, &ImageFrameTimeAxisView::remove_imageframe_group, iftag, src) ImageFrameGroupList::iterator i; if((i = find (imageframe_groups.begin(), imageframe_groups.end(), iftag)) != imageframe_groups.end()) { imageframe_groups.erase(i) ; - + ImageFrameGroupRemoved(iftag->get_group_name(), src) ; /* EMIT_SIGNAL */ } } @@ -326,7 +304,7 @@ ImageFrameTimeAxisView::remove_imageframe_group(ImageFrameTimeAxisGroup* iftag, //---------------------------------------------------------------------------------------// // Selected group methods - + /** * Sets the currently selected group upon this time axis * @@ -339,7 +317,7 @@ ImageFrameTimeAxisView::set_selected_imageframe_group(ImageFrameTimeAxisGroup* i { selected_imageframe_group->set_selected(false) ; } - + selected_imageframe_group = iftag ; selected_imageframe_group->set_selected(true) ; } @@ -357,7 +335,7 @@ ImageFrameTimeAxisView::clear_selected_imageframe_group() } selected_imageframe_group = 0 ; } - + /** * Returns the currently selected group upon this time axis * @@ -371,7 +349,7 @@ ImageFrameTimeAxisView::get_selected_imageframe_group() const //---------------------------------------------------------------------------------------// // Selected item methods - + /** * Sets the currently selected imag frame view item * @@ -382,14 +360,14 @@ void ImageFrameTimeAxisView::set_selected_imageframe_view(ImageFrameTimeAxisGroup* iftag, ImageFrameView* ifv) { set_selected_imageframe_group(iftag) ; - + if(selected_imageframe_view) { - selected_imageframe_view->set_selected(false, this) ; + selected_imageframe_view->set_selected(false) ; } - + selected_imageframe_view = ifv ; - selected_imageframe_view->set_selected(true, this) ; + selected_imageframe_view->set_selected(true) ; } /** @@ -403,14 +381,14 @@ ImageFrameTimeAxisView::clear_selected_imageframe_item(bool clear_group) { clear_selected_imageframe_group() ; } - + if(selected_imageframe_view) { - selected_imageframe_view->set_selected(false, this) ; + selected_imageframe_view->set_selected(false) ; } selected_imageframe_view = 0 ; } - + /** * Returns the currently selected image frame view item upon this time axis * @@ -424,13 +402,12 @@ ImageFrameTimeAxisView::get_selected_imageframe_view() const - + void ImageFrameTimeAxisView::set_imageframe_duration_sec(double sec) { - if(selected_imageframe_group && selected_imageframe_view) - { - selected_imageframe_view->set_duration((jack_nframes_t) (sec * _trackview.editor.current_session()->frame_rate()), this) ; + if (selected_imageframe_group && selected_imageframe_view) { + selected_imageframe_view->set_duration ((sec * _trackview.editor.session()->frame_rate()), this); } } @@ -449,7 +426,7 @@ ImageFrameTimeAxisView::remove_selected_imageframe_item(void* src) { ImageFrameView* temp_item = selected_imageframe_view ; selected_imageframe_group->remove_imageframe_item(temp_item, src) ; - + // XXX although we have removed the item from the group, we need the group id still set within the // item as the remove method requires this data when telling others about the deletion // to fully specify the item we need the track, group and item id