summaryrefslogtreecommitdiff
path: root/libs/widgets
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-07-17 18:34:35 +0200
committerRobin Gareus <robin@gareus.org>2017-07-17 21:06:04 +0200
commit601c317d70a03190257577bd867cefc2c70d3275 (patch)
tree077071290f084431a912414c4e87b6127c586677 /libs/widgets
parent1f5ebc54853446a786925941bd014666e75221d2 (diff)
Clean up library inheritance (colors.h, utils.h)
make libwidget independent of libcanvas. Confine basics to pbd and gtkmm2ext.
Diffstat (limited to 'libs/widgets')
-rw-r--r--libs/widgets/ardour_button.cc28
-rw-r--r--libs/widgets/ardour_dropdown.cc2
-rw-r--r--libs/widgets/ardour_icon.cc52
-rw-r--r--libs/widgets/ardour_knob.cc27
-rw-r--r--libs/widgets/widgets/ui_config.h4
-rw-r--r--libs/widgets/wscript2
6 files changed, 47 insertions, 68 deletions
diff --git a/libs/widgets/ardour_button.cc b/libs/widgets/ardour_button.cc
index 8c16bcdca1..9687427608 100644
--- a/libs/widgets/ardour_button.cc
+++ b/libs/widgets/ardour_button.cc
@@ -29,12 +29,10 @@
#include "pbd/error.h"
#include "pbd/stacktrace.h"
-#include "gtkmm2ext/utils.h"
-#include "gtkmm2ext/rgb_macros.h"
+#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/gui_thread.h"
-
-#include "canvas/utils.h"
-#include "canvas/colors.h"
+#include "gtkmm2ext/rgb_macros.h"
+#include "gtkmm2ext/utils.h"
#include "widgets/ardour_button.h"
#include "widgets/tooltips.h"
@@ -314,15 +312,15 @@ ArdourButton::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
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);
+ Gtkmm2ext::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);
+ Gtkmm2ext::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);
+ Gtkmm2ext::set_source_rgba (cr, fill_inactive_color);
}
cairo_fill (cr);
}
@@ -332,7 +330,7 @@ ArdourButton::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
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);
+ Gtkmm2ext::set_source_rgba (cr, fill_active_color);
cairo_stroke (cr);
}
}
@@ -418,7 +416,7 @@ ArdourButton::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
cairo_clip(cr);
cairo_new_path (cr);
- ArdourCanvas::set_source_rgba (cr, text_color);
+ Gtkmm2ext::set_source_rgba (cr, text_color);
const double text_ypos = (get_height() - _text_height) * .5;
if (_elements & Menu) {
@@ -520,7 +518,7 @@ ArdourButton::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
cairo_fill(cr);
//led color
- ArdourCanvas::set_source_rgba (cr, led_color);
+ Gtkmm2ext::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);
@@ -531,7 +529,7 @@ ArdourButton::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_
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);
+ Gtkmm2ext::set_source_rgb_a (cr, ins_color, 0.6);
cairo_fill (cr);
}
@@ -736,8 +734,8 @@ ArdourButton::set_colors ()
}
}
- text_active_color = ArdourCanvas::contrasting_text_color (fill_active_color);
- text_inactive_color = ArdourCanvas::contrasting_text_color (fill_inactive_color);
+ text_active_color = Gtkmm2ext::contrasting_text_color (fill_active_color);
+ text_inactive_color = Gtkmm2ext::contrasting_text_color (fill_inactive_color);
led_active_color = UIConfigurationBase::instance().color (string_compose ("%1: led active", name), &failed);
if (failed) {
@@ -748,7 +746,7 @@ ArdourButton::set_colors ()
* active color.
*/
- ArdourCanvas::HSV inactive (led_active_color);
+ Gtkmm2ext::HSV inactive (led_active_color);
inactive.v = 0.35;
led_inactive_color = inactive.color ();
diff --git a/libs/widgets/ardour_dropdown.cc b/libs/widgets/ardour_dropdown.cc
index 24c8d030a0..6be0ab84d6 100644
--- a/libs/widgets/ardour_dropdown.cc
+++ b/libs/widgets/ardour_dropdown.cc
@@ -31,8 +31,6 @@
#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"
diff --git a/libs/widgets/ardour_icon.cc b/libs/widgets/ardour_icon.cc
index f111e8919c..b05ed63bcb 100644
--- a/libs/widgets/ardour_icon.cc
+++ b/libs/widgets/ardour_icon.cc
@@ -22,6 +22,7 @@
#include <assert.h>
#include <algorithm> // std:min
+#include "gtkmm2ext/colors.h"
#include "widgets/ardour_icon.h"
using namespace ArdourWidgets::ArdourIcon;
@@ -37,35 +38,22 @@ using namespace ArdourWidgets::ArdourIcon;
#define OUTLINEWIDTH 1.5 // px
-#define VECTORICONSTROKEFILL(fillalpha) \
- cairo_set_line_width (cr, OUTLINEWIDTH); \
- cairo_set_source_rgba (cr, 0, 0, 0, 1.0); \
- cairo_stroke_preserve (cr); \
- cairo_set_source_rgba (cr, 1, 1, 1, (fillalpha)); \
- cairo_fill (cr);
-
-#define VECTORICONSTROKEOUTLINE(LW, color) \
- cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); \
- cairo_set_line_width (cr, (LW) + OUTLINEWIDTH); \
- ardour_icon_set_source_inv_rgba (cr, color); \
- cairo_stroke_preserve (cr); \
- ardour_icon_set_source_rgba (cr, color); \
- cairo_set_line_width (cr, (LW)); \
- cairo_stroke (cr);
+#define VECTORICONSTROKEFILL(fillalpha) \
+ cairo_set_line_width (cr, OUTLINEWIDTH); \
+ cairo_set_source_rgba (cr, 0, 0, 0, 1.0); \
+ cairo_stroke_preserve (cr); \
+ cairo_set_source_rgba (cr, 1, 1, 1, (fillalpha)); \
+ cairo_fill (cr);
+#define VECTORICONSTROKEOUTLINE(LW, color) \
+ cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); \
+ cairo_set_line_width (cr, (LW) + OUTLINEWIDTH); \
+ ardour_icon_set_source_inv_rgba (cr, color); \
+ cairo_stroke_preserve (cr); \
+ Gtkmm2ext::set_source_rgba (cr, color); \
+ cairo_set_line_width (cr, (LW)); \
+ cairo_stroke (cr);
-/** convert 32bit 'RRGGBBAA' to cairo doubles
- * from libs/canvas/utils.cc and canvas/types.h: typedef uint32_t Color;
- */
-static void ardour_icon_set_source_rgba (cairo_t *cr, uint32_t color)
-{
- cairo_set_source_rgba (cr,
- ((color >> 24) & 0xff) / 255.0,
- ((color >> 16) & 0xff) / 255.0,
- ((color >> 8) & 0xff) / 255.0,
- ((color >> 0) & 0xff) / 255.0
- );
-}
/** inverse color */
static void ardour_icon_set_source_inv_rgba (cairo_t *cr, uint32_t color)
@@ -127,7 +115,7 @@ static void icon_tool_content (cairo_t *cr, const int width, const int height) {
cairo_move_to (cr, EM_POINT( 5.0, -5.0));
cairo_close_path (cr);
- ardour_icon_set_source_rgba (cr, 0xffffffff);
+ Gtkmm2ext::set_source_rgba (cr, 0xffffffff);
cairo_set_line_width (cr, 3 * em);
cairo_stroke (cr);
#undef EM_POINT
@@ -800,7 +788,7 @@ static void icon_zoom (cairo_t *cr, const enum ArdourWidgets::ArdourIcon::Icon i
#undef LINE45DEG
// lens
- ardour_icon_set_source_rgba (cr, fg_color);
+ Gtkmm2ext::set_source_rgba (cr, fg_color);
cairo_arc (cr, x, y, r, 0, 2 * M_PI);
cairo_fill_preserve (cr);
@@ -899,7 +887,7 @@ static void icon_close_cross (cairo_t *cr, const int width, const int height, co
const double x = width * .5;
const double y = height * .5;
const double o = .5 + std::min (x, y) * .4;
- ardour_icon_set_source_rgba (cr, fg_color);
+ Gtkmm2ext::set_source_rgba (cr, fg_color);
cairo_set_line_width (cr, 1.0);
cairo_move_to (cr, x-o, y-o);
cairo_line_to (cr, x+o, y+o);
@@ -959,7 +947,7 @@ static void icon_strip_width (cairo_t *cr, const int width, const int height, co
const double ya0= height * .35;
const double ya1= height * .65;
- ardour_icon_set_source_rgba (cr, fg_color);
+ Gtkmm2ext::set_source_rgba (cr, fg_color);
cairo_set_line_width (cr, 1);
// left + right
@@ -992,7 +980,7 @@ static void icon_din_midi (cairo_t *cr, const int width, const int height, const
const double x = width * .5;
const double y = height * .5;
const double r = std::min (x, y) * .75;
- ardour_icon_set_source_rgba (cr, fg_color);
+ Gtkmm2ext::set_source_rgba (cr, fg_color);
cairo_set_line_width (cr, 1);
cairo_arc (cr, x, y, r, .57 * M_PI, 2.43 * M_PI);
cairo_stroke (cr);
diff --git a/libs/widgets/ardour_knob.cc b/libs/widgets/ardour_knob.cc
index 6948a88993..40adeb7d90 100644
--- a/libs/widgets/ardour_knob.cc
+++ b/libs/widgets/ardour_knob.cc
@@ -28,19 +28,14 @@
#include "pbd/error.h"
#include "pbd/stacktrace.h"
-#include "gtkmm2ext/utils.h"
-#include "gtkmm2ext/rgb_macros.h"
+#include "gtkmm2ext/colors.h"
#include "gtkmm2ext/gui_thread.h"
#include "gtkmm2ext/keyboard.h"
-
-#include "pbd/controllable.h"
+#include "gtkmm2ext/rgb_macros.h"
+#include "gtkmm2ext/utils.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"
@@ -109,7 +104,7 @@ ArdourKnob::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*
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()));
+ Gtkmm2ext::Color knob_color = UIConfigurationBase::instance().color (string_compose ("%1", get_name()));
float center_radius = 0.48*scale;
float border_width = 0.8;
@@ -134,11 +129,11 @@ ArdourKnob::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*
//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 );
+ Gtkmm2ext::Color arc_start_color = UIConfigurationBase::instance().color ( string_compose ("%1: arc start", get_name()));
+ Gtkmm2ext::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 );
+ Gtkmm2ext::Color arc_end_color = UIConfigurationBase::instance().color ( string_compose ("%1: arc end", get_name()) );
+ Gtkmm2ext::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));
@@ -198,7 +193,7 @@ ArdourKnob::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*
cairo_restore(cr);
//inner circle
- ArdourCanvas::set_source_rgba(cr, knob_color);
+ Gtkmm2ext::set_source_rgba(cr, knob_color);
cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
cairo_fill (cr);
@@ -216,7 +211,7 @@ ArdourKnob::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*
cairo_pattern_destroy (shade_pattern);
//flat top over beveled edge
- ArdourCanvas::set_source_rgb_a (cr, knob_color, 0.5 );
+ Gtkmm2ext::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 {
@@ -232,7 +227,7 @@ ArdourKnob::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*
} else {
//inner circle
- ArdourCanvas::set_source_rgba(cr, knob_color);
+ Gtkmm2ext::set_source_rgba(cr, knob_color);
cairo_arc (cr, 0, 0, center_radius, 0, 2.0*G_PI);
cairo_fill (cr);
}
diff --git a/libs/widgets/widgets/ui_config.h b/libs/widgets/widgets/ui_config.h
index 4087dae192..1270816985 100644
--- a/libs/widgets/widgets/ui_config.h
+++ b/libs/widgets/widgets/ui_config.h
@@ -4,7 +4,7 @@
#include <cassert>
#include "pbd/stateful.h"
-#include "canvas/colors.h"
+#include "gtkmm2ext/colors.h"
#include "widgets/visibility.h"
@@ -24,7 +24,7 @@ public:
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;
+ virtual Gtkmm2ext::Color color (const std::string&, bool* failed = 0) const = 0;
};
}
diff --git a/libs/widgets/wscript b/libs/widgets/wscript
index cf274e418c..0559abe4dc 100644
--- a/libs/widgets/wscript
+++ b/libs/widgets/wscript
@@ -78,7 +78,7 @@ def build(bld):
obj.export_includes = ['.']
obj.includes = ['.']
obj.uselib = 'SIGCPP CAIROMM GTKMM BOOST XML'
- obj.use = [ 'libpbd', 'libcanvas', 'libgtkmm2ext' ]
+ obj.use = [ 'libpbd', 'libgtkmm2ext' ]
obj.name = 'libwidgets'
obj.target = 'widgets'
obj.vnum = WIDGETS_LIB_VERSION