Fix insane formatting (how did this even happen? copy paste from an email diff or something?).

git-svn-id: svn://localhost/ardour2/branches/3.0@4631 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2009-02-19 00:25:24 +00:00
parent df329436ea
commit 2e1332f74f

View file

@ -1,4 +1,4 @@
/* /*
Copyright (C) 2000 Paul Davis Copyright (C) 2000 Paul Davis
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
@ -15,71 +15,71 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <cstdlib> #include <cstdlib>
#include <cmath> #include <cmath>
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#include <list> #include <list>
#include <libgnomecanvasmm.h> #include <libgnomecanvasmm.h>
#include <libgnomecanvasmm/canvas.h> #include <libgnomecanvasmm/canvas.h>
#include <libgnomecanvasmm/item.h> #include <libgnomecanvasmm/item.h>
#include <pbd/error.h> #include <pbd/error.h>
#include <gtkmm2ext/utils.h> #include <gtkmm2ext/utils.h>
#include <gtkmm2ext/selector.h> #include <gtkmm2ext/selector.h>
#include <gtkmm2ext/stop_signal.h> #include <gtkmm2ext/stop_signal.h>
#include <ardour/session.h> #include <ardour/session.h>
#include <ardour/utils.h> #include <ardour/utils.h>
#include <ardour/ladspa_plugin.h> #include <ardour/ladspa_plugin.h>
#include <ardour/processor.h> #include <ardour/processor.h>
#include <ardour/location.h> #include <ardour/location.h>
#include "ardour_ui.h" #include "ardour_ui.h"
#include "public_editor.h" #include "public_editor.h"
#include "time_axis_view.h" #include "time_axis_view.h"
#include "region_view.h" #include "region_view.h"
#include "ghostregion.h" #include "ghostregion.h"
#include "simplerect.h" #include "simplerect.h"
#include "simpleline.h" #include "simpleline.h"
#include "selection.h" #include "selection.h"
#include "keyboard.h" #include "keyboard.h"
#include "rgb_macros.h" #include "rgb_macros.h"
#include "utils.h" #include "utils.h"
#include "streamview.h" #include "streamview.h"
#include "i18n.h" #include "i18n.h"
using namespace Gtk; using namespace Gtk;
using namespace Gdk; using namespace Gdk;
using namespace sigc; using namespace sigc;
using namespace ARDOUR; using namespace ARDOUR;
using namespace PBD; using namespace PBD;
using namespace Editing; using namespace Editing;
using namespace ArdourCanvas; using namespace ArdourCanvas;
const double trim_handle_size = 6.0; /* pixels */ const double trim_handle_size = 6.0; /* pixels */
uint32_t TimeAxisView::hLargest = 0; uint32_t TimeAxisView::hLargest = 0;
uint32_t TimeAxisView::hLarge = 0; uint32_t TimeAxisView::hLarge = 0;
uint32_t TimeAxisView::hLarger = 0; uint32_t TimeAxisView::hLarger = 0;
uint32_t TimeAxisView::hNormal = 0; uint32_t TimeAxisView::hNormal = 0;
uint32_t TimeAxisView::hSmaller = 0; uint32_t TimeAxisView::hSmaller = 0;
uint32_t TimeAxisView::hSmall = 0; uint32_t TimeAxisView::hSmall = 0;
bool TimeAxisView::need_size_info = true; bool TimeAxisView::need_size_info = true;
int const TimeAxisView::_max_order = 512; int const TimeAxisView::_max_order = 512;
TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* rent, Canvas& canvas) TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisView* rent, Canvas& canvas)
: AxisView (sess), : AxisView (sess),
controls_table (2, 8), controls_table (2, 8),
_y_position (0), _y_position (0),
_editor (ed), _editor (ed),
_order (0) _order (0)
{ {
if (need_size_info) { if (need_size_info) {
compute_controls_size_info (); compute_controls_size_info ();
need_size_info = false; need_size_info = false;
@ -180,10 +180,10 @@
// controls_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT); // controls_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
ColorsChanged.connect (mem_fun (*this, &TimeAxisView::color_handler)); ColorsChanged.connect (mem_fun (*this, &TimeAxisView::color_handler));
} }
TimeAxisView::~TimeAxisView() TimeAxisView::~TimeAxisView()
{ {
in_destructor = true; in_destructor = true;
for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) { for (list<GhostRegion*>::iterator i = ghosts.begin(); i != ghosts.end(); ++i) {
@ -218,18 +218,18 @@
delete display_menu; delete display_menu;
display_menu = 0; display_menu = 0;
} }
/** Display this TimeAxisView as the nth component of the parent box, at y. /** Display this TimeAxisView as the nth component of the parent box, at y.
* *
* @param y y position. * @param y y position.
* @param nth index for this TimeAxisView, increased if this view has children. * @param nth index for this TimeAxisView, increased if this view has children.
* @param parent parent component. * @param parent parent component.
* @return height of this TimeAxisView. * @return height of this TimeAxisView.
*/ */
guint32 guint32
TimeAxisView::show_at (double y, int& nth, VBox *parent) TimeAxisView::show_at (double y, int& nth, VBox *parent)
{ {
if (control_parent) { if (control_parent) {
control_parent->reorder_child (controls_hbox, nth); control_parent->reorder_child (controls_hbox, nth);
} else { } else {
@ -273,11 +273,11 @@
} }
return _effective_height; return _effective_height;
} }
void void
TimeAxisView::clip_to_viewport () TimeAxisView::clip_to_viewport ()
{ {
if (_marked_for_display) { if (_marked_for_display) {
if (_y_position + _effective_height < _editor.get_trackview_group_vertical_offset () || _y_position > _editor.get_trackview_group_vertical_offset () + _canvas_display->get_canvas()->get_height()) { if (_y_position + _effective_height < _editor.get_trackview_group_vertical_offset () || _y_position > _editor.get_trackview_group_vertical_offset () + _canvas_display->get_canvas()->get_height()) {
_canvas_background->hide (); _canvas_background->hide ();
@ -288,11 +288,11 @@
_canvas_display->show (); _canvas_display->show ();
} }
return; return;
} }
bool bool
TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev) TimeAxisView::controls_ebox_scroll (GdkEventScroll* ev)
{ {
switch (ev->direction) { switch (ev->direction) {
case GDK_SCROLL_UP: case GDK_SCROLL_UP:
if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
@ -320,11 +320,11 @@
} }
return false; return false;
} }
bool bool
TimeAxisView::controls_ebox_button_release (GdkEventButton* ev) TimeAxisView::controls_ebox_button_release (GdkEventButton* ev)
{ {
switch (ev->button) { switch (ev->button) {
case 1: case 1:
selection_click (ev); selection_click (ev);
@ -336,18 +336,18 @@
} }
return true; return true;
} }
void void
TimeAxisView::selection_click (GdkEventButton* ev) TimeAxisView::selection_click (GdkEventButton* ev)
{ {
Selection::Operation op = Keyboard::selection_type (ev->state); Selection::Operation op = Keyboard::selection_type (ev->state);
_editor.set_selected_track (*this, op, false); _editor.set_selected_track (*this, op, false);
} }
void void
TimeAxisView::hide () TimeAxisView::hide ()
{ {
if (_hidden) { if (_hidden) {
return; return;
} }
@ -375,11 +375,11 @@
_editor.get_selection().remove (this); _editor.get_selection().remove (this);
Hiding (); Hiding ();
} }
void void
TimeAxisView::step_height (bool bigger) TimeAxisView::step_height (bool bigger)
{ {
static const uint32_t step = 20; static const uint32_t step = 20;
if (bigger) { if (bigger) {
@ -391,21 +391,21 @@
set_height (hSmall); set_height (hSmall);
} }
} }
} }
void void
TimeAxisView::set_heights (uint32_t h) TimeAxisView::set_heights (uint32_t h)
{ {
TrackSelection& ts (_editor.get_selection().tracks); TrackSelection& ts (_editor.get_selection().tracks);
for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) { for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) {
(*i)->set_height (h); (*i)->set_height (h);
} }
} }
void void
TimeAxisView::set_height(uint32_t h) TimeAxisView::set_height(uint32_t h)
{ {
controls_ebox.property_height_request () = h; controls_ebox.property_height_request () = h;
height = h; height = h;
@ -419,11 +419,11 @@
} }
reshow_feature_lines (); reshow_feature_lines ();
} }
bool bool
TimeAxisView::name_entry_key_release (GdkEventKey* ev) TimeAxisView::name_entry_key_release (GdkEventKey* ev)
{ {
PublicEditor::TrackViewList *allviews = 0; PublicEditor::TrackViewList *allviews = 0;
PublicEditor::TrackViewList::iterator i; PublicEditor::TrackViewList::iterator i;
@ -478,7 +478,7 @@
break; break;
} }
#ifdef TIMEOUT_NAME_EDIT #ifdef TIMEOUT_NAME_EDIT
/* adapt the timeout to reflect the user's typing speed */ /* adapt the timeout to reflect the user's typing speed */
guint32 name_entry_timeout; guint32 name_entry_timeout;
@ -497,22 +497,22 @@
name_entry_key_timeout.disconnect(); name_entry_key_timeout.disconnect();
name_entry_key_timeout = Glib::signal_timeout().connect (mem_fun (*this, &TimeAxisView::name_entry_key_timed_out), name_entry_timeout); name_entry_key_timeout = Glib::signal_timeout().connect (mem_fun (*this, &TimeAxisView::name_entry_key_timed_out), name_entry_timeout);
#endif #endif
return false; return false;
} }
bool bool
TimeAxisView::name_entry_focus_in (GdkEventFocus* ev) TimeAxisView::name_entry_focus_in (GdkEventFocus* ev)
{ {
name_entry.select_region (0, -1); name_entry.select_region (0, -1);
name_entry.set_name ("EditorActiveTrackNameDisplay"); name_entry.set_name ("EditorActiveTrackNameDisplay");
return false; return false;
} }
bool bool
TimeAxisView::name_entry_focus_out (GdkEventFocus* ev) TimeAxisView::name_entry_focus_out (GdkEventFocus* ev)
{ {
/* clean up */ /* clean up */
last_name_entry_key_press_event = 0; last_name_entry_key_press_event = 0;
@ -525,86 +525,86 @@
name_entry_changed (); name_entry_changed ();
return false; return false;
} }
bool bool
TimeAxisView::name_entry_key_timed_out () TimeAxisView::name_entry_key_timed_out ()
{ {
name_entry_activated(); name_entry_activated();
return false; return false;
} }
void void
TimeAxisView::name_entry_activated () TimeAxisView::name_entry_activated ()
{ {
controls_ebox.grab_focus(); controls_ebox.grab_focus();
} }
void void
TimeAxisView::name_entry_changed () TimeAxisView::name_entry_changed ()
{ {
} }
bool bool
TimeAxisView::name_entry_button_press (GdkEventButton *ev) TimeAxisView::name_entry_button_press (GdkEventButton *ev)
{ {
if (ev->button == 3) { if (ev->button == 3) {
return true; return true;
} }
return false; return false;
} }
bool bool
TimeAxisView::name_entry_button_release (GdkEventButton *ev) TimeAxisView::name_entry_button_release (GdkEventButton *ev)
{ {
if (ev->button == 3) { if (ev->button == 3) {
popup_display_menu (ev->time); popup_display_menu (ev->time);
return true; return true;
} }
return false; return false;
} }
void void
TimeAxisView::conditionally_add_to_selection () TimeAxisView::conditionally_add_to_selection ()
{ {
Selection& s (_editor.get_selection ()); Selection& s (_editor.get_selection ());
if (!s.selected (this)) { if (!s.selected (this)) {
_editor.set_selected_track (*this, Selection::Set); _editor.set_selected_track (*this, Selection::Set);
} }
} }
void void
TimeAxisView::popup_display_menu (guint32 when) TimeAxisView::popup_display_menu (guint32 when)
{ {
if (display_menu == 0) { if (display_menu == 0) {
build_display_menu (); build_display_menu ();
} }
conditionally_add_to_selection (); conditionally_add_to_selection ();
display_menu->popup (1, when); display_menu->popup (1, when);
} }
gint gint
TimeAxisView::size_click (GdkEventButton *ev) TimeAxisView::size_click (GdkEventButton *ev)
{ {
conditionally_add_to_selection (); conditionally_add_to_selection ();
popup_size_menu (ev->time); popup_size_menu (ev->time);
return TRUE; return TRUE;
} }
void void
TimeAxisView::popup_size_menu (guint32 when) TimeAxisView::popup_size_menu (guint32 when)
{ {
if (size_menu == 0) { if (size_menu == 0) {
build_size_menu (); build_size_menu ();
} }
size_menu->popup (1, when); size_menu->popup (1, when);
} }
void void
TimeAxisView::set_selected (bool yn) TimeAxisView::set_selected (bool yn)
{ {
if (yn == _selected) { if (yn == _selected) {
return; return;
} }
@ -638,11 +638,11 @@
} }
resizer.queue_draw (); resizer.queue_draw ();
} }
void void
TimeAxisView::build_size_menu () TimeAxisView::build_size_menu ()
{ {
using namespace Menu_Helpers; using namespace Menu_Helpers;
size_menu = new Menu; size_menu = new Menu;
@ -655,22 +655,22 @@
items.push_back (MenuElem (_("Normal"), bind (mem_fun (*this, &TimeAxisView::set_heights), hNormal))); items.push_back (MenuElem (_("Normal"), bind (mem_fun (*this, &TimeAxisView::set_heights), hNormal)));
items.push_back (MenuElem (_("Smaller"), bind (mem_fun (*this, &TimeAxisView::set_heights),hSmaller))); items.push_back (MenuElem (_("Smaller"), bind (mem_fun (*this, &TimeAxisView::set_heights),hSmaller)));
items.push_back (MenuElem (_("Small"), bind (mem_fun (*this, &TimeAxisView::set_heights), hSmall))); items.push_back (MenuElem (_("Small"), bind (mem_fun (*this, &TimeAxisView::set_heights), hSmall)));
} }
void void
TimeAxisView::build_display_menu () TimeAxisView::build_display_menu ()
{ {
using namespace Menu_Helpers; using namespace Menu_Helpers;
display_menu = new Menu; display_menu = new Menu;
display_menu->set_name ("ArdourContextMenu"); display_menu->set_name ("ArdourContextMenu");
// Just let implementing classes define what goes into the manu // Just let implementing classes define what goes into the manu
} }
void void
TimeAxisView::set_samples_per_unit (double spu) TimeAxisView::set_samples_per_unit (double spu)
{ {
for (Children::iterator i = children.begin(); i != children.end(); ++i) { for (Children::iterator i = children.begin(); i != children.end(); ++i) {
(*i)->set_samples_per_unit (spu); (*i)->set_samples_per_unit (spu);
} }
@ -682,27 +682,27 @@
(*l)->property_x1() = _editor.frame_to_pixel (*i); (*l)->property_x1() = _editor.frame_to_pixel (*i);
(*l)->property_x2() = _editor.frame_to_pixel (*i); (*l)->property_x2() = _editor.frame_to_pixel (*i);
} }
} }
void void
TimeAxisView::show_timestretch (nframes_t start, nframes_t end) TimeAxisView::show_timestretch (nframes_t start, nframes_t end)
{ {
for (Children::iterator i = children.begin(); i != children.end(); ++i) { for (Children::iterator i = children.begin(); i != children.end(); ++i) {
(*i)->show_timestretch (start, end); (*i)->show_timestretch (start, end);
} }
} }
void void
TimeAxisView::hide_timestretch () TimeAxisView::hide_timestretch ()
{ {
for (Children::iterator i = children.begin(); i != children.end(); ++i) { for (Children::iterator i = children.begin(); i != children.end(); ++i) {
(*i)->hide_timestretch (); (*i)->hide_timestretch ();
} }
} }
void void
TimeAxisView::show_selection (TimeSelection& ts) TimeAxisView::show_selection (TimeSelection& ts)
{ {
double x1; double x1;
double x2; double x2;
double y2; double y2;
@ -767,21 +767,21 @@
rect->rect->show (); rect->rect->show ();
used_selection_rects.push_back (rect); used_selection_rects.push_back (rect);
} }
} }
void void
TimeAxisView::reshow_selection (TimeSelection& ts) TimeAxisView::reshow_selection (TimeSelection& ts)
{ {
show_selection (ts); show_selection (ts);
for (Children::iterator i = children.begin(); i != children.end(); ++i) { for (Children::iterator i = children.begin(); i != children.end(); ++i) {
(*i)->show_selection (ts); (*i)->show_selection (ts);
} }
} }
void void
TimeAxisView::hide_selection () TimeAxisView::hide_selection ()
{ {
if (canvas_item_visible (selection_group)) { if (canvas_item_visible (selection_group)) {
while (!used_selection_rects.empty()) { while (!used_selection_rects.empty()) {
free_selection_rects.push_front (used_selection_rects.front()); free_selection_rects.push_front (used_selection_rects.front());
@ -796,11 +796,11 @@
for (Children::iterator i = children.begin(); i != children.end(); ++i) { for (Children::iterator i = children.begin(); i != children.end(); ++i) {
(*i)->hide_selection (); (*i)->hide_selection ();
} }
} }
void void
TimeAxisView::order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top) TimeAxisView::order_selection_trims (ArdourCanvas::Item *item, bool put_start_on_top)
{ {
/* find the selection rect this is for. we have the item corresponding to one /* find the selection rect this is for. we have the item corresponding to one
of the trim handles. of the trim handles.
*/ */
@ -819,11 +819,11 @@
break; break;
} }
} }
} }
SelectionRect * SelectionRect *
TimeAxisView::get_selection_rect (uint32_t id) TimeAxisView::get_selection_rect (uint32_t id)
{ {
SelectionRect *rect; SelectionRect *rect;
/* check to see if we already have a visible rect for this particular selection ID */ /* check to see if we already have a visible rect for this particular selection ID */
@ -881,56 +881,57 @@
rect->id = id; rect->id = id;
free_selection_rects.pop_front(); free_selection_rects.pop_front();
return rect; return rect;
} }
struct null_deleter { void operator()(void const *) const {} }; struct null_deleter { void operator()(void const *) const {} };
bool bool
TimeAxisView::is_child (TimeAxisView* tav) TimeAxisView::is_child (TimeAxisView* tav)
{ {
return find (children.begin(), children.end(), boost::shared_ptr<TimeAxisView>(tav, null_deleter())) != children.end(); return find (children.begin(), children.end(), boost::shared_ptr<TimeAxisView>(tav, null_deleter())) != children.end();
} }
void void
TimeAxisView::add_child (boost::shared_ptr<TimeAxisView> child) TimeAxisView::add_child (boost::shared_ptr<TimeAxisView> child)
{ {
children.push_back (child); children.push_back (child);
} }
void void
TimeAxisView::remove_child (boost::shared_ptr<TimeAxisView> child) TimeAxisView::remove_child (boost::shared_ptr<TimeAxisView> child)
{ {
Children::iterator i; Children::iterator i;
if ((i = find (children.begin(), children.end(), child)) != children.end()) { if ((i = find (children.begin(), children.end(), child)) != children.end()) {
children.erase (i); children.erase (i);
} }
} }
void void
TimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& result) TimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable*>& result)
{ {
return; return;
} }
void void
TimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result) TimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& result)
{ {
return; return;
} }
void void
TimeAxisView::add_ghost (RegionView* rv) { TimeAxisView::add_ghost (RegionView* rv)
{
GhostRegion* gr = rv->add_ghost (*this); GhostRegion* gr = rv->add_ghost (*this);
if(gr) { if(gr) {
ghosts.push_back(gr); ghosts.push_back(gr);
gr->GoingAway.connect (mem_fun(*this, &TimeAxisView::erase_ghost)); gr->GoingAway.connect (mem_fun(*this, &TimeAxisView::erase_ghost));
} }
} }
void void
TimeAxisView::remove_ghost (RegionView* rv) { TimeAxisView::remove_ghost (RegionView* rv) {
rv->remove_ghost_in (*this); rv->remove_ghost_in (*this);
} }