separate header dependencies on button joiner, and make each button joiner look up the right color for the type of buttons it contains

git-svn-id: svn://localhost/ardour2/branches/3.0@11440 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-02-03 18:49:43 +00:00
parent c21c9e6662
commit 1f0f5e89bb
6 changed files with 23 additions and 20 deletions

View file

@ -154,8 +154,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
, play_selection_controllable (new TransportControllable ("transport play selection", *this, TransportControllable::PlaySelection)) , play_selection_controllable (new TransportControllable ("transport play selection", *this, TransportControllable::PlaySelection))
, rec_controllable (new TransportControllable ("transport rec-enable", *this, TransportControllable::RecordEnable)) , rec_controllable (new TransportControllable ("transport rec-enable", *this, TransportControllable::RecordEnable))
, transport_joiner (play_selection_button, roll_button)
, auto_return_button (ArdourButton::led_default_elements) , auto_return_button (ArdourButton::led_default_elements)
, auto_play_button (ArdourButton::led_default_elements) , auto_play_button (ArdourButton::led_default_elements)
, auto_input_button (ArdourButton::led_default_elements) , auto_input_button (ArdourButton::led_default_elements)

View file

@ -67,7 +67,6 @@
#include "ardour_dialog.h" #include "ardour_dialog.h"
#include "ardour_button.h" #include "ardour_button.h"
#include "button_joiner.h"
#include "editing.h" #include "editing.h"
#include "ui_config.h" #include "ui_config.h"
#include "window_proxy.h" #include "window_proxy.h"
@ -80,6 +79,7 @@ class ArdourStartup;
class ArdourKeyboard; class ArdourKeyboard;
class AudioClock; class AudioClock;
class BundleManager; class BundleManager;
class ButtonJoiner;
class ConnectionEditor; class ConnectionEditor;
class KeyEditor; class KeyEditor;
class LocationUIWindow; class LocationUIWindow;
@ -424,7 +424,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
ArdourButton play_selection_button; ArdourButton play_selection_button;
ArdourButton rec_button; ArdourButton rec_button;
ButtonJoiner transport_joiner; ButtonJoiner* transport_joiner;
void toggle_external_sync (); void toggle_external_sync ();
void toggle_time_master (); void toggle_time_master ();

View file

@ -48,6 +48,7 @@
#include "public_editor.h" #include "public_editor.h"
#include "audio_clock.h" #include "audio_clock.h"
#include "actions.h" #include "actions.h"
#include "button_joiner.h"
#include "utils.h" #include "utils.h"
#include "theme_manager.h" #include "theme_manager.h"
#include "midi_tracer.h" #include "midi_tracer.h"
@ -133,9 +134,7 @@ ARDOUR_UI::setup_tooltips ()
set_tip (goto_end_button, _("Go to end of session")); set_tip (goto_end_button, _("Go to end of session"));
set_tip (auto_loop_button, _("Play loop range")); set_tip (auto_loop_button, _("Play loop range"));
set_tip (midi_panic_button, _("MIDI Panic\nSend note off and reset controller messages on all MIDI channels")); set_tip (midi_panic_button, _("MIDI Panic\nSend note off and reset controller messages on all MIDI channels"));
set_tip (*transport_joiner, _("Always Play Range Selection (if any)"));
set_tip (transport_joiner, _("Always Play Range Selection (if any)"));
set_tip (auto_return_button, _("Return to last playback start when stopped")); set_tip (auto_return_button, _("Return to last playback start when stopped"));
set_tip (auto_play_button, _("Start playback after any locate")); set_tip (auto_play_button, _("Start playback after any locate"));
set_tip (auto_input_button, _("Be sensible about input monitoring")); set_tip (auto_input_button, _("Be sensible about input monitoring"));
@ -295,8 +294,10 @@ ARDOUR_UI::setup_transport ()
act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync")); act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
sync_button.set_related_action (act); sync_button.set_related_action (act);
transport_joiner = manage (new ButtonJoiner ("transport button", play_selection_button, roll_button));
act = ActionManager::get_action (X_("Transport"), X_("AlwaysPlayRange")); act = ActionManager::get_action (X_("Transport"), X_("AlwaysPlayRange"));
transport_joiner.set_related_action (act); transport_joiner->set_related_action (act);
/* clocks, etc. */ /* clocks, etc. */
@ -367,7 +368,7 @@ ARDOUR_UI::setup_transport ()
play_selection_button.set_rounded_corner_mask (0x1); /* upper left only */ play_selection_button.set_rounded_corner_mask (0x1); /* upper left only */
roll_button.set_rounded_corner_mask (0x2); /* upper right only */ roll_button.set_rounded_corner_mask (0x2); /* upper right only */
tbox2->pack_start (transport_joiner, false, false); tbox2->pack_start (*transport_joiner, false, false);
tbox3->pack_start (stop_button, false, false); tbox3->pack_start (stop_button, false, false);
tbox3->pack_start (rec_button, false, false, 6); tbox3->pack_start (rec_button, false, false, 6);

View file

@ -1,8 +1,10 @@
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <gtkmm/toggleaction.h> #include <gtkmm/toggleaction.h>
#include "pbd/compose.h"
#include "gtkmm2ext/utils.h" #include "gtkmm2ext/utils.h"
#include "gtkmm2ext/rgb_macros.h" #include "gtkmm2ext/rgb_macros.h"
@ -11,9 +13,10 @@
using namespace Gtk; using namespace Gtk;
ButtonJoiner::ButtonJoiner (Gtk::Widget& l, Gtk::Widget& r) ButtonJoiner::ButtonJoiner (const std::string& str, Gtk::Widget& l, Gtk::Widget& r)
: left (l) : left (l)
, right (r) , right (r)
, name (str)
, active_fill_pattern (0) , active_fill_pattern (0)
, inactive_fill_pattern (0) , inactive_fill_pattern (0)
{ {
@ -189,15 +192,15 @@ ButtonJoiner::set_colors ()
active_fill_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height()); active_fill_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height());
inactive_fill_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height()); inactive_fill_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, get_height());
start_color = ARDOUR_UI::config()->color_by_name ("transport button: fill start"); start_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill start", name));
end_color = ARDOUR_UI::config()->color_by_name ("transport button: fill end"); end_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill end", name));
UINT_TO_RGBA (start_color, &r, &g, &b, &a); UINT_TO_RGBA (start_color, &r, &g, &b, &a);
cairo_pattern_add_color_stop_rgba (inactive_fill_pattern, 0, r/255.0,g/255.0,b/255.0, a/255.0); cairo_pattern_add_color_stop_rgba (inactive_fill_pattern, 0, r/255.0,g/255.0,b/255.0, a/255.0);
UINT_TO_RGBA (end_color, &r, &g, &b, &a); UINT_TO_RGBA (end_color, &r, &g, &b, &a);
cairo_pattern_add_color_stop_rgba (inactive_fill_pattern, 1, r/255.0,g/255.0,b/255.0, a/255.0); cairo_pattern_add_color_stop_rgba (inactive_fill_pattern, 1, r/255.0,g/255.0,b/255.0, a/255.0);
start_color = ARDOUR_UI::config()->color_by_name ("transport button: fill start active"); start_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill start active", name));
end_color = ARDOUR_UI::config()->color_by_name ("transport button: fill end active"); end_color = ARDOUR_UI::config()->color_by_name (string_compose ("%1: fill end active", name));
UINT_TO_RGBA (start_color, &r, &g, &b, &a); UINT_TO_RGBA (start_color, &r, &g, &b, &a);
cairo_pattern_add_color_stop_rgba (active_fill_pattern, 0, r/255.0,g/255.0,b/255.0, a/255.0); cairo_pattern_add_color_stop_rgba (active_fill_pattern, 0, r/255.0,g/255.0,b/255.0, a/255.0);
UINT_TO_RGBA (end_color, &r, &g, &b, &a); UINT_TO_RGBA (end_color, &r, &g, &b, &a);

View file

@ -10,7 +10,7 @@
class ButtonJoiner : public CairoWidget, public Gtkmm2ext::Activatable { class ButtonJoiner : public CairoWidget, public Gtkmm2ext::Activatable {
public: public:
ButtonJoiner (Gtk::Widget&, Gtk::Widget&); ButtonJoiner (const std::string&, Gtk::Widget&, Gtk::Widget&);
~ButtonJoiner (); ~ButtonJoiner ();
void set_related_action (Glib::RefPtr<Gtk::Action>); void set_related_action (Glib::RefPtr<Gtk::Action>);
@ -28,11 +28,11 @@ class ButtonJoiner : public CairoWidget, public Gtkmm2ext::Activatable {
void action_toggled (); void action_toggled ();
private: private:
Gtk::Widget& left; Gtk::Widget& left;
Gtk::Widget& right; Gtk::Widget& right;
Gtk::HBox packer; Gtk::HBox packer;
Gtk::Alignment align; Gtk::Alignment align;
std::string name;
cairo_pattern_t* active_fill_pattern; cairo_pattern_t* active_fill_pattern;
cairo_pattern_t* inactive_fill_pattern; cairo_pattern_t* inactive_fill_pattern;

View file

@ -86,6 +86,7 @@
#include "audio_time_axis.h" #include "audio_time_axis.h"
#include "automation_time_axis.h" #include "automation_time_axis.h"
#include "bundle_manager.h" #include "bundle_manager.h"
#include "button_joiner.h"
#include "canvas-noevent-text.h" #include "canvas-noevent-text.h"
#include "canvas_impl.h" #include "canvas_impl.h"
#include "crossfade_edit.h" #include "crossfade_edit.h"
@ -2787,7 +2788,7 @@ Editor::setup_toolbar ()
/* make them just a bit bigger */ /* make them just a bit bigger */
mouse_move_button.set_size_request (-1, 25); mouse_move_button.set_size_request (-1, 25);
smart_mode_joiner = manage (new ButtonJoiner (mouse_move_button, mouse_select_button)); smart_mode_joiner = manage (new ButtonJoiner ("mouse mode button", mouse_move_button, mouse_select_button));
smart_mode_joiner->set_related_action (smart_mode_action); smart_mode_joiner->set_related_action (smart_mode_action);
mouse_move_button.set_rounded_corner_mask (0x1); // upper left only mouse_move_button.set_rounded_corner_mask (0x1); // upper left only