diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-31 02:40:08 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-31 02:40:08 +0000 |
commit | 71c94e69438c7c282b2dcac5ead080119944b290 (patch) | |
tree | 17bc6b75ff24c0eca6a7a45043f2c9d11cc2ff0c /gtk2_ardour | |
parent | 74df5d49c8ff42c05d7eb9300c3a9f9a7257e694 (diff) |
massive changes in automation state handling, not entirely complete; some bug fixes for automation line drawing
git-svn-id: svn://localhost/ardour2/trunk@1034 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/SConscript | 1 | ||||
-rw-r--r-- | gtk2_ardour/audio_region_view.cc | 7 | ||||
-rw-r--r-- | gtk2_ardour/automation_line.cc | 56 | ||||
-rw-r--r-- | gtk2_ardour/editor_tempodisplay.cc | 12 | ||||
-rw-r--r-- | gtk2_ardour/gain_automation_time_axis.cc | 8 | ||||
-rw-r--r-- | gtk2_ardour/region_gain_line.cc | 15 | ||||
-rw-r--r-- | gtk2_ardour/route_ui.h | 2 |
7 files changed, 55 insertions, 46 deletions
diff --git a/gtk2_ardour/SConscript b/gtk2_ardour/SConscript index 40e7855a1b..077937540d 100644 --- a/gtk2_ardour/SConscript +++ b/gtk2_ardour/SConscript @@ -305,7 +305,6 @@ env.Alias('install', env.Install(os.path.join(install_prefix, 'share/ardour2'), env.Alias('install', env.Install(os.path.join(install_prefix, 'share/ardour2/pixmaps'), pixmap_files)) env.Alias('install', env.Install(os.path.join(install_prefix, 'share/ardour2/icons'), icon_files)) -env.AlwaysBuild ('version.cc') env.Alias ('version', gtkardour.VersionBuild(['version.cc','version.h'], 'SConscript')) #dist diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index d04efb51d7..aaeea53878 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -902,12 +902,11 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev) trackview.session().begin_reversible_command (_("add gain control point")); XMLNode &before = audio_region()->envelope().get_state(); - if (!audio_region()->envelope_active()) { - XMLNode &before = audio_region()->get_state(); + XMLNode ®ion_before = audio_region()->get_state(); audio_region()->set_envelope_active(true); - XMLNode &after = audio_region()->get_state(); - trackview.session().add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), &before, &after)); + XMLNode ®ion_after = audio_region()->get_state(); + trackview.session().add_command (new MementoCommand<AudioRegion>(*(audio_region().get()), ®ion_before, ®ion_after)); } audio_region()->envelope().add (fx, y); diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 339af96d76..f52b2dcf42 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -245,7 +245,7 @@ AutomationLine::AutomationLine (const string & name, TimeAxisView& tv, ArdourCan alist.StateChanged.connect (mem_fun(*this, &AutomationLine::list_changed)); - trackview.session().register_with_memento_command_factory(_id, this); + trackview.session().register_with_memento_command_factory(alist.id(), this); } @@ -670,11 +670,16 @@ AutomationLine::determine_visible_control_points (ALPoints& points) uint32_t this_ry = 0; uint32_t prev_ry = 0; double* slope; + double box_size; + uint32_t cpsize; /* hide all existing points, and the line */ + + cpsize = 0; for (vector<ControlPoint*>::iterator i = control_points.begin(); i != control_points.end(); ++i) { (*i)->hide(); + ++cpsize; } line->hide (); @@ -695,6 +700,13 @@ AutomationLine::determine_visible_control_points (ALPoints& points) slope[n] = ydelta/xdelta; } + if (_height > (guint32) TimeAxisView::Larger) { + box_size = 8.0; + } else if (_height > (guint32) TimeAxisView::Normal) { + box_size = 6.0; + } else { + box_size = 4.0; + } /* read all points and decide which ones to show as control points */ view_index = 0; @@ -738,27 +750,23 @@ AutomationLine::determine_visible_control_points (ALPoints& points) this_rx = (uint32_t) rint (tx); this_ry = (unsigned long) rint (ty); - if (view_index && pi != npoints && (this_rx == prev_rx) && (this_ry == prev_ry)) { - + if (view_index && pi != npoints && (this_rx == prev_rx) && (this_ry == prev_ry) || + ((this_rx - prev_rx) < (box_size + 2))) { continue; } /* ok, we should display this point */ - if (view_index >= control_points.size()) { + if (view_index >= cpsize) { + /* make sure we have enough control points */ ControlPoint* ncp = new ControlPoint (*this); - - if (_height > (guint32) TimeAxisView::Larger) { - ncp->set_size (8.0); - } else if (_height > (guint32) TimeAxisView::Normal) { - ncp->set_size (6.0); - } else { - ncp->set_size (4.0); - } + + ncp->set_size (box_size); control_points.push_back (ncp); + ++cpsize; } ControlPoint::ShapeType shape; @@ -829,6 +837,10 @@ AutomationLine::determine_visible_control_points (ALPoints& points) line_points.push_back (Art::Point (0,0)); } + while (line_points.size() > npoints) { + line_points.pop_back (); + } + for (view_index = 0; view_index < npoints; ++view_index) { line_points[view_index].set_x (control_points[view_index]->get_x()); line_points[view_index].set_y (control_points[view_index]->get_y()); @@ -1193,9 +1205,7 @@ AutomationLine::reset_callback (const AutomationList& events) for (ai = events.const_begin(); ai != events.const_end(); ++ai) { - double translated_y; - - translated_y = (*ai)->value; + double translated_y = (*ai)->value; model_to_view_y (translated_y); tmp_points.push_back (ALPoint (trackview.editor.frame_to_unit ((*ai)->when), @@ -1263,16 +1273,16 @@ AutomationLine::hide_all_but_selected_control_points () } } -XMLNode &AutomationLine::get_state(void) +XMLNode & +AutomationLine::get_state (void) { - XMLNode *node = new XMLNode("AutomationLine"); - node->add_child_nocopy(alist.get_state()); - return *node; + /* function as a proxy for the model */ + return alist.get_state(); } -int AutomationLine::set_state(const XMLNode &node) +int +AutomationLine::set_state (const XMLNode &node) { - // TODO - //alist.set_state(node); - return 0; + /* function as a proxy for the model */ + return alist.set_state (node); } diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index 177f82bd44..3285d44e01 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -96,6 +96,10 @@ Editor::draw_metric_marks (const Metrics& metrics) void Editor::tempo_map_changed (Change ignored) { + if (!session) { + return; + } + ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::tempo_map_changed), ignored)); BBT_Time previous_beat, next_beat; // the beats previous to the leftmost frame and after the rightmost frame @@ -112,13 +116,13 @@ Editor::tempo_map_changed (Change ignored) previous_beat.ticks = 0; if (session->tempo_map().meter_at(leftmost_frame + current_page_frames()).beats_per_bar () > next_beat.beats + 1) { - next_beat.beats += 1; + next_beat.beats += 1; } else { - next_beat.bars += 1; - next_beat.beats = 1; + next_beat.bars += 1; + next_beat.beats = 1; } next_beat.ticks = 0; - + if (current_bbt_points) { delete current_bbt_points; current_bbt_points = 0; diff --git a/gtk2_ardour/gain_automation_time_axis.cc b/gtk2_ardour/gain_automation_time_axis.cc index 7e4a1b1fbf..c1261fdf23 100644 --- a/gtk2_ardour/gain_automation_time_axis.cc +++ b/gtk2_ardour/gain_automation_time_axis.cc @@ -63,12 +63,10 @@ GainAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkE lines.front()->view_to_model_y (y); _session.begin_reversible_command (_("add gain automation event")); - - XMLNode &before = curve.get_state(); + XMLNode& before = curve.get_state(); curve.add (when, y); - XMLNode &after = curve.get_state(); - _session.add_command(new MementoCommand<ARDOUR::Curve>(curve, &before, &after)); - _session.commit_reversible_command (); + XMLNode& after = curve.get_state(); + _session.commit_reversible_command (new MementoCommand<ARDOUR::Curve>(curve, &before, &after)); _session.set_dirty (); } diff --git a/gtk2_ardour/region_gain_line.cc b/gtk2_ardour/region_gain_line.cc index a961af5256..6354763c09 100644 --- a/gtk2_ardour/region_gain_line.cc +++ b/gtk2_ardour/region_gain_line.cc @@ -50,7 +50,7 @@ AudioRegionGainLine::start_drag (ControlPoint* cp, float fraction) if (!rv.audio_region()->envelope_active()) { trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), &rv.audio_region()->get_state(), 0)); rv.audio_region()->set_envelope_active(false); - } + } } // This is an extended copy from AutomationList @@ -65,12 +65,12 @@ AudioRegionGainLine::remove_point (ControlPoint& cp) XMLNode &before = get_state(); if (!rv.audio_region()->envelope_active()) { - XMLNode &before = rv.audio_region()->get_state(); + XMLNode ®ion_before = rv.audio_region()->get_state(); rv.audio_region()->set_envelope_active(true); - XMLNode &after = rv.audio_region()->get_state(); - trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), &before, &after)); - } - + XMLNode ®ion_after = rv.audio_region()->get_state(); + trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), ®ion_before, ®ion_after)); + } + alist.erase (mr.start, mr.end); trackview.editor.current_session()->add_command (new MementoCommand<AudioRegionGainLine>(*this, &before, &get_state())); @@ -84,7 +84,8 @@ AudioRegionGainLine::end_drag (ControlPoint* cp) if (!rv.audio_region()->envelope_active()) { rv.audio_region()->set_envelope_active(true); trackview.session().add_command(new MementoCommand<AudioRegion>(*(rv.audio_region().get()), 0, &rv.audio_region()->get_state())); - } + } + AutomationLine::end_drag(cp); } diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index 6ea867745f..ea86041986 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -153,8 +153,6 @@ class RouteUI : public virtual AxisView void reversibly_apply_route_boolean (string name, void (ARDOUR::Route::*func)(bool, void*), bool, void *); void reversibly_apply_audio_track_boolean (string name, void (ARDOUR::AudioTrack::*func)(bool, void*), bool, void *); - - sigc::signal<void> GoingAway; }; #endif /* __ardour_route_ui__ */ |