along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id$
*/
#include <cmath>
#include <climits>
#include <string.h>
-#include <pbd/error.h>
-#include <ardour/panner.h>
+#include <cairo.h>
+#include <gtkmm/menu.h>
+
+#include "pbd/error.h"
+#include "pbd/cartesian.h"
+#include "ardour/panner.h"
#include <gtkmm2ext/gtk_ui.h>
#include "panner2d.h"
using namespace std;
using namespace Gtk;
-using namespace sigc;
using namespace ARDOUR;
+using namespace PBD;
+using Gtkmm2ext::Keyboard;
-Panner2d::Target::Target (float xa, float ya, const char *txt)
- : x (xa), y (ya), text (txt ? strdup (txt) : 0)
+Panner2d::Target::Target (const AngularVector& a, const char *txt)
+ : position (a)
+ , text (txt)
+ , _selected (false)
{
- if (text) {
- textlen = strlen (txt);
- } else {
- textlen = 0;
- }
}
Panner2d::Target::~Target ()
-{
- if (text) {
- free (text);
- }
+{
}
-Panner2d::Panner2d (Panner& p, int32_t w, int32_t h)
- : panner (p), width (w), height (h)
+void
+Panner2d::Target::set_text (const char* txt)
{
- context_menu = 0;
- bypass_menu_item = 0;
+ text = txt;
+}
- allow_x = false;
- allow_y = false;
- allow_target = false;
+Panner2d::Panner2d (boost::shared_ptr<Panner> p, int32_t h)
+ : panner (p), width (0), height (h)
+{
+ panner->StateChanged.connect (state_connection, invalidator (*this), boost::bind (&Panner2d::handle_state_change, this), gui_context());
+ panner->Changed.connect (change_connection, invalidator (*this), boost::bind (&Panner2d::handle_position_change, this), gui_context());
- panner.StateChanged.connect (mem_fun(*this, &Panner2d::handle_state_change));
-
drag_target = 0;
set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
-
}
Panner2d::~Panner2d()
{
for (Targets::iterator i = targets.begin(); i != targets.end(); ++i) {
- delete i->second;
+ delete *i;
}
}
void
Panner2d::reset (uint32_t n_inputs)
{
- /* add pucks */
-
- drop_pucks ();
-
+ Targets::size_type existing_pucks = pucks.size();
+
+ /* pucks */
+
+ while (pucks.size() < n_inputs) {
+ add_puck ("", AngularVector());
+ }
+
+ if (pucks.size() > n_inputs) {
+ for (uint32_t i = pucks.size(); i < n_inputs; ++i) {
+ delete pucks[i];
+ }
+
+ pucks.resize (n_inputs);
+ }
+
+ for (Targets::iterator x = pucks.begin(); x != pucks.end(); ++x) {
+ (*x)->visible = false;
+ }
+
switch (n_inputs) {
case 0:
break;
-
+
case 1:
- add_puck ("", 0.0f, 0.5f);
+ pucks[0]->set_text ("");
break;
-
+
case 2:
- add_puck ("L", 0.5f, 0.25f);
- add_puck ("R", 0.25f, 0.5f);
- show_puck (0);
- show_puck (1);
+ pucks[0]->set_text ("R");
+ pucks[1]->set_text ("L");
break;
-
+
default:
for (uint32_t i = 0; i < n_inputs; ++i) {
char buf[64];
- snprintf (buf, sizeof (buf), "%" PRIu32, i);
- add_puck (buf, 0.0f, 0.5f);
- show_puck (i);
+ snprintf (buf, sizeof (buf), "%" PRIu32, i + 1);
+ pucks[i]->set_text (buf);
}
break;
}
-
- /* add all outputs */
-
- drop_targets ();
-
- for (uint32_t n = 0; n < panner.nouts(); ++n) {
- add_target (panner.output (n).x, panner.output (n).y);
+
+ for (uint32_t i = existing_pucks; i < n_inputs; ++i) {
+ pucks[i]->position = panner->streampanner (i).get_position ();
+ pucks[i]->visible = true;
}
-
- allow_x_motion (true);
- allow_y_motion (true);
- allow_target_motion (true);
-}
-void
-Panner2d::on_size_allocate (Gtk::Allocation alloc)
-{
- width = alloc.get_width();
- height = alloc.get_height();
+ /* add all outputs */
- DrawingArea::on_size_allocate (alloc);
-}
+ while (targets.size() < panner->nouts()) {
+ add_target (AngularVector());
+ }
-int
-Panner2d::add_puck (const char* text, float x, float y)
-{
- Target* puck = new Target (x, y, text);
+ if (targets.size() > panner->nouts()) {
+ for (uint32_t i = panner->nouts(); i < targets.size(); ++i) {
+ delete targets[i];
+ }
- pair<int,Target *> newpair;
- newpair.first = pucks.size();
- newpair.second = puck;
+ targets.resize (panner->nouts ());
+ }
- pucks.insert (newpair);
- puck->visible = true;
-
- return 0;
-}
+ for (Targets::iterator x = targets.begin(); x != targets.end(); ++x) {
+ (*x)->visible = false;
+ }
-int
-Panner2d::add_target (float x, float y)
-{
- Target *target = new Target (x, y, "");
+ for (uint32_t n = 0; n < panner->nouts(); ++n) {
+ char buf[16];
- pair<int,Target *> newpair;
- newpair.first = targets.size();
- newpair.second = target;
+ snprintf (buf, sizeof (buf), "%d", n+1);
+ targets[n]->set_text (buf);
+ targets[n]->position = panner->output(n).position;
+ targets[n]->visible = true;
+ }
- targets.insert (newpair);
- target->visible = true;
queue_draw ();
-
- return newpair.first;
}
void
-Panner2d::drop_targets ()
+Panner2d::on_size_allocate (Gtk::Allocation& alloc)
{
- for (Targets::iterator i = targets.begin(); i != targets.end(); ) {
-
- Targets::iterator tmp;
-
- tmp = i;
- ++tmp;
-
- delete i->second;
- targets.erase (i);
+ width = alloc.get_width();
+ height = alloc.get_height();
- i = tmp;
+ if (height > 100) {
+ width -= 20;
+ height -= 20;
}
- queue_draw ();
+ DrawingArea::on_size_allocate (alloc);
}
-void
-Panner2d::drop_pucks ()
+int
+Panner2d::add_puck (const char* text, const AngularVector& a)
{
- for (Targets::iterator i = pucks.begin(); i != pucks.end(); ) {
-
- Targets::iterator tmp;
-
- tmp = i;
- ++tmp;
-
- delete i->second;
- pucks.erase (i);
-
- i = tmp;
- }
+ Target* puck = new Target (a, text);
+ pucks.push_back (puck);
+ puck->visible = true;
- queue_draw ();
+ return 0;
}
-void
-Panner2d::remove_target (int which)
+int
+Panner2d::add_target (const AngularVector& a)
{
- Targets::iterator i = targets.find (which);
+ Target* target = new Target (a, "");
+ targets.push_back (target);
+ target->visible = true;
+ queue_draw ();
- if (i != targets.end()) {
- delete i->second;
- targets.erase (i);
- queue_draw ();
- }
-}
+ return targets.size() - 1;
+}
void
Panner2d::handle_state_change ()
{
- ENSURE_GUI_THREAD(mem_fun(*this, &Panner2d::handle_state_change));
+ ENSURE_GUI_THREAD (*this, &Panner2d::handle_state_change)
queue_draw ();
}
void
-Panner2d::move_target (int which, float x, float y)
+Panner2d::handle_position_change ()
{
- Targets::iterator i = targets.find (which);
- Target *target;
-
- if (!allow_target) {
- return;
- }
+ uint32_t n;
+ ENSURE_GUI_THREAD (*this, &Panner2d::handle_position_change)
- if (i != targets.end()) {
- target = i->second;
- target->x = x;
- target->y = y;
-
- queue_draw ();
+ for (n = 0; n < pucks.size(); ++n) {
+ pucks[n]->position = panner->streampanner(n).get_position ();
}
-}
-void
-Panner2d::move_puck (int which, float x, float y)
-{
- Targets::iterator i = pucks.find (which);
- Target *target;
-
- if (i != pucks.end()) {
- target = i->second;
- target->x = x;
- target->y = y;
-
- queue_draw ();
+ for (n = 0; n < targets.size(); ++n) {
+ targets[n]->position = panner->output(n).position;
}
-}
-void
-Panner2d::show_puck (int which)
-{
- Targets::iterator i = pucks.find (which);
-
- if (i != pucks.end()) {
- Target* puck = i->second;
- if (!puck->visible) {
- puck->visible = true;
- queue_draw ();
- }
- }
-}
-
-void
-Panner2d::hide_puck (int which)
-{
- Targets::iterator i = pucks.find (which);
-
- if (i != pucks.end()) {
- Target* puck = i->second;
- if (!puck->visible) {
- puck->visible = false;
- queue_draw ();
- }
- }
-}
-
-void
-Panner2d::show_target (int which)
-{
- Targets::iterator i = targets.find (which);
- if (i != targets.end()) {
- if (!i->second->visible) {
- i->second->visible = true;
- queue_draw ();
- }
- }
+ queue_draw ();
}
void
-Panner2d::hide_target (int which)
+Panner2d::move_puck (int which, const AngularVector& a)
{
- Targets::iterator i = targets.find (which);
- if (i != targets.end()) {
- if (i->second->visible) {
- i->second->visible = false;
- queue_draw ();
- }
+ if (which >= int (targets.size())) {
+ return;
}
+
+ targets[which]->position = a;
+ queue_draw ();
}
Panner2d::Target *
-Panner2d::find_closest_object (gdouble x, gdouble y, int& which, bool& is_puck) const
+Panner2d::find_closest_object (gdouble x, gdouble y, int& which) const
{
- gdouble efx, efy;
Target *closest = 0;
Target *candidate;
float distance;
float best_distance = FLT_MAX;
int pwhich;
- efx = x/width;
- efy = y/height;
which = 0;
pwhich = 0;
- is_puck = false;
- for (Targets::const_iterator i = targets.begin(); i != targets.end(); ++i, ++which) {
- candidate = i->second;
+ cerr << "@ " << x << ", " << y << endl;
- distance = sqrt ((candidate->x - efx) * (candidate->x - efx) +
- (candidate->y - efy) * (candidate->y - efy));
+ for (Targets::const_iterator i = pucks.begin(); i != pucks.end(); ++i, ++pwhich) {
+ candidate = *i;
- if (distance < best_distance) {
- closest = candidate;
- best_distance = distance;
- }
- }
+ CartesianVector c;
- for (Targets::const_iterator i = pucks.begin(); i != pucks.end(); ++i, ++pwhich) {
- candidate = i->second;
+ candidate->position.cartesian (c);
+ cart_to_gtk (c);
+
+ distance = sqrt ((c.x - x) * (c.x - x) +
+ (c.y - y) * (c.y - y));
- distance = sqrt ((candidate->x - efx) * (candidate->x - efx) +
- (candidate->y - efy) * (candidate->y - efy));
+ cerr << "\tConsider candiate " << candidate->text << " @ " << c.x << ", " << c.y << ", " << c.z << " distance = " << distance << endl;
if (distance < best_distance) {
closest = candidate;
best_distance = distance;
- is_puck = true;
which = pwhich;
}
}
-
+
+
+ if (best_distance > 20) { // arbitrary
+ return 0;
+ }
+
+ cerr << "the winner is " << closest->text << endl;
+
return closest;
-}
+}
bool
Panner2d::on_motion_notify_event (GdkEventMotion *ev)
y = (int) floor (ev->y);
state = (GdkModifierType) ev->state;
}
+
return handle_motion (x, y, state);
}
-gint
-Panner2d::handle_motion (gint evx, gint evy, GdkModifierType state)
+bool
+Panner2d::on_expose_event (GdkEventExpose *event)
{
- if (drag_target == 0 || (state & GDK_BUTTON1_MASK) == 0) {
- return FALSE;
- }
+ gint x, y;
+ cairo_t* cr;
- int x, y;
- bool need_move = false;
+ cr = gdk_cairo_create (get_window()->gobj());
- if (!drag_is_puck && !allow_target) {
- return TRUE;
- }
+ cairo_set_line_width (cr, 1.0);
- if (allow_x || !drag_is_puck) {
- float new_x;
- x = min (evx, width - 1);
- x = max (x, 0);
- new_x = (float) x / (width - 1);
- if (new_x != drag_target->x) {
- drag_target->x = new_x;
- need_move = true;
- }
+ cairo_rectangle (cr, event->area.x, event->area.y, event->area.width, event->area.height);
+ if (!panner->bypassed()) {
+ cairo_set_source_rgba (cr, 0.1, 0.1, 0.1, 1.0);
+ } else {
+ cairo_set_source_rgba (cr, 0.1, 0.1, 0.1, 0.2);
}
+ cairo_fill_preserve (cr);
+ cairo_clip (cr);
- if (allow_y || drag_is_puck) {
- float new_y;
- y = min (evy, height - 1);
- y = max (y, 0);
- new_y = (float) y / (height - 1);
- if (new_y != drag_target->y) {
- drag_target->y = new_y;
- need_move = true;
- }
+ if (height > 100) {
+ cairo_translate (cr, 10.0, 10.0);
}
- if (need_move) {
- queue_draw ();
+ /* horizontal line of "crosshairs" */
- if (drag_is_puck) {
-
- panner[drag_index]->set_position (drag_target->x, drag_target->y);
+ cairo_set_source_rgb (cr, 0.0, 0.1, 0.7);
+ cairo_move_to (cr, 0.5, height/2.0+0.5);
+ cairo_line_to (cr, width+0.5, height/2+0.5);
+ cairo_stroke (cr);
- } else {
+ /* vertical line of "crosshairs" */
- TargetMoved (drag_index);
- }
- }
+ cairo_move_to (cr, width/2+0.5, 0.5);
+ cairo_line_to (cr, width/2+0.5, height+0.5);
+ cairo_stroke (cr);
- return TRUE;
-}
+ /* the circle on which signals live */
-bool
-Panner2d::on_expose_event (GdkEventExpose *event)
-{
- gint x, y;
- float fx, fy;
+ cairo_arc (cr, width/2, height/2, height/2, 0, 2.0 * M_PI);
+ cairo_stroke (cr);
- /* redraw the background */
+ if (!panner->bypassed()) {
+ float arc_radius;
- get_window()->draw_rectangle (get_style()->get_bg_gc(get_state()),
- true,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-
+ cairo_select_font_face (cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
- if (!panner.bypassed()) {
+ if (height < 100) {
+ cairo_set_font_size (cr, 10);
+ arc_radius = 2.0;
+ } else {
+ cairo_set_font_size (cr, 16);
+ arc_radius = 4.0;
+ }
for (Targets::iterator i = pucks.begin(); i != pucks.end(); ++i) {
- Target* puck = i->second;
- Pango::Layout layout = new Pango::Layout(get_window()->create_pango_layout());
+ Target* puck = *i;
if (puck->visible) {
/* redraw puck */
-
- fx = min (puck->x, 1.0f);
- fx = max (fx, -1.0f);
- x = (gint) floor (width * fx - 4);
-
- fy = min (puck->y, 1.0f);
- fy = max (fy, -1.0f);
- y = (gint) floor (height * fy - 4);
-
- get_window()->draw_arc (get_style()->get_fg_gc(Gtk::STATE_NORMAL),
- true,
- x, y,
- 8, 8,
- 0, 360 * 64);
- layout.set_text(puck->text);
- //get_window()->draw_text (get_style()->get_font(),
- // get_style()->get_fg_gc(Gtk::STATE_NORMAL),
- // x + 6, y + 6,
- // puck->text,
- // puck->textlen);
- // GTK2FIX : needs a pango layout
+
+ CartesianVector c;
+
+ puck->position.cartesian (c);
+ cart_to_gtk (c);
+
+ x = (gint) floor (c.x);
+ y = (gint) floor (c.y);
+
+ /* XXX need to shift circles so that they are centered on the circle */
+
+ cairo_arc (cr, x, y, arc_radius, 0, 2.0 * M_PI);
+ cairo_set_source_rgb (cr, 0.8, 0.2, 0.1);
+ cairo_close_path (cr);
+ cairo_fill (cr);
+
+ cairo_move_to (cr, x + 6, y + 6);
+
+ char buf[256];
+ snprintf (buf, sizeof (buf), "%s:%d", puck->text.c_str(), (int) lrint (puck->position.azi));
+ cairo_show_text (cr, buf);
}
}
/* redraw any visible targets */
+ int n = 0;
+
for (Targets::iterator i = targets.begin(); i != targets.end(); ++i) {
- Target *target = i->second;
+ Target *target = *i;
+ char buf[256];
+ ++n;
if (target->visible) {
-
- /* why -8 ??? why is this necessary ? */
-
- fx = min (target->x, 1.0f);
- fx = max (fx, -1.0f);
- x = (gint) floor ((width - 8) * fx);
-
- fy = min (target->y, 1.0f);
- fy = max (fy, -1.0f);
- y = (gint) floor ((height - 8) * fy);
-
- get_window()->draw_rectangle (get_style()->get_fg_gc(Gtk::STATE_ACTIVE),
- true,
- x, y,
- 4, 4);
+
+ CartesianVector c;
+
+ target->position.cartesian (c);
+ cart_to_gtk (c);
+
+ x = (int) floor (c.x);
+ y = (int) floor (c.y);
+
+ snprintf (buf, sizeof (buf), "%d", n);
+
+ cairo_set_source_rgb (cr, 0.0, 0.8, 0.1);
+ cairo_rectangle (cr, x-2, y-2, 4, 4);
+ cairo_fill (cr);
+ cairo_move_to (cr, x+6, y+6);
+ cairo_show_text (cr, buf);
+
}
}
}
+ cairo_destroy (cr);
+
return TRUE;
}
bool
Panner2d::on_button_press_event (GdkEventButton *ev)
{
+ GdkModifierType state;
+
+ if (ev->type == GDK_2BUTTON_PRESS && ev->button == 1) {
+ return false;
+ }
+
switch (ev->button) {
case 1:
- gint x, y;
- GdkModifierType state;
+ case 2:
+ if ((drag_target = find_closest_object (ev->x, ev->y, drag_index)) != 0) {
+ drag_target->set_selected (true);
+ }
- drag_target = find_closest_object (ev->x, ev->y, drag_index, drag_is_puck);
-
- x = (int) floor (ev->x);
- y = (int) floor (ev->y);
+ drag_x = (int) floor (ev->x);
+ drag_y = (int) floor (ev->y);
state = (GdkModifierType) ev->state;
- return handle_motion (x, y, state);
+ return handle_motion (drag_x, drag_y, state);
break;
+
default:
break;
}
-
+
return FALSE;
}
bool
Panner2d::on_button_release_event (GdkEventButton *ev)
{
+ gint x, y;
+ GdkModifierType state;
+ bool ret = false;
+
switch (ev->button) {
case 1:
- gint x, y;
- int ret;
- GdkModifierType state;
-
x = (int) floor (ev->x);
y = (int) floor (ev->y);
state = (GdkModifierType) ev->state;
- if (drag_is_puck && (Keyboard::modifier_state_contains (state, Keyboard::Shift))) {
-
+ if (Keyboard::modifier_state_contains (state, Keyboard::TertiaryModifier)) {
+
for (Targets::iterator i = pucks.begin(); i != pucks.end(); ++i) {
- Target* puck = i->second;
- puck->x = 0.5;
- puck->y = 0.5;
+ //Target* puck = i->second;
+ /* XXX DO SOMETHING TO SET PUCK BACK TO "normal" */
}
queue_draw ();
PuckMoved (-1);
- ret = TRUE;
+ ret = true;
} else {
ret = handle_motion (x, y, state);
}
-
- drag_target = 0;
- return ret;
+ drag_target = 0;
break;
+
case 2:
- toggle_bypass ();
- return TRUE;
+ x = (int) floor (ev->x);
+ y = (int) floor (ev->y);
+ state = (GdkModifierType) ev->state;
+
+ if (Keyboard::modifier_state_contains (state, Keyboard::TertiaryModifier)) {
+ toggle_bypass ();
+ ret = true;
+ } else {
+ ret = handle_motion (x, y, state);
+ }
+
+ drag_target = 0;
+ break;
case 3:
- show_context_menu ();
break;
}
- return FALSE;
+ return ret;
}
-void
-Panner2d::toggle_bypass ()
+gint
+Panner2d::handle_motion (gint evx, gint evy, GdkModifierType state)
{
- if (bypass_menu_item && (panner.bypassed() != bypass_menu_item->get_active())) {
- panner.set_bypassed (!panner.bypassed());
+ if (drag_target == 0) {
+ return false;
}
+
+ if ((state & (GDK_BUTTON1_MASK|GDK_BUTTON2_MASK)) == 0) {
+ return false;
+ }
+
+
+ if (state & GDK_BUTTON1_MASK && !(state & GDK_BUTTON2_MASK)) {
+
+ CartesianVector c;
+ bool need_move = false;
+
+ drag_target->position.cartesian (c);
+ cart_to_gtk (c);
+
+ if ((evx != c.x) || (evy != c.y)) {
+ need_move = true;
+ }
+
+ if (need_move) {
+ CartesianVector cp (evx, evy, 0.0);
+
+ /* canonicalize position */
+
+ gtk_to_cart (cp);
+
+ /* position actual signal on circle */
+
+ clamp_to_circle (cp.x, cp.y);
+
+ /* generate an angular representation and set drag target (GUI) position */
+
+ cp.angular (drag_target->position); /* sets drag target position */
+
+ panner->streampanner (drag_index).set_position (drag_target->position);
+
+ queue_draw ();
+ }
+ }
+
+ return true;
}
void
-Panner2d::show_context_menu ()
+Panner2d::cart_to_gtk (CartesianVector& c) const
{
- using namespace Menu_Helpers;
+ /* "c" uses a coordinate space that is:
+
+ center = 0.0
+ dimension = 2.0 * 2.0
+ so max values along each axis are -1..+1
- if (context_menu == 0) {
- context_menu = manage (new Menu);
- context_menu->set_name ("ArdourContextMenu");
- MenuList& items = context_menu->items();
+ GTK uses a coordinate space that is:
- items.push_back (CheckMenuElem (_("Bypass")));
- bypass_menu_item = static_cast<CheckMenuItem*> (&items.back());
- bypass_menu_item->signal_toggled().connect (mem_fun(*this, &Panner2d::toggle_bypass));
+ top left = 0.0
+ dimension = width * height
+ so max values along each axis are 0,width and
+ 0,height
+ */
- }
+ c.x = (width / 2) * (c.x + 1);
+ c.y = (height / 2) * (1 - c.y);
- bypass_menu_item->set_active (panner.bypassed());
- context_menu->popup (1, 0);
+ /* XXX z-axis not handled - 2D for now */
}
void
-Panner2d::allow_x_motion (bool yn)
+Panner2d::gtk_to_cart (CartesianVector& c) const
{
- allow_x = yn;
+ c.x = (c.x / (width / 2.0)) - 1.0;
+ c.y = -((c.y / (height / 2.0)) - 1.0);
+
+ /* XXX z-axis not handled - 2D for now */
}
void
-Panner2d::allow_target_motion (bool yn)
+Panner2d::clamp_to_circle (double& x, double& y)
{
- allow_target = yn;
+ double azi, ele;
+ double z = 0.0;
+
+ PBD::cart_to_azi_ele (x, y, z, azi, ele);
+ PBD::azi_ele_to_cart (azi, ele, x, y, z);
}
void
-Panner2d::allow_y_motion (bool yn)
+Panner2d::toggle_bypass ()
{
- allow_y = yn;
+ panner->set_bypassed (!panner->bypassed());
}
-int
-Panner2d::puck_position (int which, float& x, float& y)
+Panner2dWindow::Panner2dWindow (boost::shared_ptr<Panner> p, int32_t h, uint32_t inputs)
+ : widget (p, h)
+ , reset_button (_("Reset"))
+ , bypass_button (_("Bypass"))
+ , mute_button (_("Mute"))
{
- Targets::iterator i;
-
- if ((i = pucks.find (which)) != pucks.end()) {
- x = i->second->x;
- y = i->second->y;
- return 0;
- }
-
- return -1;
+ widget.set_name ("MixerPanZone");
+
+ set_title (_("Panner"));
+ widget.set_size_request (h, h);
+
+ button_box.set_spacing (6);
+ button_box.pack_start (reset_button, false, false);
+ button_box.pack_start (bypass_button, false, false);
+ button_box.pack_start (mute_button, false, false);
+
+ spinner_box.set_spacing (6);
+ left_side.set_spacing (6);
+
+ left_side.pack_start (button_box, false, false);
+ left_side.pack_start (spinner_box, false, false);
+
+ reset_button.show ();
+ bypass_button.show ();
+ mute_button.show ();
+ button_box.show ();
+ spinner_box.show ();
+ left_side.show ();
+
+ hpacker.set_spacing (6);
+ hpacker.set_border_width (12);
+ hpacker.pack_start (widget, false, false);
+ hpacker.pack_start (left_side, false, false);
+ hpacker.show ();
+
+ add (hpacker);
+ reset (inputs);
+ widget.show ();
}
-int
-Panner2d::target_position (int which, float& x, float& y)
+void
+Panner2dWindow::reset (uint32_t n_inputs)
{
- Targets::iterator i;
-
- if ((i = targets.find (which)) != targets.end()) {
- x = i->second->x;
- y = i->second->y;
- return 0;
+ widget.reset (n_inputs);
+
+#if 0
+ while (spinners.size() < n_inputs) {
+ // spinners.push_back (new Gtk::SpinButton (widget.azimuth (spinners.size())));
+ //spinner_box.pack_start (*spinners.back(), false, false);
+ //spinners.back()->set_digits (4);
+ spinners.back()->show ();
}
- return -1;
+ while (spinners.size() > n_inputs) {
+ spinner_box.remove (*spinners.back());
+ delete spinners.back();
+ spinners.erase (--spinners.end());
+ }
+#endif
}
-