13
0

MCP: possible support for metering

git-svn-id: svn://localhost/ardour2/branches/3.0@11842 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-04-09 00:03:35 +00:00
parent ad06e7cb8d
commit 89aed48f92
3 changed files with 60 additions and 26 deletions

View File

@ -13,21 +13,38 @@
using namespace Gtk;
ButtonJoiner::ButtonJoiner (const std::string& str, Gtk::Widget& lw, Gtk::Widget& rw)
ButtonJoiner::ButtonJoiner (const std::string& str, Gtk::Widget& lw, Gtk::Widget& rw, bool central_joiner)
: left (lw)
, right (rw)
, name (str)
, active_fill_pattern (0)
, inactive_fill_pattern (0)
, central_link (central_joiner)
{
packer.set_homogeneous (true);
if (central_link) {
packer.set_spacing (20);
}
packer.pack_start (left);
packer.pack_start (right);
packer.show ();
/* this alignment is how we position the box that holds the two widgets
within our allocation, and how we request more space around them.
*/
align.add (packer);
align.set (0.5, 1.0);
align.set_padding (9, 0, 9, 9);
if (!central_link) {
align.set (0.5, 1.0);
align.set_padding (9, 0, 9, 9);
} else {
align.set (0.5, 0.5);
align.set_padding (1, 1, 1, 1);
}
align.show ();
add (align);
@ -73,22 +90,44 @@ ButtonJoiner::render (cairo_t* cr)
cairo_set_source (cr, active_fill_pattern);
}
/* outer rect */
Gtkmm2ext::rounded_top_rectangle (cr, 0, 0, get_width(), h, 8);
cairo_fill_preserve (cr);
/* outer edge */
cairo_set_line_width (cr, 1.5);
cairo_set_source_rgb (cr, border_r, border_g, border_b);
cairo_stroke (cr);
/* inner "edge" */
Gtkmm2ext::rounded_top_rectangle (cr, 8, 8, get_width() - 16, h - 8, 6);
cairo_stroke (cr);
if (!central_link) {
/* outer rect */
Gtkmm2ext::rounded_top_rectangle (cr, 0, 0, get_width(), h, 8);
cairo_fill_preserve (cr);
/* outer edge */
cairo_set_line_width (cr, 1.5);
cairo_set_source_rgb (cr, border_r, border_g, border_b);
cairo_stroke (cr);
/* inner "edge" */
Gtkmm2ext::rounded_top_rectangle (cr, 8, 8, get_width() - 16, h - 8, 6);
cairo_stroke (cr);
} else {
if (get_active()) {
Gtkmm2ext::rounded_top_rectangle (cr, 0, 0, (get_width() - 20.0)/2.0 , h, 8);
cairo_fill_preserve (cr);
Gtkmm2ext::rounded_top_rectangle (cr, (get_width() - 20.)/2.0 + 20.0, 0.0,
(get_width() - 20.0)/2.0 , h, 8);
cairo_fill_preserve (cr);
cairo_move_to (cr, get_width()/2.0 - 10.0, h/2.0);
cairo_set_line_width (cr, 1.5);
cairo_rel_line_to (cr, 20.0, 0.0);
cairo_set_source (cr, active_fill_pattern);
cairo_stroke (cr);
} else {
cairo_arc (cr, get_width()/2.0, h/2.0, 6.0, 0, M_PI*2.0);
cairo_set_line_width (cr, 1.5);
cairo_fill_preserve (cr);
cairo_set_source_rgb (cr, border_r, border_g, border_b);
cairo_stroke (cr);
}
}
}
void

View File

@ -10,7 +10,7 @@
class ButtonJoiner : public CairoWidget, public Gtkmm2ext::Activatable {
public:
ButtonJoiner (const std::string&, Gtk::Widget&, Gtk::Widget&);
ButtonJoiner (const std::string&, Gtk::Widget&, Gtk::Widget&, bool central_link = false);
~ButtonJoiner ();
void set_related_action (Glib::RefPtr<Gtk::Action>);
@ -35,6 +35,7 @@ class ButtonJoiner : public CairoWidget, public Gtkmm2ext::Activatable {
std::string name;
cairo_pattern_t* active_fill_pattern;
cairo_pattern_t* inactive_fill_pattern;
bool central_link;
double border_r;
double border_g;
double border_b;

View File

@ -2817,15 +2817,9 @@ Editor::setup_toolbar ()
/* make them just a bit bigger */
mouse_move_button.set_size_request (-1, 25);
smart_mode_joiner = manage (new ButtonJoiner ("mouse mode button", mouse_move_button, mouse_select_button));
smart_mode_joiner = manage (new ButtonJoiner ("mouse mode button", mouse_move_button, mouse_select_button, true));
smart_mode_joiner->set_related_action (smart_mode_action);
mouse_move_button.set_elements (ArdourButton::Element (ArdourButton::Body|ArdourButton::Text));
mouse_select_button.set_elements (ArdourButton::Element (ArdourButton::Body|ArdourButton::Text));
mouse_move_button.set_rounded_corner_mask (0x1); // upper left only
mouse_select_button.set_rounded_corner_mask (0x2); // upper right only
mouse_mode_hbox2->set_spacing (2);
mouse_mode_box->set_spacing (2);