Mercurial > audlegacy
changeset 3098:821a712c08a3
replace EqSlider with UiSkinnedEqualizerSlider
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Thu, 19 Jul 2007 11:16:38 +0200 |
parents | 5a7dea5211f3 |
children | 4f011bf1d083 |
files | src/audacious/Makefile src/audacious/ui_equalizer.c src/audacious/ui_skinned_equalizer_slider.c src/audacious/ui_skinned_equalizer_slider.h src/audacious/widgets/Makefile src/audacious/widgets/eq_slider.c src/audacious/widgets/eq_slider.h src/audacious/widgets/widgetcore.h |
diffstat | 8 files changed, 492 insertions(+), 317 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/Makefile Tue Jul 17 18:33:49 2007 +0900 +++ b/src/audacious/Makefile Thu Jul 19 11:16:38 2007 +0200 @@ -117,6 +117,7 @@ ui_skinned_menurow.c \ ui_skinned_playstatus.c \ ui_skinned_monostereo.c \ + ui_skinned_equalizer_slider.c \ ui_skinselector.c \ ui_urlopener.c \ util.c \
--- a/src/audacious/ui_equalizer.c Tue Jul 17 18:33:49 2007 +0900 +++ b/src/audacious/ui_equalizer.c Thu Jul 19 11:16:38 2007 +0200 @@ -55,6 +55,7 @@ #include "ui_skinned_window.h" #include "ui_skinned_button.h" #include "ui_skinned_horizontal_slider.h" +#include "ui_skinned_equalizer_slider.h" enum PresetViewCols { PRESET_VIEW_COL_NAME, @@ -88,7 +89,7 @@ static GtkWidget *equalizerwin_close, *equalizerwin_presets, *equalizerwin_shade; static EqGraph *equalizerwin_graph; -static EqSlider *equalizerwin_preamp, *equalizerwin_bands[10]; +static GtkWidget *equalizerwin_preamp,*equalizerwin_bands[10]; static GtkWidget *equalizerwin_volume, *equalizerwin_balance; static GList *equalizer_presets = NULL, *equalizer_auto_presets = NULL; @@ -215,9 +216,9 @@ { gint i; - cfg.equalizer_preamp = eqslider_get_position(equalizerwin_preamp); + cfg.equalizer_preamp = ui_skinned_equalizer_slider_get_position(equalizerwin_preamp); for (i = 0; i < 10; i++) - cfg.equalizer_bands[i] = eqslider_get_position(equalizerwin_bands[i]); + cfg.equalizer_bands[i] = ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]); /* um .. i think we need both of these for xmms compatibility .. not sure. -larne */ input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, @@ -688,20 +689,13 @@ ui_skinned_window_widgetlist_associate(equalizerwin, WIDGET(equalizerwin_graph)); - equalizerwin_preamp = - create_eqslider(&equalizerwin_wlist, equalizerwin_bg, - SKINNED_WINDOW(equalizerwin)->gc, 21, 38); - eqslider_set_position(equalizerwin_preamp, cfg.equalizer_preamp); - ui_skinned_window_widgetlist_associate(equalizerwin, - WIDGET(equalizerwin_preamp)); + equalizerwin_preamp = ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->fixed, 21, 38); + ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, cfg.equalizer_preamp); for (i = 0; i < 10; i++) { equalizerwin_bands[i] = - create_eqslider(&equalizerwin_wlist, equalizerwin_bg, - SKINNED_WINDOW(equalizerwin)->gc, 78 + (i * 18), 38); - eqslider_set_position(equalizerwin_bands[i], cfg.equalizer_bands[i]); - ui_skinned_window_widgetlist_associate(equalizerwin, - WIDGET(equalizerwin_bands[i])); + ui_skinned_equalizer_slider_new(SKINNED_WINDOW(equalizerwin)->fixed, 78 + (i * 18), 38); + ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], cfg.equalizer_bands[i]); } equalizerwin_volume = @@ -907,9 +901,9 @@ gint i; if ((preset = equalizerwin_find_preset(list, name)) != NULL) { - eqslider_set_position(equalizerwin_preamp, preset->preamp); + ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preset->preamp); for (i = 0; i < 10; i++) - eqslider_set_position(equalizerwin_bands[i], preset->bands[i]); + ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], preset->bands[i]); equalizerwin_eq_changed(); return TRUE; } @@ -929,9 +923,9 @@ list = g_list_append(list, preset); } - preset->preamp = eqslider_get_position(equalizerwin_preamp); + preset->preamp = ui_skinned_equalizer_slider_get_position(equalizerwin_preamp); for (i = 0; i < 10; i++) - preset->bands[i] = eqslider_get_position(equalizerwin_bands[i]); + preset->bands[i] = ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]); equalizerwin_write_preset_file(list, filename); @@ -1050,11 +1044,11 @@ if (vfs_fread(bands, 1, 11, file) != 11) return; - eqslider_set_position(equalizerwin_preamp, + ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, 20.0 - ((bands[10] * 40.0) / 63.0)); for (i = 0; i < 10; i++) - eqslider_set_position(equalizerwin_bands[i], + ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], 20.0 - ((bands[i] * 40.0) / 64.0)); } @@ -1068,12 +1062,12 @@ gint i; if (bmp_rcfile_read_float(rcfile, "Equalizer preset", "Preamp", &val)) - eqslider_set_position(equalizerwin_preamp, val); + ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, val); for (i = 0; i < 10; i++) { gchar tmp[7]; g_snprintf(tmp, sizeof(tmp), "Band%d", i); if (bmp_rcfile_read_float(rcfile, "Equalizer preset", tmp, &val)) - eqslider_set_position(equalizerwin_bands[i], val); + ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], val); } equalizerwin_eq_changed(); } @@ -1278,13 +1272,13 @@ rcfile = bmp_rcfile_new(); bmp_rcfile_write_float(rcfile, "Equalizer preset", "Preamp", - eqslider_get_position(equalizerwin_preamp)); + ui_skinned_equalizer_slider_get_position(equalizerwin_preamp)); for (i = 0; i < 10; i++) { gchar tmp[7]; g_snprintf(tmp, sizeof(tmp), "Band%d", i); bmp_rcfile_write_float(rcfile, "Equalizer preset", tmp, - eqslider_get_position(equalizerwin_bands[i])); + ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i])); } bmp_rcfile_write(rcfile, filename); @@ -1315,8 +1309,8 @@ vfs_fwrite(name, 1, 257, file); for (i = 0; i < 10; i++) - bands[i] = 63 - (((eqslider_get_position(equalizerwin_bands[i]) + 20) * 63) / 40); - bands[10] = 63 - (((eqslider_get_position(equalizerwin_preamp) + 20) * 63) / 40); + bands[i] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_bands[i]) + 20) * 63) / 40); + bands[10] = 63 - (((ui_skinned_equalizer_slider_get_position(equalizerwin_preamp) + 20) * 63) / 40); vfs_fwrite(bands, 1, 11, file); vfs_fclose(file); @@ -1479,7 +1473,7 @@ void equalizerwin_set_preamp(gfloat preamp) { - eqslider_set_position(equalizerwin_preamp, preamp); + ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, preamp); equalizerwin_eq_changed(); } @@ -1487,20 +1481,20 @@ equalizerwin_set_band(gint band, gfloat value) { g_return_if_fail(band >= 0 && band < 10); - eqslider_set_position(equalizerwin_bands[band], value); + ui_skinned_equalizer_slider_set_position(equalizerwin_bands[band], value); } gfloat equalizerwin_get_preamp(void) { - return eqslider_get_position(equalizerwin_preamp); + return ui_skinned_equalizer_slider_get_position(equalizerwin_preamp); } gfloat equalizerwin_get_band(gint band) { g_return_val_if_fail(band >= 0 && band < 10, 0); - return eqslider_get_position(equalizerwin_bands[band]); + return ui_skinned_equalizer_slider_get_position(equalizerwin_bands[band]); } void @@ -1547,10 +1541,10 @@ action_equ_zero_preset(void) { gint i; - - eqslider_set_position(equalizerwin_preamp, 0); + + ui_skinned_equalizer_slider_set_position(equalizerwin_preamp, 0); for (i = 0; i < 10; i++) - eqslider_set_position(equalizerwin_bands[i], 0); + ui_skinned_equalizer_slider_set_position(equalizerwin_bands[i], 0); equalizerwin_eq_changed(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/ui_skinned_equalizer_slider.c Thu Jul 19 11:16:38 2007 +0200 @@ -0,0 +1,402 @@ +/* + * Audacious - a cross-platform multimedia player + * Copyright (c) 2007 Audacious development team. + * + * Based on: + * BMP - Cross-platform multimedia player + * Copyright (C) 2003-2004 BMP development team. + * XMMS: + * Copyright (C) 1998-2003 XMMS development team. + * + * 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; under version 2 of the License. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "widgets/widgetcore.h" +#include "ui_skinned_equalizer_slider.h" +#include "util.h" +#include "ui_equalizer.h" +#include "ui_main.h" +#include <glib/gi18n.h> + +#define UI_TYPE_SKINNED_EQUALIZER_SLIDER (ui_skinned_equalizer_slider_get_type()) +#define UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UI_TYPE_SKINNED_EQUALIZER_SLIDER, UiSkinnedEqualizerSliderPrivate)) +typedef struct _UiSkinnedEqualizerSliderPrivate UiSkinnedEqualizerSliderPrivate; + +enum { + DOUBLED, + LAST_SIGNAL +}; + +struct _UiSkinnedEqualizerSliderPrivate { + GtkWidget *fixed; + SkinPixmapId skin_index; + gboolean double_size; + gint position; + gint width, height; + gboolean pressed; + gint drag_y; +}; + +static void ui_skinned_equalizer_slider_class_init (UiSkinnedEqualizerSliderClass *klass); +static void ui_skinned_equalizer_slider_init (UiSkinnedEqualizerSlider *equalizer_slider); +static void ui_skinned_equalizer_slider_destroy (GtkObject *object); +static void ui_skinned_equalizer_slider_realize (GtkWidget *widget); +static void ui_skinned_equalizer_slider_size_request (GtkWidget *widget, GtkRequisition *requisition); +static void ui_skinned_equalizer_slider_size_allocate (GtkWidget *widget, GtkAllocation *allocation); +static gboolean ui_skinned_equalizer_slider_expose (GtkWidget *widget, GdkEventExpose *event); +static gboolean ui_skinned_equalizer_slider_button_press (GtkWidget *widget, GdkEventButton *event); +static gboolean ui_skinned_equalizer_slider_button_release (GtkWidget *widget, GdkEventButton *event); +static gboolean ui_skinned_equalizer_slider_motion_notify (GtkWidget *widget, GdkEventMotion *event); +static gboolean ui_skinned_equalizer_slider_scroll (GtkWidget *widget, GdkEventScroll *event); +static void ui_skinned_equalizer_slider_toggle_doublesize (UiSkinnedEqualizerSlider *equalizer_slider); +void ui_skinned_equalizer_slider_set_mainwin_text (UiSkinnedEqualizerSlider * es); + +static GtkWidgetClass *parent_class = NULL; +static guint equalizer_slider_signals[LAST_SIGNAL] = { 0 }; + +GType ui_skinned_equalizer_slider_get_type() { + static GType equalizer_slider_type = 0; + if (!equalizer_slider_type) { + static const GTypeInfo equalizer_slider_info = { + sizeof (UiSkinnedEqualizerSliderClass), + NULL, + NULL, + (GClassInitFunc) ui_skinned_equalizer_slider_class_init, + NULL, + NULL, + sizeof (UiSkinnedEqualizerSlider), + 0, + (GInstanceInitFunc) ui_skinned_equalizer_slider_init, + }; + equalizer_slider_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedEqualizerSlider", &equalizer_slider_info, 0); + } + + return equalizer_slider_type; +} + +static void ui_skinned_equalizer_slider_class_init(UiSkinnedEqualizerSliderClass *klass) { + GObjectClass *gobject_class; + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + + gobject_class = G_OBJECT_CLASS(klass); + object_class = (GtkObjectClass*) klass; + widget_class = (GtkWidgetClass*) klass; + parent_class = gtk_type_class (gtk_widget_get_type ()); + + object_class->destroy = ui_skinned_equalizer_slider_destroy; + + widget_class->realize = ui_skinned_equalizer_slider_realize; + widget_class->expose_event = ui_skinned_equalizer_slider_expose; + widget_class->size_request = ui_skinned_equalizer_slider_size_request; + widget_class->size_allocate = ui_skinned_equalizer_slider_size_allocate; + widget_class->button_press_event = ui_skinned_equalizer_slider_button_press; + widget_class->button_release_event = ui_skinned_equalizer_slider_button_release; + widget_class->motion_notify_event = ui_skinned_equalizer_slider_motion_notify; + widget_class->scroll_event = ui_skinned_equalizer_slider_scroll; + + klass->doubled = ui_skinned_equalizer_slider_toggle_doublesize; + + equalizer_slider_signals[DOUBLED] = + g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (UiSkinnedEqualizerSliderClass, doubled), NULL, NULL, + gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_type_class_add_private (gobject_class, sizeof (UiSkinnedEqualizerSliderPrivate)); +} + +static void ui_skinned_equalizer_slider_init(UiSkinnedEqualizerSlider *equalizer_slider) { + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(equalizer_slider); + priv->pressed = FALSE; +} + +GtkWidget* ui_skinned_equalizer_slider_new(GtkWidget *fixed, gint x, gint y) { + UiSkinnedEqualizerSlider *es = g_object_new (ui_skinned_equalizer_slider_get_type (), NULL); + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(es); + + es->x = x; + es->y = y; + priv->width = 14; + priv->height = 63; + priv->skin_index = SKIN_EQMAIN; + priv->fixed = fixed; + + gtk_fixed_put(GTK_FIXED(priv->fixed), GTK_WIDGET(es), es->x, es->y); + + return GTK_WIDGET(es); +} + +static void ui_skinned_equalizer_slider_destroy(GtkObject *object) { + UiSkinnedEqualizerSlider *equalizer_slider; + + g_return_if_fail (object != NULL); + g_return_if_fail (UI_SKINNED_IS_EQUALIZER_SLIDER (object)); + + equalizer_slider = UI_SKINNED_EQUALIZER_SLIDER (object); + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + +static void ui_skinned_equalizer_slider_realize(GtkWidget *widget) { + UiSkinnedEqualizerSlider *equalizer_slider; + GdkWindowAttr attributes; + gint attributes_mask; + + g_return_if_fail (widget != NULL); + g_return_if_fail (UI_SKINNED_IS_EQUALIZER_SLIDER(widget)); + + GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); + equalizer_slider = UI_SKINNED_EQUALIZER_SLIDER(widget); + + attributes.x = widget->allocation.x; + attributes.y = widget->allocation.y; + attributes.width = widget->allocation.width; + attributes.height = widget->allocation.height; + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.window_type = GDK_WINDOW_CHILD; + attributes.event_mask = gtk_widget_get_events(widget); + attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK; + attributes.visual = gtk_widget_get_visual(widget); + attributes.colormap = gtk_widget_get_colormap(widget); + + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); + + widget->style = gtk_style_attach(widget->style, widget->window); + gdk_window_set_user_data(widget->window, widget); +} + +static void ui_skinned_equalizer_slider_size_request(GtkWidget *widget, GtkRequisition *requisition) { + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(widget); + + requisition->width = priv->width*(1+priv->double_size); + requisition->height = priv->height*(1+priv->double_size); +} + +static void ui_skinned_equalizer_slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { + UiSkinnedEqualizerSlider *equalizer_slider = UI_SKINNED_EQUALIZER_SLIDER (widget); + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(equalizer_slider); + + widget->allocation = *allocation; + widget->allocation.x *= (1+priv->double_size); + widget->allocation.y *= (1+priv->double_size); + if (GTK_WIDGET_REALIZED (widget)) + gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); + + equalizer_slider->x = widget->allocation.x/(priv->double_size ? 2 : 1); + equalizer_slider->y = widget->allocation.y/(priv->double_size ? 2 : 1); +} + +static gboolean ui_skinned_equalizer_slider_expose(GtkWidget *widget, GdkEventExpose *event) { + g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (UI_SKINNED_IS_EQUALIZER_SLIDER (widget), FALSE); + g_return_val_if_fail (event != NULL, FALSE); + + UiSkinnedEqualizerSlider *es = UI_SKINNED_EQUALIZER_SLIDER (widget); + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(es); + + GdkPixmap *obj = NULL; + GdkGC *gc; + + obj = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth); + gc = gdk_gc_new(obj); + + gint frame; + frame = 27 - ((priv->position * 27) / 50); + if (frame < 14) + skin_draw_pixmap(bmp_active_skin, obj, gc, priv->skin_index, (frame * 15) + 13, 164, 0, 0, priv->width, priv->height); + else + skin_draw_pixmap(bmp_active_skin, obj, gc, priv->skin_index, ((frame - 14) * 15) + 13, 229, 0, 0, priv->width, priv->height); + + if (priv->pressed) + skin_draw_pixmap(bmp_active_skin, obj, gc, priv->skin_index, 0, 176, 1, priv->position, 11, 11); + else + skin_draw_pixmap(bmp_active_skin, obj, gc, priv->skin_index, 0, 164, 1, priv->position, 11, 11); + + GdkPixmap *image = NULL; + + if (priv->double_size) { + image = create_dblsize_pixmap(obj); + } else { + image = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth); + gdk_draw_drawable (image, gc, obj, 0, 0, 0, 0, priv->width, priv->height); + } + + g_object_unref(obj); + + gdk_draw_drawable (widget->window, gc, image, 0, 0, 0, 0, + priv->width*(1+priv->double_size), priv->height*(1+priv->double_size)); + g_object_unref(gc); + g_object_unref(image); + + return FALSE; +} + +static gboolean ui_skinned_equalizer_slider_button_press(GtkWidget *widget, GdkEventButton *event) { + g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (UI_SKINNED_IS_EQUALIZER_SLIDER (widget), FALSE); + g_return_val_if_fail (event != NULL, FALSE); + + UiSkinnedEqualizerSlider *es = UI_SKINNED_EQUALIZER_SLIDER (widget); + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(es); + + gint y; + + if (event->type == GDK_BUTTON_PRESS) { + if (event->button == 1) { + priv->pressed = TRUE; + y = event->y; + + if (y >= priv->position && y < priv->position + 11) + priv->drag_y = y - priv->position; + else { + priv->position = y - 5; + priv->drag_y = 5; + if (priv->position < 0) + priv->position = 0; + if (priv->position > 50) + priv->position = 50; + if (priv->position >= 24 && priv->position <= 26) + priv->position = 25; + equalizerwin_eq_changed(); + } + + ui_skinned_equalizer_slider_set_mainwin_text(es); + gtk_widget_queue_draw(widget); + } + } + + return TRUE; +} + +static gboolean ui_skinned_equalizer_slider_button_release(GtkWidget *widget, GdkEventButton *event) { + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(widget); + + if (event->button == 1) { + priv->pressed = FALSE; + mainwin_release_info_text(); + gtk_widget_queue_draw(widget); + } + return TRUE; +} + +static gboolean ui_skinned_equalizer_slider_motion_notify(GtkWidget *widget, GdkEventMotion *event) { + g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (UI_SKINNED_IS_EQUALIZER_SLIDER (widget), FALSE); + g_return_val_if_fail (event != NULL, FALSE); + UiSkinnedEqualizerSlider *es = UI_SKINNED_EQUALIZER_SLIDER(widget); + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(widget); + + if (priv->pressed) { + gint y; + + y = event->y; + priv->position = y - priv->drag_y; + + if (priv->position < 0) + priv->position = 0; + if (priv->position > 50) + priv->position = 50; + if (priv->position >= 24 && priv->position <= 26) + priv->position = 25; + + ui_skinned_equalizer_slider_set_mainwin_text(es); + equalizerwin_eq_changed(); + gtk_widget_queue_draw(widget); + } + + return TRUE; +} + +static gboolean ui_skinned_equalizer_slider_scroll(GtkWidget *widget, GdkEventScroll *event) { + g_return_val_if_fail (UI_SKINNED_IS_EQUALIZER_SLIDER (widget), FALSE); + g_return_val_if_fail (event != NULL, FALSE); + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(widget); + + if (event->direction == GDK_SCROLL_UP) { + priv->position -= 2; + + if (priv->position < 0) + priv->position = 0; + } + else { + priv->position += 2; + + if (priv->position > 50) + priv->position = 50; + } + + equalizerwin_eq_changed(); + gtk_widget_queue_draw(widget); + return TRUE; +} + +static void ui_skinned_equalizer_slider_toggle_doublesize(UiSkinnedEqualizerSlider *equalizer_slider) { + GtkWidget *widget = GTK_WIDGET (equalizer_slider); + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(equalizer_slider); + + priv->double_size = !priv->double_size; + + gtk_widget_set_size_request(widget, priv->width*(1+priv->double_size), priv->height*(1+priv->double_size)); + + gtk_widget_queue_draw(GTK_WIDGET(equalizer_slider)); +} + +void ui_skinned_equalizer_slider_set_position(GtkWidget *widget, gint pos) { + g_return_if_fail (UI_SKINNED_IS_EQUALIZER_SLIDER (widget)); + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(widget); + + if (priv->pressed) + return; + + priv->position = 25 - (gint) ((pos * 25.0) / 20.0); + + if (priv->position < 0) + priv->position = 0; + + if (priv->position > 50) + priv->position = 50; + + if (priv->position >= 24 && priv->position <= 26) + priv->position = 25; + + gtk_widget_queue_draw(widget); +} + +gfloat ui_skinned_equalizer_slider_get_position(GtkWidget *widget) { + g_return_val_if_fail (UI_SKINNED_IS_EQUALIZER_SLIDER (widget), -1); + UiSkinnedEqualizerSliderPrivate *priv = UI_SKINNED_EQUALIZER_SLIDER_GET_PRIVATE(widget); + return (20.0 - (((gfloat) priv->position * 20.0) / 25.0)); +} + +void ui_skinned_equalizer_slider_set_mainwin_text(UiSkinnedEqualizerSlider * es) { + gint band = 0; + const gchar *bandname[11] = { N_("PREAMP"), N_("60HZ"), N_("170HZ"), + N_("310HZ"), N_("600HZ"), N_("1KHZ"), + N_("3KHZ"), N_("6KHZ"), N_("12KHZ"), + N_("14KHZ"), N_("16KHZ") + }; + gchar *tmp; + + if (es->x > 21) + band = ((es->x - 78) / 18) + 1; + + tmp = + g_strdup_printf("EQ: %s: %+.1f DB", _(bandname[band]), + ui_skinned_equalizer_slider_get_position(GTK_WIDGET(es))); + mainwin_lock_info_text(tmp); + g_free(tmp); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audacious/ui_skinned_equalizer_slider.h Thu Jul 19 11:16:38 2007 +0200 @@ -0,0 +1,62 @@ +/* + * Audacious - a cross-platform multimedia player + * Copyright (c) 2007 Audacious development team. + * + * Based on: + * BMP - Cross-platform multimedia player + * Copyright (C) 2003-2004 BMP development team. + * XMMS: + * Copyright (C) 1998-2003 XMMS development team. + * + * 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; under version 2 of the License. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef UISKINNEDEQUALIZER_SLIDER_H +#define UISKINNEDEQUALIZER_SLIDER_H + +#include <gdk/gdk.h> +#include <gtk/gtkadjustment.h> +#include <gtk/gtkwidget.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define UI_SKINNED_EQUALIZER_SLIDER(obj) GTK_CHECK_CAST (obj, ui_skinned_equalizer_slider_get_type (), UiSkinnedEqualizerSlider) +#define UI_SKINNED_EQUALIZER_SLIDER_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, ui_skinned_equalizer_slider_get_type (), UiSkinnedEqualizerSliderClass) +#define UI_SKINNED_IS_EQUALIZER_SLIDER(obj) GTK_CHECK_TYPE (obj, ui_skinned_equalizer_slider_get_type ()) + +typedef struct _UiSkinnedEqualizerSlider UiSkinnedEqualizerSlider; +typedef struct _UiSkinnedEqualizerSliderClass UiSkinnedEqualizerSliderClass; + +struct _UiSkinnedEqualizerSlider { + GtkWidget widget; + gint x, y; +}; + +struct _UiSkinnedEqualizerSliderClass { + GtkWidgetClass parent_class; + void (* doubled) (UiSkinnedEqualizerSlider *equalizer_slider); +}; + +GtkWidget* ui_skinned_equalizer_slider_new(GtkWidget *fixed, gint x, gint y); +GtkType ui_skinned_equalizer_slider_get_type(void); +void ui_skinned_equalizer_slider_set_position(GtkWidget *widget, gint pos); +gfloat ui_skinned_equalizer_slider_get_position(GtkWidget *widget); + +#ifdef __cplusplus +} +#endif + +#endif
--- a/src/audacious/widgets/Makefile Tue Jul 17 18:33:49 2007 +0900 +++ b/src/audacious/widgets/Makefile Thu Jul 19 11:16:38 2007 +0200 @@ -23,7 +23,6 @@ playlist_list.c \ playlist_slider.c \ eq_graph.c \ - eq_slider.c \ skin.c OBJECTS = ${SOURCES:.c=.o}
--- a/src/audacious/widgets/eq_slider.c Tue Jul 17 18:33:49 2007 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,234 +0,0 @@ -/* BMP - Cross-platform multimedia player - * Copyright (C) 2003-2004 BMP development team. - * - * Based on XMMS: - * Copyright (C) 1998-2003 XMMS development team. - * - * 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; under version 2 of the License. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "widgetcore.h" - -#include <glib.h> -#include <glib/gi18n.h> -#include <gtk/gtk.h> -#include <gdk/gdk.h> - -#include "ui_equalizer.h" -#include "ui_main.h" -#include "skin.h" - -void -eqslider_set_position(EqSlider * es, - gfloat pos) -{ - es->es_position = 25 - (gint) ((pos * 25.0) / 20.0); - - if (es->es_position < 0) - es->es_position = 0; - - if (es->es_position > 50) - es->es_position = 50; - - if (es->es_position >= 24 && es->es_position <= 26) - es->es_position = 25; - - widget_draw(WIDGET(es)); -} - -gfloat -eqslider_get_position(EqSlider * es) -{ - return 20.0 - (((gfloat) es->es_position * 20.0) / 25.0); -} - -void -eqslider_draw(Widget * w) -{ - EqSlider *es = (EqSlider *) w; - GdkPixmap *obj; - SkinPixmapId src; - gint frame; - - src = SKIN_EQMAIN; - obj = es->es_widget.parent; - - frame = 27 - ((es->es_position * 27) / 50); - if (frame < 14) - skin_draw_pixmap(bmp_active_skin, obj, es->es_widget.gc, src, - (frame * 15) + 13, 164, es->es_widget.x, - es->es_widget.y, es->es_widget.width, - es->es_widget.height); - else - skin_draw_pixmap(bmp_active_skin, obj, es->es_widget.gc, src, - ((frame - 14) * 15) + 13, 229, es->es_widget.x, - es->es_widget.y, es->es_widget.width, - es->es_widget.height); - if (es->es_isdragging) - skin_draw_pixmap(bmp_active_skin, obj, es->es_widget.gc, src, 0, - 176, es->es_widget.x + 1, - es->es_widget.y + es->es_position, 11, 11); - else - skin_draw_pixmap(bmp_active_skin, obj, es->es_widget.gc, src, 0, - 164, es->es_widget.x + 1, - es->es_widget.y + es->es_position, 11, 11); -} - -void -eqslider_set_mainwin_text(EqSlider * es) -{ - gint band = 0; - const gchar *bandname[11] = { N_("PREAMP"), N_("60HZ"), N_("170HZ"), - N_("310HZ"), N_("600HZ"), N_("1KHZ"), - N_("3KHZ"), N_("6KHZ"), N_("12KHZ"), - N_("14KHZ"), N_("16KHZ") - }; - gchar *tmp; - - if (es->es_widget.x > 21) - band = ((es->es_widget.x - 78) / 18) + 1; - - tmp = - g_strdup_printf("EQ: %s: %+.1f DB", _(bandname[band]), - eqslider_get_position(es)); - mainwin_lock_info_text(tmp); - g_free(tmp); -} - -void -eqslider_button_press_cb(GtkWidget * w, - GdkEventButton * event, - gpointer data) -{ - EqSlider *es = EQ_SLIDER(data); - gint y; - - if (widget_contains(&es->es_widget, event->x, event->y)) { - if (event->button == 1) { - y = event->y - es->es_widget.y; - es->es_isdragging = TRUE; - if (y >= es->es_position && y < es->es_position + 11) - es->es_drag_y = y - es->es_position; - else { - es->es_position = y - 5; - es->es_drag_y = 5; - if (es->es_position < 0) - es->es_position = 0; - if (es->es_position > 50) - es->es_position = 50; - if (es->es_position >= 24 && es->es_position <= 26) - es->es_position = 25; - equalizerwin_eq_changed(); - } - - eqslider_set_mainwin_text(es); - widget_draw(WIDGET(es)); - } - if (event->button == 4) { - es->es_position -= 2; - if (es->es_position < 0) - es->es_position = 0; - equalizerwin_eq_changed(); - widget_draw(WIDGET(es)); - } - } -} - -void -eqslider_mouse_scroll_cb(GtkWidget * w, - GdkEventScroll * event, - gpointer data) -{ - EqSlider *es = EQ_SLIDER(data); - - if (!widget_contains(&es->es_widget, event->x, event->y)) - return; - - if (event->direction == GDK_SCROLL_UP) { - es->es_position -= 2; - - if (es->es_position < 0) - es->es_position = 0; - - equalizerwin_eq_changed(); - widget_draw(WIDGET(es)); - } - else { - es->es_position += 2; - - if (es->es_position > 50) - es->es_position = 50; - - equalizerwin_eq_changed(); - widget_draw(WIDGET(es)); - } -} - -void -eqslider_motion_cb(GtkWidget * w, - GdkEventMotion * event, - gpointer data) -{ - EqSlider *es = EQ_SLIDER(data); - gint y; - - y = event->y - es->es_widget.y; - if (es->es_isdragging) { - es->es_position = y - es->es_drag_y; - if (es->es_position < 0) - es->es_position = 0; - if (es->es_position > 50) - es->es_position = 50; - if (es->es_position >= 24 && es->es_position <= 26) - es->es_position = 25; - equalizerwin_eq_changed(); - eqslider_set_mainwin_text(es); - widget_draw(WIDGET(es)); - } -} - -void -eqslider_button_release_cb(GtkWidget * w, - GdkEventButton * event, - gpointer data) -{ - EqSlider *es = EQ_SLIDER(data); - - if (es->es_isdragging) { - es->es_isdragging = FALSE; - mainwin_release_info_text(); - widget_draw(WIDGET(es)); - } -} - -EqSlider * -create_eqslider(GList ** wlist, - GdkPixmap * parent, - GdkGC * gc, - gint x, gint y) -{ - EqSlider *es; - - es = g_new0(EqSlider, 1); - widget_init(&es->es_widget, parent, gc, x, y, 14, 63, TRUE); - es->es_widget.button_press_cb = eqslider_button_press_cb; - es->es_widget.button_release_cb = eqslider_button_release_cb; - es->es_widget.motion_cb = eqslider_motion_cb; - es->es_widget.draw = eqslider_draw; - es->es_widget.mouse_scroll_cb = eqslider_mouse_scroll_cb; - - widget_list_add(wlist, WIDGET(es)); - - return es; -}
--- a/src/audacious/widgets/eq_slider.h Tue Jul 17 18:33:49 2007 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* BMP - Cross-platform multimedia player - * Copyright (C) 2003-2004 BMP development team. - * - * Based on XMMS: - * Copyright (C) 1998-2003 XMMS development team. - * - * 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; under version 2 of the License. - * - * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef _WIDGETCORE_H_ -#error Please do not include me directly! Use widgetcore.h instead! -#endif - -#ifndef EQ_SLIDER_H -#define EQ_SLIDER_H - -#include <glib.h> -#include <gdk/gdk.h> - -#include "widget.h" - -#define EQ_SLIDER(x) ((EqSlider *)(x)) -struct _EqSlider { - Widget es_widget; - gint es_position; - gboolean es_isdragging; - gint es_drag_y; -}; - -typedef struct _EqSlider EqSlider; - -EqSlider *create_eqslider(GList ** wlist, GdkPixmap * parent, GdkGC * gc, - gint x, gint y); -void eqslider_set_position(EqSlider * es, gfloat pos); -gfloat eqslider_get_position(EqSlider * es); - -#endif
--- a/src/audacious/widgets/widgetcore.h Tue Jul 17 18:33:49 2007 +0900 +++ b/src/audacious/widgets/widgetcore.h Thu Jul 19 11:16:38 2007 +0200 @@ -20,7 +20,6 @@ #define _WIDGETCORE_H_ #include "eq_graph.h" -#include "eq_slider.h" #include "playlist_list.h" #include "playlist_slider.h" #include "skin.h"