diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-05-05 20:29:46 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-05-05 20:29:46 +0000 |
commit | 1ae1eeb25762887599fcc12e1fc9163c76014525 (patch) | |
tree | 410d49990b2a429dbb68c415b89096903d74f6ae /gtk2_ardour | |
parent | 958d5ffefd8cbd386ec334060b9e887797afa728 (diff) |
led\'s for solo-safe and solo-isolate, rather than a context menu (mixer strip only). not finished and some logic errors in terms of turning things on and off
git-svn-id: svn://localhost/ardour2/branches/3.0@7066 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/ardour3_ui_dark.rc.in | 14 | ||||
-rw-r--r-- | gtk2_ardour/led.cc | 120 | ||||
-rw-r--r-- | gtk2_ardour/led.h | 47 | ||||
-rw-r--r-- | gtk2_ardour/mixer_strip.cc | 29 | ||||
-rw-r--r-- | gtk2_ardour/route_ui.cc | 44 | ||||
-rw-r--r-- | gtk2_ardour/route_ui.h | 7 | ||||
-rw-r--r-- | gtk2_ardour/wscript | 1 |
7 files changed, 253 insertions, 9 deletions
diff --git a/gtk2_ardour/ardour3_ui_dark.rc.in b/gtk2_ardour/ardour3_ui_dark.rc.in index dc50a77a18..87dab6f39c 100644 --- a/gtk2_ardour/ardour3_ui_dark.rc.in +++ b/gtk2_ardour/ardour3_ui_dark.rc.in @@ -325,6 +325,18 @@ style "solo_button" = "small_button" fg[ACTIVE] = { 0, 0, 0 } } +style "solo_isolate_led" +{ + fg[ACTIVE] = { 1.0, 0, 0 } + fg[NORMAL] = { 1, 1, 1 } +} + +style "solo_safe_led" +{ + fg[ACTIVE] = { 0.26, 0.47, 0.69 } + fg[NORMAL] = { 0, 1.0, 0 } +} + style "solo_button_alternate" = "small_button" { # @@ -1787,3 +1799,5 @@ widget "*MidiListView*" style:highest "white_tree_view" widget "*ProcessorSelector*" style:highest "processor_list_display" widget "*PortMatrixLabel*" style:highest "small_text" widget "*MidiTracerTextView" style:highest "midi_tracer_textview" +widget "*SoloIsolatedLED" style:highest "solo_isolate_led" +widget "*SoloSafeLED" style:highest "solo_safe_led" diff --git a/gtk2_ardour/led.cc b/gtk2_ardour/led.cc new file mode 100644 index 0000000000..c751eb91e0 --- /dev/null +++ b/gtk2_ardour/led.cc @@ -0,0 +1,120 @@ +/* + Copyright (C) 2010 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 <iostream> +#include <cmath> +#include <algorithm> + +#include "led.h" + +using namespace Gdk; +using namespace Gtk; +using namespace Glib; + +LED::LED() + : _visual_state (0) + , _active (false) + , _red (0.0) + , _green (1.0) + , _blue (0.0) + +{ +} + +LED::~LED() +{ +} + +void +LED::render (cairo_t* cr) +{ + float diameter = std::min (_width, _height); + + //background + cairo_rectangle(cr, 0, 0, _width, _height); + cairo_stroke_preserve(cr); + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_fill(cr); + + cairo_translate(cr, _width/2, _height/2); + +#if 0 + //inset + cairo_pattern_t *pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, diameter); + cairo_pattern_add_color_stop_rgba (pat, 0, 0,0,0, 0.4); + cairo_pattern_add_color_stop_rgba (pat, 1, 1,1,1, 0.7); + cairo_arc (cr, 0, 0, diameter/2, 0, 2 * M_PI); + cairo_set_source (cr, pat); + cairo_fill (cr); + cairo_pattern_destroy (pat); + + //black ring + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_arc (cr, 0, 0, diameter/2-2, 0, 2 * M_PI); + cairo_fill(cr); + + //knob color + cairo_set_source_rgba (cr, _red, _green, _blue, _active ? 0.8 : 0.2); + cairo_arc (cr, 0, 0, diameter/2-3, 0, 2 * M_PI); + cairo_fill(cr); + + //reflection + cairo_scale(cr, 0.7, 0.7); + cairo_pattern_t *pat2 = cairo_pattern_create_linear (0.0, 0.0, 0.0, diameter/2-3); + cairo_pattern_add_color_stop_rgba (pat2, 0, 1,1,1, _active ? 0.4 : 0.2); + cairo_pattern_add_color_stop_rgba (pat2, 1, 1,1,1, 0.0); + cairo_arc (cr, 0, 0, diameter/2-3, 0, 2 * M_PI); + cairo_set_source (cr, pat2); + cairo_fill (cr); + cairo_pattern_destroy (pat2); +#endif + + cairo_set_source_rgba (cr, _red, _green, _blue, 1.0); + cairo_arc (cr, 0, 0, diameter/2-5, 0, 2 * M_PI); + cairo_fill(cr); + + cairo_stroke (cr); +} + +void +LED::set_visual_state (int32_t s) +{ + if (s != _visual_state) { + + _visual_state = s; + + RefPtr<Style> style = get_style(); + Color c; + + switch (_visual_state) { + case 0: + c = style->get_fg (STATE_NORMAL); + break; + default: + c = style->get_fg (STATE_ACTIVE); + break; + } + + _red = c.get_red_p (); + _green = c.get_green_p (); + _blue = c.get_blue_p (); + + set_dirty (); + } +} diff --git a/gtk2_ardour/led.h b/gtk2_ardour/led.h new file mode 100644 index 0000000000..69ff7a3ead --- /dev/null +++ b/gtk2_ardour/led.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2010 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 __gtk2_ardour_led_h__ +#define __gtk2_ardour_led_h__ + +#include <stdint.h> + +#include "cairo_widget.h" + +class LED : public CairoWidget +{ + public: + LED (); + virtual ~LED (); + + void set_visual_state (int32_t s); + int32_t visual_state() const { return _visual_state; } + + protected: + void render (cairo_t *); + + private: + int32_t _visual_state; + bool _active; + float _red; + float _green; + float _blue; +}; + +#endif /* __gtk2_ardour_led_h__ */ diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 6f3d10d94b..8bcb1ca0b9 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -54,6 +54,7 @@ #include "mixer_strip.h" #include "mixer_ui.h" #include "keyboard.h" +#include "led.h" #include "public_editor.h" #include "send_ui.h" #include "io_selector.h" @@ -84,7 +85,7 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, bool in_mixer) , panners (sess) , _mono_button (_("Mono")) , button_table (4, 2) - , middle_button_table (1, 2) + , middle_button_table (2, 2) , bottom_button_table (1, 2) , meter_point_label (_("pre")) , comment_button (_("Comments")) @@ -184,6 +185,22 @@ MixerStrip::init () solo_button->set_name ("MixerSoloButton"); invert_button->set_name ("MixerInvertButton"); + solo_isolated_led = manage (new LED); + solo_isolated_led->show (); + solo_isolated_led->set_no_show_all (true); + solo_isolated_led->set_name (X_("SoloIsolatedLED")); + solo_isolated_led->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); + solo_isolated_led->signal_button_release_event().connect (sigc::mem_fun (*this, &RouteUI::solo_isolate_button_release)); + UI::instance()->set_tip (solo_isolated_led, _("Isolate Solo"), ""); + + solo_safe_led = manage (new LED); + solo_safe_led->show (); + solo_safe_led->set_no_show_all (true); + solo_safe_led->set_name (X_("SoloSafeLED")); + solo_safe_led->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); + solo_safe_led->signal_button_release_event().connect (sigc::mem_fun (*this, &RouteUI::solo_safe_button_release)); + UI::instance()->set_tip (solo_safe_led, _("Lock Solo Status"), ""); + button_table.set_homogeneous (true); button_table.set_spacings (0); @@ -193,8 +210,10 @@ MixerStrip::init () middle_button_table.set_homogeneous (true); middle_button_table.set_spacings (0); - middle_button_table.attach (*mute_button, 0, 1, 0, 1); - middle_button_table.attach (*solo_button, 1, 2, 0, 1); + middle_button_table.attach (*solo_safe_led, 0, 1, 0, 1); + middle_button_table.attach (*solo_isolated_led, 1, 2, 0, 1); + middle_button_table.attach (*mute_button, 0, 1, 1, 2); + middle_button_table.attach (*solo_button, 1, 2, 1, 2); bottom_button_table.set_col_spacings (0); bottom_button_table.set_homogeneous (true); @@ -346,8 +365,12 @@ MixerStrip::set_route (boost::shared_ptr<Route> rt) if (route()->is_master()) { solo_button->hide (); + solo_isolated_led->hide (); + solo_safe_led->hide (); } else { solo_button->show (); + solo_isolated_led->show (); + solo_safe_led->show (); } if (_mixer_owned && (route()->is_master() || route()->is_monitor())) { diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 851a96da5a..3c424f446b 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -35,6 +35,7 @@ #include "ardour_ui.h" #include "editor.h" #include "route_ui.h" +#include "led.h" #include "keyboard.h" #include "utils.h" #include "prompter.h" @@ -99,6 +100,8 @@ RouteUI::init () main_mute_check = 0; solo_safe_check = 0; solo_isolated_check = 0; + solo_isolated_led = 0; + solo_safe_led = 0; ignore_toggle = false; _solo_release = 0; _mute_release = 0; @@ -372,11 +375,14 @@ RouteUI::solo_press(GdkEventButton* ev) if (Keyboard::is_context_menu_event (ev)) { - if (solo_menu == 0) { - build_solo_menu (); - } - - solo_menu->popup (1, ev->time); + if (!solo_isolated_led) { + + if (solo_menu == 0) { + build_solo_menu (); + } + + solo_menu->popup (1, ev->time); + } } else { @@ -811,7 +817,16 @@ RouteUI::update_solo_display () set_button_names (); - solo_button->set_visual_state (solo_visual_state_with_isolate (_route)); + if (solo_isolated_led) { + cerr << _route->name() << " reset iso vis = " << (_route->solo_isolated() ? 1 : 0) << endl; + solo_isolated_led->set_visual_state (_route->solo_isolated() ? 1 : 0); + } + + if (solo_safe_led) { + solo_safe_led->set_visual_state (_route->solo_safe() ? 1 : 0); + } + + solo_button->set_visual_state (solo_visual_state (_route)); } void @@ -1055,6 +1070,23 @@ RouteUI::muting_change () } } +bool +RouteUI::solo_isolate_button_release (GdkEventButton* ev) +{ + bool view = (solo_isolated_led->visual_state() != 0); + cerr << _route->name() << "button release, view is " << view << " set to " << !view << endl; + _route->set_solo_isolated (!view, this); + cerr << "DONE with SSI\n"; + return true; +} + +bool +RouteUI::solo_safe_button_release (GdkEventButton* ev) +{ + _route->set_solo_safe (!(solo_safe_led->visual_state() > 0), this); + return true; +} + void RouteUI::toggle_solo_isolated (Gtk::CheckMenuItem* check) { diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index 1dae38d9d9..cc11b18094 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -47,6 +47,7 @@ namespace Gtk { } class BindableToggleButton; +class LED; class RouteUI : public virtual AxisView { @@ -89,6 +90,9 @@ class RouteUI : public virtual AxisView BindableToggleButton* rec_enable_button; /* audio tracks */ BindableToggleButton* show_sends_button; /* busses */ + LED* solo_safe_led; + LED* solo_isolated_led; + Gtk::Label solo_button_label; Gtk::Label mute_button_label; Gtk::Label invert_button_label; @@ -144,6 +148,9 @@ class RouteUI : public virtual AxisView void solo_isolated_toggle (void*, Gtk::CheckMenuItem*); void toggle_solo_isolated (Gtk::CheckMenuItem*); + bool solo_isolate_button_release (GdkEventButton*); + bool solo_safe_button_release (GdkEventButton*); + void solo_safe_toggle (void*, Gtk::CheckMenuItem*); void toggle_solo_safe (Gtk::CheckMenuItem*); diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 7ec88b3751..1d87d395e7 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -121,6 +121,7 @@ gtk2_ardour_sources = [ 'keyboard.cc', 'keyeditor.cc', 'latency_gui.cc', + 'led.cc', 'level_meter.cc', 'lineset.cc', 'location_ui.cc', |