Refactor group tabs code a bit. Allow dragging of group tabs to alter group membership.
git-svn-id: svn://localhost/ardour2/branches/3.0@5237 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
955d731fa6
commit
49928d3fa3
|
@ -20,7 +20,7 @@
|
||||||
#include "ardour/route_group.h"
|
#include "ardour/route_group.h"
|
||||||
#include "editor_group_tabs.h"
|
#include "editor_group_tabs.h"
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
#include "time_axis_view.h"
|
#include "route_time_axis.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -32,18 +32,14 @@ EditorGroupTabs::EditorGroupTabs (Editor* e)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
list<GroupTabs::Tab>
|
||||||
EditorGroupTabs::render (cairo_t* cr)
|
EditorGroupTabs::compute_tabs () const
|
||||||
{
|
{
|
||||||
/* background */
|
list<Tab> tabs;
|
||||||
|
|
||||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
Tab tab;
|
||||||
cairo_rectangle (cr, 0, 0, _width, _height);
|
tab.from = 0;
|
||||||
cairo_fill (cr);
|
tab.group = 0;
|
||||||
|
|
||||||
int32_t curr_start = 0;
|
|
||||||
RouteGroup* curr_group = 0;
|
|
||||||
Gdk::Color curr_colour;
|
|
||||||
|
|
||||||
int32_t y = 0;
|
int32_t y = 0;
|
||||||
for (Editor::TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
|
for (Editor::TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
|
||||||
|
@ -54,74 +50,103 @@ EditorGroupTabs::render (cairo_t* cr)
|
||||||
|
|
||||||
RouteGroup* g = (*i)->route_group ();
|
RouteGroup* g = (*i)->route_group ();
|
||||||
|
|
||||||
if (g != curr_group) {
|
if (g != tab.group) {
|
||||||
if (curr_group) {
|
if (tab.group) {
|
||||||
draw_group (cr, curr_start, y, curr_group, curr_colour);
|
tab.to = y;
|
||||||
|
tabs.push_back (tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_start = y;
|
tab.from = y;
|
||||||
curr_group = g;
|
tab.group = g;
|
||||||
curr_colour = (*i)->color ();
|
tab.colour = (*i)->color ();
|
||||||
}
|
}
|
||||||
|
|
||||||
y += (*i)->effective_height ();
|
y += (*i)->effective_height ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curr_group) {
|
if (tab.group) {
|
||||||
draw_group (cr, curr_start, y, curr_group, curr_colour);
|
tab.to = y;
|
||||||
|
tabs.push_back (tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EditorGroupTabs::draw_group (cairo_t* cr, int32_t y1, int32_t y2, RouteGroup* g, Gdk::Color const & colour)
|
EditorGroupTabs::draw_tab (cairo_t* cr, Tab const & tab) const
|
||||||
{
|
{
|
||||||
double const arc_radius = _width;
|
double const arc_radius = _width;
|
||||||
|
|
||||||
if (g->is_active()) {
|
if (tab.group->is_active()) {
|
||||||
cairo_set_source_rgba (cr, colour.get_red_p (), colour.get_green_p (), colour.get_blue_p (), 1);
|
cairo_set_source_rgba (cr, tab.colour.get_red_p (), tab.colour.get_green_p (), tab.colour.get_blue_p (), 1);
|
||||||
} else {
|
} else {
|
||||||
cairo_set_source_rgba (cr, 1, 1, 1, 0.2);
|
cairo_set_source_rgba (cr, 1, 1, 1, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_move_to (cr, 0, y1 + arc_radius);
|
cairo_move_to (cr, 0, tab.from + arc_radius);
|
||||||
cairo_arc (cr, _width, y1 + arc_radius, arc_radius, M_PI, 3 * M_PI / 2);
|
cairo_arc (cr, _width, tab.from + arc_radius, arc_radius, M_PI, 3 * M_PI / 2);
|
||||||
cairo_line_to (cr, _width, y2);
|
cairo_line_to (cr, _width, tab.to);
|
||||||
cairo_arc (cr, _width, y2 - arc_radius, arc_radius, M_PI / 2, M_PI);
|
cairo_arc (cr, _width, tab.to - arc_radius, arc_radius, M_PI / 2, M_PI);
|
||||||
cairo_line_to (cr, 0, y1 + arc_radius);
|
cairo_line_to (cr, 0, tab.from + arc_radius);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
|
|
||||||
pair<string, double> const f = fit_to_pixels (cr, g->name(), y2 - y1 - arc_radius * 2);
|
pair<string, double> const f = fit_to_pixels (cr, tab.group->name(), tab.to - tab.from - arc_radius * 2);
|
||||||
|
|
||||||
cairo_text_extents_t ext;
|
cairo_text_extents_t ext;
|
||||||
cairo_text_extents (cr, g->name().c_str(), &ext);
|
cairo_text_extents (cr, tab.group->name().c_str(), &ext);
|
||||||
|
|
||||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||||
cairo_move_to (cr, _width - ext.height / 2, y1 + (f.second + y2 - y1) / 2);
|
cairo_move_to (cr, _width - ext.height / 2, tab.from + (f.second + tab.to - tab.from) / 2);
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
cairo_rotate (cr, - M_PI / 2);
|
cairo_rotate (cr, - M_PI / 2);
|
||||||
cairo_show_text (cr, f.first.c_str());
|
cairo_show_text (cr, f.first.c_str());
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
RouteGroup*
|
double
|
||||||
EditorGroupTabs::click_to_route_group (GdkEventButton* ev)
|
EditorGroupTabs::primary_coordinate (double, double y) const
|
||||||
{
|
{
|
||||||
int32_t y = 0;
|
return y;
|
||||||
Editor::TrackViewList::iterator i = _editor->track_views.begin();
|
}
|
||||||
while (y < ev->y && i != _editor->track_views.end()) {
|
|
||||||
|
void
|
||||||
if ((*i)->marked_for_display()) {
|
EditorGroupTabs::reflect_tabs (list<Tab> const & tabs)
|
||||||
y += (*i)->effective_height ();
|
{
|
||||||
}
|
list<Tab>::const_iterator j = tabs.begin ();
|
||||||
|
|
||||||
if (y < ev->y) {
|
int32_t y = 0;
|
||||||
++i;
|
for (Editor::TrackViewList::iterator i = _editor->track_views.begin(); i != _editor->track_views.end(); ++i) {
|
||||||
}
|
|
||||||
}
|
if ((*i)->marked_for_display() == false) {
|
||||||
|
continue;
|
||||||
if (i == _editor->track_views.end()) {
|
}
|
||||||
return 0;
|
|
||||||
}
|
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
|
||||||
|
if (rtv) {
|
||||||
return (*i)->route_group ();
|
|
||||||
|
if (j == tabs.end()) {
|
||||||
|
|
||||||
|
/* already run out of tabs, so no edit group */
|
||||||
|
rtv->route()->set_route_group (0, this);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (y >= j->to) {
|
||||||
|
/* this tab finishes before this track starts, so onto the next tab */
|
||||||
|
++j;
|
||||||
|
}
|
||||||
|
|
||||||
|
double const h = y + (*i)->effective_height() / 2;
|
||||||
|
|
||||||
|
if (j->from < h && j->to > h) {
|
||||||
|
rtv->route()->set_route_group (j->group, this);
|
||||||
|
} else {
|
||||||
|
rtv->route()->set_route_group (0, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
y += (*i)->effective_height ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,13 @@ public:
|
||||||
EditorGroupTabs (Editor *);
|
EditorGroupTabs (Editor *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ARDOUR::RouteGroup* click_to_route_group (GdkEventButton *);
|
std::list<Tab> compute_tabs () const;
|
||||||
void render (cairo_t *);
|
void draw_tab (cairo_t *, Tab const &) const;
|
||||||
|
double primary_coordinate (double, double) const;
|
||||||
void draw_group (cairo_t *, int32_t, int32_t, ARDOUR::RouteGroup* , Gdk::Color const &);
|
void reflect_tabs (std::list<Tab> const &);
|
||||||
|
double extent () const {
|
||||||
|
return _height;
|
||||||
|
}
|
||||||
|
|
||||||
Editor* _editor;
|
Editor* _editor;
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,12 +24,14 @@
|
||||||
#include "group_tabs.h"
|
#include "group_tabs.h"
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
using namespace Gtk;
|
using namespace Gtk;
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
|
|
||||||
GroupTabs::GroupTabs ()
|
GroupTabs::GroupTabs ()
|
||||||
: _session (0),
|
: _session (0),
|
||||||
_menu (0)
|
_menu (0),
|
||||||
|
_dragging (0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,19 +60,37 @@ GroupTabs::on_button_press_event (GdkEventButton* ev)
|
||||||
{
|
{
|
||||||
using namespace Menu_Helpers;
|
using namespace Menu_Helpers;
|
||||||
|
|
||||||
RouteGroup* g = click_to_route_group (ev);
|
double const p = primary_coordinate (ev->x, ev->y);
|
||||||
|
|
||||||
if (ev->button == 1 && g) {
|
Tab* prev;
|
||||||
|
Tab* next;
|
||||||
|
Tab* t = click_to_tab (p, &prev, &next);
|
||||||
|
if (t == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
g->set_active (!g->is_active (), this);
|
if (ev->button == 1) {
|
||||||
|
|
||||||
} else if (ev->button == 3 && g) {
|
_dragging = t;
|
||||||
|
_drag_moved = false;
|
||||||
|
_drag_last = p;
|
||||||
|
|
||||||
|
double const h = (t->from + t->to) / 2;
|
||||||
|
_drag_from = p < h;
|
||||||
|
|
||||||
|
if (_drag_from) {
|
||||||
|
_drag_limit = prev ? prev->to : 0;
|
||||||
|
} else {
|
||||||
|
_drag_limit = next ? next->from : extent ();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (ev->button == 3) {
|
||||||
|
|
||||||
if (!_menu) {
|
if (!_menu) {
|
||||||
_menu = new Menu;
|
_menu = new Menu;
|
||||||
MenuList& items = _menu->items ();
|
MenuList& items = _menu->items ();
|
||||||
items.push_back (MenuElem (_("Edit..."), bind (mem_fun (*this, &GroupTabs::edit_group), g)));
|
items.push_back (MenuElem (_("Edit..."), bind (mem_fun (*this, &GroupTabs::edit_group), t->group)));
|
||||||
items.push_back (MenuElem (_("Remove"), bind (mem_fun (*this, &GroupTabs::remove_group), g)));
|
items.push_back (MenuElem (_("Remove"), bind (mem_fun (*this, &GroupTabs::remove_group), t->group)));
|
||||||
}
|
}
|
||||||
|
|
||||||
_menu->popup (ev->button, ev->time);
|
_menu->popup (ev->button, ev->time);
|
||||||
|
@ -81,6 +101,63 @@ GroupTabs::on_button_press_event (GdkEventButton* ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
GroupTabs::on_motion_notify_event (GdkEventMotion* ev)
|
||||||
|
{
|
||||||
|
if (_dragging == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
double const p = primary_coordinate (ev->x, ev->y);
|
||||||
|
|
||||||
|
if (p != _drag_last) {
|
||||||
|
_drag_moved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_drag_from) {
|
||||||
|
double f = _dragging->from + p - _drag_last;
|
||||||
|
if (f < _drag_limit) {
|
||||||
|
f = _drag_limit;
|
||||||
|
}
|
||||||
|
_dragging->from = f;
|
||||||
|
} else {
|
||||||
|
double t = _dragging->to + p - _drag_last;
|
||||||
|
if (t > _drag_limit) {
|
||||||
|
t = _drag_limit;
|
||||||
|
}
|
||||||
|
_dragging->to = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
set_dirty ();
|
||||||
|
queue_draw ();
|
||||||
|
|
||||||
|
_drag_last = p;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
GroupTabs::on_button_release_event (GdkEventButton* ev)
|
||||||
|
{
|
||||||
|
if (_dragging == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_drag_moved) {
|
||||||
|
_dragging->group->set_active (!_dragging->group->is_active (), this);
|
||||||
|
_dragging = 0;
|
||||||
|
} else {
|
||||||
|
_dragging = 0;
|
||||||
|
reflect_tabs (_tabs);
|
||||||
|
set_dirty ();
|
||||||
|
queue_draw ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GroupTabs::edit_group (RouteGroup* g)
|
GroupTabs::edit_group (RouteGroup* g)
|
||||||
{
|
{
|
||||||
|
@ -93,3 +170,49 @@ GroupTabs::remove_group (RouteGroup *g)
|
||||||
{
|
{
|
||||||
_session->remove_route_group (*g);
|
_session->remove_route_group (*g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GroupTabs::render (cairo_t* cr)
|
||||||
|
{
|
||||||
|
if (_dragging == 0) {
|
||||||
|
_tabs = compute_tabs ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* background */
|
||||||
|
|
||||||
|
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||||
|
cairo_rectangle (cr, 0, 0, _width, _height);
|
||||||
|
cairo_fill (cr);
|
||||||
|
|
||||||
|
/* tabs */
|
||||||
|
|
||||||
|
for (list<Tab>::const_iterator i = _tabs.begin(); i != _tabs.end(); ++i) {
|
||||||
|
draw_tab (cr, *i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GroupTabs::Tab *
|
||||||
|
GroupTabs::click_to_tab (double c, Tab** prev, Tab** next)
|
||||||
|
{
|
||||||
|
list<Tab>::iterator i = _tabs.begin ();
|
||||||
|
while (i != _tabs.end() && (c < i->from || c > i->to)) {
|
||||||
|
*prev = &(*i);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == _tabs.end()) {
|
||||||
|
*next = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
list<Tab>::iterator j = i;
|
||||||
|
++j;
|
||||||
|
if (j == _tabs.end()) {
|
||||||
|
*next = 0;
|
||||||
|
} else {
|
||||||
|
*next = &(*j);
|
||||||
|
}
|
||||||
|
|
||||||
|
return &(*i);
|
||||||
|
}
|
||||||
|
|
|
@ -34,16 +34,38 @@ public:
|
||||||
|
|
||||||
void set_session (ARDOUR::Session *);
|
void set_session (ARDOUR::Session *);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
virtual ARDOUR::RouteGroup* click_to_route_group (GdkEventButton* ev) = 0;
|
|
||||||
virtual void render (cairo_t *) = 0;
|
|
||||||
|
|
||||||
|
struct Tab {
|
||||||
|
double from;
|
||||||
|
double to;
|
||||||
|
Gdk::Color colour;
|
||||||
|
ARDOUR::RouteGroup* group;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual std::list<Tab> compute_tabs () const = 0;
|
||||||
|
virtual void draw_tab (cairo_t *, Tab const &) const = 0;
|
||||||
|
virtual double primary_coordinate (double, double) const = 0;
|
||||||
|
virtual void reflect_tabs (std::list<Tab> const &) = 0;
|
||||||
|
virtual double extent () const = 0;
|
||||||
|
|
||||||
|
void render (cairo_t *);
|
||||||
void on_size_request (Gtk::Requisition *);
|
void on_size_request (Gtk::Requisition *);
|
||||||
bool on_button_press_event (GdkEventButton *);
|
bool on_button_press_event (GdkEventButton *);
|
||||||
|
bool on_motion_notify_event (GdkEventMotion *);
|
||||||
|
bool on_button_release_event (GdkEventButton *);
|
||||||
|
|
||||||
|
Tab * click_to_tab (double, Tab**, Tab**);
|
||||||
void edit_group (ARDOUR::RouteGroup *);
|
void edit_group (ARDOUR::RouteGroup *);
|
||||||
void remove_group (ARDOUR::RouteGroup *);
|
void remove_group (ARDOUR::RouteGroup *);
|
||||||
|
|
||||||
ARDOUR::Session* _session;
|
ARDOUR::Session* _session;
|
||||||
Gtk::Menu* _menu;
|
Gtk::Menu* _menu;
|
||||||
|
std::list<Tab> _tabs;
|
||||||
|
Tab* _dragging;
|
||||||
|
bool _drag_moved;
|
||||||
|
bool _drag_from;
|
||||||
|
double _drag_last;
|
||||||
|
double _drag_limit;
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,18 +34,14 @@ MixerGroupTabs::MixerGroupTabs (Mixer_UI* m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
list<GroupTabs::Tab>
|
||||||
MixerGroupTabs::render (cairo_t* cr)
|
MixerGroupTabs::compute_tabs () const
|
||||||
{
|
{
|
||||||
/* background */
|
list<Tab> tabs;
|
||||||
|
|
||||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
Tab tab;
|
||||||
cairo_rectangle (cr, 0, 0, _width, _height);
|
tab.from = 0;
|
||||||
cairo_fill (cr);
|
tab.group = 0;
|
||||||
|
|
||||||
int32_t curr_start = 0;
|
|
||||||
RouteGroup* curr_group = 0;
|
|
||||||
Gdk::Color curr_colour;
|
|
||||||
|
|
||||||
int32_t x = 0;
|
int32_t x = 0;
|
||||||
for (list<MixerStrip*>::iterator i = _mixer->strips.begin(); i != _mixer->strips.end(); ++i) {
|
for (list<MixerStrip*>::iterator i = _mixer->strips.begin(); i != _mixer->strips.end(); ++i) {
|
||||||
|
@ -56,72 +52,98 @@ MixerGroupTabs::render (cairo_t* cr)
|
||||||
|
|
||||||
RouteGroup* g = (*i)->route_group ();
|
RouteGroup* g = (*i)->route_group ();
|
||||||
|
|
||||||
if (g != curr_group) {
|
if (g != tab.group) {
|
||||||
if (curr_group) {
|
if (tab.group) {
|
||||||
draw_group (cr, curr_start, x, curr_group, curr_colour);
|
tab.to = x;
|
||||||
|
tabs.push_back (tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_start = x;
|
tab.from = x;
|
||||||
curr_group = g;
|
tab.group = g;
|
||||||
curr_colour = (*i)->color ();
|
tab.colour = (*i)->color ();
|
||||||
}
|
}
|
||||||
|
|
||||||
x += (*i)->get_width ();
|
x += (*i)->get_width ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curr_group) {
|
if (tab.group) {
|
||||||
draw_group (cr, curr_start, x, curr_group, curr_colour);
|
tab.to = x;
|
||||||
|
tabs.push_back (tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MixerGroupTabs::draw_group (cairo_t* cr, int32_t x1, int32_t x2, RouteGroup* g, Gdk::Color const & colour)
|
MixerGroupTabs::draw_tab (cairo_t* cr, Tab const & tab) const
|
||||||
{
|
{
|
||||||
double const arc_radius = _height;
|
double const arc_radius = _height;
|
||||||
|
|
||||||
if (g->is_active()) {
|
if (tab.group->is_active()) {
|
||||||
cairo_set_source_rgba (cr, colour.get_red_p (), colour.get_green_p (), colour.get_blue_p (), 1);
|
cairo_set_source_rgba (cr, tab.colour.get_red_p (), tab.colour.get_green_p (), tab.colour.get_blue_p (), 1);
|
||||||
} else {
|
} else {
|
||||||
cairo_set_source_rgba (cr, 1, 1, 1, 0.2);
|
cairo_set_source_rgba (cr, 1, 1, 1, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_arc (cr, x1 + arc_radius, _height, arc_radius, M_PI, 3 * M_PI / 2);
|
cairo_arc (cr, tab.from + arc_radius, _height, arc_radius, M_PI, 3 * M_PI / 2);
|
||||||
cairo_line_to (cr, x2 - arc_radius, 0);
|
cairo_line_to (cr, tab.to - arc_radius, 0);
|
||||||
cairo_arc (cr, x2 - arc_radius, _height, arc_radius, 3 * M_PI / 2, 2 * M_PI);
|
cairo_arc (cr, tab.to - arc_radius, _height, arc_radius, 3 * M_PI / 2, 2 * M_PI);
|
||||||
cairo_line_to (cr, x1, _height);
|
cairo_line_to (cr, tab.from, _height);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
|
|
||||||
pair<string, double> const f = fit_to_pixels (cr, g->name(), x2 - x1 - arc_radius * 2);
|
pair<string, double> const f = fit_to_pixels (cr, tab.group->name(), tab.to - tab.from - arc_radius * 2);
|
||||||
|
|
||||||
cairo_text_extents_t ext;
|
cairo_text_extents_t ext;
|
||||||
cairo_text_extents (cr, g->name().c_str(), &ext);
|
cairo_text_extents (cr, tab.group->name().c_str(), &ext);
|
||||||
|
|
||||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||||
cairo_move_to (cr, x1 + (x2 - x1 - f.second) / 2, _height - ext.height / 2);
|
cairo_move_to (cr, tab.from + (tab.to - tab.from - f.second) / 2, _height - ext.height / 2);
|
||||||
cairo_save (cr);
|
cairo_save (cr);
|
||||||
cairo_show_text (cr, f.first.c_str());
|
cairo_show_text (cr, f.first.c_str());
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
RouteGroup*
|
double
|
||||||
MixerGroupTabs::click_to_route_group (GdkEventButton* ev)
|
MixerGroupTabs::primary_coordinate (double x, double) const
|
||||||
{
|
{
|
||||||
int32_t x = 0;
|
return x;
|
||||||
list<MixerStrip*>::iterator i = _mixer->strips.begin();
|
|
||||||
while (x < ev->x && i != _mixer->strips.end()) {
|
|
||||||
|
|
||||||
if (!(*i)->route()->is_master() && !(*i)->route()->is_control() && (*i)->marked_for_display()) {
|
|
||||||
x += (*i)->get_width ();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x < ev->x) {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == _mixer->strips.end()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (*i)->route_group ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MixerGroupTabs::reflect_tabs (list<Tab> const & tabs)
|
||||||
|
{
|
||||||
|
list<Tab>::const_iterator j = tabs.begin ();
|
||||||
|
|
||||||
|
int32_t x = 0;
|
||||||
|
for (list<MixerStrip*>::iterator i = _mixer->strips.begin(); i != _mixer->strips.end(); ++i) {
|
||||||
|
|
||||||
|
if ((*i)->route()->is_master() || (*i)->route()->is_control() || !(*i)->marked_for_display()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (j == tabs.end()) {
|
||||||
|
|
||||||
|
/* already run out of tabs, so no edit group */
|
||||||
|
(*i)->route()->set_route_group (0, this);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (x >= j->to) {
|
||||||
|
/* this tab finishes before this track starts, so onto the next tab */
|
||||||
|
++j;
|
||||||
|
}
|
||||||
|
|
||||||
|
double const h = x + (*i)->get_width() / 2;
|
||||||
|
|
||||||
|
if (j->from < h && j->to > h) {
|
||||||
|
(*i)->route()->set_route_group (j->group, this);
|
||||||
|
} else {
|
||||||
|
(*i)->route()->set_route_group (0, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
x += (*i)->get_width ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,10 +27,13 @@ public:
|
||||||
MixerGroupTabs (Mixer_UI *);
|
MixerGroupTabs (Mixer_UI *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ARDOUR::RouteGroup* click_to_route_group (GdkEventButton *);
|
std::list<Tab> compute_tabs () const;
|
||||||
void render (cairo_t *);
|
void draw_tab (cairo_t *, Tab const &) const;
|
||||||
|
double primary_coordinate (double, double) const;
|
||||||
void draw_group (cairo_t *, int32_t, int32_t, ARDOUR::RouteGroup* , Gdk::Color const &);
|
void reflect_tabs (std::list<Tab> const &);
|
||||||
|
double extent () const {
|
||||||
|
return _width;
|
||||||
|
}
|
||||||
|
|
||||||
Mixer_UI* _mixer;
|
Mixer_UI* _mixer;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user