#include "gtkmm2ext/utils.h"
#include "gtkmm2ext/doi.h"
+#include "widgets/tooltips.h"
+
#include "ardour/plugin_manager.h"
#include "ardour/profile.h"
#include "ardour/template_utils.h"
#include "utils.h"
#include "add_route_dialog.h"
#include "route_group_dialog.h"
-#include "tooltips.h"
#include "pbd/i18n.h"
using namespace Gtk;
table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
table2->attach (strict_io_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
- ARDOUR_UI_UTILS::set_tooltip (strict_io_combo,
+ ArdourWidgets::set_tooltip (strict_io_combo,
_("With strict-i/o enabled, Effect Processors will not modify the number of channels on a track. The number of output channels will always match the number of input channels."));
++n;
}
export GTK_PATH=~/.ardour3:$libs/clearlooks-newer
export VAMP_PATH=$libs/vamp-plugins${VAMP_PATH:+:$VAMP_PATH}
-export LD_LIBRARY_PATH=$libs/ptformat:$libs/qm-dsp:$libs/vamp-sdk:$libs/surfaces:$libs/surfaces/control_protocol:$libs/ardour:$libs/midi++2:$libs/pbd:$libs/rubberband:$libs/soundtouch:$libs/gtkmm2ext:$libs/gnomecanvas:$libs/libsndfile:$libs/appleutility:$libs/taglib:$libs/evoral:$libs/evoral/src/libsmf:$libs/audiographer:$libs/timecode:$libs/libltc:$libs/canvas:$libs/ardouralsautil${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
+export LD_LIBRARY_PATH=$libs/ptformat:$libs/qm-dsp:$libs/vamp-sdk:$libs/surfaces:$libs/surfaces/control_protocol:$libs/ardour:$libs/midi++2:$libs/pbd:$libs/rubberband:$libs/soundtouch:$libs/gtkmm2ext:$libs/widgets:$libs/appleutility:$libs/taglib:$libs/evoral:$libs/evoral/src/libsmf:$libs/audiographer:$libs/timecode:$libs/libltc:$libs/canvas:$libs/ardouralsautil${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
# DYLD_LIBRARY_PATH is for darwin.
export DYLD_FALLBACK_LIBRARY_PATH=$LD_LIBRARY_PATH
+++ /dev/null
-/*
- 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 <pangomm/layout.h>
-
-#include "pbd/compose.h"
-#include "pbd/controllable.h"
-#include "pbd/error.h"
-#include "pbd/stacktrace.h"
-
-#include "gtkmm2ext/utils.h"
-#include "gtkmm2ext/rgb_macros.h"
-#include "gtkmm2ext/gui_thread.h"
-
-#include "canvas/utils.h"
-#include "canvas/colors.h"
-
-#include "ardour_button.h"
-#include "tooltips.h"
-#include "ui_config.h"
-
-#include "pbd/i18n.h"
-
-#define BASELINESTRETCH (1.25)
-#define TRACKHEADERBTNW (3.10)
-
-using namespace Gtk;
-using namespace Glib;
-using namespace PBD;
-using namespace ARDOUR_UI_UTILS;
-using std::max;
-using std::min;
-using namespace std;
-
-ArdourButton::Element ArdourButton::default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text);
-ArdourButton::Element ArdourButton::led_default_elements = ArdourButton::Element (ArdourButton::default_elements|ArdourButton::Indicator);
-ArdourButton::Element ArdourButton::just_led_default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Indicator);
-
-ArdourButton::ArdourButton (Element e)
- : _sizing_text("")
- , _markup (false)
- , _elements (e)
- , _icon (Gtkmm2ext::ArdourIcon::NoIcon)
- , _icon_render_cb (0)
- , _icon_render_cb_data (0)
- , _tweaks (Tweaks (0))
- , _char_pixel_width (0)
- , _char_pixel_height (0)
- , _char_avg_pixel_width (0)
- , _text_width (0)
- , _text_height (0)
- , _diameter (0)
- , _corner_radius (3.5)
- , _corner_mask (0xf)
- , _angle(0)
- , _xalign(.5)
- , _yalign(.5)
- , fill_inactive_color (0)
- , fill_active_color (0)
- , text_active_color(0)
- , text_inactive_color(0)
- , led_active_color(0)
- , led_inactive_color(0)
- , led_custom_color (0)
- , use_custom_led_color (false)
- , convex_pattern (0)
- , concave_pattern (0)
- , led_inset_pattern (0)
- , _led_rect (0)
- , _act_on_release (true)
- , _led_left (false)
- , _distinct_led_click (false)
- , _hovering (false)
- , _focused (false)
- , _fixed_colors_set (false)
- , _fallthrough_to_parent (false)
- , _layout_ellipsize_width (-1)
- , _ellipsis (Pango::ELLIPSIZE_NONE)
- , _update_colors (true)
- , _pattern_height (0)
-{
- UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
- /* This is not provided by gtkmm */
- signal_grab_broken_event().connect (sigc::mem_fun (*this, &ArdourButton::on_grab_broken_event));
-}
-
-ArdourButton::ArdourButton (const std::string& str, Element e)
- : _sizing_text("")
- , _markup (false)
- , _elements (e)
- , _icon (Gtkmm2ext::ArdourIcon::NoIcon)
- , _tweaks (Tweaks (0))
- , _char_pixel_width (0)
- , _char_pixel_height (0)
- , _char_avg_pixel_width (0)
- , _text_width (0)
- , _text_height (0)
- , _diameter (0)
- , _corner_radius (3.5)
- , _corner_mask (0xf)
- , _angle(0)
- , _xalign(.5)
- , _yalign(.5)
- , fill_inactive_color (0)
- , fill_active_color (0)
- , text_active_color(0)
- , text_inactive_color(0)
- , led_active_color(0)
- , led_inactive_color(0)
- , led_custom_color (0)
- , use_custom_led_color (false)
- , convex_pattern (0)
- , concave_pattern (0)
- , led_inset_pattern (0)
- , _led_rect (0)
- , _act_on_release (true)
- , _led_left (false)
- , _distinct_led_click (false)
- , _hovering (false)
- , _focused (false)
- , _fixed_colors_set (false)
- , _fallthrough_to_parent (false)
- , _layout_ellipsize_width (-1)
- , _ellipsis (Pango::ELLIPSIZE_NONE)
- , _update_colors (true)
- , _pattern_height (0)
-{
- set_text (str);
- UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
- UIConfiguration::instance().DPIReset.connect (sigc::mem_fun (*this, &ArdourButton::on_name_changed));
- /* This is not provided by gtkmm */
- signal_grab_broken_event().connect (sigc::mem_fun (*this, &ArdourButton::on_grab_broken_event));
-}
-
-ArdourButton::~ArdourButton()
-{
- delete _led_rect;
-
- if (convex_pattern) {
- cairo_pattern_destroy (convex_pattern);
- }
-
- if (concave_pattern) {
- cairo_pattern_destroy (concave_pattern);
- }
-
- if (led_inset_pattern) {
- cairo_pattern_destroy (led_inset_pattern);
- }
-}
-
-void
-ArdourButton::set_layout_font (const Pango::FontDescription& fd)
-{
- ensure_layout ();
- if (_layout) {
- _layout->set_font_description (fd);
- queue_resize ();
- _char_pixel_width = 0;
- _char_pixel_height = 0;
- }
-}
-
-void
-ArdourButton::set_text_internal () {
- assert (_layout);
- if (_markup) {
- _layout->set_markup (_text);
- } else {
- _layout->set_text (_text);
- }
-}
-
-void
-ArdourButton::set_text (const std::string& str, bool markup)
-{
- if (!(_elements & Text)) {
- return;
- }
- if (_text == str && _markup == markup) {
- return;
- }
-
- _text = str;
- _markup = markup;
- if (!is_realized()) {
- return;
- }
- ensure_layout ();
- if (_layout && _layout->get_text() != _text) {
- set_text_internal ();
- /* on_size_request() will fill in _text_width/height
- * so queue it even if _sizing_text != "" */
- queue_resize ();
- }
-}
-
-void
-ArdourButton::set_sizing_text (const std::string& str)
-{
- if (_sizing_text == str) {
- return;
- }
- _sizing_text = str;
- if (!is_realized()) {
- return;
- }
- ensure_layout ();
- if (_layout) {
- queue_resize ();
- }
-}
-
-void
-ArdourButton::set_angle (const double angle)
-{
- _angle = angle;
-}
-
-void
-ArdourButton::set_alignment (const float xa, const float ya)
-{
- _xalign = xa;
- _yalign = ya;
-}
-
-
-/* TODO make this a dedicated function elsewhere.
- *
- * Option 1:
- * virtual ArdourButton::render_vector_icon()
- * ArdourIconButton::render_vector_icon
- *
- * Option 2:
- * ARDOUR_UI_UTILS::render_vector_icon()
- */
-void
-ArdourButton::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
-{
- cairo_t* cr = ctx->cobj();
-
- uint32_t text_color;
- uint32_t led_color;
-
- const float corner_radius = std::max(2.f, _corner_radius * UIConfiguration::instance().get_ui_scale());
-
- if (_update_colors) {
- set_colors ();
- }
- if (get_height() != _pattern_height) {
- build_patterns ();
- }
-
- if ( active_state() == Gtkmm2ext::ExplicitActive ) {
- text_color = text_active_color;
- led_color = led_active_color;
- } else {
- text_color = text_inactive_color;
- led_color = led_inactive_color;
- }
-
- if (use_custom_led_color) {
- led_color = led_custom_color;
- }
-
- void (*rounded_function)(cairo_t*, double, double, double, double, double);
-
- switch (_corner_mask) {
- case 0x1: /* upper left only */
- rounded_function = Gtkmm2ext::rounded_top_left_rectangle;
- break;
- case 0x2: /* upper right only */
- rounded_function = Gtkmm2ext::rounded_top_right_rectangle;
- break;
- case 0x3: /* upper only */
- rounded_function = Gtkmm2ext::rounded_top_rectangle;
- break;
- /* should really have functions for lower right, lower left,
- lower only, but for now, we don't
- */
- default:
- rounded_function = Gtkmm2ext::rounded_rectangle;
- }
-
- // draw edge (filling a rect underneath, rather than stroking a border on top, allows the corners to be lighter-weight.
- if ((_elements & (Body|Edge)) == (Body|Edge)) {
- rounded_function (cr, 0, 0, get_width(), get_height(), corner_radius + 1.5);
- cairo_set_source_rgba (cr, 0, 0, 0, 1);
- cairo_fill(cr);
- }
-
- // background fill
- if ((_elements & Body)==Body) {
- rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, corner_radius);
- if (active_state() == Gtkmm2ext::ImplicitActive && !((_elements & Indicator)==Indicator)) {
- ArdourCanvas::set_source_rgba (cr, fill_inactive_color);
- cairo_fill (cr);
- } else if ( (active_state() == Gtkmm2ext::ExplicitActive) && !((_elements & Indicator)==Indicator) ) {
- //background color
- ArdourCanvas::set_source_rgba (cr, fill_active_color);
- cairo_fill (cr);
- } else { //inactive, or it has an indicator
- //background color
- ArdourCanvas::set_source_rgba (cr, fill_inactive_color);
- }
- cairo_fill (cr);
- }
-
- // IMPLICIT ACTIVE: draw a border of the active color
- if ((_elements & Body)==Body) {
- if (active_state() == Gtkmm2ext::ImplicitActive && !((_elements & Indicator)==Indicator)) {
- cairo_set_line_width (cr, 2.0);
- rounded_function (cr, 2, 2, get_width() - 4, get_height() - 4, corner_radius-0.5);
- ArdourCanvas::set_source_rgba (cr, fill_active_color);
- cairo_stroke (cr);
- }
- }
-
- //show the "convex" or "concave" gradient
- if (!_flat_buttons && (_elements & Body)==Body) {
- if ( active_state() == Gtkmm2ext::ExplicitActive && ( !((_elements & Indicator)==Indicator) || use_custom_led_color) ) {
- //concave
- cairo_set_source (cr, concave_pattern);
- Gtkmm2ext::rounded_rectangle (cr, 1, 1, get_width() - 2, get_height() - 2, corner_radius);
- cairo_fill (cr);
- } else {
- cairo_set_source (cr, convex_pattern);
- Gtkmm2ext::rounded_rectangle (cr, 1, 1, get_width() - 2, get_height() - 2, corner_radius);
- cairo_fill (cr);
- }
- }
-
- //Pixbuf, if any
- if (_pixbuf) {
- double x = rint((get_width() - _pixbuf->get_width()) * .5);
- const double y = rint((get_height() - _pixbuf->get_height()) * .5);
-#if 0 // DEBUG style (print on hover)
- if (_hovering || (_elements & Inactive)) {
- printf("%s: p:%dx%d (%dx%d)\n",
- get_name().c_str(),
- _pixbuf->get_width(), _pixbuf->get_height(),
- get_width(), get_height());
- }
-#endif
- if (_elements & Menu) {
- //if this is a DropDown with an icon, then we need to
- //move the icon left slightly to accomomodate the arrow
- x -= _diameter - 2;
- }
- cairo_rectangle (cr, x, y, _pixbuf->get_width(), _pixbuf->get_height());
- gdk_cairo_set_source_pixbuf (cr, _pixbuf->gobj(), x, y);
- cairo_fill (cr);
- }
- else /* VectorIcon, IconRenderCallback are exclusive to Pixbuf Icons */
- if (_elements & (VectorIcon | IconRenderCallback)) {
- int vw = get_width();
- int vh = get_height();
- if (_elements & Menu) {
- vw -= _diameter + 4;
- }
- if (_elements & VectorIcon) {
- Gtkmm2ext::ArdourIcon::render (cr, _icon, vw, vh, active_state(), text_color);
- } else {
- cairo_save (cr);
- rounded_function (cr, 0, 0, get_width(), get_height(), corner_radius + 1.5);
- cairo_clip (cr);
- _icon_render_cb (cr, vw, vh, text_color, _icon_render_cb_data);
- cairo_restore (cr);
- }
- }
-
- const int text_margin = char_pixel_width();
- // Text, if any
- if (!_pixbuf && ((_elements & Text)==Text) && !_text.empty()) {
- assert(_layout);
-#if 0 // DEBUG style (print on hover)
- if (_hovering || (_elements & Inactive)) {
- bool layout_font = true;
- Pango::FontDescription fd = _layout->get_font_description();
- if (fd.gobj() == NULL) {
- layout_font = false;
- fd = get_pango_context()->get_font_description();
- }
- printf("%s: f:%dx%d aw:%.3f bh:%.0f t:%dx%d (%dx%d) %s\"%s\"\n",
- get_name().c_str(),
- char_pixel_width(), char_pixel_height(), char_avg_pixel_width(),
- ceil(char_pixel_height() * BASELINESTRETCH),
- _text_width, _text_height,
- get_width(), get_height(),
- layout_font ? "L:" : "W:",
- fd.to_string().c_str());
- }
-#endif
-
- cairo_save (cr);
- cairo_rectangle (cr, 2, 1, get_width() - 4, get_height() - 2);
- cairo_clip(cr);
-
- cairo_new_path (cr);
- ArdourCanvas::set_source_rgba (cr, text_color);
- const double text_ypos = (get_height() - _text_height) * .5;
-
- if (_elements & Menu) {
- // always left align (dropdown)
- cairo_move_to (cr, text_margin, text_ypos);
- pango_cairo_show_layout (cr, _layout->gobj());
- } else if ( (_elements & Indicator) == Indicator) {
- // left/right align depending on LED position
- if (_led_left) {
- cairo_move_to (cr, text_margin + _diameter + .5 * char_pixel_width(), text_ypos);
- } else {
- cairo_move_to (cr, text_margin, text_ypos);
- }
- pango_cairo_show_layout (cr, _layout->gobj());
- } else {
- /* centered text otherwise */
- double ww, wh;
- double xa, ya;
- ww = get_width();
- wh = get_height();
-
- cairo_matrix_t m1;
- cairo_get_matrix (cr, &m1);
- cairo_matrix_t m2 = m1;
- m2.x0 = 0;
- m2.y0 = 0;
- cairo_set_matrix (cr, &m2);
-
- if (_angle) {
- cairo_rotate(cr, _angle * M_PI / 180.0);
- }
-
- cairo_device_to_user(cr, &ww, &wh);
- xa = text_margin + (ww - _text_width - 2 * text_margin) * _xalign;
- ya = (wh - _text_height) * _yalign;
-
- /* quick hack for left/bottom alignment at -90deg
- * TODO this should be generalized incl rotation.
- * currently only 'user' of this API is meter_strip.cc
- */
- if (_xalign < 0) xa = ceil(.5 + (ww * fabs(_xalign) + text_margin));
-
- cairo_move_to (cr, xa + m1.x0, ya + m1.y0);
- pango_cairo_update_layout(cr, _layout->gobj());
- pango_cairo_show_layout (cr, _layout->gobj());
- }
- cairo_restore (cr);
- }
-
- //Menu "triangle"
- if (_elements & Menu) {
- const float trih = ceil(_diameter * .5);
- const float triw2 = ceil(.577 * _diameter * .5); // 1/sqrt(3) Equilateral triangle
- //menu arrow
- cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
- cairo_move_to(cr, get_width() - triw2 - 3. , rint((get_height() + trih) * .5));
- cairo_rel_line_to(cr, -triw2, -trih);
- cairo_rel_line_to(cr, 2. * triw2, 0);
- cairo_close_path(cr);
-
- cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
- cairo_fill(cr);
-
- cairo_move_to(cr, get_width() - triw2 - 3 , rint((get_height() + trih) * .5));
- cairo_rel_line_to(cr, .5 - triw2, .5 - trih);
- cairo_rel_line_to(cr, 2. * triw2 - 1, 0);
- cairo_close_path(cr);
- cairo_set_source_rgba (cr, 0, 0, 0, 0.8);
- cairo_set_line_width(cr, 1);
- cairo_stroke(cr);
- }
-
- //Indicator LED
- if (_elements & Indicator) {
- cairo_save (cr);
-
- /* move to the center of the indicator/led */
- if (_elements & Text) {
- int led_xoff = ceil(char_pixel_width() + _diameter * .5);
- if (_led_left) {
- cairo_translate (cr, led_xoff, get_height() * .5);
- } else {
- cairo_translate (cr, get_width() - led_xoff, get_height() * .5);
- }
- } else {
- cairo_translate (cr, get_width() * .5, get_height() * .5);
- }
-
- //inset
- if (!_flat_buttons) {
- cairo_arc (cr, 0, 0, _diameter * .5, 0, 2 * M_PI);
- cairo_set_source (cr, led_inset_pattern);
- cairo_fill (cr);
- }
-
- //black ring
- cairo_set_source_rgb (cr, 0, 0, 0);
- cairo_arc (cr, 0, 0, _diameter * .5 - 1 * UIConfiguration::instance().get_ui_scale(), 0, 2 * M_PI);
- cairo_fill(cr);
-
- //led color
- ArdourCanvas::set_source_rgba (cr, led_color);
- cairo_arc (cr, 0, 0, _diameter * .5 - 3 * UIConfiguration::instance().get_ui_scale(), 0, 2 * M_PI);
- cairo_fill(cr);
-
- cairo_restore (cr);
- }
-
- // a transparent overlay to indicate insensitivity
- if ((visual_state() & Gtkmm2ext::Insensitive)) {
- rounded_function (cr, 0, 0, get_width(), get_height(), corner_radius);
- uint32_t ins_color = UIConfiguration::instance().color ("gtk_background");
- ArdourCanvas::set_source_rgb_a (cr, ins_color, 0.6);
- cairo_fill (cr);
- }
-
- // if requested, show hovering
- if (UIConfiguration::instance().get_widget_prelight()
- && !((visual_state() & Gtkmm2ext::Insensitive))) {
- if (_hovering) {
- rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, corner_radius);
- cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.2);
- cairo_fill (cr);
- }
- }
-
- //user is currently pressing the button. dark outline helps to indicate this
- if (_grabbed && !(_elements & (Inactive|Menu))) {
- rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, corner_radius);
- cairo_set_line_width(cr, 2);
- cairo_set_source_rgba (cr, 0.1, 0.1, 0.1, .5);
- cairo_stroke (cr);
- }
-
- //some buttons (like processor boxes) can be selected (so they can be deleted). Draw a selection indicator
- if (visual_state() & Gtkmm2ext::Selected) {
- cairo_set_line_width(cr, 1);
- cairo_set_source_rgba (cr, 1, 0, 0, 0.8);
- rounded_function (cr, 0.5, 0.5, get_width() - 1, get_height() - 1, corner_radius);
- cairo_stroke (cr);
- }
-
- //I guess this means we have keyboard focus. I don't think this works currently
- //
- //A: yes, it's keyboard focus and it does work when there's no editor window
- // (the editor is always the first receiver for KeyDown).
- // It's needed for eg. the engine-dialog at startup or after closing a sesion.
- if (_focused) {
- rounded_function (cr, 1.5, 1.5, get_width() - 3, get_height() - 3, corner_radius);
- cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.8);
- double dashes = 1;
- cairo_set_dash (cr, &dashes, 1, 0);
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
- cairo_set_line_width (cr, 1.0);
- cairo_stroke (cr);
- cairo_set_dash (cr, 0, 0, 0);
- }
-}
-
-void
-ArdourButton::set_corner_radius (float r)
-{
- _corner_radius = r;
- CairoWidget::set_dirty ();
-}
-
-void
-ArdourButton::on_realize()
-{
- CairoWidget::on_realize ();
- ensure_layout ();
- if (_layout) {
- if (_layout->get_text() != _text) {
- set_text_internal ();
- queue_resize ();
- }
- }
-}
-
-void
-ArdourButton::on_size_request (Gtk::Requisition* req)
-{
- req->width = req->height = 0;
- CairoWidget::on_size_request (req);
-
- if (_diameter == 0) {
- const float newdia = rintf (11.f * UIConfiguration::instance().get_ui_scale());
- if (_diameter != newdia) {
- _pattern_height = 0;
- _diameter = newdia;
- }
- }
-
- if (_elements & Text) {
-
- ensure_layout();
- set_text_internal ();
-
- /* render() needs the size of the displayed text */
- _layout->get_pixel_size (_text_width, _text_height);
-
- if (_tweaks & OccasionalText) {
-
- /* size should not change based on presence or absence
- * of text.
- */
-
- } else /*if (!_text.empty() || !_sizing_text.empty()) */ {
-
- req->height = std::max(req->height, (int) ceil(char_pixel_height() * BASELINESTRETCH + 1.0));
- req->width += rint(1.75 * char_pixel_width()); // padding
-
- if (!_sizing_text.empty()) {
- _layout->set_text (_sizing_text); /* use sizing text */
- }
-
- int sizing_text_width = 0, sizing_text_height = 0;
- _layout->get_pixel_size (sizing_text_width, sizing_text_height);
-
- req->width += sizing_text_width;
-
- if (!_sizing_text.empty()) {
- set_text_internal (); /* restore display text */
- }
- }
-
- /* XXX hack (surprise). Deal with two common rotation angles */
-
- if (_angle == 90 || _angle == 270) {
- /* do not swap text width or height because we rely on
- these being the un-rotated values in ::render()
- */
- swap (req->width, req->height);
- }
-
- } else {
- _text_width = 0;
- _text_height = 0;
- }
-
- if (_pixbuf) {
- req->width += _pixbuf->get_width() + char_pixel_width();
- req->height = std::max(req->height, _pixbuf->get_height() + 4);
- }
-
- if (_elements & Indicator) {
- req->width += lrint (_diameter) + char_pixel_width();
- req->height = std::max (req->height, (int) lrint (_diameter) + 4);
- }
-
- if ((_elements & Menu)) {
- req->width += _diameter + 4;
- }
-
- if (_elements & (VectorIcon | IconRenderCallback)) {
- assert(!(_elements & Text));
- const int wh = std::max (6., std::max (rint (TRACKHEADERBTNW * char_avg_pixel_width()), ceil (char_pixel_height() * BASELINESTRETCH + 1.)));
- req->width += wh;
- req->height = std::max(req->height, wh);
- }
-
- /* Tweaks to mess the nice stuff above up again. */
- if (_tweaks & TrackHeader) {
- // forget everything above and just use a fixed square [em] size
- // "TrackHeader Buttons" are single letter (usually uppercase)
- // a SizeGroup is much less efficient (lots of gtk work under the hood for each track)
- const int wh = std::max (rint (TRACKHEADERBTNW * char_avg_pixel_width()), ceil (char_pixel_height() * BASELINESTRETCH + 1.));
- req->width = wh;
- req->height = wh;
- }
- else if (_tweaks & Square) {
- // currerntly unused (again)
- if (req->width < req->height)
- req->width = req->height;
- if (req->height < req->width)
- req->height = req->width;
- } else if (_sizing_text.empty() && _text_width > 0 && !(_elements & Menu)) {
- // properly centered text for those elements that are centered
- // (no sub-pixel offset)
- if ((req->width - _text_width) & 1) { ++req->width; }
- if ((req->height - _text_height) & 1) { ++req->height; }
- }
-#if 0
- printf("REQ: %s: %dx%d\n", get_name().c_str(), req->width, req->height);
-#endif
-}
-
-/**
- * This sets the colors used for rendering based on the name of the button, and
- * thus uses information from the GUI config data.
- */
-void
-ArdourButton::set_colors ()
-{
- _update_colors = false;
-
- if (_fixed_colors_set == 0x3) {
- return;
- }
-
- std::string name = get_name();
- bool failed = false;
-
- if (!(_fixed_colors_set & 0x1)) {
- fill_active_color = UIConfiguration::instance().color (string_compose ("%1: fill active", name), &failed);
- if (failed) {
- fill_active_color = UIConfiguration::instance().color ("generic button: fill active");
- }
- }
-
- if (!(_fixed_colors_set & 0x2)) {
- fill_inactive_color = UIConfiguration::instance().color (string_compose ("%1: fill", name), &failed);
- if (failed) {
- fill_inactive_color = UIConfiguration::instance().color ("generic button: fill");
- }
- }
-
- text_active_color = ArdourCanvas::contrasting_text_color (fill_active_color);
- text_inactive_color = ArdourCanvas::contrasting_text_color (fill_inactive_color);
-
- led_active_color = UIConfiguration::instance().color (string_compose ("%1: led active", name), &failed);
- if (failed) {
- led_active_color = UIConfiguration::instance().color ("generic button: led active");
- }
-
- /* The inactive color for the LED is just a fairly dark version of the
- * active color.
- */
-
- ArdourCanvas::HSV inactive (led_active_color);
- inactive.v = 0.35;
-
- led_inactive_color = inactive.color ();
-}
-
-/**
- * This sets the colors used for rendering based on two fixed values, rather
- * than basing them on the button name, and thus information in the GUI config
- * data.
- */
-void ArdourButton::set_fixed_colors (const uint32_t color_active, const uint32_t color_inactive)
-{
- set_active_color (color_active);
- set_inactive_color (color_inactive);
-}
-
-void ArdourButton::set_active_color (const uint32_t color)
-{
- _fixed_colors_set |= 0x1;
-
- fill_active_color = color;
-
- unsigned char r, g, b, a;
- UINT_TO_RGBA(color, &r, &g, &b, &a);
-
- double white_contrast = (max (double(r), 255.) - min (double(r), 255.)) +
- (max (double(g), 255.) - min (double(g), 255.)) +
- (max (double(b), 255.) - min (double(b), 255.));
-
- double black_contrast = (max (double(r), 0.) - min (double(r), 0.)) +
- (max (double(g), 0.) - min (double(g), 0.)) +
- (max (double(b), 0.) - min (double(b), 0.));
-
- text_active_color = (white_contrast > black_contrast) ?
- RGBA_TO_UINT(255, 255, 255, 255) : /* use white */
- RGBA_TO_UINT( 0, 0, 0, 255); /* use black */
-
- /* XXX what about led colors ? */
- CairoWidget::set_dirty ();
-}
-
-void ArdourButton::set_inactive_color (const uint32_t color)
-{
- _fixed_colors_set |= 0x2;
-
- fill_inactive_color = color;
-
- unsigned char r, g, b, a;
- UINT_TO_RGBA(color, &r, &g, &b, &a);
-
- double white_contrast = (max (double(r), 255.) - min (double(r), 255.)) +
- (max (double(g), 255.) - min (double(g), 255.)) +
- (max (double(b), 255.) - min (double(b), 255.));
-
- double black_contrast = (max (double(r), 0.) - min (double(r), 0.)) +
- (max (double(g), 0.) - min (double(g), 0.)) +
- (max (double(b), 0.) - min (double(b), 0.));
-
- text_inactive_color = (white_contrast > black_contrast) ?
- RGBA_TO_UINT(255, 255, 255, 255) : /* use white */
- RGBA_TO_UINT( 0, 0, 0, 255); /* use black */
-
- /* XXX what about led colors ? */
- CairoWidget::set_dirty ();
-}
-
-void
-ArdourButton::build_patterns ()
-{
- if (convex_pattern) {
- cairo_pattern_destroy (convex_pattern);
- convex_pattern = 0;
- }
-
- if (concave_pattern) {
- cairo_pattern_destroy (concave_pattern);
- concave_pattern = 0;
- }
-
- if (led_inset_pattern) {
- cairo_pattern_destroy (led_inset_pattern);
- led_inset_pattern = 0;
- }
-
- //convex gradient
- convex_pattern = cairo_pattern_create_linear (0.0, 0, 0.0, get_height());
- cairo_pattern_add_color_stop_rgba (convex_pattern, 0.0, 0,0,0, 0.0);
- cairo_pattern_add_color_stop_rgba (convex_pattern, 1.0, 0,0,0, 0.35);
-
- //concave gradient
- concave_pattern = cairo_pattern_create_linear (0.0, 0, 0.0, get_height());
- cairo_pattern_add_color_stop_rgba (concave_pattern, 0.0, 0,0,0, 0.5);
- cairo_pattern_add_color_stop_rgba (concave_pattern, 0.7, 0,0,0, 0.0);
-
- led_inset_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, _diameter);
- cairo_pattern_add_color_stop_rgba (led_inset_pattern, 0, 0,0,0, 0.4);
- cairo_pattern_add_color_stop_rgba (led_inset_pattern, 1, 1,1,1, 0.7);
-
- _pattern_height = get_height() ;
-}
-
-void
-ArdourButton::set_led_left (bool yn)
-{
- _led_left = yn;
-}
-
-bool
-ArdourButton::on_button_press_event (GdkEventButton *ev)
-{
- focus_handler (this);
-
- if (ev->button == 1 && (_elements & Indicator) && _led_rect && _distinct_led_click) {
- if (ev->x >= _led_rect->x && ev->x < _led_rect->x + _led_rect->width &&
- ev->y >= _led_rect->y && ev->y < _led_rect->y + _led_rect->height) {
- return true;
- }
- }
-
- if (binding_proxy.button_press_handler (ev)) {
- return true;
- }
-
- _grabbed = true;
- CairoWidget::set_dirty ();
-
- if (ev->button == 1 && !_act_on_release) {
- if (_action) {
- _action->activate ();
- return true;
- }
- }
-
- if (_fallthrough_to_parent)
- return false;
-
- return true;
-}
-
-bool
-ArdourButton::on_button_release_event (GdkEventButton *ev)
-{
- if (ev->button == 1 && _hovering && (_elements & Indicator) && _led_rect && _distinct_led_click) {
- if (ev->x >= _led_rect->x && ev->x < _led_rect->x + _led_rect->width &&
- ev->y >= _led_rect->y && ev->y < _led_rect->y + _led_rect->height) {
- signal_led_clicked(ev); /* EMIT SIGNAL */
- return true;
- }
- }
-
- _grabbed = false;
- CairoWidget::set_dirty ();
-
- if (ev->button == 1 && _hovering) {
- signal_clicked ();
- if (_act_on_release) {
- if (_action) {
- _action->activate ();
- return true;
- }
- }
- }
-
- if (_fallthrough_to_parent)
- return false;
-
- return true;
-}
-
-void
-ArdourButton::set_distinct_led_click (bool yn)
-{
- _distinct_led_click = yn;
- setup_led_rect ();
-}
-
-void
-ArdourButton::color_handler ()
-{
- _update_colors = true;
- CairoWidget::set_dirty ();
-}
-
-void
-ArdourButton::on_size_allocate (Allocation& alloc)
-{
- CairoWidget::on_size_allocate (alloc);
- setup_led_rect ();
-}
-
-void
-ArdourButton::set_controllable (boost::shared_ptr<Controllable> c)
-{
- watch_connection.disconnect ();
- binding_proxy.set_controllable (c);
-}
-
-void
-ArdourButton::watch ()
-{
- boost::shared_ptr<Controllable> c (binding_proxy.get_controllable ());
-
- if (!c) {
- warning << _("button cannot watch state of non-existing Controllable\n") << endmsg;
- return;
- }
- c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&ArdourButton::controllable_changed, this), gui_context());
-}
-
-void
-ArdourButton::controllable_changed ()
-{
- float val = binding_proxy.get_controllable()->get_value();
-
- if (fabs (val) >= 0.5f) {
- set_active_state (Gtkmm2ext::ExplicitActive);
- } else {
- unset_active_state ();
- }
- CairoWidget::set_dirty ();
-}
-
-void
-ArdourButton::set_related_action (RefPtr<Action> act)
-{
- Gtkmm2ext::Activatable::set_related_action (act);
-
- if (_action) {
-
- action_tooltip_changed ();
- action_sensitivity_changed ();
-
- Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
- if (tact) {
- action_toggled ();
- tact->signal_toggled().connect (sigc::mem_fun (*this, &ArdourButton::action_toggled));
- }
-
- _action->connect_property_changed ("sensitive", sigc::mem_fun (*this, &ArdourButton::action_sensitivity_changed));
- _action->connect_property_changed ("visible", sigc::mem_fun (*this, &ArdourButton::action_visibility_changed));
- _action->connect_property_changed ("tooltip", sigc::mem_fun (*this, &ArdourButton::action_tooltip_changed));
- }
-}
-
-void
-ArdourButton::action_toggled ()
-{
- Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
-
- if (tact) {
- if (tact->get_active()) {
- set_active_state (Gtkmm2ext::ExplicitActive);
- } else {
- unset_active_state ();
- }
- }
-}
-
-void
-ArdourButton::on_style_changed (const RefPtr<Gtk::Style>&)
-{
- _update_colors = true;
- CairoWidget::set_dirty ();
- _char_pixel_width = 0;
- _char_pixel_height = 0;
- if (is_realized()) {
- queue_resize ();
- }
-}
-
-void
-ArdourButton::on_name_changed ()
-{
- _char_pixel_width = 0;
- _char_pixel_height = 0;
- _diameter = 0;
- _update_colors = true;
- if (is_realized()) {
- queue_resize ();
- }
-}
-
-void
-ArdourButton::setup_led_rect ()
-{
- if (!(_elements & Indicator)) {
- delete _led_rect;
- _led_rect = 0;
- return;
- }
-
- if (!_led_rect) {
- _led_rect = new cairo_rectangle_t;
- }
-
- if (_elements & Text) {
- if (_led_left) {
- _led_rect->x = char_pixel_width();
- } else {
- _led_rect->x = get_width() - char_pixel_width() + _diameter;
- }
- } else {
- /* centered */
- _led_rect->x = .5 * get_width() - _diameter;
- }
-
- _led_rect->y = .5 * (get_height() - _diameter);
- _led_rect->width = _diameter;
- _led_rect->height = _diameter;
-}
-
-void
-ArdourButton::set_image (const RefPtr<Gdk::Pixbuf>& img)
-{
- _elements = (ArdourButton::Element) (_elements & ~ArdourButton::Text);
- _pixbuf = img;
- if (is_realized()) {
- queue_resize ();
- }
-}
-
-void
-ArdourButton::set_active_state (Gtkmm2ext::ActiveState s)
-{
- bool changed = (_active_state != s);
- CairoWidget::set_active_state (s);
- if (changed) {
- _update_colors = true;
- CairoWidget::set_dirty ();
- }
-}
-
-void
-ArdourButton::set_visual_state (Gtkmm2ext::VisualState s)
-{
- bool changed = (_visual_state != s);
- CairoWidget::set_visual_state (s);
- if (changed) {
- _update_colors = true;
- CairoWidget::set_dirty ();
- }
-}
-
-bool
-ArdourButton::on_focus_in_event (GdkEventFocus* ev)
-{
- _focused = true;
- CairoWidget::set_dirty ();
- return CairoWidget::on_focus_in_event (ev);
-}
-
-bool
-ArdourButton::on_focus_out_event (GdkEventFocus* ev)
-{
- _focused = false;
- CairoWidget::set_dirty ();
- return CairoWidget::on_focus_out_event (ev);
-}
-
-bool
-ArdourButton::on_key_release_event (GdkEventKey *ev) {
- if (_act_on_release && _focused &&
- (ev->keyval == GDK_space || ev->keyval == GDK_Return))
- {
- signal_clicked();
- if (_action) {
- _action->activate ();
- }
- return true;
- }
- return CairoWidget::on_key_release_event (ev);
-}
-
-bool
-ArdourButton::on_key_press_event (GdkEventKey *ev) {
- if (!_act_on_release && _focused &&
- (ev->keyval == GDK_space || ev->keyval == GDK_Return))
- {
- signal_clicked();
- if (_action) {
- _action->activate ();
- }
- return true;
- }
- return CairoWidget::on_key_release_event (ev);
-}
-
-bool
-ArdourButton::on_enter_notify_event (GdkEventCrossing* ev)
-{
- _hovering = (_elements & Inactive) ? false : true;
-
- if (UIConfiguration::instance().get_widget_prelight()) {
- CairoWidget::set_dirty ();
- }
-
- boost::shared_ptr<PBD::Controllable> c (binding_proxy.get_controllable ());
- if (c) {
- PBD::Controllable::GUIFocusChanged (boost::weak_ptr<PBD::Controllable> (c));
- }
-
- return CairoWidget::on_enter_notify_event (ev);
-}
-
-bool
-ArdourButton::on_leave_notify_event (GdkEventCrossing* ev)
-{
- _hovering = false;
-
- if (UIConfiguration::instance().get_widget_prelight()) {
- CairoWidget::set_dirty ();
- }
-
- if (binding_proxy.get_controllable()) {
- PBD::Controllable::GUIFocusChanged (boost::weak_ptr<PBD::Controllable> ());
- }
-
- return CairoWidget::on_leave_notify_event (ev);
-}
-
-bool
-ArdourButton::on_grab_broken_event(GdkEventGrabBroken* grab_broken_event) {
- /* Our implicit grab due to a button_press was broken by another grab:
- * the button will not get any button_release event if the mouse leaves
- * while the grab is taken, so unpress ourselves */
- _grabbed = false;
- CairoWidget::set_dirty ();
- return true;
-}
-
-void
-ArdourButton::set_tweaks (Tweaks t)
-{
- if (_tweaks != t) {
- _tweaks = t;
- if (is_realized()) {
- queue_resize ();
- }
- }
-}
-
-void
-ArdourButton::action_sensitivity_changed ()
-{
- if (_action->property_sensitive ()) {
- set_visual_state (Gtkmm2ext::VisualState (visual_state() & ~Gtkmm2ext::Insensitive));
- } else {
- set_visual_state (Gtkmm2ext::VisualState (visual_state() | Gtkmm2ext::Insensitive));
- }
-}
-
-void
-ArdourButton::set_layout_ellipsize_width (int w)
-{
- if (_layout_ellipsize_width == w) {
- return;
- }
- _layout_ellipsize_width = w;
- if (!_layout) {
- return;
- }
- if (_layout_ellipsize_width > 3 * PANGO_SCALE) {
- _layout->set_width (_layout_ellipsize_width - 3 * PANGO_SCALE);
- }
- if (is_realized ()) {
- queue_resize ();
- }
-}
-
-void
-ArdourButton::set_text_ellipsize (Pango::EllipsizeMode e)
-{
- if (_ellipsis == e) {
- return;
- }
- _ellipsis = e;
- if (!_layout) {
- return;
- }
- _layout->set_ellipsize(_ellipsis);
- if (_layout_ellipsize_width > 3 * PANGO_SCALE) {
- _layout->set_width (_layout_ellipsize_width - 3 * PANGO_SCALE);
- }
- if (is_realized ()) {
- queue_resize ();
- }
-}
-
-void
-ArdourButton::ensure_layout ()
-{
- if (!_layout) {
- ensure_style ();
- _layout = Pango::Layout::create (get_pango_context());
- _layout->set_ellipsize(_ellipsis);
- if (_layout_ellipsize_width > 3 * PANGO_SCALE) {
- _layout->set_width (_layout_ellipsize_width - 3* PANGO_SCALE);
- }
- }
-}
-
-void
-ArdourButton::recalc_char_pixel_geometry ()
-{
- if (_char_pixel_height > 0 && _char_pixel_width > 0) {
- return;
- }
- ensure_layout();
- // NB. this is not static, since the geometry is different
- // depending on the font used.
- int w, h;
- std::string x = _("@ABCDEFGHIJLKMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
- _layout->set_text (x);
- _layout->get_pixel_size (w, h);
- _char_pixel_height = std::max(4, h);
- // number of actual chars in the string (not bytes)
- // Glib to the rescue.
- Glib::ustring gx(x);
- _char_avg_pixel_width = w / (float)gx.size();
- _char_pixel_width = std::max(4, (int) ceil (_char_avg_pixel_width));
- set_text_internal (); /* restore display text */
-}
-
-void
-ArdourButton::action_visibility_changed ()
-{
- if (_action->property_visible ()) {
- show ();
- } else {
- hide ();
- }
-}
-
-void
-ArdourButton::action_tooltip_changed ()
-{
- string str = _action->property_tooltip().get_value();
- set_tooltip (*this, str);
-}
-
-void
-ArdourButton::set_elements (Element e)
-{
- _elements = e;
- CairoWidget::set_dirty ();
-}
-
-void
-ArdourButton::add_elements (Element e)
-{
- _elements = (ArdourButton::Element) (_elements | e);
- CairoWidget::set_dirty ();
-}
-
-void
-ArdourButton::set_icon (Gtkmm2ext::ArdourIcon::Icon i)
-{
- _icon = i;
- _icon_render_cb = 0;
- _icon_render_cb_data = 0;
- _elements = (ArdourButton::Element) ((_elements | VectorIcon) & ~(ArdourButton::Text | IconRenderCallback));
- CairoWidget::set_dirty ();
-}
-
-void
-ArdourButton::set_icon (rendercallback_t cb, void* d)
-{
- if (!cb) {
- _elements = (ArdourButton::Element) ((_elements | ArdourButton::Text) & ~(IconRenderCallback | VectorIcon));
- _icon_render_cb = 0;
- _icon_render_cb_data = 0;
- } else {
- _elements = (ArdourButton::Element) ((_elements | IconRenderCallback) & ~(ArdourButton::Text | VectorIcon));
- _icon_render_cb = cb;
- _icon_render_cb_data = d;
- }
- CairoWidget::set_dirty ();
-}
-
-void
-ArdourButton::set_custom_led_color (uint32_t c, bool useit)
-{
- if (led_custom_color == c && use_custom_led_color == useit) {
- return;
- }
-
- led_custom_color = c;
- use_custom_led_color = useit;
- CairoWidget::set_dirty ();
-}
+++ /dev/null
-/*
- 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_ardour_button_h__
-#define __gtk2_ardour_ardour_button_h__
-
-#include <list>
-#include <stdint.h>
-
-#include <gtkmm/action.h>
-
-#include "pbd/signals.h"
-#include "gtkmm2ext/ardour_icon.h"
-#include "gtkmm2ext/binding_proxy.h"
-#include "gtkmm2ext/activatable.h"
-#include "gtkmm2ext/cairo_widget.h"
-
-class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
-{
- public:
- enum Element {
- Edge = 0x1,
- Body = 0x2,
- Text = 0x4,
- Indicator = 0x8,
- unused = 0x10,
- Menu = 0x20,
- Inactive = 0x40, // no _action is defined AND state is not used
- VectorIcon = 0x80,
- IconRenderCallback = 0x100,
- };
-
- typedef void (* rendercallback_t) (cairo_t*, int, int, uint32_t, void*);
-
- static Element default_elements;
- static Element led_default_elements;
- static Element just_led_default_elements;
-
- ArdourButton (Element e = default_elements);
- ArdourButton (const std::string&, Element e = default_elements);
- virtual ~ArdourButton ();
-
- enum Tweaks {
- Square = 0x1,
- TrackHeader = 0x2,
- OccasionalText = 0x4,
- unused4 = 0x8,
- };
-
- Tweaks tweaks() const { return _tweaks; }
- void set_tweaks (Tweaks);
-
- void set_active_state (Gtkmm2ext::ActiveState);
- void set_visual_state (Gtkmm2ext::VisualState);
-
- void set_custom_led_color (const uint32_t c, const bool useit = true);
-
- void set_act_on_release (bool onRelease) { _act_on_release = onRelease; }
-
- Element elements() const { return _elements; }
- void set_elements (Element);
- void add_elements (Element);
-
- Gtkmm2ext::ArdourIcon::Icon icon() const { return _icon; }
- void set_icon (Gtkmm2ext::ArdourIcon::Icon);
- void set_icon (rendercallback_t, void*);
-
- void set_corner_radius (float);
-
- void set_text (const std::string&, bool markup = false);
- const std::string& get_text () { return _text; }
- bool get_markup () const { return _markup; }
- void set_angle (const double);
- void set_alignment (const float, const float);
- void get_alignment (float& xa, float& ya) {xa = _xalign; ya = _yalign;};
-
- void set_led_left (bool yn);
- void set_distinct_led_click (bool yn);
-
- void set_layout_ellipsize_width (int w);
- void set_layout_font (const Pango::FontDescription&);
- void set_text_ellipsize (Pango::EllipsizeMode);
-
- /* Sets the text used for size request computation. Pass an
- * empty string to return to the default behavior which uses
- * the currently displayed text for measurement. */
- void set_sizing_text (const std::string&);
- const std::string& get_sizing_text () {return _sizing_text;}
-
- sigc::signal<void, GdkEventButton*> signal_led_clicked;
- sigc::signal<void> signal_clicked;
-
- boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
- void set_controllable (boost::shared_ptr<PBD::Controllable> c);
- void watch ();
-
- void set_related_action (Glib::RefPtr<Gtk::Action>);
-
- bool on_button_press_event (GdkEventButton*);
- bool on_button_release_event (GdkEventButton*);
-
- void set_image (const Glib::RefPtr<Gdk::Pixbuf>&);
-
- void set_fixed_colors (const uint32_t active_color, const uint32_t inactive_color);
- void set_active_color (const uint32_t active_color);
- void set_inactive_color (const uint32_t inactive_color);
-
- void set_fallthrough_to_parent(bool fall) { _fallthrough_to_parent = fall; }
-
- unsigned int char_pixel_width() { if (_char_pixel_width < 1) recalc_char_pixel_geometry() ; return _char_pixel_width; }
- unsigned int char_pixel_height() { if (_char_pixel_height < 1) recalc_char_pixel_geometry() ; return _char_pixel_height; }
- float char_avg_pixel_width() { if (_char_pixel_width < 1) recalc_char_pixel_geometry() ; return _char_avg_pixel_width; }
-
- protected:
- void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
- void on_size_request (Gtk::Requisition* req);
- void on_size_allocate (Gtk::Allocation&);
- void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
- void on_name_changed ();
- void on_realize ();
- bool on_enter_notify_event (GdkEventCrossing*);
- bool on_leave_notify_event (GdkEventCrossing*);
- bool on_grab_broken_event(GdkEventGrabBroken*);
- bool on_focus_in_event (GdkEventFocus*);
- bool on_focus_out_event (GdkEventFocus*);
- bool on_key_release_event (GdkEventKey *);
- bool on_key_press_event (GdkEventKey *);
-
- void controllable_changed ();
- PBD::ScopedConnection watch_connection;
-
- protected:
- Glib::RefPtr<Pango::Layout> _layout;
- Glib::RefPtr<Gdk::Pixbuf> _pixbuf;
- std::string _text;
- std::string _sizing_text;
- bool _markup;
- Element _elements;
- Gtkmm2ext::ArdourIcon::Icon _icon;
- rendercallback_t _icon_render_cb;
- void* _icon_render_cb_data;
- Tweaks _tweaks;
- BindingProxy binding_proxy;
-
- void set_text_internal ();
- void recalc_char_pixel_geometry ();
- unsigned int _char_pixel_width;
- unsigned int _char_pixel_height;
- float _char_avg_pixel_width;
-
- int _text_width;
- int _text_height;
- float _diameter;
- float _corner_radius;
- int _corner_mask;
-
- double _angle;
- float _xalign, _yalign;
-
- uint32_t fill_inactive_color;
- uint32_t fill_active_color;
-
- uint32_t text_active_color;
- uint32_t text_inactive_color;
-
- uint32_t led_active_color;
- uint32_t led_inactive_color;
- uint32_t led_custom_color;
- bool use_custom_led_color;
-
- cairo_pattern_t* convex_pattern;
- cairo_pattern_t* concave_pattern;
- cairo_pattern_t* led_inset_pattern;
- cairo_rectangle_t* _led_rect;
-
- bool _act_on_release;
- bool _led_left;
- bool _distinct_led_click;
- bool _hovering;
- bool _focused;
- int _fixed_colors_set;
- bool _fallthrough_to_parent;
- int _layout_ellipsize_width;
- Pango::EllipsizeMode _ellipsis;
- bool _update_colors;
- int _pattern_height;
-
- void setup_led_rect ();
- void set_colors ();
- void color_handler ();
- void build_patterns ();
- void ensure_layout ();
-
- void action_toggled ();
- void action_sensitivity_changed ();
- void action_visibility_changed ();
- void action_tooltip_changed ();
-};
-
-#endif /* __gtk2_ardour_ardour_button_h__ */
+++ /dev/null
-/*
- Copyright (C) 2014 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 <pangomm/layout.h>
-
-#include "pbd/compose.h"
-#include "pbd/controllable.h"
-#include "pbd/error.h"
-#include "pbd/stacktrace.h"
-
-#include "gtkmm2ext/utils.h"
-#include "gtkmm2ext/rgb_macros.h"
-#include "gtkmm2ext/gui_thread.h"
-#include "gtkmm2ext/keyboard.h"
-
-#include "ardour/rc_configuration.h" // for widget prelight preference
-
-#include "ardour_display.h"
-
-#include "pbd/i18n.h"
-
-using namespace Gtkmm2ext;
-using namespace Gdk;
-using namespace Gtk;
-using namespace Glib;
-using namespace PBD;
-using std::max;
-using std::min;
-using namespace std;
-
-
-ArdourDisplay::ArdourDisplay (Element e)
-{
- add_elements(ArdourButton::Text);
-}
-
-ArdourDisplay::~ArdourDisplay ()
-{
-}
-
-
-bool
-ArdourDisplay::on_scroll_event (GdkEventScroll* ev)
-{
- /* mouse wheel */
-
- float scale = 1.0;
- if (ev->state & Keyboard::GainFineScaleModifier) {
- if (ev->state & Keyboard::GainExtraFineScaleModifier) {
- scale *= 0.01;
- } else {
- scale *= 0.10;
- }
- }
-
- boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
- if (c) {
- float val = c->get_interface();
-
- if ( ev->direction == GDK_SCROLL_UP )
- val += 0.05 * scale; //by default, we step in 1/20ths of the knob travel
- else
- val -= 0.05 * scale;
-
- c->set_interface(val);
- }
-
- return true;
-}
-
-
-void
-ArdourDisplay::add_controllable_preset (const char *txt, float val)
-{
- using namespace Menu_Helpers;
- AddMenuElem(MenuElem (txt, sigc::bind (sigc::mem_fun(*this, &ArdourDisplay::handle_controllable_preset), val)));
-}
-
-
-void
-ArdourDisplay::handle_controllable_preset (float p)
-{
- boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
-
- if (!c) return;
-
- /* This should not use dB_to_coefficient(), but the Controllable's value.
- *
- * The only user of this API is currently monitor_section.cc which conveniently
- * binds dB values. Once there are other use-cases, for this, this (GUI only) API
- * needs fixing.
- */
- c->set_value(dB_to_coefficient (p), Controllable::NoGroup);
-}
-
-
-void
-ArdourDisplay::set_controllable (boost::shared_ptr<Controllable> c)
-{
- watch_connection.disconnect (); //stop watching the old controllable
-
- if (!c) return;
-
- binding_proxy.set_controllable (c);
-
- c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&ArdourDisplay::controllable_changed, this), gui_context());
-
- controllable_changed();
-}
-
-void
-ArdourDisplay::controllable_changed ()
-{
- boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
-
- if (!c) return;
-
- set_text(c->get_user_string());
-
- set_dirty();
-}
+++ /dev/null
-/*
- Copyright (C) 2014 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_ardour_display_h__
-#define __gtk2_ardour_ardour_display_h__
-
-#include <list>
-#include <stdint.h>
-
-#include <gtkmm/action.h>
-#include <gtkmm/menu.h>
-#include <gtkmm/menuitem.h>
-
-
-#include "ardour_dropdown.h"
-
-class ArdourDisplay : public ArdourDropdown
-{
-public:
-
- ArdourDisplay (Element e = default_elements);
- virtual ~ArdourDisplay ();
-
- boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
- void set_controllable (boost::shared_ptr<PBD::Controllable> c);
-
- bool on_scroll_event (GdkEventScroll* ev);
-
- void add_controllable_preset (const char*, float);
- void handle_controllable_preset (float p);
-
- void controllable_changed ();
- PBD::ScopedConnection watch_connection;
-};
-
-#endif /* __gtk2_ardour_ardour_menu_h__ */
+++ /dev/null
-/*
- Copyright (C) 2014 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 <pangomm/layout.h>
-
-#include "pbd/compose.h"
-#include "pbd/error.h"
-#include "pbd/stacktrace.h"
-
-#include "gtkmm2ext/utils.h"
-#include "gtkmm2ext/rgb_macros.h"
-#include "gtkmm2ext/gui_thread.h"
-
-#include "ardour/rc_configuration.h" // for widget prelight preference
-
-#include "ardour_dropdown.h"
-
-#include "pbd/i18n.h"
-
-#define REFLECTION_HEIGHT 2
-
-using namespace Gdk;
-using namespace Gtk;
-using namespace Glib;
-using namespace PBD;
-using namespace std;
-
-
-ArdourDropdown::ArdourDropdown (Element e)
- : _scrolling_disabled(false)
-{
-// signal_button_press_event().connect (sigc::mem_fun(*this, &ArdourDropdown::on_mouse_pressed));
- _menu.signal_size_request().connect (sigc::mem_fun(*this, &ArdourDropdown::menu_size_request));
-
- _menu.set_reserve_toggle_size(false);
-
- add_elements(e);
- add_elements(ArdourButton::Menu);
-}
-
-ArdourDropdown::~ArdourDropdown ()
-{
-}
-
-void
-ArdourDropdown::menu_size_request(Requisition *req) {
- req->width = max(req->width, get_allocation().get_width());
-}
-
-bool
-ArdourDropdown::on_button_press_event (GdkEventButton* ev)
-{
- if (binding_proxy.button_press_handler (ev)) {
- return true;
- }
-
- if (ev->type == GDK_BUTTON_PRESS && ev->button == 1) {
- Gtkmm2ext::anchored_menu_popup(&_menu, this, get_text(), 1, ev->time);
- }
-
- return true;
-}
-
-bool
-ArdourDropdown::on_scroll_event (GdkEventScroll* ev)
-{
- using namespace Menu_Helpers;
-
- if (_scrolling_disabled) {
- return false;
- }
-
- const MenuItem * current_active = _menu.get_active();
- const MenuList& items = _menu.items ();
- int c = 0;
-
- if (!current_active) {
- return true;
- }
-
- /* work around another gtkmm API clusterfuck
- * const MenuItem* get_active () const
- * void set_active (guint index)
- *
- * also MenuList.activate_item does not actually
- * set it as active in the menu.
- *
- */
-
- switch (ev->direction) {
- case GDK_SCROLL_UP:
-
- for (MenuList::const_reverse_iterator i = items.rbegin(); i != items.rend(); ++i, ++c) {
- if ( &(*i) != current_active) {
- continue;
- }
- if (++i != items.rend()) {
- c = items.size() - 2 - c;
- assert(c >= 0);
- _menu.set_active(c);
- _menu.activate_item(*i);
- }
- break;
- }
- break;
- case GDK_SCROLL_DOWN:
- for (MenuList::const_iterator i = items.begin(); i != items.end(); ++i, ++c) {
- if ( &(*i) != current_active) {
- continue;
- }
- if (++i != items.end()) {
- assert(c + 1 < (int) items.size());
- _menu.set_active(c + 1);
- _menu.activate_item(*i);
- }
- break;
- }
- break;
- default:
- break;
- }
- return true;
-}
-
-void
-ArdourDropdown::clear_items ()
-{
- _menu.items ().clear ();
-}
-
-void
-ArdourDropdown::AddMenuElem (Menu_Helpers::Element e)
-{
- using namespace Menu_Helpers;
-
- MenuList& items = _menu.items ();
-
- items.push_back (e);
-}
-
-void
-ArdourDropdown::disable_scrolling()
-{
- _scrolling_disabled = true;
-}
+++ /dev/null
-/*
- Copyright (C) 2014 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_ardour_dropdown_h__
-#define __gtk2_ardour_ardour_dropdown_h__
-
-#include <list>
-#include <stdint.h>
-
-#include <gtkmm/action.h>
-#include <gtkmm/menu.h>
-#include <gtkmm/menuitem.h>
-
-
-#include "ardour_button.h"
-
-class ArdourDropdown : public ArdourButton
-{
-public:
-
- ArdourDropdown (Element e = default_elements);
- virtual ~ArdourDropdown ();
-
- bool on_button_press_event (GdkEventButton*);
- bool on_scroll_event (GdkEventScroll*);
- void menu_size_request(Gtk::Requisition*);
-
- void clear_items ();
- void AddMenuElem (Gtk::Menu_Helpers::Element e);
-
- void disable_scrolling();
-
- Gtk::Menu_Helpers::MenuList& items () { return _menu.items (); }
-
-private:
- Gtk::Menu _menu;
-
- bool _scrolling_disabled;
-};
-
-#endif /* __gtk2_ardour_ardour_dropdown_h__ */
+++ /dev/null
-/*
- 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 <pangomm/layout.h>
-
-#include "pbd/compose.h"
-#include "pbd/controllable.h"
-#include "pbd/error.h"
-#include "pbd/stacktrace.h"
-
-#include "gtkmm2ext/utils.h"
-#include "gtkmm2ext/rgb_macros.h"
-#include "gtkmm2ext/gui_thread.h"
-#include "gtkmm2ext/keyboard.h"
-
-#include "ardour/automation_control.h"
-#include "ardour/rc_configuration.h" // for widget prelight preference
-
-#include "ardour_knob.h"
-#include "timers.h"
-#include "ui_config.h"
-
-#include "canvas/colors.h"
-#include "canvas/utils.h"
-
-#include "pbd/i18n.h"
-
-using namespace Gtkmm2ext;
-using namespace Gtk;
-using namespace Glib;
-using namespace PBD;
-using std::max;
-using std::min;
-using namespace std;
-
-ArdourKnob::Element ArdourKnob::default_elements = ArdourKnob::Element (ArdourKnob::Arc);
-
-ArdourKnob::ArdourKnob (Element e, Flags flags)
- : _elements (e)
- , _hovering (false)
- , _grabbed_x (0)
- , _grabbed_y (0)
- , _val (0)
- , _normal (0)
- , _dead_zone_delta (0)
- , _flags (flags)
- , _tooltip (this)
-{
- UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &ArdourKnob::color_handler));
-
- // watch automation :(
- // TODO only use for GainAutomation
- Timers::rapid_connect (sigc::bind (sigc::mem_fun (*this, &ArdourKnob::controllable_changed), false));
-}
-
-ArdourKnob::~ArdourKnob()
-{
-}
-
-void
-ArdourKnob::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
-{
- cairo_t* cr = ctx->cobj();
- cairo_pattern_t* shade_pattern;
-
- float width = get_width();
- float height = get_height();
-
- const float scale = min(width, height);
- const float pointer_thickness = 3.0 * (scale/80); //(if the knob is 80 pixels wide, we want a 3-pix line on it)
-
- const float start_angle = ((180 - 65) * G_PI) / 180;
- const float end_angle = ((360 + 65) * G_PI) / 180;
-
- float zero = 0;
- if (_flags & ArcToZero) {
- zero = _normal;
- }
-
- const float value_angle = start_angle + (_val * (end_angle - start_angle));
- const float zero_angle = start_angle + (zero * (end_angle - start_angle));
-
- float value_x = cos (value_angle);
- float value_y = sin (value_angle);
-
- float xc = 0.5 + width/ 2.0;
- float yc = 0.5 + height/ 2.0;
-
- cairo_translate (cr, xc, yc); //after this, everything is based on the center of the knob
-
- //get the knob color from the theme
- ArdourCanvas::Color knob_color = UIConfiguration::instance().color (string_compose ("%1", get_name()));
-
- float center_radius = 0.48*scale;
- float border_width = 0.8;
-
- bool arc = (_elements & Arc)==Arc;
- bool bevel = (_elements & Bevel)==Bevel;
- bool flat = _flat_buttons;
-
- if ( arc ) {
- center_radius = scale*0.33;
-
- float inner_progress_radius = scale*0.38;
- float outer_progress_radius = scale*0.48;
- float progress_width = (outer_progress_radius-inner_progress_radius);
- float progress_radius = inner_progress_radius + progress_width/2.0;
-
- //dark arc background
- cairo_set_source_rgb (cr, 0.3, 0.3, 0.3 );
- cairo_set_line_width (cr, progress_width);
- cairo_arc (cr, 0, 0, progress_radius, start_angle, end_angle);
- cairo_stroke (cr);
-
- //look up the arc colors from the config
- double red_start, green_start, blue_start, unused;
- ArdourCanvas::Color arc_start_color = UIConfiguration::instance().color ( string_compose ("%1: arc start", get_name()));
- ArdourCanvas::color_to_rgba( arc_start_color, red_start, green_start, blue_start, unused );
- double red_end, green_end, blue_end;
- ArdourCanvas::Color arc_end_color = UIConfiguration::instance().color ( string_compose ("%1: arc end", get_name()) );
- ArdourCanvas::color_to_rgba( arc_end_color, red_end, green_end, blue_end, unused );
-
- //vary the arc color over the travel of the knob
- float intensity = fabsf (_val - zero) / std::max(zero, (1.f - zero));
- const float intensity_inv = 1.0 - intensity;
- float r = intensity_inv * red_end + intensity * red_start;
- float g = intensity_inv * green_end + intensity * green_start;
- float b = intensity_inv * blue_end + intensity * blue_start;
-
- //draw the arc
- cairo_set_source_rgb (cr, r,g,b);
- cairo_set_line_width (cr, progress_width);
- if (zero_angle > value_angle) {
- cairo_arc (cr, 0, 0, progress_radius, value_angle, zero_angle);
- } else {
- cairo_arc (cr, 0, 0, progress_radius, zero_angle, value_angle);
- }
- cairo_stroke (cr);
-
- //shade the arc
- if (!flat) {
- shade_pattern = cairo_pattern_create_linear (0.0, -yc, 0.0, yc); //note we have to offset the pattern from our centerpoint
- cairo_pattern_add_color_stop_rgba (shade_pattern, 0.0, 1,1,1, 0.15);
- cairo_pattern_add_color_stop_rgba (shade_pattern, 0.5, 1,1,1, 0.0);
- cairo_pattern_add_color_stop_rgba (shade_pattern, 1.0, 1,1,1, 0.0);
- cairo_set_source (cr, shade_pattern);
- cairo_arc (cr, 0, 0, outer_progress_radius-1, 0, 2.0*G_PI);
- cairo_fill (cr);
- cairo_pattern_destroy (shade_pattern);
- }
-
-#if 0 //black border
- const float start_angle_x = cos (start_angle);
- const float start_angle_y = sin (start_angle);
- const float end_angle_x = cos (end_angle);
- const float end_angle_y = sin (end_angle);
-
- cairo_set_source_rgb (cr, 0, 0, 0 );
- cairo_set_line_width (cr, border_width);
- cairo_move_to (cr, (outer_progress_radius * start_angle_x), (outer_progress_radius * start_angle_y));
- cairo_line_to (cr, (inner_progress_radius * start_angle_x), (inner_progress_radius * start_angle_y));
- cairo_stroke (cr);
- cairo_move_to (cr, (outer_progress_radius * end_angle_x), (outer_progress_radius * end_angle_y));
- cairo_line_to (cr, (inner_progress_radius * end_angle_x), (inner_progress_radius * end_angle_y));
- cairo_stroke (cr);
- cairo_arc (cr, 0, 0, outer_progress_radius, start_angle, end_angle);
- cairo_stroke (cr);
-#endif
- }
-
- if (!flat) {
- //knob shadow
- cairo_save(cr);
- cairo_translate(cr, pointer_thickness+1, pointer_thickness+1 );
- cairo_set_source_rgba (cr, 0, 0, 0, 0.1 );
- cairo_arc (cr, 0, 0, center_radius-1, 0, 2.0*G_PI);
- cairo_fill (cr);
- cairo_restore(cr);
-
- //inner circle
- ArdourCanvas::set_source_rgba(cr, knob_color);
- cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
- cairo_fill (cr);
-
- //gradient
- if (bevel) {
- //knob gradient
- shade_pattern = cairo_pattern_create_linear (0.0, -yc, 0.0, yc); //note we have to offset the gradient from our centerpoint
- cairo_pattern_add_color_stop_rgba (shade_pattern, 0.0, 1,1,1, 0.2);
- cairo_pattern_add_color_stop_rgba (shade_pattern, 0.2, 1,1,1, 0.2);
- cairo_pattern_add_color_stop_rgba (shade_pattern, 0.8, 0,0,0, 0.2);
- cairo_pattern_add_color_stop_rgba (shade_pattern, 1.0, 0,0,0, 0.2);
- cairo_set_source (cr, shade_pattern);
- cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
- cairo_fill (cr);
- cairo_pattern_destroy (shade_pattern);
-
- //flat top over beveled edge
- ArdourCanvas::set_source_rgb_a (cr, knob_color, 0.5 );
- cairo_arc (cr, 0, 0, center_radius-pointer_thickness, 0, 2.0*G_PI);
- cairo_fill (cr);
- } else {
- //radial gradient
- shade_pattern = cairo_pattern_create_radial ( -center_radius, -center_radius, 1, -center_radius, -center_radius, center_radius*2.5 ); //note we have to offset the gradient from our centerpoint
- cairo_pattern_add_color_stop_rgba (shade_pattern, 0.0, 1,1,1, 0.2);
- cairo_pattern_add_color_stop_rgba (shade_pattern, 1.0, 0,0,0, 0.3);
- cairo_set_source (cr, shade_pattern);
- cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
- cairo_fill (cr);
- cairo_pattern_destroy (shade_pattern);
- }
-
- } else {
- //inner circle
- ArdourCanvas::set_source_rgba(cr, knob_color);
- cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
- cairo_fill (cr);
- }
-
-
- //black knob border
- cairo_set_line_width (cr, border_width);
- cairo_set_source_rgba (cr, 0,0,0, 1 );
- cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
- cairo_stroke (cr);
-
- //line shadow
- if (!flat) {
- cairo_save(cr);
- cairo_translate(cr, 1, 1 );
- cairo_set_source_rgba (cr, 0,0,0,0.3 );
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_set_line_width (cr, pointer_thickness);
- cairo_move_to (cr, (center_radius * value_x), (center_radius * value_y));
- cairo_line_to (cr, ((center_radius*0.4) * value_x), ((center_radius*0.4) * value_y));
- cairo_stroke (cr);
- cairo_restore(cr);
- }
-
- //line
- cairo_set_source_rgba (cr, 1,1,1, 1 );
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
- cairo_set_line_width (cr, pointer_thickness);
- cairo_move_to (cr, (center_radius * value_x), (center_radius * value_y));
- cairo_line_to (cr, ((center_radius*0.4) * value_x), ((center_radius*0.4) * value_y));
- cairo_stroke (cr);
-
- //highlight if grabbed or if mouse is hovering over me
- if (_tooltip.dragging() || (_hovering && UIConfiguration::instance().get_widget_prelight() ) ) {
- cairo_set_source_rgba (cr, 1,1,1, 0.12 );
- cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
- cairo_fill (cr);
- }
-
- cairo_identity_matrix(cr);
-}
-
-void
-ArdourKnob::on_size_request (Gtk::Requisition* req)
-{
- // see ardour-button VectorIcon size, use font scaling as default
- CairoWidget::on_size_request (req); // allow to override
-
- // we're square
- if (req->width < req->height) {
- req->width = req->height;
- }
- if (req->height < req->width) {
- req->height = req->width;
- }
-}
-
-bool
-ArdourKnob::on_scroll_event (GdkEventScroll* ev)
-{
- /* mouse wheel */
-
- float scale = 0.05; //by default, we step in 1/20ths of the knob travel
- if (ev->state & Keyboard::GainFineScaleModifier) {
- if (ev->state & Keyboard::GainExtraFineScaleModifier) {
- scale *= 0.01;
- } else {
- scale *= 0.10;
- }
- }
-
- boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
- if (c) {
- float val = c->get_interface();
-
- if ( ev->direction == GDK_SCROLL_UP )
- val += scale;
- else
- val -= scale;
-
- c->set_interface(val);
- }
-
- return true;
-}
-
-bool
-ArdourKnob::on_motion_notify_event (GdkEventMotion *ev)
-{
- if (!(ev->state & Gdk::BUTTON1_MASK)) {
- return true;
- }
-
- boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
- if (!c) {
- return true;
- }
-
-
- //scale the adjustment based on keyboard modifiers & GUI size
- const float ui_scale = max (1.f, UIConfiguration::instance().get_ui_scale());
- float scale = 0.0025 / ui_scale;
-
- if (ev->state & Keyboard::GainFineScaleModifier) {
- if (ev->state & Keyboard::GainExtraFineScaleModifier) {
- scale *= 0.01;
- } else {
- scale *= 0.10;
- }
- }
-
- //calculate the travel of the mouse
- int delta = (_grabbed_y - ev->y) - (_grabbed_x - ev->x);
- if (delta == 0) {
- return true;
- }
-
- _grabbed_x = ev->x;
- _grabbed_y = ev->y;
- float val = c->get_interface();
-
- if (_flags & Detent) {
- const float px_deadzone = 42.f * ui_scale;
-
- if ((val - _normal) * (val - _normal + delta * scale) < 0) {
- /* detent */
- const int tozero = (_normal - val) * scale;
- int remain = delta - tozero;
- if (abs (remain) > px_deadzone) {
- /* slow down passing the default value */
- remain += (remain > 0) ? px_deadzone * -.5 : px_deadzone * .5;
- delta = tozero + remain;
- _dead_zone_delta = 0;
- } else {
- c->set_value (c->normal(), Controllable::NoGroup);
- _dead_zone_delta = remain / px_deadzone;
- return true;
- }
- }
-
- if (fabsf (rintf((val - _normal) / scale) + _dead_zone_delta) < 1) {
- c->set_value (c->normal(), Controllable::NoGroup);
- _dead_zone_delta += delta / px_deadzone;
- return true;
- }
-
- _dead_zone_delta = 0;
- }
-
- val += delta * scale;
- c->set_interface(val);
-
- return true;
-}
-
-bool
-ArdourKnob::on_button_press_event (GdkEventButton *ev)
-{
- _grabbed_x = ev->x;
- _grabbed_y = ev->y;
- _dead_zone_delta = 0;
-
- if (ev->type != GDK_BUTTON_PRESS) {
- if (_grabbed) {
- remove_modal_grab();
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
- }
- return true;
- }
-
- if (binding_proxy.button_press_handler (ev)) {
- return true;
- }
-
- if (ev->button != 1 && ev->button != 2) {
- return false;
- }
-
- set_active_state (Gtkmm2ext::ExplicitActive);
- _tooltip.start_drag();
- add_modal_grab();
- _grabbed = true;
- gdk_pointer_grab(ev->window,false,
- GdkEventMask( Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK |Gdk::BUTTON_RELEASE_MASK),
- NULL,NULL,ev->time);
- return true;
-}
-
-bool
-ArdourKnob::on_button_release_event (GdkEventButton *ev)
-{
- _tooltip.stop_drag();
- _grabbed = false;
- remove_modal_grab();
- gdk_pointer_ungrab (GDK_CURRENT_TIME);
-
- if ( (_grabbed_y == ev->y && _grabbed_x == ev->x) && Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { //no move, shift-click sets to default
- boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
- if (!c) return false;
- c->set_value (c->normal(), Controllable::NoGroup);
- return true;
- }
-
- unset_active_state ();
-
- return true;
-}
-
-void
-ArdourKnob::color_handler ()
-{
- set_dirty ();
-}
-
-void
-ArdourKnob::on_size_allocate (Allocation& alloc)
-{
- CairoWidget::on_size_allocate (alloc);
-}
-
-void
-ArdourKnob::set_controllable (boost::shared_ptr<Controllable> c)
-{
- watch_connection.disconnect (); //stop watching the old controllable
-
- if (!c) return;
-
- binding_proxy.set_controllable (c);
-
- c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&ArdourKnob::controllable_changed, this, false), gui_context());
-
- _normal = c->internal_to_interface(c->normal());
-
- controllable_changed();
-}
-
-void
-ArdourKnob::controllable_changed (bool force_update)
-{
- boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
- if (!c) return;
-
- float val = c->get_interface();
- val = min( max(0.0f, val), 1.0f); // clamp
-
- if (val == _val && !force_update) {
- return;
- }
-
- _val = val;
- if (!_tooltip_prefix.empty()) {
- boost::shared_ptr<ARDOUR::AutomationControl> ac = boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (c);
- _tooltip.set_tip (_tooltip_prefix + c->get_user_string());
- }
- set_dirty();
-}
-
-void
-ArdourKnob::on_style_changed (const RefPtr<Gtk::Style>&)
-{
- set_dirty ();
-}
-
-void
-ArdourKnob::on_name_changed ()
-{
- set_dirty ();
-}
-
-
-void
-ArdourKnob::set_active_state (Gtkmm2ext::ActiveState s)
-{
- if (_active_state != s)
- CairoWidget::set_active_state (s);
-}
-
-void
-ArdourKnob::set_visual_state (Gtkmm2ext::VisualState s)
-{
- if (_visual_state != s)
- CairoWidget::set_visual_state (s);
-}
-
-
-bool
-ArdourKnob::on_focus_in_event (GdkEventFocus* ev)
-{
- set_dirty ();
- return CairoWidget::on_focus_in_event (ev);
-}
-
-bool
-ArdourKnob::on_focus_out_event (GdkEventFocus* ev)
-{
- set_dirty ();
- return CairoWidget::on_focus_out_event (ev);
-}
-
-bool
-ArdourKnob::on_enter_notify_event (GdkEventCrossing* ev)
-{
- _hovering = true;
-
- set_dirty ();
-
- boost::shared_ptr<PBD::Controllable> c (binding_proxy.get_controllable ());
- if (c) {
- PBD::Controllable::GUIFocusChanged (boost::weak_ptr<PBD::Controllable> (c));
- }
-
- return CairoWidget::on_enter_notify_event (ev);
-}
-
-bool
-ArdourKnob::on_leave_notify_event (GdkEventCrossing* ev)
-{
- _hovering = false;
-
- set_dirty ();
-
- if (binding_proxy.get_controllable()) {
- PBD::Controllable::GUIFocusChanged (boost::weak_ptr<PBD::Controllable> ());
- }
-
- return CairoWidget::on_leave_notify_event (ev);
-}
-
-void
-ArdourKnob::set_elements (Element e)
-{
- _elements = e;
-}
-
-void
-ArdourKnob::add_elements (Element e)
-{
- _elements = (ArdourKnob::Element) (_elements | e);
-}
-
-
-KnobPersistentTooltip::KnobPersistentTooltip (Gtk::Widget* w)
- : PersistentTooltip (w, true, 3)
- , _dragging (false)
-{
-}
-
-void
-KnobPersistentTooltip::start_drag ()
-{
- _dragging = true;
-}
-
-void
-KnobPersistentTooltip::stop_drag ()
-{
- _dragging = false;
-}
-
-bool
-KnobPersistentTooltip::dragging () const
-{
- return _dragging;
-}
+++ /dev/null
-/*
- Copyright (C) 2014 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_ardour_knob_h__
-#define __gtk2_ardour_ardour_knob_h__
-
-#include <list>
-#include <stdint.h>
-
-#include <gtkmm/action.h>
-
-#include "pbd/signals.h"
-#include "ardour/automatable.h"
-
-#include "gtkmm2ext/binding_proxy.h"
-#include "gtkmm2ext/activatable.h"
-#include "gtkmm2ext/cairo_widget.h"
-#include "gtkmm2ext/persistent_tooltip.h"
-
-class KnobPersistentTooltip : public Gtkmm2ext::PersistentTooltip
-{
-public:
- KnobPersistentTooltip (Gtk::Widget* w);
-
- void start_drag ();
- void stop_drag ();
- bool dragging () const;
-
-private:
- bool _dragging;
-};
-
-
-class ArdourKnob : public CairoWidget , public Gtkmm2ext::Activatable
-{
-public:
-
- enum Element {
- Arc = 0x1,
- Bevel = 0x2,
- unused2 = 0x4,
- unused3 = 0x8,
- unused4 = 0x10,
- unused5 = 0x20,
- };
-
- enum Flags {
- NoFlags = 0,
- Detent = 0x1,
- ArcToZero = 0x2,
- };
-
- ArdourKnob (Element e = default_elements, Flags flags = NoFlags);
- virtual ~ArdourKnob ();
-
- void set_active_state (Gtkmm2ext::ActiveState);
- void set_visual_state (Gtkmm2ext::VisualState);
-
- Element elements() const { return _elements; }
- void set_elements (Element);
- void add_elements (Element);
- static Element default_elements;
-
- void set_tooltip_prefix (std::string pfx) { _tooltip_prefix = pfx; controllable_changed (true); }
-
- boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
- void set_controllable (boost::shared_ptr<PBD::Controllable> c);
-
- bool on_button_press_event (GdkEventButton*);
- bool on_button_release_event (GdkEventButton*);
- bool on_scroll_event (GdkEventScroll* ev);
- bool on_motion_notify_event (GdkEventMotion *ev) ;
-
- void color_handler ();
-
- protected:
- void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
- void on_size_request (Gtk::Requisition* req);
- void on_size_allocate (Gtk::Allocation&);
- void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
- void on_name_changed ();
- bool on_enter_notify_event (GdkEventCrossing*);
- bool on_leave_notify_event (GdkEventCrossing*);
- bool on_focus_in_event (GdkEventFocus*);
- bool on_focus_out_event (GdkEventFocus*);
-
- void controllable_changed (bool force_update = false);
- PBD::ScopedConnection watch_connection;
-
-
- private:
- Element _elements;
- BindingProxy binding_proxy;
-
- bool _hovering;
- float _grabbed_x;
- float _grabbed_y;
-
- float _val; // current value [0..1]
- float _normal; // default value, arc
- float _dead_zone_delta;
-
- Flags _flags;
-
- void action_sensitivity_changed ();
- void action_visibility_changed ();
- void action_tooltip_changed ();
-
- std::string _tooltip_prefix;
- KnobPersistentTooltip _tooltip;
-};
-
-#endif /* __gtk2_ardour_ardour_knob_h__ */
+++ /dev/null
-/*
- * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#ifndef __gtkardour_ardour_spacer_h__
-#define __gtkardour_ardour_spacer_h__
-
-#include "gtkmm2ext/cairo_widget.h"
-
-class ArdourVSpacer : public CairoWidget
-{
-public:
- ArdourVSpacer (float r = 0.75f) : CairoWidget (), ratio (r) {}
-
-protected:
- void render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t* r) {
- float h = r->height * ratio;
- float t = .5f * (r->height - h);
- ctx->rectangle (0, t, 1, h);
- ctx->set_source_rgb (0, 0, 0);
- ctx->fill ();
- }
-
- void on_size_request (Gtk::Requisition* req) {
- req->width = 1;
- req->height = 0;
- CairoWidget::on_size_request (req);
- }
-
- float ratio;
-};
-
-#endif
+++ /dev/null
-/*
- * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
- * Copyright (C) 2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include "gtkmm2ext/gui_thread.h"
-#include "gtkmm2ext/utils.h"
-#include "gtkmm2ext/keyboard.h"
-
-#include "ardour/value_as_string.h"
-
-#include "ardour_spinner.h"
-
-using namespace ARDOUR;
-
-ArdourSpinner::ArdourSpinner (
- boost::shared_ptr<ARDOUR::AutomationControl> c,
- Gtk::Adjustment* adj)
- : _btn (ArdourButton::Text)
- , _ctrl_adj (adj)
- , _spin_adj (0, c->lower (), c->upper (), .1, .01)
- , _spinner (_spin_adj)
- , _switching (false)
- , _switch_on_release (false)
- , _ctrl_ignore (false)
- , _spin_ignore (false)
- , _controllable (c)
-{
- add_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
- set (.5, .5, 1.0, 1.0);
- set_border_width (0);
-
- _btn.set_controllable (c);
- _btn.set_fallthrough_to_parent (true);
-
- _spinner.signal_activate().connect (mem_fun (*this, &ArdourSpinner::entry_activated));
- _spinner.signal_focus_out_event().connect (mem_fun (*this, &ArdourSpinner::entry_focus_out));
- _spinner.set_digits (4);
- _spinner.set_numeric (true);
- _spinner.set_name ("BarControlSpinner");
-
- _spin_adj.set_step_increment(c->interface_to_internal(_ctrl_adj->get_step_increment()) - c->lower ());
- _spin_adj.set_page_increment(c->interface_to_internal(_ctrl_adj->get_page_increment()) - c->lower ());
-
- _spin_adj.signal_value_changed().connect (sigc::mem_fun(*this, &ArdourSpinner::spin_adjusted));
- adj->signal_value_changed().connect (sigc::mem_fun(*this, &ArdourSpinner::ctrl_adjusted));
- c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&ArdourSpinner::controllable_changed, this), gui_context());
-
-
- // this assume the "upper" value needs most space.
- std::string txt = ARDOUR::value_as_string (c->desc(), c->upper ());
- Gtkmm2ext::set_size_request_to_display_given_text (*this, txt, 2, 2);
-
- add (_btn);
- show_all ();
-
- controllable_changed();
- ctrl_adjusted ();
-}
-
-
-ArdourSpinner::~ArdourSpinner ()
-{
-}
-
-bool
-ArdourSpinner::on_button_press_event (GdkEventButton* ev)
-{
- if (get_child() != &_btn) {
- return false;
- }
-
- if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
- _switch_on_release = true;
- return true;
- } else {
- _switch_on_release = false;
- }
- return false;
-}
-
-bool
-ArdourSpinner::on_button_release_event (GdkEventButton* ev)
-{
- if (get_child() != &_btn) {
- return false;
- }
- if (ev->button == 1 && _switch_on_release) {
- Glib::signal_idle().connect (mem_fun (*this, &ArdourSpinner::switch_to_spinner));
- return true;
- }
- return false;
-}
-
-bool
-ArdourSpinner::on_scroll_event (GdkEventScroll* ev)
-{
- float scale = 1.0;
- if (ev->state & Gtkmm2ext::Keyboard::GainFineScaleModifier) {
- if (ev->state & Gtkmm2ext::Keyboard::GainExtraFineScaleModifier) {
- scale *= 0.01;
- } else {
- scale *= 0.10;
- }
- }
-
- boost::shared_ptr<PBD::Controllable> c = _btn.get_controllable();
- if (c) {
- float val = c->get_interface();
-
- if ( ev->direction == GDK_SCROLL_UP )
- val += 0.05 * scale; //by default, we step in 1/20ths of the knob travel
- else
- val -= 0.05 * scale;
-
- c->set_interface(val);
- }
-
- return true;
-}
-
-gint
-ArdourSpinner::switch_to_button ()
-{
- if (_switching || get_child() == &_btn) {
- return false;
- }
- _switching = true;
- remove ();
- add (_btn);
- _btn.show ();
- _btn.set_dirty ();
- _switching = false;
- return false;
-}
-
-gint
-ArdourSpinner::switch_to_spinner ()
-{
- if (_switching || get_child() != &_btn) {
- return false;
- }
- _switching = true;
- remove ();
- add (_spinner);
- _spinner.show ();
- _spinner.select_region (0, _spinner.get_text_length ());
- _spinner.grab_focus ();
- _switching = false;
- return false;
-}
-
-void
-ArdourSpinner::entry_activated ()
-{
- switch_to_button ();
-}
-
-bool
-ArdourSpinner::entry_focus_out (GdkEventFocus* /*ev*/)
-{
- entry_activated ();
- return true;
-}
-
-void
-ArdourSpinner::ctrl_adjusted ()
-{
- if (_spin_ignore) {
- return;
- }
- _ctrl_ignore = true;
- _spin_adj.set_value (_controllable->interface_to_internal (_ctrl_adj->get_value ()));
- _ctrl_ignore = false;
-}
-
-void
-ArdourSpinner::spin_adjusted ()
-{
- if (_ctrl_ignore) {
- return;
- }
- _spin_ignore = true;
- _ctrl_adj->set_value (_controllable->internal_to_interface (_spin_adj.get_value ()));
- _spin_ignore = false;
-}
-
-void
-ArdourSpinner::controllable_changed ()
-{
- _btn.set_text (_controllable->get_user_string());
- _btn.set_dirty();
-}
+++ /dev/null
-/*
- * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
- * Copyright (C) 2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-#include <boost/algorithm/string.hpp>
-#ifndef __gtk2_ardour_ardour_spinner_h__
-#define __gtk2_ardour_ardour_spinner_h__
-
-#include <gtkmm.h>
-
-#include "ardour/automatable.h"
-#include "ardour/automation_control.h"
-#include "ardour_button.h"
-
-class ArdourSpinner : public Gtk::Alignment
-{
- public:
- ArdourSpinner (
- boost::shared_ptr<ARDOUR::AutomationControl>,
- Gtk::Adjustment* adj);
-
- virtual ~ArdourSpinner ();
-
- protected:
- bool on_button_press_event (GdkEventButton*);
- bool on_button_release_event (GdkEventButton*);
- bool on_scroll_event (GdkEventScroll* ev);
-
- void controllable_changed ();
- PBD::ScopedConnection watch_connection;
-
- private:
-
- bool entry_focus_out (GdkEventFocus*);
- void entry_activated ();
- gint switch_to_button ();
- gint switch_to_spinner ();
-
- void ctrl_adjusted();
- void spin_adjusted();
-
- ArdourButton _btn;
- Gtk::Adjustment* _ctrl_adj;
- Gtk::Adjustment _spin_adj;
- Gtk::SpinButton _spinner;
- bool _switching;
- bool _switch_on_release;
- bool _ctrl_ignore;
- bool _spin_ignore;
-
- boost::shared_ptr<ARDOUR::AutomationControl> _controllable;
-
-};
-
-#endif /* __gtk2_ardour_ardour_menu_h__ */
using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Gtkmm2ext;
+using namespace ArdourWidgets;
using namespace Gtk;
using namespace std;
using namespace Editing;
, solo_alert_button (_("Solo"))
, feedback_alert_button (_("Feedback"))
, error_alert_button ( ArdourButton::just_led_default_elements )
- , editor_meter(0)
, editor_meter_peak_display()
+ , editor_meter(0)
, _suspend_editor_meter_callbacks (false)
, _numpad_locate_happening (false)
, _session_is_new (false)
#include "video_timeline.h"
+#include "widgets/ardour_button.h"
+#include "widgets/ardour_spacer.h"
+
#include "add_route_dialog.h"
-#include "ardour_button.h"
#include "ardour_dialog.h"
-#include "ardour_spacer.h"
#include "ardour_window.h"
#include "editing.h"
#include "enums.h"
class VideoTimeLine;
class ArdourKeyboard;
-class ArdourVSpacer;
class AudioClock;
class ButtonJoiner;
class ConnectionEditor;
Gtk::Frame transport_frame;
Gtk::HBox transport_hbox;
- ArdourVSpacer *secondary_clock_spacer;
+ ArdourWidgets::ArdourVSpacer* secondary_clock_spacer;
void repack_transport_hbox ();
void update_clock_visibility ();
void set_transport_controllable_state (const XMLNode&);
XMLNode& get_transport_controllable_state ();
- ArdourButton roll_button;
- ArdourButton stop_button;
- ArdourButton goto_start_button;
- ArdourButton goto_end_button;
- ArdourButton auto_loop_button;
- ArdourButton play_selection_button;
- ArdourButton rec_button;
- ArdourButton punch_in_button;
- ArdourButton punch_out_button;
- ArdourButton layered_button;
+ ArdourWidgets::ArdourButton roll_button;
+ ArdourWidgets::ArdourButton stop_button;
+ ArdourWidgets::ArdourButton goto_start_button;
+ ArdourWidgets::ArdourButton goto_end_button;
+ ArdourWidgets::ArdourButton auto_loop_button;
+ ArdourWidgets::ArdourButton play_selection_button;
+ ArdourWidgets::ArdourButton rec_button;
+ ArdourWidgets::ArdourButton punch_in_button;
+ ArdourWidgets::ArdourButton punch_out_button;
+ ArdourWidgets::ArdourButton layered_button;
- ArdourVSpacer recpunch_spacer;
- ArdourVSpacer monitoring_spacer;
+ ArdourWidgets::ArdourVSpacer recpunch_spacer;
+ ArdourWidgets::ArdourVSpacer monitoring_spacer;
- ArdourButton monitor_in_button;
- ArdourButton monitor_disk_button;
- ArdourButton auto_input_button;
+ ArdourWidgets::ArdourButton monitor_in_button;
+ ArdourWidgets::ArdourButton monitor_disk_button;
+ ArdourWidgets::ArdourButton auto_input_button;
Gtk::Label punch_label;
Gtk::Label layered_label;
MiniTimeline mini_timeline;
TimeInfoBox *time_info_box;
- ArdourButton auto_return_button;
- ArdourButton follow_edits_button;
- ArdourButton click_button;
- ArdourButton sync_button;
+ ArdourWidgets::ArdourButton auto_return_button;
+ ArdourWidgets::ArdourButton follow_edits_button;
+ ArdourWidgets::ArdourButton click_button;
+ ArdourWidgets::ArdourButton sync_button;
- ArdourButton auditioning_alert_button;
- ArdourButton solo_alert_button;
- ArdourButton feedback_alert_button;
- ArdourButton error_alert_button;
+ ArdourWidgets::ArdourButton auditioning_alert_button;
+ ArdourWidgets::ArdourButton solo_alert_button;
+ ArdourWidgets::ArdourButton feedback_alert_button;
+ ArdourWidgets::ArdourButton error_alert_button;
- ArdourButton action_script_call_btn[10];
+ ArdourWidgets::ArdourButton action_script_call_btn[10];
Gtk::Table action_script_table;
Gtk::VBox alert_box;
Gtk::VBox meter_box;
- LevelMeterHBox * editor_meter;
- float editor_meter_max_peak;
- ArdourButton editor_meter_peak_display;
- bool editor_meter_peak_button_release (GdkEventButton*);
+ ArdourWidgets::ArdourButton editor_meter_peak_display;
+ LevelMeterHBox * editor_meter;
+ float editor_meter_max_peak;
+ bool editor_meter_peak_button_release (GdkEventButton*);
bool editor_meter_button_press (GdkEventButton* ev);
void popup_editor_meter_menu (GdkEventButton* ev);
void feedback_detected ();
- ArdourButton midi_panic_button;
+ ArdourWidgets::ArdourButton midi_panic_button;
void midi_panic ();
void successful_graph_sort ();
void tabs_switch (GtkNotebookPage*, guint page_number);
void tabs_page_added (Gtk::Widget*, guint);
void tabs_page_removed (Gtk::Widget*, guint);
- ArdourButton editor_visibility_button;
- ArdourButton mixer_visibility_button;
- ArdourButton prefs_visibility_button;
+ ArdourWidgets::ArdourButton editor_visibility_button;
+ ArdourWidgets::ArdourButton mixer_visibility_button;
+ ArdourWidgets::ArdourButton prefs_visibility_button;
bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev, Gtkmm2ext::Bindings*);
bool try_gtk_accel_binding (GtkWindow* win, GdkEventKey* ev, bool translate, GdkModifierType modifier);
using namespace ARDOUR;
using namespace PBD;
using namespace Gtkmm2ext;
+using namespace ArdourWidgets;
using namespace Gtk;
using namespace Glib;
using namespace ARDOUR_UI_UTILS;
using namespace Glib;
using namespace Gtk;
using namespace Gtkmm2ext;
+using namespace ArdourWidgets;
void
ARDOUR_UI::set_session (Session *s)
using namespace Gtkmm2ext;
using namespace ARDOUR;
using namespace PBD;
+using namespace ArdourWidgets;
void
ARDOUR_UI::toggle_external_sync()
#include "gtkmm2ext/utils.h"
#include "gtkmm2ext/rgb_macros.h"
+#include "widgets/tooltips.h"
+
#include "ardour/profile.h"
#include "ardour/lmath.h"
#include "ardour/session.h"
#include "enums_convert.h"
#include "gui_thread.h"
#include "keyboard.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "utils.h"
using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
using namespace PBD;
using namespace Gtk;
using namespace std;
#include "ardour/session_handle.h"
#include "gtkmm2ext/cairo_widget.h"
-#include "ardour_button.h"
+#include "widgets/ardour_button.h"
namespace ARDOUR {
class Session;
void set_session (ARDOUR::Session *s);
void set_negative_allowed (bool yn);
- ArdourButton* left_btn () { return &_left_btn; }
- ArdourButton* right_btn () { return &_right_btn; }
+ ArdourWidgets::ArdourButton* left_btn () { return &_left_btn; }
+ ArdourWidgets::ArdourButton* right_btn () { return &_right_btn; }
/** Alter cairo scaling during rendering.
*
bool on_button_press_event (GdkEventButton *ev);
bool on_button_release_event(GdkEventButton *ev);
- ArdourButton _left_btn;
- ArdourButton _right_btn;
+ ArdourWidgets::ArdourButton _left_btn;
+ ArdourWidgets::ArdourButton _right_btn;
private:
Mode _mode;
#include "gtkmm2ext/bindable_button.h"
#include "gtkmm2ext/utils.h"
+#include "widgets/ardour_button.h"
+
#include "ardour/event_type_map.h"
#include "ardour/pannable.h"
#include "ardour/panner.h"
#include "ardour/panner_shell.h"
-#include "ardour_button.h"
#include "audio_time_axis.h"
#include "automation_line.h"
#include "enums.h"
using namespace std;
using namespace ARDOUR;
+using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Gtk;
#include "ardour/session.h"
#include "ardour/tempo.h"
-#include "ardour_button.h"
-#include "ardour_knob.h"
+#include "widgets/ardour_button.h"
+#include "widgets/ardour_knob.h"
#include "automation_controller.h"
#include "gui_thread.h"
#include "note_select_dialog.h"
using namespace ARDOUR;
using namespace Gtk;
+using namespace ArdourWidgets;
using PBD::Controllable;
#include "canvas/debug.h"
+#include "widgets/tooltips.h"
+
#include "automation_time_axis.h"
#include "automation_streamview.h"
#include "gui_thread.h"
#include "paste_context.h"
#include "public_editor.h"
#include "selection.h"
-#include "tooltips.h"
#include "rgb_macros.h"
#include "point_selection.h"
#include "control_point.h"
using namespace std;
using namespace ARDOUR;
+using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Gtk;
#include "canvas/rectangle.h"
+#include "widgets/ardour_button.h"
+#include "widgets/ardour_dropdown.h"
+
#include "time_axis_view.h"
#include "automation_controller.h"
-#include "ardour_button.h"
-#include "ardour_dropdown.h"
namespace ARDOUR {
class Session;
bool ignore_toggle;
bool first_call_to_set_height;
- ArdourButton hide_button;
- ArdourDropdown auto_dropdown;
+ ArdourWidgets::ArdourButton hide_button;
+ ArdourWidgets::ArdourDropdown auto_dropdown;
Gtk::Label* plugname;
bool plugname_packed;
#include "gtkmm2ext/utils.h"
#include "gtkmm2ext/rgb_macros.h"
+#include "widgets/tooltips.h"
+
#include "button_joiner.h"
-#include "tooltips.h"
#include "ui_config.h"
using namespace Gtk;
+using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
ButtonJoiner::ButtonJoiner (const std::string& str, Gtk::Widget& lw, Gtk::Widget& rw, bool central_joiner)
#include "canvas/scroll_group.h"
#include "canvas/wave_view.h"
-#include "ardour_button.h"
#include "ardour_dialog.h"
#include "color_theme_manager.h"
#include "rgb_macros.h"
#include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/utils.h"
-#include "ardour_button.h"
#include "control_slave_ui.h"
#include "gui_thread.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
+using namespace ArdourWidgets;
using namespace Gtk;
using std::string;
#include "ardour/session_handle.h"
-#include "ardour_button.h"
+#include "widgets/ardour_button.h"
namespace ARDOUR {
class VCA;
private:
boost::shared_ptr<ARDOUR::Stripable> stripable;
- PBD::ScopedConnectionList connections;
- PBD::ScopedConnectionList master_connections;
- ArdourButton initial_button;
+ PBD::ScopedConnectionList connections;
+ PBD::ScopedConnectionList master_connections;
+ ArdourWidgets::ArdourButton initial_button;
void master_property_changed (PBD::PropertyChange const &);
void update_vca_display ();
#include "canvas/debug.h"
#include "canvas/text.h"
+#include "widgets/ardour_spacer.h"
+#include "widgets/tooltips.h"
+
#include "control_protocol/control_protocol.h"
#include "actions.h"
#include "analysis_window.h"
-#include "ardour_spacer.h"
#include "audio_clock.h"
#include "audio_region_view.h"
#include "audio_streamview.h"
#include "time_axis_view.h"
#include "time_info_box.h"
#include "timers.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "utils.h"
#include "vca_time_axis.h"
using namespace std;
using namespace ARDOUR;
+using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Gtk;
#include "canvas/fwd.h"
#include "canvas/ruler.h"
-#include "ardour_button.h"
+#include "widgets/ardour_button.h"
+#include "widgets/ardour_dropdown.h"
+
#include "ardour_dialog.h"
-#include "ardour_dropdown.h"
#include "public_editor.h"
#include "editing.h"
#include "enums.h"
void editor_mixer_button_toggled ();
void editor_list_button_toggled ();
- ArdourButton zoom_in_button;
- ArdourButton zoom_out_button;
- ArdourButton zoom_out_full_button;
+ ArdourWidgets::ArdourButton zoom_in_button;
+ ArdourWidgets::ArdourButton zoom_out_button;
+ ArdourWidgets::ArdourButton zoom_out_full_button;
- ArdourButton tav_expand_button;
- ArdourButton tav_shrink_button;
- ArdourDropdown visible_tracks_selector;
- ArdourDropdown zoom_preset_selector;
+ ArdourWidgets::ArdourButton tav_expand_button;
+ ArdourWidgets::ArdourButton tav_shrink_button;
+ ArdourWidgets::ArdourDropdown visible_tracks_selector;
+ ArdourWidgets::ArdourDropdown zoom_preset_selector;
int32_t _visible_track_count;
void build_track_count_menu ();
Gtk::Table toolbar_selection_clock_table;
Gtk::Label toolbar_selection_cursor_label;
- ArdourButton mouse_select_button;
- ArdourButton mouse_draw_button;
- ArdourButton mouse_move_button;
- ArdourButton mouse_timefx_button;
- ArdourButton mouse_content_button;
- ArdourButton mouse_audition_button;
- ArdourButton mouse_cut_button;
+ ArdourWidgets::ArdourButton mouse_select_button;
+ ArdourWidgets::ArdourButton mouse_draw_button;
+ ArdourWidgets::ArdourButton mouse_move_button;
+ ArdourWidgets::ArdourButton mouse_timefx_button;
+ ArdourWidgets::ArdourButton mouse_content_button;
+ ArdourWidgets::ArdourButton mouse_audition_button;
+ ArdourWidgets::ArdourButton mouse_cut_button;
- ArdourButton smart_mode_button;
+ ArdourWidgets::ArdourButton smart_mode_button;
Glib::RefPtr<Gtk::ToggleAction> smart_mode_action;
void mouse_mode_toggled (Editing::MouseMode m);
Gtk::Button automation_mode_button;
//edit mode menu stuff
- ArdourDropdown edit_mode_selector;
- void edit_mode_selection_done ( ARDOUR::EditMode m );
+ ArdourWidgets::ArdourDropdown edit_mode_selector;
+ void edit_mode_selection_done (ARDOUR::EditMode);
void build_edit_mode_menu ();
- Gtk::VBox edit_mode_box;
+ Gtk::VBox edit_mode_box;
void set_edit_mode (ARDOUR::EditMode);
void cycle_edit_mode ();
- ArdourDropdown snap_type_selector;
+ ArdourWidgets::ArdourDropdown snap_type_selector;
void build_snap_type_menu ();
- ArdourDropdown snap_mode_selector;
+ ArdourWidgets::ArdourDropdown snap_mode_selector;
void build_snap_mode_menu ();
- Gtk::HBox snap_box;
+ Gtk::HBox snap_box;
std::vector<std::string> snap_type_strings;
std::vector<std::string> snap_mode_strings;
Glib::RefPtr<Gtk::RadioAction> snap_mode_action (Editing::SnapMode);
//zoom focus meu stuff
- ArdourDropdown zoom_focus_selector;
- void zoom_focus_selection_done ( Editing::ZoomFocus f );
+ ArdourWidgets::ArdourDropdown zoom_focus_selector;
+ void zoom_focus_selection_done (Editing::ZoomFocus);
void build_zoom_focus_menu ();
std::vector<std::string> zoom_focus_strings;
Glib::RefPtr<Gtk::RadioAction> zoom_focus_action (Editing::ZoomFocus);
- Gtk::HBox _track_box;
+ Gtk::HBox _track_box;
- Gtk::HBox _zoom_box;
- void zoom_adjustment_changed();
+ Gtk::HBox _zoom_box;
+ void zoom_adjustment_changed();
void setup_toolbar ();
void setup_tooltips ();
- Gtk::HBox toolbar_hbox;
+ Gtk::HBox toolbar_hbox;
void setup_midi_toolbar ();
/* transport range select process */
- ArdourCanvas::Rectangle* cd_marker_bar_drag_rect;
- ArdourCanvas::Rectangle* range_bar_drag_rect;
- ArdourCanvas::Rectangle* transport_bar_drag_rect;
- ArdourCanvas::Rectangle *transport_bar_range_rect;
- ArdourCanvas::Rectangle *transport_bar_preroll_rect;
- ArdourCanvas::Rectangle *transport_bar_postroll_rect;
- ArdourCanvas::Rectangle *transport_loop_range_rect;
- ArdourCanvas::Rectangle *transport_punch_range_rect;
- ArdourCanvas::Line *transport_punchin_line;
- ArdourCanvas::Line *transport_punchout_line;
- ArdourCanvas::Rectangle *transport_preroll_rect;
- ArdourCanvas::Rectangle *transport_postroll_rect;
+ ArdourCanvas::Rectangle* cd_marker_bar_drag_rect;
+ ArdourCanvas::Rectangle* range_bar_drag_rect;
+ ArdourCanvas::Rectangle* transport_bar_drag_rect;
+ ArdourCanvas::Rectangle* transport_bar_range_rect;
+ ArdourCanvas::Rectangle* transport_bar_preroll_rect;
+ ArdourCanvas::Rectangle* transport_bar_postroll_rect;
+ ArdourCanvas::Rectangle* transport_loop_range_rect;
+ ArdourCanvas::Rectangle* transport_punch_range_rect;
+ ArdourCanvas::Line* transport_punchin_line;
+ ArdourCanvas::Line* transport_punchout_line;
+ ArdourCanvas::Rectangle* transport_preroll_rect;
+ ArdourCanvas::Rectangle* transport_postroll_rect;
- ARDOUR::Location* transport_loop_location();
- ARDOUR::Location* transport_punch_location();
+ ARDOUR::Location* transport_loop_location();
+ ARDOUR::Location* transport_punch_location();
- ARDOUR::Location *temp_location;
+ ARDOUR::Location* temp_location;
/* object rubberband select process */
void select_all_within (framepos_t, framepos_t, double, double, TrackViewList const &, Selection::Operation, bool);
- ArdourCanvas::Rectangle *rubberband_rect;
+ ArdourCanvas::Rectangle* rubberband_rect;
EditorRouteGroups* _route_groups;
- EditorRoutes* _routes;
- EditorRegions* _regions;
- EditorSnapshots* _snapshots;
- EditorLocations* _locations;
+ EditorRoutes* _routes;
+ EditorRegions* _regions;
+ EditorSnapshots* _snapshots;
+ EditorLocations* _locations;
/* diskstream/route display management */
Glib::RefPtr<Gdk::Pixbuf> rec_enabled_icon;
bool sync_track_view_list_and_routes ();
- Gtk::VBox list_vpacker;
+ Gtk::VBox list_vpacker;
/* autoscrolling */
/* nudge */
- ArdourButton nudge_forward_button;
- ArdourButton nudge_backward_button;
+ ArdourWidgets::ArdourButton nudge_forward_button;
+ ArdourWidgets::ArdourButton nudge_backward_button;
Gtk::HBox nudge_hbox;
Gtk::VBox nudge_vbox;
AudioClock* nudge_clock;
Editing::EditPoint _edit_point;
- ArdourDropdown edit_point_selector;
+ ArdourWidgets::ArdourDropdown edit_point_selector;
void build_edit_point_menu();
void set_edit_point_preference (Editing::EditPoint ep, bool force = false);
using namespace PBD;
using namespace Gtk;
using namespace Gtkmm2ext;
+using namespace ArdourWidgets;
using namespace Editing;
using Gtkmm2ext::Keyboard;
#include "gtkmm2ext/treeutils.h"
#include "gtkmm2ext/utils.h"
+#include "widgets/tooltips.h"
+
#include "audio_clock.h"
#include "editor.h"
#include "editing.h"
#include "editor_regions.h"
#include "editor_drag.h"
#include "main_clock.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "pbd/i18n.h"
using namespace std;
using namespace ARDOUR;
+using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Gtk;
#include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/cell_renderer_color_selector.h"
+#include "widgets/tooltips.h"
+
#include "ardour/route_group.h"
#include "ardour/route.h"
#include "ardour/session.h"
#include "route_group_dialog.h"
#include "route_time_axis.h"
#include "time_axis_view.h"
-#include "tooltips.h"
#include "utils.h"
#include "pbd/i18n.h"
using namespace std;
using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
using namespace PBD;
using namespace Gtk;
using Gtkmm2ext::Keyboard;
#include "gtkmm2ext/cell_renderer_pixbuf_toggle.h"
#include "gtkmm2ext/treeutils.h"
+#include "widgets/tooltips.h"
+
#include "actions.h"
#include "ardour_ui.h"
#include "audio_time_axis.h"
#include "mixer_strip.h"
#include "plugin_setup_dialog.h"
#include "route_sorter.h"
-#include "tooltips.h"
#include "vca_time_axis.h"
#include "utils.h"
using namespace std;
using namespace ARDOUR;
+using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Gtk;
using namespace Gtkmm2ext;
using namespace PBD;
using namespace Glib;
+using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
#define DEBUG_ECONTROL(msg) DEBUG_TRACE (PBD::DEBUG::EngineControl, string_compose ("%1: %2\n", __LINE__, msg));
#include "pbd/signals.h"
+#include "widgets/ardour_button.h"
+
#include "ardour_dialog.h"
-#include "ardour_button.h"
class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList
{
Gtk::Adjustment ports_adjustment;
Gtk::SpinButton ports_spinner;
- Gtk::Label have_control_text;
- ArdourButton control_app_button;
- ArdourButton midi_devices_button;
- ArdourButton start_stop_button;
- ArdourButton update_devices_button;
- ArdourButton use_buffered_io_button;
+ Gtk::Label have_control_text;
+ ArdourWidgets::ArdourButton control_app_button;
+ ArdourWidgets::ArdourButton midi_devices_button;
+ ArdourWidgets::ArdourButton start_stop_button;
+ ArdourWidgets::ArdourButton update_devices_button;
+ ArdourWidgets::ArdourButton use_buffered_io_button;
Gtk::Button connect_disconnect_button;
/* latency measurement */
- Gtk::ComboBoxText lm_output_channel_combo;
- Gtk::ComboBoxText lm_input_channel_combo;
- Gtk::Label lm_measure_label;
- Gtk::Button lm_measure_button;
- Gtk::Button lm_use_button;
- Gtk::Button lm_back_button;
- ArdourButton lm_button_audio;
- Gtk::Label lm_title;
- Gtk::Label lm_preamble;
- Gtk::Label lm_results;
- Gtk::Table lm_table;
- Gtk::VBox lm_vbox;
- bool have_lm_results;
- bool lm_running;
+ Gtk::ComboBoxText lm_output_channel_combo;
+ Gtk::ComboBoxText lm_input_channel_combo;
+ Gtk::Label lm_measure_label;
+ Gtk::Button lm_measure_button;
+ Gtk::Button lm_use_button;
+ Gtk::Button lm_back_button;
+ ArdourWidgets::ArdourButton lm_button_audio;
+ Gtk::Label lm_title;
+ Gtk::Label lm_preamble;
+ Gtk::Label lm_results;
+ Gtk::Table lm_table;
+ Gtk::VBox lm_vbox;
+ bool have_lm_results;
+ bool lm_running;
/* MIDI Tab */
MidiDeviceSettings _measure_midi;
void midi_latency_adjustment_changed(Gtk::Adjustment *, MidiDeviceSettings, bool);
- void midi_device_enabled_toggled(ArdourButton *, MidiDeviceSettings);
+ void midi_device_enabled_toggled(ArdourWidgets::ArdourButton *, MidiDeviceSettings);
sigc::connection lm_back_button_signal;
};
#include "ardour/session.h"
#include "ardour/export_format_specification.h"
+#include "widgets/tooltips.h"
+
#include "export_format_dialog.h"
#include "gui_thread.h"
-#include "tooltips.h"
+
#include "pbd/i18n.h"
using namespace ARDOUR;
normalize_hbox.pack_start (normalize_dbtp_spinbutton, false, false, 2);
normalize_hbox.pack_start (normalize_dbtp_label, false, false, 0);
- ARDOUR_UI_UTILS::set_tooltip (normalize_loudness_rb,
+ ArdourWidgets::set_tooltip (normalize_loudness_rb,
_("Normalize to EBU-R128 LUFS target loudness without exceeding the given true-peak limit. EBU-R128 normalization is only available for mono and stereo targets, true-peak works for any channel layout."));
normalize_dbfs_spinbutton.configure (normalize_dbfs_adjustment, 0.1, 2);
get_vbox()->pack_start (command_label, false, false);
get_vbox()->pack_start (command_entry, false, false);
- ARDOUR_UI_UTILS::set_tooltip (command_entry,
+ ArdourWidgets::set_tooltip (command_entry,
_(
"%a Artist name\n"
"%b File's base-name\n"
#include "ardour/utils.h"
#include <pangomm.h>
-#include <gtkmm/style.h>
-#include <gdkmm/color.h>
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/fastmeter.h>
-#include <gtkmm2ext/gtk_ui.h>
+
+#include "gtkmm/style.h"
+#include "gdkmm/color.h"
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/fastmeter.h"
+#include "gtkmm2ext/gtk_ui.h"
+
+#include "widgets/tooltips.h"
+
#include "pbd/fastlog.h"
#include "pbd/stacktrace.h"
#include "utils.h"
#include "meter_patterns.h"
#include "timers.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "ardour/session.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
using namespace PBD;
using namespace Gtkmm2ext;
using namespace Gtk;
bool
GainMeterBase::gain_key_press (GdkEventKey* ev)
{
- if (key_is_legal_for_numeric_entry (ev->keyval)) {
+ if (ARDOUR_UI_UTILS::key_is_legal_for_numeric_entry (ev->keyval)) {
/* drop through to normal handling */
return false;
}
#include "ardour/types.h"
#include "ardour/session_handle.h"
-#include "ardour_button.h"
+#include "widgets/ardour_button.h"
#include "gtkmm2ext/click_box.h"
#include "gtkmm2ext/focus_entry.h"
sigc::connection gain_watching;
- ArdourButton gain_automation_state_button;
+ ArdourWidgets::ArdourButton gain_automation_state_button;
Gtk::Menu gain_astate_menu;
- ArdourButton meter_point_button;
+ ArdourWidgets::ArdourButton meter_point_button;
Gtk::Menu meter_point_menu;
#include "pbd/xml++.h"
#include "pbd/failed_constructor.h"
-#include <gtkmm2ext/click_box.h>
-#include <gtkmm2ext/fastmeter.h>
-#include <gtkmm2ext/barcontroller.h>
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/doi.h>
-#include <gtkmm2ext/slider_controller.h>
+#include "gtkmm2ext/click_box.h"
+#include "gtkmm2ext/fastmeter.h"
+#include "gtkmm2ext/barcontroller.h"
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/doi.h"
+#include "gtkmm2ext/slider_controller.h"
+
+#include "widgets/ardour_knob.h"
+#include "widgets/tooltips.h"
#include "ardour/plugin.h"
#include "ardour/plugin_insert.h"
#include "plugin_ui.h"
#include "gui_thread.h"
#include "automation_controller.h"
-#include "ardour_knob.h"
#include "gain_meter.h"
#include "timers.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
using namespace PBD;
using namespace Gtkmm2ext;
+using namespace ArdourWidgets;
using namespace Gtk;
using namespace ARDOUR_UI_UTILS;
#include "ardour/session.h"
#include "pbd/memento_command.h"
+#include "widgets/tooltips.h"
#include "ardour_ui.h"
#include "clock_group.h"
#include "prompter.h"
#include "utils.h"
#include "public_editor.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "pbd/i18n.h"
using namespace std;
using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
using namespace PBD;
using namespace Gtk;
using namespace Gtkmm2ext;
#include "ardour/location.h"
#include "ardour/session_handle.h"
-#include <gtkmm2ext/pane.h>
+#include "gtkmm2ext/pane.h"
+#include "widgets/ardour_button.h"
-#include "ardour_button.h"
#include "ardour_window.h"
#include "audio_clock.h"
Gtk::HBox start_hbox;
AudioClock start_clock;
- ArdourButton start_to_playhead_button;
- ArdourButton locate_to_start_button;
+ ArdourWidgets::ArdourButton start_to_playhead_button;
+ ArdourWidgets::ArdourButton locate_to_start_button;
Gtk::HBox end_hbox;
AudioClock end_clock;
- ArdourButton end_to_playhead_button;
- ArdourButton locate_to_end_button;
+ ArdourWidgets::ArdourButton end_to_playhead_button;
+ ArdourWidgets::ArdourButton locate_to_end_button;
AudioClock length_clock;
Gtk::CheckButton cd_check_button;
Gtk::CheckButton lock_check_button;
Gtk::CheckButton glue_check_button;
- ArdourButton remove_button;
+ ArdourWidgets::ArdourButton remove_button;
Gtk::HBox cd_track_details_hbox;
Gtk::Entry isrc_entry;
#include "gtkmm2ext/slider_controller.h"
#include "gtkmm2ext/utils.h"
+#include "widgets/ardour_dropdown.h"
+
#include "ardour_dialog.h"
-#include "ardour_dropdown.h"
#include "luadialog.h"
#include "utils.h"
_rv = rv;
}
- ArdourDropdown _dd;
+ ArdourWidgets::ArdourDropdown _dd;
std::vector<luabridge::LuaRef*> _refs;
luabridge::LuaRef* _rv;
};
#include "gtkmm2ext/utils.h"
#include "gtkmm2ext/window_title.h"
+#include "widgets/tooltips.h"
+
#include "ardour/filesystem_paths.h"
#include "ardour/luabindings.h"
#include "LuaBridge/LuaBridge.h"
#include "luainstance.h"
#include "luawindow.h"
#include "public_editor.h"
-#include "tooltips.h"
#include "utils.h"
#include "utils_videotl.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Gtk;
using namespace Glib;
vpane->show_all ();
add (*vpane);
set_size_request (640, 480); // XXX
- ARDOUR_UI_UTILS::set_tooltip (script_select, _("Select Editor Buffer"));
+ ArdourWidgets::set_tooltip (script_select, _("Select Editor Buffer"));
setup_buffers ();
LuaScripting::instance().scripts_changed.connect (*this, invalidator (*this), boost::bind (&LuaWindow::refresh_scriptlist, this), gui_context());
{
if (!_visible) return 0;
_visible = false;
- return just_hide_it (ev, static_cast<Gtk::Window *>(this));
+ return ARDOUR_UI_UTILS::just_hide_it (ev, static_cast<Gtk::Window *>(this));
}
void LuaWindow::reinit_lua ()
#include "lua/luastate.h"
-#include "ardour_button.h"
-#include "ardour_dropdown.h"
+#include "widgets/ardour_button.h"
+#include "widgets/ardour_dropdown.h"
class LuaWindow :
public Gtk::Window,
Gtk::TextView outtext;
Gtk::ScrolledWindow scrollout;
- ArdourButton _btn_run;
- ArdourButton _btn_clear;
- ArdourButton _btn_open;
- ArdourButton _btn_save;
- ArdourButton _btn_delete;
- ArdourButton _btn_revert;
+ ArdourWidgets::ArdourButton _btn_run;
+ ArdourWidgets::ArdourButton _btn_clear;
+ ArdourWidgets::ArdourButton _btn_open;
+ ArdourWidgets::ArdourButton _btn_save;
+ ArdourWidgets::ArdourButton _btn_delete;
+ ArdourWidgets::ArdourButton _btn_revert;
- ArdourDropdown script_select;
+ ArdourWidgets::ArdourDropdown script_select;
typedef boost::shared_ptr<ScriptBuffer> ScriptBufferPtr;
typedef std::vector<ScriptBufferPtr> ScriptBufferList;
#include "ardour/audio_track.h"
#include "ardour/midi_track.h"
-#include <gtkmm2ext/gtk_ui.h>
-#include <gtkmm2ext/keyboard.h>
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/rgb_macros.h>
+#include "gtkmm2ext/gtk_ui.h"
+#include "gtkmm2ext/keyboard.h"
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/rgb_macros.h"
+
+#include "widgets/tooltips.h"
#include "gui_thread.h"
#include "ardour_window.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "utils.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
+using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Gtk;
#include "ardour/types.h"
#include "ardour/ardour.h"
+
+#include "widgets/ardour_button.h"
+
#include "route_ui.h"
-#include "ardour_button.h"
#include "level_meter.h"
Gtk::HBox spacer;
Gtk::HBox namebx;
Gtk::VBox namenumberbx;
- ArdourButton name_label;
- ArdourButton number_label;
+ ArdourWidgets::ArdourButton name_label;
+ ArdourWidgets::ArdourButton number_label;
Gtk::DrawingArea meter_metric_area;
Gtk::DrawingArea meter_ticks1_area;
Gtk::DrawingArea meter_ticks2_area;
Gtk::Alignment peak_align;
Gtk::HBox peakbx;
Gtk::VBox btnbox;
- ArdourButton peak_display;
+ ArdourWidgets::ArdourButton peak_display;
std::vector<ARDOUR::DataType> _types;
ARDOUR::MeterType metric_type;
#include "gtkmm2ext/bindable_button.h"
#include "gtkmm2ext/utils.h"
+#include "widgets/tooltips.h"
+
#include "ardour/event_type_map.h"
#include "ardour/midi_patch_manager.h"
#include "ardour/midi_playlist.h"
#include "ardour/track.h"
#include "ardour/types.h"
-#include "ardour_button.h"
#include "automation_line.h"
#include "automation_time_axis.h"
#include "editor.h"
#include "rgb_macros.h"
#include "selection.h"
#include "step_editor.h"
-#include "tooltips.h"
#include "utils.h"
#include "note_base.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Gtk;
using namespace Gtkmm2ext;
*/
RouteTimeAxisView::set_route (rt);
- _view->apply_color (gdk_color_to_rgba (color()), StreamView::RegionColor);
+ _view->apply_color (ARDOUR_UI_UTILS::gdk_color_to_rgba (color()), StreamView::RegionColor);
subplugin_menu.set_name ("ArdourContextMenu");
}
}
- set_tooltip (_midnam_model_selector, _("External MIDI Device"));
- set_tooltip (_midnam_custom_device_mode_selector, _("External Device Mode"));
+ ArdourWidgets::set_tooltip (_midnam_model_selector, _("External MIDI Device"));
+ ArdourWidgets::set_tooltip (_midnam_custom_device_mode_selector, _("External Device Mode"));
_midi_controls_box.pack_start (_midnam_model_selector, false, false, 2);
_midi_controls_box.pack_start (_midnam_custom_device_mode_selector, false, false, 2);
#include "ardour/types.h"
#include "ardour/region.h"
+#include "widgets/ardour_dropdown.h"
+
#include "ardour_dialog.h"
-#include "ardour_dropdown.h"
#include "route_ui.h"
#include "enums.h"
#include "route_time_axis.h"
void update_control_names ();
- bool _ignore_signals;
- MidiScroomer* _range_scroomer;
- PianoRollHeader* _piano_roll_header;
- ARDOUR::NoteMode _note_mode;
- Gtk::RadioMenuItem* _note_mode_item;
- Gtk::RadioMenuItem* _percussion_mode_item;
- ARDOUR::ColorMode _color_mode;
- Gtk::RadioMenuItem* _meter_color_mode_item;
- Gtk::RadioMenuItem* _channel_color_mode_item;
- Gtk::RadioMenuItem* _track_color_mode_item;
- Gtk::VBox _midi_controls_box;
- MidiChannelSelectorWindow* _channel_selector;
- ArdourDropdown _midnam_model_selector;
- ArdourDropdown _midnam_custom_device_mode_selector;
+ bool _ignore_signals;
+ MidiScroomer* _range_scroomer;
+ PianoRollHeader* _piano_roll_header;
+ ARDOUR::NoteMode _note_mode;
+ Gtk::RadioMenuItem* _note_mode_item;
+ Gtk::RadioMenuItem* _percussion_mode_item;
+ ARDOUR::ColorMode _color_mode;
+ Gtk::RadioMenuItem* _meter_color_mode_item;
+ Gtk::RadioMenuItem* _channel_color_mode_item;
+ Gtk::RadioMenuItem* _track_color_mode_item;
+ Gtk::VBox _midi_controls_box;
+ MidiChannelSelectorWindow* _channel_selector;
+ ArdourWidgets::ArdourDropdown _midnam_model_selector;
+ ArdourWidgets::ArdourDropdown _midnam_custom_device_mode_selector;
Gtk::CheckMenuItem* _step_edit_item;
Gtk::Menu* default_channel_menu;
#include "canvas/colors.h"
#include "canvas/utils.h"
+#include "widgets/tooltips.h"
+
#include "ardour_ui.h"
#include "public_editor.h"
#include "main_clock.h"
#include "mini_timeline.h"
#include "timers.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "pbd/i18n.h"
Location::start_changed.connect (marker_connection, invalidator (*this), boost::bind (&MiniTimeline::update_minitimeline, this), gui_context ());
Location::flags_changed.connect (marker_connection, invalidator (*this), boost::bind (&MiniTimeline::update_minitimeline, this), gui_context ());
- ARDOUR_UI_UTILS::set_tooltip (*this,
+ ArdourWidgets::set_tooltip (*this,
string_compose (_("<b>Navigation Timeline</b>. Use left-click to locate to time position or marker; scroll-wheel to jump, hold %1 for fine grained and %2 + %3 for extra-fine grained control. Right-click to set display range. The display unit is defined by the primary clock."),
Gtkmm2ext::Keyboard::primary_modifier_name(),
Gtkmm2ext::Keyboard::primary_modifier_name (),
#include "gtkmm2ext/slider_controller.h"
#include "gtkmm2ext/bindable_button.h"
+#include "widgets/tooltips.h"
+
#include "ardour/amp.h"
#include "ardour/audio_track.h"
#include "ardour/audioengine.h"
#include "mixer_strip.h"
#include "mixer_ui.h"
#include "keyboard.h"
-#include "ardour_button.h"
#include "public_editor.h"
#include "send_ui.h"
#include "io_selector.h"
#include "gui_thread.h"
#include "route_group_menu.h"
#include "meter_patterns.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
using namespace PBD;
using namespace Gtk;
using namespace Gtkmm2ext;
void
MixerStrip::route_color_changed ()
{
+ using namespace ARDOUR_UI_UTILS;
name_button.modify_bg (STATE_NORMAL, color());
number_label.set_fixed_colors (gdk_color_to_rgba (color()), gdk_color_to_rgba (color()));
reset_strip_style ();
#include "pbd/fastlog.h"
+#include "widgets/ardour_button.h"
+#include "widgets/ardour_knob.h"
+
#include "axis_view.h"
#include "control_slave_ui.h"
-#include "ardour_knob.h"
#include "route_ui.h"
#include "gain_meter.h"
#include "panner_ui.h"
Width _width;
void* _width_owner;
- ArdourButton hide_button;
- ArdourButton width_button;
- ArdourButton number_label;
- Gtk::HBox width_hide_box;
- Gtk::EventBox spacer;
+ ArdourWidgets::ArdourButton hide_button;
+ ArdourWidgets::ArdourButton width_button;
+ ArdourWidgets::ArdourButton number_label;
+ Gtk::HBox width_hide_box;
+ Gtk::EventBox spacer;
void hide_clicked();
bool width_button_pressed (GdkEventButton *);
void meter_changed ();
void monitor_changed ();
- ArdourButton input_button;
- ArdourButton output_button;
+ ArdourWidgets::ArdourButton input_button;
+ ArdourWidgets::ArdourButton output_button;
- ArdourButton* monitor_section_button;
+ ArdourWidgets::ArdourButton* monitor_section_button;
void input_button_resized (Gtk::Allocation&);
void output_button_resized (Gtk::Allocation&);
void comment_button_resized (Gtk::Allocation&);
- ArdourButton* midi_input_enable_button;
- Gtk::HBox input_button_box;
+ ArdourWidgets::ArdourButton* midi_input_enable_button;
+ Gtk::HBox input_button_box;
std::string longest_label;
gint mark_update_safe ();
guint32 mode_switch_in_progress;
- ArdourButton name_button;
-
- ArdourButton _comment_button;
-
- ArdourKnob trim_control;
+ ArdourWidgets::ArdourButton name_button;
+ ArdourWidgets::ArdourButton _comment_button;
+ ArdourWidgets::ArdourKnob trim_control;
void setup_comment_button ();
- ArdourButton group_button;
- RouteGroupMenu *group_menu;
+ ArdourWidgets::ArdourButton group_button;
+ RouteGroupMenu* group_menu;
gint input_press (GdkEventButton *);
gint input_release (GdkEventButton *);
#include <gtkmm/menu.h>
#include <gtkmm/menuitem.h>
+#include "widgets/tooltips.h"
+
#include "ardour/amp.h"
#include "ardour/audioengine.h"
#include "ardour/monitor_processor.h"
#include "monitor_section.h"
#include "public_editor.h"
#include "timers.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "utils.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
+using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
using namespace Gtk;
using namespace Gtkmm2ext;
#include "gtkmm2ext/bindable_button.h"
#include "gtkmm2ext/bindings.h"
-#include "ardour_button.h"
-#include "ardour_knob.h"
-#include "ardour_display.h"
+#include "widgets/ardour_button.h"
+#include "widgets/ardour_knob.h"
+#include "widgets/ardour_display.h"
+
#include "level_meter.h"
#include "route_ui.h"
#include "monitor_selector.h"
Glib::RefPtr<Gtk::SizeGroup> channel_size_group;
struct ChannelButtonSet {
- ArdourButton cut;
- ArdourButton dim;
- ArdourButton solo;
- ArdourButton invert;
+ ArdourWidgets::ArdourButton cut;
+ ArdourWidgets::ArdourButton dim;
+ ArdourWidgets::ArdourButton solo;
+ ArdourWidgets::ArdourButton invert;
ChannelButtonSet ();
};
typedef std::vector<ChannelButtonSet*> ChannelButtons;
ChannelButtons _channel_buttons;
- ArdourKnob* gain_control;
- ArdourKnob* dim_control;
- ArdourKnob* solo_boost_control;
- ArdourKnob* solo_cut_control;
+ ArdourWidgets::ArdourKnob* gain_control;
+ ArdourWidgets::ArdourKnob* dim_control;
+ ArdourWidgets::ArdourKnob* solo_boost_control;
+ ArdourWidgets::ArdourKnob* solo_cut_control;
- ArdourDisplay* gain_display;
- ArdourDisplay* dim_display;
- ArdourDisplay* solo_boost_display;
- ArdourDisplay* solo_cut_display;
+ ArdourWidgets::ArdourDisplay* gain_display;
+ ArdourWidgets::ArdourDisplay* dim_display;
+ ArdourWidgets::ArdourDisplay* solo_boost_display;
+ ArdourWidgets::ArdourDisplay* solo_cut_display;
std::list<boost::shared_ptr<ARDOUR::Bundle> > output_menu_bundles;
Gtk::Menu output_menu;
MonitorSelectorWindow *_output_selector;
- ArdourButton* output_button;
+ ArdourWidgets::ArdourButton* output_button;
void maybe_add_bundle_to_output_menu (boost::shared_ptr<ARDOUR::Bundle>, ARDOUR::BundleList const &);
void bundle_output_chosen (boost::shared_ptr<ARDOUR::Bundle>);
gint output_press (GdkEventButton *);
gint output_release (GdkEventButton *);
- ArdourButton solo_in_place_button;
- ArdourButton afl_button;
- ArdourButton pfl_button;
+ ArdourWidgets::ArdourButton solo_in_place_button;
+ ArdourWidgets::ArdourButton afl_button;
+ ArdourWidgets::ArdourButton pfl_button;
Gtk::VBox solo_model_box;
void solo_use_in_place ();
void solo_use_afl ();
void solo_use_pfl ();
- ArdourButton cut_all_button;
- ArdourButton dim_all_button;
- ArdourButton mono_button;
- ArdourButton rude_solo_button;
- ArdourButton rude_iso_button;
- ArdourButton rude_audition_button;
- ArdourButton exclusive_solo_button;
- ArdourButton solo_mute_override_button;
- ArdourButton toggle_processorbox_button;
+ ArdourWidgets::ArdourButton cut_all_button;
+ ArdourWidgets::ArdourButton dim_all_button;
+ ArdourWidgets::ArdourButton mono_button;
+ ArdourWidgets::ArdourButton rude_solo_button;
+ ArdourWidgets::ArdourButton rude_iso_button;
+ ArdourWidgets::ArdourButton rude_audition_button;
+ ArdourWidgets::ArdourButton exclusive_solo_button;
+ ArdourWidgets::ArdourButton solo_mute_override_button;
+ ArdourWidgets::ArdourButton toggle_processorbox_button;
void do_blink (bool);
void solo_blink (bool);
#include "ardour/panner_shell.h"
#include "ardour/session.h"
+#include "widgets/tooltips.h"
+
#include "panner_ui.h"
#include "panner2d.h"
#include "gui_thread.h"
#include "stereo_panner.h"
#include "timers.h"
-#include "tooltips.h"
#include "mono_panner.h"
#include "ui_config.h"
using namespace PBD;
using namespace Gtkmm2ext;
using namespace Gtk;
-using namespace ARDOUR_UI_UTILS;
PannerUI::PannerUI (Session* s)
: _current_nouts (-1)
pan_automation_state_button.set_name ("MixerAutomationPlaybackButton");
- set_tooltip (pan_automation_state_button, _("Pan automation mode"));
+ ArdourWidgets::set_tooltip (pan_automation_state_button, _("Pan automation mode"));
//set_size_request_to_display_given_text (pan_automation_state_button, X_("O"), 2, 2);
#include "gtkmm2ext/rgb_macros.h"
#include "gtkmm2ext/menu_elems.h"
+#include "widgets/tooltips.h"
+
#include "ardour/amp.h"
#include "ardour/audioengine.h"
#include "ardour/pannable.h"
#include "plugin_pin_dialog.h"
#include "gui_thread.h"
#include "timers.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "pbd/i18n.h"
using namespace std;
using namespace Gtk;
using namespace Gtkmm2ext;
+using namespace ArdourWidgets;
PluginPinWidget::PluginPinWidget (boost::shared_ptr<ARDOUR::PluginInsert> pi)
: _set_config (_("Manual Config"), ArdourButton::led_default_elements)
tl->pack_start (*manage (new Label ("")), true, true); // invisible separator
tl->pack_start (*manage (new HSeparator ()), false, false, 4);
_out_presets.disable_scrolling ();
- ARDOUR_UI_UTILS::set_tooltip (_out_presets, _("Output Presets"));
+ ArdourWidgets::set_tooltip (_out_presets, _("Output Presets"));
tl->pack_start (_out_presets, false, false);
/* right side */
ArdourButton *pb = manage (new ArdourButton (lbl));
pb->set_text_ellipsize (Pango::ELLIPSIZE_MIDDLE);
pb->set_layout_ellipsize_width (108 * PANGO_SCALE);
- ARDOUR_UI_UTILS::set_tooltip (*pb, tip);
+ ArdourWidgets::set_tooltip (*pb, tip);
_sidechain_tbl->attach (*pb, 0, 1, r, r +1 , EXPAND|FILL, SHRINK);
pb->signal_button_press_event ().connect (sigc::bind (sigc::mem_fun (*this, &PluginPinWidget::sc_input_press), boost::weak_ptr<Port> (p)), false);
#include "gtkmm2ext/persistent_tooltip.h"
#include "gtkmm2ext/slider_controller.h"
-#include "ardour_button.h"
-#include "ardour_dropdown.h"
+#include "widgets/ardour_button.h"
+#include "widgets/ardour_dropdown.h"
+
#include "ardour_window.h"
#include "io_selector.h"
Gtk::DrawingArea darea;
- ArdourButton _set_config;
- ArdourButton _tgl_sidechain;
- ArdourButton _add_plugin;
- ArdourButton _del_plugin;
- ArdourButton _add_input_audio;
- ArdourButton _del_input_audio;
- ArdourButton _add_input_midi;
- ArdourButton _del_input_midi;
- ArdourButton _add_output_audio;
- ArdourButton _del_output_audio;
- ArdourButton _add_output_midi;
- ArdourButton _del_output_midi;
- ArdourButton _add_sc_audio;
- ArdourButton _add_sc_midi;
-
- ArdourDropdown _out_presets;
+
+ ArdourWidgets::ArdourButton _set_config;
+ ArdourWidgets::ArdourButton _tgl_sidechain;
+ ArdourWidgets::ArdourButton _add_plugin;
+ ArdourWidgets::ArdourButton _del_plugin;
+ ArdourWidgets::ArdourButton _add_input_audio;
+ ArdourWidgets::ArdourButton _del_input_audio;
+ ArdourWidgets::ArdourButton _add_input_midi;
+ ArdourWidgets::ArdourButton _del_input_midi;
+ ArdourWidgets::ArdourButton _add_output_audio;
+ ArdourWidgets::ArdourButton _del_output_audio;
+ ArdourWidgets::ArdourButton _add_output_midi;
+ ArdourWidgets::ArdourButton _del_output_midi;
+ ArdourWidgets::ArdourButton _add_sc_audio;
+ ArdourWidgets::ArdourButton _add_sc_midi;
+
+ ArdourWidgets::ArdourDropdown _out_presets;
Gtk::Menu reset_menu;
Gtk::Menu input_menu;
#include <gtkmm/button.h>
#include <gtkmm/notebook.h>
-#include <gtkmm2ext/utils.h>
-
+#include "gtkmm2ext/utils.h"
#include "pbd/convert.h"
+#include "widgets/tooltips.h"
#include "ardour/plugin_manager.h"
#include "ardour/plugin.h"
#include "plugin_selector.h"
#include "gui_thread.h"
-#include "tooltips.h"
#include "pbd/i18n.h"
using namespace PBD;
using namespace Gtk;
using namespace std;
-using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
static const char* _filter_mode_strings[] = {
N_("Name contains"),
#include "ardour/plugin.h"
#include "ardour/session_handle.h"
-#include "plugin_interest.h"
-#include "ardour_button.h"
+#include "widgets/ardour_button.h"
+
+#include "plugin_interest.h"
#include "ardour_dialog.h"
namespace ARDOUR {
Gtk::Entry filter_entry;
Gtk::Button filter_button;
- ArdourButton fil_hidden_button;
- ArdourButton fil_instruments_button;
- ArdourButton fil_analysis_button;
- ArdourButton fil_utils_button;
+ ArdourWidgets::ArdourButton fil_hidden_button;
+ ArdourWidgets::ArdourButton fil_instruments_button;
+ ArdourWidgets::ArdourButton fil_analysis_button;
+ ArdourWidgets::ArdourButton fil_utils_button;
void filter_button_clicked ();
void filter_entry_changed ();
#include "pbd/i18n.h"
using namespace ARDOUR;
+using namespace ArdourWidgets;
using namespace Gtk;
PluginSetupDialog::PluginSetupDialog (boost::shared_ptr<ARDOUR::Route> r, boost::shared_ptr<ARDOUR::PluginInsert> pi, ARDOUR::Route::PluginSetupOptions flags)
#include "ardour/plugin_insert.h"
#include "ardour/route.h"
-#include "ardour_dropdown.h"
+#include "widgets/ardour_button.h"
+#include "widgets/ardour_dropdown.h"
+
#include "ardour_dialog.h"
class PluginSetupDialog : public ArdourDialog
boost::shared_ptr<ARDOUR::Route> _route;
boost::shared_ptr<ARDOUR::PluginInsert> _pi;
- ArdourDropdown _out_presets;
- ArdourButton _keep_mapping;
- ArdourButton _fan_out;
+ ArdourWidgets::ArdourDropdown _out_presets;
+ ArdourWidgets::ArdourButton _keep_mapping;
+ ArdourWidgets::ArdourButton _fan_out;
ARDOUR::ChanCount _cur_inputs;
ARDOUR::ChanCount _cur_outputs;
};
#include "pbd/xml++.h"
#include "pbd/failed_constructor.h"
-#include <gtkmm/widget.h>
-#include <gtkmm/box.h>
-#include <gtkmm2ext/click_box.h>
-#include <gtkmm2ext/fastmeter.h>
-#include <gtkmm2ext/barcontroller.h>
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/doi.h>
-#include <gtkmm2ext/slider_controller.h>
-#include <gtkmm2ext/application.h>
+#include "gtkmm/widget.h"
+#include "gtkmm/box.h"
+#include "gtkmm2ext/click_box.h"
+#include "gtkmm2ext/fastmeter.h"
+#include "gtkmm2ext/barcontroller.h"
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/doi.h"
+#include "gtkmm2ext/slider_controller.h"
+#include "gtkmm2ext/application.h"
+
+#include "widgets/tooltips.h"
#include "ardour/session.h"
#include "ardour/plugin.h"
#include "latency_gui.h"
#include "plugin_eq_gui.h"
#include "new_plugin_preset_dialog.h"
-#include "tooltips.h"
#include "pbd/i18n.h"
using namespace std;
using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
using namespace PBD;
using namespace Gtkmm2ext;
using namespace Gtk;
#include "ardour/plugin.h"
#include "ardour/variant.h"
-#include "ardour_button.h"
-#include "ardour_dropdown.h"
-#include "ardour_spinner.h"
+#include "widgets/ardour_button.h"
+#include "widgets/ardour_dropdown.h"
+#include "widgets/ardour_spinner.h"
+
#include "ardour_window.h"
#include "automation_controller.h"
/* UI elements that can subclasses can add to their widgets */
/** a ComboBoxText which lists presets and manages their selection */
- ArdourDropdown _preset_combo;
+ ArdourWidgets::ArdourDropdown _preset_combo;
/** a label which has a * in if the current settings are different from the preset being shown */
Gtk::Label _preset_modified;
/** a button to add a preset */
- ArdourButton add_button;
+ ArdourWidgets::ArdourButton add_button;
/** a button to save the current settings as a new user preset */
- ArdourButton save_button;
+ ArdourWidgets::ArdourButton save_button;
/** a button to delete the current preset (if it is a user one) */
- ArdourButton delete_button;
+ ArdourWidgets::ArdourButton delete_button;
/** a button to delete the reset the plugin params */
- ArdourButton reset_button;
+ ArdourWidgets::ArdourButton reset_button;
/** a button to bypass the plugin */
- ArdourButton bypass_button;
+ ArdourWidgets::ArdourButton bypass_button;
/** and self-explaining button :) */
- ArdourButton pin_management_button;
+ ArdourWidgets::ArdourButton pin_management_button;
/** a button to acquire keyboard focus */
Gtk::EventBox focus_button;
/** an expander containing the plugin description */
/** an expander containing the plugin analysis graph */
Gtk::Expander plugin_analysis_expander;
/** a button which, when clicked, opens the latency GUI */
- ArdourButton latency_button;
+ ArdourWidgets::ArdourButton latency_button;
/** a button which sets all controls' automation setting to Manual */
- ArdourButton automation_manual_all_button;
+ ArdourWidgets::ArdourButton automation_manual_all_button;
/** a button which sets all controls' automation setting to Play */
- ArdourButton automation_play_all_button;
+ ArdourWidgets::ArdourButton automation_play_all_button;
/** a button which sets all controls' automation setting to Write */
- ArdourButton automation_write_all_button;
+ ArdourWidgets::ArdourButton automation_write_all_button;
/** a button which sets all controls' automation setting to Touch */
- ArdourButton automation_touch_all_button;
+ ArdourWidgets::ArdourButton automation_touch_all_button;
void set_latency_label ();
boost::shared_ptr<ARDOUR::ScalePoints> scale_points;
boost::shared_ptr<AutomationController> controller;
- ArdourButton automate_button;
+ ArdourWidgets::ArdourButton automate_button;
Gtk::Label label;
- ArdourDropdown* combo;
+ ArdourWidgets::ArdourDropdown* combo;
Gtkmm2ext::ClickBox* clickbox;
Gtk::FileChooserButton* file_button;
- ArdourSpinner* spin_box;
+ ArdourWidgets::ArdourSpinner* spin_box;
bool button;
bool update_pending;
#include <gtkmm/messagedialog.h>
-#include <gtkmm2ext/gtk_ui.h>
+#include "gtkmm2ext/gtk_ui.h"
#include "gtkmm2ext/menu_elems.h"
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/choice.h>
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/doi.h>
-#include <gtkmm2ext/rgb_macros.h>
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/choice.h"
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/doi.h"
+#include "gtkmm2ext/rgb_macros.h"
+
+#include "widgets/tooltips.h"
#include "ardour/amp.h"
#include "ardour/audio_track.h"
#include "script_selector.h"
#include "send_ui.h"
#include "timers.h"
-#include "tooltips.h"
#include "new_plugin_preset_dialog.h"
#include "pbd/i18n.h"
using namespace Gtk;
using namespace Glib;
using namespace Gtkmm2ext;
+using namespace ArdourWidgets;
ProcessorBox* ProcessorBox::_current_processor_box = 0;
RefPtr<Action> ProcessorBox::paste_action;
}
if (pi->plugin()->has_editor()) {
- ARDOUR_UI_UTILS::set_tooltip (_button,
+ set_tooltip (_button,
string_compose (_("<b>%1</b>\nDouble-click to show GUI.\n%2+double-click to show generic GUI.%3"), name (Wide), Keyboard::secondary_modifier_name (), postfix));
} else {
- ARDOUR_UI_UTILS::set_tooltip (_button,
+ set_tooltip (_button,
string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
}
return;
if ((send = boost::dynamic_pointer_cast<Send> (_processor)) != 0 &&
!boost::dynamic_pointer_cast<InternalSend>(_processor)) {
if (send->remove_on_disconnect ()) {
- ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>> %1</b>\nThis (sidechain) send will be removed when disconnected.", _processor->name()));
+ set_tooltip (_button, string_compose ("<b>> %1</b>\nThis (sidechain) send will be removed when disconnected.", _processor->name()));
} else {
- ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>> %1</b>", _processor->name()));
+ set_tooltip (_button, string_compose ("<b>> %1</b>", _processor->name()));
}
return;
}
}
- ARDOUR_UI_UTILS::set_tooltip (_button, string_compose ("<b>%1</b>", name (Wide)));
+ set_tooltip (_button, string_compose ("<b>%1</b>", name (Wide)));
}
string
std::string tt = _name + ": " + ARDOUR::value_as_string (c->desc(), c->get_value ());
string sm = Gtkmm2ext::markup_escape_text (tt);
_slider_persistant_tooltip.set_tip (sm);
- ARDOUR_UI_UTILS::set_tooltip (_button, sm);
+ ArdourWidgets::set_tooltip (_button, sm);
}
void
std::string postfix = string_compose(_("\n%1+double-click to toggle inline-display"), Keyboard::tertiary_modifier_name ());
if (_plug->has_editor()) {
- ARDOUR_UI_UTILS::set_tooltip (*this,
+ set_tooltip (*this,
string_compose (_("<b>%1</b>\nDouble-click to show GUI.\n%2+double-click to show generic GUI.%3"), e.name (Wide), Keyboard::primary_modifier_name (), postfix));
} else {
- ARDOUR_UI_UTILS::set_tooltip (*this,
+ set_tooltip (*this,
string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), e.name (Wide), postfix));
}
}
);
}
- ARDOUR_UI_UTILS::set_tooltip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
+ set_tooltip (processor_display, _("Right-click to add/remove/edit\nplugins,inserts,sends and more"));
}
ProcessorBox::~ProcessorBox ()
#include "pbd/fastlog.h"
+#include "widgets/ardour_button.h"
+
#include "plugin_interest.h"
#include "io_selector.h"
#include "send_ui.h"
#include "enums.h"
-#include "ardour_button.h"
#include "window_manager.h"
class MotionController;
Gtk::Menu* build_send_options_menu ();
protected:
- ArdourButton _button;
+ ArdourWidgets::ArdourButton _button;
Gtk::VBox _vbox;
Position _position;
uint32_t _position_num;
Gtkmm2ext::HSliderController _slider;
Gtkmm2ext::PersistentTooltip _slider_persistant_tooltip;
/* things for a button */
- ArdourButton _button;
+ ArdourWidgets::ArdourButton _button;
bool _ignore_ui_adjustment;
PBD::ScopedConnectionList _connections;
bool _visible;
#include <gtkmm/stock.h>
#include <gtkmm/scale.h>
-#include <gtkmm2ext/utils.h>
-#include <gtkmm2ext/slider_controller.h>
-#include <gtkmm2ext/gtk_ui.h>
-#include <gtkmm2ext/paths_dialog.h>
-#include <gtkmm2ext/window_title.h>
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/slider_controller.h"
+#include "gtkmm2ext/gtk_ui.h"
+#include "gtkmm2ext/paths_dialog.h"
+#include "gtkmm2ext/window_title.h"
#include "pbd/fpu.h"
#include "pbd/cpus.h"
#include "control_protocol/control_protocol.h"
#include "canvas/wave_view.h"
+#include "widgets/tooltips.h"
#include "ardour_dialog.h"
#include "ardour_ui.h"
#include "midi_tracer.h"
#include "rc_option_editor.h"
#include "sfdb_ui.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "utils.h"
using namespace PBD;
using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
class ClickOptions : public OptionEditorMiniPage
{
#include "pbd/memento_command.h"
#include "pbd/stateful_diff_command.h"
+#include "widgets/tooltips.h"
+
#include "ardour/region.h"
#include "ardour/session.h"
#include "ardour/source.h"
#include "gui_thread.h"
#include "region_editor.h"
#include "public_editor.h"
-#include "tooltips.h"
#include "pbd/i18n.h"
using namespace PBD;
using namespace std;
using namespace Gtkmm2ext;
-using namespace ARDOUR_UI_UTILS;
RegionEditor::RegionEditor (Session* s, boost::shared_ptr<Region> r)
: ArdourDialog (_("Region"))
sync_offset_absolute_clock.set_session (_session);
start_clock.set_session (_session);
- set_tooltip (audition_button, _("audition this region"));
+ ArdourWidgets::set_tooltip (audition_button, _("audition this region"));
audition_button.unset_flags (Gtk::CAN_FOCUS);
#include "pbd/enumwriter.h"
#include "pbd/stateful_diff_command.h"
-#include <gtkmm/menu.h>
-#include <gtkmm/menuitem.h>
-#include <gtkmm2ext/gtk_ui.h>
-#include <gtkmm2ext/selector.h>
-#include <gtkmm2ext/bindable_button.h>
-#include <gtkmm2ext/utils.h>
+#include "gtkmm/menu.h"
+#include "gtkmm/menuitem.h"
+#include "gtkmm2ext/gtk_ui.h"
+#include "gtkmm2ext/selector.h"
+#include "gtkmm2ext/bindable_button.h"
+#include "gtkmm2ext/utils.h"
+
+#include "widgets/ardour_button.h"
+#include "widgets/tooltips.h"
#include "ardour/amp.h"
#include "ardour/meter.h"
#include "canvas/debug.h"
#include "ardour_ui.h"
-#include "ardour_button.h"
#include "audio_streamview.h"
#include "debug.h"
#include "enums_convert.h"
#include "rgb_macros.h"
#include "selection.h"
#include "streamview.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "utils.h"
#include "route_group_menu.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
using namespace PBD;
using namespace Gtkmm2ext;
using namespace Gtk;
void
RouteTimeAxisView::route_color_changed ()
{
+ using namespace ARDOUR_UI_UTILS;
if (_view) {
_view->apply_color (color(), StreamView::RegionColor);
}
-
number_label.set_fixed_colors (gdk_color_to_rgba (color()), gdk_color_to_rgba (color()));
}
#include <gtkmm2ext/selector.h>
#include <gtkmm2ext/slider_controller.h>
+#include "widgets/ardour_button.h"
+
#include "ardour/playlist.h"
#include "ardour/types.h"
-#include "ardour_button.h"
#include "ardour_dialog.h"
#include "route_ui.h"
#include "enums.h"
Gtk::HBox other_button_hbox;
Gtk::Table button_table;
- ArdourButton route_group_button;
- ArdourButton playlist_button;
- ArdourButton automation_button;
- ArdourButton number_label;
+ ArdourWidgets::ArdourButton route_group_button;
+ ArdourWidgets::ArdourButton playlist_button;
+ ArdourWidgets::ArdourButton automation_button;
+ ArdourWidgets::ArdourButton number_label;
Gtk::Menu subplugin_menu;
Gtk::Menu* automation_action_menu;
#include <map>
#include <boost/algorithm/string.hpp>
-#include <gtkmm2ext/gtk_ui.h>
-#include <gtkmm2ext/choice.h>
-#include <gtkmm2ext/doi.h>
-#include <gtkmm2ext/bindable_button.h>
-#include <gtkmm2ext/barcontroller.h>
-#include <gtkmm2ext/gtk_ui.h>
-#include <gtkmm2ext/utils.h>
+#include "gtkmm2ext/gtk_ui.h"
+#include "gtkmm2ext/choice.h"
+#include "gtkmm2ext/doi.h"
+#include "gtkmm2ext/bindable_button.h"
+#include "gtkmm2ext/barcontroller.h"
+#include "gtkmm2ext/gtk_ui.h"
+#include "gtkmm2ext/utils.h"
+
+#include "widgets/ardour_button.h"
#include "pbd/memento_command.h"
#include "pbd/stacktrace.h"
#include "ardour/session.h"
#include "ardour/template_utils.h"
-#include "ardour_button.h"
+
#include "ardour_dialog.h"
#include "ardour_ui.h"
#include "automation_time_axis.h"
using namespace Gtkmm2ext;
using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
using namespace PBD;
using namespace std;
class Widget;
}
-class ArdourButton;
+namespace ArdourWidgets {
+ class ArdourButton;
+}
+
class ArdourWindow;
class IOSelectorWindow;
class ControlSlaveUI;
bool multiple_solo_change;
Gtk::HBox _invert_button_box;
- ArdourButton* mute_button;
- ArdourButton* solo_button;
- ArdourButton* rec_enable_button; /* audio tracks */
- ArdourButton* show_sends_button; /* busses */
- ArdourButton* monitor_input_button;
- ArdourButton* monitor_disk_button;
+ ArdourWidgets::ArdourButton* mute_button;
+ ArdourWidgets::ArdourButton* solo_button;
+ ArdourWidgets::ArdourButton* rec_enable_button; /* audio tracks */
+ ArdourWidgets::ArdourButton* show_sends_button; /* busses */
+ ArdourWidgets::ArdourButton* monitor_input_button;
+ ArdourWidgets::ArdourButton* monitor_disk_button;
Glib::RefPtr<Gdk::Pixbuf> solo_safe_pixbuf;
- ArdourButton* solo_safe_led;
- ArdourButton* solo_isolated_led;
+ ArdourWidgets::ArdourButton* solo_safe_led;
+ ArdourWidgets::ArdourButton* solo_isolated_led;
Gtk::Label monitor_input_button_label;
bool invert_release (GdkEventButton *, uint32_t i);
int _i_am_the_modifier;
- std::vector<ArdourButton*> _invert_buttons;
+ std::vector<ArdourWidgets::ArdourButton*> _invert_buttons;
Gtk::Menu* _invert_menu;
StripableColorDialog _color_picker;
#include "gtkmm2ext/utils.h"
#include "gtkmm2ext/keyboard.h"
+#include "widgets/tooltips.h"
+
#include "ardour/audioengine.h"
#include "ardour/filesystem_paths.h"
#include "ardour/recent_sessions.h"
#include "opts.h"
#include "engine_dialog.h"
#include "pbd/i18n.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "utils.h"
using namespace Glib;
using namespace PBD;
using namespace ARDOUR;
+using namespace ArdourWidgets;
using namespace ARDOUR_UI_UTILS;
SessionDialog::SessionDialog (bool require_new, const std::string& session_name, const std::string& session_path, const std::string& template_name, bool cancel_not_quit)
#include "canvas/utils.h"
#include "canvas/colors.h"
+#include "widgets/tooltips.h"
+
#include "actions.h"
#include "rgb_macros.h"
#include "shuttle_control.h"
-#include "tooltips.h"
#include "pbd/i18n.h"
using namespace Gtk;
using namespace Gtkmm2ext;
using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
using std::min;
using std::max;
#include "ardour/session_handle.h"
#include "ardour/types.h"
-#include "ardour_button.h"
+#include "widgets/ardour_button.h"
namespace Gtk {
class Menu;
boost::shared_ptr<ShuttleControllable> controllable() const { return _controllable; }
void set_colors ();
- ArdourButton* info_button () { return &_info_button; }
+ ArdourWidgets::ArdourButton* info_button () { return &_info_button; }
protected:
bool _hovering;
cairo_pattern_t* shine_pattern;
ARDOUR::microseconds_t last_shuttle_request;
PBD::ScopedConnection parameter_connection;
- ArdourButton _info_button;
+ ArdourWidgets::ArdourButton _info_button;
Gtk::Menu* shuttle_unit_menu;
Gtk::Menu* shuttle_style_menu;
Gtk::Menu* shuttle_context_menu;
#include "gtkmm2ext/actions.h"
#include "gtkmm2ext/keyboard.h"
+#include "widgets/tooltips.h"
+
#include "ardour/filesystem_paths.h"
#include "midi_channel_selector.h"
#include "midi_time_axis.h"
#include "step_editor.h"
#include "step_entry.h"
-#include "tooltips.h"
#include "utils.h"
#include "pbd/i18n.h"
using namespace PBD;
using namespace ARDOUR;
using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
static void
_note_off_event_handler (GtkWidget* /*widget*/, int note, gpointer arg)
#include "canvas/utils.h"
#include "canvas/colors.h"
+#include "widgets/tooltips.h"
+
#include "ardour/profile.h"
#include "ardour_dialog.h"
#include "streamview.h"
#include "editor_drag.h"
#include "editor.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "pbd/i18n.h"
using namespace Gtk;
using namespace Gdk;
using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
using namespace PBD;
using namespace Editing;
using namespace ArdourCanvas;
+using namespace ArdourWidgets;
using Gtkmm2ext::Keyboard;
#define TOP_LEVEL_WIDGET controls_ebox
#include "ardour/ardour.h"
#include "ardour/session_handle.h"
-#include "ardour_button.h"
-
namespace ARDOUR {
class Session;
class Location;
+++ /dev/null
-/*
- Copyright (C) 2014 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 "tooltips.h"
-
-#include "gtkmm2ext/gtk_ui.h"
-
-namespace ARDOUR_UI_UTILS {
-
-void
-set_tooltip (Gtk::Widget& w, const std::string& text) {
- Gtkmm2ext::UI::instance()->set_tip(w, text);
-}
-
-void
-set_tooltip (Gtk::Widget* w, const std::string& text) {
- Gtkmm2ext::UI::instance()->set_tip(*w, text);
-}
-
-void
-set_tooltip (Gtk::Widget* w, const std::string& text, const std::string& help_text) {
- Gtkmm2ext::UI::instance()->set_tip(w, text.c_str(), help_text.c_str());
-}
-
-} // ARDOUR_UI_UTILS
+++ /dev/null
-/*
- Copyright (C) 2014 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 UI_TOOLTIPS_H
-#define UI_TOOLTIPS_H
-
-#include <string>
-
-namespace Gtk {
- class Widget;
-}
-
-// Reduce these down to just one function
-namespace ARDOUR_UI_UTILS {
-
-void set_tooltip (Gtk::Widget& w, const std::string& text);
-
-void set_tooltip (Gtk::Widget* w, const std::string& text);
-
-void set_tooltip (Gtk::Widget* w, const std::string& text, const std::string& help_text);
-
-}
-
-#endif // UI_TOOLTIPS_H
-
UIConfiguration::instance ()
{
static UIConfiguration s_instance;
+ _instance = &s_instance;
return s_instance;
}
#include "pbd/configuration_variable.h"
#include "canvas/colors.h"
+#include "widgets/ui_config.h"
#include "utils.h"
-class UIConfiguration : public PBD::Stateful
+class UIConfiguration : public ArdourWidgets::UIConfigurationBase
{
private:
UIConfiguration();
static std::string color_to_hex_string (ArdourCanvas::Color c);
static std::string color_to_hex_string_no_alpha (ArdourCanvas::Color c);
- sigc::signal<void> ColorsChanged;
-
void reset_dpi ();
-
float get_ui_scale ();
- sigc::signal<void> DPIReset;
-
sigc::signal<void,std::string> ParameterChanged;
void map_parameters (boost::function<void (std::string)>&);
#include "gtkmm2ext/doi.h"
#include "gtkmm2ext/keyboard.h"
+#include "widgets/tooltips.h"
#include "ardour_dialog.h"
#include "floating_text_entry.h"
#include "gui_thread.h"
#include "mixer_ui.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "utils.h"
#include "vca_master_strip.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
using namespace Gtkmm2ext;
using namespace Gtk;
using namespace PBD;
/* set color for the VCA, if not already done. */
if (!_vca->presentation_info().color_set()) {
- _vca->presentation_info().set_color (gdk_color_to_rgba (unique_random_color()));
+ _vca->presentation_info().set_color (ARDOUR_UI_UTILS::gdk_color_to_rgba (unique_random_color()));
}
control_slave_ui.set_stripable (boost::dynamic_pointer_cast<Stripable> (v));
Gdk::Color
VCAMasterStrip::color () const
{
- return gdk_color_from_rgba (_vca->presentation_info().color ());
+ return ARDOUR_UI_UTILS::gdk_color_from_rgba (_vca->presentation_info().color ());
}
string
#include <boost/shared_ptr.hpp>
-#include <gtkmm/box.h>
-#include <gtkmm/menuitem.h>
-#include <gtkmm/colorselection.h>
+#include "gtkmm/box.h"
+#include "gtkmm/menuitem.h"
+#include "gtkmm/colorselection.h"
+
+#include "widgets/ardour_button.h"
-#include "ardour_button.h"
#include "axis_view.h"
#include "control_slave_ui.h"
#include "gain_meter.h"
boost::shared_ptr<ARDOUR::VCA> _vca;
GainMeter gain_meter;
- Gtk::Frame global_frame;
- Gtk::VBox global_vpacker;
- Gtk::HBox top_padding;
- Gtk::HBox bottom_padding;
- Gtk::HBox solo_mute_box;
- ArdourButton width_button;
- ArdourButton color_button;
- ArdourButton hide_button;
- ArdourButton number_label;
- ArdourButton solo_button;
- ArdourButton mute_button;
- Gtk::Menu* context_menu;
- Gtk::MessageDialog* delete_dialog;
- ArdourButton vertical_button;
- ControlSlaveUI control_slave_ui;
- PBD::ScopedConnectionList vca_connections;
+ Gtk::Frame global_frame;
+ Gtk::VBox global_vpacker;
+ Gtk::HBox top_padding;
+ Gtk::HBox bottom_padding;
+ Gtk::HBox solo_mute_box;
+ ArdourWidgets::ArdourButton width_button;
+ ArdourWidgets::ArdourButton color_button;
+ ArdourWidgets::ArdourButton hide_button;
+ ArdourWidgets::ArdourButton number_label;
+ ArdourWidgets::ArdourButton solo_button;
+ ArdourWidgets::ArdourButton mute_button;
+ Gtk::Menu* context_menu;
+ Gtk::MessageDialog* delete_dialog;
+ ArdourWidgets::ArdourButton vertical_button;
+ ControlSlaveUI control_slave_ui;
+ PBD::ScopedConnectionList vca_connections;
void spill ();
void spill_change (boost::shared_ptr<ARDOUR::Stripable>);
#include "ardour/vca.h"
#include "gtkmm2ext/doi.h"
-#include <gtkmm2ext/utils.h>
+#include "gtkmm2ext/utils.h"
+#include "widgets/tooltips.h"
#include "gui_thread.h"
#include "public_editor.h"
-#include "tooltips.h"
#include "ui_config.h"
#include "vca_time_axis.h"
#include "pbd/i18n.h"
using namespace ARDOUR;
-using namespace ARDOUR_UI_UTILS;
+using namespace ArdourWidgets;
using namespace Gtk;
using namespace Gtkmm2ext;
using namespace PBD;
Gdk::Color
VCATimeAxisView::color () const
{
- return gdk_color_from_rgb (_vca->presentation_info().color ());
+ return ARDOUR_UI_UTILS::gdk_color_from_rgb (_vca->presentation_info().color ());
}
void
#ifndef __ardour_vca_time_axis_h__
#define __ardour_vca_time_axis_h__
-#include "ardour_button.h"
+#include "widgets/ardour_button.h"
+
#include "stripable_time_axis.h"
#include "gain_meter.h"
protected:
boost::shared_ptr<ARDOUR::VCA> _vca;
- ArdourButton solo_button;
- ArdourButton mute_button;
- ArdourButton automation_button;
- ArdourButton drop_button;
- ArdourButton number_label;
- GainMeterBase gain_meter;
- PBD::ScopedConnectionList vca_connections;
+ ArdourWidgets::ArdourButton solo_button;
+ ArdourWidgets::ArdourButton mute_button;
+ ArdourWidgets::ArdourButton automation_button;
+ ArdourWidgets::ArdourButton drop_button;
+ ArdourWidgets::ArdourButton number_label;
+ GainMeterBase gain_meter;
+ PBD::ScopedConnectionList vca_connections;
void create_gain_automation_child (const Evoral::Parameter &, bool);
void create_trim_automation_child (const Evoral::Parameter &, bool) {}
'add_route_dialog.cc',
'ambiguous_file_dialog.cc',
'analysis_window.cc',
- 'ardour_button.cc',
'ardour_dialog.cc',
- 'ardour_display.cc',
- 'ardour_dropdown.cc',
'ardour_http.cc',
- 'ardour_knob.cc',
- 'ardour_spinner.cc',
'ardour_ui.cc',
'ardour_ui2.cc',
'ardour_ui_dependents.cc',
'time_info_box.cc',
'time_selection.cc',
'timers.cc',
- 'tooltips.cc',
'track_selection.cc',
'track_view_list.cc',
'transform_dialog.cc',
'libmidipp',
'libgtkmm2ext',
'libcanvas',
+ 'libwidgets',
'libptformat',
]
obj.defines = [
obj.defines += [ 'LXVST_SUPPORT' ]
obj.use += [ 'X11' ]
- # Tool to test libcanvas
- if re.search ("linux", sys.platform) != None and bld.env['CANVASTESTUI']:
- obj = bld (features = 'cxx c cxxprogram')
- obj.install_path = None
- obj.source = list(gtk2_ardour_sources)
- obj.source = [ 'ardour_button.cc', 'ui_config.cc', 'tooltips.cc' ]
- obj.target = 'canvas_test'
- obj.includes = ['.', '../libs']
- obj.ldflags = ['-no-undefined']
- obj.use = [
- 'libpbd',
- 'libardour',
- 'libardour_cp',
- 'libtimecode',
- 'libmidipp',
- 'libgtkmm2ext',
- 'libcanvas',
- 'libptformat',
- ]
- obj.defines = [
- 'NOMAIN',
- 'PACKAGE="' + I18N_PACKAGE + '"',
- 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
- 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
- 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"',
- ]
- obj.linkflags = ''
- obj.uselib = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL GTKMM CANVAS FFTW3F LO TAGLIB XML '
- # obj.source += [ 'canvas_test.cc', ]
- obj.source += [ 'toolbar_test.cc', 'enums.cc']
+# # Tool to test libcanvas
+# if re.search ("linux", sys.platform) != None and bld.env['CANVASTESTUI']:
+# obj = bld (features = 'cxx c cxxprogram')
+# obj.install_path = None
+# obj.source = list(gtk2_ardour_sources)
+# obj.source = [ 'ardour_button.cc', 'ui_config.cc', 'tooltips.cc' ]
+# obj.target = 'canvas_test'
+# obj.includes = ['.', '../libs']
+# obj.ldflags = ['-no-undefined']
+# obj.use = [
+# 'libpbd',
+# 'libardour',
+# 'libardour_cp',
+# 'libtimecode',
+# 'libmidipp',
+# 'libgtkmm2ext',
+# 'libcanvas',
+# 'libptformat',
+# ]
+# obj.defines = [
+# 'NOMAIN',
+# 'PACKAGE="' + I18N_PACKAGE + '"',
+# 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"',
+# 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"',
+# 'LOCALEDIR="' + os.path.normpath(bld.env['LOCALEDIR']) + '"',
+# ]
+# obj.linkflags = ''
+# obj.uselib = 'UUID FLAC FONTCONFIG GLIBMM GTHREAD GTK OGG CURL DL GTKMM CANVAS FFTW3F LO TAGLIB XML '
+# # obj.source += [ 'canvas_test.cc', ]
+# obj.source += [ 'toolbar_test.cc', 'enums.cc']
if bld.is_defined('WINDOWS_VST_SUPPORT') and bld.env['build_target'] != 'mingw':
'libgtk2_ardour',
'libgtkmm2ext',
'libcanvas',
+ 'libwidgets',
'libptformat',
]
obj.target = 'ardour-' + str (bld.env['VERSION']) + '-vst.exe.so'
'libmidipp',
'libgtkmm2ext',
'libcanvas',
+ 'libwidgets',
'libptformat',
]
--- /dev/null
+/*
+ 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 <pangomm/layout.h>
+
+#include "pbd/compose.h"
+#include "pbd/controllable.h"
+#include "pbd/error.h"
+#include "pbd/stacktrace.h"
+
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/rgb_macros.h"
+#include "gtkmm2ext/gui_thread.h"
+
+#include "canvas/utils.h"
+#include "canvas/colors.h"
+
+#include "widgets/ardour_button.h"
+#include "widgets/tooltips.h"
+#include "widgets/ui_config.h"
+
+#include "pbd/i18n.h"
+
+#define BASELINESTRETCH (1.25)
+#define TRACKHEADERBTNW (3.10)
+
+using namespace Gtk;
+using namespace Glib;
+using namespace PBD;
+using namespace ArdourWidgets;
+using std::max;
+using std::min;
+using namespace std;
+
+ArdourButton::Element ArdourButton::default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text);
+ArdourButton::Element ArdourButton::led_default_elements = ArdourButton::Element (ArdourButton::default_elements|ArdourButton::Indicator);
+ArdourButton::Element ArdourButton::just_led_default_elements = ArdourButton::Element (ArdourButton::Edge|ArdourButton::Body|ArdourButton::Indicator);
+
+ArdourButton::ArdourButton (Element e)
+ : _sizing_text("")
+ , _markup (false)
+ , _elements (e)
+ , _icon (Gtkmm2ext::ArdourIcon::NoIcon)
+ , _icon_render_cb (0)
+ , _icon_render_cb_data (0)
+ , _tweaks (Tweaks (0))
+ , _char_pixel_width (0)
+ , _char_pixel_height (0)
+ , _char_avg_pixel_width (0)
+ , _text_width (0)
+ , _text_height (0)
+ , _diameter (0)
+ , _corner_radius (3.5)
+ , _corner_mask (0xf)
+ , _angle(0)
+ , _xalign(.5)
+ , _yalign(.5)
+ , fill_inactive_color (0)
+ , fill_active_color (0)
+ , text_active_color(0)
+ , text_inactive_color(0)
+ , led_active_color(0)
+ , led_inactive_color(0)
+ , led_custom_color (0)
+ , use_custom_led_color (false)
+ , convex_pattern (0)
+ , concave_pattern (0)
+ , led_inset_pattern (0)
+ , _led_rect (0)
+ , _act_on_release (true)
+ , _led_left (false)
+ , _distinct_led_click (false)
+ , _hovering (false)
+ , _focused (false)
+ , _fixed_colors_set (false)
+ , _fallthrough_to_parent (false)
+ , _layout_ellipsize_width (-1)
+ , _ellipsis (Pango::ELLIPSIZE_NONE)
+ , _update_colors (true)
+ , _pattern_height (0)
+{
+ UIConfigurationBase::instance().ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
+ /* This is not provided by gtkmm */
+ signal_grab_broken_event().connect (sigc::mem_fun (*this, &ArdourButton::on_grab_broken_event));
+}
+
+ArdourButton::ArdourButton (const std::string& str, Element e)
+ : _sizing_text("")
+ , _markup (false)
+ , _elements (e)
+ , _icon (Gtkmm2ext::ArdourIcon::NoIcon)
+ , _tweaks (Tweaks (0))
+ , _char_pixel_width (0)
+ , _char_pixel_height (0)
+ , _char_avg_pixel_width (0)
+ , _text_width (0)
+ , _text_height (0)
+ , _diameter (0)
+ , _corner_radius (3.5)
+ , _corner_mask (0xf)
+ , _angle(0)
+ , _xalign(.5)
+ , _yalign(.5)
+ , fill_inactive_color (0)
+ , fill_active_color (0)
+ , text_active_color(0)
+ , text_inactive_color(0)
+ , led_active_color(0)
+ , led_inactive_color(0)
+ , led_custom_color (0)
+ , use_custom_led_color (false)
+ , convex_pattern (0)
+ , concave_pattern (0)
+ , led_inset_pattern (0)
+ , _led_rect (0)
+ , _act_on_release (true)
+ , _led_left (false)
+ , _distinct_led_click (false)
+ , _hovering (false)
+ , _focused (false)
+ , _fixed_colors_set (false)
+ , _fallthrough_to_parent (false)
+ , _layout_ellipsize_width (-1)
+ , _ellipsis (Pango::ELLIPSIZE_NONE)
+ , _update_colors (true)
+ , _pattern_height (0)
+{
+ set_text (str);
+ UIConfigurationBase::instance().ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
+ UIConfigurationBase::instance().DPIReset.connect (sigc::mem_fun (*this, &ArdourButton::on_name_changed));
+ /* This is not provided by gtkmm */
+ signal_grab_broken_event().connect (sigc::mem_fun (*this, &ArdourButton::on_grab_broken_event));
+}
+
+ArdourButton::~ArdourButton()
+{
+ delete _led_rect;
+
+ if (convex_pattern) {
+ cairo_pattern_destroy (convex_pattern);
+ }
+
+ if (concave_pattern) {
+ cairo_pattern_destroy (concave_pattern);
+ }
+
+ if (led_inset_pattern) {
+ cairo_pattern_destroy (led_inset_pattern);
+ }
+}
+
+void
+ArdourButton::set_layout_font (const Pango::FontDescription& fd)
+{
+ ensure_layout ();
+ if (_layout) {
+ _layout->set_font_description (fd);
+ queue_resize ();
+ _char_pixel_width = 0;
+ _char_pixel_height = 0;
+ }
+}
+
+void
+ArdourButton::set_text_internal () {
+ assert (_layout);
+ if (_markup) {
+ _layout->set_markup (_text);
+ } else {
+ _layout->set_text (_text);
+ }
+}
+
+void
+ArdourButton::set_text (const std::string& str, bool markup)
+{
+ if (!(_elements & Text)) {
+ return;
+ }
+ if (_text == str && _markup == markup) {
+ return;
+ }
+
+ _text = str;
+ _markup = markup;
+ if (!is_realized()) {
+ return;
+ }
+ ensure_layout ();
+ if (_layout && _layout->get_text() != _text) {
+ set_text_internal ();
+ /* on_size_request() will fill in _text_width/height
+ * so queue it even if _sizing_text != "" */
+ queue_resize ();
+ }
+}
+
+void
+ArdourButton::set_sizing_text (const std::string& str)
+{
+ if (_sizing_text == str) {
+ return;
+ }
+ _sizing_text = str;
+ if (!is_realized()) {
+ return;
+ }
+ ensure_layout ();
+ if (_layout) {
+ queue_resize ();
+ }
+}
+
+void
+ArdourButton::set_angle (const double angle)
+{
+ _angle = angle;
+}
+
+void
+ArdourButton::set_alignment (const float xa, const float ya)
+{
+ _xalign = xa;
+ _yalign = ya;
+}
+
+
+/* TODO make this a dedicated function elsewhere.
+ *
+ * Option 1:
+ * virtual ArdourButton::render_vector_icon()
+ * ArdourIconButton::render_vector_icon
+ *
+ * Option 2:
+ * ARDOUR_UI_UTILS::render_vector_icon()
+ */
+void
+ArdourButton::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
+{
+ cairo_t* cr = ctx->cobj();
+
+ uint32_t text_color;
+ uint32_t led_color;
+
+ const float corner_radius = std::max(2.f, _corner_radius * UIConfigurationBase::instance().get_ui_scale());
+
+ if (_update_colors) {
+ set_colors ();
+ }
+ if (get_height() != _pattern_height) {
+ build_patterns ();
+ }
+
+ if ( active_state() == Gtkmm2ext::ExplicitActive ) {
+ text_color = text_active_color;
+ led_color = led_active_color;
+ } else {
+ text_color = text_inactive_color;
+ led_color = led_inactive_color;
+ }
+
+ if (use_custom_led_color) {
+ led_color = led_custom_color;
+ }
+
+ void (*rounded_function)(cairo_t*, double, double, double, double, double);
+
+ switch (_corner_mask) {
+ case 0x1: /* upper left only */
+ rounded_function = Gtkmm2ext::rounded_top_left_rectangle;
+ break;
+ case 0x2: /* upper right only */
+ rounded_function = Gtkmm2ext::rounded_top_right_rectangle;
+ break;
+ case 0x3: /* upper only */
+ rounded_function = Gtkmm2ext::rounded_top_rectangle;
+ break;
+ /* should really have functions for lower right, lower left,
+ lower only, but for now, we don't
+ */
+ default:
+ rounded_function = Gtkmm2ext::rounded_rectangle;
+ }
+
+ // draw edge (filling a rect underneath, rather than stroking a border on top, allows the corners to be lighter-weight.
+ if ((_elements & (Body|Edge)) == (Body|Edge)) {
+ rounded_function (cr, 0, 0, get_width(), get_height(), corner_radius + 1.5);
+ cairo_set_source_rgba (cr, 0, 0, 0, 1);
+ cairo_fill(cr);
+ }
+
+ // background fill
+ if ((_elements & Body)==Body) {
+ rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, corner_radius);
+ if (active_state() == Gtkmm2ext::ImplicitActive && !((_elements & Indicator)==Indicator)) {
+ ArdourCanvas::set_source_rgba (cr, fill_inactive_color);
+ cairo_fill (cr);
+ } else if ( (active_state() == Gtkmm2ext::ExplicitActive) && !((_elements & Indicator)==Indicator) ) {
+ //background color
+ ArdourCanvas::set_source_rgba (cr, fill_active_color);
+ cairo_fill (cr);
+ } else { //inactive, or it has an indicator
+ //background color
+ ArdourCanvas::set_source_rgba (cr, fill_inactive_color);
+ }
+ cairo_fill (cr);
+ }
+
+ // IMPLICIT ACTIVE: draw a border of the active color
+ if ((_elements & Body)==Body) {
+ if (active_state() == Gtkmm2ext::ImplicitActive && !((_elements & Indicator)==Indicator)) {
+ cairo_set_line_width (cr, 2.0);
+ rounded_function (cr, 2, 2, get_width() - 4, get_height() - 4, corner_radius-0.5);
+ ArdourCanvas::set_source_rgba (cr, fill_active_color);
+ cairo_stroke (cr);
+ }
+ }
+
+ //show the "convex" or "concave" gradient
+ if (!_flat_buttons && (_elements & Body)==Body) {
+ if ( active_state() == Gtkmm2ext::ExplicitActive && ( !((_elements & Indicator)==Indicator) || use_custom_led_color) ) {
+ //concave
+ cairo_set_source (cr, concave_pattern);
+ Gtkmm2ext::rounded_rectangle (cr, 1, 1, get_width() - 2, get_height() - 2, corner_radius);
+ cairo_fill (cr);
+ } else {
+ cairo_set_source (cr, convex_pattern);
+ Gtkmm2ext::rounded_rectangle (cr, 1, 1, get_width() - 2, get_height() - 2, corner_radius);
+ cairo_fill (cr);
+ }
+ }
+
+ //Pixbuf, if any
+ if (_pixbuf) {
+ double x = rint((get_width() - _pixbuf->get_width()) * .5);
+ const double y = rint((get_height() - _pixbuf->get_height()) * .5);
+#if 0 // DEBUG style (print on hover)
+ if (_hovering || (_elements & Inactive)) {
+ printf("%s: p:%dx%d (%dx%d)\n",
+ get_name().c_str(),
+ _pixbuf->get_width(), _pixbuf->get_height(),
+ get_width(), get_height());
+ }
+#endif
+ if (_elements & Menu) {
+ //if this is a DropDown with an icon, then we need to
+ //move the icon left slightly to accomomodate the arrow
+ x -= _diameter - 2;
+ }
+ cairo_rectangle (cr, x, y, _pixbuf->get_width(), _pixbuf->get_height());
+ gdk_cairo_set_source_pixbuf (cr, _pixbuf->gobj(), x, y);
+ cairo_fill (cr);
+ }
+ else /* VectorIcon, IconRenderCallback are exclusive to Pixbuf Icons */
+ if (_elements & (VectorIcon | IconRenderCallback)) {
+ int vw = get_width();
+ int vh = get_height();
+ if (_elements & Menu) {
+ vw -= _diameter + 4;
+ }
+ if (_elements & VectorIcon) {
+ Gtkmm2ext::ArdourIcon::render (cr, _icon, vw, vh, active_state(), text_color);
+ } else {
+ cairo_save (cr);
+ rounded_function (cr, 0, 0, get_width(), get_height(), corner_radius + 1.5);
+ cairo_clip (cr);
+ _icon_render_cb (cr, vw, vh, text_color, _icon_render_cb_data);
+ cairo_restore (cr);
+ }
+ }
+
+ const int text_margin = char_pixel_width();
+ // Text, if any
+ if (!_pixbuf && ((_elements & Text)==Text) && !_text.empty()) {
+ assert(_layout);
+#if 0 // DEBUG style (print on hover)
+ if (_hovering || (_elements & Inactive)) {
+ bool layout_font = true;
+ Pango::FontDescription fd = _layout->get_font_description();
+ if (fd.gobj() == NULL) {
+ layout_font = false;
+ fd = get_pango_context()->get_font_description();
+ }
+ printf("%s: f:%dx%d aw:%.3f bh:%.0f t:%dx%d (%dx%d) %s\"%s\"\n",
+ get_name().c_str(),
+ char_pixel_width(), char_pixel_height(), char_avg_pixel_width(),
+ ceil(char_pixel_height() * BASELINESTRETCH),
+ _text_width, _text_height,
+ get_width(), get_height(),
+ layout_font ? "L:" : "W:",
+ fd.to_string().c_str());
+ }
+#endif
+
+ cairo_save (cr);
+ cairo_rectangle (cr, 2, 1, get_width() - 4, get_height() - 2);
+ cairo_clip(cr);
+
+ cairo_new_path (cr);
+ ArdourCanvas::set_source_rgba (cr, text_color);
+ const double text_ypos = (get_height() - _text_height) * .5;
+
+ if (_elements & Menu) {
+ // always left align (dropdown)
+ cairo_move_to (cr, text_margin, text_ypos);
+ pango_cairo_show_layout (cr, _layout->gobj());
+ } else if ( (_elements & Indicator) == Indicator) {
+ // left/right align depending on LED position
+ if (_led_left) {
+ cairo_move_to (cr, text_margin + _diameter + .5 * char_pixel_width(), text_ypos);
+ } else {
+ cairo_move_to (cr, text_margin, text_ypos);
+ }
+ pango_cairo_show_layout (cr, _layout->gobj());
+ } else {
+ /* centered text otherwise */
+ double ww, wh;
+ double xa, ya;
+ ww = get_width();
+ wh = get_height();
+
+ cairo_matrix_t m1;
+ cairo_get_matrix (cr, &m1);
+ cairo_matrix_t m2 = m1;
+ m2.x0 = 0;
+ m2.y0 = 0;
+ cairo_set_matrix (cr, &m2);
+
+ if (_angle) {
+ cairo_rotate(cr, _angle * M_PI / 180.0);
+ }
+
+ cairo_device_to_user(cr, &ww, &wh);
+ xa = text_margin + (ww - _text_width - 2 * text_margin) * _xalign;
+ ya = (wh - _text_height) * _yalign;
+
+ /* quick hack for left/bottom alignment at -90deg
+ * TODO this should be generalized incl rotation.
+ * currently only 'user' of this API is meter_strip.cc
+ */
+ if (_xalign < 0) xa = ceil(.5 + (ww * fabs(_xalign) + text_margin));
+
+ cairo_move_to (cr, xa + m1.x0, ya + m1.y0);
+ pango_cairo_update_layout(cr, _layout->gobj());
+ pango_cairo_show_layout (cr, _layout->gobj());
+ }
+ cairo_restore (cr);
+ }
+
+ //Menu "triangle"
+ if (_elements & Menu) {
+ const float trih = ceil(_diameter * .5);
+ const float triw2 = ceil(.577 * _diameter * .5); // 1/sqrt(3) Equilateral triangle
+ //menu arrow
+ cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+ cairo_move_to(cr, get_width() - triw2 - 3. , rint((get_height() + trih) * .5));
+ cairo_rel_line_to(cr, -triw2, -trih);
+ cairo_rel_line_to(cr, 2. * triw2, 0);
+ cairo_close_path(cr);
+
+ cairo_set_source_rgba (cr, 1, 1, 1, 0.4);
+ cairo_fill(cr);
+
+ cairo_move_to(cr, get_width() - triw2 - 3 , rint((get_height() + trih) * .5));
+ cairo_rel_line_to(cr, .5 - triw2, .5 - trih);
+ cairo_rel_line_to(cr, 2. * triw2 - 1, 0);
+ cairo_close_path(cr);
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.8);
+ cairo_set_line_width(cr, 1);
+ cairo_stroke(cr);
+ }
+
+ //Indicator LED
+ if (_elements & Indicator) {
+ cairo_save (cr);
+
+ /* move to the center of the indicator/led */
+ if (_elements & Text) {
+ int led_xoff = ceil(char_pixel_width() + _diameter * .5);
+ if (_led_left) {
+ cairo_translate (cr, led_xoff, get_height() * .5);
+ } else {
+ cairo_translate (cr, get_width() - led_xoff, get_height() * .5);
+ }
+ } else {
+ cairo_translate (cr, get_width() * .5, get_height() * .5);
+ }
+
+ //inset
+ if (!_flat_buttons) {
+ cairo_arc (cr, 0, 0, _diameter * .5, 0, 2 * M_PI);
+ cairo_set_source (cr, led_inset_pattern);
+ cairo_fill (cr);
+ }
+
+ //black ring
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_arc (cr, 0, 0, _diameter * .5 - 1 * UIConfigurationBase::instance().get_ui_scale(), 0, 2 * M_PI);
+ cairo_fill(cr);
+
+ //led color
+ ArdourCanvas::set_source_rgba (cr, led_color);
+ cairo_arc (cr, 0, 0, _diameter * .5 - 3 * UIConfigurationBase::instance().get_ui_scale(), 0, 2 * M_PI);
+ cairo_fill(cr);
+
+ cairo_restore (cr);
+ }
+
+ // a transparent overlay to indicate insensitivity
+ if ((visual_state() & Gtkmm2ext::Insensitive)) {
+ rounded_function (cr, 0, 0, get_width(), get_height(), corner_radius);
+ uint32_t ins_color = UIConfigurationBase::instance().color ("gtk_background");
+ ArdourCanvas::set_source_rgb_a (cr, ins_color, 0.6);
+ cairo_fill (cr);
+ }
+
+ // if requested, show hovering
+ if (UIConfigurationBase::instance().get_widget_prelight()
+ && !((visual_state() & Gtkmm2ext::Insensitive))) {
+ if (_hovering) {
+ rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, corner_radius);
+ cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.2);
+ cairo_fill (cr);
+ }
+ }
+
+ //user is currently pressing the button. dark outline helps to indicate this
+ if (_grabbed && !(_elements & (Inactive|Menu))) {
+ rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, corner_radius);
+ cairo_set_line_width(cr, 2);
+ cairo_set_source_rgba (cr, 0.1, 0.1, 0.1, .5);
+ cairo_stroke (cr);
+ }
+
+ //some buttons (like processor boxes) can be selected (so they can be deleted). Draw a selection indicator
+ if (visual_state() & Gtkmm2ext::Selected) {
+ cairo_set_line_width(cr, 1);
+ cairo_set_source_rgba (cr, 1, 0, 0, 0.8);
+ rounded_function (cr, 0.5, 0.5, get_width() - 1, get_height() - 1, corner_radius);
+ cairo_stroke (cr);
+ }
+
+ //I guess this means we have keyboard focus. I don't think this works currently
+ //
+ //A: yes, it's keyboard focus and it does work when there's no editor window
+ // (the editor is always the first receiver for KeyDown).
+ // It's needed for eg. the engine-dialog at startup or after closing a sesion.
+ if (_focused) {
+ rounded_function (cr, 1.5, 1.5, get_width() - 3, get_height() - 3, corner_radius);
+ cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.8);
+ double dashes = 1;
+ cairo_set_dash (cr, &dashes, 1, 0);
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
+ cairo_set_line_width (cr, 1.0);
+ cairo_stroke (cr);
+ cairo_set_dash (cr, 0, 0, 0);
+ }
+}
+
+void
+ArdourButton::set_corner_radius (float r)
+{
+ _corner_radius = r;
+ CairoWidget::set_dirty ();
+}
+
+void
+ArdourButton::on_realize()
+{
+ CairoWidget::on_realize ();
+ ensure_layout ();
+ if (_layout) {
+ if (_layout->get_text() != _text) {
+ set_text_internal ();
+ queue_resize ();
+ }
+ }
+}
+
+void
+ArdourButton::on_size_request (Gtk::Requisition* req)
+{
+ req->width = req->height = 0;
+ CairoWidget::on_size_request (req);
+
+ if (_diameter == 0) {
+ const float newdia = rintf (11.f * UIConfigurationBase::instance().get_ui_scale());
+ if (_diameter != newdia) {
+ _pattern_height = 0;
+ _diameter = newdia;
+ }
+ }
+
+ if (_elements & Text) {
+
+ ensure_layout();
+ set_text_internal ();
+
+ /* render() needs the size of the displayed text */
+ _layout->get_pixel_size (_text_width, _text_height);
+
+ if (_tweaks & OccasionalText) {
+
+ /* size should not change based on presence or absence
+ * of text.
+ */
+
+ } else /*if (!_text.empty() || !_sizing_text.empty()) */ {
+
+ req->height = std::max(req->height, (int) ceil(char_pixel_height() * BASELINESTRETCH + 1.0));
+ req->width += rint(1.75 * char_pixel_width()); // padding
+
+ if (!_sizing_text.empty()) {
+ _layout->set_text (_sizing_text); /* use sizing text */
+ }
+
+ int sizing_text_width = 0, sizing_text_height = 0;
+ _layout->get_pixel_size (sizing_text_width, sizing_text_height);
+
+ req->width += sizing_text_width;
+
+ if (!_sizing_text.empty()) {
+ set_text_internal (); /* restore display text */
+ }
+ }
+
+ /* XXX hack (surprise). Deal with two common rotation angles */
+
+ if (_angle == 90 || _angle == 270) {
+ /* do not swap text width or height because we rely on
+ these being the un-rotated values in ::render()
+ */
+ swap (req->width, req->height);
+ }
+
+ } else {
+ _text_width = 0;
+ _text_height = 0;
+ }
+
+ if (_pixbuf) {
+ req->width += _pixbuf->get_width() + char_pixel_width();
+ req->height = std::max(req->height, _pixbuf->get_height() + 4);
+ }
+
+ if (_elements & Indicator) {
+ req->width += lrint (_diameter) + char_pixel_width();
+ req->height = std::max (req->height, (int) lrint (_diameter) + 4);
+ }
+
+ if ((_elements & Menu)) {
+ req->width += _diameter + 4;
+ }
+
+ if (_elements & (VectorIcon | IconRenderCallback)) {
+ assert(!(_elements & Text));
+ const int wh = std::max (6., std::max (rint (TRACKHEADERBTNW * char_avg_pixel_width()), ceil (char_pixel_height() * BASELINESTRETCH + 1.)));
+ req->width += wh;
+ req->height = std::max(req->height, wh);
+ }
+
+ /* Tweaks to mess the nice stuff above up again. */
+ if (_tweaks & TrackHeader) {
+ // forget everything above and just use a fixed square [em] size
+ // "TrackHeader Buttons" are single letter (usually uppercase)
+ // a SizeGroup is much less efficient (lots of gtk work under the hood for each track)
+ const int wh = std::max (rint (TRACKHEADERBTNW * char_avg_pixel_width()), ceil (char_pixel_height() * BASELINESTRETCH + 1.));
+ req->width = wh;
+ req->height = wh;
+ }
+ else if (_tweaks & Square) {
+ // currerntly unused (again)
+ if (req->width < req->height)
+ req->width = req->height;
+ if (req->height < req->width)
+ req->height = req->width;
+ } else if (_sizing_text.empty() && _text_width > 0 && !(_elements & Menu)) {
+ // properly centered text for those elements that are centered
+ // (no sub-pixel offset)
+ if ((req->width - _text_width) & 1) { ++req->width; }
+ if ((req->height - _text_height) & 1) { ++req->height; }
+ }
+#if 0
+ printf("REQ: %s: %dx%d\n", get_name().c_str(), req->width, req->height);
+#endif
+}
+
+/**
+ * This sets the colors used for rendering based on the name of the button, and
+ * thus uses information from the GUI config data.
+ */
+void
+ArdourButton::set_colors ()
+{
+ _update_colors = false;
+
+ if (_fixed_colors_set == 0x3) {
+ return;
+ }
+
+ std::string name = get_name();
+ bool failed = false;
+
+ if (!(_fixed_colors_set & 0x1)) {
+ fill_active_color = UIConfigurationBase::instance().color (string_compose ("%1: fill active", name), &failed);
+ if (failed) {
+ fill_active_color = UIConfigurationBase::instance().color ("generic button: fill active");
+ }
+ }
+
+ if (!(_fixed_colors_set & 0x2)) {
+ fill_inactive_color = UIConfigurationBase::instance().color (string_compose ("%1: fill", name), &failed);
+ if (failed) {
+ fill_inactive_color = UIConfigurationBase::instance().color ("generic button: fill");
+ }
+ }
+
+ text_active_color = ArdourCanvas::contrasting_text_color (fill_active_color);
+ text_inactive_color = ArdourCanvas::contrasting_text_color (fill_inactive_color);
+
+ led_active_color = UIConfigurationBase::instance().color (string_compose ("%1: led active", name), &failed);
+ if (failed) {
+ led_active_color = UIConfigurationBase::instance().color ("generic button: led active");
+ }
+
+ /* The inactive color for the LED is just a fairly dark version of the
+ * active color.
+ */
+
+ ArdourCanvas::HSV inactive (led_active_color);
+ inactive.v = 0.35;
+
+ led_inactive_color = inactive.color ();
+}
+
+/**
+ * This sets the colors used for rendering based on two fixed values, rather
+ * than basing them on the button name, and thus information in the GUI config
+ * data.
+ */
+void ArdourButton::set_fixed_colors (const uint32_t color_active, const uint32_t color_inactive)
+{
+ set_active_color (color_active);
+ set_inactive_color (color_inactive);
+}
+
+void ArdourButton::set_active_color (const uint32_t color)
+{
+ _fixed_colors_set |= 0x1;
+
+ fill_active_color = color;
+
+ unsigned char r, g, b, a;
+ UINT_TO_RGBA(color, &r, &g, &b, &a);
+
+ double white_contrast = (max (double(r), 255.) - min (double(r), 255.)) +
+ (max (double(g), 255.) - min (double(g), 255.)) +
+ (max (double(b), 255.) - min (double(b), 255.));
+
+ double black_contrast = (max (double(r), 0.) - min (double(r), 0.)) +
+ (max (double(g), 0.) - min (double(g), 0.)) +
+ (max (double(b), 0.) - min (double(b), 0.));
+
+ text_active_color = (white_contrast > black_contrast) ?
+ RGBA_TO_UINT(255, 255, 255, 255) : /* use white */
+ RGBA_TO_UINT( 0, 0, 0, 255); /* use black */
+
+ /* XXX what about led colors ? */
+ CairoWidget::set_dirty ();
+}
+
+void ArdourButton::set_inactive_color (const uint32_t color)
+{
+ _fixed_colors_set |= 0x2;
+
+ fill_inactive_color = color;
+
+ unsigned char r, g, b, a;
+ UINT_TO_RGBA(color, &r, &g, &b, &a);
+
+ double white_contrast = (max (double(r), 255.) - min (double(r), 255.)) +
+ (max (double(g), 255.) - min (double(g), 255.)) +
+ (max (double(b), 255.) - min (double(b), 255.));
+
+ double black_contrast = (max (double(r), 0.) - min (double(r), 0.)) +
+ (max (double(g), 0.) - min (double(g), 0.)) +
+ (max (double(b), 0.) - min (double(b), 0.));
+
+ text_inactive_color = (white_contrast > black_contrast) ?
+ RGBA_TO_UINT(255, 255, 255, 255) : /* use white */
+ RGBA_TO_UINT( 0, 0, 0, 255); /* use black */
+
+ /* XXX what about led colors ? */
+ CairoWidget::set_dirty ();
+}
+
+void
+ArdourButton::build_patterns ()
+{
+ if (convex_pattern) {
+ cairo_pattern_destroy (convex_pattern);
+ convex_pattern = 0;
+ }
+
+ if (concave_pattern) {
+ cairo_pattern_destroy (concave_pattern);
+ concave_pattern = 0;
+ }
+
+ if (led_inset_pattern) {
+ cairo_pattern_destroy (led_inset_pattern);
+ led_inset_pattern = 0;
+ }
+
+ //convex gradient
+ convex_pattern = cairo_pattern_create_linear (0.0, 0, 0.0, get_height());
+ cairo_pattern_add_color_stop_rgba (convex_pattern, 0.0, 0,0,0, 0.0);
+ cairo_pattern_add_color_stop_rgba (convex_pattern, 1.0, 0,0,0, 0.35);
+
+ //concave gradient
+ concave_pattern = cairo_pattern_create_linear (0.0, 0, 0.0, get_height());
+ cairo_pattern_add_color_stop_rgba (concave_pattern, 0.0, 0,0,0, 0.5);
+ cairo_pattern_add_color_stop_rgba (concave_pattern, 0.7, 0,0,0, 0.0);
+
+ led_inset_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, _diameter);
+ cairo_pattern_add_color_stop_rgba (led_inset_pattern, 0, 0,0,0, 0.4);
+ cairo_pattern_add_color_stop_rgba (led_inset_pattern, 1, 1,1,1, 0.7);
+
+ _pattern_height = get_height() ;
+}
+
+void
+ArdourButton::set_led_left (bool yn)
+{
+ _led_left = yn;
+}
+
+bool
+ArdourButton::on_button_press_event (GdkEventButton *ev)
+{
+ focus_handler (this);
+
+ if (ev->button == 1 && (_elements & Indicator) && _led_rect && _distinct_led_click) {
+ if (ev->x >= _led_rect->x && ev->x < _led_rect->x + _led_rect->width &&
+ ev->y >= _led_rect->y && ev->y < _led_rect->y + _led_rect->height) {
+ return true;
+ }
+ }
+
+ if (binding_proxy.button_press_handler (ev)) {
+ return true;
+ }
+
+ _grabbed = true;
+ CairoWidget::set_dirty ();
+
+ if (ev->button == 1 && !_act_on_release) {
+ if (_action) {
+ _action->activate ();
+ return true;
+ }
+ }
+
+ if (_fallthrough_to_parent)
+ return false;
+
+ return true;
+}
+
+bool
+ArdourButton::on_button_release_event (GdkEventButton *ev)
+{
+ if (ev->button == 1 && _hovering && (_elements & Indicator) && _led_rect && _distinct_led_click) {
+ if (ev->x >= _led_rect->x && ev->x < _led_rect->x + _led_rect->width &&
+ ev->y >= _led_rect->y && ev->y < _led_rect->y + _led_rect->height) {
+ signal_led_clicked(ev); /* EMIT SIGNAL */
+ return true;
+ }
+ }
+
+ _grabbed = false;
+ CairoWidget::set_dirty ();
+
+ if (ev->button == 1 && _hovering) {
+ signal_clicked ();
+ if (_act_on_release) {
+ if (_action) {
+ _action->activate ();
+ return true;
+ }
+ }
+ }
+
+ if (_fallthrough_to_parent)
+ return false;
+
+ return true;
+}
+
+void
+ArdourButton::set_distinct_led_click (bool yn)
+{
+ _distinct_led_click = yn;
+ setup_led_rect ();
+}
+
+void
+ArdourButton::color_handler ()
+{
+ _update_colors = true;
+ CairoWidget::set_dirty ();
+}
+
+void
+ArdourButton::on_size_allocate (Allocation& alloc)
+{
+ CairoWidget::on_size_allocate (alloc);
+ setup_led_rect ();
+}
+
+void
+ArdourButton::set_controllable (boost::shared_ptr<Controllable> c)
+{
+ watch_connection.disconnect ();
+ binding_proxy.set_controllable (c);
+}
+
+void
+ArdourButton::watch ()
+{
+ boost::shared_ptr<Controllable> c (binding_proxy.get_controllable ());
+
+ if (!c) {
+ warning << _("button cannot watch state of non-existing Controllable\n") << endmsg;
+ return;
+ }
+ c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&ArdourButton::controllable_changed, this), gui_context());
+}
+
+void
+ArdourButton::controllable_changed ()
+{
+ float val = binding_proxy.get_controllable()->get_value();
+
+ if (fabs (val) >= 0.5f) {
+ set_active_state (Gtkmm2ext::ExplicitActive);
+ } else {
+ unset_active_state ();
+ }
+ CairoWidget::set_dirty ();
+}
+
+void
+ArdourButton::set_related_action (RefPtr<Action> act)
+{
+ Gtkmm2ext::Activatable::set_related_action (act);
+
+ if (_action) {
+
+ action_tooltip_changed ();
+ action_sensitivity_changed ();
+
+ Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
+ if (tact) {
+ action_toggled ();
+ tact->signal_toggled().connect (sigc::mem_fun (*this, &ArdourButton::action_toggled));
+ }
+
+ _action->connect_property_changed ("sensitive", sigc::mem_fun (*this, &ArdourButton::action_sensitivity_changed));
+ _action->connect_property_changed ("visible", sigc::mem_fun (*this, &ArdourButton::action_visibility_changed));
+ _action->connect_property_changed ("tooltip", sigc::mem_fun (*this, &ArdourButton::action_tooltip_changed));
+ }
+}
+
+void
+ArdourButton::action_toggled ()
+{
+ Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
+
+ if (tact) {
+ if (tact->get_active()) {
+ set_active_state (Gtkmm2ext::ExplicitActive);
+ } else {
+ unset_active_state ();
+ }
+ }
+}
+
+void
+ArdourButton::on_style_changed (const RefPtr<Gtk::Style>&)
+{
+ _update_colors = true;
+ CairoWidget::set_dirty ();
+ _char_pixel_width = 0;
+ _char_pixel_height = 0;
+ if (is_realized()) {
+ queue_resize ();
+ }
+}
+
+void
+ArdourButton::on_name_changed ()
+{
+ _char_pixel_width = 0;
+ _char_pixel_height = 0;
+ _diameter = 0;
+ _update_colors = true;
+ if (is_realized()) {
+ queue_resize ();
+ }
+}
+
+void
+ArdourButton::setup_led_rect ()
+{
+ if (!(_elements & Indicator)) {
+ delete _led_rect;
+ _led_rect = 0;
+ return;
+ }
+
+ if (!_led_rect) {
+ _led_rect = new cairo_rectangle_t;
+ }
+
+ if (_elements & Text) {
+ if (_led_left) {
+ _led_rect->x = char_pixel_width();
+ } else {
+ _led_rect->x = get_width() - char_pixel_width() + _diameter;
+ }
+ } else {
+ /* centered */
+ _led_rect->x = .5 * get_width() - _diameter;
+ }
+
+ _led_rect->y = .5 * (get_height() - _diameter);
+ _led_rect->width = _diameter;
+ _led_rect->height = _diameter;
+}
+
+void
+ArdourButton::set_image (const RefPtr<Gdk::Pixbuf>& img)
+{
+ _elements = (ArdourButton::Element) (_elements & ~ArdourButton::Text);
+ _pixbuf = img;
+ if (is_realized()) {
+ queue_resize ();
+ }
+}
+
+void
+ArdourButton::set_active_state (Gtkmm2ext::ActiveState s)
+{
+ bool changed = (_active_state != s);
+ CairoWidget::set_active_state (s);
+ if (changed) {
+ _update_colors = true;
+ CairoWidget::set_dirty ();
+ }
+}
+
+void
+ArdourButton::set_visual_state (Gtkmm2ext::VisualState s)
+{
+ bool changed = (_visual_state != s);
+ CairoWidget::set_visual_state (s);
+ if (changed) {
+ _update_colors = true;
+ CairoWidget::set_dirty ();
+ }
+}
+
+bool
+ArdourButton::on_focus_in_event (GdkEventFocus* ev)
+{
+ _focused = true;
+ CairoWidget::set_dirty ();
+ return CairoWidget::on_focus_in_event (ev);
+}
+
+bool
+ArdourButton::on_focus_out_event (GdkEventFocus* ev)
+{
+ _focused = false;
+ CairoWidget::set_dirty ();
+ return CairoWidget::on_focus_out_event (ev);
+}
+
+bool
+ArdourButton::on_key_release_event (GdkEventKey *ev) {
+ if (_act_on_release && _focused &&
+ (ev->keyval == GDK_space || ev->keyval == GDK_Return))
+ {
+ signal_clicked();
+ if (_action) {
+ _action->activate ();
+ }
+ return true;
+ }
+ return CairoWidget::on_key_release_event (ev);
+}
+
+bool
+ArdourButton::on_key_press_event (GdkEventKey *ev) {
+ if (!_act_on_release && _focused &&
+ (ev->keyval == GDK_space || ev->keyval == GDK_Return))
+ {
+ signal_clicked();
+ if (_action) {
+ _action->activate ();
+ }
+ return true;
+ }
+ return CairoWidget::on_key_release_event (ev);
+}
+
+bool
+ArdourButton::on_enter_notify_event (GdkEventCrossing* ev)
+{
+ _hovering = (_elements & Inactive) ? false : true;
+
+ if (UIConfigurationBase::instance().get_widget_prelight()) {
+ CairoWidget::set_dirty ();
+ }
+
+ boost::shared_ptr<PBD::Controllable> c (binding_proxy.get_controllable ());
+ if (c) {
+ PBD::Controllable::GUIFocusChanged (boost::weak_ptr<PBD::Controllable> (c));
+ }
+
+ return CairoWidget::on_enter_notify_event (ev);
+}
+
+bool
+ArdourButton::on_leave_notify_event (GdkEventCrossing* ev)
+{
+ _hovering = false;
+
+ if (UIConfigurationBase::instance().get_widget_prelight()) {
+ CairoWidget::set_dirty ();
+ }
+
+ if (binding_proxy.get_controllable()) {
+ PBD::Controllable::GUIFocusChanged (boost::weak_ptr<PBD::Controllable> ());
+ }
+
+ return CairoWidget::on_leave_notify_event (ev);
+}
+
+bool
+ArdourButton::on_grab_broken_event(GdkEventGrabBroken* grab_broken_event) {
+ /* Our implicit grab due to a button_press was broken by another grab:
+ * the button will not get any button_release event if the mouse leaves
+ * while the grab is taken, so unpress ourselves */
+ _grabbed = false;
+ CairoWidget::set_dirty ();
+ return true;
+}
+
+void
+ArdourButton::set_tweaks (Tweaks t)
+{
+ if (_tweaks != t) {
+ _tweaks = t;
+ if (is_realized()) {
+ queue_resize ();
+ }
+ }
+}
+
+void
+ArdourButton::action_sensitivity_changed ()
+{
+ if (_action->property_sensitive ()) {
+ set_visual_state (Gtkmm2ext::VisualState (visual_state() & ~Gtkmm2ext::Insensitive));
+ } else {
+ set_visual_state (Gtkmm2ext::VisualState (visual_state() | Gtkmm2ext::Insensitive));
+ }
+}
+
+void
+ArdourButton::set_layout_ellipsize_width (int w)
+{
+ if (_layout_ellipsize_width == w) {
+ return;
+ }
+ _layout_ellipsize_width = w;
+ if (!_layout) {
+ return;
+ }
+ if (_layout_ellipsize_width > 3 * PANGO_SCALE) {
+ _layout->set_width (_layout_ellipsize_width - 3 * PANGO_SCALE);
+ }
+ if (is_realized ()) {
+ queue_resize ();
+ }
+}
+
+void
+ArdourButton::set_text_ellipsize (Pango::EllipsizeMode e)
+{
+ if (_ellipsis == e) {
+ return;
+ }
+ _ellipsis = e;
+ if (!_layout) {
+ return;
+ }
+ _layout->set_ellipsize(_ellipsis);
+ if (_layout_ellipsize_width > 3 * PANGO_SCALE) {
+ _layout->set_width (_layout_ellipsize_width - 3 * PANGO_SCALE);
+ }
+ if (is_realized ()) {
+ queue_resize ();
+ }
+}
+
+void
+ArdourButton::ensure_layout ()
+{
+ if (!_layout) {
+ ensure_style ();
+ _layout = Pango::Layout::create (get_pango_context());
+ _layout->set_ellipsize(_ellipsis);
+ if (_layout_ellipsize_width > 3 * PANGO_SCALE) {
+ _layout->set_width (_layout_ellipsize_width - 3* PANGO_SCALE);
+ }
+ }
+}
+
+void
+ArdourButton::recalc_char_pixel_geometry ()
+{
+ if (_char_pixel_height > 0 && _char_pixel_width > 0) {
+ return;
+ }
+ ensure_layout();
+ // NB. this is not static, since the geometry is different
+ // depending on the font used.
+ int w, h;
+ std::string x = _("@ABCDEFGHIJLKMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
+ _layout->set_text (x);
+ _layout->get_pixel_size (w, h);
+ _char_pixel_height = std::max(4, h);
+ // number of actual chars in the string (not bytes)
+ // Glib to the rescue.
+ Glib::ustring gx(x);
+ _char_avg_pixel_width = w / (float)gx.size();
+ _char_pixel_width = std::max(4, (int) ceil (_char_avg_pixel_width));
+ set_text_internal (); /* restore display text */
+}
+
+void
+ArdourButton::action_visibility_changed ()
+{
+ if (_action->property_visible ()) {
+ show ();
+ } else {
+ hide ();
+ }
+}
+
+void
+ArdourButton::action_tooltip_changed ()
+{
+ string str = _action->property_tooltip().get_value();
+ set_tooltip (*this, str);
+}
+
+void
+ArdourButton::set_elements (Element e)
+{
+ _elements = e;
+ CairoWidget::set_dirty ();
+}
+
+void
+ArdourButton::add_elements (Element e)
+{
+ _elements = (ArdourButton::Element) (_elements | e);
+ CairoWidget::set_dirty ();
+}
+
+void
+ArdourButton::set_icon (Gtkmm2ext::ArdourIcon::Icon i)
+{
+ _icon = i;
+ _icon_render_cb = 0;
+ _icon_render_cb_data = 0;
+ _elements = (ArdourButton::Element) ((_elements | VectorIcon) & ~(ArdourButton::Text | IconRenderCallback));
+ CairoWidget::set_dirty ();
+}
+
+void
+ArdourButton::set_icon (rendercallback_t cb, void* d)
+{
+ if (!cb) {
+ _elements = (ArdourButton::Element) ((_elements | ArdourButton::Text) & ~(IconRenderCallback | VectorIcon));
+ _icon_render_cb = 0;
+ _icon_render_cb_data = 0;
+ } else {
+ _elements = (ArdourButton::Element) ((_elements | IconRenderCallback) & ~(ArdourButton::Text | VectorIcon));
+ _icon_render_cb = cb;
+ _icon_render_cb_data = d;
+ }
+ CairoWidget::set_dirty ();
+}
+
+void
+ArdourButton::set_custom_led_color (uint32_t c, bool useit)
+{
+ if (led_custom_color == c && use_custom_led_color == useit) {
+ return;
+ }
+
+ led_custom_color = c;
+ use_custom_led_color = useit;
+ CairoWidget::set_dirty ();
+}
--- /dev/null
+/*
+ Copyright (C) 2014 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 <pangomm/layout.h>
+
+#include "pbd/compose.h"
+#include "pbd/controllable.h"
+#include "pbd/error.h"
+#include "pbd/stacktrace.h"
+
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/rgb_macros.h"
+#include "gtkmm2ext/gui_thread.h"
+#include "gtkmm2ext/keyboard.h"
+
+#include "widgets/ardour_display.h"
+
+#include "pbd/i18n.h"
+
+using namespace Gtkmm2ext;
+using namespace Gdk;
+using namespace Gtk;
+using namespace Glib;
+using namespace PBD;
+using namespace ArdourWidgets;
+using std::max;
+using std::min;
+using namespace std;
+
+ArdourDisplay::ArdourDisplay (Element e)
+{
+ add_elements(ArdourButton::Text);
+}
+
+ArdourDisplay::~ArdourDisplay ()
+{
+}
+
+
+bool
+ArdourDisplay::on_scroll_event (GdkEventScroll* ev)
+{
+ /* mouse wheel */
+
+ float scale = 1.0;
+ if (ev->state & Keyboard::GainFineScaleModifier) {
+ if (ev->state & Keyboard::GainExtraFineScaleModifier) {
+ scale *= 0.01;
+ } else {
+ scale *= 0.10;
+ }
+ }
+
+ boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
+ if (c) {
+ float val = c->get_interface();
+
+ if ( ev->direction == GDK_SCROLL_UP )
+ val += 0.05 * scale; //by default, we step in 1/20ths of the knob travel
+ else
+ val -= 0.05 * scale;
+
+ c->set_interface(val);
+ }
+
+ return true;
+}
+
+
+void
+ArdourDisplay::add_controllable_preset (const char *txt, float val)
+{
+ using namespace Menu_Helpers;
+ AddMenuElem(MenuElem (txt, sigc::bind (sigc::mem_fun(*this, &ArdourDisplay::handle_controllable_preset), val)));
+}
+
+static inline float dB_to_coefficient (float dB) {
+ return dB > -318.8f ? pow (10.0f, dB * 0.05f) : 0.0f;
+}
+
+void
+ArdourDisplay::handle_controllable_preset (float p)
+{
+ boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
+
+ if (!c) return;
+
+ /* This should not use dB_to_coefficient(), but the Controllable's value.
+ *
+ * The only user of this API is currently monitor_section.cc which conveniently
+ * binds dB values. Once there are other use-cases, for this, this (GUI only) API
+ * needs fixing.
+ */
+ c->set_value(dB_to_coefficient (p), Controllable::NoGroup);
+}
+
+
+void
+ArdourDisplay::set_controllable (boost::shared_ptr<Controllable> c)
+{
+ watch_connection.disconnect (); //stop watching the old controllable
+
+ if (!c) return;
+
+ binding_proxy.set_controllable (c);
+
+ c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&ArdourDisplay::controllable_changed, this), gui_context());
+
+ controllable_changed();
+}
+
+void
+ArdourDisplay::controllable_changed ()
+{
+ boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
+
+ if (!c) return;
+
+ set_text(c->get_user_string());
+
+ set_dirty();
+}
--- /dev/null
+/*
+ Copyright (C) 2014 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 <pangomm/layout.h>
+
+#include "pbd/compose.h"
+#include "pbd/error.h"
+#include "pbd/stacktrace.h"
+
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/rgb_macros.h"
+#include "gtkmm2ext/gui_thread.h"
+
+#include "ardour/rc_configuration.h" // for widget prelight preference
+
+#include "widgets/ardour_dropdown.h"
+
+#include "pbd/i18n.h"
+
+#define REFLECTION_HEIGHT 2
+
+using namespace Gdk;
+using namespace Gtk;
+using namespace Glib;
+using namespace PBD;
+using namespace ArdourWidgets;
+using namespace std;
+
+
+ArdourDropdown::ArdourDropdown (Element e)
+ : _scrolling_disabled(false)
+{
+// signal_button_press_event().connect (sigc::mem_fun(*this, &ArdourDropdown::on_mouse_pressed));
+ _menu.signal_size_request().connect (sigc::mem_fun(*this, &ArdourDropdown::menu_size_request));
+
+ _menu.set_reserve_toggle_size(false);
+
+ add_elements(e);
+ add_elements(ArdourButton::Menu);
+}
+
+ArdourDropdown::~ArdourDropdown ()
+{
+}
+
+void
+ArdourDropdown::menu_size_request(Requisition *req) {
+ req->width = max(req->width, get_allocation().get_width());
+}
+
+bool
+ArdourDropdown::on_button_press_event (GdkEventButton* ev)
+{
+ if (binding_proxy.button_press_handler (ev)) {
+ return true;
+ }
+
+ if (ev->type == GDK_BUTTON_PRESS && ev->button == 1) {
+ Gtkmm2ext::anchored_menu_popup(&_menu, this, get_text(), 1, ev->time);
+ }
+
+ return true;
+}
+
+bool
+ArdourDropdown::on_scroll_event (GdkEventScroll* ev)
+{
+ using namespace Menu_Helpers;
+
+ if (_scrolling_disabled) {
+ return false;
+ }
+
+ const MenuItem * current_active = _menu.get_active();
+ const MenuList& items = _menu.items ();
+ int c = 0;
+
+ if (!current_active) {
+ return true;
+ }
+
+ /* work around another gtkmm API clusterfuck
+ * const MenuItem* get_active () const
+ * void set_active (guint index)
+ *
+ * also MenuList.activate_item does not actually
+ * set it as active in the menu.
+ *
+ */
+
+ switch (ev->direction) {
+ case GDK_SCROLL_UP:
+
+ for (MenuList::const_reverse_iterator i = items.rbegin(); i != items.rend(); ++i, ++c) {
+ if ( &(*i) != current_active) {
+ continue;
+ }
+ if (++i != items.rend()) {
+ c = items.size() - 2 - c;
+ assert(c >= 0);
+ _menu.set_active(c);
+ _menu.activate_item(*i);
+ }
+ break;
+ }
+ break;
+ case GDK_SCROLL_DOWN:
+ for (MenuList::const_iterator i = items.begin(); i != items.end(); ++i, ++c) {
+ if ( &(*i) != current_active) {
+ continue;
+ }
+ if (++i != items.end()) {
+ assert(c + 1 < (int) items.size());
+ _menu.set_active(c + 1);
+ _menu.activate_item(*i);
+ }
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ return true;
+}
+
+void
+ArdourDropdown::clear_items ()
+{
+ _menu.items ().clear ();
+}
+
+void
+ArdourDropdown::AddMenuElem (Menu_Helpers::Element e)
+{
+ using namespace Menu_Helpers;
+
+ MenuList& items = _menu.items ();
+
+ items.push_back (e);
+}
+
+void
+ArdourDropdown::disable_scrolling()
+{
+ _scrolling_disabled = true;
+}
--- /dev/null
+/*
+ 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 <pangomm/layout.h>
+
+#include "pbd/compose.h"
+#include "pbd/controllable.h"
+#include "pbd/error.h"
+#include "pbd/stacktrace.h"
+
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/rgb_macros.h"
+#include "gtkmm2ext/gui_thread.h"
+#include "gtkmm2ext/keyboard.h"
+
+#include "pbd/controllable.h"
+
+#include "widgets/ardour_knob.h"
+#include "widgets/ui_config.h"
+//#include "timers.h"
+
+#include "canvas/colors.h"
+#include "canvas/utils.h"
+
+#include "pbd/i18n.h"
+
+using namespace Gtkmm2ext;
+using namespace ArdourWidgets;
+using namespace Gtk;
+using namespace Glib;
+using namespace PBD;
+using std::max;
+using std::min;
+using namespace std;
+
+ArdourKnob::Element ArdourKnob::default_elements = ArdourKnob::Element (ArdourKnob::Arc);
+
+ArdourKnob::ArdourKnob (Element e, Flags flags)
+ : _elements (e)
+ , _hovering (false)
+ , _grabbed_x (0)
+ , _grabbed_y (0)
+ , _val (0)
+ , _normal (0)
+ , _dead_zone_delta (0)
+ , _flags (flags)
+ , _tooltip (this)
+{
+ UIConfigurationBase::instance().ColorsChanged.connect (sigc::mem_fun (*this, &ArdourKnob::color_handler));
+
+ // watch automation :(
+ // TODO only use for GainAutomation
+ //Timers::rapid_connect (sigc::bind (sigc::mem_fun (*this, &ArdourKnob::controllable_changed), false));
+}
+
+ArdourKnob::~ArdourKnob()
+{
+}
+
+void
+ArdourKnob::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
+{
+ cairo_t* cr = ctx->cobj();
+ cairo_pattern_t* shade_pattern;
+
+ float width = get_width();
+ float height = get_height();
+
+ const float scale = min(width, height);
+ const float pointer_thickness = 3.0 * (scale/80); //(if the knob is 80 pixels wide, we want a 3-pix line on it)
+
+ const float start_angle = ((180 - 65) * G_PI) / 180;
+ const float end_angle = ((360 + 65) * G_PI) / 180;
+
+ float zero = 0;
+ if (_flags & ArcToZero) {
+ zero = _normal;
+ }
+
+ const float value_angle = start_angle + (_val * (end_angle - start_angle));
+ const float zero_angle = start_angle + (zero * (end_angle - start_angle));
+
+ float value_x = cos (value_angle);
+ float value_y = sin (value_angle);
+
+ float xc = 0.5 + width/ 2.0;
+ float yc = 0.5 + height/ 2.0;
+
+ cairo_translate (cr, xc, yc); //after this, everything is based on the center of the knob
+
+ //get the knob color from the theme
+ ArdourCanvas::Color knob_color = UIConfigurationBase::instance().color (string_compose ("%1", get_name()));
+
+ float center_radius = 0.48*scale;
+ float border_width = 0.8;
+
+ bool arc = (_elements & Arc)==Arc;
+ bool bevel = (_elements & Bevel)==Bevel;
+ bool flat = _flat_buttons;
+
+ if ( arc ) {
+ center_radius = scale*0.33;
+
+ float inner_progress_radius = scale*0.38;
+ float outer_progress_radius = scale*0.48;
+ float progress_width = (outer_progress_radius-inner_progress_radius);
+ float progress_radius = inner_progress_radius + progress_width/2.0;
+
+ //dark arc background
+ cairo_set_source_rgb (cr, 0.3, 0.3, 0.3 );
+ cairo_set_line_width (cr, progress_width);
+ cairo_arc (cr, 0, 0, progress_radius, start_angle, end_angle);
+ cairo_stroke (cr);
+
+ //look up the arc colors from the config
+ double red_start, green_start, blue_start, unused;
+ ArdourCanvas::Color arc_start_color = UIConfigurationBase::instance().color ( string_compose ("%1: arc start", get_name()));
+ ArdourCanvas::color_to_rgba( arc_start_color, red_start, green_start, blue_start, unused );
+ double red_end, green_end, blue_end;
+ ArdourCanvas::Color arc_end_color = UIConfigurationBase::instance().color ( string_compose ("%1: arc end", get_name()) );
+ ArdourCanvas::color_to_rgba( arc_end_color, red_end, green_end, blue_end, unused );
+
+ //vary the arc color over the travel of the knob
+ float intensity = fabsf (_val - zero) / std::max(zero, (1.f - zero));
+ const float intensity_inv = 1.0 - intensity;
+ float r = intensity_inv * red_end + intensity * red_start;
+ float g = intensity_inv * green_end + intensity * green_start;
+ float b = intensity_inv * blue_end + intensity * blue_start;
+
+ //draw the arc
+ cairo_set_source_rgb (cr, r,g,b);
+ cairo_set_line_width (cr, progress_width);
+ if (zero_angle > value_angle) {
+ cairo_arc (cr, 0, 0, progress_radius, value_angle, zero_angle);
+ } else {
+ cairo_arc (cr, 0, 0, progress_radius, zero_angle, value_angle);
+ }
+ cairo_stroke (cr);
+
+ //shade the arc
+ if (!flat) {
+ shade_pattern = cairo_pattern_create_linear (0.0, -yc, 0.0, yc); //note we have to offset the pattern from our centerpoint
+ cairo_pattern_add_color_stop_rgba (shade_pattern, 0.0, 1,1,1, 0.15);
+ cairo_pattern_add_color_stop_rgba (shade_pattern, 0.5, 1,1,1, 0.0);
+ cairo_pattern_add_color_stop_rgba (shade_pattern, 1.0, 1,1,1, 0.0);
+ cairo_set_source (cr, shade_pattern);
+ cairo_arc (cr, 0, 0, outer_progress_radius-1, 0, 2.0*G_PI);
+ cairo_fill (cr);
+ cairo_pattern_destroy (shade_pattern);
+ }
+
+#if 0 //black border
+ const float start_angle_x = cos (start_angle);
+ const float start_angle_y = sin (start_angle);
+ const float end_angle_x = cos (end_angle);
+ const float end_angle_y = sin (end_angle);
+
+ cairo_set_source_rgb (cr, 0, 0, 0 );
+ cairo_set_line_width (cr, border_width);
+ cairo_move_to (cr, (outer_progress_radius * start_angle_x), (outer_progress_radius * start_angle_y));
+ cairo_line_to (cr, (inner_progress_radius * start_angle_x), (inner_progress_radius * start_angle_y));
+ cairo_stroke (cr);
+ cairo_move_to (cr, (outer_progress_radius * end_angle_x), (outer_progress_radius * end_angle_y));
+ cairo_line_to (cr, (inner_progress_radius * end_angle_x), (inner_progress_radius * end_angle_y));
+ cairo_stroke (cr);
+ cairo_arc (cr, 0, 0, outer_progress_radius, start_angle, end_angle);
+ cairo_stroke (cr);
+#endif
+ }
+
+ if (!flat) {
+ //knob shadow
+ cairo_save(cr);
+ cairo_translate(cr, pointer_thickness+1, pointer_thickness+1 );
+ cairo_set_source_rgba (cr, 0, 0, 0, 0.1 );
+ cairo_arc (cr, 0, 0, center_radius-1, 0, 2.0*G_PI);
+ cairo_fill (cr);
+ cairo_restore(cr);
+
+ //inner circle
+ ArdourCanvas::set_source_rgba(cr, knob_color);
+ cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
+ cairo_fill (cr);
+
+ //gradient
+ if (bevel) {
+ //knob gradient
+ shade_pattern = cairo_pattern_create_linear (0.0, -yc, 0.0, yc); //note we have to offset the gradient from our centerpoint
+ cairo_pattern_add_color_stop_rgba (shade_pattern, 0.0, 1,1,1, 0.2);
+ cairo_pattern_add_color_stop_rgba (shade_pattern, 0.2, 1,1,1, 0.2);
+ cairo_pattern_add_color_stop_rgba (shade_pattern, 0.8, 0,0,0, 0.2);
+ cairo_pattern_add_color_stop_rgba (shade_pattern, 1.0, 0,0,0, 0.2);
+ cairo_set_source (cr, shade_pattern);
+ cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
+ cairo_fill (cr);
+ cairo_pattern_destroy (shade_pattern);
+
+ //flat top over beveled edge
+ ArdourCanvas::set_source_rgb_a (cr, knob_color, 0.5 );
+ cairo_arc (cr, 0, 0, center_radius-pointer_thickness, 0, 2.0*G_PI);
+ cairo_fill (cr);
+ } else {
+ //radial gradient
+ shade_pattern = cairo_pattern_create_radial ( -center_radius, -center_radius, 1, -center_radius, -center_radius, center_radius*2.5 ); //note we have to offset the gradient from our centerpoint
+ cairo_pattern_add_color_stop_rgba (shade_pattern, 0.0, 1,1,1, 0.2);
+ cairo_pattern_add_color_stop_rgba (shade_pattern, 1.0, 0,0,0, 0.3);
+ cairo_set_source (cr, shade_pattern);
+ cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
+ cairo_fill (cr);
+ cairo_pattern_destroy (shade_pattern);
+ }
+
+ } else {
+ //inner circle
+ ArdourCanvas::set_source_rgba(cr, knob_color);
+ cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
+ cairo_fill (cr);
+ }
+
+
+ //black knob border
+ cairo_set_line_width (cr, border_width);
+ cairo_set_source_rgba (cr, 0,0,0, 1 );
+ cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
+ cairo_stroke (cr);
+
+ //line shadow
+ if (!flat) {
+ cairo_save(cr);
+ cairo_translate(cr, 1, 1 );
+ cairo_set_source_rgba (cr, 0,0,0,0.3 );
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_width (cr, pointer_thickness);
+ cairo_move_to (cr, (center_radius * value_x), (center_radius * value_y));
+ cairo_line_to (cr, ((center_radius*0.4) * value_x), ((center_radius*0.4) * value_y));
+ cairo_stroke (cr);
+ cairo_restore(cr);
+ }
+
+ //line
+ cairo_set_source_rgba (cr, 1,1,1, 1 );
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
+ cairo_set_line_width (cr, pointer_thickness);
+ cairo_move_to (cr, (center_radius * value_x), (center_radius * value_y));
+ cairo_line_to (cr, ((center_radius*0.4) * value_x), ((center_radius*0.4) * value_y));
+ cairo_stroke (cr);
+
+ //highlight if grabbed or if mouse is hovering over me
+ if (_tooltip.dragging() || (_hovering && UIConfigurationBase::instance().get_widget_prelight() ) ) {
+ cairo_set_source_rgba (cr, 1,1,1, 0.12 );
+ cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
+ cairo_fill (cr);
+ }
+
+ cairo_identity_matrix(cr);
+}
+
+void
+ArdourKnob::on_size_request (Gtk::Requisition* req)
+{
+ // see ardour-button VectorIcon size, use font scaling as default
+ CairoWidget::on_size_request (req); // allow to override
+
+ // we're square
+ if (req->width < req->height) {
+ req->width = req->height;
+ }
+ if (req->height < req->width) {
+ req->height = req->width;
+ }
+}
+
+bool
+ArdourKnob::on_scroll_event (GdkEventScroll* ev)
+{
+ /* mouse wheel */
+
+ float scale = 0.05; //by default, we step in 1/20ths of the knob travel
+ if (ev->state & Keyboard::GainFineScaleModifier) {
+ if (ev->state & Keyboard::GainExtraFineScaleModifier) {
+ scale *= 0.01;
+ } else {
+ scale *= 0.10;
+ }
+ }
+
+ boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
+ if (c) {
+ float val = c->get_interface();
+
+ if ( ev->direction == GDK_SCROLL_UP )
+ val += scale;
+ else
+ val -= scale;
+
+ c->set_interface(val);
+ }
+
+ return true;
+}
+
+bool
+ArdourKnob::on_motion_notify_event (GdkEventMotion *ev)
+{
+ if (!(ev->state & Gdk::BUTTON1_MASK)) {
+ return true;
+ }
+
+ boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
+ if (!c) {
+ return true;
+ }
+
+
+ //scale the adjustment based on keyboard modifiers & GUI size
+ const float ui_scale = max (1.f, UIConfigurationBase::instance().get_ui_scale());
+ float scale = 0.0025 / ui_scale;
+
+ if (ev->state & Keyboard::GainFineScaleModifier) {
+ if (ev->state & Keyboard::GainExtraFineScaleModifier) {
+ scale *= 0.01;
+ } else {
+ scale *= 0.10;
+ }
+ }
+
+ //calculate the travel of the mouse
+ int delta = (_grabbed_y - ev->y) - (_grabbed_x - ev->x);
+ if (delta == 0) {
+ return true;
+ }
+
+ _grabbed_x = ev->x;
+ _grabbed_y = ev->y;
+ float val = c->get_interface();
+
+ if (_flags & Detent) {
+ const float px_deadzone = 42.f * ui_scale;
+
+ if ((val - _normal) * (val - _normal + delta * scale) < 0) {
+ /* detent */
+ const int tozero = (_normal - val) * scale;
+ int remain = delta - tozero;
+ if (abs (remain) > px_deadzone) {
+ /* slow down passing the default value */
+ remain += (remain > 0) ? px_deadzone * -.5 : px_deadzone * .5;
+ delta = tozero + remain;
+ _dead_zone_delta = 0;
+ } else {
+ c->set_value (c->normal(), Controllable::NoGroup);
+ _dead_zone_delta = remain / px_deadzone;
+ return true;
+ }
+ }
+
+ if (fabsf (rintf((val - _normal) / scale) + _dead_zone_delta) < 1) {
+ c->set_value (c->normal(), Controllable::NoGroup);
+ _dead_zone_delta += delta / px_deadzone;
+ return true;
+ }
+
+ _dead_zone_delta = 0;
+ }
+
+ val += delta * scale;
+ c->set_interface(val);
+
+ return true;
+}
+
+bool
+ArdourKnob::on_button_press_event (GdkEventButton *ev)
+{
+ _grabbed_x = ev->x;
+ _grabbed_y = ev->y;
+ _dead_zone_delta = 0;
+
+ if (ev->type != GDK_BUTTON_PRESS) {
+ if (_grabbed) {
+ remove_modal_grab();
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
+ }
+ return true;
+ }
+
+ if (binding_proxy.button_press_handler (ev)) {
+ return true;
+ }
+
+ if (ev->button != 1 && ev->button != 2) {
+ return false;
+ }
+
+ set_active_state (Gtkmm2ext::ExplicitActive);
+ _tooltip.start_drag();
+ add_modal_grab();
+ _grabbed = true;
+ gdk_pointer_grab(ev->window,false,
+ GdkEventMask( Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK |Gdk::BUTTON_RELEASE_MASK),
+ NULL,NULL,ev->time);
+ return true;
+}
+
+bool
+ArdourKnob::on_button_release_event (GdkEventButton *ev)
+{
+ _tooltip.stop_drag();
+ _grabbed = false;
+ remove_modal_grab();
+ gdk_pointer_ungrab (GDK_CURRENT_TIME);
+
+ if ( (_grabbed_y == ev->y && _grabbed_x == ev->x) && Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { //no move, shift-click sets to default
+ boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
+ if (!c) return false;
+ c->set_value (c->normal(), Controllable::NoGroup);
+ return true;
+ }
+
+ unset_active_state ();
+
+ return true;
+}
+
+void
+ArdourKnob::color_handler ()
+{
+ set_dirty ();
+}
+
+void
+ArdourKnob::on_size_allocate (Allocation& alloc)
+{
+ CairoWidget::on_size_allocate (alloc);
+}
+
+void
+ArdourKnob::set_controllable (boost::shared_ptr<Controllable> c)
+{
+ watch_connection.disconnect (); //stop watching the old controllable
+
+ if (!c) return;
+
+ binding_proxy.set_controllable (c);
+
+ c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&ArdourKnob::controllable_changed, this, false), gui_context());
+
+ _normal = c->internal_to_interface(c->normal());
+
+ controllable_changed();
+}
+
+void
+ArdourKnob::controllable_changed (bool force_update)
+{
+ boost::shared_ptr<PBD::Controllable> c = binding_proxy.get_controllable();
+ if (!c) return;
+
+ float val = c->get_interface();
+ val = min( max(0.0f, val), 1.0f); // clamp
+
+ if (val == _val && !force_update) {
+ return;
+ }
+
+ _val = val;
+ if (!_tooltip_prefix.empty()) {
+ _tooltip.set_tip (_tooltip_prefix + c->get_user_string());
+ }
+ set_dirty();
+}
+
+void
+ArdourKnob::on_style_changed (const RefPtr<Gtk::Style>&)
+{
+ set_dirty ();
+}
+
+void
+ArdourKnob::on_name_changed ()
+{
+ set_dirty ();
+}
+
+
+void
+ArdourKnob::set_active_state (Gtkmm2ext::ActiveState s)
+{
+ if (_active_state != s)
+ CairoWidget::set_active_state (s);
+}
+
+void
+ArdourKnob::set_visual_state (Gtkmm2ext::VisualState s)
+{
+ if (_visual_state != s)
+ CairoWidget::set_visual_state (s);
+}
+
+
+bool
+ArdourKnob::on_focus_in_event (GdkEventFocus* ev)
+{
+ set_dirty ();
+ return CairoWidget::on_focus_in_event (ev);
+}
+
+bool
+ArdourKnob::on_focus_out_event (GdkEventFocus* ev)
+{
+ set_dirty ();
+ return CairoWidget::on_focus_out_event (ev);
+}
+
+bool
+ArdourKnob::on_enter_notify_event (GdkEventCrossing* ev)
+{
+ _hovering = true;
+
+ set_dirty ();
+
+ boost::shared_ptr<PBD::Controllable> c (binding_proxy.get_controllable ());
+ if (c) {
+ PBD::Controllable::GUIFocusChanged (boost::weak_ptr<PBD::Controllable> (c));
+ }
+
+ return CairoWidget::on_enter_notify_event (ev);
+}
+
+bool
+ArdourKnob::on_leave_notify_event (GdkEventCrossing* ev)
+{
+ _hovering = false;
+
+ set_dirty ();
+
+ if (binding_proxy.get_controllable()) {
+ PBD::Controllable::GUIFocusChanged (boost::weak_ptr<PBD::Controllable> ());
+ }
+
+ return CairoWidget::on_leave_notify_event (ev);
+}
+
+void
+ArdourKnob::set_elements (Element e)
+{
+ _elements = e;
+}
+
+void
+ArdourKnob::add_elements (Element e)
+{
+ _elements = (ArdourKnob::Element) (_elements | e);
+}
+
+
+KnobPersistentTooltip::KnobPersistentTooltip (Gtk::Widget* w)
+ : PersistentTooltip (w, true, 3)
+ , _dragging (false)
+{
+}
+
+void
+KnobPersistentTooltip::start_drag ()
+{
+ _dragging = true;
+}
+
+void
+KnobPersistentTooltip::stop_drag ()
+{
+ _dragging = false;
+}
+
+bool
+KnobPersistentTooltip::dragging () const
+{
+ return _dragging;
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "widgets/ardour_spacer.h"
+
+using namespace ArdourWidgets;
+
+ArdourVSpacer::ArdourVSpacer (float r)
+ : CairoWidget ()
+ , ratio (r)
+{
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "gtkmm2ext/gui_thread.h"
+#include "gtkmm2ext/utils.h"
+#include "gtkmm2ext/keyboard.h"
+
+#include "widgets/ardour_spinner.h"
+
+//#include "ardour/value_as_string.h" // XXX
+
+using namespace ArdourWidgets;
+
+ArdourSpinner::ArdourSpinner (boost::shared_ptr<PBD::Controllable> c, Gtk::Adjustment* adj)
+ : _btn (ArdourButton::Text)
+ , _ctrl_adj (adj)
+ , _spin_adj (0, c->lower (), c->upper (), .1, .01)
+ , _spinner (_spin_adj)
+ , _switching (false)
+ , _switch_on_release (false)
+ , _ctrl_ignore (false)
+ , _spin_ignore (false)
+ , _controllable (c)
+{
+ add_events (Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+ set (.5, .5, 1.0, 1.0);
+ set_border_width (0);
+
+ _btn.set_controllable (c);
+ _btn.set_fallthrough_to_parent (true);
+
+ _spinner.signal_activate().connect (mem_fun (*this, &ArdourSpinner::entry_activated));
+ _spinner.signal_focus_out_event().connect (mem_fun (*this, &ArdourSpinner::entry_focus_out));
+ _spinner.set_digits (4);
+ _spinner.set_numeric (true);
+ _spinner.set_name ("BarControlSpinner");
+
+ _spin_adj.set_step_increment(c->interface_to_internal(_ctrl_adj->get_step_increment()) - c->lower ());
+ _spin_adj.set_page_increment(c->interface_to_internal(_ctrl_adj->get_page_increment()) - c->lower ());
+
+ _spin_adj.signal_value_changed().connect (sigc::mem_fun(*this, &ArdourSpinner::spin_adjusted));
+ adj->signal_value_changed().connect (sigc::mem_fun(*this, &ArdourSpinner::ctrl_adjusted));
+ c->Changed.connect (watch_connection, invalidator(*this), boost::bind (&ArdourSpinner::controllable_changed, this), gui_context());
+
+#if 0
+ // this assume the "upper" value needs most space.
+ std::string txt = ARDOUR::value_as_string (c->desc(), c->upper ());
+ Gtkmm2ext::set_size_request_to_display_given_text (*this, txt, 2, 2);
+#endif
+
+ add (_btn);
+ show_all ();
+
+ controllable_changed();
+ ctrl_adjusted ();
+}
+
+
+ArdourSpinner::~ArdourSpinner ()
+{
+}
+
+bool
+ArdourSpinner::on_button_press_event (GdkEventButton* ev)
+{
+ if (get_child() != &_btn) {
+ return false;
+ }
+
+ if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
+ _switch_on_release = true;
+ return true;
+ } else {
+ _switch_on_release = false;
+ }
+ return false;
+}
+
+bool
+ArdourSpinner::on_button_release_event (GdkEventButton* ev)
+{
+ if (get_child() != &_btn) {
+ return false;
+ }
+ if (ev->button == 1 && _switch_on_release) {
+ Glib::signal_idle().connect (mem_fun (*this, &ArdourSpinner::switch_to_spinner));
+ return true;
+ }
+ return false;
+}
+
+bool
+ArdourSpinner::on_scroll_event (GdkEventScroll* ev)
+{
+ float scale = 1.0;
+ if (ev->state & Gtkmm2ext::Keyboard::GainFineScaleModifier) {
+ if (ev->state & Gtkmm2ext::Keyboard::GainExtraFineScaleModifier) {
+ scale *= 0.01;
+ } else {
+ scale *= 0.10;
+ }
+ }
+
+ boost::shared_ptr<PBD::Controllable> c = _btn.get_controllable();
+ if (c) {
+ float val = c->get_interface();
+
+ if ( ev->direction == GDK_SCROLL_UP )
+ val += 0.05 * scale; //by default, we step in 1/20ths of the knob travel
+ else
+ val -= 0.05 * scale;
+
+ c->set_interface(val);
+ }
+
+ return true;
+}
+
+gint
+ArdourSpinner::switch_to_button ()
+{
+ if (_switching || get_child() == &_btn) {
+ return false;
+ }
+ _switching = true;
+ remove ();
+ add (_btn);
+ _btn.show ();
+ _btn.set_dirty ();
+ _switching = false;
+ return false;
+}
+
+gint
+ArdourSpinner::switch_to_spinner ()
+{
+ if (_switching || get_child() != &_btn) {
+ return false;
+ }
+ _switching = true;
+ remove ();
+ add (_spinner);
+ _spinner.show ();
+ _spinner.select_region (0, _spinner.get_text_length ());
+ _spinner.grab_focus ();
+ _switching = false;
+ return false;
+}
+
+void
+ArdourSpinner::entry_activated ()
+{
+ switch_to_button ();
+}
+
+bool
+ArdourSpinner::entry_focus_out (GdkEventFocus* /*ev*/)
+{
+ entry_activated ();
+ return true;
+}
+
+void
+ArdourSpinner::ctrl_adjusted ()
+{
+ if (_spin_ignore) {
+ return;
+ }
+ _ctrl_ignore = true;
+ _spin_adj.set_value (_controllable->interface_to_internal (_ctrl_adj->get_value ()));
+ _ctrl_ignore = false;
+}
+
+void
+ArdourSpinner::spin_adjusted ()
+{
+ if (_ctrl_ignore) {
+ return;
+ }
+ _spin_ignore = true;
+ _ctrl_adj->set_value (_controllable->internal_to_interface (_spin_adj.get_value ()));
+ _spin_ignore = false;
+}
+
+void
+ArdourSpinner::controllable_changed ()
+{
+ _btn.set_text (_controllable->get_user_string());
+ _btn.set_dirty();
+}
--- /dev/null
+/*
+ Copyright (C) 2014 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 "gtkmm2ext/gtk_ui.h"
+#include "widgets/tooltips.h"
+
+namespace ArdourWidgets {
+
+void
+set_tooltip (Gtk::Widget& w, const std::string& text) {
+ Gtkmm2ext::UI::instance()->set_tip(w, text);
+}
+
+void
+set_tooltip (Gtk::Widget* w, const std::string& text) {
+ Gtkmm2ext::UI::instance()->set_tip(*w, text);
+}
+
+void
+set_tooltip (Gtk::Widget* w, const std::string& text, const std::string& help_text) {
+ Gtkmm2ext::UI::instance()->set_tip(w, text.c_str(), help_text.c_str());
+}
+
+}
--- /dev/null
+#include "widgets/ui_config.h"
+
+namespace ArdourWidgets {
+
+UIConfigurationBase* UIConfigurationBase::_instance = 0;
+
+};
--- /dev/null
+/*
+ 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 _WIDGETS_ARDOUR_BUTTON_H_
+#define _WIDGETS_ARDOUR_BUTTON_H_
+
+#include <list>
+#include <stdint.h>
+
+#include <gtkmm/action.h>
+
+#include "pbd/signals.h"
+#include "gtkmm2ext/ardour_icon.h"
+#include "gtkmm2ext/binding_proxy.h"
+#include "gtkmm2ext/activatable.h"
+#include "gtkmm2ext/cairo_widget.h"
+
+#include "widgets/visibility.h"
+
+namespace ArdourWidgets {
+
+class LIBWIDGETS_API ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
+{
+ public:
+ enum Element {
+ Edge = 0x1,
+ Body = 0x2,
+ Text = 0x4,
+ Indicator = 0x8,
+ unused = 0x10,
+ Menu = 0x20,
+ Inactive = 0x40, // no _action is defined AND state is not used
+ VectorIcon = 0x80,
+ IconRenderCallback = 0x100,
+ };
+
+ typedef void (* rendercallback_t) (cairo_t*, int, int, uint32_t, void*);
+
+ static Element default_elements;
+ static Element led_default_elements;
+ static Element just_led_default_elements;
+
+ ArdourButton (Element e = default_elements);
+ ArdourButton (const std::string&, Element e = default_elements);
+ virtual ~ArdourButton ();
+
+ enum Tweaks {
+ Square = 0x1,
+ TrackHeader = 0x2,
+ OccasionalText = 0x4,
+ unused4 = 0x8,
+ };
+
+ Tweaks tweaks() const { return _tweaks; }
+ void set_tweaks (Tweaks);
+
+ void set_active_state (Gtkmm2ext::ActiveState);
+ void set_visual_state (Gtkmm2ext::VisualState);
+
+ void set_custom_led_color (const uint32_t c, const bool useit = true);
+
+ void set_act_on_release (bool onRelease) { _act_on_release = onRelease; }
+
+ Element elements() const { return _elements; }
+ void set_elements (Element);
+ void add_elements (Element);
+
+ Gtkmm2ext::ArdourIcon::Icon icon() const { return _icon; }
+ void set_icon (Gtkmm2ext::ArdourIcon::Icon);
+ void set_icon (rendercallback_t, void*);
+
+ void set_corner_radius (float);
+
+ void set_text (const std::string&, bool markup = false);
+ const std::string& get_text () { return _text; }
+ bool get_markup () const { return _markup; }
+ void set_angle (const double);
+ void set_alignment (const float, const float);
+ void get_alignment (float& xa, float& ya) {xa = _xalign; ya = _yalign;};
+
+ void set_led_left (bool yn);
+ void set_distinct_led_click (bool yn);
+
+ void set_layout_ellipsize_width (int w);
+ void set_layout_font (const Pango::FontDescription&);
+ void set_text_ellipsize (Pango::EllipsizeMode);
+
+ /* Sets the text used for size request computation. Pass an
+ * empty string to return to the default behavior which uses
+ * the currently displayed text for measurement. */
+ void set_sizing_text (const std::string&);
+ const std::string& get_sizing_text () {return _sizing_text;}
+
+ sigc::signal<void, GdkEventButton*> signal_led_clicked;
+ sigc::signal<void> signal_clicked;
+
+ boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
+ void set_controllable (boost::shared_ptr<PBD::Controllable> c);
+ void watch ();
+
+ void set_related_action (Glib::RefPtr<Gtk::Action>);
+
+ bool on_button_press_event (GdkEventButton*);
+ bool on_button_release_event (GdkEventButton*);
+
+ void set_image (const Glib::RefPtr<Gdk::Pixbuf>&);
+
+ void set_fixed_colors (const uint32_t active_color, const uint32_t inactive_color);
+ void set_active_color (const uint32_t active_color);
+ void set_inactive_color (const uint32_t inactive_color);
+
+ void set_fallthrough_to_parent(bool fall) { _fallthrough_to_parent = fall; }
+
+ unsigned int char_pixel_width() { if (_char_pixel_width < 1) recalc_char_pixel_geometry() ; return _char_pixel_width; }
+ unsigned int char_pixel_height() { if (_char_pixel_height < 1) recalc_char_pixel_geometry() ; return _char_pixel_height; }
+ float char_avg_pixel_width() { if (_char_pixel_width < 1) recalc_char_pixel_geometry() ; return _char_avg_pixel_width; }
+
+ protected:
+ void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
+ void on_size_request (Gtk::Requisition* req);
+ void on_size_allocate (Gtk::Allocation&);
+ void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
+ void on_name_changed ();
+ void on_realize ();
+ bool on_enter_notify_event (GdkEventCrossing*);
+ bool on_leave_notify_event (GdkEventCrossing*);
+ bool on_grab_broken_event(GdkEventGrabBroken*);
+ bool on_focus_in_event (GdkEventFocus*);
+ bool on_focus_out_event (GdkEventFocus*);
+ bool on_key_release_event (GdkEventKey *);
+ bool on_key_press_event (GdkEventKey *);
+
+ void controllable_changed ();
+ PBD::ScopedConnection watch_connection;
+
+ protected:
+ Glib::RefPtr<Pango::Layout> _layout;
+ Glib::RefPtr<Gdk::Pixbuf> _pixbuf;
+ std::string _text;
+ std::string _sizing_text;
+ bool _markup;
+ Element _elements;
+ Gtkmm2ext::ArdourIcon::Icon _icon;
+ rendercallback_t _icon_render_cb;
+ void* _icon_render_cb_data;
+ Tweaks _tweaks;
+ BindingProxy binding_proxy;
+
+ void set_text_internal ();
+ void recalc_char_pixel_geometry ();
+ unsigned int _char_pixel_width;
+ unsigned int _char_pixel_height;
+ float _char_avg_pixel_width;
+
+ int _text_width;
+ int _text_height;
+ float _diameter;
+ float _corner_radius;
+ int _corner_mask;
+
+ double _angle;
+ float _xalign, _yalign;
+
+ uint32_t fill_inactive_color;
+ uint32_t fill_active_color;
+
+ uint32_t text_active_color;
+ uint32_t text_inactive_color;
+
+ uint32_t led_active_color;
+ uint32_t led_inactive_color;
+ uint32_t led_custom_color;
+ bool use_custom_led_color;
+
+ cairo_pattern_t* convex_pattern;
+ cairo_pattern_t* concave_pattern;
+ cairo_pattern_t* led_inset_pattern;
+ cairo_rectangle_t* _led_rect;
+
+ bool _act_on_release;
+ bool _led_left;
+ bool _distinct_led_click;
+ bool _hovering;
+ bool _focused;
+ int _fixed_colors_set;
+ bool _fallthrough_to_parent;
+ int _layout_ellipsize_width;
+ Pango::EllipsizeMode _ellipsis;
+ bool _update_colors;
+ int _pattern_height;
+
+ void setup_led_rect ();
+ void set_colors ();
+ void color_handler ();
+ void build_patterns ();
+ void ensure_layout ();
+
+ void action_toggled ();
+ void action_sensitivity_changed ();
+ void action_visibility_changed ();
+ void action_tooltip_changed ();
+};
+
+} /* end namespace */
+
+#endif
--- /dev/null
+/*
+ Copyright (C) 2014 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 _WIDGETS_ARDOUR_DISPLAY_H_
+#define _WIDGETS_ARDOUR_DISPLAY_H_
+
+#include <list>
+#include <stdint.h>
+
+#include <gtkmm/action.h>
+#include <gtkmm/menu.h>
+#include <gtkmm/menuitem.h>
+
+#include "widgets/ardour_dropdown.h"
+#include "widgets/visibility.h"
+
+namespace ArdourWidgets {
+
+class LIBWIDGETS_API ArdourDisplay : public ArdourWidgets::ArdourDropdown
+{
+public:
+
+ ArdourDisplay (Element e = default_elements);
+ virtual ~ArdourDisplay ();
+
+ boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
+ void set_controllable (boost::shared_ptr<PBD::Controllable> c);
+
+ bool on_scroll_event (GdkEventScroll* ev);
+
+ void add_controllable_preset (const char*, float);
+ void handle_controllable_preset (float p);
+
+ void controllable_changed ();
+ PBD::ScopedConnection watch_connection;
+};
+
+} /* end namespace */
+
+#endif /* __gtk2_ardour_ardour_menu_h__ */
--- /dev/null
+/*
+ Copyright (C) 2014 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 _WIDGETS_ARDOUR_DROPDOWN_H_
+#define _WIDGETS_ARDOUR_DROPDOWN_H_
+
+#include <list>
+#include <stdint.h>
+
+#include <gtkmm/action.h>
+#include <gtkmm/menu.h>
+#include <gtkmm/menuitem.h>
+
+#include "widgets/ardour_button.h"
+#include "widgets/visibility.h"
+
+namespace ArdourWidgets {
+
+class LIBWIDGETS_API ArdourDropdown : public ArdourButton
+{
+public:
+
+ ArdourDropdown (Element e = default_elements);
+ virtual ~ArdourDropdown ();
+
+ bool on_button_press_event (GdkEventButton*);
+ bool on_scroll_event (GdkEventScroll*);
+ void menu_size_request(Gtk::Requisition*);
+
+ void clear_items ();
+ void AddMenuElem (Gtk::Menu_Helpers::Element e);
+
+ void disable_scrolling();
+
+ Gtk::Menu_Helpers::MenuList& items () { return _menu.items (); }
+
+private:
+ Gtk::Menu _menu;
+
+ bool _scrolling_disabled;
+};
+
+} /* end namespace */
+
+#endif
--- /dev/null
+/*
+ Copyright (C) 2014 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_ardour_knob_h__
+#define __gtk2_ardour_ardour_knob_h__
+
+#include <list>
+#include <stdint.h>
+
+#include <gtkmm/action.h>
+
+#include "pbd/signals.h"
+
+#include "gtkmm2ext/binding_proxy.h"
+#include "gtkmm2ext/activatable.h"
+#include "gtkmm2ext/cairo_widget.h"
+#include "gtkmm2ext/persistent_tooltip.h"
+
+#include "widgets/visibility.h"
+
+namespace ArdourWidgets {
+
+class LIBWIDGETS_API KnobPersistentTooltip : public Gtkmm2ext::PersistentTooltip
+{
+public:
+ KnobPersistentTooltip (Gtk::Widget* w);
+
+ void start_drag ();
+ void stop_drag ();
+ bool dragging () const;
+
+private:
+ bool _dragging;
+};
+
+
+class LIBWIDGETS_API ArdourKnob : public CairoWidget , public Gtkmm2ext::Activatable
+{
+public:
+
+ enum Element {
+ Arc = 0x1,
+ Bevel = 0x2,
+ unused2 = 0x4,
+ unused3 = 0x8,
+ unused4 = 0x10,
+ unused5 = 0x20,
+ };
+
+ enum Flags {
+ NoFlags = 0,
+ Detent = 0x1,
+ ArcToZero = 0x2,
+ };
+
+ ArdourKnob (Element e = default_elements, Flags flags = NoFlags);
+ virtual ~ArdourKnob ();
+
+ void set_active_state (Gtkmm2ext::ActiveState);
+ void set_visual_state (Gtkmm2ext::VisualState);
+
+ Element elements() const { return _elements; }
+ void set_elements (Element);
+ void add_elements (Element);
+ static Element default_elements;
+
+ void set_tooltip_prefix (std::string pfx) { _tooltip_prefix = pfx; controllable_changed (true); }
+
+ boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
+ void set_controllable (boost::shared_ptr<PBD::Controllable> c);
+
+ bool on_button_press_event (GdkEventButton*);
+ bool on_button_release_event (GdkEventButton*);
+ bool on_scroll_event (GdkEventScroll* ev);
+ bool on_motion_notify_event (GdkEventMotion *ev) ;
+
+ void color_handler ();
+
+ protected:
+ void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
+ void on_size_request (Gtk::Requisition* req);
+ void on_size_allocate (Gtk::Allocation&);
+ void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
+ void on_name_changed ();
+ bool on_enter_notify_event (GdkEventCrossing*);
+ bool on_leave_notify_event (GdkEventCrossing*);
+ bool on_focus_in_event (GdkEventFocus*);
+ bool on_focus_out_event (GdkEventFocus*);
+
+ void controllable_changed (bool force_update = false);
+ PBD::ScopedConnection watch_connection;
+
+
+ private:
+ Element _elements;
+ BindingProxy binding_proxy;
+
+ bool _hovering;
+ float _grabbed_x;
+ float _grabbed_y;
+
+ float _val; // current value [0..1]
+ float _normal; // default value, arc
+ float _dead_zone_delta;
+
+ Flags _flags;
+
+ void action_sensitivity_changed ();
+ void action_visibility_changed ();
+ void action_tooltip_changed ();
+
+ std::string _tooltip_prefix;
+ KnobPersistentTooltip _tooltip;
+};
+
+} /* namespace */
+
+#endif /* __gtk2_ardour_ardour_knob_h__ */
--- /dev/null
+/*
+ * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _WIDGETS_ARDOUR_SPACER_H_
+#define _WIDGETS_ARDOUR_SPACER_H_
+
+#include "gtkmm2ext/cairo_widget.h"
+
+#include "widgets/visibility.h"
+
+namespace ArdourWidgets {
+
+class LIBWIDGETS_API ArdourVSpacer : public CairoWidget
+{
+public:
+ ArdourVSpacer (float r = 0.75f);
+
+protected:
+ void render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t* r) {
+ float h = r->height * ratio;
+ float t = .5f * (r->height - h);
+ ctx->rectangle (0, t, 1, h);
+ ctx->set_source_rgb (0, 0, 0);
+ ctx->fill ();
+ }
+
+ void on_size_request (Gtk::Requisition* req) {
+ req->width = 1;
+ req->height = 0;
+ CairoWidget::on_size_request (req);
+ }
+
+ float ratio;
+};
+
+} /* end namespace */
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2011 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _WIDGETS_ARDOUR_SPINNER_H_
+#define _WIDGETS_ARDOUR_SPINNER_H_
+
+#include <boost/algorithm/string.hpp>
+#include <gtkmm.h>
+
+#include "pbd/controllable.h"
+
+#include "widgets/ardour_button.h"
+#include "widgets/visibility.h"
+
+namespace ArdourWidgets {
+
+class LIBWIDGETS_API ArdourSpinner : public Gtk::Alignment
+{
+ public:
+ ArdourSpinner (boost::shared_ptr<PBD::Controllable>, Gtk::Adjustment* adj);
+
+ virtual ~ArdourSpinner ();
+
+ protected:
+ bool on_button_press_event (GdkEventButton*);
+ bool on_button_release_event (GdkEventButton*);
+ bool on_scroll_event (GdkEventScroll* ev);
+
+ void controllable_changed ();
+ PBD::ScopedConnection watch_connection;
+
+ private:
+
+ bool entry_focus_out (GdkEventFocus*);
+ void entry_activated ();
+ gint switch_to_button ();
+ gint switch_to_spinner ();
+
+ void ctrl_adjusted();
+ void spin_adjusted();
+
+ ArdourWidgets::ArdourButton _btn;
+ Gtk::Adjustment* _ctrl_adj;
+ Gtk::Adjustment _spin_adj;
+ Gtk::SpinButton _spinner;
+ bool _switching;
+ bool _switch_on_release;
+ bool _ctrl_ignore;
+ bool _spin_ignore;
+
+ boost::shared_ptr<PBD::Controllable> _controllable;
+
+};
+
+} /* end namespace */
+
+#endif
--- /dev/null
+/*
+ Copyright (C) 2014 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 _WIDGETS_TOOLTIPS_H_
+#define _WIDGETS_TOOLTIPS_H_
+
+#include <string>
+
+namespace Gtk {
+ class Widget;
+}
+
+#include "widgets/visibility.h"
+
+namespace ArdourWidgets {
+
+extern LIBWIDGETS_API void set_tooltip (Gtk::Widget& w, const std::string& text);
+
+extern LIBWIDGETS_API void set_tooltip (Gtk::Widget* w, const std::string& text);
+
+extern LIBWIDGETS_API void set_tooltip (Gtk::Widget* w, const std::string& text, const std::string& help_text);
+
+}
+
+#endif
--- /dev/null
+#ifndef _WIDGETS_UI_BASE_H_
+#define _WIDGETS_UI_BASE_H_
+
+#include <cassert>
+
+#include "pbd/stateful.h"
+#include "canvas/colors.h"
+
+#include "widgets/visibility.h"
+
+namespace ArdourWidgets {
+
+class LIBWIDGETS_API UIConfigurationBase : public PBD::Stateful
+{
+protected:
+ virtual ~UIConfigurationBase() { _instance = 0; }
+ static UIConfigurationBase* _instance;
+
+public:
+ static UIConfigurationBase& instance() { return *_instance; }
+
+ sigc::signal<void> DPIReset;
+ sigc::signal<void> ColorsChanged;
+
+ virtual float get_ui_scale () = 0;
+ virtual bool get_widget_prelight () const = 0;
+ virtual ArdourCanvas::Color color (const std::string&, bool* failed = 0) const = 0;
+};
+
+}
+#endif
--- /dev/null
+/*
+ Copyright (C) 2013 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 __libwidgets_visibility_h__
+#define __libwidgets_visibility_h__
+
+#if defined(COMPILER_MSVC)
+ #define LIBWIDGETS_DLL_IMPORT __declspec(dllimport)
+ #define LIBWIDGETS_DLL_EXPORT __declspec(dllexport)
+ #define LIBWIDGETS_DLL_LOCAL
+#else
+ #define LIBWIDGETS_DLL_IMPORT __attribute__ ((visibility ("default")))
+ #define LIBWIDGETS_DLL_EXPORT __attribute__ ((visibility ("default")))
+ #define LIBWIDGETS_DLL_LOCAL __attribute__ ((visibility ("hidden")))
+#endif
+
+#ifdef LIBWIDGETS_STATIC // libwidgets is not a DLL
+#define LIBWIDGETS_API
+#define LIBWIDGETS_LOCAL
+#else
+ #ifdef LIBWIDGETS_DLL_EXPORTS // defined if we are building the libwidgets DLL (instead of using it)
+ #define LIBWIDGETS_API LIBWIDGETS_DLL_EXPORT
+ #else
+ #define LIBWIDGETS_API LIBWIDGETS_DLL_IMPORT
+ #endif
+ #define LIBWIDGETS_LOCAL LIBWIDGETS_DLL_LOCAL
+#endif
+
+#endif /* __libwidgets_visibility_h__ */
--- /dev/null
+#!/usr/bin/env python
+from waflib.extras import autowaf as autowaf
+from waflib import Options
+from waflib import TaskGen
+import os
+
+# Version of this package (even if built as a child)
+MAJOR = '0'
+MINOR = '0'
+MICRO = '0'
+WIDGETS_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
+
+# Library version (UNIX style major, minor, micro)
+# major increment <=> incompatible changes
+# minor increment <=> compatible changes (additions)
+# micro increment <=> no interface changes
+WIDGETS_LIB_VERSION = '0.0.0'
+
+# Variables for 'waf dist'
+APPNAME = 'widgets'
+VERSION = WIDGETS_VERSION
+I18N_PACKAGE = 'libwidgets'
+
+# Mandatory variables
+top = '.'
+out = 'build'
+
+widgets_sources = [
+ 'ardour_button.cc',
+ 'ardour_display.cc',
+ 'ardour_dropdown.cc',
+ 'ardour_knob.cc',
+ 'ardour_spacer.cc',
+ 'ardour_spinner.cc',
+ 'tooltips.cc',
+ 'ui_config.cc',
+]
+
+def options(opt):
+ autowaf.set_options(opt)
+
+def configure(conf):
+ conf.load ('compiler_cxx')
+ autowaf.configure(conf)
+ autowaf.check_pkg(conf, 'cairomm-1.0', uselib_store='CAIROMM', atleast_version='1.8.4')
+
+def build(bld):
+ # Library
+ if bld.is_defined ('INTERNAL_SHARED_LIBS'):
+ obj = bld.shlib(features = 'cxx cxxshlib', source=widgets_sources)
+ obj.defines = [ 'LIBWIDGETS_DLL_EXPORTS=1' ]
+ else:
+ obj = bld.stlib(features = 'cxx cxxstlib', source=widgets_sources)
+ obj.cxxflags = [ '-fPIC' ]
+ obj.cflags = [ '-fPIC' ]
+ obj.defines = [ ]
+
+ obj.export_includes = ['.']
+ obj.includes = ['.']
+ obj.uselib = 'SIGCPP CAIROMM GTKMM BOOST XML'
+ obj.use = [ 'libpbd', 'libcanvas', 'libgtkmm2ext' ]
+ obj.name = 'libwidgets'
+ obj.target = 'widgets'
+ obj.vnum = WIDGETS_LIB_VERSION
+ obj.install_path = bld.env['LIBDIR']
+ obj.defines += [ 'PACKAGE="' + I18N_PACKAGE + '"' ]
+
+def shutdown():
+ autowaf.shutdown()
+
'libs/gtkmm2ext',
'libs/audiographer',
'libs/canvas',
+ 'libs/widgets',
'libs/plugins/reasonablesynth.lv2',
'libs/plugins/a-comp.lv2',
'libs/plugins/a-delay.lv2',