13
0

ardourfader: beginning of per-fader color

This commit is contained in:
Paul Davis 2022-08-10 18:15:39 -06:00
parent e0d33bb726
commit 9459ca5583
2 changed files with 25 additions and 4 deletions

View File

@ -58,6 +58,8 @@ ArdourFader::ArdourFader (Gtk::Adjustment& adj, int orientation, int fader_lengt
, _dragging (false)
, _centered_text (true)
, _current_parent (0)
, have_explicit_bg (false)
, have_explicit_fg (false)
{
_default_value = _adjustment.get_value();
update_unity_position ();
@ -206,6 +208,18 @@ ArdourFader::create_patterns ()
cairo_surface_destroy (surface);
}
Gdk::Color
ArdourFader::bg_color (Gtk::StateType s)
{
return get_style()->get_bg (s);
}
Gdk::Color
ArdourFader::fg_color (Gtk::StateType s)
{
return get_style()->get_fg (s);
}
void
ArdourFader::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t* area)
{
@ -258,9 +272,9 @@ ArdourFader::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t
cairo_matrix_init_translate (&matrix, 0, (h - ds));
cairo_pattern_set_matrix (_pattern, &matrix);
} else {
CairoWidget::set_source_rgb_a (cr, get_style()->get_bg (get_state()), 1);
CairoWidget::set_source_rgb_a (cr, bg_color (get_state()), 1);
cairo_fill (cr);
CairoWidget::set_source_rgb_a (cr, get_style()->get_fg (get_state()), 1);
CairoWidget::set_source_rgb_a (cr, fg_color (get_state()), 1);
Gtkmm2ext::rounded_rectangle (cr, CORNER_OFFSET, ds + CORNER_OFFSET,
w - CORNER_SIZE, h - ds - CORNER_SIZE, CORNER_RADIUS);
}
@ -288,9 +302,9 @@ ArdourFader::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t
cairo_matrix_init_translate (&matrix, w - ds, 0);
cairo_pattern_set_matrix (_pattern, &matrix);
} else {
CairoWidget::set_source_rgb_a (cr, get_style()->get_bg (get_state()), 1);
CairoWidget::set_source_rgb_a (cr, bg_color (get_state()), 1);
cairo_fill (cr);
CairoWidget::set_source_rgb_a (cr, get_style()->get_fg (get_state()), 1);
CairoWidget::set_source_rgb_a (cr, fg_color (get_state()), 1);
Gtkmm2ext::rounded_rectangle (cr, CORNER_OFFSET, CORNER_OFFSET,
ds - CORNER_SIZE, h - CORNER_SIZE, CORNER_RADIUS);
}

View File

@ -27,6 +27,7 @@
#include <gtkmm/adjustment.h>
#include "gtkmm2ext/cairo_widget.h"
#include "gtkmm2ext/colors.h"
#include "widgets/visibility.h"
namespace ArdourWidgets {
@ -99,12 +100,18 @@ private:
sigc::connection _parent_style_change;
Widget * _current_parent;
Gdk::Color get_parent_bg ();
Gtkmm2ext::Color _explicit_bg;
bool have_explicit_bg;
Gtkmm2ext::Color _explicit_fg;
bool have_explicit_fg;
void create_patterns();
void adjustment_changed ();
void set_adjustment_from_event (GdkEventButton *);
void update_unity_position ();
int display_span ();
Gdk::Color bg_color (Gtk::StateType);
Gdk::Color fg_color (Gtk::StateType);
struct FaderImage {
cairo_pattern_t* pattern;