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
This commit is contained in:
Paul Davis 2010-05-05 20:29:46 +00:00
parent 958d5ffefd
commit 1ae1eeb257
8 changed files with 255 additions and 9 deletions

View File

@ -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"

120
gtk2_ardour/led.cc Normal file
View File

@ -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 ();
}
}

47
gtk2_ardour/led.h Normal file
View File

@ -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__ */

View File

@ -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())) {

View File

@ -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)
{

View File

@ -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*);

View File

@ -121,6 +121,7 @@ gtk2_ardour_sources = [
'keyboard.cc',
'keyeditor.cc',
'latency_gui.cc',
'led.cc',
'level_meter.cc',
'lineset.cc',
'location_ui.cc',

View File

@ -696,6 +696,8 @@ Route::set_solo_isolated (bool yn, void *src)
_route_group->apply (&Route::set_solo_isolated, yn, _route_group);
return;
}
cerr << name() << " SET SOLO ISO " << yn << " cur = " << _solo_isolated << endl;
/* forward propagate solo-isolate status to everything fed by this route, but not those via sends only */