From f509da7043222197c2efce7ab0a816626ef9ab54 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 26 Jun 2008 01:53:36 +0000 Subject: [PATCH] make dynamic track resizing "work" again; colinf's patch for operations on multiple selected regions from the region context menu git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3495 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor.cc | 53 +++++++++++++++++++++++++++++++++++ gtk2_ardour/editor.h | 6 ++++ gtk2_ardour/public_editor.h | 1 + gtk2_ardour/time_axis_view.cc | 23 ++++----------- gtk2_ardour/time_axis_view.h | 3 +- 5 files changed, 67 insertions(+), 19 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 82e720f6d8..b86469bd2d 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -344,6 +344,7 @@ Editor::Editor () resize_line_y = 0; old_resize_line_y = -1; no_region_list_redisplay = false; + resize_idle_id = -1; _scrubbing = false; scrubbing_direction = 0; @@ -1873,6 +1874,16 @@ Editor::add_region_context_items (AudioStreamView* sv, boost::shared_ptr fooc.block (false); } } + } else { + // multiple regions selected + // how should these act? + // here they toggle the property of all selected regions + + items.push_back (MenuElem (_("Lock"), mem_fun(*this, &Editor::toggle_region_lock))); + items.push_back (MenuElem (_("Mute"), mem_fun(*this, &Editor::toggle_region_mute))); + if (!Profile->get_sae()) { + items.push_back (MenuElem (_("Opaque"), mem_fun(*this, &Editor::toggle_region_opaque))); + } } items.push_back (CheckMenuElem (_("Original position"), mem_fun(*this, &Editor::naturalize))); @@ -4712,14 +4723,17 @@ Editor::first_idle () void Editor::start_resize_line_ops () { +#if 0 old_resize_line_y = -1; resize_line_y = -1; need_resize_line = true; +#endif } void Editor::end_resize_line_ops () { +#if 0 need_resize_line = false; if (old_resize_line_y >= 0) { @@ -4728,11 +4742,13 @@ Editor::end_resize_line_ops () cerr << "Final invalidation at " << old_resize_line_y << endl; win->invalidate_rect (r, false); } +#endif } void Editor::queue_draw_resize_line (int at) { +#if 0 Glib::RefPtr win = get_window(); resize_line_y = at; @@ -4760,6 +4776,7 @@ Editor::queue_draw_resize_line (int at) Gdk::Rectangle r (xroot, at - 1, controls_width + (int) canvas_width, 3); win->invalidate_rect (r, true); } +#endif } bool @@ -4774,6 +4791,7 @@ Editor::on_expose_event (GdkEventExpose* ev) */ bool ret = Window::on_expose_event (ev); +#if 0 if (need_resize_line) { int xroot, yroot, discard; @@ -4831,5 +4849,40 @@ Editor::on_expose_event (GdkEventExpose* ev) } //cerr << "--- editor expose\n"; +#endif + return ret; } + +static gboolean +_idle_resizer (gpointer arg) +{ + return ((Editor*)arg)->idle_resize (); +} + +void +Editor::add_to_idle_resize (TimeAxisView* view, uint32_t h) +{ + if (resize_idle_id < 0) { + resize_idle_id = g_idle_add (_idle_resizer, this); + } + + resize_idle_target = h; + + pending_resizes.push_back (view); + + if (!selection->tracks.empty()) { + pending_resizes.insert (pending_resizes.end(), selection->tracks.begin(), selection->tracks.end()); + } +} + +bool +Editor::idle_resize () +{ + for (vector::iterator i = pending_resizes.begin(); i != pending_resizes.end(); ++i) { + (*i)->idle_resize (resize_idle_target); + } + pending_resizes.clear(); + resize_idle_id = -1; + return false; +} diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 7f7ce96465..7aad4391f3 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -160,6 +160,7 @@ class Editor : public PublicEditor void scroll_timeaxis_to_imageframe_item(const TimeAxisViewItem* item) ; TimeAxisView* get_named_time_axis(const std::string & name) ; void foreach_time_axis_view (sigc::slot); + void add_to_idle_resize (TimeAxisView*, uint32_t); void consider_auditioning (boost::shared_ptr); void hide_a_region (boost::shared_ptr); @@ -2155,6 +2156,11 @@ public: void waveform_scale_chosen (Editing::WaveformScale); bool _have_idled; + int resize_idle_id; + int32_t resize_idle_target; + bool idle_resize(); + friend gboolean _idle_resize (gpointer); + std::vector pending_resizes; }; #endif /* __ardour_editor_h__ */ diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 502aa448b7..3c2d588b22 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -167,6 +167,7 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulThingWithGoingAway virtual void split_region_at_points (boost::shared_ptr, ARDOUR::AnalysisFeatureList&, bool can_ferret) = 0; virtual void mouse_add_new_marker (nframes64_t where, bool is_cd=false, bool is_xrun=false) = 0; virtual void foreach_time_axis_view (sigc::slot) = 0; + virtual void add_to_idle_resize (TimeAxisView*,uint32_t) = 0; sigc::signal ZoomFocusChanged; sigc::signal ZoomChanged; diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index 8944fdc082..69a057bcf9 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -96,7 +96,6 @@ TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisVie last_name_entry_key_press_event = 0; name_packing = NamePackingBits (0); resize_drag_start = -1; - resize_idle_id = -1; /* Create the standard LHS Controls @@ -349,7 +348,7 @@ TimeAxisView::hide () void TimeAxisView::step_height (bool bigger) { -static const int step = 20; + static const uint32_t step = 20; if (bigger) { set_height (height + step); @@ -1201,18 +1200,10 @@ TimeAxisView::resizer_button_release (GdkEventButton* ev) return true; } -static gboolean -_idle_resizer (gpointer arg) +void +TimeAxisView::idle_resize (uint32_t h) { - return ((TimeAxisView*)arg)->idle_resize (); -} - -bool -TimeAxisView::idle_resize () -{ - set_height (resize_idle_target); - resize_idle_id = -1; - return false; + set_height (h); } bool @@ -1233,10 +1224,8 @@ TimeAxisView::resizer_motion (GdkEventMotion* ev) resize_idle_target = std::max (resize_idle_target - delta, (int) hSmall); - if (resize_idle_id < 0) { - // resize_idle_id = g_idle_add (_idle_resizer, this); - } - + editor.add_to_idle_resize (this, resize_idle_target); + resize_drag_start = ev->y_root; return true; diff --git a/gtk2_ardour/time_axis_view.h b/gtk2_ardour/time_axis_view.h index ee950cfac8..8ae4f55ec3 100644 --- a/gtk2_ardour/time_axis_view.h +++ b/gtk2_ardour/time_axis_view.h @@ -125,8 +125,7 @@ class TimeAxisView : public virtual AxisView, public Stateful double resize_drag_start; int32_t resize_idle_target; - int32_t resize_idle_id; - bool idle_resize(); + void idle_resize (uint32_t); void hide_name_label (); void hide_name_entry ();