mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
Factor out 'persistent' tooltip code from the panner
interface and use it for processor box sliders (#4461). git-svn-id: svn://localhost/ardour2/branches/3.0@12661 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
366b7ac36b
commit
f4ed14a83b
13 changed files with 318 additions and 96 deletions
|
|
@ -31,6 +31,7 @@
|
||||||
#include "gtkmm2ext/gtk_ui.h"
|
#include "gtkmm2ext/gtk_ui.h"
|
||||||
#include "gtkmm2ext/keyboard.h"
|
#include "gtkmm2ext/keyboard.h"
|
||||||
#include "gtkmm2ext/utils.h"
|
#include "gtkmm2ext/utils.h"
|
||||||
|
#include "gtkmm2ext/persistent_tooltip.h"
|
||||||
|
|
||||||
#include "ardour/pannable.h"
|
#include "ardour/pannable.h"
|
||||||
#include "ardour/panner.h"
|
#include "ardour/panner.h"
|
||||||
|
|
@ -64,6 +65,7 @@ MonoPanner::MonoPanner (boost::shared_ptr<ARDOUR::Panner> panner)
|
||||||
, accumulated_delta (0)
|
, accumulated_delta (0)
|
||||||
, detented (false)
|
, detented (false)
|
||||||
, position_binder (position_control)
|
, position_binder (position_control)
|
||||||
|
, _dragging (false)
|
||||||
{
|
{
|
||||||
if (!have_colors) {
|
if (!have_colors) {
|
||||||
set_colors ();
|
set_colors ();
|
||||||
|
|
@ -73,6 +75,8 @@ MonoPanner::MonoPanner (boost::shared_ptr<ARDOUR::Panner> panner)
|
||||||
position_control->Changed.connect (connections, invalidator(*this), boost::bind (&MonoPanner::value_change, this), gui_context());
|
position_control->Changed.connect (connections, invalidator(*this), boost::bind (&MonoPanner::value_change, this), gui_context());
|
||||||
|
|
||||||
ColorsChanged.connect (sigc::mem_fun (*this, &MonoPanner::color_handler));
|
ColorsChanged.connect (sigc::mem_fun (*this, &MonoPanner::color_handler));
|
||||||
|
|
||||||
|
set_tooltip ();
|
||||||
}
|
}
|
||||||
|
|
||||||
MonoPanner::~MonoPanner ()
|
MonoPanner::~MonoPanner ()
|
||||||
|
|
@ -81,12 +85,8 @@ MonoPanner::~MonoPanner ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MonoPanner::set_drag_data ()
|
MonoPanner::set_tooltip ()
|
||||||
{
|
{
|
||||||
if (!_drag_data_label) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
double pos = position_control->get_value(); // 0..1
|
double pos = position_control->get_value(); // 0..1
|
||||||
|
|
||||||
/* We show the position of the center of the image relative to the left & right.
|
/* We show the position of the center of the image relative to the left & right.
|
||||||
|
|
@ -101,7 +101,7 @@ MonoPanner::set_drag_data ()
|
||||||
snprintf (buf, sizeof (buf), "L:%3d R:%3d",
|
snprintf (buf, sizeof (buf), "L:%3d R:%3d",
|
||||||
(int) rint (100.0 * (1.0 - pos)),
|
(int) rint (100.0 * (1.0 - pos)),
|
||||||
(int) rint (100.0 * pos));
|
(int) rint (100.0 * pos));
|
||||||
_drag_data_label->set_markup (buf);
|
_tooltip.set_tip (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -255,6 +255,7 @@ MonoPanner::on_button_press_event (GdkEventButton* ev)
|
||||||
last_drag_x = ev->x;
|
last_drag_x = ev->x;
|
||||||
|
|
||||||
_dragging = false;
|
_dragging = false;
|
||||||
|
_tooltip.target_stop_drag ();
|
||||||
accumulated_delta = 0;
|
accumulated_delta = 0;
|
||||||
detented = false;
|
detented = false;
|
||||||
|
|
||||||
|
|
@ -290,6 +291,7 @@ MonoPanner::on_button_press_event (GdkEventButton* ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
_dragging = false;
|
_dragging = false;
|
||||||
|
_tooltip.target_stop_drag ();
|
||||||
|
|
||||||
} else if (ev->type == GDK_BUTTON_PRESS) {
|
} else if (ev->type == GDK_BUTTON_PRESS) {
|
||||||
|
|
||||||
|
|
@ -299,8 +301,8 @@ MonoPanner::on_button_press_event (GdkEventButton* ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
_dragging = true;
|
_dragging = true;
|
||||||
|
_tooltip.target_start_drag ();
|
||||||
StartGesture ();
|
StartGesture ();
|
||||||
show_drag_data_window ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -318,11 +320,10 @@ MonoPanner::on_button_release_event (GdkEventButton* ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
_dragging = false;
|
_dragging = false;
|
||||||
|
_tooltip.target_stop_drag ();
|
||||||
accumulated_delta = 0;
|
accumulated_delta = 0;
|
||||||
detented = false;
|
detented = false;
|
||||||
|
|
||||||
hide_drag_data_window ();
|
|
||||||
|
|
||||||
if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
|
if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
|
||||||
_panner->reset ();
|
_panner->reset ();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class MonoPanner : public PannerInterface
|
||||||
|
|
||||||
BindingProxy position_binder;
|
BindingProxy position_binder;
|
||||||
|
|
||||||
void set_drag_data ();
|
void set_tooltip ();
|
||||||
|
|
||||||
struct ColorScheme {
|
struct ColorScheme {
|
||||||
uint32_t outline;
|
uint32_t outline;
|
||||||
|
|
@ -74,6 +74,8 @@ class MonoPanner : public PannerInterface
|
||||||
uint32_t pos_fill;
|
uint32_t pos_fill;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool _dragging;
|
||||||
|
|
||||||
static ColorScheme colors;
|
static ColorScheme colors;
|
||||||
static void set_colors ();
|
static void set_colors ();
|
||||||
static bool have_colors;
|
static bool have_colors;
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
#include "gtkmm2ext/keyboard.h"
|
#include "gtkmm2ext/keyboard.h"
|
||||||
|
#include "gtkmm2ext/persistent_tooltip.h"
|
||||||
#include "panner_interface.h"
|
#include "panner_interface.h"
|
||||||
#include "panner_editor.h"
|
#include "panner_editor.h"
|
||||||
#include "global_signals.h"
|
#include "global_signals.h"
|
||||||
|
|
@ -32,9 +33,7 @@ using namespace Gtkmm2ext;
|
||||||
|
|
||||||
PannerInterface::PannerInterface (boost::shared_ptr<Panner> p)
|
PannerInterface::PannerInterface (boost::shared_ptr<Panner> p)
|
||||||
: _panner (p)
|
: _panner (p)
|
||||||
, _drag_data_window (0)
|
, _tooltip (this)
|
||||||
, _drag_data_label (0)
|
|
||||||
, _dragging (false)
|
|
||||||
, _editor (0)
|
, _editor (0)
|
||||||
{
|
{
|
||||||
set_flags (Gtk::CAN_FOCUS);
|
set_flags (Gtk::CAN_FOCUS);
|
||||||
|
|
@ -49,66 +48,14 @@ PannerInterface::PannerInterface (boost::shared_ptr<Panner> p)
|
||||||
|
|
||||||
PannerInterface::~PannerInterface ()
|
PannerInterface::~PannerInterface ()
|
||||||
{
|
{
|
||||||
delete _drag_data_window;
|
|
||||||
delete _editor;
|
delete _editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
PannerInterface::show_drag_data_window ()
|
|
||||||
{
|
|
||||||
if (!_drag_data_window) {
|
|
||||||
_drag_data_window = new Window (WINDOW_POPUP);
|
|
||||||
_drag_data_window->set_name (X_("ContrastingPopup"));
|
|
||||||
_drag_data_window->set_position (WIN_POS_MOUSE);
|
|
||||||
_drag_data_window->set_decorated (false);
|
|
||||||
|
|
||||||
_drag_data_label = manage (new Label);
|
|
||||||
_drag_data_label->set_use_markup (true);
|
|
||||||
|
|
||||||
_drag_data_window->set_border_width (6);
|
|
||||||
_drag_data_window->add (*_drag_data_label);
|
|
||||||
_drag_data_label->show ();
|
|
||||||
|
|
||||||
Window* toplevel = dynamic_cast<Window*> (get_toplevel());
|
|
||||||
if (toplevel) {
|
|
||||||
_drag_data_window->set_transient_for (*toplevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
set_drag_data ();
|
|
||||||
|
|
||||||
if (!_drag_data_window->is_visible ()) {
|
|
||||||
/* move the window a little away from the mouse */
|
|
||||||
int rx, ry;
|
|
||||||
get_window()->get_origin (rx, ry);
|
|
||||||
_drag_data_window->move (rx, ry + get_height());
|
|
||||||
_drag_data_window->present ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PannerInterface::hide_drag_data_window ()
|
|
||||||
{
|
|
||||||
if (_drag_data_window) {
|
|
||||||
_drag_data_window->hide ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
PannerInterface::on_enter_notify_event (GdkEventCrossing *)
|
PannerInterface::on_enter_notify_event (GdkEventCrossing *)
|
||||||
{
|
{
|
||||||
grab_focus ();
|
grab_focus ();
|
||||||
Keyboard::magic_widget_grab_focus ();
|
Keyboard::magic_widget_grab_focus ();
|
||||||
|
|
||||||
_drag_data_timeout = Glib::signal_timeout().connect (sigc::mem_fun (*this, &PannerInterface::drag_data_timeout), 500);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
PannerInterface::drag_data_timeout ()
|
|
||||||
{
|
|
||||||
show_drag_data_window ();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,12 +63,6 @@ bool
|
||||||
PannerInterface::on_leave_notify_event (GdkEventCrossing *)
|
PannerInterface::on_leave_notify_event (GdkEventCrossing *)
|
||||||
{
|
{
|
||||||
Keyboard::magic_widget_drop_focus ();
|
Keyboard::magic_widget_drop_focus ();
|
||||||
|
|
||||||
_drag_data_timeout.disconnect ();
|
|
||||||
if (!_dragging) {
|
|
||||||
hide_drag_data_window ();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,7 +75,7 @@ PannerInterface::on_key_release_event (GdkEventKey*)
|
||||||
void
|
void
|
||||||
PannerInterface::value_change ()
|
PannerInterface::value_change ()
|
||||||
{
|
{
|
||||||
set_drag_data ();
|
set_tooltip ();
|
||||||
queue_draw ();
|
queue_draw ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,3 +108,28 @@ PannerInterface::edit ()
|
||||||
_editor = editor ();
|
_editor = editor ();
|
||||||
_editor->show ();
|
_editor->show ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PannerPersistentTooltip::PannerPersistentTooltip (Gtk::Widget* w)
|
||||||
|
: PersistentTooltip (w)
|
||||||
|
, _dragging (false)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PannerPersistentTooltip::target_start_drag ()
|
||||||
|
{
|
||||||
|
_dragging = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PannerPersistentTooltip::target_stop_drag ()
|
||||||
|
{
|
||||||
|
_dragging = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PannerPersistentTooltip::dragging () const
|
||||||
|
{
|
||||||
|
return _dragging;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <gtkmm/drawingarea.h>
|
#include <gtkmm/drawingarea.h>
|
||||||
#include <gtkmm/label.h>
|
#include <gtkmm/label.h>
|
||||||
|
#include "gtkmm2ext/persistent_tooltip.h"
|
||||||
#include "pbd/destructible.h"
|
#include "pbd/destructible.h"
|
||||||
|
|
||||||
namespace ARDOUR {
|
namespace ARDOUR {
|
||||||
|
|
@ -31,6 +32,21 @@ namespace ARDOUR {
|
||||||
|
|
||||||
class PannerEditor;
|
class PannerEditor;
|
||||||
|
|
||||||
|
class PannerPersistentTooltip : public Gtkmm2ext::PersistentTooltip
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PannerPersistentTooltip (Gtk::Widget* w);
|
||||||
|
|
||||||
|
void target_start_drag ();
|
||||||
|
void target_stop_drag ();
|
||||||
|
|
||||||
|
bool dragging () const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _dragging;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Parent class for some panner UI classes that contains some common code */
|
/** Parent class for some panner UI classes that contains some common code */
|
||||||
class PannerInterface : public Gtk::DrawingArea, public PBD::Destructible
|
class PannerInterface : public Gtk::DrawingArea, public PBD::Destructible
|
||||||
{
|
{
|
||||||
|
|
@ -45,10 +61,8 @@ public:
|
||||||
void edit ();
|
void edit ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void set_drag_data () = 0;
|
virtual void set_tooltip () = 0;
|
||||||
|
|
||||||
void show_drag_data_window ();
|
|
||||||
void hide_drag_data_window ();
|
|
||||||
void value_change ();
|
void value_change ();
|
||||||
|
|
||||||
bool on_enter_notify_event (GdkEventCrossing *);
|
bool on_enter_notify_event (GdkEventCrossing *);
|
||||||
|
|
@ -58,14 +72,9 @@ protected:
|
||||||
bool on_button_release_event (GdkEventButton*);
|
bool on_button_release_event (GdkEventButton*);
|
||||||
|
|
||||||
boost::shared_ptr<ARDOUR::Panner> _panner;
|
boost::shared_ptr<ARDOUR::Panner> _panner;
|
||||||
Gtk::Window* _drag_data_window;
|
PannerPersistentTooltip _tooltip;
|
||||||
Gtk::Label* _drag_data_label;
|
|
||||||
bool _dragging;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool drag_data_timeout ();
|
|
||||||
sigc::connection _drag_data_timeout;
|
|
||||||
|
|
||||||
virtual PannerEditor* editor () = 0;
|
virtual PannerEditor* editor () = 0;
|
||||||
PannerEditor* _editor;
|
PannerEditor* _editor;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -411,6 +411,7 @@ ProcessorEntry::Control::Control (Glib::RefPtr<Gdk::Pixbuf> s, Glib::RefPtr<Gdk:
|
||||||
: _control (c)
|
: _control (c)
|
||||||
, _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
|
, _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1)
|
||||||
, _slider (s, sd, &_adjustment, 0, false)
|
, _slider (s, sd, &_adjustment, 0, false)
|
||||||
|
, _slider_persistant_tooltip (&_slider)
|
||||||
, _button (ArdourButton::Element (ArdourButton::Text | ArdourButton::Indicator))
|
, _button (ArdourButton::Element (ArdourButton::Text | ArdourButton::Indicator))
|
||||||
, _ignore_ui_adjustment (false)
|
, _ignore_ui_adjustment (false)
|
||||||
, _visible (false)
|
, _visible (false)
|
||||||
|
|
@ -454,6 +455,9 @@ ProcessorEntry::Control::Control (Glib::RefPtr<Gdk::Pixbuf> s, Glib::RefPtr<Gdk:
|
||||||
|
|
||||||
control_changed ();
|
control_changed ();
|
||||||
set_tooltip ();
|
set_tooltip ();
|
||||||
|
|
||||||
|
/* We're providing our own PersistentTooltip */
|
||||||
|
set_no_tooltip_whatsoever (_slider);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -470,11 +474,13 @@ ProcessorEntry::Control::set_tooltip ()
|
||||||
if (c->toggled ()) {
|
if (c->toggled ()) {
|
||||||
s << (c->get_value() > 0.5 ? _("on") : _("off"));
|
s << (c->get_value() > 0.5 ? _("on") : _("off"));
|
||||||
} else {
|
} else {
|
||||||
s << c->internal_to_interface (c->get_value ());
|
s << setprecision(2) << fixed;
|
||||||
|
s << c->internal_to_user (c->get_value ());
|
||||||
}
|
}
|
||||||
|
|
||||||
ARDOUR_UI::instance()->set_tip (_label, s.str ());
|
ARDOUR_UI::instance()->set_tip (_label, s.str ());
|
||||||
ARDOUR_UI::instance()->set_tip (_slider, s.str ());
|
_slider_persistant_tooltip.set_tip (s.str ());
|
||||||
|
// ARDOUR_UI::instance()->set_tip (_slider, " ");
|
||||||
ARDOUR_UI::instance()->set_tip (_button, s.str ());
|
ARDOUR_UI::instance()->set_tip (_button, s.str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -498,6 +504,7 @@ ProcessorEntry::Control::slider_adjusted ()
|
||||||
}
|
}
|
||||||
|
|
||||||
c->set_value (c->interface_to_internal (_adjustment.get_value ()));
|
c->set_value (c->interface_to_internal (_adjustment.get_value ()));
|
||||||
|
set_tooltip ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -537,8 +544,6 @@ ProcessorEntry::Control::control_changed ()
|
||||||
s.precision (1);
|
s.precision (1);
|
||||||
s.setf (ios::fixed, ios::floatfield);
|
s.setf (ios::fixed, ios::floatfield);
|
||||||
s << c->internal_to_user (c->get_value ());
|
s << c->internal_to_user (c->get_value ());
|
||||||
|
|
||||||
_slider.set_tooltip_text (s.str ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ignore_ui_adjustment = false;
|
_ignore_ui_adjustment = false;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include "gtkmm2ext/click_box.h"
|
#include "gtkmm2ext/click_box.h"
|
||||||
#include "gtkmm2ext/dndvbox.h"
|
#include "gtkmm2ext/dndvbox.h"
|
||||||
#include "gtkmm2ext/pixfader.h"
|
#include "gtkmm2ext/pixfader.h"
|
||||||
|
#include "gtkmm2ext/persistent_tooltip.h"
|
||||||
|
|
||||||
#include "pbd/stateful.h"
|
#include "pbd/stateful.h"
|
||||||
#include "pbd/signals.h"
|
#include "pbd/signals.h"
|
||||||
|
|
@ -189,6 +190,7 @@ private:
|
||||||
Gtk::Adjustment _adjustment;
|
Gtk::Adjustment _adjustment;
|
||||||
Gtkmm2ext::HSliderController _slider;
|
Gtkmm2ext::HSliderController _slider;
|
||||||
Gtk::Label _label;
|
Gtk::Label _label;
|
||||||
|
Gtkmm2ext::PersistentTooltip _slider_persistant_tooltip;
|
||||||
/* things for a button */
|
/* things for a button */
|
||||||
ArdourButton _button;
|
ArdourButton _button;
|
||||||
bool _ignore_ui_adjustment;
|
bool _ignore_ui_adjustment;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include "gtkmm2ext/gtk_ui.h"
|
#include "gtkmm2ext/gtk_ui.h"
|
||||||
#include "gtkmm2ext/keyboard.h"
|
#include "gtkmm2ext/keyboard.h"
|
||||||
#include "gtkmm2ext/utils.h"
|
#include "gtkmm2ext/utils.h"
|
||||||
|
#include "gtkmm2ext/persistent_tooltip.h"
|
||||||
|
|
||||||
#include "ardour/pannable.h"
|
#include "ardour/pannable.h"
|
||||||
#include "ardour/panner.h"
|
#include "ardour/panner.h"
|
||||||
|
|
@ -70,6 +71,7 @@ StereoPanner::StereoPanner (boost::shared_ptr<Panner> panner)
|
||||||
, detented (false)
|
, detented (false)
|
||||||
, position_binder (position_control)
|
, position_binder (position_control)
|
||||||
, width_binder (width_control)
|
, width_binder (width_control)
|
||||||
|
, _dragging (false)
|
||||||
{
|
{
|
||||||
if (!have_colors) {
|
if (!have_colors) {
|
||||||
set_colors ();
|
set_colors ();
|
||||||
|
|
@ -80,6 +82,8 @@ StereoPanner::StereoPanner (boost::shared_ptr<Panner> panner)
|
||||||
width_control->Changed.connect (connections, invalidator(*this), boost::bind (&StereoPanner::value_change, this), gui_context());
|
width_control->Changed.connect (connections, invalidator(*this), boost::bind (&StereoPanner::value_change, this), gui_context());
|
||||||
|
|
||||||
ColorsChanged.connect (sigc::mem_fun (*this, &StereoPanner::color_handler));
|
ColorsChanged.connect (sigc::mem_fun (*this, &StereoPanner::color_handler));
|
||||||
|
|
||||||
|
set_tooltip ();
|
||||||
}
|
}
|
||||||
|
|
||||||
StereoPanner::~StereoPanner ()
|
StereoPanner::~StereoPanner ()
|
||||||
|
|
@ -88,12 +92,8 @@ StereoPanner::~StereoPanner ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
StereoPanner::set_drag_data ()
|
StereoPanner::set_tooltip ()
|
||||||
{
|
{
|
||||||
if (!_drag_data_label) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
double pos = position_control->get_value(); // 0..1
|
double pos = position_control->get_value(); // 0..1
|
||||||
|
|
||||||
/* We show the position of the center of the image relative to the left & right.
|
/* We show the position of the center of the image relative to the left & right.
|
||||||
|
|
@ -108,7 +108,7 @@ StereoPanner::set_drag_data ()
|
||||||
snprintf (buf, sizeof (buf), "L:%3d R:%3d Width:%d%%", (int) rint (100.0 * (1.0 - pos)),
|
snprintf (buf, sizeof (buf), "L:%3d R:%3d Width:%d%%", (int) rint (100.0 * (1.0 - pos)),
|
||||||
(int) rint (100.0 * pos),
|
(int) rint (100.0 * pos),
|
||||||
(int) floor (100.0 * width_control->get_value()));
|
(int) floor (100.0 * width_control->get_value()));
|
||||||
_drag_data_label->set_markup (buf);
|
_tooltip.set_tip (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -360,8 +360,6 @@ StereoPanner::on_button_press_event (GdkEventButton* ev)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
show_drag_data_window ();
|
|
||||||
|
|
||||||
if (ev->y < 20) {
|
if (ev->y < 20) {
|
||||||
/* top section of widget is for position drags */
|
/* top section of widget is for position drags */
|
||||||
dragging_position = true;
|
dragging_position = true;
|
||||||
|
|
@ -395,6 +393,7 @@ StereoPanner::on_button_press_event (GdkEventButton* ev)
|
||||||
}
|
}
|
||||||
|
|
||||||
_dragging = true;
|
_dragging = true;
|
||||||
|
_tooltip.target_start_drag ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -414,14 +413,13 @@ StereoPanner::on_button_release_event (GdkEventButton* ev)
|
||||||
bool const dp = dragging_position;
|
bool const dp = dragging_position;
|
||||||
|
|
||||||
_dragging = false;
|
_dragging = false;
|
||||||
|
_tooltip.target_stop_drag ();
|
||||||
dragging_position = false;
|
dragging_position = false;
|
||||||
dragging_left = false;
|
dragging_left = false;
|
||||||
dragging_right = false;
|
dragging_right = false;
|
||||||
accumulated_delta = 0;
|
accumulated_delta = 0;
|
||||||
detented = false;
|
detented = false;
|
||||||
|
|
||||||
hide_drag_data_window ();
|
|
||||||
|
|
||||||
if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
|
if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
|
||||||
_panner->reset ();
|
_panner->reset ();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class StereoPanner : public PannerInterface
|
||||||
BindingProxy position_binder;
|
BindingProxy position_binder;
|
||||||
BindingProxy width_binder;
|
BindingProxy width_binder;
|
||||||
|
|
||||||
void set_drag_data ();
|
void set_tooltip ();
|
||||||
|
|
||||||
struct ColorScheme {
|
struct ColorScheme {
|
||||||
uint32_t outline;
|
uint32_t outline;
|
||||||
|
|
@ -88,6 +88,8 @@ class StereoPanner : public PannerInterface
|
||||||
Inverted
|
Inverted
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool _dragging;
|
||||||
|
|
||||||
static ColorScheme colors[3];
|
static ColorScheme colors[3];
|
||||||
static void set_colors ();
|
static void set_colors ();
|
||||||
static bool have_colors;
|
static bool have_colors;
|
||||||
|
|
|
||||||
67
libs/gtkmm2ext/gtkmm2ext/persistent_tooltip.h
Normal file
67
libs/gtkmm2ext/gtkmm2ext/persistent_tooltip.h
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2012 Paul Davis
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef gtkmm2ext_persistent_tooltip_h
|
||||||
|
#define gtkmm2ext_persistent_tooltip_h
|
||||||
|
|
||||||
|
#include <sigc++/trackable.h>
|
||||||
|
|
||||||
|
namespace Gtkmm2ext {
|
||||||
|
|
||||||
|
/** A class which offers a tooltip-like window which can be made to
|
||||||
|
* stay open during a drag.
|
||||||
|
*/
|
||||||
|
class PersistentTooltip : public sigc::trackable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PersistentTooltip (Gtk::Widget *);
|
||||||
|
virtual ~PersistentTooltip ();
|
||||||
|
|
||||||
|
void set_tip (std::string);
|
||||||
|
|
||||||
|
virtual bool dragging () const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool timeout ();
|
||||||
|
void show ();
|
||||||
|
void hide ();
|
||||||
|
bool enter (GdkEventCrossing *);
|
||||||
|
bool leave (GdkEventCrossing *);
|
||||||
|
bool press (GdkEventButton *);
|
||||||
|
bool release (GdkEventButton *);
|
||||||
|
|
||||||
|
/** The widget that we are providing a tooltip for */
|
||||||
|
Gtk::Widget* _target;
|
||||||
|
/** Our window */
|
||||||
|
Gtk::Window* _window;
|
||||||
|
/** Our label */
|
||||||
|
Gtk::Label* _label;
|
||||||
|
/** true if we are `dragging', in the sense that button 1
|
||||||
|
is being held over _target.
|
||||||
|
*/
|
||||||
|
bool _maybe_dragging;
|
||||||
|
/** Connection to a timeout used to open the tooltip */
|
||||||
|
sigc::connection _timeout;
|
||||||
|
/** The tip text */
|
||||||
|
std::string _tip;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -108,6 +108,8 @@ namespace Gtkmm2ext {
|
||||||
void rounded_bottom_half_rectangle (cairo_t*, double x, double y, double w, double h, double r=10);
|
void rounded_bottom_half_rectangle (cairo_t*, double x, double y, double w, double h, double r=10);
|
||||||
|
|
||||||
Gtk::Label* left_aligned_label (std::string const &);
|
Gtk::Label* left_aligned_label (std::string const &);
|
||||||
|
|
||||||
|
void set_no_tooltip_whatsoever (Gtk::Widget &);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __gtkmm2ext_utils_h__ */
|
#endif /* __gtkmm2ext_utils_h__ */
|
||||||
|
|
|
||||||
148
libs/gtkmm2ext/persistent_tooltip.cc
Normal file
148
libs/gtkmm2ext/persistent_tooltip.cc
Normal file
|
|
@ -0,0 +1,148 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2012 Paul Davis
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtkmm/window.h>
|
||||||
|
#include <gtkmm/label.h>
|
||||||
|
#include "gtkmm2ext/persistent_tooltip.h"
|
||||||
|
|
||||||
|
#include "i18n.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace Gtk;
|
||||||
|
using namespace Gtkmm2ext;
|
||||||
|
|
||||||
|
/** @param target The widget to provide the tooltip for */
|
||||||
|
PersistentTooltip::PersistentTooltip (Gtk::Widget* target)
|
||||||
|
: _target (target)
|
||||||
|
, _window (0)
|
||||||
|
, _label (0)
|
||||||
|
, _maybe_dragging (false)
|
||||||
|
{
|
||||||
|
target->signal_enter_notify_event().connect (sigc::mem_fun (*this, &PersistentTooltip::enter), false);
|
||||||
|
target->signal_leave_notify_event().connect (sigc::mem_fun (*this, &PersistentTooltip::leave), false);
|
||||||
|
target->signal_button_press_event().connect (sigc::mem_fun (*this, &PersistentTooltip::press), false);
|
||||||
|
target->signal_button_release_event().connect (sigc::mem_fun (*this, &PersistentTooltip::release), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
PersistentTooltip::~PersistentTooltip ()
|
||||||
|
{
|
||||||
|
delete _window;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PersistentTooltip::enter (GdkEventCrossing *)
|
||||||
|
{
|
||||||
|
_timeout = Glib::signal_timeout().connect (sigc::mem_fun (*this, &PersistentTooltip::timeout), 500);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PersistentTooltip::timeout ()
|
||||||
|
{
|
||||||
|
show ();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PersistentTooltip::leave (GdkEventCrossing *)
|
||||||
|
{
|
||||||
|
_timeout.disconnect ();
|
||||||
|
if (!dragging ()) {
|
||||||
|
hide ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PersistentTooltip::press (GdkEventButton* ev)
|
||||||
|
{
|
||||||
|
if (ev->type == GDK_BUTTON_PRESS && ev->button == 1) {
|
||||||
|
_maybe_dragging = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PersistentTooltip::release (GdkEventButton* ev)
|
||||||
|
{
|
||||||
|
if (ev->type == GDK_BUTTON_RELEASE && ev->button == 1) {
|
||||||
|
_maybe_dragging = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PersistentTooltip::dragging () const
|
||||||
|
{
|
||||||
|
return _maybe_dragging;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PersistentTooltip::hide ()
|
||||||
|
{
|
||||||
|
if (_window) {
|
||||||
|
_window->hide ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PersistentTooltip::show ()
|
||||||
|
{
|
||||||
|
if (!_window) {
|
||||||
|
_window = new Window (WINDOW_POPUP);
|
||||||
|
_window->set_name (X_("ContrastingPopup"));
|
||||||
|
_window->set_position (WIN_POS_MOUSE);
|
||||||
|
_window->set_decorated (false);
|
||||||
|
|
||||||
|
_label = manage (new Label);
|
||||||
|
_label->set_use_markup (true);
|
||||||
|
|
||||||
|
_window->set_border_width (6);
|
||||||
|
_window->add (*_label);
|
||||||
|
_label->show ();
|
||||||
|
|
||||||
|
Gtk::Window* tlw = dynamic_cast<Gtk::Window*> (_target->get_toplevel ());
|
||||||
|
if (tlw) {
|
||||||
|
_window->set_transient_for (*tlw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set_tip (_tip);
|
||||||
|
|
||||||
|
if (!_window->is_visible ()) {
|
||||||
|
/* move the window a little away from the mouse */
|
||||||
|
int rx, ry;
|
||||||
|
_target->get_window()->get_origin (rx, ry);
|
||||||
|
_window->move (rx, ry + _target->get_height());
|
||||||
|
_window->present ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PersistentTooltip::set_tip (string t)
|
||||||
|
{
|
||||||
|
_tip = t;
|
||||||
|
|
||||||
|
if (_label) {
|
||||||
|
_label->set_markup (t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include <gtkmm/paned.h>
|
#include <gtkmm/paned.h>
|
||||||
#include <gtkmm/label.h>
|
#include <gtkmm/label.h>
|
||||||
#include <gtkmm/comboboxtext.h>
|
#include <gtkmm/comboboxtext.h>
|
||||||
|
#include <gtkmm/tooltip.h>
|
||||||
|
|
||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
|
|
||||||
|
|
@ -631,3 +632,21 @@ Gtkmm2ext::left_aligned_label (string const & t)
|
||||||
l->set_alignment (0, 0.5);
|
l->set_alignment (0, 0.5);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
make_null_tooltip (int, int, bool, const Glib::RefPtr<Gtk::Tooltip>& t)
|
||||||
|
{
|
||||||
|
t->set_tip_area (Gdk::Rectangle (0, 0, 0, 0));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Hackily arrange for the provided widget to have no tooltip,
|
||||||
|
* and also to stop any other widget from providing one while
|
||||||
|
* the mouse is over w.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Gtkmm2ext::set_no_tooltip_whatsoever (Gtk::Widget& w)
|
||||||
|
{
|
||||||
|
w.property_has_tooltip() = true;
|
||||||
|
w.signal_query_tooltip().connect (sigc::ptr_fun (make_null_tooltip));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ gtkmm2ext_sources = [
|
||||||
'idle_adjustment.cc',
|
'idle_adjustment.cc',
|
||||||
'keyboard.cc',
|
'keyboard.cc',
|
||||||
'motionfeedback.cc',
|
'motionfeedback.cc',
|
||||||
|
'persistent_tooltip.cc',
|
||||||
'prolooks_helpers.c',
|
'prolooks_helpers.c',
|
||||||
'pixfader.cc',
|
'pixfader.cc',
|
||||||
'pixscroller.cc',
|
'pixscroller.cc',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue