summaryrefslogtreecommitdiff
path: root/plugins/gtkui/ddbequalizer.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-10-23 11:50:41 +0200
committerGravatar waker <wakeroid@gmail.com>2011-10-23 11:50:41 +0200
commita9c813ddbda28a2d0beff104fe8cf80299292533 (patch)
tree5630dfd20c5e4484148dc4fde06fdb2a0e9aeefa /plugins/gtkui/ddbequalizer.c
parent2f2937a5554d4cdca177eb546a0e0c449b16c700 (diff)
parent50208fdf54d7afaf8b42abc511ddc675b9475184 (diff)
Merge branch 'master' into devel
Conflicts: deadbeef.h metacache.c playlist.c plugins.c plugins/gtkui/Makefile.am plugins/gtkui/ddbcellrenderertextmultiline.c plugins/gtkui/ddbcellrenderertextmultiline.h plugins/gtkui/ddbequalizer.c plugins/gtkui/ddbequalizer.h plugins/gtkui/ddbseekbar.c plugins/gtkui/ddbseekbar.h plugins/gtkui/ddbtabstrip.c plugins/gtkui/fileman.c plugins/gtkui/gtkui.c plugins/gtkui/interface.c plugins/gtkui/plcommon.c plugins/gtkui/trkproperties.c
Diffstat (limited to 'plugins/gtkui/ddbequalizer.c')
-rw-r--r--plugins/gtkui/ddbequalizer.c890
1 files changed, 543 insertions, 347 deletions
diff --git a/plugins/gtkui/ddbequalizer.c b/plugins/gtkui/ddbequalizer.c
index cf1c10eb..8f69f073 100644
--- a/plugins/gtkui/ddbequalizer.c
+++ b/plugins/gtkui/ddbequalizer.c
@@ -1,6 +1,3 @@
-/* ddbequalizer.c generated by valac, the Vala compiler
- * generated from ddbequalizer.vala, do not modify */
-
/*
SuperEQ GTK Widget for for DeaDBeeF
Copyright (C) 2010 Viktor Semykin <thesame.ml@gmail.com>
@@ -28,8 +25,10 @@
#include <float.h>
#include <math.h>
#include <gdk/gdk.h>
-#include <gtkui.h>
#include <drawing.h>
+#include <gtkui.h>
+#include <cairo.h>
+#include <pango/pangocairo.h>
#include <pango/pango.h>
@@ -46,7 +45,7 @@ typedef struct _DdbEqualizerPrivate DdbEqualizerPrivate;
#define _gdk_cursor_unref0(var) ((var == NULL) ? NULL : (var = (gdk_cursor_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
-#define _pango_font_description_free0(var) ((var == NULL) ? NULL : (var = (pango_font_description_free (var), NULL)))
+#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))
struct _DdbEqualizer {
GtkDrawingArea parent_instance;
@@ -58,15 +57,15 @@ struct _DdbEqualizerClass {
};
struct _DdbEqualizerPrivate {
- double* values;
+ gdouble* values;
gint values_length1;
gint _values_size_;
- double preamp;
+ gdouble preamp;
gint mouse_y;
gboolean curve_hook;
gboolean preamp_hook;
- gint margin_bottom;
- gint margin_left;
+ gint eq_margin_bottom;
+ gint eq_margin_left;
GdkCursor* pointer_cursor;
};
@@ -82,31 +81,51 @@ enum {
#define DDB_EQUALIZER_spot_size 3
static gboolean ddb_equalizer_real_configure_event (GtkWidget* base, GdkEventConfigure* event);
static void ddb_equalizer_real_realize (GtkWidget* base);
-static inline double ddb_equalizer_scale (DdbEqualizer* self, double val);
+#if !GTK_CHECK_VERSION(3,0,0)
static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose* event);
-static gboolean ddb_equalizer_in_curve_area (DdbEqualizer* self, double x, double y);
-static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, double x, double y);
+#endif
+static inline gdouble ddb_equalizer_scale (DdbEqualizer* self, gdouble val);
+static gboolean ddb_equalizer_in_curve_area (DdbEqualizer* self, gdouble x, gdouble y);
+static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, gdouble x, gdouble y);
static gboolean ddb_equalizer_real_button_press_event (GtkWidget* base, GdkEventButton* event);
static gboolean ddb_equalizer_real_button_release_event (GtkWidget* base, GdkEventButton* event);
static gboolean ddb_equalizer_real_leave_notify_event (GtkWidget* base, GdkEventCrossing* event);
static gboolean ddb_equalizer_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event);
-void ddb_equalizer_set_band (DdbEqualizer* self, gint band, double v);
-double ddb_equalizer_get_band (DdbEqualizer* self, gint band);
-void ddb_equalizer_set_preamp (DdbEqualizer* self, double v);
-double ddb_equalizer_get_preamp (DdbEqualizer* self);
+void ddb_equalizer_set_band (DdbEqualizer* self, gint band, gdouble v);
+gdouble ddb_equalizer_get_band (DdbEqualizer* self, gint band);
+void ddb_equalizer_set_preamp (DdbEqualizer* self, gdouble v);
+gdouble ddb_equalizer_get_preamp (DdbEqualizer* self);
DdbEqualizer* ddb_equalizer_new (void);
DdbEqualizer* ddb_equalizer_construct (GType object_type);
static GObject * ddb_equalizer_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void ddb_equalizer_finalize (GObject* obj);
-const char* freqs[18] = {"55 Hz", "77 Hz", "110 Hz", "156 Hz", "220 Hz", "311 Hz", "440 Hz", "622 Hz", "880 Hz", "1.2 kHz", "1.8 kHz", "2.5 kHz", "3.5 kHz", "5 kHz", "7 kHz", "10 kHz", "14 kHz", "20 kHz"};
-
+const gchar* freqs[18] = {"55 Hz", "77 Hz", "110 Hz", "156 Hz", "220 Hz", "311 Hz", "440 Hz", "622 Hz", "880 Hz", "1.2 kHz", "1.8 kHz", "2.5 kHz", "3.5 kHz", "5 kHz", "7 kHz", "10 kHz", "14 kHz", "20 kHz"};
static gboolean ddb_equalizer_real_configure_event (GtkWidget* base, GdkEventConfigure* event) {
DdbEqualizer * self;
gboolean result = FALSE;
self = (DdbEqualizer*) base;
+ g_return_val_if_fail (event != NULL, FALSE);
gtkui_init_theme_colors ();
+
+ GtkStyle* _tmp0_ = NULL;
+ const PangoFontDescription* _tmp1_;
+ gint _tmp2_ = 0;
+ gdouble _tmp3_ = 0.0;
+ GdkScreen* _tmp4_ = NULL;
+ gdouble _tmp5_ = 0.0;
+ gint _tmp6_;
+
+ _tmp0_ = gtk_widget_get_style ((GtkWidget*) self);
+ _tmp1_ = _tmp0_->font_desc;
+ _tmp2_ = pango_font_description_get_size (_tmp1_);
+ _tmp3_ = pango_units_to_double (_tmp2_);
+ _tmp4_ = gdk_screen_get_default ();
+ _tmp5_ = gdk_screen_get_resolution (_tmp4_);
+ self->priv->eq_margin_bottom = (gint) (((_tmp3_ * _tmp5_) / 72) + 4);
+ _tmp6_ = self->priv->eq_margin_bottom;
+ self->priv->eq_margin_left = _tmp6_ * 4;
result = FALSE;
return result;
}
@@ -125,317 +144,351 @@ static gpointer _g_object_ref0 (gpointer self) {
}
+static gboolean ddb_equalizer_real_draw (GtkWidget *widget, cairo_t *cr) {
+ DdbEqualizer *self = DDB_EQUALIZER (widget);
+ GdkColor fore_bright_color;
+ gtkui_get_bar_foreground_color (&fore_bright_color);
+ GdkColor c1 = fore_bright_color;
+ GdkColor c2;
+ gtkui_get_bar_background_color (&c2);
+ GdkColor fore_dark_color = c2;
+
+ fore_dark_color.red += (c1.red - c2.red) * 0.5;
+ fore_dark_color.green += (c1.green - c2.green) * 0.5;
+ fore_dark_color.blue += (c1.blue - c2.blue) * 0.5;
+
+ GtkAllocation alloc;
+ gtk_widget_get_allocation (widget, &alloc);
+
+ int width = alloc.width;
+ int height = alloc.height;
+
+ cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
+ cairo_set_line_width (cr, 1.0);
+ gdk_cairo_set_source_color (cr, &c2);
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_fill (cr);
+
+ gdk_cairo_set_source_color (cr, &fore_dark_color);
+
+ //drawing grid:
+ double step = (double)(width - self->priv->eq_margin_left) / (double)(DDB_EQUALIZER_bands+1);
+ int i;
+ for (i = 0; i < DDB_EQUALIZER_bands; i++)
+ {
+ //does anyone know why this method is static?
+ cairo_move_to (cr, (int)((i+1)*step)+self->priv->eq_margin_left, 0);
+ cairo_line_to (cr, (int)((i+1)*step)+self->priv->eq_margin_left, height - self->priv->eq_margin_bottom);
+ }
+
+ double vstep = (double)(height-self->priv->eq_margin_bottom);
+ for (double di=0; di < 2; di += 0.25)
+ {
+ cairo_move_to (cr, self->priv->eq_margin_left, (int)((di-self->priv->preamp)*vstep));
+ cairo_line_to (cr, width, (int)((di-self->priv->preamp)*vstep));
+ }
+ cairo_stroke (cr);
+
+ gdk_cairo_set_source_color (cr, &fore_bright_color);
+
+ //drawing freqs:
+
+ PangoLayout *l = pango_cairo_create_layout (cr);
+ PangoContext *pctx = pango_layout_get_context (l);
+
+ GtkStyle *st = gtk_widget_get_style (widget);
+
+ PangoFontDescription *fd = pango_font_description_copy (st->font_desc);
+
+ pango_font_description_set_size (fd, (int)(pango_font_description_get_size (st->font_desc) * 0.7));
+ pango_context_set_font_description (pctx, fd);
+ for (i = 0; i < DDB_EQUALIZER_bands; i++)
+ {
+ cairo_save (cr);
+ pango_layout_set_text (l, freqs[i], strlen (freqs[i]));
+ PangoRectangle ink, log;
+ pango_layout_get_pixel_extents (l, &ink, &log);
+ int offs = 2;
+ if ((i % 2) != 0) {
+ offs += 2;
+ }
+ cairo_move_to (cr, (int)((i+1)*step)+self->priv->eq_margin_left - ink.width/2, height-self->priv->eq_margin_bottom + offs);
+ pango_cairo_show_layout (cr, l);
+ cairo_restore (cr);
+ }
+ pango_font_description_set_size (fd, (int)(pango_font_description_get_size (st->font_desc)));
+ pango_context_set_font_description (pctx, fd);
+
+ //drawing db's:
+ pango_layout_set_width (l, self->priv->eq_margin_left-1);
+ pango_layout_set_alignment (l, PANGO_ALIGN_RIGHT);
+
+ int fontsize = (int)(pango_units_to_double (pango_font_description_get_size (fd)) * gdk_screen_get_resolution (gdk_screen_get_default ()) / 72);
+
+ char tmp[100];
+
+ if ((self->priv->mouse_y >= 0) && (self->priv->mouse_y < height - self->priv->eq_margin_bottom))
+ {
+ cairo_save (cr);
+ double db = ddb_equalizer_scale(self, (double)(self->priv->mouse_y-1) / (double)(height - self->priv->eq_margin_bottom - 2));
+ snprintf (tmp, sizeof (tmp), "%s%.1fdB", db > 0 ? "+" : "", db);
+ pango_layout_set_text (l, tmp, strlen (tmp));
+ cairo_move_to (cr, self->priv->eq_margin_left-1, self->priv->mouse_y-3);
+ pango_cairo_show_layout (cr, l);
+ cairo_restore (cr);
+ }
+
+ cairo_save (cr);
+ double val = ddb_equalizer_scale(self, 1);
+ snprintf (tmp, sizeof (tmp), "%s%.1fdB", val > 0 ? "+" : "", val);
+ pango_layout_set_text (l, tmp, strlen(tmp));
+ cairo_move_to (cr, self->priv->eq_margin_left-1, height-self->priv->eq_margin_bottom-fontsize);
+ pango_cairo_show_layout (cr, l);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ val = ddb_equalizer_scale(self, 0);
+ snprintf (tmp, sizeof (tmp), "%s%.1fdB", val > 0 ? "+" : "", val);
+ pango_layout_set_text (l, tmp, strlen (tmp));
+ cairo_move_to (cr, self->priv->eq_margin_left-1, 1);
+ pango_cairo_show_layout (cr, l);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ pango_layout_set_text (l, "+0dB", 4);
+ cairo_move_to (cr, self->priv->eq_margin_left-1, (int)((1-self->priv->preamp)*(height-self->priv->eq_margin_bottom))-fontsize/2);
+ pango_cairo_show_layout (cr, l);
+ cairo_restore (cr);
+
+ cairo_save (cr);
+ pango_layout_set_text (l, "preamp", 6);
+ pango_layout_set_alignment (l, PANGO_ALIGN_LEFT);
+ cairo_move_to (cr, 1, height-self->priv->eq_margin_bottom+2);
+ pango_cairo_show_layout (cr, l);
+ cairo_restore (cr);
+
+ // frame
+ cairo_rectangle (cr, self->priv->eq_margin_left, 0, width-self->priv->eq_margin_left, height-self->priv->eq_margin_bottom);
+ cairo_stroke (cr);
+
+ //draw preamp
+ cairo_rectangle (cr, 0, (int)(self->priv->preamp * (height-self->priv->eq_margin_bottom)), 11, height);
+ cairo_clip (cr);
+
+ gdk_cairo_set_source_color (cr, &fore_bright_color);
+ int count = (int)((height-self->priv->eq_margin_bottom) / 6)+1;
+ for (int j = 0; j < count; j++) {
+ cairo_rectangle (cr, 1, height-self->priv->eq_margin_bottom-j*6 - 6, 11, 4);
+ }
+ cairo_fill (cr);
+ cairo_reset_clip (cr);
+
+ //drawing bars:
+ int bar_w = 11;
+ if (step < bar_w)
+ bar_w = (int)step-1;
+
+
+ for (i = 0; i < DDB_EQUALIZER_bands; i++)
+ {
+ cairo_reset_clip (cr);
+ cairo_rectangle (cr, (int)((i+1)*step)+self->priv->eq_margin_left - bar_w/2, (int)(self->priv->values[i] * (height-self->priv->eq_margin_bottom)), 11, height);
+ cairo_clip (cr);
+ count = (int)((height-self->priv->eq_margin_bottom) * (1-self->priv->values[i]) / 6)+1;
+ for (int j = 0; j < count; j++) {
+ cairo_rectangle (cr, (int)((i+1)*step)+self->priv->eq_margin_left - bar_w/2, height-self->priv->eq_margin_bottom-j*6 - 6, bar_w, 4);
+ }
+ cairo_fill (cr);
+ }
+
+ //drawing mouse coordinates:
+ cairo_reset_clip (cr);
+ double dash[] = {4, 4};
+ cairo_set_dash (cr, dash, 2, 0);
+ cairo_move_to (cr, self->priv->eq_margin_left+1, self->priv->mouse_y);
+ cairo_line_to (cr, width, self->priv->mouse_y);
+ cairo_stroke (cr);
+
+ return FALSE;
+}
+
+#if !GTK_CHECK_VERSION(3,0,0)
static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose* event) {
- DdbEqualizer * self;
- gboolean result = FALSE;
- GdkColor _tmp0_ = {0};
- GdkColor fore_bright_color;
- GdkColor c1;
- GdkColor _tmp1_ = {0};
- GdkColor c2;
- GdkColor fore_dark_color;
- gint width;
- gint height;
- GdkDrawable* d;
- GdkGCValues _tmp3_;
- GdkGCValues _tmp2_ = {0};
- GdkGC* gc;
- double step;
- gint i = 0;
- double vstep;
- PangoLayout* l;
- PangoContext* ctx;
- PangoFontDescription* fd;
- gint fontsize;
- gboolean _tmp7_ = FALSE;
- char* tmp;
- double val;
- const char* _tmp9_;
- char* _tmp10_;
- const char* _tmp11_;
- char* _tmp12_;
- GdkRectangle _tmp14_;
- GdkRectangle _tmp13_ = {0};
- gint count;
- GdkRectangle _tmp17_;
- GdkRectangle _tmp16_ = {0};
- gint bar_w;
- GdkRectangle _tmp23_;
- GdkRectangle _tmp22_ = {0};
- self = (DdbEqualizer*) base;
- fore_bright_color = (gtkui_get_bar_foreground_color (&_tmp0_), _tmp0_);
- c1 = fore_bright_color;
- c2 = (gtkui_get_bar_background_color (&_tmp1_), _tmp1_);
- fore_dark_color = c2;
- fore_dark_color.red = fore_dark_color.red + ((guint16) ((gint16) ((c1.red - c2.red) * 0.5)));
- fore_dark_color.green = fore_dark_color.green + ((guint16) ((gint16) ((c1.green - c2.green) * 0.5)));
- fore_dark_color.blue = fore_dark_color.blue + ((guint16) ((gint16) ((c1.blue - c2.blue) * 0.5)));
- width = ((GtkWidget*) self)->allocation.width;
- height = ((GtkWidget*) self)->allocation.height;
- d = _g_object_ref0 ((GdkDrawable*) gtk_widget_get_window ((GtkWidget*) self));
- gc = _g_object_ref0 (GDK_DRAWABLE_GET_CLASS (d)->create_gc (d, (_tmp3_ = (memset (&_tmp2_, 0, sizeof (GdkGCValues)), _tmp2_), &_tmp3_), 0));
- gdk_gc_set_rgb_fg_color (gc, &c2);
- gdk_draw_rectangle (d, gc, TRUE, 0, 0, width, height);
- gdk_gc_set_rgb_fg_color (gc, &fore_dark_color);
- step = ((double) (width - self->priv->margin_left)) / ((double) (DDB_EQUALIZER_bands + 1));
- {
- gboolean _tmp4_;
- i = 0;
- _tmp4_ = TRUE;
- while (TRUE) {
- if (!_tmp4_) {
- i++;
- }
- _tmp4_ = FALSE;
- if (!(i < DDB_EQUALIZER_bands)) {
- break;
- }
- gdk_draw_line (d, gc, ((gint) ((i + 1) * step)) + self->priv->margin_left, 0, ((gint) ((i + 1) * step)) + self->priv->margin_left, height - self->priv->margin_bottom);
- }
- }
- vstep = (double) (height - self->priv->margin_bottom);
- {
- double di;
- di = (double) 0;
- {
- gboolean _tmp5_;
- _tmp5_ = TRUE;
- while (TRUE) {
- if (!_tmp5_) {
- di = di + 0.25;
- }
- _tmp5_ = FALSE;
- if (!(di < 2)) {
- break;
- }
- gdk_draw_line (d, gc, self->priv->margin_left, (gint) ((di - self->priv->preamp) * vstep), width, (gint) ((di - self->priv->preamp) * vstep));
- }
- }
- }
- gdk_gc_set_rgb_fg_color (gc, &fore_bright_color);
- l = gtk_widget_create_pango_layout ((GtkWidget*) self, NULL);
- ctx = _g_object_ref0 (pango_layout_get_context (l));
- fd = pango_font_description_copy (gtk_widget_get_style ((GtkWidget*) self)->font_desc);
- pango_font_description_set_size (fd, (gint) (pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc) * 0.7));
- pango_context_set_font_description (ctx, fd);
- {
- gboolean _tmp6_;
- i = 0;
- _tmp6_ = TRUE;
- while (TRUE) {
- PangoRectangle ink = {0};
- PangoRectangle log = {0};
- gint offs;
- if (!_tmp6_) {
- i++;
- }
- _tmp6_ = FALSE;
- if (!(i < DDB_EQUALIZER_bands)) {
- break;
- }
- pango_layout_set_text (l, freqs[i], (gint) g_utf8_strlen (freqs[i], -1));
- pango_layout_get_pixel_extents (l, &ink, &log);
- offs = 2;
- if ((i % 2) != 0) {
- offs = offs + 2;
- }
- gdk_draw_layout (d, gc, (((gint) ((i + 1) * step)) + self->priv->margin_left) - (ink.width / 2), (height - self->priv->margin_bottom) + offs, l);
- }
- }
- pango_font_description_set_size (fd, (gint) pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc));
- pango_context_set_font_description (ctx, fd);
- pango_layout_set_width (l, self->priv->margin_left - 1);
- pango_layout_set_alignment (l, PANGO_ALIGN_RIGHT);
- fontsize = (gint) ((pango_units_to_double (pango_font_description_get_size (fd)) * gdk_screen_get_resolution (gdk_screen_get_default ())) / 72);
- if (self->priv->mouse_y >= 0) {
- _tmp7_ = self->priv->mouse_y < (height - self->priv->margin_bottom);
- } else {
- _tmp7_ = FALSE;
- }
- if (_tmp7_) {
- double db;
- const char* _tmp8_;
- char* tmp;
- db = ddb_equalizer_scale (self, ((double) (self->priv->mouse_y - 1)) / ((double) ((height - self->priv->margin_bottom) - 2)));
- _tmp8_ = NULL;
- if (db > 0) {
- _tmp8_ = "+";
- } else {
- _tmp8_ = "";
- }
- tmp = g_strdup_printf ("%s%.1fdB", _tmp8_, db);
- pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1));
- gdk_draw_layout (d, gc, self->priv->margin_left - 1, self->priv->mouse_y - 3, l);
- _g_free0 (tmp);
- }
- tmp = NULL;
- val = ddb_equalizer_scale (self, (double) 1);
- _tmp9_ = NULL;
- if (val > 0) {
- _tmp9_ = "+";
- } else {
- _tmp9_ = "";
- }
- tmp = (_tmp10_ = g_strdup_printf ("%s%.1fdB", _tmp9_, val), _g_free0 (tmp), _tmp10_);
- pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1));
- gdk_draw_layout (d, gc, self->priv->margin_left - 1, (height - self->priv->margin_bottom) - fontsize, l);
- val = ddb_equalizer_scale (self, (double) 0);
- _tmp11_ = NULL;
- if (val > 0) {
- _tmp11_ = "+";
- } else {
- _tmp11_ = "";
- }
- tmp = (_tmp12_ = g_strdup_printf ("%s%.1fdB", _tmp11_, val), _g_free0 (tmp), _tmp12_);
- pango_layout_set_text (l, tmp, (gint) g_utf8_strlen (tmp, -1));
- gdk_draw_layout (d, gc, self->priv->margin_left - 1, 1, l);
- pango_layout_set_text (l, "+0dB", 4);
- gdk_draw_layout (d, gc, self->priv->margin_left - 1, ((gint) ((1 - self->priv->preamp) * (height - self->priv->margin_bottom))) - (fontsize / 2), l);
- pango_layout_set_text (l, "preamp", 6);
- pango_layout_set_alignment (l, PANGO_ALIGN_LEFT);
- gdk_draw_layout (d, gc, 1, (height - self->priv->margin_bottom) + 2, l);
- gdk_draw_rectangle (d, gc, FALSE, self->priv->margin_left, 0, (width - self->priv->margin_left) - 1, (height - self->priv->margin_bottom) - 1);
- gdk_gc_set_line_attributes (gc, 2, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
- gdk_gc_set_clip_rectangle (gc, (_tmp14_ = (_tmp13_.x = 0, _tmp13_.y = (gint) (self->priv->preamp * (height - self->priv->margin_bottom)), _tmp13_.width = 11, _tmp13_.height = height, _tmp13_), &_tmp14_));
- gdk_gc_set_rgb_fg_color (gc, &fore_bright_color);
- count = ((gint) ((height - self->priv->margin_bottom) / 6)) + 1;
- {
- gint j;
- j = 0;
- {
- gboolean _tmp15_;
- _tmp15_ = TRUE;
- while (TRUE) {
- if (!_tmp15_) {
- j++;
- }
- _tmp15_ = FALSE;
- if (!(j < count)) {
- break;
- }
- gdk_draw_rectangle (d, gc, TRUE, 1, ((height - self->priv->margin_bottom) - (j * 6)) - 6, 11, 4);
- }
- }
- }
- gdk_gc_set_clip_rectangle (gc, (_tmp17_ = (_tmp16_.x = self->priv->margin_left + 1, _tmp16_.y = 1, _tmp16_.width = (width - self->priv->margin_left) - 2, _tmp16_.height = (height - self->priv->margin_bottom) - 2, _tmp16_), &_tmp17_));
- gdk_gc_set_rgb_fg_color (gc, &fore_bright_color);
- bar_w = 11;
- if (step < bar_w) {
- bar_w = ((gint) step) - 1;
- }
- {
- gboolean _tmp18_;
- i = 0;
- _tmp18_ = TRUE;
- while (TRUE) {
- GdkRectangle _tmp20_;
- GdkRectangle _tmp19_ = {0};
- if (!_tmp18_) {
- i++;
- }
- _tmp18_ = FALSE;
- if (!(i < DDB_EQUALIZER_bands)) {
- break;
- }
- gdk_gc_set_clip_rectangle (gc, (_tmp20_ = (_tmp19_.x = (((gint) ((i + 1) * step)) + self->priv->margin_left) - (bar_w / 2), _tmp19_.y = (gint) (self->priv->values[i] * (height - self->priv->margin_bottom)), _tmp19_.width = 11, _tmp19_.height = height, _tmp19_), &_tmp20_));
- count = ((gint) (((height - self->priv->margin_bottom) * (1 - self->priv->values[i])) / 6)) + 1;
- {
- gint j;
- j = 0;
- {
- gboolean _tmp21_;
- _tmp21_ = TRUE;
- while (TRUE) {
- if (!_tmp21_) {
- j++;
- }
- _tmp21_ = FALSE;
- if (!(j < count)) {
- break;
- }
- gdk_draw_rectangle (d, gc, TRUE, (((gint) ((i + 1) * step)) + self->priv->margin_left) - (bar_w / 2), ((height - self->priv->margin_bottom) - (j * 6)) - 6, bar_w, 4);
- }
- }
- }
- }
- }
- gdk_gc_set_clip_rectangle (gc, (_tmp23_ = (_tmp22_.x = 0, _tmp22_.y = 0, _tmp22_.width = width, _tmp22_.height = height, _tmp22_), &_tmp23_));
- gdk_gc_set_line_attributes (gc, 1, GDK_LINE_ON_OFF_DASH, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
- gdk_draw_line (d, gc, self->priv->margin_left + 1, self->priv->mouse_y, width, self->priv->mouse_y);
- result = FALSE;
- _g_object_unref0 (d);
- _g_object_unref0 (gc);
- _g_object_unref0 (l);
- _g_object_unref0 (ctx);
- _pango_font_description_free0 (fd);
- _g_free0 (tmp);
- return result;
+ g_return_val_if_fail (event != NULL, FALSE);
+ cairo_t *cr= gdk_cairo_create ((GdkDrawable*) gtk_widget_get_window (base));
+ ddb_equalizer_real_draw (base, cr);
+ _cairo_destroy0 (cr);
+ return FALSE;
}
+#endif
-static inline double ddb_equalizer_scale (DdbEqualizer* self, double val) {
- double result = 0.0;
- double k;
- double d;
+static inline gdouble ddb_equalizer_scale (DdbEqualizer* self, gdouble val) {
+ gdouble result = 0.0;
+ gdouble k;
+ gdouble d;
+ gdouble _tmp0_;
+ gdouble _tmp1_;
g_return_val_if_fail (self != NULL, 0.0);
- k = (double) (-40);
- d = (double) 20;
- result = (((val + self->priv->preamp) - 0.5) * k) + d;
+ k = (gdouble) (-40);
+ d = (gdouble) 20;
+ _tmp0_ = val;
+ _tmp1_ = self->priv->preamp;
+ result = (((_tmp0_ + _tmp1_) - 0.5) * k) + d;
return result;
}
-static gboolean ddb_equalizer_in_curve_area (DdbEqualizer* self, double x, double y) {
+static gboolean ddb_equalizer_in_curve_area (DdbEqualizer* self, gdouble x, gdouble y) {
gboolean result = FALSE;
gboolean _tmp0_ = FALSE;
gboolean _tmp1_ = FALSE;
gboolean _tmp2_ = FALSE;
+ gdouble _tmp3_;
+ gint _tmp4_;
+ gboolean _tmp8_;
+ gboolean _tmp10_;
+ gboolean _tmp15_;
g_return_val_if_fail (self != NULL, FALSE);
- if (x > self->priv->margin_left) {
- _tmp2_ = x < (((GtkWidget*) self)->allocation.width - 1);
+ _tmp3_ = x;
+ _tmp4_ = self->priv->eq_margin_left;
+ GtkAllocation _tmp6_;
+ gtk_widget_get_allocation ((GtkWidget*) self, &_tmp6_);
+ if (_tmp3_ > ((gdouble) _tmp4_)) {
+ gdouble _tmp5_;
+ gint _tmp7_;
+ _tmp5_ = x;
+ _tmp7_ = _tmp6_.width;
+ _tmp2_ = _tmp5_ < ((gdouble) (_tmp7_ - 1));
} else {
_tmp2_ = FALSE;
}
- if (_tmp2_) {
- _tmp1_ = y > 1;
+ _tmp8_ = _tmp2_;
+ if (_tmp8_) {
+ gdouble _tmp9_;
+ _tmp9_ = y;
+ _tmp1_ = _tmp9_ > ((gdouble) 1);
} else {
_tmp1_ = FALSE;
}
- if (_tmp1_) {
- _tmp0_ = y < (((GtkWidget*) self)->allocation.height - self->priv->margin_bottom);
+ _tmp10_ = _tmp1_;
+ if (_tmp10_) {
+ gdouble _tmp11_;
+ GtkAllocation _tmp12_;
+ gint _tmp13_;
+ gint _tmp14_;
+ _tmp11_ = y;
+ _tmp13_ = _tmp6_.height;
+ _tmp14_ = self->priv->eq_margin_bottom;
+ _tmp0_ = _tmp11_ < ((gdouble) (_tmp13_ - _tmp14_));
} else {
_tmp0_ = FALSE;
}
- result = _tmp0_;
+ _tmp15_ = _tmp0_;
+ result = _tmp15_;
return result;
}
-static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, double x, double y) {
- double band_width;
+static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, gdouble x, gdouble y) {
+ GtkAllocation _tmp0_;
+ gint _tmp1_;
+ gint _tmp2_;
+ gdouble band_width;
+ gdouble _tmp3_;
+ gint _tmp4_;
+ gdouble _tmp5_;
+ gdouble _tmp6_ = 0.0;
gint band;
- gboolean _tmp0_ = FALSE;
+ gint _tmp7_;
+ gint _tmp8_;
+ gboolean _tmp10_ = FALSE;
+ gint _tmp11_;
+ gboolean _tmp13_;
g_return_if_fail (self != NULL);
- band_width = ((double) (((GtkWidget*) self)->allocation.width - self->priv->margin_left)) / ((double) (DDB_EQUALIZER_bands + 1));
- band = (gint) floor (((x - self->priv->margin_left) / band_width) - 0.5);
- if (band < 0) {
+ gtk_widget_get_allocation ((GtkWidget*) self, &_tmp0_);
+ _tmp1_ = _tmp0_.width;
+ _tmp2_ = self->priv->eq_margin_left;
+ band_width = ((gdouble) (_tmp1_ - _tmp2_)) / ((gdouble) (DDB_EQUALIZER_bands + 1));
+ _tmp3_ = x;
+ _tmp4_ = self->priv->eq_margin_left;
+ _tmp5_ = band_width;
+ _tmp6_ = floor (((_tmp3_ - _tmp4_) / _tmp5_) - 0.5);
+ band = (gint) _tmp6_;
+ _tmp7_ = band;
+ if (_tmp7_ < 0) {
band = 0;
}
- if (band >= DDB_EQUALIZER_bands) {
- band = band - 1;
+ _tmp8_ = band;
+ if (_tmp8_ >= DDB_EQUALIZER_bands) {
+ gint _tmp9_;
+ _tmp9_ = band;
+ band = _tmp9_ - 1;
}
- if (band >= 0) {
- _tmp0_ = band < DDB_EQUALIZER_bands;
+ _tmp11_ = band;
+ if (_tmp11_ >= 0) {
+ gint _tmp12_;
+ _tmp12_ = band;
+ _tmp10_ = _tmp12_ < DDB_EQUALIZER_bands;
} else {
- _tmp0_ = FALSE;
+ _tmp10_ = FALSE;
}
- if (_tmp0_) {
- self->priv->values[band] = y / ((double) (((GtkWidget*) self)->allocation.height - self->priv->margin_bottom));
- if (self->priv->values[band] > 1) {
- self->priv->values[band] = (double) 1;
+ _tmp13_ = _tmp10_;
+ if (_tmp13_) {
+ gdouble* _tmp14_;
+ gint _tmp14__length1;
+ gint _tmp15_;
+ gdouble _tmp16_;
+ GtkAllocation _tmp17_;
+ gint _tmp18_;
+ gint _tmp19_;
+ gdouble _tmp20_;
+ gdouble* _tmp21_;
+ gint _tmp21__length1;
+ gint _tmp22_;
+ gdouble _tmp23_;
+ _tmp14_ = self->priv->values;
+ _tmp14__length1 = self->priv->values_length1;
+ _tmp15_ = band;
+ _tmp16_ = y;
+ gtk_widget_get_allocation ((GtkWidget*) self, &_tmp17_);
+ _tmp18_ = _tmp17_.height;
+ _tmp19_ = self->priv->eq_margin_bottom;
+ _tmp14_[_tmp15_] = _tmp16_ / ((gdouble) (_tmp18_ - _tmp19_));
+ _tmp20_ = _tmp14_[_tmp15_];
+ _tmp21_ = self->priv->values;
+ _tmp21__length1 = self->priv->values_length1;
+ _tmp22_ = band;
+ _tmp23_ = _tmp21_[_tmp22_];
+ if (_tmp23_ > ((gdouble) 1)) {
+ gdouble* _tmp24_;
+ gint _tmp24__length1;
+ gint _tmp25_;
+ gdouble _tmp26_;
+ _tmp24_ = self->priv->values;
+ _tmp24__length1 = self->priv->values_length1;
+ _tmp25_ = band;
+ _tmp24_[_tmp25_] = (gdouble) 1;
+ _tmp26_ = _tmp24_[_tmp25_];
} else {
- if (self->priv->values[band] < 0) {
- self->priv->values[band] = (double) 0;
+ gdouble* _tmp27_;
+ gint _tmp27__length1;
+ gint _tmp28_;
+ gdouble _tmp29_;
+ _tmp27_ = self->priv->values;
+ _tmp27__length1 = self->priv->values_length1;
+ _tmp28_ = band;
+ _tmp29_ = _tmp27_[_tmp28_];
+ if (_tmp29_ < ((gdouble) 0)) {
+ gdouble* _tmp30_;
+ gint _tmp30__length1;
+ gint _tmp31_;
+ gdouble _tmp32_;
+ _tmp30_ = self->priv->values;
+ _tmp30__length1 = self->priv->values_length1;
+ _tmp31_ = band;
+ _tmp30_[_tmp31_] = (gdouble) 0;
+ _tmp32_ = _tmp30_[_tmp31_];
}
}
g_signal_emit_by_name (self, "on-changed");
@@ -446,38 +499,103 @@ static void ddb_equalizer_update_eq_drag (DdbEqualizer* self, double x, double y
static gboolean ddb_equalizer_real_button_press_event (GtkWidget* base, GdkEventButton* event) {
DdbEqualizer * self;
gboolean result = FALSE;
- gboolean _tmp0_ = FALSE;
- gboolean _tmp1_ = FALSE;
- gboolean _tmp2_ = FALSE;
+ GdkEventButton _tmp0_;
+ gdouble _tmp1_;
+ GdkEventButton _tmp2_;
+ gdouble _tmp3_;
+ gboolean _tmp4_ = FALSE;
+ gboolean _tmp11_ = FALSE;
+ gboolean _tmp12_ = FALSE;
+ gboolean _tmp13_ = FALSE;
+ GdkEventButton _tmp14_;
+ gdouble _tmp15_;
+ gboolean _tmp18_;
+ gboolean _tmp24_;
+ gboolean _tmp27_;
self = (DdbEqualizer*) base;
- if (ddb_equalizer_in_curve_area (self, (double) ((gint) (*event).x), (double) ((gint) (*event).y))) {
+ g_return_val_if_fail (event != NULL, FALSE);
+ _tmp0_ = *event;
+ _tmp1_ = _tmp0_.x;
+ _tmp2_ = *event;
+ _tmp3_ = _tmp2_.y;
+ _tmp4_ = ddb_equalizer_in_curve_area (self, (gdouble) ((gint) _tmp1_), (gdouble) ((gint) _tmp3_));
+ if (_tmp4_) {
+ GdkEventButton _tmp5_;
+ gdouble _tmp6_;
+ GdkEventButton _tmp7_;
+ gdouble _tmp8_;
+ GdkEventButton _tmp9_;
+ gdouble _tmp10_;
self->priv->curve_hook = TRUE;
- ddb_equalizer_update_eq_drag (self, (double) ((gint) (*event).x), (double) ((gint) (*event).y));
- self->priv->mouse_y = (gint) (*event).y;
+ _tmp5_ = *event;
+ _tmp6_ = _tmp5_.x;
+ _tmp7_ = *event;
+ _tmp8_ = _tmp7_.y;
+ ddb_equalizer_update_eq_drag (self, (gdouble) ((gint) _tmp6_), (gdouble) ((gint) _tmp8_));
+ _tmp9_ = *event;
+ _tmp10_ = _tmp9_.y;
+ self->priv->mouse_y = (gint) _tmp10_;
gtk_widget_queue_draw ((GtkWidget*) self);
result = FALSE;
return result;
}
- if ((*event).x <= 11) {
- _tmp2_ = (*event).y > 1;
+ _tmp14_ = *event;
+ _tmp15_ = _tmp14_.x;
+ if (_tmp15_ <= ((gdouble) 11)) {
+ GdkEventButton _tmp16_;
+ gdouble _tmp17_;
+ _tmp16_ = *event;
+ _tmp17_ = _tmp16_.y;
+ _tmp13_ = _tmp17_ > ((gdouble) 1);
} else {
- _tmp2_ = FALSE;
+ _tmp13_ = FALSE;
}
- if (_tmp2_) {
- _tmp1_ = (*event).y <= (((GtkWidget*) self)->allocation.height - self->priv->margin_bottom);
+ _tmp18_ = _tmp13_;
+ if (_tmp18_) {
+ GdkEventButton _tmp19_;
+ gdouble _tmp20_;
+ GtkAllocation _tmp21_;
+ gint _tmp22_;
+ gint _tmp23_;
+ _tmp19_ = *event;
+ _tmp20_ = _tmp19_.y;
+ gtk_widget_get_allocation ((GtkWidget*) self, &_tmp21_);
+ _tmp22_ = _tmp21_.height;
+ _tmp23_ = self->priv->eq_margin_bottom;
+ _tmp12_ = _tmp20_ <= ((gdouble) (_tmp22_ - _tmp23_));
} else {
- _tmp1_ = FALSE;
+ _tmp12_ = FALSE;
}
- if (_tmp1_) {
- _tmp0_ = (*event).button == 1;
+ _tmp24_ = _tmp12_;
+ if (_tmp24_) {
+ GdkEventButton _tmp25_;
+ guint _tmp26_;
+ _tmp25_ = *event;
+ _tmp26_ = _tmp25_.button;
+ _tmp11_ = _tmp26_ == ((guint) 1);
} else {
- _tmp0_ = FALSE;
+ _tmp11_ = FALSE;
}
- if (_tmp0_) {
- self->priv->preamp = (*event).y / ((double) (((GtkWidget*) self)->allocation.height - self->priv->margin_bottom));
+ _tmp27_ = _tmp11_;
+ if (_tmp27_) {
+ GdkEventButton _tmp28_;
+ gdouble _tmp29_;
+ GtkAllocation _tmp30_;
+ gint _tmp31_;
+ gint _tmp32_;
+ GdkEventButton _tmp33_;
+ gdouble _tmp34_;
+ _tmp28_ = *event;
+ _tmp29_ = _tmp28_.y;
+ gtk_widget_get_allocation ((GtkWidget*) self, &_tmp30_);
+ _tmp31_ = _tmp30_.height;
+ _tmp32_ = self->priv->eq_margin_bottom;
+ self->priv->preamp = _tmp29_ / ((gdouble) (_tmp31_ - _tmp32_));
g_signal_emit_by_name (self, "on-changed");
self->priv->preamp_hook = TRUE;
- self->priv->mouse_y = (gint) (*event).y;
+ _tmp33_ = *event;
+ _tmp34_ = _tmp33_.y;
+ self->priv->mouse_y = (gint) _tmp34_;
gtk_widget_queue_draw ((GtkWidget*) self);
}
result = FALSE;
@@ -488,10 +606,15 @@ static gboolean ddb_equalizer_real_button_press_event (GtkWidget* base, GdkEvent
static gboolean ddb_equalizer_real_button_release_event (GtkWidget* base, GdkEventButton* event) {
DdbEqualizer * self;
gboolean result = FALSE;
+ GdkWindow* _tmp0_ = NULL;
+ GdkCursor* _tmp1_;
self = (DdbEqualizer*) base;
+ g_return_val_if_fail (event != NULL, FALSE);
self->priv->curve_hook = FALSE;
self->priv->preamp_hook = FALSE;
- gdk_window_set_cursor (gtk_widget_get_window ((GtkWidget*) self), self->priv->pointer_cursor);
+ _tmp0_ = gtk_widget_get_window ((GtkWidget*) self);
+ _tmp1_ = self->priv->pointer_cursor;
+ gdk_window_set_cursor (_tmp0_, _tmp1_);
result = FALSE;
return result;
}
@@ -501,6 +624,7 @@ static gboolean ddb_equalizer_real_leave_notify_event (GtkWidget* base, GdkEvent
DdbEqualizer * self;
gboolean result = FALSE;
self = (DdbEqualizer*) base;
+ g_return_val_if_fail (event != NULL, FALSE);
self->priv->mouse_y = -1;
gtk_widget_queue_draw ((GtkWidget*) self);
result = FALSE;
@@ -511,30 +635,77 @@ static gboolean ddb_equalizer_real_leave_notify_event (GtkWidget* base, GdkEvent
static gboolean ddb_equalizer_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event) {
DdbEqualizer * self;
gboolean result = FALSE;
- double y;
+ GdkEventMotion _tmp0_;
+ gdouble _tmp1_;
+ GtkAllocation _tmp2_;
+ gint _tmp3_;
+ gint _tmp4_;
+ gdouble y;
+ gdouble _tmp5_;
+ gdouble _tmp6_;
+ gboolean _tmp7_;
+ GdkEventMotion _tmp9_;
+ gdouble _tmp10_;
+ GdkEventMotion _tmp11_;
+ gdouble _tmp12_;
+ gboolean _tmp13_ = FALSE;
+ gboolean _tmp16_;
self = (DdbEqualizer*) base;
- y = (*event).y / ((double) (((GtkWidget*) self)->allocation.height - self->priv->margin_bottom));
- if (y < 0) {
- y = (double) 0;
+ g_return_val_if_fail (event != NULL, FALSE);
+ _tmp0_ = *event;
+ _tmp1_ = _tmp0_.y;
+ gtk_widget_get_allocation ((GtkWidget*) self, &_tmp2_);
+ _tmp3_ = _tmp2_.height;
+ _tmp4_ = self->priv->eq_margin_bottom;
+ y = _tmp1_ / ((gdouble) (_tmp3_ - _tmp4_));
+ _tmp5_ = y;
+ if (_tmp5_ < ((gdouble) 0)) {
+ y = (gdouble) 0;
}
- if (y > 1) {
- y = (double) 1;
+ _tmp6_ = y;
+ if (_tmp6_ > ((gdouble) 1)) {
+ y = (gdouble) 1;
}
- if (self->priv->preamp_hook) {
- self->priv->preamp = y;
+ _tmp7_ = self->priv->preamp_hook;
+ if (_tmp7_) {
+ gdouble _tmp8_;
+ _tmp8_ = y;
+ self->priv->preamp = _tmp8_;
g_signal_emit_by_name (self, "on-changed");
gtk_widget_queue_draw ((GtkWidget*) self);
result = FALSE;
return result;
}
- if (!ddb_equalizer_in_curve_area (self, (double) ((gint) (*event).x), (double) ((gint) (*event).y))) {
+ _tmp9_ = *event;
+ _tmp10_ = _tmp9_.x;
+ _tmp11_ = *event;
+ _tmp12_ = _tmp11_.y;
+ _tmp13_ = ddb_equalizer_in_curve_area (self, (gdouble) ((gint) _tmp10_), (gdouble) ((gint) _tmp12_));
+ if (!_tmp13_) {
self->priv->mouse_y = -1;
} else {
- self->priv->mouse_y = (gint) (*event).y;
+ GdkEventMotion _tmp14_;
+ gdouble _tmp15_;
+ _tmp14_ = *event;
+ _tmp15_ = _tmp14_.y;
+ self->priv->mouse_y = (gint) _tmp15_;
}
- if (self->priv->curve_hook) {
- ddb_equalizer_update_eq_drag (self, (double) ((gint) (*event).x), (double) ((gint) (*event).y));
- self->priv->mouse_y = (gint) (*event).y;
+ _tmp16_ = self->priv->curve_hook;
+ if (_tmp16_) {
+ GdkEventMotion _tmp17_;
+ gdouble _tmp18_;
+ GdkEventMotion _tmp19_;
+ gdouble _tmp20_;
+ GdkEventMotion _tmp21_;
+ gdouble _tmp22_;
+ _tmp17_ = *event;
+ _tmp18_ = _tmp17_.x;
+ _tmp19_ = *event;
+ _tmp20_ = _tmp19_.y;
+ ddb_equalizer_update_eq_drag (self, (gdouble) ((gint) _tmp18_), (gdouble) ((gint) _tmp20_));
+ _tmp21_ = *event;
+ _tmp22_ = _tmp21_.y;
+ self->priv->mouse_y = (gint) _tmp22_;
}
gtk_widget_queue_draw ((GtkWidget*) self);
result = FALSE;
@@ -542,37 +713,59 @@ static gboolean ddb_equalizer_real_motion_notify_event (GtkWidget* base, GdkEven
}
-void ddb_equalizer_set_band (DdbEqualizer* self, gint band, double v) {
+void ddb_equalizer_set_band (DdbEqualizer* self, gint band, gdouble v) {
+ gdouble* _tmp0_;
+ gint _tmp0__length1;
+ gint _tmp1_;
+ gdouble _tmp2_;
+ gdouble _tmp3_;
g_return_if_fail (self != NULL);
- self->priv->values[band] = 1 - ((v + 20.0) / 40.0);
+ _tmp0_ = self->priv->values;
+ _tmp0__length1 = self->priv->values_length1;
+ _tmp1_ = band;
+ _tmp2_ = v;
+ _tmp0_[_tmp1_] = 1 - ((_tmp2_ + 20.0) / 40.0);
+ _tmp3_ = _tmp0_[_tmp1_];
}
-double ddb_equalizer_get_band (DdbEqualizer* self, gint band) {
- double result = 0.0;
+gdouble ddb_equalizer_get_band (DdbEqualizer* self, gint band) {
+ gdouble result = 0.0;
+ gdouble* _tmp0_;
+ gint _tmp0__length1;
+ gint _tmp1_;
+ gdouble _tmp2_;
g_return_val_if_fail (self != NULL, 0.0);
- result = ((1 - self->priv->values[band]) * 40.0) - 20.0;
+ _tmp0_ = self->priv->values;
+ _tmp0__length1 = self->priv->values_length1;
+ _tmp1_ = band;
+ _tmp2_ = _tmp0_[_tmp1_];
+ result = ((1 - _tmp2_) * 40.0) - 20.0;
return result;
}
-void ddb_equalizer_set_preamp (DdbEqualizer* self, double v) {
+void ddb_equalizer_set_preamp (DdbEqualizer* self, gdouble v) {
+ gdouble _tmp0_;
g_return_if_fail (self != NULL);
- self->priv->preamp = 1 - ((v + 20.0) / 40.0);
+ _tmp0_ = v;
+ self->priv->preamp = 1 - ((_tmp0_ + 20.0) / 40.0);
}
-double ddb_equalizer_get_preamp (DdbEqualizer* self) {
- double result = 0.0;
+gdouble ddb_equalizer_get_preamp (DdbEqualizer* self) {
+ gdouble result = 0.0;
+ gdouble _tmp0_;
g_return_val_if_fail (self != NULL, 0.0);
- result = ((1 - self->priv->preamp) * 40.0) - 20.0;
+ _tmp0_ = self->priv->preamp;
+ result = ((1 - _tmp0_) * 40.0) - 20.0;
return result;
}
DdbEqualizer* ddb_equalizer_construct (GType object_type) {
- DdbEqualizer * self;
- self = g_object_newv (object_type, 0, NULL);
+ DdbEqualizer * self = NULL;
+ self = (DdbEqualizer*) g_object_new (object_type, NULL);
return self;
}
@@ -589,10 +782,6 @@ static GObject * ddb_equalizer_constructor (GType type, guint n_construct_proper
parent_class = G_OBJECT_CLASS (ddb_equalizer_parent_class);
obj = parent_class->constructor (type, n_construct_properties, construct_properties);
self = DDB_EQUALIZER (obj);
- {
- self->priv->margin_bottom = (gint) (((pango_units_to_double (pango_font_description_get_size (gtk_widget_get_style ((GtkWidget*) self)->font_desc)) * gdk_screen_get_resolution (gdk_screen_get_default ())) / 72) + 4);
- self->priv->margin_left = self->priv->margin_bottom * 4;
- }
return obj;
}
@@ -602,7 +791,11 @@ static void ddb_equalizer_class_init (DdbEqualizerClass * klass) {
g_type_class_add_private (klass, sizeof (DdbEqualizerPrivate));
GTK_WIDGET_CLASS (klass)->configure_event = ddb_equalizer_real_configure_event;
GTK_WIDGET_CLASS (klass)->realize = ddb_equalizer_real_realize;
+#if GTK_CHECK_VERSION(3,0,0)
+ GTK_WIDGET_CLASS (klass)->draw = ddb_equalizer_real_draw;
+#else
GTK_WIDGET_CLASS (klass)->expose_event = ddb_equalizer_real_expose_event;
+#endif
GTK_WIDGET_CLASS (klass)->button_press_event = ddb_equalizer_real_button_press_event;
GTK_WIDGET_CLASS (klass)->button_release_event = ddb_equalizer_real_button_release_event;
GTK_WIDGET_CLASS (klass)->leave_notify_event = ddb_equalizer_real_leave_notify_event;
@@ -614,17 +807,21 @@ static void ddb_equalizer_class_init (DdbEqualizerClass * klass) {
static void ddb_equalizer_instance_init (DdbEqualizer * self) {
+ gdouble* _tmp0_ = NULL;
+ GdkCursor* _tmp1_;
self->priv = DDB_EQUALIZER_GET_PRIVATE (self);
- self->priv->values = g_new0 (double, DDB_EQUALIZER_bands);
+ _tmp0_ = g_new0 (gdouble, DDB_EQUALIZER_bands);
+ self->priv->values = _tmp0_;
self->priv->values_length1 = DDB_EQUALIZER_bands;
self->priv->_values_size_ = self->priv->values_length1;
self->priv->preamp = 0.5;
self->priv->mouse_y = -1;
self->priv->curve_hook = FALSE;
self->priv->preamp_hook = FALSE;
- self->priv->margin_bottom = -1;
- self->priv->margin_left = -1;
- self->priv->pointer_cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ self->priv->eq_margin_bottom = -1;
+ self->priv->eq_margin_left = -1;
+ _tmp1_ = gdk_cursor_new (GDK_LEFT_PTR);
+ self->priv->pointer_cursor = _tmp1_;
}
@@ -650,4 +847,3 @@ GType ddb_equalizer_get_type (void) {
-