From 2c72f58aa19c169752e6c09310c7d7917b63c3eb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 3 Mar 2011 14:51:02 +0000 Subject: [PATCH] experiment with making MIDI region boxes vanish when in note/internal edit mode ... to be continued git-svn-id: svn://localhost/ardour2/branches/3.0@9054 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_mouse.cc | 8 +++++ gtk2_ardour/midi_region_view.cc | 22 +++++++++++-- gtk2_ardour/midi_streamview.cc | 16 +++++++++ gtk2_ardour/midi_streamview.h | 3 ++ gtk2_ardour/midi_time_axis.cc | 16 +++++++++ gtk2_ardour/midi_time_axis.h | 3 ++ gtk2_ardour/region_view.cc | 1 + gtk2_ardour/streamview.h | 3 ++ gtk2_ardour/time_axis_view.h | 3 ++ gtk2_ardour/time_axis_view_item.cc | 52 +++++++++++++++++++++++++----- gtk2_ardour/time_axis_view_item.h | 8 +++-- 11 files changed, 122 insertions(+), 13 deletions(-) diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index d92fc162e9..9e6d3922fe 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -2635,12 +2635,20 @@ Editor::set_internal_edit (bool yn) ARDOUR_UI::instance()->set_tip (mouse_select_button, _("Draw/Edit MIDI Notes")); mouse_mode_toggled (mouse_mode); + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + (*i)->enter_internal_edit_mode (); + } + } else { mouse_select_button.set_image (*(manage (new Image (::get_icon("tool_range"))))); mouse_select_button.get_image ()->show (); ARDOUR_UI::instance()->set_tip (mouse_select_button, _("Select/Move Ranges")); mouse_mode_toggled (mouse_mode); // sets cursor + + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + (*i)->leave_internal_edit_mode (); + } } } diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 24ad86f7d6..4ef7c014bb 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -2856,17 +2856,33 @@ MidiRegionView::note_mouse_position (float x_fraction, float /*y_fraction*/, boo void MidiRegionView::set_frame_color() { + uint32_t f; + if (!frame) { return; } if (_selected) { - frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectedFrameBase.get(); + f = ARDOUR_UI::config()->canvasvar_SelectedFrameBase.get(); } else if (high_enough_for_name) { - frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_MidiFrameBase.get(); + f= ARDOUR_UI::config()->canvasvar_MidiFrameBase.get(); } else { - frame->property_fill_color_rgba() = fill_color; + f = fill_color; } + + if (!rect_visible) { + f = UINT_RGBA_CHANGE_A (f, 0); + } + + frame->property_fill_color_rgba() = f; + + f = ARDOUR_UI::config()->canvasvar_TimeAxisFrame.get(); + + if (!rect_visible) { + f = UINT_RGBA_CHANGE_A (f, 0); + } + + frame->property_outline_color_rgba() = f; } void diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index 723b522202..807d6253d4 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -206,6 +206,22 @@ MidiStreamView::display_region(MidiRegionView* region_view, bool load_model) region_view->display_model(source->model()); } +void +MidiStreamView::enter_internal_edit_mode () +{ + for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { + (*i)->hide_rect (); + } +} + +void +MidiStreamView::leave_internal_edit_mode () +{ + for (list::iterator i = region_views.begin(); i != region_views.end(); ++i) { + (*i)->show_rect (); + } +} + void MidiStreamView::display_track (boost::shared_ptr tr) { diff --git a/gtk2_ardour/midi_streamview.h b/gtk2_ardour/midi_streamview.h index 0774fd61bd..8acb62b51e 100644 --- a/gtk2_ardour/midi_streamview.h +++ b/gtk2_ardour/midi_streamview.h @@ -56,6 +56,9 @@ class MidiStreamView : public StreamView MidiStreamView (MidiTimeAxisView&); ~MidiStreamView (); + void enter_internal_edit_mode (); + void leave_internal_edit_mode (); + void set_selected_regionviews (RegionSelection&); void get_inverted_selectables (Selection&, std::list& results); diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index d08e40b8ef..b1068e7e3f 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -244,6 +244,22 @@ MidiTimeAxisView::~MidiTimeAxisView () delete _step_editor; } +void +MidiTimeAxisView::enter_internal_edit_mode () +{ + if (midi_view()) { + midi_view()->enter_internal_edit_mode (); + } +} + +void +MidiTimeAxisView::leave_internal_edit_mode () +{ + if (midi_view()) { + midi_view()->leave_internal_edit_mode (); + } +} + void MidiTimeAxisView::check_step_edit () { diff --git a/gtk2_ardour/midi_time_axis.h b/gtk2_ardour/midi_time_axis.h index a72ccc5914..1adba26d24 100644 --- a/gtk2_ardour/midi_time_axis.h +++ b/gtk2_ardour/midi_time_axis.h @@ -69,6 +69,9 @@ class MidiTimeAxisView : public RouteTimeAxisView void set_height (uint32_t); void hide (); + void enter_internal_edit_mode (); + void leave_internal_edit_mode (); + boost::shared_ptr add_region (ARDOUR::framepos_t, ARDOUR::framecnt_t, bool); void show_all_automation (); diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index e4d6650b8b..1debfd6a07 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -941,3 +941,4 @@ RegionView::trim_contents (framepos_t frame_delta, bool left_direction, bool swa _region->trim_start ((framepos_t) (new_bound * speed), this); region_changed (PropertyChange (ARDOUR::Properties::start)); } + diff --git a/gtk2_ardour/streamview.h b/gtk2_ardour/streamview.h index 2b542b4a20..3268519534 100644 --- a/gtk2_ardour/streamview.h +++ b/gtk2_ardour/streamview.h @@ -74,6 +74,9 @@ public: gdouble get_samples_per_unit () { return _samples_per_unit; } virtual void horizontal_position_changed () {} + virtual void enter_internal_edit_mode () {} + virtual void leave_internal_edit_mode () {} + void set_layer_display (LayerDisplay); LayerDisplay layer_display () const { return _layer_display; } diff --git a/gtk2_ardour/time_axis_view.h b/gtk2_ardour/time_axis_view.h index 9630b3f19c..6fd6865485 100644 --- a/gtk2_ardour/time_axis_view.h +++ b/gtk2_ardour/time_axis_view.h @@ -98,6 +98,9 @@ class TimeAxisView : public virtual AxisView, public PBD::Stateful /** @return maximum allowable value of order */ static int max_order () { return _max_order; } + virtual void enter_internal_edit_mode () {} + virtual void leave_internal_edit_mode () {} + ArdourCanvas::Group* canvas_display () { return _canvas_display; } ArdourCanvas::Group* canvas_background () { return _canvas_background; } ArdourCanvas::Group* ghost_group () { return _ghost_group; } diff --git a/gtk2_ardour/time_axis_view_item.cc b/gtk2_ardour/time_axis_view_item.cc index fc0b4b24a1..43634f43f5 100644 --- a/gtk2_ardour/time_axis_view_item.cc +++ b/gtk2_ardour/time_axis_view_item.cc @@ -156,6 +156,7 @@ TimeAxisViewItem::init ( last_item_width = 0; wide_enough_for_name = wide; high_enough_for_name = high; + rect_visible = true; if (duration == 0) { warning << "Time Axis Item Duration == 0" << endl; @@ -234,6 +235,28 @@ TimeAxisViewItem::~TimeAxisViewItem() delete group; } +void +TimeAxisViewItem::hide_rect () +{ + rect_visible = false; + set_frame_color (); + + if (name_highlight) { + name_highlight->property_outline_what() = 0x0; + } +} + +void +TimeAxisViewItem::show_rect () +{ + rect_visible = true; + set_frame_color (); + + if (name_highlight) { + name_highlight->property_outline_what() = 0x4; + } +} + /** * Set the position of this item on the timeline. @@ -682,21 +705,30 @@ TimeAxisViewItem::set_colors() void TimeAxisViewItem::set_frame_color() { + uint32_t f = 0; + if (!frame) { return; } if (_selected) { + + f = ARDOUR_UI::config()->canvasvar_SelectedFrameBase.get(); + if (fill_opacity) { - frame->property_fill_color_rgba() = UINT_RGBA_CHANGE_A (ARDOUR_UI::config()->canvasvar_SelectedFrameBase.get(), fill_opacity); - } else { - frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_SelectedFrameBase.get(); - } + f = UINT_RGBA_CHANGE_A (f, fill_opacity); + } + + if (!rect_visible) { + f = UINT_RGBA_CHANGE_A (f, 0); + } + } else { + if (_recregion) { - frame->property_fill_color_rgba() = ARDOUR_UI::config()->canvasvar_RecordingRect.get(); + f = ARDOUR_UI::config()->canvasvar_RecordingRect.get(); } else { - uint32_t f = 0; + if (high_enough_for_name && !Config->get_color_regions_using_track_color()) { f = ARDOUR_UI::config()->canvasvar_FrameBase.get(); } else { @@ -707,9 +739,13 @@ TimeAxisViewItem::set_frame_color() f = UINT_RGBA_CHANGE_A (f, fill_opacity); } - frame->property_fill_color_rgba() = f; - } + if (!rect_visible) { + f = UINT_RGBA_CHANGE_A (f, 0); + } + } } + + frame->property_fill_color_rgba() = f; } /** diff --git a/gtk2_ardour/time_axis_view_item.h b/gtk2_ardour/time_axis_view_item.h index dc5c8b7f8d..dedc4a0485 100644 --- a/gtk2_ardour/time_axis_view_item.h +++ b/gtk2_ardour/time_axis_view_item.h @@ -82,7 +82,10 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList virtual void raise_to_top () { return; } virtual void lower () { return; } virtual void lower_to_bottom () { return; } - + + virtual void hide_rect (); + virtual void show_rect (); + /** @return true if the name area should respond to events */ bool name_active() const { return name_connected; } @@ -220,7 +223,8 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList int name_pixbuf_width; bool wide_enough_for_name; bool high_enough_for_name; - + bool rect_visible; + ArdourCanvas::Group* group; ArdourCanvas::SimpleRect* vestigial_frame; ArdourCanvas::SimpleRect* frame;