From c64e96b6a8f6782a5ad0bc41b7200ec94408aaa5 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 9 Oct 2008 21:55:05 +0000 Subject: [PATCH] add toggles for region fade in/out/both active, plus toggle for region fades visibility git-svn-id: svn://localhost/ardour2/branches/3.0@3904 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour-sae.menus | 2 + gtk2_ardour/ardour.menus | 5 +++ gtk2_ardour/audio_region_view.cc | 39 ++++++++++++++++++- gtk2_ardour/audio_region_view.h | 2 + gtk2_ardour/audio_streamview.cc | 22 +++++++++++ gtk2_ardour/audio_streamview.h | 3 ++ gtk2_ardour/editor.h | 4 ++ gtk2_ardour/editor_actions.cc | 21 ++++++++++- gtk2_ardour/editor_canvas.cc | 2 +- gtk2_ardour/editor_ops.cc | 65 ++++++++++++++++++++++++++++++++ 10 files changed, 161 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/ardour-sae.menus b/gtk2_ardour/ardour-sae.menus index 01482d61a3..dd57e2aa36 100644 --- a/gtk2_ardour/ardour-sae.menus +++ b/gtk2_ardour/ardour-sae.menus @@ -213,6 +213,7 @@ + @@ -221,6 +222,7 @@ + diff --git a/gtk2_ardour/ardour.menus b/gtk2_ardour/ardour.menus index c56abbbcee..eab75387a4 100644 --- a/gtk2_ardour/ardour.menus +++ b/gtk2_ardour/ardour.menus @@ -228,6 +228,10 @@ + + + + @@ -377,6 +381,7 @@ + diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index 1c52a05ea6..40046cd9a1 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -567,7 +567,9 @@ AudioRegionView::reset_fade_in_shape_width (nframes_t width) return; } - fade_in_shape->show(); + if (Config->get_show_region_fades()) { + fade_in_shape->show(); + } float curve[npoints]; audio_region()->fade_in()->curve().get_vector (0, audio_region()->fade_in()->back()->when, curve, npoints); @@ -653,7 +655,9 @@ AudioRegionView::reset_fade_out_shape_width (nframes_t width) return; } - fade_out_shape->show(); + if (Config->get_show_region_fades()) { + fade_out_shape->show(); + } float curve[npoints]; audio_region()->fade_out()->curve().get_vector (0, audio_region()->fade_out()->back()->when, curve, npoints); @@ -1313,3 +1317,34 @@ AudioRegionView::set_frame_color () } } +void +AudioRegionView::set_fade_visibility (bool yn) +{ + if (yn) { + if (fade_in_shape) { + fade_in_shape->show(); + } + if (fade_out_shape) { + fade_out_shape->show (); + } + if (fade_in_handle) { + fade_in_handle->show (); + } + if (fade_out_handle) { + fade_out_handle->show (); + } + } else { + if (fade_in_shape) { + fade_in_shape->hide(); + } + if (fade_out_shape) { + fade_out_shape->hide (); + } + if (fade_in_handle) { + fade_in_handle->hide (); + } + if (fade_out_handle) { + fade_out_handle->hide (); + } + } +} diff --git a/gtk2_ardour/audio_region_view.h b/gtk2_ardour/audio_region_view.h index b8e3370877..a43ba0db86 100644 --- a/gtk2_ardour/audio_region_view.h +++ b/gtk2_ardour/audio_region_view.h @@ -106,6 +106,8 @@ class AudioRegionView : public RegionView void reset_fade_in_shape_width (nframes_t); void reset_fade_out_shape_width (nframes_t); + void set_fade_visibility (bool); + virtual void entered (); virtual void exited (); diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index 76e15aa528..7fc7be2db2 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -755,6 +755,28 @@ AudioStreamView::update_rec_regions () } } +void +AudioStreamView::show_all_fades () +{ + for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { + AudioRegionView* const arv = dynamic_cast(*i); + if (arv) { + arv->set_fade_visibility (true); + } + } +} + +void +AudioStreamView::hide_all_fades () +{ + for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { + AudioRegionView* const arv = dynamic_cast(*i); + if (arv) { + arv->set_fade_visibility (false); + } + } +} + void AudioStreamView::show_all_xfades () { diff --git a/gtk2_ardour/audio_streamview.h b/gtk2_ardour/audio_streamview.h index c4db364618..85055249c5 100644 --- a/gtk2_ardour/audio_streamview.h +++ b/gtk2_ardour/audio_streamview.h @@ -72,6 +72,9 @@ class AudioStreamView : public StreamView void foreach_crossfadeview (void (CrossfadeView::*pmf)(void)); + void show_all_fades (); + void hide_all_fades (); + void show_all_xfades (); void hide_all_xfades (); void hide_xfades_involving (AudioRegionView&); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 81dad3c244..e21996621e 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -339,6 +339,10 @@ class Editor : public PublicEditor /* fades/xfades */ void toggle_region_fades (); + void toggle_region_fades_visible (); + void toggle_selected_region_fades (int dir); + void update_region_fade_visibility (); + void toggle_auto_xfade (); void toggle_xfades_active (); void toggle_xfade_visibility (); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index fb5c8d04f4..0f78b60f74 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -118,7 +118,16 @@ Editor::register_actions () ActionManager::session_sensitive_actions.push_back (act); act = ActionManager::register_toggle_action (editor_actions, "toggle-auto-xfades", _("Created Automatically"), mem_fun(*this, &Editor::toggle_auto_xfade)); ActionManager::session_sensitive_actions.push_back (act); - act = ActionManager::register_toggle_action (editor_actions, "toggle-region-fades", _("Active Region Fades"), mem_fun(*this, &Editor::toggle_region_fades)); + + act = ActionManager::register_toggle_action (editor_actions, "toggle-region-fades", _("Use Region Fades (global)"), mem_fun(*this, &Editor::toggle_region_fades)); + ActionManager::session_sensitive_actions.push_back (act); + act = ActionManager::register_toggle_action (editor_actions, "toggle-region-fades-visible", _("Show Region Fades"), mem_fun(*this, &Editor::toggle_region_fades_visible)); + ActionManager::session_sensitive_actions.push_back (act); + act = ActionManager::register_action (editor_actions, "toggle-selected-region-fade-in", _("Toggle Region Fade In"), bind (mem_fun(*this, &Editor::toggle_selected_region_fades), 1));; + ActionManager::session_sensitive_actions.push_back (act); + act = ActionManager::register_action (editor_actions, "toggle-selected-region-fade-out", _("Toggle Region Fade Out"), bind (mem_fun(*this, &Editor::toggle_selected_region_fades), -1));; + ActionManager::session_sensitive_actions.push_back (act); + act = ActionManager::register_action (editor_actions, "toggle-selected-region-fades", _("Toggle Region Fades"), bind (mem_fun(*this, &Editor::toggle_selected_region_fades), 0)); ActionManager::session_sensitive_actions.push_back (act); act = ActionManager::register_action (editor_actions, "playhead-to-next-region-boundary", _("Playhead to Next Region Boundary"), bind (mem_fun(*this, &Editor::cursor_to_next_region_boundary), playhead_cursor)); @@ -1664,6 +1673,12 @@ Editor::toggle_region_fades () ActionManager::toggle_config_state ("Editor", "toggle-region-fades", &Configuration::set_use_region_fades, &Configuration::get_use_region_fades); } +void +Editor::toggle_region_fades_visible () +{ + ActionManager::toggle_config_state ("Editor", "toggle-region-fades-visible", &Configuration::set_show_region_fades, &Configuration::get_show_region_fades); +} + void Editor::toggle_auto_xfade () { @@ -1716,6 +1731,9 @@ Editor::parameter_changed (const char* parameter_name) } else if (PARAM_IS ("xfades-visible")) { ActionManager::map_some_state ("Editor", "toggle-xfades-visible", &Configuration::get_xfades_visible); update_xfade_visibility (); + } else if (PARAM_IS ("show-region-fades")) { + ActionManager::map_some_state ("Editor", "toggle-region-fades-visible", &Configuration::get_show_region_fades); + update_region_fade_visibility (); } else if (PARAM_IS ("use-region-fades")) { ActionManager::map_some_state ("Editor", "toggle-region-fades", &Configuration::get_use_region_fades); } else if (PARAM_IS ("auto-xfade")) { @@ -1754,3 +1772,4 @@ Editor::reset_canvas_action_sensitivity (bool onoff) (*x)->set_sensitive (onoff); } } + diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 045ed9926f..6e556ba506 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -375,7 +375,7 @@ Editor::controls_layout_size_request (Requisition* req) if (!screen) { screen = Gdk::Screen::get_default(); } - gint height = min ( (gint) pos, (screen->get_height() - 400)); + gint height = min ( (gint) pos, (screen->get_height() - 600)); gint width = max (edit_controls_vbox.get_width(), controls_layout.get_width()); /* don't get too big. the fudge factors here are just guesses */ diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index cac7be90bd..f974792d50 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -64,6 +64,7 @@ #include "audio_time_axis.h" #include "automation_time_axis.h" #include "streamview.h" +#include "audio_streamview.h" #include "audio_region_view.h" #include "midi_region_view.h" #include "rgb_macros.h" @@ -4997,6 +4998,69 @@ Editor::set_fade_out_active (bool yn) commit_reversible_command (); } +void +Editor::toggle_selected_region_fades (int dir) +{ + RegionSelection rs; + RegionSelection::iterator i; + boost::shared_ptr ar; + bool yn; + + get_regions_for_action (rs); + + if (rs.empty()) { + return; + } + + for (i = rs.begin(); i != rs.end(); ++i) { + if ((ar = boost::dynamic_pointer_cast((*i)->region())) != 0) { + if (dir == -1) { + yn = ar->fade_out_active (); + } else { + yn = ar->fade_in_active (); + } + break; + } + } + + if (i == rs.end()) { + return; + } + + /* XXX should this undo-able? */ + + for (RegionSelection::iterator i = rs.begin(); i != rs.end(); ++i) { + if ((ar = boost::dynamic_pointer_cast((*i)->region())) == 0) { + continue; + } + if (dir == 1 || dir == 0) { + ar->set_fade_in_active (!yn); + } + + if (dir == -1 || dir == 0) { + ar->set_fade_out_active (!yn); + } + } +} + + +/** Update region fade visibility after its configuration has been changed */ +void +Editor::update_region_fade_visibility () +{ + bool _fade_visibility = Config->get_show_region_fades (); + + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + AudioTimeAxisView* v = dynamic_cast(*i); + if (v) { + if (_fade_visibility) { + v->audio_view()->show_all_fades (); + } else { + v->audio_view()->hide_all_fades (); + } + } + } +} /** Update crossfade visibility after its configuration has been changed */ void @@ -6120,3 +6184,4 @@ Editor::end_visual_state_op (uint32_t n) return false; // do not call again } +