diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-10-06 22:07:10 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-10-06 22:07:10 +0000 |
commit | aefcce1c99598cc8c1748940a01e2d8aa55caf85 (patch) | |
tree | 9a6b0a3be7faac2c82b58f3517640fa195c96825 /gtk2_ardour | |
parent | 77364b0e25bcf97d0f3000ee97c27b2dca8454c6 (diff) |
ogg/flac support bits and pieces; fix up MIDI note dragging and front-edge trims; BROKEN IN PERCUSSIVE MODE FOR NOW
git-svn-id: svn://localhost/ardour2/branches/3.0@5745 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/canvas-hit.h | 3 | ||||
-rw-r--r-- | gtk2_ardour/canvas-note-event.cc | 11 | ||||
-rw-r--r-- | gtk2_ardour/canvas-note-event.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/canvas-note.cc | 17 | ||||
-rw-r--r-- | gtk2_ardour/canvas-note.h | 1 | ||||
-rw-r--r-- | gtk2_ardour/diamond.cc | 32 | ||||
-rw-r--r-- | gtk2_ardour/diamond.h | 11 | ||||
-rw-r--r-- | gtk2_ardour/editor.h | 4 | ||||
-rw-r--r-- | gtk2_ardour/editor_drag.cc | 17 | ||||
-rw-r--r-- | gtk2_ardour/editor_imageframe.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.cc | 39 | ||||
-rw-r--r-- | gtk2_ardour/midi_region_view.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/public_editor.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/startup.cc | 14 | ||||
-rw-r--r-- | gtk2_ardour/startup.h | 1 | ||||
-rw-r--r-- | gtk2_ardour/wscript | 3 |
16 files changed, 110 insertions, 51 deletions
diff --git a/gtk2_ardour/canvas-hit.h b/gtk2_ardour/canvas-hit.h index a467952966..2a94907cd6 100644 --- a/gtk2_ardour/canvas-hit.h +++ b/gtk2_ardour/canvas-hit.h @@ -52,7 +52,8 @@ public: void set_outline_color(uint32_t c) { property_outline_color_rgba() = c; } void set_fill_color(uint32_t c) { property_fill_color_rgba() = c; } - bool on_event(GdkEvent* ev) { return CanvasNoteEvent::on_event(ev); } + bool on_event(GdkEvent* ev); + void move_event(double dx, double dy); }; } // namespace Gnome diff --git a/gtk2_ardour/canvas-note-event.cc b/gtk2_ardour/canvas-note-event.cc index 55e31db4e1..b3c6b49ee0 100644 --- a/gtk2_ardour/canvas-note-event.cc +++ b/gtk2_ardour/canvas-note-event.cc @@ -73,17 +73,6 @@ CanvasNoteEvent::validate () _valid = true; } -void -CanvasNoteEvent::move_event(double dx, double dy) -{ - _item->move(dx, dy); - if (_text) { - _text->hide(); - _text->move(dx, dy); - _text->show(); - } -} - void CanvasNoteEvent::show_velocity() { diff --git a/gtk2_ardour/canvas-note-event.h b/gtk2_ardour/canvas-note-event.h index 6b394e1bb5..a9fa6ccb2d 100644 --- a/gtk2_ardour/canvas-note-event.h +++ b/gtk2_ardour/canvas-note-event.h @@ -73,7 +73,7 @@ public: bool selected() const { return _selected; } void selected(bool yn); - void move_event(double dx, double dy); + virtual void move_event(double dx, double dy) = 0; uint32_t base_color(); diff --git a/gtk2_ardour/canvas-note.cc b/gtk2_ardour/canvas-note.cc index b43514edcc..4686a80df9 100644 --- a/gtk2_ardour/canvas-note.cc +++ b/gtk2_ardour/canvas-note.cc @@ -18,5 +18,22 @@ CanvasNote::on_event(GdkEvent* ev) } } +void +CanvasNote::move_event(double dx, double dy) +{ + property_x1() = property_x1() + dx; + property_y1() = property_y1() + dy; + property_x2() = property_x2() + dx; + property_y2() = property_y2() + dy; + + if (_text) { + _text->hide(); + _text->property_x() = _text->property_x() + dx; + _text->property_y() = _text->property_y() + dy; + _text->show(); + } +} + + } // namespace Gnome } // namespace Canvas diff --git a/gtk2_ardour/canvas-note.h b/gtk2_ardour/canvas-note.h index cd3c166951..b65eae53d6 100644 --- a/gtk2_ardour/canvas-note.h +++ b/gtk2_ardour/canvas-note.h @@ -45,6 +45,7 @@ public: void hide() { SimpleRect::hide(); } bool on_event(GdkEvent* ev); + void move_event(double dx, double dy); CanvasNote (MidiRegionView& region, Group& group, diff --git a/gtk2_ardour/diamond.cc b/gtk2_ardour/diamond.cc index 7d3e66357d..3cc198fb98 100644 --- a/gtk2_ardour/diamond.cc +++ b/gtk2_ardour/diamond.cc @@ -25,17 +25,35 @@ using namespace Gnome::Art; Diamond::Diamond(Group& group, double height) : Polygon(group) { - set_height(height); + points = gnome_canvas_points_new (4); + g_object_set (gobj(), "points", points, NULL); + set_height (height); +} + +Diamond::~Diamond () +{ + gnome_canvas_points_free (points); } void Diamond::set_height(double height) { - Points points; - points.push_back(Art::Point(0, height*2.0)); - points.push_back(Art::Point(height, height)); - points.push_back(Art::Point(0, 0)); - points.push_back(Art::Point(-height, height)); - property_points() = points; + double x1, y1, x2, y2; + + get_bounds (x1, y1, x2, y2); + + points->coords[0] = x1; + points->coords[1] = y1 + height*2.0; + + points->coords[2] = x2 + height; + points->coords[3] = y1 + height; + + points->coords[4] = x1; + points->coords[5] = y2; + + points->coords[6] = x2 -height; + points->coords[7] = y2 + height; + + g_object_set (gobj(), "points", points, NULL); } diff --git a/gtk2_ardour/diamond.h b/gtk2_ardour/diamond.h index 6afa3e3d64..adfb289c6f 100644 --- a/gtk2_ardour/diamond.h +++ b/gtk2_ardour/diamond.h @@ -28,11 +28,16 @@ namespace Gnome { namespace Canvas { -class Diamond : public Polygon { -public: +class Diamond : public Polygon +{ + public: Diamond(Group& group, double height); - + ~Diamond (); + void set_height(double height); + + protected: + GnomeCanvasPoints* points; }; diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 5b68abc7bd..76830f4474 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -195,9 +195,9 @@ class Editor : public PublicEditor void add_imageframe_marker_time_axis(const std::string & track_name, TimeAxisView* marked_track, void*) ; void connect_to_image_compositor() ; void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) ; -#endif - TimeAxisView* get_named_time_axis(const std::string & name) ; +#endif /* WITH_CMT */ + void foreach_time_axis_view (sigc::slot<void,TimeAxisView&>); void add_to_idle_resize (TimeAxisView*, int32_t); diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 5e4a002e94..5aef521608 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -45,6 +45,7 @@ using namespace PBD; using namespace sigc; using namespace Gtk; using namespace Editing; +using namespace ArdourCanvas; double const ControlPointDrag::_zero_gain_fraction = gain_to_slider_position (dB_to_coefficient (0.0)); @@ -3366,7 +3367,7 @@ MouseZoomDrag::finished (GdkEvent* event, bool movement_occurred) NoteDrag::NoteDrag (Editor* e, ArdourCanvas::Item* i) : Drag (e, i) { - ArdourCanvas::CanvasNote* cnote = dynamic_cast<ArdourCanvas::CanvasNote*>(_item); + CanvasNoteEvent* cnote = dynamic_cast<CanvasNoteEvent*>(_item); region = &cnote->region_view(); } @@ -3389,7 +3390,7 @@ NoteDrag::start_grab (GdkEvent* event, Gdk::Cursor *) last_x = region->snap_to_pixel(event_x); last_y = event_y; - ArdourCanvas::CanvasNote* cnote = dynamic_cast<ArdourCanvas::CanvasNote*>(_item); + CanvasNoteEvent* cnote = dynamic_cast<CanvasNoteEvent*>(_item); if (!(was_selected = cnote->selected())) { @@ -3447,8 +3448,16 @@ NoteDrag::motion (GdkEvent*, bool) dy = streamview->note_height() * this_delta_note; last_y = last_y + dy; } - - region->move_selection (dx, dy); + + if (dx || dy) { + region->move_selection (dx, dy); + + CanvasNoteEvent* cnote = dynamic_cast<CanvasNoteEvent*>(_item); + char buf[4]; + snprintf (buf, sizeof (buf), "%g", (int) cnote->note()->note() + drag_delta_note); + //editor.show_verbose_canvas_cursor_with (Evoral::midi_note_name (ev->note()->note())); + _editor->show_verbose_canvas_cursor_with (buf); + } } void diff --git a/gtk2_ardour/editor_imageframe.cc b/gtk2_ardour/editor_imageframe.cc index a0a400d715..4fee0c7062 100644 --- a/gtk2_ardour/editor_imageframe.cc +++ b/gtk2_ardour/editor_imageframe.cc @@ -63,7 +63,6 @@ Editor::get_named_time_axis(const string & name) } /* <CMT Additions file="editor.cc"> */ -#ifdef HAVE_CMT void Editor::add_imageframe_time_axis(const string & track_name, void* src) @@ -1115,4 +1114,3 @@ Editor::handle_new_imageframe_marker_time_axis_view(const string & track_name, T /* </CMT Additions file="editor_route_list.cc"> */ -#endif /* HAVE_CMT */ diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 14e4199bd6..e7b70d29de 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -1191,12 +1191,10 @@ MidiRegionView::update_note (CanvasNote* ev) const nframes64_t note_end_frames = beats_to_frames(note->end_time()); const double x = trackview.editor().frame_to_pixel(note_start_frames - _region->start()); - - const double y1 = midi_stream_view()->note_to_y(note->note()); const double note_endpixel = trackview.editor().frame_to_pixel(note_end_frames - _region->start()); - + ev->property_x1() = x; ev->property_y1() = y1; if (note->length() > 0) { @@ -1237,7 +1235,7 @@ MidiRegionView::update_hit (CanvasHit* ev) const double diamond_size = midi_stream_view()->note_height() / 2.0; const double y = midi_stream_view()->note_to_y(note->note()) + ((diamond_size-2) / 4.0); - ev->move(x, y); + ev->move_event (x, y); } /** Add a MIDI note to the view (with length). @@ -1680,24 +1678,22 @@ MidiRegionView::move_selection(double dx, double dy) } void -MidiRegionView::note_dropped(CanvasNoteEvent* ev, double dt, uint8_t dnote) +MidiRegionView::note_dropped(CanvasNoteEvent* ev, double dt, int8_t dnote) { - // TODO: This would be faster/nicer with a MoveCommand that doesn't need to copy... - if (_selection.find(ev) == _selection.end()) { - return; - } + assert (!_selection.empty()); - uint8_t lowest_note_in_selection = midi_stream_view()->lowest_note(); - uint8_t highest_note_in_selection = midi_stream_view()->highest_note(); + uint8_t lowest_note_in_selection = 127; + uint8_t highest_note_in_selection = 0; uint8_t highest_note_difference = 0; // find highest and lowest notes first + for (Selection::iterator i = _selection.begin(); i != _selection.end(); ++i) { uint8_t pitch = (*i)->note()->note(); lowest_note_in_selection = std::min(lowest_note_in_selection, pitch); highest_note_in_selection = std::max(highest_note_in_selection, pitch); } - + /* cerr << "dnote: " << (int) dnote << endl; cerr << "lowest note (streamview): " << int(midi_stream_view()->lowest_note()) @@ -1707,7 +1703,7 @@ MidiRegionView::note_dropped(CanvasNoteEvent* ev, double dt, uint8_t dnote) cerr << "selection size: " << _selection.size() << endl; cerr << "Highest note in selection: " << (int) highest_note_in_selection << endl; */ - + // Make sure the note pitch does not exceed the MIDI standard range if (dnote <= 127 && (highest_note_in_selection + dnote > 127)) { highest_note_difference = highest_note_in_selection - 127; @@ -1735,7 +1731,7 @@ MidiRegionView::note_dropped(CanvasNoteEvent* ev, double dt, uint8_t dnote) uint8_t original_pitch = (*i)->note()->note(); uint8_t new_pitch = original_pitch + dnote - highest_note_difference; - + // keep notes in standard midi range clamp_to_0_127(new_pitch); @@ -1755,7 +1751,7 @@ MidiRegionView::note_dropped(CanvasNoteEvent* ev, double dt, uint8_t dnote) // care about notes being moved beyond the upper/lower bounds on the canvas if (lowest_note_in_selection < midi_stream_view()->lowest_note() || - highest_note_in_selection > midi_stream_view()->highest_note()) { + highest_note_in_selection > midi_stream_view()->highest_note()) { midi_stream_view()->set_note_range(MidiStreamView::ContentsRange); } } @@ -1918,6 +1914,14 @@ MidiRegionView::commit_resizing (bool at_front, double delta_x, bool relative) if (at_front && current_x < canvas_note->note()->end_time()) { diff_add_change (canvas_note, MidiModel::DiffCommand::StartTime, current_x); + + double len = canvas_note->note()->time() - current_x; + len += canvas_note->note()->length(); + + if (len > 0) { + /* XXX convert to beats */ + diff_add_change (canvas_note, MidiModel::DiffCommand::Length, len); + } } if (!at_front) { @@ -2263,7 +2267,10 @@ MidiRegionView::note_entered(ArdourCanvas::CanvasNoteEvent* ev) } PublicEditor& editor (trackview.editor()); - editor.show_verbose_canvas_cursor_with (Evoral::midi_note_name (ev->note()->note())); + char buf[4]; + snprintf (buf, sizeof (buf), "%d", (int) ev->note()->note()); + //editor.show_verbose_canvas_cursor_with (Evoral::midi_note_name (ev->note()->note())); + editor.show_verbose_canvas_cursor_with (buf); } void diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h index 952bd9517a..a2c56a2473 100644 --- a/gtk2_ardour/midi_region_view.h +++ b/gtk2_ardour/midi_region_view.h @@ -192,7 +192,7 @@ class MidiRegionView : public RegionView size_t selection_size() { return _selection.size(); } void move_selection(double dx, double dy); - void note_dropped(ArdourCanvas::CanvasNoteEvent* ev, double d_pixels, uint8_t d_note); + void note_dropped(ArdourCanvas::CanvasNoteEvent* ev, double d_pixels, int8_t d_note); /** Return true iff the note is within the extent of the region. * @param visible will be set to true if the note is within the visible note range, false otherwise. diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index c396131108..d7df0e8d2f 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -269,9 +269,9 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway virtual void add_imageframe_time_axis(const std::string & track_name, void*) = 0; virtual void add_imageframe_marker_time_axis(const std::string & track_name, TimeAxisView* marked_track, void*) = 0; virtual void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) = 0; + virtual TimeAxisView* get_named_time_axis(const std::string & name) = 0; #endif - virtual TimeAxisView* get_named_time_axis(const std::string & name) = 0; virtual RouteTimeAxisView* get_route_view_by_id (PBD::ID& id) = 0; virtual void get_equivalent_regions (RegionView* rv, std::vector<RegionView*>&, ARDOUR::RouteGroup::Property) const = 0; diff --git a/gtk2_ardour/startup.cc b/gtk2_ardour/startup.cc index 370ce1b377..e4b19947a7 100644 --- a/gtk2_ardour/startup.cc +++ b/gtk2_ardour/startup.cc @@ -359,6 +359,8 @@ ArdourStartup::setup_initial_choice_page () centering_vbox->pack_start (ic_new_session_button, false, true); centering_vbox->pack_start (ic_existing_session_button, false, true); + ic_new_session_button.signal_button_press_event().connect(mem_fun(*this, &ArdourStartup::initial_choice_activated), false); + ic_existing_session_button.signal_button_press_event().connect(mem_fun(*this, &ArdourStartup::initial_choice_activated), false); centering_hbox->pack_start (*centering_vbox, true, true); @@ -377,6 +379,18 @@ ArdourStartup::setup_initial_choice_page () set_page_complete (ic_vbox, true); } +bool +ArdourStartup::initial_choice_activated(GdkEventButton *event) +{ + if (event && event->type == GDK_2BUTTON_PRESS && session_page_index != -1) + { + set_current_page(session_page_index); + return true; + } + else + return false; +} + void ArdourStartup::setup_session_page () { diff --git a/gtk2_ardour/startup.h b/gtk2_ardour/startup.h index ed8db3fbe8..b3b1379ea5 100644 --- a/gtk2_ardour/startup.h +++ b/gtk2_ardour/startup.h @@ -89,6 +89,7 @@ class ArdourStartup : public Gtk::Assistant { Gtk::VBox ic_vbox; Gtk::RadioButton ic_new_session_button; Gtk::RadioButton ic_existing_session_button; + bool initial_choice_activated(GdkEventButton *); /* monitoring choices */ diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 095fc4b97c..bf53167f5e 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -52,6 +52,7 @@ gtk2_ardour_sources = [ 'bundle_manager.cc', 'cairo_widget.cc', 'canvas-flag.cc', + 'canvas-hit.cc', 'canvas-note-event.cc', 'canvas-note.cc', 'canvas-program-change.cc', @@ -79,7 +80,6 @@ gtk2_ardour_sources = [ 'editor_export_audio.cc', 'editor_group_tabs.cc', 'editor_hscroller.cc', - 'editor_imageframe.cc', 'editor_keyboard.cc', 'editor_keys.cc', 'editor_markers.cc', @@ -342,7 +342,6 @@ def build(bld): else: key = "_".join (['FONT',sizename]) fontstyle = " ".join ([basefont,points]) - print key font_subst_dict[key] = fontstyle # RC files |