mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-15 19:16:40 +01:00
Make pan double-click entry work in percentage left or right. Write pan position to the panner as text (except when centered). Use a virtual function rather than a signal for BarController labels.
git-svn-id: svn://localhost/ardour2/branches/3.0@5104 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
dbe20bd3a9
commit
64524c0ba4
10 changed files with 191 additions and 96 deletions
|
|
@ -36,12 +36,10 @@ using namespace Gtk;
|
|||
using namespace Gtkmm2ext;
|
||||
|
||||
BarController::BarController (Gtk::Adjustment& adj,
|
||||
boost::shared_ptr<PBD::Controllable> mc,
|
||||
sigc::slot<void,char*,unsigned int> lc)
|
||||
boost::shared_ptr<PBD::Controllable> mc)
|
||||
|
||||
: adjustment (adj),
|
||||
binding_proxy (mc),
|
||||
label_callback (lc),
|
||||
spinner (adjustment)
|
||||
|
||||
{
|
||||
|
|
@ -49,7 +47,6 @@ BarController::BarController (Gtk::Adjustment& adj,
|
|||
grabbed = false;
|
||||
switching = false;
|
||||
switch_on_release = false;
|
||||
with_text = true;
|
||||
use_parent = false;
|
||||
|
||||
layout = darea.create_pango_layout("");
|
||||
|
|
@ -76,6 +73,8 @@ BarController::BarController (Gtk::Adjustment& adj,
|
|||
|
||||
spinner.signal_activate().connect (mem_fun (*this, &BarController::entry_activated));
|
||||
spinner.signal_focus_out_event().connect (mem_fun (*this, &BarController::entry_focus_out));
|
||||
spinner.signal_input().connect (mem_fun (*this, &BarController::entry_input));
|
||||
spinner.signal_output().connect (mem_fun (*this, &BarController::entry_output));
|
||||
spinner.set_digits (3);
|
||||
|
||||
add (darea);
|
||||
|
|
@ -343,46 +342,32 @@ BarController::expose (GdkEventExpose* event)
|
|||
break;
|
||||
}
|
||||
|
||||
if (with_text) {
|
||||
/* draw label */
|
||||
/* draw label */
|
||||
|
||||
int xpos = -1;
|
||||
std::string const label = get_label (xpos);
|
||||
|
||||
if (!label.empty()) {
|
||||
|
||||
char buf[64];
|
||||
buf[0] = '\0';
|
||||
|
||||
if (label_callback)
|
||||
label_callback (buf, 64);
|
||||
|
||||
if (buf[0] != '\0') {
|
||||
|
||||
layout->set_text (buf);
|
||||
|
||||
int width, height;
|
||||
layout->get_pixel_size (width, height);
|
||||
|
||||
int xpos;
|
||||
layout->set_text (label);
|
||||
|
||||
int width, height;
|
||||
layout->get_pixel_size (width, height);
|
||||
|
||||
if (xpos == -1) {
|
||||
xpos = max (3, 1 + (x2 - (width/2)));
|
||||
xpos = min (darea.get_width() - width - 3, xpos);
|
||||
|
||||
win->draw_layout (get_style()->get_text_gc (get_state()),
|
||||
xpos,
|
||||
(darea.get_height()/2) - (height/2),
|
||||
layout);
|
||||
}
|
||||
|
||||
win->draw_layout (get_style()->get_text_gc (get_state()),
|
||||
xpos,
|
||||
(darea.get_height()/2) - (height/2),
|
||||
layout);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
BarController::set_with_text (bool yn)
|
||||
{
|
||||
if (with_text != yn) {
|
||||
with_text = yn;
|
||||
queue_draw ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BarController::set_style (Style s)
|
||||
{
|
||||
|
|
@ -467,3 +452,17 @@ BarController::set_sensitive (bool yn)
|
|||
Frame::set_sensitive (yn);
|
||||
darea.set_sensitive (yn);
|
||||
}
|
||||
|
||||
bool
|
||||
BarController::entry_input (double* v)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
BarController::entry_output ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,10 @@ namespace Gtkmm2ext {
|
|||
class BarController : public Gtk::Frame
|
||||
{
|
||||
public:
|
||||
typedef sigc::slot<void,char*,unsigned int> LabelCallback;
|
||||
|
||||
BarController (Gtk::Adjustment& adj, boost::shared_ptr<PBD::Controllable>, LabelCallback lc = LabelCallback());
|
||||
BarController (Gtk::Adjustment& adj, boost::shared_ptr<PBD::Controllable>);
|
||||
|
||||
virtual ~BarController () {}
|
||||
|
||||
|
||||
enum Style {
|
||||
LeftToRight,
|
||||
RightToLeft,
|
||||
|
|
@ -50,13 +48,10 @@ class BarController : public Gtk::Frame
|
|||
|
||||
Style style() const { return _style; }
|
||||
void set_style (Style);
|
||||
void set_with_text (bool yn);
|
||||
void set_use_parent (bool yn);
|
||||
|
||||
void set_sensitive (bool yn);
|
||||
|
||||
Gtk::SpinButton& get_spin_button() { return spinner; }
|
||||
|
||||
sigc::signal<void> StartGesture;
|
||||
sigc::signal<void> StopGesture;
|
||||
|
||||
|
|
@ -71,25 +66,29 @@ class BarController : public Gtk::Frame
|
|||
Gtk::Adjustment& adjustment;
|
||||
BindingProxy binding_proxy;
|
||||
Gtk::DrawingArea darea;
|
||||
LabelCallback label_callback;
|
||||
Glib::RefPtr<Pango::Layout> layout;
|
||||
Style _style;
|
||||
bool grabbed;
|
||||
bool switching;
|
||||
bool switch_on_release;
|
||||
bool with_text;
|
||||
double initial_value;
|
||||
double grab_x;
|
||||
GdkWindow* grab_window;
|
||||
Gtk::SpinButton spinner;
|
||||
bool use_parent;
|
||||
|
||||
virtual std::string get_label (int& x) {
|
||||
return "";
|
||||
}
|
||||
|
||||
virtual bool button_press (GdkEventButton *);
|
||||
virtual bool button_release (GdkEventButton *);
|
||||
virtual bool motion (GdkEventMotion *);
|
||||
virtual bool expose (GdkEventExpose *);
|
||||
virtual bool scroll (GdkEventScroll *);
|
||||
virtual bool entry_focus_out (GdkEventFocus*);
|
||||
virtual bool entry_input (double *);
|
||||
virtual bool entry_output ();
|
||||
|
||||
gint mouse_control (double x, GdkWindow* w, double scaling);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue