13
0

prolooks helper code from hans, enabling new knob drawing based on Thorsten Wilm's lovely knob/dial design. To Be Tweaked

git-svn-id: svn://localhost/ardour2/branches/3.0@7074 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-05-06 21:02:08 +00:00
parent b0a59ba6da
commit 29da90651e
9 changed files with 1879 additions and 123 deletions

View File

@ -370,12 +370,6 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou
protected:
friend class Session;
void set_graph_level (int32_t);
int32_t graph_level() const { return _graph_level; }
void check_physical_connections ();
// this functions may ONLY be called during a route resort
bool physically_connected () const { return _physically_connected; }
void catch_up_on_solo_mute_override ();
void mod_solo_by_others_upstream (int32_t);
void mod_solo_by_others_downstream (int32_t);
@ -433,8 +427,6 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou
std::string _comment;
bool _have_internal_generator;
bool _physically_connected; // valid ONLY during a route resort
int32_t _graph_level;
bool _solo_safe;
DataType _default_type;
FedBy _fed_by;

View File

@ -415,16 +415,12 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
void remove_route (boost::shared_ptr<Route>);
void resort_routes ();
void resort_routes_using (boost::shared_ptr<RouteList>);
void find_route_levels (boost::shared_ptr<RouteList>);
void set_remote_control_ids();
AudioEngine & engine() { return _engine; }
AudioEngine const & engine () const { return _engine; }
int32_t max_level;
int32_t min_level;
/* Time */
nframes64_t transport_frame () const {return _transport_frame; }

View File

@ -92,8 +92,6 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type)
, _mute_master (new MuteMaster (sess, name))
, _mute_points (MuteMaster::AllPoints)
, _have_internal_generator (false)
, _physically_connected (false)
, _graph_level (-1)
, _solo_safe (false)
, _default_type (default_type)
, _remote_control_id (0)
@ -2584,12 +2582,6 @@ Route::direct_feeds (boost::shared_ptr<Route> other, bool* only_send)
return false;
}
void
Route::check_physical_connections ()
{
_physically_connected = _output->physically_connected ();
}
void
Route::handle_transport_stopped (bool /*abort_ignored*/, bool did_locate, bool can_flush_processors)
{
@ -3361,8 +3353,3 @@ Route::has_io_processor_named (const string& name)
return false;
}
void
Route::set_graph_level (int32_t l)
{
_graph_level = l;
}

View File

@ -1353,10 +1353,6 @@ Session::resort_routes_using (shared_ptr<RouteList> r)
{
RouteList::iterator i, j;
for (i = r->begin(); i != r->end(); ++i) {
(*i)->check_physical_connections ();
}
for (i = r->begin(); i != r->end(); ++i) {
(*i)->clear_fed_by ();
@ -1388,102 +1384,16 @@ Session::resort_routes_using (shared_ptr<RouteList> r)
RouteSorter cmp;
r->sort (cmp);
find_route_levels (r);
#ifndef NDEBUG
DEBUG_TRACE (DEBUG::Graph, "Routes resorted, order follows:\n");
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
DEBUG_TRACE (DEBUG::Graph, string_compose ("\t%1 signal order %2 level %3\n",
(*i)->name(), (*i)->order_key ("signal"),
(*i)->graph_level()));
DEBUG_TRACE (DEBUG::Graph, string_compose ("\t%1 signal order %2\n",
(*i)->name(), (*i)->order_key ("signal")));
}
#endif
}
void
Session::find_route_levels (shared_ptr<RouteList> rl)
{
uint32_t setcnt = 0;
uint32_t limit = rl->size();
RouteList last_level;
RouteList this_level;
for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
/* find routes with direct physical connections,
or routes with no connections at all. Mark them
with "special" level values, and push them into
the "last_level" set.
All other routes get marked with a graph level
of -1, which indicates that it needs to be set.
*/
if ((*r)->physically_connected()) {
last_level.push_back (*r);
(*r)->set_graph_level (0);
setcnt++;
} else if (!(*r)->output()->connected()) {
last_level.push_back (*r);
(*r)->set_graph_level (INT32_MAX/2);
setcnt++;
} else {
(*r)->set_graph_level (-1);
}
}
// until we've set the graph level for every route ...
while (setcnt < limit) {
for (RouteList::reverse_iterator r = rl->rbegin(); r != rl->rend(); ++r) {
int32_t l = INT32_MAX;
bool found = false;
if ((*r)->graph_level() != -1) {
// we already have the graph level for this route
continue;
}
/* check if this route (r) has a direction connection to anything in
the set of routes we processed last time. On the first pass
through this, last_level will contain routes with either
no connections or direct "physical" connections. If there is
at least 1 connection, store the lowest graph level of whatever
r is connected to.
*/
for (RouteList::iterator o = last_level.begin(); o != last_level.end(); ++o) {
bool sends_only;
if ((*r)->direct_feeds (*o, &sends_only)) {
if (!sends_only) {
l = min (l, (*o)->graph_level());
found = true;
}
}
}
/* if we found any connections, then mark the graph level of r, and push
it into the "this_level" set that will become "last_level" next time
around the while() loop.
*/
if (found) {
(*r)->set_graph_level (l + 1);
this_level.push_back (*r);
setcnt++;
}
}
last_level = this_level;
this_level.clear ();
}
}
/** Find the route name starting with \a base with the lowest \a id.
*
* Names are constructed like e.g. "Audio 3" for base="Audio" and id=3.

View File

@ -25,6 +25,7 @@
#include <gtkmm/eventbox.h>
#include "gtkmm2ext/binding_proxy.h"
#include "gtkmm2ext/prolooks-helpers.h"
namespace Gtk {
class Adjustment;
@ -62,6 +63,7 @@ class MotionFeedback : public Gtk::VBox
gfloat range () { return _range; }
void set_controllable (boost::shared_ptr<PBD::Controllable> c) { binding_proxy.set_controllable (c); }
void set_lamp_color (const Gdk::Color&);
protected:
gfloat _range;
@ -100,6 +102,11 @@ class MotionFeedback : public Gtk::VBox
int subwidth;
int subheight;
void adjustment_changed ();
ProlooksHSV* lamp_hsv;
Gdk::Color _lamp_color;
void core_draw (cairo_t*, int, double, double, double);
};
} /* namespace */

View File

@ -0,0 +1,257 @@
/* Helpers.c generated by valac, the Vala compiler */
/*
Copyright 2009 by Hans Baier
License: LGPLv2+
*/
#ifndef __prolooks_helpers_h__
#define __prolooks_helpers_h__
#include <glib.h>
#include <glib-object.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#include <gdk/gdk.h>
#include <gdk-pixbuf/gdk-pixdata.h>
#include <gobject/gvaluecollector.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CAIRO_TYPE_COLOR (cairo_color_get_type ())
#define CAIRO_COLOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAIRO_TYPE_COLOR, CairoColor))
#define CAIRO_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAIRO_TYPE_COLOR, CairoColorClass))
#define CAIRO_IS_COLOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAIRO_TYPE_COLOR))
#define CAIRO_IS_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAIRO_TYPE_COLOR))
#define CAIRO_COLOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CAIRO_TYPE_COLOR, CairoColorClass))
typedef struct _CairoColor CairoColor;
typedef struct _CairoColorClass CairoColorClass;
typedef struct _CairoColorPrivate CairoColorPrivate;
#define PROLOOKS_TYPE_HSL (prolooks_hsl_get_type ())
#define PROLOOKS_HSL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROLOOKS_TYPE_HSL, ProlooksHSL))
#define PROLOOKS_HSL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROLOOKS_TYPE_HSL, ProlooksHSLClass))
#define PROLOOKS_IS_HSL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROLOOKS_TYPE_HSL))
#define PROLOOKS_IS_HSL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROLOOKS_TYPE_HSL))
#define PROLOOKS_HSL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROLOOKS_TYPE_HSL, ProlooksHSLClass))
typedef struct _ProlooksHSL ProlooksHSL;
typedef struct _ProlooksHSLClass ProlooksHSLClass;
#define _prolooks_hsl_unref0(var) ((var == NULL) ? NULL : (var = (prolooks_hsl_unref (var), NULL)))
#define _cairo_color_unref0(var) ((var == NULL) ? NULL : (var = (cairo_color_unref (var), NULL)))
typedef struct _CairoParamSpecColor CairoParamSpecColor;
#define PROLOOKS_TYPE_BUTTON_STATE (prolooks_button_state_get_type ())
#define PROLOOKS_TYPE_BUTTON_TYPE (prolooks_button_type_get_type ())
#define _cairo_pattern_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_pattern_destroy (var), NULL)))
typedef struct _ProlooksHSLPrivate ProlooksHSLPrivate;
typedef struct _ProlooksParamSpecHSL ProlooksParamSpecHSL;
#define PROLOOKS_TYPE_HSV (prolooks_hsv_get_type ())
#define PROLOOKS_HSV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROLOOKS_TYPE_HSV, ProlooksHSV))
#define PROLOOKS_HSV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROLOOKS_TYPE_HSV, ProlooksHSVClass))
#define PROLOOKS_IS_HSV(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROLOOKS_TYPE_HSV))
#define PROLOOKS_IS_HSV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROLOOKS_TYPE_HSV))
#define PROLOOKS_HSV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROLOOKS_TYPE_HSV, ProlooksHSVClass))
typedef struct _ProlooksHSV ProlooksHSV;
typedef struct _ProlooksHSVClass ProlooksHSVClass;
typedef struct _ProlooksHSVPrivate ProlooksHSVPrivate;
typedef struct _ProlooksParamSpecHSV ProlooksParamSpecHSV;
struct _CairoColor {
GTypeInstance parent_instance;
volatile int ref_count;
CairoColorPrivate * priv;
};
struct _CairoColorClass {
GTypeClass parent_class;
void (*finalize) (CairoColor *self);
};
struct _CairoColorPrivate {
double _red;
double _green;
double _blue;
double _alpha;
};
struct _CairoParamSpecColor {
GParamSpec parent_instance;
};
typedef enum {
PROLOOKS_BUTTON_STATE_NORMAL,
PROLOOKS_BUTTON_STATE_PRESSED
} ProlooksButtonState;
typedef enum {
PROLOOKS_BUTTON_TYPE_PRESS_BUTTON,
PROLOOKS_BUTTON_TYPE_TOGGLE_BUTTON
} ProlooksButtonType;
struct _ProlooksHSL {
GTypeInstance parent_instance;
volatile int ref_count;
ProlooksHSLPrivate * priv;
};
struct _ProlooksHSLClass {
GTypeClass parent_class;
void (*finalize) (ProlooksHSL *self);
};
struct _ProlooksHSLPrivate {
double _hue;
double _saturation;
double _lightness;
};
struct _ProlooksParamSpecHSL {
GParamSpec parent_instance;
};
struct _ProlooksHSV {
GTypeInstance parent_instance;
volatile int ref_count;
ProlooksHSVPrivate * priv;
};
struct _ProlooksHSVClass {
GTypeClass parent_class;
void (*finalize) (ProlooksHSV *self);
};
struct _ProlooksHSVPrivate {
double _hue;
double _saturation;
double _value;
};
struct _ProlooksParamSpecHSV {
GParamSpec parent_instance;
};
static gpointer cairo_color_parent_class = NULL;
static gpointer prolooks_hsl_parent_class = NULL;
static gpointer prolooks_hsv_parent_class = NULL;
gpointer cairo_color_ref (gpointer instance);
void cairo_color_unref (gpointer instance);
GParamSpec* cairo_param_spec_color (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void cairo_value_set_color (GValue* value, gpointer v_object);
void cairo_value_take_color (GValue* value, gpointer v_object);
gpointer cairo_value_get_color (const GValue* value);
GType cairo_color_get_type (void);
#define CAIRO_COLOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CAIRO_TYPE_COLOR, CairoColorPrivate))
enum {
CAIRO_COLOR_DUMMY_PROPERTY
};
void cairo_color_set_red (CairoColor* self, double value);
void cairo_color_set_green (CairoColor* self, double value);
void cairo_color_set_blue (CairoColor* self, double value);
void cairo_color_set_alpha (CairoColor* self, double value);
CairoColor* cairo_color_new (double red, double green, double blue, double alpha);
CairoColor* cairo_color_construct (GType object_type, double red, double green, double blue, double alpha);
double cairo_color_get_red (CairoColor* self);
double cairo_color_get_green (CairoColor* self);
double cairo_color_get_blue (CairoColor* self);
double cairo_color_get_alpha (CairoColor* self);
CairoColor* cairo_color_copy (CairoColor* self);
void cairo_color_set_from_string (CairoColor* self, const char* webcolor);
CairoColor* cairo_color_new_from_string (const char* webcolor);
CairoColor* cairo_color_construct_from_string (GType object_type, const char* webcolor);
ProlooksHSL* prolooks_hsl_new (void);
ProlooksHSL* prolooks_hsl_construct (GType object_type);
gpointer prolooks_hsl_ref (gpointer instance);
void prolooks_hsl_unref (gpointer instance);
GParamSpec* prolooks_param_spec_hsl (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void prolooks_value_set_hsl (GValue* value, gpointer v_object);
void prolooks_value_take_hsl (GValue* value, gpointer v_object);
gpointer prolooks_value_get_hsl (const GValue* value);
GType prolooks_hsl_get_type (void);
void prolooks_hsl_from_cairo_color (ProlooksHSL* self, CairoColor* color);
double prolooks_hsl_get_lightness (ProlooksHSL* self);
void prolooks_hsl_set_lightness (ProlooksHSL* self, double value);
double prolooks_hsl_get_saturation (ProlooksHSL* self);
void prolooks_hsl_set_saturation (ProlooksHSL* self, double value);
CairoColor* prolooks_hsl_to_cairo_color (ProlooksHSL* self);
CairoColor* cairo_color_shade (CairoColor* self, double shade_factor);
void cairo_color_set_to (CairoColor* self, CairoColor* a_color);
void cairo_color_set_as_source_in (CairoColor* self, cairo_t* cr);
void cairo_color_add_color_stop_to (CairoColor* self, cairo_pattern_t* p, double offset);
CairoColor* prolooks_gdk_color_to_cairo (GdkColor* color);
void prolooks_color_from_string (const char* webcolor, GdkColor* result);
static void cairo_color_finalize (CairoColor* obj);
GType prolooks_button_state_get_type (void);
GType prolooks_button_type_get_type (void);
void prolooks_set_line_width_from_device (cairo_t* cr);
char* prolooks_color_to_string (GdkColor* color);
CairoColor* prolooks_cairo_color_from_string (const char* webcolor);
void prolooks_set_source_color (cairo_t* cr, GdkColor* color, double alpha);
void prolooks_gdk_color_to_cairo_color (GdkColor* color, double* red, double* green, double* blue);
void prolooks_cairo_color_to_gdk (CairoColor* cairo_color, GdkColor* result);
void prolooks_set_source_color_string (cairo_t* cr, const char* color, double alpha);
void prolooks_add_color_stop (cairo_pattern_t* p, double offset, GdkColor* color, double alpha);
void prolooks_add_color_stop_str (cairo_pattern_t* p, double offset, const char* color, double alpha);
cairo_pattern_t* prolooks_create_gradient (double x1, double y1, double x2, double y2, GdkColor* start, GdkColor* stop, double alpha_start, double alpha_stop);
cairo_pattern_t* prolooks_create_gradient_str (double x1, double y1, double x2, double y2, const char* start, const char* stop, double alpha_start, double alpha_stop);
void prolooks_rounded_rect (cairo_t* cr, double x, double y, double w, double h, double radius_x, double radius_y);
void prolooks_background_gradient (cairo_t* cr, double w, double h);
double prolooks_modula (double number, double divisor);
#define PROLOOKS_HSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PROLOOKS_TYPE_HSL, ProlooksHSLPrivate))
enum {
PROLOOKS_HSL_DUMMY_PROPERTY
};
double prolooks_hsl_get_hue (ProlooksHSL* self);
char* prolooks_hsl_to_string (ProlooksHSL* self);
void prolooks_hsl_to_gdk_color (ProlooksHSL* self, GdkColor* result);
void prolooks_hsl_from_gdk_color (ProlooksHSL* self, GdkColor* color);
void prolooks_hsl_set_hue (ProlooksHSL* self, double value);
static void prolooks_hsl_finalize (ProlooksHSL* obj);
gpointer prolooks_hsv_ref (gpointer instance);
void prolooks_hsv_unref (gpointer instance);
GParamSpec* prolooks_param_spec_hsv (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void prolooks_value_set_hsv (GValue* value, gpointer v_object);
void prolooks_value_take_hsv (GValue* value, gpointer v_object);
gpointer prolooks_value_get_hsv (const GValue* value);
GType prolooks_hsv_get_type (void);
#define PROLOOKS_HSV_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PROLOOKS_TYPE_HSV, ProlooksHSVPrivate))
enum {
PROLOOKS_HSV_DUMMY_PROPERTY
};
double prolooks_hsv_get_hue (ProlooksHSV* self);
double prolooks_hsv_get_saturation (ProlooksHSV* self);
double prolooks_hsv_get_value (ProlooksHSV* self);
char* prolooks_hsv_to_string (ProlooksHSV* self);
void prolooks_hsv_from_gdk_color (ProlooksHSV* self, GdkColor* color);
ProlooksHSV* prolooks_hsv_new_for_gdk_color (GdkColor* color);
ProlooksHSV* prolooks_hsv_construct_for_gdk_color (GType object_type, GdkColor* color);
void prolooks_hsv_from_cairo_color (ProlooksHSV* self, CairoColor* color);
ProlooksHSV* prolooks_hsv_new_for_cairo_color (CairoColor* color);
ProlooksHSV* prolooks_hsv_construct_for_cairo_color (GType object_type, CairoColor* color);
CairoColor* prolooks_hsv_to_cairo_color (ProlooksHSV* self);
void prolooks_hsv_to_gdk_color (ProlooksHSV* self, GdkColor* result);
void prolooks_hsv_set_value (ProlooksHSV* self, double value);
void prolooks_hsv_set_hue (ProlooksHSV* self, double value);
void prolooks_hsv_set_saturation (ProlooksHSV* self, double value);
ProlooksHSV* prolooks_hsv_new (void);
ProlooksHSV* prolooks_hsv_construct (GType object_type);
static void prolooks_hsv_finalize (ProlooksHSV* obj);
void prolooks_shade_color (GdkColor* orig, double shade_ratio, GdkColor* result);
GdkPixbuf* prolooks_cairo_image_surface_to_pixbuf (cairo_surface_t* surface);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* __prolooks_helpers_h__ */

View File

@ -27,6 +27,7 @@
#include "gtkmm2ext/motionfeedback.h"
#include "gtkmm2ext/keyboard.h"
#include "gtkmm2ext/prolooks-helpers.h"
using namespace Gtk;
using namespace Gtkmm2ext;
@ -62,6 +63,8 @@ MotionFeedback::MotionFeedback (Glib::RefPtr<Gdk::Pixbuf> pix,
pack_start (*hpacker, false, false);
pixwin.show ();
set_lamp_color (Gdk::Color ("#b9feff"));
if (with_numeric_display) {
value_packer = new HBox;
@ -296,10 +299,225 @@ MotionFeedback::adjustment_changed ()
pixwin.queue_draw ();
}
void
MotionFeedback::core_draw (cairo_t* cr, int phase, double radius, double x, double y)
{
double width;
double height;
double xc;
double yc;
double start_angle;
double end_angle;
double value_angle;
double value;
double value_x;
double value_y;
double start_angle_x;
double start_angle_y;
double end_angle_x;
double end_angle_y;
double progress_width;
double progress_radius;
double progress_radius_inner;
double progress_radius_outer;
double knob_disc_radius;
cairo_pattern_t* pattern;
GdkColor col2 = {0,0,0,0};
GdkColor lamp_bright;
GdkColor col3 = {0,0,0,0};
GdkColor lamp_dark;
double progress_rim_width;
cairo_pattern_t* progress_shine;
double degrees;
cairo_pattern_t* knob_ripples;
g_return_if_fail (cr != NULL);
cairo_set_source_rgba (cr, 0.75, 0.75, 0.75, (double) 0);
cairo_rectangle (cr, (double) 0, (double) 0, subwidth, subheight);
cairo_fill (cr);
width = 105.0;
height = 105.0;
xc = width / 2.0;
yc = height / 2.0;
start_angle = 0.0;
end_angle = 0.0;
value_angle = 0.0;
value = (phase * 1.0) / (65 - 1);
start_angle = ((180 - 45) * G_PI) / 180;
end_angle = ((360 + 45) * G_PI) / 180;
value_angle = start_angle + (value * (end_angle - start_angle));
value_x = cos (value_angle);
value_y = sin (value_angle);
start_angle_x = cos (start_angle);
start_angle_y = sin (start_angle);
end_angle_x = cos (end_angle);
end_angle_y = sin (end_angle);
cairo_save (cr);
//cairo_translate (cr, x, (double) 0);
cairo_scale (cr, (2.0 * radius) / width, (2.0 * radius) / height);
//cairo_translate (cr, -xc, (double) 0);
pattern = prolooks_create_gradient_str ((double) 32, (double) 16, (double) 75, (double) 16, "#d4c8b9", "#ae977b", 1.0, 1.0);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_set_line_width (cr, 2.0);
cairo_arc (cr, xc, yc, 31.5, 0.0, 2 * G_PI);
cairo_stroke (cr);
progress_width = 20.0;
progress_radius = 40.0;
progress_radius_inner = progress_radius - (progress_width / 2.0);
progress_radius_outer = progress_radius + (progress_width / 2.0);
knob_disc_radius = progress_radius_inner - 5.0;
pattern = prolooks_create_gradient_str ((double) 20, (double) 20, (double) 89, (double) 87, "#2f2f4c", "#090a0d", 1.0, 1.0);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_set_line_width (cr, progress_width);
cairo_arc (cr, xc, yc, progress_radius, start_angle, end_angle);
cairo_stroke (cr);
lamp_bright = (prolooks_hsv_to_gdk_color (lamp_hsv, &col2), col2);
prolooks_hsv_set_saturation (lamp_hsv, 0.66);
prolooks_hsv_set_value (lamp_hsv, 0.67);
lamp_dark = (prolooks_hsv_to_gdk_color (lamp_hsv, &col3), col3);
pattern = prolooks_create_gradient ((double) 20, (double) 20, (double) 89, (double) 87, &lamp_bright, &lamp_dark, 1.0, 1.0);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_set_line_width (cr, progress_width);
cairo_arc (cr, xc, yc, progress_radius, start_angle, value_angle);
cairo_stroke (cr);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
progress_rim_width = 2.0;
cairo_set_line_width (cr, progress_rim_width);
pattern = prolooks_create_gradient_str ((double) 18, (double) 79, (double) 35, (double) 79, "#dfd5c9", "#dfd5c9", 1.0, 0.0);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_move_to (cr, xc + (progress_radius_outer * start_angle_x), yc + (progress_radius_outer * start_angle_y));
cairo_line_to (cr, xc + (progress_radius_inner * start_angle_x), yc + (progress_radius_inner * start_angle_y));
cairo_stroke (cr);
prolooks_set_source_color_string (cr, "#b3a190", 1.0);
cairo_move_to (cr, xc + (progress_radius_outer * end_angle_x), yc + (progress_radius_outer * end_angle_y));
cairo_line_to (cr, xc + (progress_radius_inner * end_angle_x), yc + (progress_radius_inner * end_angle_y));
cairo_stroke (cr);
pattern = prolooks_create_gradient_str ((double) 95, (double) 6, (double) 5, (double) 44, "#dfd5c9", "#b0a090", 1.0, 1.0);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_arc (cr, xc, yc, progress_radius_outer, start_angle, end_angle);
cairo_stroke (cr);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
pattern = prolooks_create_gradient ((double) 20, (double) 20, (double) 89, (double) 87, &lamp_bright, &lamp_dark, 0.25, 0.25);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_set_line_width (cr, progress_width);
cairo_arc (cr, xc, yc, progress_radius, start_angle, value_angle + (G_PI / 180.0));
cairo_stroke (cr);
progress_shine = prolooks_create_gradient_str ((double) 89, (double) 73, (double) 34, (double) 16, "#ffffff", "#ffffff", 0.3, 0.04);
cairo_pattern_add_color_stop_rgba (progress_shine, 0.5, 1.0, 1.0, 1.0, 0.0);
cairo_pattern_add_color_stop_rgba (progress_shine, 0.75, 1.0, 1.0, 1.0, 0.3);
cairo_set_source (cr, progress_shine);
cairo_set_line_width (cr, progress_width);
cairo_arc (cr, xc, yc, progress_radius, start_angle, end_angle);
cairo_stroke (cr);
cairo_set_line_width (cr, 1.0);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_arc (cr, xc, yc, progress_radius_inner, (double) 0, 2 * G_PI);
pattern = prolooks_create_gradient_str ((double) 35, (double) 31, (double) 75, (double) 72, "#68625c", "#44494b", 1.0, 1.0);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_fill (cr);
cairo_set_source_rgb (cr, (double) 0, (double) 0, (double) 0);
cairo_arc (cr, xc, yc, progress_radius_inner, (double) 0, 2 * G_PI);
cairo_stroke (cr);
pattern = prolooks_create_gradient_str ((double) 42, (double) 34, (double) 68, (double) 70, "#e7ecef", "#9cafb8", 1.0, 1.0);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_arc (cr, xc, yc, knob_disc_radius, (double) 0, 2 * G_PI);
cairo_fill (cr);
cairo_set_line_width (cr, 2.0);
degrees = G_PI / 180.0;
pattern = prolooks_create_gradient_str ((double) 38, (double) 34, (double) 70, (double) 68, "#ffffff", "#caddf2", 0.2, 0.2);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_move_to (cr, xc, yc);
cairo_arc (cr, xc, yc, knob_disc_radius - 1, (-154) * degrees, (-120) * degrees);
cairo_move_to (cr, xc, yc);
cairo_arc (cr, xc, yc, knob_disc_radius - 1, (G_PI / 2.0) - (60 * degrees), (G_PI / 2.0) - (29 * degrees));
cairo_fill (cr);
pattern = prolooks_create_gradient_str ((double) 50, (double) 40, (double) 62, (double) 60, "#a1adb6", "#47535c", 0.07, 0.15);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_move_to (cr, xc, yc);
cairo_arc (cr, xc, yc, knob_disc_radius - 1, (-67) * degrees, (-27) * degrees);
cairo_move_to (cr, xc, yc);
cairo_arc (cr, xc, yc, knob_disc_radius - 1, G_PI - (67 * degrees), G_PI - (27 * degrees));
cairo_fill (cr);
knob_ripples = cairo_pattern_create_radial (xc, yc, (double) 0, xc, yc, (double) 4);
prolooks_add_color_stop_str (knob_ripples, 0.0, "#e7ecef", 0.05);
prolooks_add_color_stop_str (knob_ripples, 0.5, "#58717d", 0.05);
prolooks_add_color_stop_str (knob_ripples, 0.75, "#d1d9de", 0.05);
prolooks_add_color_stop_str (knob_ripples, 1.0, "#5d7682", 0.05);
cairo_pattern_set_extend (knob_ripples, CAIRO_EXTEND_REPEAT);
cairo_set_line_width (cr, 0.0);
cairo_set_source (cr, knob_ripples);
cairo_arc (cr, xc, yc, knob_disc_radius, (double) 0, 2 * G_PI);
cairo_fill (cr);
cairo_save (cr);
cairo_translate (cr, xc + (knob_disc_radius * value_x), yc + (knob_disc_radius * value_y));
cairo_rotate (cr, value_angle - G_PI);
cairo_set_source (cr, pattern = prolooks_create_gradient_str ((double) 16, (double) (-2), (double) 9, (double) 13, "#e7ecef", "#9cafb8", 0.8, 0.8));
cairo_pattern_destroy (pattern);
cairo_move_to (cr, (double) 0, (double) 4);
cairo_line_to (cr, (double) 17, (double) 4);
cairo_curve_to (cr, (double) 19, (double) 4, (double) 21, (double) 2, (double) 21, (double) 0);
cairo_curve_to (cr, (double) 21, (double) (-2), (double) 19, (double) (-4), (double) 17, (double) (-4));
cairo_line_to (cr, (double) 0, (double) (-4));
cairo_close_path (cr);
cairo_fill (cr);
pattern = prolooks_create_gradient_str ((double) 9, (double) (-2), (double) 9, (double) 2, "#68625c", "#44494b", 1.0, 1.0);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_move_to (cr, (double) 0, (double) 2);
cairo_line_to (cr, (double) 16, (double) 2);
cairo_curve_to (cr, (double) 17, (double) 2, (double) 18, (double) 1, (double) 18, (double) 0);
cairo_curve_to (cr, (double) 18, (double) (-1), (double) 17, (double) (-2), (double) 16, (double) (-2));
cairo_line_to (cr, (double) 0, (double) (-2));
cairo_close_path (cr);
cairo_fill (cr);
cairo_restore (cr);
cairo_set_line_width (cr, 2.0);
pattern = prolooks_create_gradient_str ((double) 38, (double) 32, (double) 70, (double) 67, "#3d3d3d", "#000000", 1.0, 1.0);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_arc (cr, xc, yc, knob_disc_radius, (double) 0, 2 * G_PI);
cairo_stroke (cr);
cairo_restore (cr);
cairo_pattern_destroy (progress_shine);
cairo_pattern_destroy (knob_ripples);
}
bool
MotionFeedback::pixwin_expose_event (GdkEventExpose* ev)
{
GtkWidget* widget = GTK_WIDGET(pixwin.gobj());
GdkWindow *window = pixwin.get_window()->gobj();
GtkAdjustment* adj = adjustment->gobj();
@ -333,11 +551,14 @@ MotionFeedback::pixwin_expose_event (GdkEventExpose* ev)
phase = (phase + 63) % 64;
}
gdk_draw_pixbuf (GDK_DRAWABLE(window), widget->style->fg_gc[0],
pixbuf->gobj(),
phase * subwidth, type * subheight,
0, 0, subwidth, subheight, GDK_RGB_DITHER_NORMAL, 0, 0);
cairo_t* cr = gdk_cairo_create (GDK_DRAWABLE (window));
gdk_cairo_rectangle (cr, &ev->area);
cairo_clip (cr);
core_draw (cr, phase, subheight/2, subwidth/2, subheight/2);
cairo_destroy (cr);
return true;
}
@ -375,3 +596,10 @@ MotionFeedback::pixwin_size_request (GtkRequisition* req)
req->width = subwidth;
req->height = subheight;
}
void
MotionFeedback::set_lamp_color (const Gdk::Color& c)
{
_lamp_color = c;
lamp_hsv = prolooks_hsv_new_for_gdk_color (_lamp_color.gobj());
}

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,7 @@ gtkmm2ext_sources = [
'idle_adjustment.cc',
'keyboard.cc',
'motionfeedback.cc',
'prolooks_helpers.c',
'pixfader.cc',
'pixscroller.cc',
'popup.cc',