mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
unify BarController with Slider/Pixfader.
This commit is contained in:
parent
41ccf6a806
commit
efb03f4596
4 changed files with 71 additions and 504 deletions
|
|
@ -13,8 +13,6 @@
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
$Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -40,54 +38,31 @@ using namespace Gtk;
|
||||||
using namespace Gtkmm2ext;
|
using namespace Gtkmm2ext;
|
||||||
|
|
||||||
BarController::BarController (Gtk::Adjustment& adj,
|
BarController::BarController (Gtk::Adjustment& adj,
|
||||||
boost::shared_ptr<PBD::Controllable> mc)
|
boost::shared_ptr<PBD::Controllable> mc)
|
||||||
|
: _slider (&adj, 60, 16)
|
||||||
: adjustment (adj)
|
, _logarithmic (false)
|
||||||
, binding_proxy (mc)
|
, _switching (false)
|
||||||
, spinner (adjustment)
|
, _switch_on_release (false)
|
||||||
, _hovering (false)
|
{
|
||||||
{
|
|
||||||
_style = LeftToRight;
|
|
||||||
grabbed = false;
|
|
||||||
switching = false;
|
|
||||||
switch_on_release = false;
|
|
||||||
use_parent = false;
|
|
||||||
logarithmic = false;
|
|
||||||
|
|
||||||
layout = darea.create_pango_layout("");
|
|
||||||
|
|
||||||
|
add_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
|
||||||
set (.5, .5, 1.0, 1.0);
|
set (.5, .5, 1.0, 1.0);
|
||||||
set_border_width(0);
|
set_border_width (0);
|
||||||
|
_slider.set_controllable (mc);
|
||||||
|
|
||||||
initial_value = adjustment.get_value ();
|
_slider.StartGesture.connect (sigc::mem_fun(*this, &BarController::passtrhu_gesture_start));
|
||||||
|
_slider.StopGesture.connect (sigc::mem_fun(*this, &BarController::passtrhu_gesture_stop));
|
||||||
adjustment.signal_value_changed().connect (mem_fun (*this, &Gtk::Widget::queue_draw));
|
_slider.OnExpose.connect (sigc::mem_fun(*this, &BarController::before_expose));
|
||||||
adjustment.signal_changed().connect (mem_fun (*this, &Gtk::Widget::queue_draw));
|
|
||||||
|
|
||||||
darea.add_events (Gdk::BUTTON_RELEASE_MASK|
|
|
||||||
Gdk::BUTTON_PRESS_MASK|
|
|
||||||
Gdk::POINTER_MOTION_MASK|
|
|
||||||
Gdk::ENTER_NOTIFY_MASK|
|
|
||||||
Gdk::LEAVE_NOTIFY_MASK|
|
|
||||||
Gdk::SCROLL_MASK);
|
|
||||||
|
|
||||||
darea.signal_expose_event().connect (mem_fun (*this, &BarController::expose));
|
|
||||||
darea.signal_motion_notify_event().connect (mem_fun (*this, &BarController::motion));
|
|
||||||
darea.signal_button_press_event().connect (mem_fun (*this, &BarController::button_press), false);
|
|
||||||
darea.signal_button_release_event().connect (mem_fun (*this, &BarController::button_release), false);
|
|
||||||
darea.signal_scroll_event().connect (mem_fun (*this, &BarController::scroll));
|
|
||||||
darea.signal_enter_notify_event().connect (mem_fun (*this, &BarController::on_enter_notify_event));
|
|
||||||
darea.signal_leave_notify_event().connect (mem_fun (*this, &BarController::on_leave_notify_event));
|
|
||||||
|
|
||||||
|
Gtk::SpinButton& spinner = _slider.get_spin_button();
|
||||||
spinner.signal_activate().connect (mem_fun (*this, &BarController::entry_activated));
|
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_focus_out_event().connect (mem_fun (*this, &BarController::entry_focus_out));
|
||||||
spinner.signal_input().connect (mem_fun (*this, &BarController::entry_input));
|
spinner.signal_input().connect (mem_fun (*this, &BarController::entry_input));
|
||||||
spinner.signal_output().connect (mem_fun (*this, &BarController::entry_output));
|
spinner.signal_output().connect (mem_fun (*this, &BarController::entry_output));
|
||||||
spinner.set_digits (9);
|
spinner.set_digits (9);
|
||||||
spinner.set_numeric (true);
|
spinner.set_numeric (true);
|
||||||
|
spinner.set_name ("BarControlSpinner");
|
||||||
add (darea);
|
add (_slider);
|
||||||
|
|
||||||
show_all ();
|
show_all ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,435 +71,68 @@ BarController::~BarController ()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BarController::on_enter_notify_event (GdkEventCrossing*)
|
BarController::on_button_press_event (GdkEventButton* ev)
|
||||||
{
|
{
|
||||||
_hovering = true;
|
if (get_child() != &_slider) {
|
||||||
Keyboard::magic_widget_grab_focus ();
|
|
||||||
queue_draw ();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
BarController::on_leave_notify_event (GdkEventCrossing*)
|
|
||||||
{
|
|
||||||
_hovering = false;
|
|
||||||
Keyboard::magic_widget_drop_focus();
|
|
||||||
queue_draw ();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
BarController::drop_grab ()
|
|
||||||
{
|
|
||||||
if (grabbed) {
|
|
||||||
grabbed = false;
|
|
||||||
darea.remove_modal_grab();
|
|
||||||
StopGesture ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
BarController::button_press (GdkEventButton* ev)
|
|
||||||
{
|
|
||||||
double fract;
|
|
||||||
|
|
||||||
if (binding_proxy.button_press_handler (ev)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (ev->button) {
|
|
||||||
case 1:
|
|
||||||
if (ev->type == GDK_2BUTTON_PRESS) {
|
|
||||||
switch_on_release = true;
|
|
||||||
drop_grab ();
|
|
||||||
} else {
|
|
||||||
switch_on_release = false;
|
|
||||||
darea.add_modal_grab();
|
|
||||||
grabbed = true;
|
|
||||||
grab_x = ev->x;
|
|
||||||
grab_window = ev->window;
|
|
||||||
StartGesture ();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
fract = ev->x / (darea.get_width() - 2.0);
|
|
||||||
adjustment.set_value (adjustment.get_lower() + fract * (adjustment.get_upper() - adjustment.get_lower()));
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
BarController::button_release (GdkEventButton* ev)
|
|
||||||
{
|
|
||||||
drop_grab ();
|
|
||||||
|
|
||||||
switch (ev->button) {
|
|
||||||
case 1:
|
|
||||||
if (switch_on_release) {
|
|
||||||
Glib::signal_idle().connect (mem_fun (*this, &BarController::switch_to_spinner));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ev->state & (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier)) == Keyboard::TertiaryModifier) {
|
|
||||||
adjustment.set_value (initial_value);
|
|
||||||
} else {
|
|
||||||
double scale;
|
|
||||||
|
|
||||||
if ((ev->state & (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier)) == (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier)) {
|
|
||||||
scale = 0.01;
|
|
||||||
} else if (ev->state & Keyboard::PrimaryModifier) {
|
|
||||||
scale = 0.1;
|
|
||||||
} else {
|
|
||||||
scale = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
mouse_control (ev->x, ev->window, scale);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
|
||||||
return true;
|
_switch_on_release = true;
|
||||||
}
|
return true;
|
||||||
|
|
||||||
bool
|
|
||||||
BarController::scroll (GdkEventScroll* ev)
|
|
||||||
{
|
|
||||||
double scale;
|
|
||||||
|
|
||||||
if ((ev->state & (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier)) == (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier)) {
|
|
||||||
scale = 0.01;
|
|
||||||
} else if (ev->state & Keyboard::PrimaryModifier) {
|
|
||||||
scale = 0.1;
|
|
||||||
} else {
|
} else {
|
||||||
scale = 1.0;
|
_switch_on_release = false;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
switch (ev->direction) {
|
|
||||||
case GDK_SCROLL_UP:
|
|
||||||
case GDK_SCROLL_RIGHT:
|
|
||||||
adjustment.set_value (adjustment.get_value() + (scale * adjustment.get_step_increment()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GDK_SCROLL_DOWN:
|
|
||||||
case GDK_SCROLL_LEFT:
|
|
||||||
adjustment.set_value (adjustment.get_value() - (scale * adjustment.get_step_increment()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
BarController::motion (GdkEventMotion* ev)
|
BarController::on_button_release_event (GdkEventButton* ev)
|
||||||
{
|
{
|
||||||
double scale;
|
if (get_child() != &_slider) {
|
||||||
|
return false;
|
||||||
if (!grabbed) {
|
}
|
||||||
|
if (ev->button == 1 && _switch_on_release) {
|
||||||
|
Glib::signal_idle().connect (mem_fun (*this, &BarController::switch_to_spinner));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
if ((ev->state & (Keyboard::TertiaryModifier|Keyboard::PrimaryModifier)) == Keyboard::TertiaryModifier) {
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ev->state & (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier)) == (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier)) {
|
|
||||||
scale = 0.01;
|
|
||||||
} else if (ev->state & Keyboard::PrimaryModifier) {
|
|
||||||
scale = 0.1;
|
|
||||||
} else {
|
|
||||||
scale = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mouse_control (ev->x, ev->window, scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
gint
|
|
||||||
BarController::mouse_control (double x, GdkWindow* window, double scaling)
|
|
||||||
{
|
|
||||||
double fract = 0.0;
|
|
||||||
double delta;
|
|
||||||
|
|
||||||
if (window != grab_window) {
|
|
||||||
grab_x = x;
|
|
||||||
grab_window = window;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
delta = x - grab_x;
|
|
||||||
grab_x = x;
|
|
||||||
|
|
||||||
switch (_style) {
|
|
||||||
case Line:
|
|
||||||
case Blob:
|
|
||||||
case LeftToRight:
|
|
||||||
case CenterOut:
|
|
||||||
fract = scaling * (delta / (darea.get_width() - 2));
|
|
||||||
fract = min (1.0, fract);
|
|
||||||
fract = max (-1.0, fract);
|
|
||||||
adjustment.set_value (adjustment.get_value() + fract * (adjustment.get_upper() - adjustment.get_lower()));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fract = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Gdk::Color
|
|
||||||
BarController::get_parent_bg ()
|
|
||||||
{
|
|
||||||
Widget* parent;
|
|
||||||
|
|
||||||
parent = get_parent ();
|
|
||||||
|
|
||||||
while (parent) {
|
|
||||||
static const char* has_cairo_widget_background_info = "has_cairo_widget_background_info";
|
|
||||||
void* p = g_object_get_data (G_OBJECT(parent->gobj()), has_cairo_widget_background_info);
|
|
||||||
|
|
||||||
if (p) {
|
|
||||||
Glib::RefPtr<Gtk::Style> style = parent->get_style();
|
|
||||||
return style->get_bg (get_state());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parent->get_has_window()) {
|
|
||||||
parent = parent->get_parent();
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parent && parent->get_has_window()) {
|
|
||||||
return parent->get_style ()->get_bg (parent->get_state());
|
|
||||||
}
|
|
||||||
|
|
||||||
return get_style ()->get_bg (get_state());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
BarController::expose (GdkEventExpose* /*event*/)
|
|
||||||
{
|
|
||||||
Glib::RefPtr<Gdk::Window> win (darea.get_window());
|
|
||||||
Cairo::RefPtr<Cairo::Context> context = win->create_cairo_context();
|
|
||||||
cairo_t* cr = context->cobj();
|
|
||||||
|
|
||||||
Gdk::Color fg_col = get_style()->get_fg (get_state());
|
|
||||||
|
|
||||||
double fract = ((adjustment.get_value() - adjustment.get_lower()) /
|
|
||||||
(adjustment.get_upper() - adjustment.get_lower()));
|
|
||||||
|
|
||||||
gint w = darea.get_width() ;
|
|
||||||
gint h = darea.get_height();
|
|
||||||
gint bar_start, bar_width;
|
|
||||||
double radius = 4;
|
|
||||||
|
|
||||||
switch (_style) {
|
|
||||||
case Line:
|
|
||||||
bar_start = (gint) floor ((w-1) * fract);
|
|
||||||
bar_width = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Blob:
|
|
||||||
// ????
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CenterOut:
|
|
||||||
bar_width = (w*fract);
|
|
||||||
bar_start = (w/2) - bar_width/2; // center, back up half the bar width
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LeftToRight:
|
|
||||||
bar_start = 1;
|
|
||||||
bar_width = floor((w-2)*fract);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RightToLeft:
|
|
||||||
break;
|
|
||||||
case TopToBottom:
|
|
||||||
break;
|
|
||||||
case BottomToTop:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//fill in the bg rect ...
|
|
||||||
Gdk::Color c = get_parent_bg(); //get_style()->get_bg (Gtk::STATE_PRELIGHT); //why prelight? Shouldn't we be using the parent's color? maybe get_parent_bg ?
|
|
||||||
CairoWidget::set_source_rgb_a (cr, c);
|
|
||||||
cairo_rectangle (cr, 0, 0, w, h);
|
|
||||||
cairo_fill(cr);
|
|
||||||
|
|
||||||
//"slot"
|
|
||||||
cairo_set_source_rgba (cr, 0.17, 0.17, 0.17, 1.0);
|
|
||||||
Gtkmm2ext::rounded_rectangle (cr, 1, 1, w-2, h-2, radius-0.5);
|
|
||||||
cairo_fill(cr);
|
|
||||||
|
|
||||||
//mask off the corners
|
|
||||||
Gtkmm2ext::rounded_rectangle (cr, 1, 1, w-2, h-2, radius-0.5);
|
|
||||||
cairo_clip(cr);
|
|
||||||
|
|
||||||
//background gradient
|
|
||||||
if ( !CairoWidget::flat_buttons() ) {
|
|
||||||
cairo_pattern_t *bg_gradient = cairo_pattern_create_linear (0.0, 0.0, 0, h);
|
|
||||||
cairo_pattern_add_color_stop_rgba (bg_gradient, 0, 0, 0, 0, 0.4);
|
|
||||||
cairo_pattern_add_color_stop_rgba (bg_gradient, 0.2, 0, 0, 0, 0.2);
|
|
||||||
cairo_pattern_add_color_stop_rgba (bg_gradient, 1, 0, 0, 0, 0.0);
|
|
||||||
cairo_set_source (cr, bg_gradient);
|
|
||||||
Gtkmm2ext::rounded_rectangle (cr, 1, 1, w-2, h-2, radius-1.5);
|
|
||||||
cairo_fill (cr);
|
|
||||||
cairo_pattern_destroy(bg_gradient);
|
|
||||||
}
|
|
||||||
|
|
||||||
//fg color
|
|
||||||
CairoWidget::set_source_rgb_a (cr, fg_col, 1.0);
|
|
||||||
Gtkmm2ext::rounded_rectangle (cr, bar_start, 1, bar_width, h-2, radius - 1.5);
|
|
||||||
cairo_fill(cr);
|
|
||||||
|
|
||||||
//fg gradient
|
|
||||||
if (!CairoWidget::flat_buttons() ) {
|
|
||||||
cairo_pattern_t * fg_gradient = cairo_pattern_create_linear (0.0, 0.0, 0, h);
|
|
||||||
cairo_pattern_add_color_stop_rgba (fg_gradient, 0, 0, 0, 0, 0.0);
|
|
||||||
cairo_pattern_add_color_stop_rgba (fg_gradient, 0.1, 0, 0, 0, 0.0);
|
|
||||||
cairo_pattern_add_color_stop_rgba (fg_gradient, 1, 0, 0, 0, 0.3);
|
|
||||||
cairo_set_source (cr, fg_gradient);
|
|
||||||
Gtkmm2ext::rounded_rectangle (cr, bar_start, 1, bar_width, h-2, radius - 1.5);
|
|
||||||
cairo_fill (cr);
|
|
||||||
cairo_pattern_destroy(fg_gradient);
|
|
||||||
}
|
|
||||||
|
|
||||||
cairo_reset_clip(cr);
|
|
||||||
|
|
||||||
//black border
|
|
||||||
cairo_set_line_width (cr, 1.0);
|
|
||||||
cairo_set_source_rgba (cr, 0, 0, 0, 1.0);
|
|
||||||
Gtkmm2ext::rounded_rectangle (cr, 0.5, 0.5, w-1, h-1, radius);
|
|
||||||
cairo_stroke(cr);
|
|
||||||
|
|
||||||
/* draw the unity-position line if it's not at either end*/
|
|
||||||
/* if (unity_loc > 0) {
|
|
||||||
context->set_line_width (1);
|
|
||||||
cairo_set_source_rgba (cr, 1,1,1, 1.0);
|
|
||||||
if ( _orien == VERT) {
|
|
||||||
if (unity_loc < h ) {
|
|
||||||
context->move_to (2.5, unity_loc + radius + .5);
|
|
||||||
context->line_to (girth-2.5, unity_loc + radius + .5);
|
|
||||||
context->stroke ();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ( unity_loc < w ){
|
|
||||||
context->move_to (unity_loc - radius + .5, 3.5);
|
|
||||||
context->line_to (unity_loc - radius + .5, girth-3.5);
|
|
||||||
context->stroke ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (!darea.get_sensitive()) {
|
|
||||||
rounded_rectangle (context, 0, 0, darea.get_width(), darea.get_height(), 3);
|
|
||||||
context->set_source_rgba (0.505, 0.517, 0.525, 0.6);
|
|
||||||
context->fill ();
|
|
||||||
} else if (_hovering) {
|
|
||||||
Gtkmm2ext::rounded_rectangle (cr, 1, 1, w-2, h-2, radius);
|
|
||||||
cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.1);
|
|
||||||
cairo_fill (cr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* draw label */
|
|
||||||
|
|
||||||
double xpos = -1;
|
|
||||||
std::string const label = get_label (xpos);
|
|
||||||
if (!label.empty()) {
|
|
||||||
|
|
||||||
int twidth, theight;
|
|
||||||
layout->set_text (label);
|
|
||||||
layout->get_pixel_size (twidth, theight);
|
|
||||||
|
|
||||||
if (fract > 0.5) {
|
|
||||||
cairo_set_source_rgba (cr, 0.17, 0.17, 0.17, 1.0);
|
|
||||||
context->move_to ( 5, (darea.get_height()/2) - (theight/2));
|
|
||||||
} else {
|
|
||||||
c = get_style()->get_text (get_state());
|
|
||||||
CairoWidget::set_source_rgb_a (cr, c, 0.7);
|
|
||||||
context->move_to ( w-twidth-5, (darea.get_height()/2) - (theight/2));
|
|
||||||
}
|
|
||||||
layout->show_in_cairo_context (context);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
BarController::set_style (barStyle s)
|
|
||||||
{
|
|
||||||
_style = s;
|
|
||||||
darea.queue_draw ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
BarController::switch_to_bar ()
|
BarController::switch_to_bar ()
|
||||||
{
|
{
|
||||||
if (switching) {
|
if (_switching || get_child() == &_slider) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
_switching = true;
|
||||||
switching = true;
|
|
||||||
|
|
||||||
if (get_child() == &darea) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
remove ();
|
remove ();
|
||||||
add (darea);
|
add (_slider);
|
||||||
darea.show ();
|
_slider.show ();
|
||||||
|
_slider.queue_draw ();
|
||||||
switching = false;
|
_switching = false;
|
||||||
|
|
||||||
SpinnerActive (false); /* EMIT SIGNAL */
|
SpinnerActive (false); /* EMIT SIGNAL */
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
BarController::switch_to_spinner ()
|
BarController::switch_to_spinner ()
|
||||||
{
|
{
|
||||||
if (switching) {
|
if (_switching || get_child() != &_slider) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
switching = true;
|
_switching = true;
|
||||||
|
Gtk::SpinButton& spinner = _slider.get_spin_button();
|
||||||
if (get_child() == &spinner) {
|
if (spinner.get_parent()) {
|
||||||
return FALSE;
|
spinner.get_parent()->remove(spinner);
|
||||||
}
|
}
|
||||||
|
|
||||||
remove ();
|
remove ();
|
||||||
add (spinner);
|
add (spinner);
|
||||||
spinner.show ();
|
spinner.show ();
|
||||||
spinner.select_region (0, spinner.get_text_length());
|
spinner.select_region (0, spinner.get_text_length());
|
||||||
spinner.grab_focus ();
|
spinner.grab_focus ();
|
||||||
|
_switching = false;
|
||||||
switching = false;
|
|
||||||
|
|
||||||
SpinnerActive (true); /* EMIT SIGNAL */
|
SpinnerActive (true); /* EMIT SIGNAL */
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -542,17 +150,17 @@ BarController::entry_focus_out (GdkEventFocus* /*ev*/)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BarController::set_use_parent (bool yn)
|
BarController::before_expose ()
|
||||||
{
|
{
|
||||||
use_parent = yn;
|
double xpos = -1;
|
||||||
queue_draw ();
|
_slider.set_text (get_label (xpos), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
BarController::set_sensitive (bool yn)
|
BarController::set_sensitive (bool yn)
|
||||||
{
|
{
|
||||||
Alignment::set_sensitive (yn);
|
Alignment::set_sensitive (yn);
|
||||||
darea.set_sensitive (yn);
|
_slider.set_sensitive (yn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -570,11 +178,12 @@ BarController::set_sensitive (bool yn)
|
||||||
int
|
int
|
||||||
BarController::entry_input (double* new_value)
|
BarController::entry_input (double* new_value)
|
||||||
{
|
{
|
||||||
if (!logarithmic) {
|
if (!_logarithmic) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// extract a double from the string and take its log
|
// extract a double from the string and take its log
|
||||||
|
Gtk::SpinButton& spinner = _slider.get_spin_button();
|
||||||
Entry *entry = dynamic_cast<Entry *>(&spinner);
|
Entry *entry = dynamic_cast<Entry *>(&spinner);
|
||||||
double value;
|
double value;
|
||||||
|
|
||||||
|
|
@ -604,18 +213,19 @@ BarController::entry_input (double* new_value)
|
||||||
bool
|
bool
|
||||||
BarController::entry_output ()
|
BarController::entry_output ()
|
||||||
{
|
{
|
||||||
if (!logarithmic) {
|
if (!_logarithmic) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char buf[128];
|
||||||
|
Gtk::SpinButton& spinner = _slider.get_spin_button();
|
||||||
|
|
||||||
// generate the exponential and turn it into a string
|
// generate the exponential and turn it into a string
|
||||||
// convert to correct locale.
|
// convert to correct locale.
|
||||||
|
|
||||||
stringstream stream;
|
stringstream stream;
|
||||||
string str;
|
string str;
|
||||||
|
|
||||||
char buf[128];
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// Switch to user's preferred locale so that
|
// Switch to user's preferred locale so that
|
||||||
// if they use different LC_NUMERIC conventions,
|
// if they use different LC_NUMERIC conventions,
|
||||||
|
|
@ -630,6 +240,3 @@ BarController::entry_output ()
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,11 @@
|
||||||
#define __gtkmm2ext_bar_controller_h__
|
#define __gtkmm2ext_bar_controller_h__
|
||||||
|
|
||||||
#include <gtkmm/alignment.h>
|
#include <gtkmm/alignment.h>
|
||||||
#include <gtkmm/frame.h>
|
|
||||||
#include <gtkmm/drawingarea.h>
|
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
|
|
||||||
#include "gtkmm2ext/visibility.h"
|
#include "gtkmm2ext/visibility.h"
|
||||||
#include "gtkmm2ext/binding_proxy.h"
|
#include "gtkmm2ext/binding_proxy.h"
|
||||||
|
#include "gtkmm2ext/slider_controller.h"
|
||||||
|
|
||||||
namespace Gtkmm2ext {
|
namespace Gtkmm2ext {
|
||||||
|
|
||||||
|
|
@ -36,34 +35,14 @@ class LIBGTKMM2EXT_API BarController : public Gtk::Alignment
|
||||||
|
|
||||||
virtual ~BarController ();
|
virtual ~BarController ();
|
||||||
|
|
||||||
enum barStyle {
|
|
||||||
LeftToRight,
|
|
||||||
RightToLeft,
|
|
||||||
Line,
|
|
||||||
Blob,
|
|
||||||
CenterOut,
|
|
||||||
|
|
||||||
TopToBottom,
|
|
||||||
BottomToTop
|
|
||||||
};
|
|
||||||
|
|
||||||
barStyle style() const { return _style; }
|
|
||||||
void set_style (barStyle);
|
|
||||||
void set_use_parent (bool yn);
|
|
||||||
|
|
||||||
void set_sensitive (bool yn);
|
void set_sensitive (bool yn);
|
||||||
|
void set_logarithmic (bool yn) { _logarithmic = yn; }
|
||||||
void set_logarithmic (bool yn) { logarithmic = yn; }
|
|
||||||
|
|
||||||
sigc::signal<void> StartGesture;
|
sigc::signal<void> StartGesture;
|
||||||
sigc::signal<void> StopGesture;
|
sigc::signal<void> StopGesture;
|
||||||
|
|
||||||
/* export this to allow direct connection to button events */
|
/* export this to allow direct connection to button events */
|
||||||
|
Gtk::Widget& event_widget() { return _slider; }
|
||||||
Gtk::Widget& event_widget() { return darea; }
|
|
||||||
|
|
||||||
boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
|
|
||||||
void set_controllable(boost::shared_ptr<PBD::Controllable> c) { binding_proxy.set_controllable(c); }
|
|
||||||
|
|
||||||
/** Emitted when the adjustment spinner is activated or deactivated;
|
/** Emitted when the adjustment spinner is activated or deactivated;
|
||||||
* the parameter is true on activation, false on deactivation.
|
* the parameter is true on activation, false on deactivation.
|
||||||
|
|
@ -71,51 +50,32 @@ class LIBGTKMM2EXT_API BarController : public Gtk::Alignment
|
||||||
sigc::signal<void, bool> SpinnerActive;
|
sigc::signal<void, bool> SpinnerActive;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Gtk::Adjustment& adjustment;
|
bool on_button_press_event (GdkEventButton*);
|
||||||
BindingProxy binding_proxy;
|
bool on_button_release_event (GdkEventButton*);
|
||||||
Gtk::DrawingArea darea;
|
|
||||||
Glib::RefPtr<Pango::Layout> layout;
|
|
||||||
barStyle _style;
|
|
||||||
bool grabbed;
|
|
||||||
bool switching;
|
|
||||||
bool switch_on_release;
|
|
||||||
double initial_value;
|
|
||||||
double grab_x;
|
|
||||||
GdkWindow* grab_window;
|
|
||||||
Gtk::SpinButton spinner;
|
|
||||||
bool use_parent;
|
|
||||||
bool logarithmic;
|
|
||||||
sigc::slot<std::string> _label_slot;
|
|
||||||
bool _use_slot;
|
|
||||||
|
|
||||||
virtual std::string get_label (double& /*x*/) {
|
virtual std::string get_label (double& /*x*/) {
|
||||||
return "";
|
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*);
|
|
||||||
bool on_enter_notify_event (GdkEventCrossing* ev);
|
|
||||||
bool on_leave_notify_event (GdkEventCrossing* ev);
|
|
||||||
|
|
||||||
gint mouse_control (double x, GdkWindow* w, double scaling);
|
private:
|
||||||
|
HSliderController _slider;
|
||||||
Gdk::Color get_parent_bg ();
|
bool entry_focus_out (GdkEventFocus*);
|
||||||
|
void entry_activated ();
|
||||||
|
int entry_input (double* new_value);
|
||||||
|
bool entry_output ();
|
||||||
|
void before_expose ();
|
||||||
|
|
||||||
gint switch_to_bar ();
|
gint switch_to_bar ();
|
||||||
gint switch_to_spinner ();
|
gint switch_to_spinner ();
|
||||||
|
|
||||||
void entry_activated ();
|
bool _grabbed;
|
||||||
void drop_grab ();
|
bool _logarithmic;
|
||||||
|
bool _switching;
|
||||||
int entry_input (double* new_value);
|
bool _switch_on_release;
|
||||||
bool entry_output ();
|
|
||||||
|
|
||||||
bool _hovering;
|
|
||||||
|
|
||||||
|
void passtrhu_gesture_start() { StartGesture (); }
|
||||||
|
void passtrhu_gesture_stop() { StopGesture (); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ class LIBGTKMM2EXT_API PixFader : public Gtk::DrawingArea
|
||||||
sigc::signal<void> OnExpose;
|
sigc::signal<void> OnExpose;
|
||||||
|
|
||||||
void set_default_value (float);
|
void set_default_value (float);
|
||||||
void set_text (const std::string&, bool);
|
void set_text (const std::string&, bool centered = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Glib::RefPtr<Pango::Layout> _layout;
|
Glib::RefPtr<Pango::Layout> _layout;
|
||||||
|
|
|
||||||
|
|
@ -632,7 +632,7 @@ PixFader::set_default_value (float d)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PixFader::set_text (const std::string& str, bool centered = true)
|
PixFader::set_text (const std::string& str, bool centered)
|
||||||
{
|
{
|
||||||
if (_layout && _text == str) {
|
if (_layout && _text == str) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue