remove all traces of "prolooks" and related classes

This commit is contained in:
Paul Davis 2016-02-11 13:03:24 -05:00
parent 2429308bac
commit e6b06597b7
10 changed files with 0 additions and 2810 deletions

View File

@ -26,7 +26,6 @@
#include "gtkmm2ext/bindable_button.h"
#include "gtkmm2ext/tearoff.h"
#include "gtkmm2ext/actions.h"
#include "gtkmm2ext/motionfeedback.h"
#include "gtkmm2ext/utils.h"
#include <gtkmm/menu.h>
@ -45,7 +44,6 @@
#include "public_editor.h"
#include "timers.h"
#include "tooltips.h"
#include "volume_controller.h"
#include "ui_config.h"
#include "utils.h"

View File

@ -36,11 +36,8 @@
namespace Gtkmm2ext {
class TearOff;
class MotionFeedback;
}
class VolumeController;
class MonitorSection : public RouteUI
{
public:

View File

@ -1,280 +0,0 @@
/*
Copyright (C) 1998-2007 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.
$Id: volume_controller.cc,v 1.4 2000/05/03 15:54:21 pbd Exp $
*/
#include <algorithm>
#include <string.h>
#include <limits.h>
#include "pbd/controllable.h"
#include "pbd/stacktrace.h"
#include "gtkmm2ext/gui_thread.h"
#include "ardour/dB.h"
#include "ardour/rc_configuration.h"
#include "ardour/utils.h"
#include "volume_controller.h"
using namespace Gtk;
VolumeController::VolumeController (Glib::RefPtr<Gdk::Pixbuf> p,
boost::shared_ptr<PBD::Controllable> c,
double def,
double step,
double page,
bool with_numeric,
int subw,
int subh,
bool linear)
: MotionFeedback (p, MotionFeedback::Rotary, c, def, step, page, "", with_numeric, subw, subh)
, _linear (linear)
{
set_print_func (VolumeController::_dB_printer, this);
value->set_width_chars (8);
}
void
VolumeController::_dB_printer (char buf[32], const boost::shared_ptr<PBD::Controllable>& c, void* arg)
{
VolumeController* vc = reinterpret_cast<VolumeController*>(arg);
vc->dB_printer (buf, c);
}
void
VolumeController::dB_printer (char buf[32], const boost::shared_ptr<PBD::Controllable>& c)
{
if (c) {
if (_linear) {
double val = accurate_coefficient_to_dB (c->get_value());
if (step_inc < 1.0) {
if (val >= 0.0) {
snprintf (buf, 32, "+%5.2f dB", val);
} else {
snprintf (buf, 32, "%5.2f dB", val);
}
} else {
if (val >= 0.0) {
snprintf (buf, 32, "+%2ld dB", lrint (val));
} else {
snprintf (buf, 32, "%2ld dB", lrint (val));
}
}
} else {
double dB = accurate_coefficient_to_dB (c->get_value());
if (step_inc < 1.0) {
if (dB >= 0.0) {
snprintf (buf, 32, "+%5.2f dB", dB);
} else {
snprintf (buf, 32, "%5.2f dB", dB);
}
} else {
if (dB >= 0.0) {
snprintf (buf, 32, "+%2ld dB", lrint (dB));
} else {
snprintf (buf, 32, "%2ld dB", lrint (dB));
}
}
}
} else {
snprintf (buf, 32, "--");
}
}
double
VolumeController::to_control_value (double display_value)
{
double v;
/* display value is always clamped to 0.0 .. 1.0 */
display_value = std::max (0.0, std::min (1.0, display_value));
if (_linear) {
v = _controllable->lower() + ((_controllable->upper() - _controllable->lower()) * display_value);
} else {
v = ARDOUR::slider_position_to_gain_with_max (display_value, ARDOUR::Config->get_max_gain());
}
return v;
}
double
VolumeController::to_display_value (double control_value)
{
double v;
if (_linear) {
v = (control_value - _controllable->lower ()) / (_controllable->upper() - _controllable->lower());
} else {
v = ARDOUR::gain_to_slider_position_with_max (control_value, _controllable->upper());
}
return v;
}
double
VolumeController::adjust (double control_delta)
{
double v;
if (!_linear) {
/* we map back into the linear/fractional slider position,
* because this kind of control goes all the way down
* to -inf dB, and we want this occur in a reasonable way in
* terms of user interaction. if we leave the adjustment in the
* gain coefficient domain (or dB domain), the lower end of the
* control range (getting close to -inf dB) takes forever.
*/
#if 0
/* convert to linear/fractional slider position domain */
v = ARDOUR::gain_to_slider_position_with_max (_controllable->get_value (), _controllable->upper());
/* increment in this domain */
v += control_delta;
/* clamp to appropriate range for linear/fractional slider domain */
v = std::max (0.0, std::min (1.0, v));
/* convert back to gain coefficient domain */
v = ARDOUR::slider_position_to_gain_with_max (v, _controllable->upper());
/* clamp in controller domain */
v = std::max (_controllable->lower(), std::min (_controllable->upper(), v));
/* convert to dB domain */
v = accurate_coefficient_to_dB (v);
/* round up/down to nearest 0.1dB */
if (control_delta > 0.0) {
v = ceil (v * 10.0) / 10.0;
} else {
v = floor (v * 10.0) / 10.0;
}
/* and return it */
return dB_to_coefficient (v);
#else
/* ^^ Above algorithm is not symmetric. Scroll up to steps, scoll down two steps, -> different gain.
*
* see ./libs/gtkmm2ext/gtkmm2ext/motionfeedback.h and gtk2_ardour/monitor_section.cc:
* min-delta (corr) = MIN(0.01 * page inc, 1 * size_inc) // (gain_control uses size_inc=0.01, page_inc=0.1)
* range corr: 0..2 -> -inf..+6dB
* step sizes [0.01, 0.10, 0.20] * page_inc, [1,2,10,100] * step_inc. [1,2,10,100] * page_inc
*
* 0.001, 0.01, 0.02, 0.1, .2, 1, 10
* -> 1k steps between -inf..0dB
* -> 1k steps between 0..+dB
*
* IOW:
* the range is from *0 (-inf dB) to *2.0 ( +6dB)
* the knob is configured to to go in steps of 0.001 - that's 2000 steps between 0 and 2.
* or 1000 steps between 0 and 1.
*
* we cannot round to .01dB steps because
* There are only 600 possible values between +0db and +6dB when going in steps of .01dB
* 1000/600 = 1.66666...
*
******
* idea: make the 'controllable use a fixed range of dB.
* do a 1:1 mapping between values. :et's stick with the range of 0..2 in 0.001 steps
*
* "-80" becomes 0 and "+6" becomes 2000. (NB +6dB is actually 1995, but we clamp that to the top)
*
* This approach is better (more consistet) but not good. At least the dial does not annoy me as much
* anymore as it did before.
*
* const double stretchfactor = rint((_controllable->upper() - _controllable->lower()) / 0.001); // 2000;
* const double logfactor = stretchfactor / ((20.0 * log10( _controllable->upper())) + 80.0); // = 23.250244732
*/
v = _controllable->get_value ();
/* assume everything below -60dB is silent (.001 ^= -60dB)
* but map range -80db..+6dB to a scale of 0..2000
* 80db was motivated because 2000/((20.0 * log(1)) + 80.0) is an integer value. "0dB" is included on the scale.
* but this leaves a dead area at the bottom of the meter..
*/
double arange = (v >= 0.001) ? ( ((20.0 * log10(v)) + 80.0) * 23.250244732 ) : ( 0 );
/* add the delta */
v = rint(arange) + rint(control_delta * 1000.0); // (min steps is 1.0/0.001 == 1000.0)
/* catch bottom -80..-60 db in one step */
if (v < 466) v = (control_delta > 0) ? 0.001 : 0;
/* reverse operation (pow(10, .05 * ((v / 23.250244732) - 80.0)))
* can be simplified to :*/
else v = pow(10, (v * 0.00215051499) - 4.0);
/* clamp value in coefficient domain */
v = std::max (_controllable->lower(), std::min (_controllable->upper(), v));
return v;
#endif
} else {
double mult;
if (control_delta < 0.0) {
mult = -1.0;
} else {
mult = 1.0;
}
if (fabs (control_delta) < 0.05) {
control_delta = mult * 0.05;
} else {
control_delta = mult * 0.1;
}
v = _controllable->get_value();
if (v == 0.0) {
/* if we don't special case this, we can't escape from
the -infinity dB black hole.
*/
if (control_delta > 0.0) {
v = dB_to_coefficient (-100 + control_delta);
}
} else {
static const double dB_minus_200 = dB_to_coefficient (-200.0);
static const double dB_minus_100 = dB_to_coefficient (-100.0);
static const double dB_minus_50 = dB_to_coefficient (-50.0);
static const double dB_minus_20 = dB_to_coefficient (-20.0);
if (control_delta < 0 && v < dB_minus_200) {
v = 0.0;
} else {
/* non-linear scaling as the dB level gets low
so that we can hit -inf and get back out of
it appropriately.
*/
if (v < dB_minus_100) {
control_delta *= 1000.0;
} else if (v < dB_minus_50) {
control_delta *= 100.0;
} else if (v < dB_minus_20) {
control_delta *= 10.0;
}
v = accurate_coefficient_to_dB (v);
v += control_delta;
v = dB_to_coefficient (v);
}
}
return std::max (_controllable->lower(), std::min (_controllable->upper(), v));
}
}

View File

@ -1,60 +0,0 @@
/*
Copyright (C) 1998-2007 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.
$Id: volume_controller.h,v 1.4 2000/05/03 15:54:21 pbd Exp $
*/
#ifndef __gtk_ardour_vol_controller_h__
#define __gtk_ardour_vol_controller_h__
#include <gtkmm/adjustment.h>
#include "gtkmm2ext/motionfeedback.h"
class VolumeController : public Gtkmm2ext::MotionFeedback
{
public:
VolumeController (Glib::RefPtr<Gdk::Pixbuf>,
boost::shared_ptr<PBD::Controllable>,
double def,
double step,
double page,
bool with_numeric = true,
int image_width = 40,
int image_height = 40,
bool linear = true);
virtual ~VolumeController () {}
static void _dB_printer (char buf[32], const boost::shared_ptr<PBD::Controllable>& adj, void* arg);
protected:
double to_control_value (double);
double to_display_value (double);
double adjust (double nominal_delta);
double display_value () const;
double control_value () const;
private:
bool _linear;
void dB_printer (char buf[32], const boost::shared_ptr<PBD::Controllable>& adj);
};
#endif // __gtk_ardour_vol_controller_h__

View File

@ -246,7 +246,6 @@ gtk2_ardour_sources = [
'utils.cc',
'verbose_cursor.cc',
'visibility_group.cc',
'volume_controller.cc',
'window_manager.cc',
# video-timeline related sources:
'video_image_frame.cc',

View File

@ -1,134 +0,0 @@
/*
Copyright (C) 1998-99 Paul Barton-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.
$Id: motionfeedback.h,v 1.1.1.1 2001/11/24 00:44:46 pbd Exp $
*/
#ifndef __gtkmm2ext_motion_feedback_h__
#define __gtkmm2ext_motion_feedback_h__
#include "pbd/signals.h"
#include <gdkmm/pixbuf.h>
#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <gtkmm/eventbox.h>
#include "gtkmm2ext/visibility.h"
#include "gtkmm2ext/binding_proxy.h"
#include "gtkmm2ext/prolooks-helpers.h"
namespace Gtk {
class Adjustment;
class SpinButton;
}
namespace Gtkmm2ext {
class LIBGTKMM2EXT_API MotionFeedback : public Gtk::VBox
{
public:
enum Type {
Rotary,
CenterSpring,
Endless
};
MotionFeedback (Glib::RefPtr<Gdk::Pixbuf>,
Type type,
boost::shared_ptr<PBD::Controllable>,
double default_value,
double step_increment,
double page_increment,
const char *widget_name = NULL,
bool with_numeric_display = true,
int sub_image_width = 40,
int sub_image_height = 40);
virtual ~MotionFeedback ();
Gtk::Widget& eventwin () { return pixwin; }
boost::shared_ptr<PBD::Controllable> controllable() const;
virtual void set_controllable (boost::shared_ptr<PBD::Controllable> c);
static void set_lamp_color (const std::string&);
static Glib::RefPtr<Gdk::Pixbuf> render_pixbuf (int size);
void set_print_func(void (*pf)(char buf[32], const boost::shared_ptr<PBD::Controllable>&, void *),
void *arg) {
print_func = pf;
print_arg = arg;
};
protected:
boost::shared_ptr<PBD::Controllable> _controllable;
Gtk::Label* value;
double default_value;
double step_inc;
double page_inc;
void pixwin_size_request (GtkRequisition *);
bool pixwin_button_press_event (GdkEventButton *);
bool pixwin_button_release_event (GdkEventButton *);
bool pixwin_motion_notify_event (GdkEventMotion *);
bool pixwin_key_press_event (GdkEventKey *);
bool pixwin_enter_notify_event (GdkEventCrossing *);
bool pixwin_leave_notify_event (GdkEventCrossing *);
bool pixwin_focus_in_event (GdkEventFocus*);
bool pixwin_focus_out_event (GdkEventFocus *);
bool pixwin_expose_event (GdkEventExpose*);
bool pixwin_scroll_event (GdkEventScroll*);
/* map a display value (0.0 .. 1.0) to a control
value (controllable->lower() .. controllable()->upper)
*/
virtual double to_control_value (double) = 0;
/* map a control value (controllable->lower() .. controllable()->upper)
to a display value (0.0 .. 1.0)
*/
virtual double to_display_value (double) = 0;
virtual double adjust (double nominal_delta) = 0;
private:
Type type;
Gtk::EventBox pixwin;
Gtk::EventBox* value_packer;
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
BindingProxy binding_proxy;
static Gdk::Color* base_color;
void (*print_func) (char buf[32], const boost::shared_ptr<PBD::Controllable>&, void *);
void *print_arg;
static void default_printer (char buf[32], const boost::shared_ptr<PBD::Controllable>&, void *);
bool grab_is_fine;
double grabbed_y;
double grabbed_x;
int subwidth;
int subheight;
void controllable_value_changed ();
PBD::ScopedConnection controller_connection;
static void core_draw (cairo_t*, int, double, double, double, double, const GdkColor* bright, const GdkColor* dark);
};
} /* namespace */
#endif // __gtkmm2ext_motion_feedback_h__

View File

@ -1,252 +0,0 @@
/* 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>
#include "gtkmm2ext/visibility.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;
};
LIBGTKMM2EXT_API gpointer cairo_color_ref (gpointer instance);
LIBGTKMM2EXT_API void cairo_color_unref (gpointer instance);
LIBGTKMM2EXT_API GParamSpec* cairo_param_spec_color (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
LIBGTKMM2EXT_API void cairo_value_set_color (GValue* value, gpointer v_object);
LIBGTKMM2EXT_API void cairo_value_take_color (GValue* value, gpointer v_object);
LIBGTKMM2EXT_API gpointer cairo_value_get_color (const GValue* value);
LIBGTKMM2EXT_API GType cairo_color_get_type (void);
#define CAIRO_COLOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CAIRO_TYPE_COLOR, CairoColorPrivate))
enum LIBGTKMM2EXT_API {
CAIRO_COLOR_DUMMY_PROPERTY
};
LIBGTKMM2EXT_API void cairo_color_set_red (CairoColor* self, double value);
LIBGTKMM2EXT_API void cairo_color_set_green (CairoColor* self, double value);
LIBGTKMM2EXT_API void cairo_color_set_blue (CairoColor* self, double value);
LIBGTKMM2EXT_API void cairo_color_set_alpha (CairoColor* self, double value);
LIBGTKMM2EXT_API CairoColor* cairo_color_new (double red, double green, double blue, double alpha);
LIBGTKMM2EXT_API CairoColor* cairo_color_construct (GType object_type, double red, double green, double blue, double alpha);
LIBGTKMM2EXT_API double cairo_color_get_red (CairoColor* self);
LIBGTKMM2EXT_API double cairo_color_get_green (CairoColor* self);
LIBGTKMM2EXT_API double cairo_color_get_blue (CairoColor* self);
LIBGTKMM2EXT_API double cairo_color_get_alpha (CairoColor* self);
LIBGTKMM2EXT_API CairoColor* cairo_color_copy (CairoColor* self);
LIBGTKMM2EXT_API void cairo_color_set_from_string (CairoColor* self, const char* webcolor);
LIBGTKMM2EXT_API CairoColor* cairo_color_new_from_string (const char* webcolor);
LIBGTKMM2EXT_API CairoColor* cairo_color_construct_from_string (GType object_type, const char* webcolor);
LIBGTKMM2EXT_API ProlooksHSL* prolooks_hsl_new (void);
LIBGTKMM2EXT_API ProlooksHSL* prolooks_hsl_construct (GType object_type);
LIBGTKMM2EXT_API gpointer prolooks_hsl_ref (gpointer instance);
LIBGTKMM2EXT_API void prolooks_hsl_unref (gpointer instance);
LIBGTKMM2EXT_API GParamSpec* prolooks_param_spec_hsl (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
LIBGTKMM2EXT_API void prolooks_value_set_hsl (GValue* value, gpointer v_object);
LIBGTKMM2EXT_API void prolooks_value_take_hsl (GValue* value, gpointer v_object);
LIBGTKMM2EXT_API gpointer prolooks_value_get_hsl (const GValue* value);
LIBGTKMM2EXT_API GType prolooks_hsl_get_type (void);
LIBGTKMM2EXT_API void prolooks_hsl_from_cairo_color (ProlooksHSL* self, CairoColor* color);
LIBGTKMM2EXT_API double prolooks_hsl_get_lightness (ProlooksHSL* self);
LIBGTKMM2EXT_API void prolooks_hsl_set_lightness (ProlooksHSL* self, double value);
LIBGTKMM2EXT_API double prolooks_hsl_get_saturation (ProlooksHSL* self);
LIBGTKMM2EXT_API void prolooks_hsl_set_saturation (ProlooksHSL* self, double value);
LIBGTKMM2EXT_API CairoColor* prolooks_hsl_to_cairo_color (ProlooksHSL* self);
LIBGTKMM2EXT_API CairoColor* cairo_color_shade (CairoColor* self, double shade_factor);
LIBGTKMM2EXT_API void cairo_color_set_to (CairoColor* self, CairoColor* a_color);
LIBGTKMM2EXT_API void cairo_color_set_as_source_in (CairoColor* self, cairo_t* cr);
LIBGTKMM2EXT_API void cairo_color_add_color_stop_to (CairoColor* self, cairo_pattern_t* p, double offset);
LIBGTKMM2EXT_API CairoColor* prolooks_gdk_color_to_cairo (const GdkColor* color);
LIBGTKMM2EXT_API void prolooks_color_from_string (const char* webcolor, GdkColor* result);
LIBGTKMM2EXT_API GType prolooks_button_state_get_type (void);
LIBGTKMM2EXT_API GType prolooks_button_type_get_type (void);
LIBGTKMM2EXT_API void prolooks_set_line_width_from_device (cairo_t* cr);
LIBGTKMM2EXT_API char* prolooks_color_to_string (const GdkColor* color);
LIBGTKMM2EXT_API CairoColor* prolooks_cairo_color_from_string (const char* webcolor);
LIBGTKMM2EXT_API void prolooks_set_source_color (cairo_t* cr, const GdkColor* color, double alpha);
LIBGTKMM2EXT_API void prolooks_gdk_color_to_cairo_color (const GdkColor* color, double* red, double* green, double* blue);
LIBGTKMM2EXT_API void prolooks_cairo_color_to_gdk (CairoColor* cairo_color, GdkColor* result);
LIBGTKMM2EXT_API void prolooks_set_source_color_string (cairo_t* cr, const char* color, double alpha);
LIBGTKMM2EXT_API void prolooks_add_color_stop (cairo_pattern_t* p, double offset, const GdkColor* color, double alpha);
LIBGTKMM2EXT_API void prolooks_add_color_stop_str (cairo_pattern_t* p, double offset, const char* color, double alpha);
LIBGTKMM2EXT_API cairo_pattern_t* prolooks_create_gradient (double x1, double y1, double x2, double y2, const GdkColor* start, const GdkColor* stop, double alpha_start, double alpha_stop);
LIBGTKMM2EXT_API 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);
LIBGTKMM2EXT_API void prolooks_rounded_rect (cairo_t* cr, double x, double y, double w, double h, double radius_x, double radius_y);
LIBGTKMM2EXT_API void prolooks_background_gradient (cairo_t* cr, double w, double h);
LIBGTKMM2EXT_API double prolooks_modula (double number, double divisor);
#define PROLOOKS_HSL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PROLOOKS_TYPE_HSL, ProlooksHSLPrivate))
enum LIBGTKMM2EXT_API {
PROLOOKS_HSL_DUMMY_PROPERTY
};
LIBGTKMM2EXT_API double prolooks_hsl_get_hue (ProlooksHSL* self);
LIBGTKMM2EXT_API char* prolooks_hsl_to_string (ProlooksHSL* self);
LIBGTKMM2EXT_API void prolooks_hsl_to_gdk_color (ProlooksHSL* self, GdkColor* result);
LIBGTKMM2EXT_API void prolooks_hsl_from_gdk_color (ProlooksHSL* self, const GdkColor* color);
LIBGTKMM2EXT_API void prolooks_hsl_set_hue (ProlooksHSL* self, double value);
LIBGTKMM2EXT_API gpointer prolooks_hsv_ref (gpointer instance);
LIBGTKMM2EXT_API void prolooks_hsv_unref (gpointer instance);
LIBGTKMM2EXT_API GParamSpec* prolooks_param_spec_hsv (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
LIBGTKMM2EXT_API void prolooks_value_set_hsv (GValue* value, gpointer v_object);
LIBGTKMM2EXT_API void prolooks_value_take_hsv (GValue* value, gpointer v_object);
LIBGTKMM2EXT_API gpointer prolooks_value_get_hsv (const GValue* value);
LIBGTKMM2EXT_API GType prolooks_hsv_get_type (void);
#define PROLOOKS_HSV_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PROLOOKS_TYPE_HSV, ProlooksHSVPrivate))
enum LIBGTKMM2EXT_API {
PROLOOKS_HSV_DUMMY_PROPERTY
};
LIBGTKMM2EXT_API double prolooks_hsv_get_hue (ProlooksHSV* self);
LIBGTKMM2EXT_API double prolooks_hsv_get_saturation (ProlooksHSV* self);
LIBGTKMM2EXT_API double prolooks_hsv_get_value (ProlooksHSV* self);
LIBGTKMM2EXT_API char* prolooks_hsv_to_string (ProlooksHSV* self);
LIBGTKMM2EXT_API void prolooks_hsv_from_gdk_color (ProlooksHSV* self, const GdkColor* color);
LIBGTKMM2EXT_API ProlooksHSV* prolooks_hsv_new_for_gdk_color (const GdkColor* color);
LIBGTKMM2EXT_API ProlooksHSV* prolooks_hsv_construct_for_gdk_color (GType object_type, const GdkColor* color);
LIBGTKMM2EXT_API void prolooks_hsv_from_cairo_color (ProlooksHSV* self, CairoColor* color);
LIBGTKMM2EXT_API ProlooksHSV* prolooks_hsv_new_for_cairo_color (CairoColor* color);
LIBGTKMM2EXT_API ProlooksHSV* prolooks_hsv_construct_for_cairo_color (GType object_type, CairoColor* color);
LIBGTKMM2EXT_API CairoColor* prolooks_hsv_to_cairo_color (ProlooksHSV* self);
LIBGTKMM2EXT_API void prolooks_hsv_to_gdk_color (ProlooksHSV* self, GdkColor* result);
LIBGTKMM2EXT_API void prolooks_hsv_set_value (ProlooksHSV* self, double value);
LIBGTKMM2EXT_API void prolooks_hsv_set_hue (ProlooksHSV* self, double value);
LIBGTKMM2EXT_API void prolooks_hsv_set_saturation (ProlooksHSV* self, double value);
LIBGTKMM2EXT_API ProlooksHSV* prolooks_hsv_new (void);
LIBGTKMM2EXT_API ProlooksHSV* prolooks_hsv_construct (GType object_type);
LIBGTKMM2EXT_API void prolooks_shade_color (const GdkColor* orig, double shade_ratio, GdkColor* result);
LIBGTKMM2EXT_API GdkPixbuf* prolooks_cairo_image_surface_to_pixbuf (cairo_surface_t* surface);
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* __prolooks_helpers_h__ */

View File

@ -1,693 +0,0 @@
/*
Copyright (C) 2010-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., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: motionfeedback.cc,v 1.5 2004/03/01 03:44:19 pauld Exp $
*/
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <unistd.h>
#include <stdio.h> /* for snprintf, grrr */
#include "pbd/gstdio_compat.h"
#include <gdk/gdkkeysyms.h>
#include <gtkmm.h>
#include "pbd/controllable.h"
#include "pbd/compose.h"
#include "pbd/error.h"
#include "gtkmm2ext/motionfeedback.h"
#include "gtkmm2ext/keyboard.h"
#include "gtkmm2ext/prolooks-helpers.h"
#include "gtkmm2ext/gui_thread.h"
#include "i18n.h"
using namespace Gtk;
using namespace Gtkmm2ext;
using namespace sigc;
using PBD::error;
using PBD::Controllable;
Gdk::Color* MotionFeedback::base_color;
MotionFeedback::MotionFeedback (Glib::RefPtr<Gdk::Pixbuf> pix,
Type t,
boost::shared_ptr<PBD::Controllable> c,
double default_val,
double step_increment,
double page_increment,
const char *widget_name,
bool with_numeric_display,
int subw,
int subh)
: _controllable (c)
, value (0)
, default_value (default_val)
, step_inc (step_increment)
, page_inc (page_increment)
, type (t)
, value_packer (0)
, pixbuf (pix)
, subwidth (subw)
, subheight (subh)
{
if (!base_color) {
base_color = new Gdk::Color ("#1a5274");
}
char value_name[1024];
print_func = default_printer;
print_arg = 0;
HBox* hpacker = manage (new HBox);
hpacker->pack_start (pixwin, true, true);
hpacker->show ();
pack_start (*hpacker, false, false);
pixwin.show ();
if (with_numeric_display) {
value_packer = new EventBox;
value_packer->set_name ("MotionControllerValue");
value_packer->show ();
value_packer->set_border_width (6);
value = new Label;
value->set_justify (Gtk::JUSTIFY_RIGHT);
value->show ();
value_packer->add (*value);
hpacker = manage (new HBox);
hpacker->pack_start (*value_packer, true, false);
hpacker->show ();
hpacker->set_border_width (6);
pack_start (*hpacker, false, false);
if (widget_name) {
snprintf (value_name, sizeof(value_name), "%sValue", widget_name);
value->set_name (value_name);
}
if (_controllable) {
char buf[32];
print_func (buf, _controllable, print_arg);
value->set_text (buf);
}
}
pixwin.set_events (Gdk::BUTTON_PRESS_MASK|
Gdk::BUTTON_RELEASE_MASK|
Gdk::POINTER_MOTION_MASK|
Gdk::ENTER_NOTIFY_MASK|
Gdk::LEAVE_NOTIFY_MASK|
Gdk::SCROLL_MASK|
Gdk::KEY_PRESS_MASK|
Gdk::KEY_RELEASE_MASK);
pixwin.set_flags (CAN_FOCUS);
/* Proxy all important events on the pixwin to ourselves */
pixwin.signal_button_press_event().connect(mem_fun (*this,&MotionFeedback::pixwin_button_press_event));
pixwin.signal_button_release_event().connect(mem_fun (*this,&MotionFeedback::pixwin_button_release_event));
pixwin.signal_motion_notify_event().connect(mem_fun (*this,&MotionFeedback::pixwin_motion_notify_event));
pixwin.signal_enter_notify_event().connect(mem_fun (*this,&MotionFeedback::pixwin_enter_notify_event));
pixwin.signal_leave_notify_event().connect(mem_fun (*this,&MotionFeedback::pixwin_leave_notify_event));
pixwin.signal_key_press_event().connect(mem_fun (*this,&MotionFeedback::pixwin_key_press_event));
pixwin.signal_scroll_event().connect(mem_fun (*this,&MotionFeedback::pixwin_scroll_event));
pixwin.signal_expose_event().connect(mem_fun (*this,&MotionFeedback::pixwin_expose_event), true);
pixwin.signal_size_request().connect(mem_fun (*this,&MotionFeedback::pixwin_size_request));
}
MotionFeedback::~MotionFeedback()
{
delete value;
delete value_packer;
}
bool
MotionFeedback::pixwin_button_press_event (GdkEventButton *ev)
{
if (binding_proxy.button_press_handler (ev)) {
return true;
}
switch (ev->button) {
case 1:
grab_is_fine = false;
break;
case 2:
grab_is_fine = true;
break;
case 3:
return false;
}
gtk_grab_add(GTK_WIDGET(pixwin.gobj()));
grabbed_y = ev->y_root;
grabbed_x = ev->x_root;
return false;
}
bool
MotionFeedback::pixwin_button_release_event (GdkEventButton *ev)
{
if (!_controllable) {
return false;
}
switch (ev->button) {
case 1:
if (pixwin.has_grab()) {
if (!grab_is_fine) {
gtk_grab_remove
(GTK_WIDGET(pixwin.gobj()));
}
}
if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
/* shift click back to the default */
_controllable->set_value (default_value, Controllable::NoGroup);
return true;
} else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
/* ctrl click back to the minimum value */
_controllable->set_value (_controllable->lower (), Controllable::NoGroup);
}
break;
case 3:
if (pixwin.has_grab()) {
if (grab_is_fine) {
gtk_grab_remove
(GTK_WIDGET(pixwin.gobj()));
}
}
break;
}
return VBox::on_button_release_event (ev);
}
bool
MotionFeedback::pixwin_motion_notify_event (GdkEventMotion *ev)
{
if (!_controllable) {
return false;
}
gfloat multiplier;
gfloat x_delta;
gfloat y_delta;
if (!pixwin.has_grab()) {
return VBox::on_motion_notify_event (ev);
}
multiplier = ((ev->state & Keyboard::TertiaryModifier) ? 100 : 1) *
((ev->state & Keyboard::PrimaryModifier) ? 10 : 1) *
((ev->state & Keyboard::SecondaryModifier) ? 0.1 : 1);
if (ev->state & Gdk::BUTTON1_MASK) {
/* vertical control */
y_delta = grabbed_y - ev->y_root;
grabbed_y = ev->y_root;
x_delta = ev->x_root - grabbed_x;
if (y_delta == 0) return TRUE;
y_delta *= 1 + (x_delta/100);
y_delta *= multiplier;
y_delta /= 10;
_controllable->set_value (adjust ((grab_is_fine ? step_inc : page_inc) * y_delta), Controllable::NoGroup);
} else if (ev->state & Gdk::BUTTON2_MASK) {
/* rotary control */
double x = ev->x - subwidth/2;
double y = - ev->y + subwidth/2;
double angle = std::atan2 (y, x) / M_PI;
if (angle < -0.5) {
angle += 2.0;
}
angle = -(2.0/3.0) * (angle - 1.25);
angle *= multiplier;
_controllable->set_value (to_control_value (angle), Controllable::NoGroup);
}
return true;
}
bool
MotionFeedback::pixwin_enter_notify_event (GdkEventCrossing*)
{
pixwin.grab_focus();
return false;
}
bool
MotionFeedback::pixwin_leave_notify_event (GdkEventCrossing*)
{
pixwin.unset_flags (HAS_FOCUS);
return false;
}
bool
MotionFeedback::pixwin_key_press_event (GdkEventKey *ev)
{
if (!_controllable) {
return false;
}
bool retval = false;
double multiplier;
multiplier = ((ev->state & Keyboard::TertiaryModifier) ? 100.0 : 1.0) *
((ev->state & Keyboard::SecondaryModifier) ? 10.0 : 1.0) *
((ev->state & Keyboard::PrimaryModifier) ? 2.0 : 1.0);
switch (ev->keyval) {
case GDK_Page_Up:
retval = true;
_controllable->set_value (adjust (multiplier * page_inc), Controllable::NoGroup);
break;
case GDK_Page_Down:
retval = true;
_controllable->set_value (adjust (-multiplier * page_inc), Controllable::NoGroup);
break;
case GDK_Up:
retval = true;
_controllable->set_value (adjust (multiplier * step_inc), Controllable::NoGroup);
break;
case GDK_Down:
retval = true;
_controllable->set_value (adjust (-multiplier * step_inc), Controllable::NoGroup);
break;
case GDK_Home:
retval = true;
_controllable->set_value (_controllable->lower(), Controllable::NoGroup);
break;
case GDK_End:
retval = true;
_controllable->set_value (_controllable->upper(), Controllable::NoGroup);
break;
}
return retval;
}
bool
MotionFeedback::pixwin_expose_event (GdkEventExpose*)
{
if (!_controllable) {
return true;
}
GdkWindow *window = pixwin.get_window()->gobj();
double display_val = to_display_value (_controllable->get_value());
int32_t phase = lrint (display_val * 64.0);
// skip middle phase except for true middle value
if (type == Rotary && phase == 32) {
double pt = (display_val * 2.0) - 1.0;
if (pt < 0)
phase = 31;
if (pt > 0)
phase = 33;
}
// endless knob: skip 90deg highlights unless the value is really a multiple of 90deg
if (type == Endless && !(phase % 16)) {
if (phase == 64) {
phase = 0;
}
double nom = phase / 64.0;
double diff = display_val - nom;
if (diff > 0.0001)
phase = (phase + 1) % 64;
if (diff < -0.0001)
phase = (phase + 63) % 64;
}
phase = std::min (phase, (int32_t) 63);
GtkWidget* widget = GTK_WIDGET(pixwin.gobj());
gdk_draw_pixbuf (GDK_DRAWABLE(window), widget->style->fg_gc[0],
pixbuf->gobj(),
phase * subwidth, type * subheight,
/* center image in allocated area */
(get_width() - subwidth)/2,
0,
subwidth, subheight, GDK_RGB_DITHER_NORMAL, 0, 0);
return true;
}
bool
MotionFeedback::pixwin_scroll_event (GdkEventScroll* ev)
{
double scale;
if (!_controllable) {
return false;
}
if (ev->state & Keyboard::GainFineScaleModifier) {
if (ev->state & Keyboard::GainExtraFineScaleModifier) {
scale = 0.01;
} else {
scale = 0.10;
}
} else {
scale = 0.20;
}
switch (ev->direction) {
case GDK_SCROLL_UP:
case GDK_SCROLL_RIGHT:
_controllable->set_value (adjust (scale * page_inc), Controllable::NoGroup);
break;
case GDK_SCROLL_DOWN:
case GDK_SCROLL_LEFT:
_controllable->set_value (adjust (-scale * page_inc), Controllable::NoGroup);
break;
}
return true;
}
void
MotionFeedback::pixwin_size_request (GtkRequisition* req)
{
req->width = subwidth;
req->height = subheight;
}
void
MotionFeedback::controllable_value_changed ()
{
if (value) {
char buf[32];
print_func (buf, _controllable, print_arg);
value->set_text (buf);
}
pixwin.queue_draw ();
}
void
MotionFeedback::set_controllable (boost::shared_ptr<PBD::Controllable> c)
{
_controllable = c;
binding_proxy.set_controllable (c);
controller_connection.disconnect ();
if (c) {
c->Changed.connect (controller_connection, MISSING_INVALIDATOR, boost::bind (&MotionFeedback::controllable_value_changed, this), gui_context());
char buf[32];
print_func (buf, _controllable, print_arg);
value->set_text (buf);
}
pixwin.queue_draw ();
}
boost::shared_ptr<PBD::Controllable>
MotionFeedback::controllable () const
{
return _controllable;
}
void
MotionFeedback::default_printer (char buf[32], const boost::shared_ptr<PBD::Controllable>& c, void *)
{
if (c) {
sprintf (buf, "%.2f", c->get_value());
} else {
buf[0] = '\0';
}
}
Glib::RefPtr<Gdk::Pixbuf>
MotionFeedback::render_pixbuf (int size)
{
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
char *path;
int fd;
GError *gerror = NULL;
fd = g_file_open_tmp ("mfimgXXXXXX", &path, &gerror);
if (gerror) {
error << string_compose (_("motionfeedback: failed to open a temporary file for writing: %1"), gerror->message) << endmsg;
g_error_free (gerror);
return pixbuf;
} else {
::close (fd);
}
GdkColor col2 = {0,0,0,0};
GdkColor col3 = {0,0,0,0};
GdkColor dark;
GdkColor bright;
ProlooksHSV* hsv;
hsv = prolooks_hsv_new_for_gdk_color (base_color->gobj());
bright = (prolooks_hsv_to_gdk_color (hsv, &col2), col2);
prolooks_hsv_set_saturation (hsv, 0.66);
prolooks_hsv_set_value (hsv, 0.67);
dark = (prolooks_hsv_to_gdk_color (hsv, &col3), col3);
cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size * 64, size);
cairo_t* cr = cairo_create (surface);
for (int i = 0; i < 64; ++i) {
cairo_save (cr);
core_draw (cr, i, size, 20, size*i, 0, &bright, &dark);
cairo_restore (cr);
}
if (cairo_surface_write_to_png (surface, path) != CAIRO_STATUS_SUCCESS) {
error << string_compose (_("motionfeedback: could not save image set to %1"), path) << endmsg;
return pixbuf;
}
cairo_destroy (cr);
cairo_surface_destroy (surface);
try {
pixbuf = Gdk::Pixbuf::create_from_file (path);
} catch (const Gdk::PixbufError &e) {
error << string_compose (_("motionfeedback: caught PixbufError: %1"), e.what()) << endmsg;
} catch (...) {
error << _("motionfeedback: unknown exception") << endmsg;
}
g_unlink (path);
g_free (path);
return pixbuf;
}
void
MotionFeedback::core_draw (cairo_t* cr, int phase, double size, double progress_width, double xorigin, double yorigin,
const GdkColor* bright, const GdkColor* dark)
{
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_radius;
double progress_radius_inner;
double progress_radius_outer;
g_return_if_fail (cr != NULL);
progress_radius = 40.0;
progress_radius_inner = progress_radius - (progress_width / 2.0);
progress_radius_outer = progress_radius + (progress_width / 2.0);
const double pad = 2.0; /* line width for boundary of progress ring */
const double actual_width = ((2.0 * pad) + (2.0 * progress_radius_outer));
const double scale_factor = size / actual_width;
/* knob center is at middle of the area bounded by (xorigin,yorigin) and (xorigin+size, yorigin+size)
but the coordinates will be scaled by the scale factor when cairo uses them so first
adjust them by the reciprocal of the scale factor.
*/
xc = (xorigin + (size / 2.0)) * (1.0/scale_factor);
yc = (yorigin + (size / 2.0)) * (1.0/scale_factor);
value = (phase * 1.0) / (65 - 1);
start_angle = ((180 - 65) * G_PI) / 180;
end_angle = ((360 + 65) * 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_scale (cr, scale_factor, scale_factor);
//dark arc background
cairo_set_source_rgb (cr, 0.3, 0.3, 0.3 );
cairo_set_line_width (cr, progress_width);
cairo_arc (cr, xc, yc, progress_radius, start_angle, end_angle);
cairo_stroke (cr);
float r = (value) * (((float)bright->red)/G_MAXUINT16) + (1.0-value)*(((float)dark->red)/G_MAXUINT16);
float g = (value) * (((float)bright->green)/G_MAXUINT16) + (1.0-value)*(((float)dark->green)/G_MAXUINT16);
float b = (value) * (((float)bright->blue)/G_MAXUINT16) + (1.0-value)*(((float)dark->blue)/G_MAXUINT16);
//colored arc
cairo_set_source_rgb (cr, r,g,b);
cairo_set_line_width (cr, progress_width);
cairo_arc (cr, xc, yc, progress_radius, start_angle, value_angle);
cairo_stroke (cr);
//overall shade
cairo_pattern_t* shade_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, progress_radius_outer);
cairo_pattern_add_color_stop_rgba (shade_pattern, 0, 1,1,1, 0.3);
cairo_pattern_add_color_stop_rgba (shade_pattern, 1, 1,1,1, 0.0);
cairo_set_source (cr, shade_pattern);
cairo_arc (cr, xc, yc, progress_radius_outer-1, 0, 2.0*G_PI);
cairo_fill (cr);
cairo_pattern_destroy (shade_pattern);
//black border
cairo_set_source_rgb (cr, 0, 0, 0 );
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_width (cr, 1.0/scale_factor);
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);
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);
cairo_arc (cr, xc, yc, progress_radius_outer, start_angle, end_angle);
cairo_stroke (cr);
cairo_arc (cr, xc, yc, progress_radius_inner, start_angle, end_angle);
cairo_stroke (cr);
//knob shadow
cairo_save(cr);
cairo_translate(cr, 6, 6 );
cairo_set_source_rgba (cr, 0,0,0,0.1 );
cairo_arc (cr, xc, yc, progress_radius_inner-1, 0, 2.0*G_PI);
cairo_fill (cr);
cairo_restore(cr);
//inner circle
cairo_set_source_rgba (cr, 0.3, 0.3, 0.3, 1 );
cairo_arc (cr, xc, yc, progress_radius_inner-1, 0, 2.0*G_PI);
cairo_fill (cr);
//knob shade
shade_pattern = cairo_pattern_create_linear (0.0, 0.0, 0.0, progress_radius_outer);
cairo_pattern_add_color_stop_rgba (shade_pattern, 0, 1,1,1, 0.5);
cairo_pattern_add_color_stop_rgba (shade_pattern, 1, 0,0,0, 0.3);
cairo_set_source (cr, shade_pattern);
cairo_arc (cr, xc, yc, progress_radius_inner-1, 0, 2.0*G_PI);
cairo_fill (cr);
cairo_pattern_destroy (shade_pattern);
//inner circle
cairo_set_source_rgba (cr, 0.3, 0.3, 0.3, 0.5 );
cairo_arc (cr, xc, yc, progress_radius_inner-5, 0, 2.0*G_PI);
cairo_fill (cr);
//line
cairo_save(cr);
cairo_translate(cr, 2, 2 );
cairo_set_source_rgba (cr, 0,0,0,0.5 );
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_width (cr, 4);
cairo_move_to (cr, xc + (progress_radius_inner * value_x), yc + (progress_radius_inner * value_y));
cairo_line_to (cr, xc + ((progress_radius_inner*0.4) * value_x), yc + ((progress_radius_inner*0.4) * value_y));
cairo_stroke (cr);
cairo_restore(cr);
cairo_set_source_rgba (cr, 1,1,1,0.7 );
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_width (cr, 4.0);
cairo_move_to (cr, xc + (progress_radius_inner * value_x), yc + (progress_radius_inner * value_y));
cairo_line_to (cr, xc + ((progress_radius_inner*0.4) * value_x), yc + ((progress_radius_inner*0.4) * value_y));
cairo_stroke (cr);
//highlight if focused (damn, this is a cached image which doesn't (yet) have a "focused" state
// if (pixwin.has_focus()) {
// cairo_set_source_rgba (cr, 1,1,1, 0.5 );
// cairo_arc (cr, xc, yc, progress_radius_inner-1, 0, 2.0*G_PI);
// cairo_fill (cr);
// }
}
void
MotionFeedback::set_lamp_color (const std::string& str)
{
if (base_color) {
*base_color = Gdk::Color (str);
} else {
base_color = new Gdk::Color (str);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -47,10 +47,8 @@ gtkmm2ext_sources = [
'gtkapplication.c',
'idle_adjustment.cc',
'keyboard.cc',
'motionfeedback.cc',
'paths_dialog.cc',
'persistent_tooltip.cc',
'prolooks_helpers.c',
'pixfader.cc',
'pixscroller.cc',
'popup.cc',