Merge with 2.0-ongoing R2653.

git-svn-id: svn://localhost/ardour2/trunk@2837 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2008-01-07 21:12:29 +00:00
parent c4110b37f0
commit 73dd9d37e7
7 changed files with 138 additions and 36 deletions

View file

@ -410,12 +410,14 @@ AudioRegionView::region_muted ()
void void
AudioRegionView::set_y_position_and_height (double y, double h) AudioRegionView::set_y_position_and_height (double y, double h)
{ {
RegionView::set_y_position_and_height(y, h - 1); //RegionView::set_y_position_and_height(y, h - 1);
RegionView::set_height (height);
const uint32_t wcnt = waves.size();
_y_position = y; _y_position = y;
_height = h; _height = h;
uint32_t const wcnt = waves.size();
for (uint32_t n = 0; n < wcnt; ++n) { for (uint32_t n = 0; n < wcnt; ++n) {
double ht; double ht;

View file

@ -171,6 +171,7 @@ Gdk::Cursor* Editor::midi_select_cursor = 0;
Gdk::Cursor* Editor::midi_erase_cursor = 0; Gdk::Cursor* Editor::midi_erase_cursor = 0;
Gdk::Cursor* Editor::wait_cursor = 0; Gdk::Cursor* Editor::wait_cursor = 0;
Gdk::Cursor* Editor::timebar_cursor = 0; Gdk::Cursor* Editor::timebar_cursor = 0;
Gdk::Cursor* Editor::transparent_cursor = 0;
void void
show_me_the_size (Requisition* r, const char* what) show_me_the_size (Requisition* r, const char* what)
@ -1311,6 +1312,14 @@ Editor::build_cursors ()
speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot); speaker_cursor = new Gdk::Cursor (source, mask, ffg, fbg, speaker_cursor_x_hot, speaker_cursor_y_hot);
} }
{
RefPtr<Bitmap> bits;
char pix[4] = { 0, 0, 0, 0 };
bits = Bitmap::create (pix, 2, 2);
Gdk::Color c;
transparent_cursor = new Gdk::Cursor (bits, bits, c, c, 0, 0);
}
grabber_cursor = new Gdk::Cursor (HAND2); grabber_cursor = new Gdk::Cursor (HAND2);
cross_hair_cursor = new Gdk::Cursor (CROSSHAIR); cross_hair_cursor = new Gdk::Cursor (CROSSHAIR);
trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW); trimmer_cursor = new Gdk::Cursor (SB_H_DOUBLE_ARROW);

View file

@ -907,6 +907,7 @@ class Editor : public PublicEditor
static Gdk::Cursor* midi_erase_cursor; static Gdk::Cursor* midi_erase_cursor;
static Gdk::Cursor* wait_cursor; static Gdk::Cursor* wait_cursor;
static Gdk::Cursor* timebar_cursor; static Gdk::Cursor* timebar_cursor;
static Gdk::Cursor* transparent_cursor;
static void build_cursors (); static void build_cursors ();
@ -1155,6 +1156,8 @@ class Editor : public PublicEditor
bool _scrubbing; bool _scrubbing;
double last_scrub_x; double last_scrub_x;
int scrubbing_direction; int scrubbing_direction;
int scrub_reversals;
int scrub_reverse_distance;
void keyboard_selection_begin (); void keyboard_selection_begin ();
void keyboard_selection_finish (bool add); void keyboard_selection_finish (bool add);
@ -1983,6 +1986,7 @@ class Editor : public PublicEditor
TimeAxisView* entered_track; TimeAxisView* entered_track;
RegionView* entered_regionview; RegionView* entered_regionview;
void ensure_entered_selected ();
bool clear_entered_track; bool clear_entered_track;
gint left_track_canvas (GdkEventCrossing*); gint left_track_canvas (GdkEventCrossing*);
void set_entered_track (TimeAxisView*); void set_entered_track (TimeAxisView*);

View file

@ -649,8 +649,7 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp
} else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) { } else if (Keyboard::modifier_state_equals (event->button.state, Keyboard::Control)) {
/* grab selection for moving */ /* grab selection for moving */
start_selection_op (item, event, SelectionMove); start_selection_op (item, event, SelectionMove);
} } else {
else {
/* this was debated, but decided the more common action was to /* this was debated, but decided the more common action was to
make a new selection */ make a new selection */
start_selection_op (item, event, CreateSelection); start_selection_op (item, event, CreateSelection);
@ -810,8 +809,11 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp
case MouseAudition: case MouseAudition:
_scrubbing = true; _scrubbing = true;
scrub_reversals = 0;
scrub_reverse_distance = 0;
last_scrub_x = event->button.x; last_scrub_x = event->button.x;
scrubbing_direction = 0; scrubbing_direction = 0;
track_canvas.get_window()->set_cursor (*transparent_cursor);
/* rest handled in motion & release */ /* rest handled in motion & release */
break; break;
@ -1144,6 +1146,7 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
case MouseAudition: case MouseAudition:
_scrubbing = false; _scrubbing = false;
track_canvas.get_window()->set_cursor (*current_canvas_cursor);
if (scrubbing_direction == 0) { if (scrubbing_direction == 0) {
/* no drag, just a click */ /* no drag, just a click */
switch (item_type) { switch (item_type) {
@ -1548,39 +1551,67 @@ Editor::motion_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item
scrubbing_direction = 1; scrubbing_direction = 1;
} else { } else {
if (last_scrub_x > drag_info.current_pointer_x) { if (last_scrub_x > drag_info.current_pointer_x) {
/* move to the left */
/* pointer moved to the left */
if (scrubbing_direction > 0) { if (scrubbing_direction > 0) {
/* we reversed direction to go backwards */ /* we reversed direction to go backwards */
session->request_transport_speed (-0.1); scrub_reversals++;
scrub_reverse_distance += (int) (last_scrub_x - drag_info.current_pointer_x);
} else { } else {
/* still moving to the left (backwards) */ /* still moving to the left (backwards) */
delta = 0.005 * (last_scrub_x - drag_info.current_pointer_x); scrub_reversals = 0;
scrub_reverse_distance = 0;
delta = 0.01 * (last_scrub_x - drag_info.current_pointer_x);
session->request_transport_speed (session->transport_speed() - delta); session->request_transport_speed (session->transport_speed() - delta);
} }
scrubbing_direction = -1;
} else { } else {
/* move to the right */ /* pointer moved to the right */
if (scrubbing_direction < 0) { if (scrubbing_direction < 0) {
/* we reversed direction to go forward */ /* we reversed direction to go forward */
session->request_transport_speed (0.1); scrub_reversals++;
scrub_reverse_distance += (int) (drag_info.current_pointer_x - last_scrub_x);
} else { } else {
/* still moving to the right */ /* still moving to the right */
scrub_reversals = 0;
scrub_reverse_distance = 0;
delta = 0.005 * (drag_info.current_pointer_x - last_scrub_x); delta = 0.01 * (drag_info.current_pointer_x - last_scrub_x);
session->request_transport_speed (session->transport_speed() + delta); session->request_transport_speed (session->transport_speed() + delta);
} }
}
/* if there have been more than 2 opposite motion moves detected, or one that moves
back more than 10 pixels, reverse direction
*/
if (scrub_reversals >= 2 || scrub_reverse_distance > 10) {
if (scrubbing_direction > 0) {
/* was forwards, go backwards */
session->request_transport_speed (-0.1);
scrubbing_direction = -1;
} else {
/* was backwards, go forwards */
session->request_transport_speed (0.1);
scrubbing_direction = 1;
}
scrubbing_direction = 1; scrub_reverse_distance = 0;
scrub_reversals = 0;
} }
} }

View file

@ -2306,6 +2306,8 @@ Editor::separate_regions_using_location (Location& loc)
void void
Editor::crop_region_to_selection () Editor::crop_region_to_selection ()
{ {
ensure_entered_selected ();
if (!selection->time.empty()) { if (!selection->time.empty()) {
crop_region_to (selection->time.start(), selection->time.end_frame()); crop_region_to (selection->time.start(), selection->time.end_frame());
@ -2329,6 +2331,8 @@ Editor::crop_region_to (nframes_t start, nframes_t end)
boost::shared_ptr<Playlist> playlist; boost::shared_ptr<Playlist> playlist;
TrackSelection* ts; TrackSelection* ts;
ensure_entered_selected ();
if (selection->tracks.empty()) { if (selection->tracks.empty()) {
ts = &track_views; ts = &track_views;
} else { } else {
@ -2567,6 +2571,8 @@ Editor::naturalize ()
void void
Editor::align (RegionPoint what) Editor::align (RegionPoint what)
{ {
ensure_entered_selected ();
nframes64_t where = get_preferred_edit_position(); nframes64_t where = get_preferred_edit_position();
if (!selection->regions.empty()) { if (!selection->regions.empty()) {
@ -2731,6 +2737,8 @@ Editor::trim_region_to_punch ()
void void
Editor::trim_region_to_location (const Location& loc, const char* str) Editor::trim_region_to_location (const Location& loc, const char* str)
{ {
ensure_entered_selected ();
RegionSelection& rs (get_regions_for_action ()); RegionSelection& rs (get_regions_for_action ());
begin_reversible_command (str); begin_reversible_command (str);
@ -3907,6 +3915,8 @@ Editor::toggle_region_opaque ()
void void
Editor::set_fade_length (bool in) Editor::set_fade_length (bool in)
{ {
ensure_entered_selected ();
/* we need a region to measure the offset from the start */ /* we need a region to measure the offset from the start */
RegionView* rv; RegionView* rv;
@ -4131,6 +4141,8 @@ Editor::set_playhead_cursor ()
void void
Editor::split () Editor::split ()
{ {
ensure_entered_selected ();
nframes64_t where = get_preferred_edit_position(); nframes64_t where = get_preferred_edit_position();
if (!selection->regions.empty()) { if (!selection->regions.empty()) {
@ -4144,3 +4156,13 @@ Editor::split ()
split_regions_at (where, rs); split_regions_at (where, rs);
} }
} }
void
Editor::ensure_entered_selected ()
{
if (entered_regionview) {
if (find (selection->regions.begin(), selection->regions.end(), entered_regionview) == selection->regions.end()) {
selection->set (entered_regionview);
}
}
}

View file

@ -70,6 +70,7 @@ RegionView::RegionView (ArdourCanvas::Group* parent,
TimeAxisViewItem::ShowFrame)) TimeAxisViewItem::ShowFrame))
, _region (r) , _region (r)
, sync_mark(0) , sync_mark(0)
, sync_line(0)
, editor(0) , editor(0)
, current_visible_sync_position(0.0) , current_visible_sync_position(0.0)
, valid(false) , valid(false)
@ -102,6 +103,7 @@ RegionView::RegionView (ArdourCanvas::Group* parent,
: TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), visibility) : TimeAxisViewItem (r->name(), *parent, tv, spu, basic_color, r->position(), r->length(), visibility)
, _region (r) , _region (r)
, sync_mark(0) , sync_mark(0)
, sync_line(0)
, editor(0) , editor(0)
, current_visible_sync_position(0.0) , current_visible_sync_position(0.0)
, valid(false) , valid(false)
@ -119,6 +121,8 @@ RegionView::init (Gdk::Color& basic_color, bool wfd)
_enable_display = false; _enable_display = false;
in_destructor = false; in_destructor = false;
wait_for_data = wfd; wait_for_data = wfd;
sync_mark = 0;
sync_line = 0;
compute_colors (basic_color); compute_colors (basic_color);
@ -128,19 +132,6 @@ RegionView::init (Gdk::Color& basic_color, bool wfd)
name_text->set_data ("regionview", this); name_text->set_data ("regionview", this);
} }
/* an equilateral triangle */
ArdourCanvas::Points shape;
shape.push_back (Gnome::Art::Point (-((sync_mark_width-1)/2), 1));
shape.push_back (Gnome::Art::Point ((sync_mark_width - 1)/2, 1));
shape.push_back (Gnome::Art::Point (0, sync_mark_width - 1));
shape.push_back (Gnome::Art::Point (-((sync_mark_width-1)/2), 1));
sync_mark = new ArdourCanvas::Polygon (*group);
sync_mark->property_points() = shape;
sync_mark->property_fill_color_rgba() = fill_color;
sync_mark->hide();
//reset_width_dependent_items ((double) _region->length() / samples_per_unit); //reset_width_dependent_items ((double) _region->length() / samples_per_unit);
if (wfd) if (wfd)
@ -370,6 +361,7 @@ RegionView::set_colors ()
if (sync_mark) { if (sync_mark) {
sync_mark->property_fill_color_rgba() = fill_color; sync_mark->property_fill_color_rgba() = fill_color;
sync_line->property_fill_color_rgba() = fill_color;
} }
} }
@ -444,15 +436,32 @@ RegionView::region_renamed ()
void void
RegionView::region_sync_changed () RegionView::region_sync_changed ()
{ {
if (sync_mark == 0) {
return;
}
int sync_dir; int sync_dir;
nframes_t sync_offset; nframes_t sync_offset;
sync_offset = _region->sync_offset (sync_dir); sync_offset = _region->sync_offset (sync_dir);
if (sync_offset == 0) {
/* no need for a sync mark */
if (sync_mark) {
sync_mark->hide();
sync_line->hide ();
}
return;
}
if (!sync_mark) {
/* points set below */
sync_mark = new ArdourCanvas::Polygon (*group);
sync_mark->property_fill_color_rgba() = fill_color;
sync_line = new ArdourCanvas::Line (*group);
sync_line->property_fill_color_rgba() = fill_color;
sync_line->property_width_pixels() = 1;
}
/* this has to handle both a genuine change of position, a change of samples_per_unit, /* this has to handle both a genuine change of position, a change of samples_per_unit,
and a change in the bounds of the _region-> and a change in the bounds of the _region->
*/ */
@ -460,8 +469,9 @@ RegionView::region_sync_changed ()
if (sync_offset == 0) { if (sync_offset == 0) {
/* no sync mark - its the start of the region */ /* no sync mark - its the start of the region */
sync_mark->hide(); sync_mark->hide();
sync_line->hide ();
} else { } else {
@ -470,6 +480,7 @@ RegionView::region_sync_changed ()
/* no sync mark - its out of the bounds of the region */ /* no sync mark - its out of the bounds of the region */
sync_mark->hide(); sync_mark->hide();
sync_line->hide ();
} else { } else {
@ -485,8 +496,14 @@ RegionView::region_sync_changed ()
points.push_back (Gnome::Art::Point (offset, sync_mark_width - 1)); points.push_back (Gnome::Art::Point (offset, sync_mark_width - 1));
points.push_back (Gnome::Art::Point (offset - ((sync_mark_width-1)/2), 1)); points.push_back (Gnome::Art::Point (offset - ((sync_mark_width-1)/2), 1));
sync_mark->property_points().set_value (points); sync_mark->property_points().set_value (points);
sync_mark->show(); sync_mark->show ();
points.clear ();
points.push_back (Gnome::Art::Point (offset, 0));
points.push_back (Gnome::Art::Point (offset, _height - NAME_HIGHLIGHT_SIZE));
sync_line->property_points().set_value (points);
sync_line->show ();
} }
} }
} }
@ -533,3 +550,18 @@ RegionView::get_fill_color ()
return fill_color; return fill_color;
} }
void
RegionView::set_height (double h)
{
if (sync_line) {
Points points;
int sync_dir;
nframes_t sync_offset;
sync_offset = _region->sync_offset (sync_dir);
double offset = sync_offset / samples_per_unit;
points.push_back (Gnome::Art::Point (offset, 0));
points.push_back (Gnome::Art::Point (offset, h - NAME_HIGHLIGHT_SIZE));
sync_line->property_points().set_value (points);
}
}

View file

@ -60,6 +60,7 @@ class RegionView : public TimeAxisViewItem
void set_valid (bool yn) { valid = yn; } void set_valid (bool yn) { valid = yn; }
virtual void set_height (double);
virtual void set_samples_per_unit (double); virtual void set_samples_per_unit (double);
virtual bool set_duration (nframes_t, void*); virtual bool set_duration (nframes_t, void*);
@ -124,6 +125,7 @@ class RegionView : public TimeAxisViewItem
boost::shared_ptr<ARDOUR::Region> _region; boost::shared_ptr<ARDOUR::Region> _region;
ArdourCanvas::Polygon* sync_mark; ///< polgyon for sync position ArdourCanvas::Polygon* sync_mark; ///< polgyon for sync position
ArdourCanvas::Line* sync_line; ///< polgyon for sync position
RegionEditor* editor; RegionEditor* editor;