From c9c7a0961a56d64082d0413fa8a719ff84541623 Mon Sep 17 00:00:00 2001 From: GZharun Date: Thu, 28 Aug 2014 10:20:21 +0300 Subject: [PATCH] [Summary] Reworked region view according to the PRD [Details] Note: the code is promoted ahead without some cosmetic stuff What is not finished: 1. Move rec color and name highlight color to the config. 2. Make region name displayed above the wave. --- gtk2_ardour/audio_region_view.cc | 26 ++- gtk2_ardour/audio_streamview.cc | 18 +- gtk2_ardour/automation_region_view.cc | 8 +- gtk2_ardour/automation_streamview.h | 2 +- gtk2_ardour/editor_mouse.cc | 2 +- gtk2_ardour/midi_streamview.h | 2 +- gtk2_ardour/region_view.cc | 4 +- gtk2_ardour/streamview.cc | 15 +- gtk2_ardour/time_axis_view_item.cc | 264 ++++++++++++-------------- gtk2_ardour/time_axis_view_item.h | 12 +- gtk2_ardour/ui_config_vars.h | 2 +- 11 files changed, 164 insertions(+), 191 deletions(-) diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index fbfc1d513f..5a9147966b 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -409,12 +409,12 @@ AudioRegionView::reset_width_dependent_items (double pixel_width) float x_pos = trackview.editor().sample_to_pixel (*i); (*l).second->set (ArdourCanvas::Duple (x_pos, 2.0), - ArdourCanvas::Duple (x_pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1)); + ArdourCanvas::Duple (x_pos, _height - 1)); (*l).first = *i; (*l).second->set (ArdourCanvas::Duple (x_pos, 2.0), - ArdourCanvas::Duple (x_pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1)); + ArdourCanvas::Duple (x_pos, _height - 1)); } reset_fade_shapes (); @@ -457,7 +457,7 @@ AudioRegionView::set_height (gdouble height) if (height < NAME_HIGHLIGHT_THRESH) { ht = ((height - 2 * wcnt) / (double) wcnt); } else { - ht = (((height - 2 * wcnt) - NAME_HIGHLIGHT_SIZE) / (double) wcnt); + ht = (((height - 2 * wcnt) ) / (double) wcnt); } gdouble yoff = n * (ht + 1); @@ -474,7 +474,7 @@ AudioRegionView::set_height (gdouble height) update_envelope_visibility (); } - gain_line->set_height ((uint32_t) rint (height - NAME_HIGHLIGHT_SIZE) - 2); + gain_line->set_height ((uint32_t) rint (height) - 2); } reset_fade_shapes (); @@ -488,7 +488,7 @@ AudioRegionView::set_height (gdouble height) if (height >= NAME_HIGHLIGHT_THRESH) { (*l).second->set (ArdourCanvas::Duple (pos_x, 2.0), - ArdourCanvas::Duple (pos_x, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1)); + ArdourCanvas::Duple (pos_x, _height - 1)); } else { (*l).second->set (ArdourCanvas::Duple (pos_x, 2.0), ArdourCanvas::Duple (pos_x, _height - 1)); @@ -545,7 +545,7 @@ AudioRegionView::reset_fade_in_shape_width (boost::shared_ptr ar, f double effective_height; if (_height >= NAME_HIGHLIGHT_THRESH) { - effective_height = _height - NAME_HIGHLIGHT_SIZE; + effective_height = _height; } else { effective_height = _height; } @@ -622,7 +622,7 @@ AudioRegionView::reset_fade_out_shape_width (boost::shared_ptr ar, double effective_height; if (_height >= NAME_HIGHLIGHT_THRESH) { - effective_height = _height - NAME_HIGHLIGHT_SIZE; + effective_height = _height; } else { effective_height = _height; } @@ -1128,11 +1128,7 @@ AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/) uint32_t nwaves = std::min (nchans, audio_region()->n_channels()); gdouble ht; - if (trackview.current_height() < NAME_HIGHLIGHT_THRESH) { - ht = ((trackview.current_height()) / (double) nchans); - } else { - ht = ((trackview.current_height() - NAME_HIGHLIGHT_SIZE) / (double) nchans); - } + ht = ((trackview.current_height()) / (double) nchans); gdouble yoff = which * ht; @@ -1225,7 +1221,7 @@ AudioRegionView::add_gain_point_event (ArdourCanvas::Item *item, GdkEvent *ev, b /* compute vertical fractional position */ - y = 1.0 - (y / (_height - NAME_HIGHLIGHT_SIZE)); + y = 1.0 - (y / (_height)); /* map using gain line */ @@ -1520,7 +1516,7 @@ AudioRegionView::transients_changed () CANVAS_DEBUG_NAME (canvas_item, string_compose ("transient group for %1", region()->name())); canvas_item->set (ArdourCanvas::Duple (-1.0, 2.0), - ArdourCanvas::Duple (1.0, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1)); + ArdourCanvas::Duple (1.0, _height - 1)); canvas_item->raise_to_top (); canvas_item->show (); @@ -1547,7 +1543,7 @@ AudioRegionView::transients_changed () (*l).second->set ( ArdourCanvas::Duple (*pos, 2.0), - ArdourCanvas::Duple (*pos, _height - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 1) + ArdourCanvas::Duple (*pos, _height - 1) ); (*l).second->set_data ("position", pos); diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index 6880c8be5b..c8c671ff1e 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -35,6 +35,7 @@ #include "ardour/session.h" #include "canvas/rectangle.h" +#include "canvas/utils.h" #include "audio_streamview.h" #include "audio_region_view.h" @@ -270,25 +271,22 @@ AudioStreamView::setup_rec_box () switch (_trackview.audio_track()->mode()) { case Normal: case NonLayered: - xend = xstart; - fill_color = ARDOUR_UI::config()->get_canvasvar_RecordingRect(); - break; - case Destructive: - xend = xstart + 2; - fill_color = ARDOUR_UI::config()->get_canvasvar_RecordingRect(); + xend = xstart; + //fill_color = ARDOUR_UI::config()->get_canvasvar_RecordingRect(); + // GZ FIXME:change in config instead of following + fill_color = ArdourCanvas::rgba_to_color (251.0/255.0, 35.0/255.0, 52.0/255.0, 1.0); /* make the recording rect translucent to allow the user to see the peak data coming in, etc. */ - fill_color = UINT_RGBA_CHANGE_A (fill_color, 120); - break; + break; } ArdourCanvas::Rectangle * rec_rect = new ArdourCanvas::Rectangle (_canvas_group); rec_rect->set_x0 (xstart); - rec_rect->set_y0 (1); + rec_rect->set_y0 (2); rec_rect->set_x1 (xend); - rec_rect->set_y1 (child_height ()); + rec_rect->set_y1 (child_height () - 3); rec_rect->set_outline_what (ArdourCanvas::Rectangle::What (0)); rec_rect->set_outline_color (ARDOUR_UI::config()->get_canvasvar_TimeAxisFrame()); rec_rect->set_fill_color (fill_color); diff --git a/gtk2_ardour/automation_region_view.cc b/gtk2_ardour/automation_region_view.cc index 86e7121677..e853ccbd95 100644 --- a/gtk2_ardour/automation_region_view.cc +++ b/gtk2_ardour/automation_region_view.cc @@ -90,7 +90,7 @@ AutomationRegionView::create_line (boost::shared_ptr lis _parameter, &_source_relative_time_converter)); _line->set_colors(); - _line->set_height ((uint32_t)rint(trackview.current_height() - NAME_HIGHLIGHT_SIZE)); + _line->set_height ((uint32_t)rint(trackview.current_height())); _line->set_visibility (AutomationLine::VisibleAspects (AutomationLine::Line|AutomationLine::ControlPoints)); _line->set_maximum_time (_region->length()); _line->set_offset (_region->start ()); @@ -120,7 +120,7 @@ AutomationRegionView::canvas_event (GdkEvent* ev) /* clamp y */ y = std::max (y, 0.0); - y = std::min (y, _height - NAME_HIGHLIGHT_SIZE); + y = std::min (y, _height); /* guard points only if primary modifier is used */ bool with_guard_points = Gtkmm2ext::Keyboard::modifier_state_equals (ev->button.state, Gtkmm2ext::Keyboard::PrimaryModifier); @@ -149,7 +149,7 @@ AutomationRegionView::add_automation_event (GdkEvent *, framepos_t when, double /* compute vertical fractional position */ - const double h = trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2; + const double h = trackview.current_height() - 2; y = 1.0 - (y / h); /* snap frame */ @@ -186,7 +186,7 @@ AutomationRegionView::set_height (double h) RegionView::set_height(h); if (_line) { - _line->set_height ((uint32_t)rint(h - NAME_HIGHLIGHT_SIZE)); + _line->set_height ((uint32_t)rint(h)); } } diff --git a/gtk2_ardour/automation_streamview.h b/gtk2_ardour/automation_streamview.h index d058f02434..188e3f9f6f 100644 --- a/gtk2_ardour/automation_streamview.h +++ b/gtk2_ardour/automation_streamview.h @@ -50,7 +50,7 @@ class AutomationStreamView : public StreamView void redisplay_track (); inline double contents_height() const { - return (_trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2); + return (_trackview.current_height() - 2); } bool has_automation () const; diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 928801d0b2..7c167b493b 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -2878,7 +2878,7 @@ Editor::update_join_object_range_location (double /*x*/, double y) double cy = y; rtv->canvas_display()->canvas_to_item (cx, cy); - double const c = cy / (rtv->view()->child_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE); + double const c = cy / (rtv->view()->child_height() ); _join_object_range_state = c <= 0.5 ? JOIN_OBJECT_RANGE_RANGE : JOIN_OBJECT_RANGE_OBJECT; } diff --git a/gtk2_ardour/midi_streamview.h b/gtk2_ardour/midi_streamview.h index b3506d4224..59a26c0c6e 100644 --- a/gtk2_ardour/midi_streamview.h +++ b/gtk2_ardour/midi_streamview.h @@ -82,7 +82,7 @@ class MidiStreamView : public StreamView void leave_internal_edit_mode (); inline double contents_height() const - { return (child_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2); } + { return (child_height() - 2); } inline double note_to_y(uint8_t note) const { return contents_height() diff --git a/gtk2_ardour/region_view.cc b/gtk2_ardour/region_view.cc index 127ce79b84..cfc8525a9e 100644 --- a/gtk2_ardour/region_view.cc +++ b/gtk2_ardour/region_view.cc @@ -681,7 +681,7 @@ RegionView::region_sync_changed () sync_mark->set (points); sync_mark->show (); - sync_line->set (ArdourCanvas::Duple (offset, 0), ArdourCanvas::Duple (offset, trackview.current_height() - NAME_HIGHLIGHT_SIZE)); + sync_line->set (ArdourCanvas::Duple (offset, 0), ArdourCanvas::Duple (offset, trackview.current_height() )); sync_line->show (); } } @@ -749,7 +749,7 @@ RegionView::set_height (double h) sync_line->set ( ArdourCanvas::Duple (offset, 0), - ArdourCanvas::Duple (offset, h - NAME_HIGHLIGHT_SIZE) + ArdourCanvas::Duple (offset, h ) ); } diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc index 404b934562..fb05004499 100644 --- a/gtk2_ardour/streamview.cc +++ b/gtk2_ardour/streamview.cc @@ -411,17 +411,12 @@ StreamView::update_rec_box () case NonLayered: case Normal: - rect.length = at - rect.start; - xstart = _trackview.editor().sample_to_pixel (rect.start); - xend = _trackview.editor().sample_to_pixel (at); - break; - case Destructive: - rect.length = 2; - xstart = _trackview.editor().sample_to_pixel (_trackview.track()->current_capture_start()); - xend = _trackview.editor().sample_to_pixel (at); - break; - + rect.length = at - rect.start; + xstart = _trackview.editor().sample_to_pixel (rect.start); + xend = _trackview.editor().sample_to_pixel (at); + break; + default: fatal << string_compose (_("programming error: %1"), "illegal track mode") << endmsg; /*NOTREACHED*/ diff --git a/gtk2_ardour/time_axis_view_item.cc b/gtk2_ardour/time_axis_view_item.cc index 33a517ca17..9661d19431 100644 --- a/gtk2_ardour/time_axis_view_item.cc +++ b/gtk2_ardour/time_axis_view_item.cc @@ -60,35 +60,40 @@ using namespace ARDOUR; using namespace Gtkmm2ext; Pango::FontDescription TimeAxisViewItem::NAME_FONT; -const double TimeAxisViewItem::NAME_X_OFFSET = 15.0; -const double TimeAxisViewItem::GRAB_HANDLE_TOP = 0.0; +const double TimeAxisViewItem::NAME_HIGHLIGHT_Y_IDENT = 3.0; +const double TimeAxisViewItem::NAME_HIGHLIGHT_X_OFFSET = 10.0; +const double TimeAxisViewItem::NAME_HIGHLIGHT_Y_OFFSET = 5.0; +const double TimeAxisViewItem::GRAB_HANDLE_TOP = 2.0; const double TimeAxisViewItem::GRAB_HANDLE_WIDTH = 10.0; const double TimeAxisViewItem::RIGHT_EDGE_SHIFT = 1.0; +const double TimeAxisViewItem::REGION_TOP_OFFSET = 2.0; +const double TimeAxisViewItem::REGION_BOTTOM_OFFSET = 3.0; + int TimeAxisViewItem::NAME_HEIGHT; +double TimeAxisViewItem::NAME_HIGHLIGHT_X_IDENT; double TimeAxisViewItem::NAME_Y_OFFSET; -double TimeAxisViewItem::NAME_HIGHLIGHT_SIZE; +double TimeAxisViewItem::NAME_HIGHLIGHT_HEIGHT; double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH; void TimeAxisViewItem::set_constant_heights () { - NAME_FONT = get_font_for_style (X_("TimeAxisViewItemName")); + NAME_FONT = get_font_for_style (X_("TimeAxisViewItemName")); - Gtk::Window win; - Gtk::Label foo; - win.add (foo); + Gtk::Window win; + Gtk::Label foo; + win.add (foo); - Glib::RefPtr layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */ - int width = 0; - int height = 0; + int width = 0; + int height = 0; - layout->set_font_description (NAME_FONT); - get_pixel_size (layout, width, height); + Glib::RefPtr layout = foo.create_pango_layout (X_("H")); /* just the ascender */ + layout->set_font_description (NAME_FONT); + get_pixel_size (layout, width, height); - layout = foo.create_pango_layout (X_("H")); /* just the ascender */ - - NAME_HEIGHT = height; + NAME_HEIGHT = height + 2; + NAME_HIGHLIGHT_X_IDENT = width + 2; /* Config->get_show_name_highlight) == true: Y_OFFSET is measured from bottom of the time axis view item. @@ -96,14 +101,8 @@ TimeAxisViewItem::set_constant_heights () Y_OFFSET is measured from the top of the time axis view item. */ - if (Config->get_show_name_highlight()) { - NAME_Y_OFFSET = height + 1; - NAME_HIGHLIGHT_SIZE = height + 2; - } else { - NAME_Y_OFFSET = 3; - NAME_HIGHLIGHT_SIZE = 0; - } - NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 3; + NAME_HIGHLIGHT_HEIGHT = NAME_HEIGHT + NAME_HIGHLIGHT_Y_IDENT*2; + NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_HEIGHT * 1.5; } /** @@ -178,7 +177,6 @@ TimeAxisViewItem::init (ArdourCanvas::Group* parent, double fpp, Gdk::Color cons frame_position = start; item_duration = duration; name_connected = false; - fill_opacity = 60; position_locked = false; max_item_duration = ARDOUR::max_framepos; min_item_duration = 0; @@ -195,7 +193,7 @@ TimeAxisViewItem::init (ArdourCanvas::Group* parent, double fpp, Gdk::Color cons warning << "Time Axis Item Duration == 0" << endl; } - vestigial_frame = new ArdourCanvas::Rectangle (group, ArdourCanvas::Rect (0.0, 1.0, 2.0, trackview.current_height())); + vestigial_frame = new ArdourCanvas::Rectangle (group, ArdourCanvas::Rect (0.0, 2.0, 2.0 + REGION_TOP_OFFSET, trackview.current_height() - REGION_BOTTOM_OFFSET)); CANVAS_DEBUG_NAME (vestigial_frame, string_compose ("vestigial frame for %1", get_item_name())); vestigial_frame->hide (); vestigial_frame->set_outline_color (ARDOUR_UI::config()->get_canvasvar_VestigialFrame()); @@ -203,67 +201,60 @@ TimeAxisViewItem::init (ArdourCanvas::Group* parent, double fpp, Gdk::Color cons if (visibility & ShowFrame) { frame = new ArdourCanvas::Rectangle (group, - ArdourCanvas::Rect (0.0, 0.0, + ArdourCanvas::Rect (0.0, REGION_TOP_OFFSET, trackview.editor().sample_to_pixel(duration) + RIGHT_EDGE_SHIFT, - trackview.current_height() - 1.0)); + trackview.current_height() - REGION_BOTTOM_OFFSET)); CANVAS_DEBUG_NAME (frame, string_compose ("frame for %1", get_item_name())); - if (Config->get_show_name_highlight()) { - frame->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::LEFT|ArdourCanvas::Rectangle::RIGHT)); - } else { - frame->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::LEFT|ArdourCanvas::Rectangle::RIGHT|ArdourCanvas::Rectangle::BOTTOM)); - } + if (_recregion) { + frame->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::LEFT| + ArdourCanvas::Rectangle::BOTTOM| + ArdourCanvas::Rectangle::TOP)); + } else { + frame->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::LEFT| + ArdourCanvas::Rectangle::RIGHT| + ArdourCanvas::Rectangle::BOTTOM| + ArdourCanvas::Rectangle::TOP)); + } - if (_recregion) { - frame->set_outline_color (ARDOUR_UI::config()->get_canvasvar_RecordingRect()); - } else { - frame->set_outline_color (ARDOUR_UI::config()->get_canvasvar_TimeAxisFrame()); - } + //ArdourCanvas::Color ouline_color = ARDOUR_UI::config()->get_canvasvar_TimeAxisFrame(); + + // GZ FIXME:change in config instead of following + ArdourCanvas::Color outline_color = ArdourCanvas::rgba_to_color (104, 104, 104, 0.6); + frame->set_outline_color (outline_color ); } else { frame = 0; } - if (Config->get_show_name_highlight() && (visibility & ShowNameHighlight)) { - + { // always show name highlight double width; - double start; - if (visibility & FullWidthNameHighlight) { - start = 0.0; - width = trackview.editor().sample_to_pixel(item_duration) + RIGHT_EDGE_SHIFT; - } else { - start = 1.0; - width = trackview.editor().sample_to_pixel(item_duration) - 2.0 + RIGHT_EDGE_SHIFT; - } + width = trackview.editor().sample_to_pixel(item_duration) - 2.0 + RIGHT_EDGE_SHIFT; name_highlight = new ArdourCanvas::Rectangle (group, - ArdourCanvas::Rect (start, - trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE, - width - 2.0 + RIGHT_EDGE_SHIFT, - trackview.current_height())); + ArdourCanvas::Rect (NAME_HIGHLIGHT_X_OFFSET, + NAME_HIGHLIGHT_Y_OFFSET, + NAME_HIGHLIGHT_X_OFFSET + 2*NAME_HIGHLIGHT_X_IDENT, + NAME_HIGHLIGHT_HEIGHT) ); CANVAS_DEBUG_NAME (name_highlight, string_compose ("name highlight for %1", get_item_name())); name_highlight->set_data ("timeaxisviewitem", this); - name_highlight->set_outline_what (ArdourCanvas::Rectangle::TOP); + name_highlight->set_outline_what (ArdourCanvas::Rectangle::What (0) ); name_highlight->set_outline_color (RGBA_TO_UINT (0,0,0,255)); - - } else { - name_highlight = 0; } - - if (visibility & ShowNameText) { + + { name_text = new ArdourCanvas::Text (group); CANVAS_DEBUG_NAME (name_text, string_compose ("name text for %1", get_item_name())); - if (Config->get_show_name_highlight()) { - name_text->set_position (ArdourCanvas::Duple (NAME_X_OFFSET, trackview.current_height() - NAME_Y_OFFSET)); - } else { - name_text->set_position (ArdourCanvas::Duple (NAME_X_OFFSET, NAME_Y_OFFSET)); - } - name_text->set_font_description (NAME_FONT); - } else { - name_text = 0; + name_text->set_position (ArdourCanvas::Duple (NAME_HIGHLIGHT_X_OFFSET + NAME_HIGHLIGHT_X_IDENT, NAME_HIGHLIGHT_Y_OFFSET + NAME_HIGHLIGHT_Y_IDENT) ); + name_text->set(""); + name_text->set_font_description (NAME_FONT); + + if (name_text->text().empty() ) { + name_highlight->hide(); + } } /* create our grab handles used for trimming/duration etc */ @@ -271,13 +262,13 @@ TimeAxisViewItem::init (ArdourCanvas::Group* parent, double fpp, Gdk::Color cons double top = TimeAxisViewItem::GRAB_HANDLE_TOP; double width = TimeAxisViewItem::GRAB_HANDLE_WIDTH; - frame_handle_start = new ArdourCanvas::DragHandle (group, ArdourCanvas::Rect (0.0, top, width, trackview.current_height()), true); + frame_handle_start = new ArdourCanvas::DragHandle (group, ArdourCanvas::Rect (0.0, top, width, trackview.current_height() - REGION_BOTTOM_OFFSET), true); CANVAS_DEBUG_NAME (frame_handle_start, "TAVI frame handle start"); frame_handle_start->set_outline (false); frame_handle_start->set_fill (false); frame_handle_start->Event.connect (sigc::bind (sigc::mem_fun (*this, &TimeAxisViewItem::frame_handle_crossing), frame_handle_start)); - frame_handle_end = new ArdourCanvas::DragHandle (group, ArdourCanvas::Rect (0.0, top, width, trackview.current_height()), false); + frame_handle_end = new ArdourCanvas::DragHandle (group, ArdourCanvas::Rect (0.0, top, width, trackview.current_height() - REGION_BOTTOM_OFFSET), false); CANVAS_DEBUG_NAME (frame_handle_end, "TAVI frame handle end"); frame_handle_end->set_outline (false); frame_handle_end->set_fill (false); @@ -325,8 +316,8 @@ TimeAxisViewItem::show_rect () set_frame_color (); if (name_highlight) { - name_highlight->set_outline_what (ArdourCanvas::Rectangle::TOP); - name_highlight->set_fill_color (fill_color); + name_highlight->set_outline_what (ArdourCanvas::Rectangle::What (0)); + name_highlight->set_fill_color (name_highlight_color); } } @@ -572,9 +563,8 @@ TimeAxisViewItem::set_name_text(const string& new_name) return; } - name_text_width = pixel_width (new_name, NAME_FONT) + 2; + name_text_width = pixel_width (new_name, NAME_FONT); name_text->set (new_name); - } /** @@ -589,23 +579,15 @@ TimeAxisViewItem::set_height (double height) manage_name_highlight (); - if (visibility & ShowNameText) { - if (Config->get_show_name_highlight()) { - name_text->set_y_position (height - NAME_Y_OFFSET); - } else { - name_text->set_y_position (NAME_Y_OFFSET); - } - } - if (frame) { - frame->set_y1 (height); + frame->set_y1 (height - REGION_BOTTOM_OFFSET); if (frame_handle_start) { - frame_handle_start->set_y1 (height); - frame_handle_end->set_y1 (height); + frame_handle_start->set_y1 (height - REGION_BOTTOM_OFFSET); + frame_handle_end->set_y1 (height - REGION_BOTTOM_OFFSET); } } - vestigial_frame->set_y1 (height - 1.0); + vestigial_frame->set_y1 (height - REGION_BOTTOM_OFFSET - 1.0); set_colors (); } @@ -613,7 +595,7 @@ TimeAxisViewItem::set_height (double height) void TimeAxisViewItem::manage_name_highlight () { - if (!name_highlight) { + if (!name_highlight) { return; } @@ -623,22 +605,29 @@ TimeAxisViewItem::manage_name_highlight () high_enough_for_name = true; } - if (_width < 2.0) { - wide_enough_for_name = false; + double highlite_y1 = name_text_width + 2*NAME_HIGHLIGHT_X_IDENT + NAME_HIGHLIGHT_X_OFFSET; + if (_width < highlite_y1) { + highlite_y1 = _width; + } + + if (highlite_y1 < NAME_HIGHLIGHT_X_OFFSET) { + wide_enough_for_name = false; } else { wide_enough_for_name = true; } - - if (name_highlight && wide_enough_for_name && high_enough_for_name) { - - name_highlight->show(); - name_highlight->set (ArdourCanvas::Rect (0.0, (double) _height - NAME_HIGHLIGHT_SIZE, _width+RIGHT_EDGE_SHIFT, (double) _height - 1.0)); + + if (wide_enough_for_name && high_enough_for_name && !name_text->text().empty() ) { + name_highlight->set (ArdourCanvas::Rect (NAME_HIGHLIGHT_X_OFFSET, + NAME_HIGHLIGHT_Y_OFFSET, + highlite_y1, + NAME_HIGHLIGHT_HEIGHT) ); + name_highlight->show(); } else { name_highlight->hide(); } - - manage_name_text (); + + manage_name_text (); } void @@ -684,6 +673,10 @@ TimeAxisViewItem::compute_colors (Gdk::Color const & base_color) g = base_color.get_green()/256; b = base_color.get_blue()/256; fill_color = RGBA_TO_UINT(r,g,b,160); + + // place to config + uint32_t opacity = 255*0.5; //50% + name_highlight_color = RGBA_TO_UINT(0, 0, 0, opacity); } /** @@ -695,7 +688,7 @@ TimeAxisViewItem::set_colors() set_frame_color(); if (name_highlight) { - name_highlight->set_fill_color (fill_color); + name_highlight->set_fill_color (name_highlight_color); } if (name_text) { @@ -721,13 +714,7 @@ TimeAxisViewItem::set_colors() (max (g, black_g) - min (g, black_g)) + (max (b, black_b) - min (b, black_b)); - if (white_contrast > black_contrast) { - /* use white */ - name_text->set_color (ArdourCanvas::rgba_to_color (1.0, 1.0, 1.0, 1.0)); - } else { - /* use black */ - name_text->set_color (ArdourCanvas::rgba_to_color (0.0, 0.0, 0.0, 1.0)); - } + name_text->set_color (ArdourCanvas::rgba_to_color (1.0, 1.0, 1.0, 1.0)); #if 0 double h, s, v; @@ -767,15 +754,13 @@ TimeAxisViewItem::get_fill_color () const } else { if (_recregion) { - f = ARDOUR_UI::config()->get_canvasvar_RecordingRect(); + //f = ARDOUR_UI::config()->get_canvasvar_RecordingRect(); + // GZ FIXME:change in config instead of following + f = ArdourCanvas::rgba_to_color (251.0/255.0, 35.0/255.0, 52.0/255.0, 1.0); } else { - if (high_enough_for_name && !ARDOUR_UI::config()->get_color_regions_using_track_color()) { - f = ARDOUR_UI::config()->get_canvasvar_FrameBase(); - } else { - f = fill_color; - f = UINT_RGBA_CHANGE_A (f, (ARDOUR_UI::config()->get_canvasvar_FrameBase() & 0x000000ff)); - } + f = fill_color; + f = UINT_RGBA_CHANGE_A (f, (ARDOUR_UI::config()->get_canvasvar_FrameBase() & 0x000000ff)); } } @@ -795,59 +780,50 @@ TimeAxisViewItem::set_frame_color() } f = get_fill_color (); - - if (fill_opacity) { - f = UINT_RGBA_CHANGE_A (f, (ARDOUR_UI::config()->get_canvasvar_FrameBase() & 0x000000ff)); - } if (!rect_visible) { f = UINT_RGBA_CHANGE_A (f, 0); } - frame->set_fill_color (f); + frame->set_fill_color (f); set_frame_gradient (); - if (!_recregion) { - if (_selected) { - f = ARDOUR_UI::config()->get_canvasvar_SelectedTimeAxisFrame(); - } else { - f = ARDOUR_UI::config()->get_canvasvar_TimeAxisFrame(); - } + //f = ARDOUR_UI::config()->get_canvasvar_TimeAxisFrame(); - if (!rect_visible) { - f = UINT_RGBA_CHANGE_A (f, 64); - } + // GZ FIXME:change in config instead of following + f = ArdourCanvas::rgba_to_color (104.0/255.0, 104.0/255.0, 104.0/255.0, 1.0); - frame->set_outline_color (f); - } + if (!rect_visible) { + f = UINT_RGBA_CHANGE_A (f, 64); + } + + frame->set_outline_color (f); } void TimeAxisViewItem::set_frame_gradient () { - if (ARDOUR_UI::config()->get_timeline_item_gradient_depth() == 0.0) { - frame->set_gradient (ArdourCanvas::Fill::StopList (), 0); - return; - } - ArdourCanvas::Fill::StopList stops; double r, g, b, a; double h, s, v; - ArdourCanvas::Color f (get_fill_color()); - + ArdourCanvas::Color fill_color (get_fill_color() ); + /* need to get alpha value */ - ArdourCanvas::color_to_rgba (f, r, g, b, a); - - /* now a darker version */ + ArdourCanvas::color_to_rgba (fill_color, r, g, b, a); + + /* set base apacity 90% */ + ArdourCanvas::Color base = ArdourCanvas::rgba_to_color (r, g, b, 0.95); + /* set middle apacity 80%*/ + ArdourCanvas::Color middle = ArdourCanvas::rgba_to_color (r, g, b, 0.8); + /* set top color as white with 75% apacity*/ + ArdourCanvas::Color top = ArdourCanvas::rgba_to_color (r, g, b, 0.65); - ArdourCanvas::color_to_hsv (f, h, s, v); - - v = min (1.0, v * (1.0 + ARDOUR_UI::config()->get_timeline_item_gradient_depth())); - - ArdourCanvas::Color lighter = ArdourCanvas::hsv_to_color (h, s, v, a); - stops.push_back (std::make_pair (0.0, lighter)); - stops.push_back (std::make_pair (0.37, f)); - stops.push_back (std::make_pair (1.0, f)); + /*set base color starting from the beginning*/ + stops.push_back (std::make_pair (0.0, top)); + /*set middle color starting from 70% of height*/ + stops.push_back (std::make_pair (0.7, middle)); + /*set middle color starting from on top*/ + stops.push_back (std::make_pair (1.0, base)); frame->set_gradient (stops, true); } @@ -993,8 +969,8 @@ TimeAxisViewItem::manage_name_text () visible_name_width = name_text_width; - if (visible_name_width > _width - NAME_X_OFFSET) { - visible_name_width = _width - NAME_X_OFFSET; + if (visible_name_width > _width - NAME_HIGHLIGHT_X_OFFSET - NAME_HIGHLIGHT_X_IDENT) { + visible_name_width = _width - NAME_HIGHLIGHT_X_OFFSET - NAME_HIGHLIGHT_X_IDENT; } if (visible_name_width < 1) { diff --git a/gtk2_ardour/time_axis_view_item.h b/gtk2_ardour/time_axis_view_item.h index 0345cb1a30..0740cc2cec 100644 --- a/gtk2_ardour/time_axis_view_item.h +++ b/gtk2_ardour/time_axis_view_item.h @@ -102,16 +102,23 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList // Default sizes, font and spacing static Pango::FontDescription NAME_FONT; static void set_constant_heights (); - static const double NAME_X_OFFSET; + static const double NAME_HIGHLIGHT_Y_IDENT; + static const double NAME_HIGHLIGHT_X_OFFSET; + static const double NAME_HIGHLIGHT_Y_OFFSET; static const double GRAB_HANDLE_TOP; static const double GRAB_HANDLE_WIDTH; + static const double REGION_TOP_OFFSET; + static const double REGION_BOTTOM_OFFSET; + /* these are not constant, but vary with the pixel size of the font used to display the item name. */ static int NAME_HEIGHT; + static double NAME_HIGHLIGHT_X_IDENT; + static double NAME_X_OFFSET; static double NAME_Y_OFFSET; - static double NAME_HIGHLIGHT_SIZE; + static double NAME_HIGHLIGHT_HEIGHT; static double NAME_HIGHLIGHT_THRESH; /* if this is 1.0, we move the right boundary @@ -231,6 +238,7 @@ class TimeAxisViewItem : public Selectable, public PBD::ScopedConnectionList uint32_t fill_opacity; uint32_t fill_color; + uint32_t name_highlight_color; uint32_t frame_color_r; uint32_t frame_color_g; uint32_t frame_color_b; diff --git a/gtk2_ardour/ui_config_vars.h b/gtk2_ardour/ui_config_vars.h index aaf73edad6..821942e99a 100644 --- a/gtk2_ardour/ui_config_vars.h +++ b/gtk2_ardour/ui_config_vars.h @@ -22,7 +22,7 @@ UI_CONFIG_VARIABLE(bool, flat_buttons, "flat-buttons", false) UI_CONFIG_VARIABLE(float, waveform_gradient_depth, "waveform-gradient-depth", 0.6) UI_CONFIG_VARIABLE(float, timeline_item_gradient_depth, "timeline-item-gradient-depth", 1.3) UI_CONFIG_VARIABLE(bool, all_floating_windows_are_dialogs, "all-floating-windows-are-dialogs", false) -UI_CONFIG_VARIABLE (bool, color_regions_using_track_color, "color-regions-using-track-color", false) +UI_CONFIG_VARIABLE (bool, color_regions_using_track_color, "color-regions-using-track-color", true) UI_CONFIG_VARIABLE (bool, show_waveform_clipping, "show-waveform-clipping", true) UI_CONFIG_VARIABLE (int, auto_lock_timer, "auto-lock-timer", 0) UI_CONFIG_VARIABLE (int, auto_save_timer, "auto-save-timer", 0)