#include "gtkmm2ext/utils.h"
#include "gtkmm2ext/gui_thread.h"
-#include "canvas/group.h"
+#include "canvas/container.h"
#include "canvas/rectangle.h"
#include "canvas/debug.h"
-#include "canvas/drag_handle.h"
#include "canvas/text.h"
#include "canvas/utils.h"
using namespace Glib;
using namespace PBD;
using namespace ARDOUR;
+using namespace ARDOUR_UI_UTILS;
using namespace Gtkmm2ext;
Pango::FontDescription TimeAxisViewItem::NAME_FONT;
void
TimeAxisViewItem::set_constant_heights ()
{
- NAME_FONT = get_font_for_style (X_("TimeAxisViewItemName"));
+ NAME_FONT = Pango::FontDescription (ARDOUR_UI::config()->get_canvasvar_SmallFont());
Gtk::Window win;
Gtk::Label foo;
* @param automation true if this is an automation region view
*/
TimeAxisViewItem::TimeAxisViewItem(
- const string & it_name, ArdourCanvas::Group& parent, TimeAxisView& tv, double spu, Gdk::Color const & base_color,
+ const string & it_name, ArdourCanvas::Item& parent, TimeAxisView& tv, double spu, uint32_t base_color,
framepos_t start, framecnt_t duration, bool recording, bool automation, Visibility vis
)
: trackview (tv)
, _dragging (other._dragging)
, _width (0.0)
{
-
- Gdk::Color c;
- int r,g,b,a;
-
- UINT_TO_RGBA (other.fill_color, &r, &g, &b, &a);
- c.set_rgb_p (r/255.0, g/255.0, b/255.0);
-
/* share the other's parent, but still create a new group */
- ArdourCanvas::Group* parent = other.group->parent();
+ ArdourCanvas::Item* parent = other.group->parent();
_selected = other._selected;
- init (parent, other.samples_per_pixel, c, other.frame_position,
+ init (parent, other.samples_per_pixel, other.fill_color, other.frame_position,
other.item_duration, other.visibility, other.wide_enough_for_name, other.high_enough_for_name);
}
void
-TimeAxisViewItem::init (ArdourCanvas::Group* parent, double fpp, Gdk::Color const & base_color,
+TimeAxisViewItem::init (ArdourCanvas::Item* parent, double fpp, uint32_t base_color,
framepos_t start, framepos_t duration, Visibility vis,
bool wide, bool high)
{
- group = new ArdourCanvas::Group (parent);
+ group = new ArdourCanvas::Container (parent);
CANVAS_DEBUG_NAME (group, string_compose ("TAVI group for %1", get_item_name()));
group->Event.connect (sigc::mem_fun (*this, &TimeAxisViewItem::canvas_group_event));
+ fill_color = base_color;
samples_per_pixel = fpp;
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;
trackview.current_height() - 1.0));
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 {
name_text->set_position (ArdourCanvas::Duple (NAME_X_OFFSET, NAME_Y_OFFSET));
}
name_text->set_font_description (NAME_FONT);
+ name_text->set_ignore_events (true);
} else {
name_text = 0;
}
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::Rectangle (group, ArdourCanvas::Rect (0.0, top, width, trackview.current_height()));
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::Rectangle (group, ArdourCanvas::Rect (0.0, top, width, trackview.current_height()));
CANVAS_DEBUG_NAME (frame_handle_end, "TAVI frame handle end");
frame_handle_end->set_outline (false);
frame_handle_end->set_fill (false);
if (_selected != yn) {
Selectable::set_selected (yn);
set_frame_color ();
+ set_name_text_color ();
+
+ if (frame) {
+ if (!Config->get_show_name_highlight() && yn) {
+ frame->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::LEFT|ArdourCanvas::Rectangle::RIGHT|ArdourCanvas::Rectangle::BOTTOM|ArdourCanvas::Rectangle::TOP));
+ frame->set_y1 (_height - 1.0);
+ } else {
+ 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));
+ }
+ frame->set_y1 (_height);
+ }
+ }
}
}
}
if (frame) {
- frame->set_y1 (height);
+ if (!Config->get_show_name_highlight() && _selected) {
+ frame->set_outline_what (ArdourCanvas::Rectangle::What (ArdourCanvas::Rectangle::LEFT|ArdourCanvas::Rectangle::RIGHT|ArdourCanvas::Rectangle::BOTTOM|ArdourCanvas::Rectangle::TOP));
+ frame->set_y1 (_height - 1.0);
+ } else {
+ 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));
+ }
+ frame->set_y1 (_height);
+ }
+
if (frame_handle_start) {
frame_handle_start->set_y1 (height);
frame_handle_end->set_y1 (height);
}
void
-TimeAxisViewItem::set_color (Gdk::Color const & base_color)
+TimeAxisViewItem::set_color (uint32_t base_color)
{
- compute_colors (base_color);
+ fill_color = base_color;
set_colors ();
}
return frame;
}
-ArdourCanvas::Group*
+ArdourCanvas::Item*
TimeAxisViewItem::get_canvas_group()
{
return group;
return name_highlight;
}
-/**
- * Calculate some contrasting color for displaying various parts of this item, based upon the base color.
- *
- * @param color the base color of the item
- */
-void
-TimeAxisViewItem::compute_colors (Gdk::Color const & base_color)
-{
- unsigned char r,g,b;
-
- /* FILL: change opacity to a fixed value */
-
- r = base_color.get_red()/256;
- g = base_color.get_green()/256;
- b = base_color.get_blue()/256;
- fill_color = RGBA_TO_UINT(r,g,b,160);
-}
-
/**
* Convenience method to set the various canvas item colors
*/
void
TimeAxisViewItem::set_colors()
{
- set_frame_color();
+ set_frame_color ();
if (name_highlight) {
name_highlight->set_fill_color (fill_color);
return;
}
- double r, g, b, a;
-
- const double black_r = 0.0;
- const double black_g = 0.0;
- const double black_b = 0.0;
-
- const double white_r = 1.0;
- const double white_g = 1.0;
- const double white_b = 1.0;
uint32_t f;
f = get_fill_color ();
}
- ArdourCanvas::color_to_rgba (f, r, g, b, a);
-
- /* Use W3C contrast guideline calculation */
-
- double white_contrast = (max (r, white_r) - min (r, white_r)) +
- (max (g, white_g) - min (g, white_g)) +
- (max (b, white_b) - min (b, white_b));
+ name_text->set_color (ArdourCanvas::contrasting_text_color (f));
+}
- double black_contrast = (max (r, black_r) - min (r, black_r)) +
- (max (g, black_g) - min (g, black_g)) +
- (max (b, black_b) - min (b, black_b));
+uint32_t
+TimeAxisViewItem::fill_opacity () const
+{
+ if (!rect_visible) {
+ /* if the frame/rect is marked as invisible, then the
+ * fill should be transparent. simplest: set
+
+ * alpha/opacity to zero.
+ */
+ return 0;
+ }
- 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));
+ if (_dragging) {
+ return 130;
}
+
+ uint32_t col = ARDOUR_UI::config()->get_canvasvar_FrameBase();
+ return UINT_RGBA_A (col);
}
uint32_t
uint32_t f;
uint32_t o;
+ o = fill_opacity ();
+
if (_selected) {
f = ARDOUR_UI::config()->get_canvasvar_SelectedFrameBase();
- if (fill_opacity != 0) {
- o = fill_opacity;
- } else {
+ if (o == 0) {
/* some condition of this item has set fill opacity to
* zero, but it has been selected, so use a mid-way
* alpha value to make it reasonably visible.
if (_recregion) {
f = ARDOUR_UI::config()->get_canvasvar_RecordingRect();
} else {
-
- if (high_enough_for_name && !ARDOUR_UI::config()->get_color_regions_using_track_color()) {
+ if ((!Config->get_show_name_highlight() || high_enough_for_name) && !ARDOUR_UI::config()->get_color_regions_using_track_color()) {
f = ARDOUR_UI::config()->get_canvasvar_FrameBase();
} else {
f = fill_color;
}
}
-
- /* tweak opacity */
-
- if (!rect_visible) {
- o = 0;
- } else {
- o = fill_opacity;
- }
-
}
return UINT_RGBA_CHANGE_A (f, o);
_width = pixel_width;
manage_name_highlight ();
+ manage_name_text ();
if (pixel_width < 2.0) {
}
void
-TimeAxisViewItem::visual_raise_to_top ()
+TimeAxisViewItem::drag_start ()
+{
+ _dragging = true;
+ set_frame_color ();
+}
+
+void
+TimeAxisViewItem::drag_end ()
{
- group->raise_to_top ();
+ _dragging = false;
+ set_frame_color ();
}