update slider rendering & set style for faders
authorRobin Gareus <robin@gareus.org>
Sun, 5 Jan 2014 12:07:31 +0000 (13:07 +0100)
committerRobin Gareus <robin@gareus.org>
Sun, 5 Jan 2014 12:07:31 +0000 (13:07 +0100)
* render background -- outside of rounded corners
* visually align unity-location with fader at 0.
* sharp lines (no more AA blur) x/y offset, radius

gtk2_ardour/ardour3_styles.rc.in
gtk2_ardour/ardour3_widget_list.rc
gtk2_ardour/processor_box.cc
gtk2_ardour/return_ui.cc
gtk2_ardour/send_ui.cc
gtk2_ardour/sfdb_ui.cc
libs/ardour/lv2_plugin.cc
libs/gtkmm2ext/pixfader.cc

index 8b5b5e4c99e460730738265b4dc28ae36ffba45c..188c57b547e6fbe6548ae0d29b58459459e838f8 100644 (file)
@@ -731,6 +731,19 @@ style "midi_track_base" = "default"
   bg[SELECTED] = @@COLPREFIX@_bg
 }
 
+style "audio_track_fader" = "gain_fader"
+{
+  bg[PRELIGHT] = @@COLPREFIX@_audio_track
+}
+style "audio_bus_fader" = "gain_fader"
+{
+  bg[PRELIGHT] = @@COLPREFIX@_audio_bus
+}
+style "midi_track_fader" = "gain_fader"
+{
+  bg[PRELIGHT] = @@COLPREFIX@_midi_track
+}
+
 style "audio_track_metrics" = "audio_track_base"
 {
        font_name = "@FONT_TINY@"
@@ -815,7 +828,9 @@ style "plugin_slider"
        bg[ACTIVE] = shade (0.6, @@COLPREFIX@_lightest)
        bg[INSENSITIVE] = shade (0.6, @@COLPREFIX@_lightest)
        bg[SELECTED] = shade (0.6, @@COLPREFIX@_lightest)
-       bg[PRELIGHT] = shade (0.6, @@COLPREFIX@_lightest)
+
+       # outer round-corner-background (pixslider does its own hover prelight)
+       bg[PRELIGHT] = @@COLPREFIX@_bg
 
        # the numeric display
 
@@ -826,6 +841,12 @@ style "plugin_slider"
        text[PRELIGHT] = @@COLPREFIX@_text
 }
 
+style "processor_control_slider"  = "plugin_slider"
+{
+       bg[PRELIGHT] = @@COLPREFIX@_darkest
+       bg[NORMAL] = @@COLPREFIX@_bg
+}
+
 style "track_list_display" = "small_bold_text"
 {
        text[NORMAL] = @@COLPREFIX@_text
index 0e7075cef4410de6894483816e0d4771d18e2cb8..d9fdd2eafa0acca9246322f9381743341967a93e 100644 (file)
@@ -186,9 +186,13 @@ widget "*AudioMidiTrackMetricsInactive" style:highest "midi_track_metrics_inacti
 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 "*SendUIFader" style:highest "plugin_slider"
+widget "*ReturnUIFader" style:highest "plugin_slider"
+
+widget "*AudioTrackFader" style:highest "audio_track_fader"
+widget "*MidiTrackFader" style:highest "midi_track_fader"
+widget "*AudioBusFader" style:highest "audio_bus_fader"
 
 widget "*BusControlsBaseUnselected" style:highest "audio_bus_base"
 widget "*TrackSeparator" style:highest "track_separator"
@@ -234,6 +238,7 @@ widget "*MotionControllerValue*" style:highest "small_entry"
 widget "*ParameterValueDisplay" style:highest "medium_bold_entry"
 widget "*PluginUIClickBox" style:highest "medium_bold_entry"
 widget "*PluginUIClickBox*" style:highest "medium_bold_entry"
+widget "*ProcessorControlSlider" style:highest "processor_control_slider"
 widget "*PluginSlider" style:highest "plugin_slider"
 widget "*GainFader" style:highest "plugin_slider"
 widget "*MixerTrackCommentArea" style:highest "option_entry"
index bbadd775e5d4b43f142364ede8445d9cb713633a..81bb5e42c356770c84a8dba855502eff2cd9ef78 100644 (file)
@@ -464,7 +464,7 @@ ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string
 
        } else {
                
-               _slider.set_name ("PluginSlider");
+               _slider.set_name ("ProcessorControlSlider");
                _slider.set_text (_name);
 
                box.add (_slider);
index 592fff0a0e6603a5e964a3734d8fb5402d0cf526..92846af4697522dc4cbc36b7f7b5ba07f462b7a1 100644 (file)
@@ -42,7 +42,7 @@ ReturnUI::ReturnUI (Gtk::Window* parent, boost::shared_ptr<Return> r, Session* s
        _gpm.set_controls (boost::shared_ptr<Route>(), r->meter(), r->amp());
 
        _hbox.pack_start (_gpm, true, true);
-       set_name ("ReturnUIFrame");
+       set_name (X_("ReturnUIFrame"));
 
        _vbox.set_spacing (5);
        _vbox.set_border_width (5);
@@ -61,7 +61,7 @@ ReturnUI::ReturnUI (Gtk::Window* parent, boost::shared_ptr<Return> r, Session* s
        _return->input()->changed.connect (input_change_connection, invalidator (*this), boost::bind (&ReturnUI::ins_changed, this, _1, _2), gui_context());
 
        _gpm.setup_meters ();
-       _gpm.set_fader_name ("ReturnUIFrame");
+       _gpm.set_fader_name (X_("ReturnUIFader"));
 
        // screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (sigc::mem_fun (*this, &ReturnUI::update));
        fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (sigc::mem_fun (*this, &ReturnUI::fast_update));
index 1bc4e031f0467c766556cc5e14ae7eda1aac56e9..1fead7308440a9b2bec1256a1a0b5d6816c7862f 100644 (file)
@@ -46,7 +46,7 @@ SendUI::SendUI (Gtk::Window* parent, boost::shared_ptr<Send> s, Session* session
        _gpm.set_controls (boost::shared_ptr<Route>(), s->meter(), s->amp());
 
        _hbox.pack_start (_gpm, true, true);
-       set_name ("SendUIFrame");
+       set_name (X_("SendUIFrame"));
 
        _vbox.set_spacing (5);
        _vbox.set_border_width (5);
@@ -77,7 +77,7 @@ SendUI::SendUI (Gtk::Window* parent, boost::shared_ptr<Send> s, Session* session
        _panners.setup_pan ();
 
        _gpm.setup_meters ();
-       _gpm.set_fader_name ("SendUIFrame");
+       _gpm.set_fader_name (X_("SendUIFader"));
 
        // screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (
        //              sigc::mem_fun (*this, &SendUI::update));
index 4944ef41a0c3ed7375ea04d0fc1e92dfa540be08..9b3d78e86d94ce133c99ea086874c0c2fc675f9e 100644 (file)
@@ -707,7 +707,7 @@ SoundFileBrowser::add_gain_meter ()
        boost::shared_ptr<Route> r = _session->the_auditioner ();
 
        gm->set_controls (r, r->shared_peak_meter(), r->amp());
-       gm->set_fader_name (X_("AudioTrackFader"));
+       gm->set_fader_name (X_("GainFader"));
 
        meter_packer.set_border_width (12);
        meter_packer.pack_start (*gm, false, true);
index a1d9de1e534c6e50388e11ab6e60de5fc0e1e8f7..36b77e6d59fb8a8f287defe69dceac24f960f34b 100644 (file)
@@ -1022,8 +1022,10 @@ LV2Plugin::load_preset(PresetRecord r)
        LilvWorld* world = _world.world;
        LilvNode*  pset  = lilv_new_uri(world, r.uri.c_str());
        LilvState* state = lilv_state_new_from_world(world, _uri_map.urid_map(), pset);
+       printf("LV2Plugin::load_preset %s\n", r.uri.c_str());
 
        if (state) {
+               printf("found state\n");
                lilv_state_restore(state, _impl->instance, set_port_value, this, 0, NULL);
                lilv_state_free(state);
        }
@@ -1093,7 +1095,13 @@ LV2Plugin::do_save_preset(string name)
 
        lilv_state_free(state);
 
-       return Glib::filename_to_uri(Glib::build_filename(bundle, file_name));
+       std::string uri = Glib::filename_to_uri(Glib::build_filename(bundle, file_name));
+       LilvNode *node = lilv_new_uri(_world.world, uri.c_str());
+       lilv_world_load_bundle(_world.world, node);
+       lilv_node_free(node);
+       printf("LV2Plugin::do_save_preset %s\n", uri.c_str());
+
+       return uri;
 }
 
 void
index 7007cf0efe8c9ee52ba72c6f42b8e0a6dc0ce9f2..22ed0dbb278e690bcaa6f3115eda5945b7b9db80 100644 (file)
@@ -33,7 +33,9 @@ using namespace Gtk;
 using namespace std;
 
 #define CORNER_RADIUS 4
-#define FADER_RESERVE (2*CORNER_RADIUS)
+#define CORNER_SIZE   2
+#define CORNER_OFFSET 1
+#define FADER_RESERVE 5
 
 std::list<PixFader::FaderImage*> PixFader::_patterns;
 
@@ -111,11 +113,8 @@ PixFader::create_patterns ()
 
        cairo_surface_t* surface;
        cairo_t* tc = 0;
-       float radius = CORNER_RADIUS;
 
-       double w = get_width();
-       
-       if (w <= 1 || get_height() <= 1) {
+       if (get_width() <= 1 || get_height() <= 1) {
                return;
        }
 
@@ -142,13 +141,12 @@ PixFader::create_patterns ()
                
                /* paint lower shade */
                
-               w -= 2.0;
-
-               shade_pattern = cairo_pattern_create_linear (0.0, 0.0, w, 0);
+               shade_pattern = cairo_pattern_create_linear (0.0, 0.0, get_width() - 2 - CORNER_OFFSET , 0);
                cairo_pattern_add_color_stop_rgba (shade_pattern, 0, fr*0.8,fg*0.8,fb*0.8, 1.0);
                cairo_pattern_add_color_stop_rgba (shade_pattern, 1, fr*0.6,fg*0.6,fb*0.6, 1.0);
                cairo_set_source (tc, shade_pattern);
-               Gtkmm2ext::rounded_top_half_rectangle (tc, 1.0, get_height(), w, get_height(), radius-1.5);
+               Gtkmm2ext::rounded_top_half_rectangle (tc, CORNER_OFFSET, get_height() + CORNER_OFFSET,
+                               get_width() - CORNER_SIZE, get_height(), CORNER_RADIUS);
                cairo_fill (tc);
 
                cairo_pattern_destroy (shade_pattern);
@@ -175,7 +173,8 @@ PixFader::create_patterns ()
                cairo_pattern_add_color_stop_rgba (shade_pattern, 0, fr*0.8,fg*0.8,fb*0.8, 1.0);
                cairo_pattern_add_color_stop_rgba (shade_pattern, 1, fr*0.6,fg*0.6,fb*0.6, 1.0);
                cairo_set_source (tc, shade_pattern);
-               Gtkmm2ext::rounded_right_half_rectangle (tc, 0, 1, get_width(), get_height() - 2.0, radius-1.5);
+               Gtkmm2ext::rounded_right_half_rectangle (tc, CORNER_OFFSET, CORNER_OFFSET,
+                               get_width() - CORNER_OFFSET, get_height() - CORNER_SIZE, CORNER_RADIUS);
                cairo_fill (tc);
                cairo_pattern_destroy (shade_pattern);
                
@@ -218,7 +217,6 @@ PixFader::on_expose_event (GdkEventExpose* ev)
                cairo_set_source_rgb (cr, br, bg, bb);
                cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
                cairo_fill (cr);
-
                return true;
        }
                   
@@ -229,18 +227,27 @@ PixFader::on_expose_event (GdkEventExpose* ev)
        float w = get_width();
        float h = get_height();
 
+       Gdk::Color c = get_style()->get_bg (Gtk::STATE_PRELIGHT);
+       cairo_set_source_rgb (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p());
+       cairo_rectangle (cr, 0, 0, w, h);
+       cairo_fill(cr);
+
+       cairo_set_line_width (cr, 1);
+       cairo_set_source_rgba (cr, 0, 0, 0, 1.0);
+
        cairo_matrix_t matrix;
+       Gtkmm2ext::rounded_rectangle (cr, CORNER_OFFSET, CORNER_OFFSET, w-CORNER_SIZE, h-CORNER_SIZE, CORNER_RADIUS);
+       cairo_stroke_preserve(cr);
 
        if (_orien == VERT) {
 
-               if (ds > h - FADER_RESERVE) {
-                       ds = h - FADER_RESERVE;
+               if (ds > h - FADER_RESERVE - CORNER_OFFSET) {
+                       ds = h - FADER_RESERVE - CORNER_OFFSET;
                }
 
                cairo_set_source (cr, pattern);
                cairo_matrix_init_translate (&matrix, 0, (h - ds));
                cairo_pattern_set_matrix (pattern, &matrix);
-               Gtkmm2ext::rounded_rectangle (cr, 0, 0, w, h, CORNER_RADIUS-1.5);
                cairo_fill (cr);
 
        } else {
@@ -264,7 +271,6 @@ PixFader::on_expose_event (GdkEventExpose* ev)
                cairo_set_source (cr, pattern);
                cairo_matrix_init_translate (&matrix, w - ds, 0);
                cairo_pattern_set_matrix (pattern, &matrix);
-               Gtkmm2ext::rounded_rectangle (cr, 0, 0, w, h, CORNER_RADIUS-1.5);
                cairo_fill (cr);
        }
                
@@ -276,14 +282,14 @@ PixFader::on_expose_event (GdkEventExpose* ev)
                context->set_source_rgba (c.get_red_p()*1.5, c.get_green_p()*1.5, c.get_blue_p()*1.5, 0.85);
                if ( _orien == VERT) {
                        if (unity_loc < h ) {
-                               context->move_to (1.5, unity_loc + .5);
-                               context->line_to (girth - 1.5, unity_loc + .5);
+                               context->move_to (1.5, unity_loc + CORNER_OFFSET + .5);
+                               context->line_to (girth - 1.5, unity_loc + CORNER_OFFSET + .5);
                                context->stroke ();
                        }
                } else {
                        if ( unity_loc < w ){
-                               context->move_to (unity_loc + .5, 1.5);
-                               context->line_to (unity_loc + .5, girth - 1.5);
+                               context->move_to (unity_loc - CORNER_OFFSET + .5, 1.5);
+                               context->line_to (unity_loc - CORNER_OFFSET + .5, girth - 1.5);
                                context->stroke ();
                        }
                }
@@ -299,11 +305,11 @@ PixFader::on_expose_event (GdkEventExpose* ev)
        } 
        
        if (!get_sensitive()) {
-               Gtkmm2ext::rounded_rectangle (cr, 0, 0, get_width(), get_height(), 3);
+               Gtkmm2ext::rounded_rectangle (cr, CORNER_OFFSET, CORNER_OFFSET, w-CORNER_SIZE, h-CORNER_SIZE, CORNER_RADIUS);
                cairo_set_source_rgba (cr, 0.505, 0.517, 0.525, 0.4);
                cairo_fill (cr);
        } else if (_hovering) {
-               Gtkmm2ext::rounded_rectangle (cr, 0, 0, get_width(), get_height(), 3);
+               Gtkmm2ext::rounded_rectangle (cr, CORNER_OFFSET, CORNER_OFFSET, w-CORNER_SIZE, h-CORNER_SIZE, CORNER_RADIUS);
                cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.1);
                cairo_fill (cr);
        }
@@ -620,6 +626,7 @@ PixFader::on_state_changed (Gtk::StateType old_state)
 {
        Widget::on_state_changed (old_state);
        create_patterns ();
+       queue_draw ();
 }
 
 void
@@ -636,4 +643,5 @@ PixFader::on_style_changed (const Glib::RefPtr<Gtk::Style>&)
        */
 
        pattern = 0;
+       queue_draw ();
 }