diff options
-rw-r--r-- | gtk2_ardour/ardour3_styles.rc.in | 9 | ||||
-rw-r--r-- | gtk2_ardour/ardour3_widget_list.rc | 3 | ||||
-rw-r--r-- | gtk2_ardour/gain_meter.cc | 14 | ||||
-rw-r--r-- | gtk2_ardour/gain_meter.h | 4 | ||||
-rw-r--r-- | gtk2_ardour/processor_box.cc | 3 | ||||
-rw-r--r-- | gtk2_ardour/route_time_axis.cc | 4 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/pixfader.h | 29 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/slider_controller.h | 6 | ||||
-rw-r--r-- | libs/gtkmm2ext/pixfader.cc | 170 | ||||
-rw-r--r-- | libs/gtkmm2ext/slider_controller.cc | 12 |
10 files changed, 142 insertions, 112 deletions
diff --git a/gtk2_ardour/ardour3_styles.rc.in b/gtk2_ardour/ardour3_styles.rc.in index 271ee2ec0a..38b2213bd7 100644 --- a/gtk2_ardour/ardour3_styles.rc.in +++ b/gtk2_ardour/ardour3_styles.rc.in @@ -68,8 +68,13 @@ style "small_red_active_and_selected_button" = "small_button" style "gain_fader" { - bg[NORMAL] = shade (0.7, @@COLPREFIX@_lightest) - bg[ACTIVE] = shade (0.705, @@COLPREFIX@_lightest) + bg[NORMAL] = shade (0.7, @@COLPREFIX@_bg) + bg[ACTIVE] = shade (0.705, @@COLPREFIX@_bg) + bg[INSENSITIVE] = shade (0.705, @@COLPREFIX@_bg) + + fg[INSENSITIVE] = shade (0.7, @@COLPREFIX@_bright_color) + fg[NORMAL] = shade (0.7, @@COLPREFIX@_bright_color) + fg[ACTIVE] = shade (0.705, @@COLPREFIX@_bright_color) } #MSR and related buttons diff --git a/gtk2_ardour/ardour3_widget_list.rc b/gtk2_ardour/ardour3_widget_list.rc index 13c3b87e53..2abe10affe 100644 --- a/gtk2_ardour/ardour3_widget_list.rc +++ b/gtk2_ardour/ardour3_widget_list.rc @@ -177,9 +177,10 @@ widget "*TimeAxisViewControlsBaseUnselected" style:highest "audio_track_base" widget "*AudioTrackControlsBaseUnselected" style:highest "audio_track_base" widget "*MidiTrackControlsBaseUnselected" style:highest "midi_track_base" widget "*AudioTrackFader" style:highest "gain_fader" +widget "*MidiTrackFader" style:highest "gain_fader" +widget "*AudioBusFader" style:highest "gain_fader" widget "*BusControlsBaseUnselected" style:highest "audio_bus_base" -widget "*AudioBusFader" style:highest "gain_fader" widget "*TrackSeparator" style:highest "track_separator" widget "*TrackEditIndicator0*" style:highest "edit_group_0" widget "*TrackEditIndicator1*" style:highest "edit_group_1" diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index 9436596afa..a405f074ae 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -62,7 +62,7 @@ sigc::signal<void,RouteGroup*> GainMeterBase::ResetGroupPeakDisplays; GainMeter::MetricPatterns GainMeter::metric_patterns; -GainMeterBase::GainMeterBase (Session* s, bool horizontal, int fader_length) +GainMeterBase::GainMeterBase (Session* s, bool horizontal, int fader_length, int fader_girth) : gain_adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0.0, 1.0, 0.01, 0.1) , gain_automation_style_button ("") , gain_automation_state_button ("") @@ -81,9 +81,9 @@ GainMeterBase::GainMeterBase (Session* s, bool horizontal, int fader_length) _width = Wide; if (horizontal) { - gain_slider = manage (new HSliderController (&gain_adjustment, fader_length, false)); + gain_slider = manage (new HSliderController (&gain_adjustment, fader_length, fader_girth, false)); } else { - gain_slider = manage (new VSliderController (&gain_adjustment, fader_length, false)); + gain_slider = manage (new VSliderController (&gain_adjustment, fader_length, fader_girth, false)); } level_meter = new LevelMeter(_session); @@ -500,10 +500,7 @@ GainMeterBase::set_meter_strip_name (const char * name) void GainMeterBase::set_fader_name (const char * name) { - uint32_t rgb_active = rgba_from_style (name, 0xff, 0, 0xff, 0, "bg", STATE_ACTIVE, false); - uint32_t rgb_normal = rgba_from_style (name, 0xff, 0xff, 0, 0, "bg", STATE_NORMAL, false); - - gain_slider->set_border_colors (rgb_normal, rgb_active); + gain_slider->set_name (name); } void @@ -511,7 +508,6 @@ GainMeterBase::update_gain_sensitive () { bool x = !(_amp->gain_control()->alist()->automation_state() & Play); static_cast<Gtkmm2ext::SliderController*>(gain_slider)->set_sensitive (x); - gain_slider->create_patterns(); } static MeterPoint @@ -854,7 +850,7 @@ GainMeterBase::on_theme_changed() } GainMeter::GainMeter (Session* s, int fader_length) - : GainMeterBase (s, false, fader_length) + : GainMeterBase (s, false, fader_length, 24) , gain_display_box(true, 0) , hbox(true, 2) { diff --git a/gtk2_ardour/gain_meter.h b/gtk2_ardour/gain_meter.h index 116a0e7dfe..cec844184a 100644 --- a/gtk2_ardour/gain_meter.h +++ b/gtk2_ardour/gain_meter.h @@ -67,7 +67,7 @@ namespace Gtk { class GainMeterBase : virtual public sigc::trackable, ARDOUR::SessionHandlePtr { public: - GainMeterBase (ARDOUR::Session*, bool horizontal, int); + GainMeterBase (ARDOUR::Session*, bool horizontal, int, int); virtual ~GainMeterBase (); virtual void set_controls (boost::shared_ptr<ARDOUR::Route> route, @@ -200,7 +200,7 @@ private: class GainMeter : public GainMeterBase, public Gtk::VBox { public: - GainMeter (ARDOUR::Session*, int); + GainMeter (ARDOUR::Session*, int); ~GainMeter () {} virtual void set_controls (boost::shared_ptr<ARDOUR::Route> route, diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 2cf051baf2..58c3e6a85b 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -394,7 +394,7 @@ ProcessorEntry::toggle_control_visibility (Control* c) ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string const & n) : _control (c) , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1) - , _slider (&_adjustment, 0, false) + , _slider (&_adjustment, 0, 13, false) , _slider_persistant_tooltip (&_slider) , _button (ArdourButton::Element (ArdourButton::Text | ArdourButton::Indicator)) , _ignore_ui_adjustment (false) @@ -417,7 +417,6 @@ ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string } else { _slider.set_name ("PluginSlider"); - _slider.set_size_request (-1, 13); _slider.set_text (_name); // box.pack_start (_label); diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index a882dd0965..7342269026 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -102,7 +102,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, Canvas& c , playlist_action_menu (0) , mode_menu (0) , color_mode_menu (0) - , gm (sess, true, 125) + , gm (sess, true, 125, 18) , _ignore_set_layer_display (false) { } @@ -194,7 +194,7 @@ RouteTimeAxisView::set_route (boost::shared_ptr<Route> rt) // pad->pack_start (gm.get_gain_slider(), false, false); // pad->pack_start (*manage (new Gtk::Label), true, true); // pad->show_all (); - controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 3, 0); + controls_table.attach (gm.get_gain_slider(), 0, 5, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::AttachOptions (0), 3, 0); ARDOUR_UI::instance()->set_tip(*solo_button,_("Solo")); ARDOUR_UI::instance()->set_tip(*mute_button,_("Mute")); diff --git a/libs/gtkmm2ext/gtkmm2ext/pixfader.h b/libs/gtkmm2ext/gtkmm2ext/pixfader.h index 3d53a0d121..039a822bcd 100644 --- a/libs/gtkmm2ext/gtkmm2ext/pixfader.h +++ b/libs/gtkmm2ext/gtkmm2ext/pixfader.h @@ -32,16 +32,11 @@ namespace Gtkmm2ext { class PixFader : public Gtk::DrawingArea { public: - PixFader (Gtk::Adjustment& adjustment, int orientation, int); + PixFader (Gtk::Adjustment& adjustment, int orientation, int span, int girth); virtual ~PixFader (); void set_fader_length (int); - void set_border_colors (uint32_t rgba_left, uint32_t rgba_right); - - void create_patterns(); - void set_default_value (float); - void set_text (const std::string&); protected: @@ -65,31 +60,19 @@ class PixFader : public Gtk::DrawingArea bool on_scroll_event (GdkEventScroll* ev); bool on_enter_notify_event (GdkEventCrossing* ev); bool on_leave_notify_event (GdkEventCrossing* ev); + void on_state_changed (Gtk::StateType); enum Orientation { - VERT=1, - HORIZ=2, + VERT, + HORIZ, }; private: - - enum State { - NORMAL, - DESENSITISED, - STATES - }; - int span, girth; int _orien; - float left_r; - float left_g; - float left_b; - float right_r; - float right_g; - float right_b; cairo_pattern_t* pattern; - cairo_pattern_t* shine_pattern; + cairo_pattern_t* texture_pattern; bool _hovering; @@ -105,6 +88,8 @@ class PixFader : public Gtk::DrawingArea int display_span (); void set_adjustment_from_event (GdkEventButton *); void update_unity_position (); + void free_patterns (); + void create_patterns(); }; diff --git a/libs/gtkmm2ext/gtkmm2ext/slider_controller.h b/libs/gtkmm2ext/gtkmm2ext/slider_controller.h index 8fe788aa37..4c6a5cb41d 100644 --- a/libs/gtkmm2ext/gtkmm2ext/slider_controller.h +++ b/libs/gtkmm2ext/gtkmm2ext/slider_controller.h @@ -39,7 +39,7 @@ namespace Gtkmm2ext { class SliderController : public Gtkmm2ext::PixFader { public: - SliderController (Gtk::Adjustment* adj, int orientation, int); + SliderController (Gtk::Adjustment* adj, int orientation, int, int); virtual ~SliderController () {} @@ -63,13 +63,13 @@ class SliderController : public Gtkmm2ext::PixFader class VSliderController : public SliderController { public: - VSliderController (Gtk::Adjustment *adj, int, bool with_numeric = true); + VSliderController (Gtk::Adjustment *adj, int, int, bool with_numeric = true); }; class HSliderController : public SliderController { public: - HSliderController (Gtk::Adjustment *adj, int, bool with_numeric = true); + HSliderController (Gtk::Adjustment *adj, int, int, bool with_numeric = true); }; diff --git a/libs/gtkmm2ext/pixfader.cc b/libs/gtkmm2ext/pixfader.cc index c27fa680dd..d7980503db 100644 --- a/libs/gtkmm2ext/pixfader.cc +++ b/libs/gtkmm2ext/pixfader.cc @@ -32,51 +32,42 @@ using namespace std; #define CORNER_RADIUS 4 #define FADER_RESERVE (2*CORNER_RADIUS) -PixFader::PixFader (Gtk::Adjustment& adj, int orientation, int fader_length) +PixFader::PixFader (Gtk::Adjustment& adj, int orientation, int fader_length, int fader_girth) : adjustment (adj) + , span (fader_length) + , girth (fader_girth) , _orien (orientation) + , pattern (0) + , texture_pattern (0) + , _hovering (false) + , last_drawn (-1) + , dragging (false) { - pattern = 0; - shine_pattern = 0; - - _hovering = false; - dragging = false; default_value = adjustment.get_value(); - last_drawn = -1; - girth = 23; - - set_fader_length (fader_length); + update_unity_position (); add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK|Gdk::SCROLL_MASK|Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK); adjustment.signal_value_changed().connect (mem_fun (*this, &PixFader::adjustment_changed)); adjustment.signal_changed().connect (mem_fun (*this, &PixFader::adjustment_changed)); - - left_r = 0; - left_g = 0; - left_b = 0; - - right_r = 0; - right_g = 0; - right_b = 0; } PixFader::~PixFader () { + free_patterns (); } void -PixFader::set_border_colors (uint32_t left, uint32_t right) +PixFader::free_patterns () { - int r, g, b; - UINT_TO_RGB(left, &r, &g, &b); - left_r = r/255.0; - left_g = g/255.0; - left_b = b/255.0; - UINT_TO_RGB(right, &r, &g, &b); - right_r = r/255.0; - right_g = g/255.0; - right_b = b/255.0; + if (pattern) { + cairo_pattern_destroy (pattern); + pattern = 0; + } + if (texture_pattern) { + cairo_pattern_destroy (texture_pattern); + texture_pattern = 0; + } } void @@ -85,41 +76,63 @@ PixFader::create_patterns () Gdk::Color c = get_style()->get_fg (get_state()); float r, g, b; - if (pattern) { - cairo_pattern_destroy (pattern); - } - - if (shine_pattern) { - cairo_pattern_destroy (shine_pattern); - } + free_patterns (); r = c.get_red_p (); g = c.get_green_p (); b = c.get_blue_p (); + cairo_surface_t* texture_surface; + cairo_t* tc = 0; + const double texture_margin = 3.0; + if (_orien == VERT) { pattern = cairo_pattern_create_linear (0.0, 0.0, get_width(), 0); cairo_pattern_add_color_stop_rgba (pattern, 0, r*0.8,g*0.8,b*0.8, 1.0); cairo_pattern_add_color_stop_rgba (pattern, 1, r*0.6,g*0.6,b*0.6, 1.0); - shine_pattern = cairo_pattern_create_linear (0.0, 0.0, 15, 0); - cairo_pattern_add_color_stop_rgba (shine_pattern, 0, 1,1,1,0.0); - cairo_pattern_add_color_stop_rgba (shine_pattern, 0.2, 1,1,1,0.3); - cairo_pattern_add_color_stop_rgba (shine_pattern, 0.5, 1,1,1,0.0); - cairo_pattern_add_color_stop_rgba (shine_pattern, 1, 1,1,1,0.0); + if (girth > 10) { + texture_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, girth, 6); + tc = cairo_create (texture_surface); + + for (double x = texture_margin; x < girth - texture_margin; x += 3.0) { + cairo_set_source_rgba (tc, 0.533, 0.533, 0.580, 1.0); + cairo_rectangle (tc, x, 2, 2, 2); + cairo_fill (tc); + cairo_set_source_rgba (tc, 0.337, 0.345, 0.349, 1.0); + cairo_rectangle (tc, x, 2, 1, 1); + cairo_fill (tc); + } + } } else { + texture_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 6, girth); + tc = cairo_create (texture_surface); + pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height()); cairo_pattern_add_color_stop_rgba (pattern, 0, r*0.8,g*0.8,b*0.8, 1.0); cairo_pattern_add_color_stop_rgba (pattern, 1, r*0.6,g*0.6,b*0.6, 1.0); - shine_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height()); - cairo_pattern_add_color_stop_rgba (shine_pattern, 0, 1,1,1,0.0); - cairo_pattern_add_color_stop_rgba (shine_pattern, 0.2, 1,1,1,0.3); - cairo_pattern_add_color_stop_rgba (shine_pattern, 0.5, 1,1,1,0.0); - cairo_pattern_add_color_stop_rgba (shine_pattern, 1, 1,1,1,0.0); + if (girth > 10) { + for (double y = texture_margin; y < girth - texture_margin; y += 3) { + cairo_set_source_rgba (tc, 0.533, 0.533, 0.580, 1.0); + cairo_rectangle (tc, 0, y, 2, 2); + cairo_fill (tc); + cairo_set_source_rgba (tc, 0.337, 0.345, 0.349, 1.0); + cairo_rectangle (tc, 0, y, 1, 1); + cairo_fill (tc); + } + } + } + + if (texture_surface) { + texture_pattern = cairo_pattern_create_for_surface (texture_surface); + cairo_pattern_set_extend (texture_pattern, CAIRO_EXTEND_REPEAT); + + cairo_destroy (tc); + cairo_surface_destroy (texture_surface); } if ( !_text.empty()) { @@ -137,11 +150,14 @@ PixFader::create_patterns () } bool -PixFader::on_expose_event (GdkEventExpose*) +PixFader::on_expose_event (GdkEventExpose* ev) { Cairo::RefPtr<Cairo::Context> context = get_window()->create_cairo_context(); cairo_t* cr = context->cobj(); + cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height); + cairo_clip (cr); + if (!pattern) { create_patterns(); } @@ -154,34 +170,58 @@ PixFader::on_expose_event (GdkEventExpose*) float h = get_height(); float radius = CORNER_RADIUS; - /* black border */ - - cairo_set_source_rgb (cr, 0,0,0); + /* background/ border */ + cairo_set_source_rgb (cr, 0.290, 0.286, 0.337); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); /* draw active box */ + + cairo_matrix_t matrix; if (_orien == VERT) { - if (ds > h - FADER_RESERVE) + if (ds > h - FADER_RESERVE) { ds = h - FADER_RESERVE; + } cairo_set_source (cr, pattern); Gtkmm2ext::rounded_top_half_rectangle (cr, 1, 1+ds, w-1, h-(1+ds)-1, radius-1.5); cairo_fill (cr); + + if (texture_pattern) { + cairo_save (cr); + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + cairo_set_source (cr, texture_pattern); + cairo_matrix_init_translate (&matrix, -1, -(1+ds)); + cairo_pattern_set_matrix (texture_pattern, &matrix); + cairo_rectangle (cr, 1, 1+ds, w-1, h-(1+ds)-1); + cairo_fill (cr); + cairo_restore (cr); + } } else { - if (ds < FADER_RESERVE) + if (ds < FADER_RESERVE) { ds = FADER_RESERVE; + } cairo_set_source (cr, pattern); Gtkmm2ext::rounded_right_half_rectangle (cr, 1, 1, ds-1, h-1, radius-1.5); cairo_fill (cr); - + + if (texture_pattern) { + cairo_save (cr); + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + cairo_set_source (cr, texture_pattern); + cairo_matrix_init_translate (&matrix, -1, -1); + cairo_pattern_set_matrix (texture_pattern, &matrix); + cairo_rectangle (cr, 1, 1, ds-1, h-1); + cairo_fill (cr); + cairo_restore (cr); + } } - + /* draw the unity-position line if it's not at either end*/ if (unity_loc > 0) { if ( _orien == VERT) { @@ -246,14 +286,18 @@ PixFader::on_size_allocate (Gtk::Allocation& alloc) if (_orien == VERT) { span = alloc.get_height(); + girth = alloc.get_width (); } else { span = alloc.get_width(); + girth = alloc.get_height (); } update_unity_position (); - create_patterns(); - - queue_draw (); + + if (is_realized()) { + create_patterns(); + queue_draw (); + } } bool @@ -460,14 +504,8 @@ PixFader::display_span () void PixFader::set_fader_length (int l) { - if (_orien == VERT) { - span = l; - } else { - span = l; - } - + span = l; update_unity_position (); - queue_draw (); } @@ -537,3 +575,9 @@ PixFader::set_text (const std::string& str) queue_resize (); } +void +PixFader::on_state_changed (Gtk::StateType old_state) +{ + Widget::on_state_changed (old_state); + create_patterns (); +} diff --git a/libs/gtkmm2ext/slider_controller.cc b/libs/gtkmm2ext/slider_controller.cc index 76e28a7beb..e3c47f332e 100644 --- a/libs/gtkmm2ext/slider_controller.cc +++ b/libs/gtkmm2ext/slider_controller.cc @@ -28,8 +28,8 @@ using namespace Gtkmm2ext; using namespace PBD; -SliderController::SliderController (Gtk::Adjustment *adj, int orientation, int fader_length) - : PixFader (*adj, orientation, fader_length) +SliderController::SliderController (Gtk::Adjustment *adj, int orientation, int fader_length, int fader_girth) + : PixFader (*adj, orientation, fader_length, fader_girth) , spin (*adj, 0, 2) { spin.set_name ("SliderControllerValue"); @@ -54,9 +54,9 @@ SliderController::on_button_press_event (GdkEventButton *ev) return PixFader::on_button_press_event (ev); } -VSliderController::VSliderController (Gtk::Adjustment *adj, int fader_length, bool with_numeric) +VSliderController::VSliderController (Gtk::Adjustment *adj, int fader_length, int fader_girth, bool with_numeric) - : SliderController (adj, VERT, fader_length) + : SliderController (adj, VERT, fader_length, fader_girth) { if (with_numeric) { spin_frame.add (spin); @@ -67,10 +67,10 @@ VSliderController::VSliderController (Gtk::Adjustment *adj, int fader_length, bo } } -HSliderController::HSliderController (Gtk::Adjustment *adj, int fader_length, +HSliderController::HSliderController (Gtk::Adjustment *adj, int fader_length, int fader_girth, bool with_numeric) - : SliderController (adj, HORIZ, fader_length) + : SliderController (adj, HORIZ, fader_length, fader_girth) { if (with_numeric) { spin_frame.add (spin); |