From 1df8d73957acb5b287036c7be4f33fb6eed6bd48 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 9 Oct 2008 21:51:10 +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/2.0-ongoing@3903 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour-sae.menus | 2 + gtk2_ardour/ardour.menus | 4 ++ gtk2_ardour/audio_region_view.cc | 50 +++++++++++++++++++++--- gtk2_ardour/audio_region_view.h | 2 + gtk2_ardour/audio_streamview.cc | 22 +++++++++++ gtk2_ardour/audio_streamview.h | 3 ++ gtk2_ardour/automation_line.cc | 3 ++ gtk2_ardour/editor.h | 5 +++ gtk2_ardour/editor_actions.cc | 21 ++++++++++- gtk2_ardour/editor_canvas.cc | 2 +- gtk2_ardour/editor_ops.cc | 65 ++++++++++++++++++++++++++++++++ 11 files changed, 172 insertions(+), 7 deletions(-) diff --git a/gtk2_ardour/ardour-sae.menus b/gtk2_ardour/ardour-sae.menus index c54d12e3e3..582fb7ead4 100644 --- a/gtk2_ardour/ardour-sae.menus +++ b/gtk2_ardour/ardour-sae.menus @@ -215,6 +215,7 @@ + @@ -223,6 +224,7 @@ + diff --git a/gtk2_ardour/ardour.menus b/gtk2_ardour/ardour.menus index 5a20327456..0b696dd9fe 100644 --- a/gtk2_ardour/ardour.menus +++ b/gtk2_ardour/ardour.menus @@ -226,6 +226,9 @@ + + + @@ -377,6 +380,7 @@ + diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index 2bc45ddaca..8b6dab3cc9 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -176,7 +176,6 @@ AudioRegionView::init (Gdk::Color& basic_color, bool wfd) fade_out_shape->property_fill_color_rgba() = fade_color; fade_out_shape->set_data ("regionview", this); - { uint32_t r,g,b,a; UINT_TO_RGBA(fill_color,&r,&g,&b,&a); @@ -199,6 +198,10 @@ AudioRegionView::init (Gdk::Color& basic_color, bool wfd) fade_out_handle->set_data ("regionview", this); } + if (!Config->get_show_region_fades()) { + set_fade_visibility (false); + } + string foo = _region->name(); foo += ':'; foo += "gain"; @@ -392,8 +395,10 @@ AudioRegionView::reset_width_dependent_items (double pixel_width) fade_in_handle->hide(); fade_out_handle->hide(); } else { - fade_in_handle->show(); - fade_out_handle->show(); + if (Config->get_show_region_fades()) { + fade_in_handle->show(); + fade_out_handle->show(); + } } } } @@ -533,7 +538,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().get_vector (0, audio_region()->fade_in().back()->when, curve, npoints); @@ -619,7 +626,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().get_vector (0, audio_region()->fade_out().back()->when, curve, npoints); @@ -1266,3 +1275,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 c2f1dd41bc..7669cb9ccc 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 f3c1955efe..3d38632dd8 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -725,6 +725,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 db4a3a5869..093762f950 100644 --- a/gtk2_ardour/audio_streamview.h +++ b/gtk2_ardour/audio_streamview.h @@ -73,6 +73,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/automation_line.cc b/gtk2_ardour/automation_line.cc index 21a7a2f515..7b4f8130bb 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -765,7 +765,10 @@ AutomationLine::get_verbose_cursor_string (float fraction) if (fraction == 0.0) { snprintf (buf, sizeof (buf), "-inf dB"); } else { + cerr << "from fraction " << fraction << " derived "; + cerr << coefficient_to_dB (slider_position_to_gain (fraction)); snprintf (buf, sizeof (buf), "%.1fdB", coefficient_to_dB (slider_position_to_gain (fraction))); + cerr << " which prints as " << buf << endl; } } else { snprintf (buf, sizeof (buf), "%.2f", fraction); diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index cd9e4baa61..2f036ca1f6 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -325,9 +325,14 @@ class Editor : public PublicEditor void update_smpte_mode(); void update_video_pullup(); void update_subframes_per_frame (); + /* 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 518cd2cc41..ee43b1d057 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -114,7 +114,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)); @@ -1657,6 +1666,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 () { @@ -1709,6 +1724,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")) { @@ -1745,3 +1763,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 870f195bae..55bb9e2a28 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -361,7 +361,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 139e07a366..a32142b99d 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -61,6 +61,7 @@ #include "audio_time_axis.h" #include "automation_time_axis.h" #include "streamview.h" +#include "audio_streamview.h" #include "audio_region_view.h" #include "rgb_macros.h" #include "selection_templates.h" @@ -4906,6 +4907,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 @@ -6035,3 +6099,4 @@ Editor::end_visual_state_op (uint32_t n) return false; // do not call again } +