X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fbutton_joiner.cc;h=8671dab9ab309178f895e13b56c019db52676c41;hb=01e0f512232fe73c18339f368c90f581a5bebdb2;hp=fffe874f034ddcd287adc4b2aa91b87dc1308fd8;hpb=b08d13706f9e98fc75a727822209942c00d8f1b3;p=ardour.git diff --git a/gtk2_ardour/button_joiner.cc b/gtk2_ardour/button_joiner.cc index fffe874f03..8671dab9ab 100644 --- a/gtk2_ardour/button_joiner.cc +++ b/gtk2_ardour/button_joiner.cc @@ -1,3 +1,22 @@ +/* + Copyright (C) 2012 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 #include @@ -13,21 +32,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 +109,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, 12); - cairo_fill_preserve (cr); - - /* outer edge */ - - cairo_set_line_width (cr, 1); - 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, 10); - 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 @@ -99,7 +157,7 @@ ButtonJoiner::on_size_allocate (Allocation& alloc) } bool -ButtonJoiner::on_button_release_event (GdkEventButton* ev) +ButtonJoiner::on_button_release_event (GdkEventButton*) { if (_action) { _action->activate ();