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 <gtkmm/menu.h>
+#include <gtkmm/checkmenuitem.h>
+
#include <pbd/error.h>
#include <ardour/panner.h>
-#include <gtkmmext/gtk_ui.h>
+#include <gtkmm2ext/gtk_ui.h>
#include "panner2d.h"
#include "keyboard.h"
using namespace std;
using namespace Gtk;
-using namespace SigC;
+using namespace sigc;
using namespace ARDOUR;
+using namespace PBD;
Panner2d::Target::Target (float xa, float ya, const char *txt)
: x (xa), y (ya), text (txt ? strdup (txt) : 0)
}
}
-Panner2d::Panner2d (Panner& p, int32_t w, int32_t h)
- : panner (p), width (w), height (h)
+Panner2d::Panner2d (Panner& p, int32_t h)
+ : panner (p), width (0), height (h)
{
context_menu = 0;
bypass_menu_item = 0;
allow_y = false;
allow_target = false;
- panner.StateChanged.connect (slot (*this, &Panner2d::handle_state_change));
+ 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);
+ set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
}
}
void
-Panner2d::size_allocate_impl (GtkAllocation *alloc)
+Panner2d::on_size_allocate (Gtk::Allocation& alloc)
{
- width = alloc->width;
- height = alloc->height;
+ width = alloc.get_width();
+ height = alloc.get_height();
- DrawingArea::size_allocate_impl (alloc);
+ DrawingArea::on_size_allocate (alloc);
}
int
void
Panner2d::handle_state_change ()
{
- ENSURE_GUI_THREAD(slot (*this, &Panner2d::handle_state_change));
+ ENSURE_GUI_THREAD(mem_fun(*this, &Panner2d::handle_state_change));
queue_draw ();
}
return closest;
}
-gint
-Panner2d::motion_notify_event_impl (GdkEventMotion *ev)
+bool
+Panner2d::on_motion_notify_event (GdkEventMotion *ev)
{
gint x, y;
GdkModifierType state;
return TRUE;
}
-gint
-Panner2d::expose_event_impl (GdkEventExpose *event)
+bool
+Panner2d::on_expose_event (GdkEventExpose *event)
{
gint x, y;
float fx, fy;
+ if (layout == 0) {
+ layout = create_pango_layout ("");
+ layout->set_font_description (get_style()->get_font());
+ }
+
/* redraw the background */
- get_window().draw_rectangle (get_style()->get_bg_gc(get_state()),
+ get_window()->draw_rectangle (get_style()->get_bg_gc(get_state()),
true,
event->area.x, event->area.y,
event->area.width, event->area.height);
fy = max (fy, -1.0f);
y = (gint) floor (height * fy - 4);
- get_window().draw_arc (get_style()->get_fg_gc(GTK_STATE_NORMAL),
+ get_window()->draw_arc (get_style()->get_fg_gc(Gtk::STATE_NORMAL),
true,
x, y,
8, 8,
0, 360 * 64);
- get_window().draw_text (get_style()->get_font(),
- get_style()->get_fg_gc(GTK_STATE_NORMAL),
- x + 6, y + 6,
- puck->text,
- puck->textlen);
+
+ layout->set_text (puck->text);
+
+ get_window()->draw_layout (get_style()->get_fg_gc (STATE_NORMAL), x+6, y+6, layout);
}
}
fy = max (fy, -1.0f);
y = (gint) floor ((height - 8) * fy);
- get_window().draw_rectangle (get_style()->get_fg_gc(GTK_STATE_ACTIVE),
+ get_window()->draw_rectangle (get_style()->get_fg_gc(Gtk::STATE_ACTIVE),
true,
x, y,
4, 4);
return TRUE;
}
-gint
-Panner2d::button_press_event_impl (GdkEventButton *ev)
+bool
+Panner2d::on_button_press_event (GdkEventButton *ev)
{
switch (ev->button) {
case 1:
return FALSE;
}
-gint
-Panner2d::button_release_event_impl (GdkEventButton *ev)
+bool
+Panner2d::on_button_release_event (GdkEventButton *ev)
{
switch (ev->button) {
case 1:
MenuList& items = context_menu->items();
items.push_back (CheckMenuElem (_("Bypass")));
- bypass_menu_item = static_cast<CheckMenuItem*> (items.back());
- bypass_menu_item->toggled.connect (slot (*this, &Panner2d::toggle_bypass));
+ bypass_menu_item = static_cast<CheckMenuItem*> (&items.back());
+ bypass_menu_item->signal_toggled().connect (mem_fun(*this, &Panner2d::toggle_bypass));
}
bypass_menu_item->set_active (panner.bypassed());
- context_menu->popup (1, 0);
+ context_menu->popup (1, gtk_get_current_event_time());
}
void