summaryrefslogtreecommitdiff
path: root/plugins/gtkui/ddbequalizer.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-08 22:23:34 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-04-08 22:23:34 +0200
commit898108c04aeaae11c06a211d743aaea863b849fe (patch)
tree5dc37a5dc3b4ed3410181b7d06c0f16820f085a6 /plugins/gtkui/ddbequalizer.c
parentdecdfd59ce2bf0427b8bfa8d6e6e79415f552e43 (diff)
few improvements to EQ gui
Diffstat (limited to 'plugins/gtkui/ddbequalizer.c')
-rw-r--r--plugins/gtkui/ddbequalizer.c64
1 files changed, 49 insertions, 15 deletions
diff --git a/plugins/gtkui/ddbequalizer.c b/plugins/gtkui/ddbequalizer.c
index db97cd45..2d8bc577 100644
--- a/plugins/gtkui/ddbequalizer.c
+++ b/plugins/gtkui/ddbequalizer.c
@@ -1,6 +1,24 @@
/* 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>
+
+ 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, see <http://www.gnu.org/licenses/>.
+*/
+/* sripped down and polished by Alexey Yakovenko <waker@users.sourceforge.net>*/
#include <glib.h>
#include <glib-object.h>
@@ -96,17 +114,14 @@ static gpointer _g_object_ref0 (gpointer self) {
}
-static gpointer _pango_font_description_copy0 (gpointer self) {
- return self ? pango_font_description_copy (self) : NULL;
-}
-
-
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;
@@ -120,6 +135,7 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose
PangoLayout* l;
PangoContext* ctx;
PangoFontDescription* fd;
+ gint fontsize;
gboolean _tmp7_ = FALSE;
char* tmp;
double val;
@@ -137,7 +153,12 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose
GdkRectangle _tmp22_ = {0};
self = (DdbEqualizer*) base;
fore_bright_color = (gtkui_get_bar_foreground_color (&_tmp0_), _tmp0_);
- fore_dark_color = (gtkui_get_bar_foreground_color (&_tmp1_), _tmp1_);
+ 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));
@@ -181,13 +202,17 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose
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_copy0 (pango_context_get_font_description (ctx));
+ 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++;
}
@@ -196,11 +221,19 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose
break;
}
pango_layout_set_text (l, freqs[i], (gint) g_utf8_strlen (freqs[i], -1));
- gdk_draw_layout (d, gc, ((gint) (((i + 1) * step) - 5)) + self->priv->margin_left, (height - self->priv->margin_bottom) + 2, l);
+ 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 != (-1)) {
_tmp7_ = self->priv->mouse_y < (height - self->priv->margin_bottom);
} else {
@@ -232,7 +265,7 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose
}
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) - 6, l);
+ 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) {
@@ -243,15 +276,15 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose
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))) - 3, 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_dark_color);
+ gdk_gc_set_rgb_fg_color (gc, &fore_bright_color);
count = ((gint) ((height - self->priv->margin_bottom) / 6)) + 1;
{
gint j;
@@ -272,7 +305,7 @@ static gboolean ddb_equalizer_real_expose_event (GtkWidget* base, GdkEventExpose
}
}
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_dark_color);
+ gdk_gc_set_rgb_fg_color (gc, &fore_bright_color);
bar_w = 11;
if (step < bar_w) {
bar_w = ((gint) step) - 1;
@@ -544,11 +577,12 @@ static GObject * ddb_equalizer_constructor (GType type, guint n_construct_proper
obj = parent_class->constructor (type, n_construct_properties, construct_properties);
self = DDB_EQUALIZER (obj);
{
- GdkColor _tmp0_;
+ GdkColor _tmp1_;
+ GdkColor _tmp0_ = {0};
gtk_widget_add_events ((GtkWidget*) self, (gint) (((GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK) | GDK_LEAVE_NOTIFY_MASK) | GDK_POINTER_MOTION_MASK));
- gtk_widget_modify_bg ((GtkWidget*) self, GTK_STATE_NORMAL, (_tmp0_ = gtk_widget_get_style ((GtkWidget*) self)->fg[GTK_STATE_NORMAL], &_tmp0_));
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;
+ gtk_widget_modify_bg ((GtkWidget*) self, GTK_STATE_NORMAL, (_tmp1_ = (gtkui_get_bar_background_color (&_tmp0_), _tmp0_), &_tmp1_));
}
return obj;
}