Mercurial > audlegacy-plugins
annotate src/skins/ui_skinned_horizontal_slider.c @ 2605:ecd8b5653c30
add ui_skinned_equalizer_slider
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Wed, 21 May 2008 14:23:38 +0200 |
parents | 5ae914e1b78c |
children | 7c7471554d88 |
rev | line source |
---|---|
2589
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
1 /* |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
2 * Audacious - a cross-platform multimedia player |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
3 * Copyright (c) 2007 Tomasz Moń |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
4 * |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
5 * Based on: |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
6 * BMP - Cross-platform multimedia player |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
7 * Copyright (C) 2003-2004 BMP development team. |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
8 * XMMS: |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
9 * Copyright (C) 1998-2003 XMMS development team. |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
10 * |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
11 * This program is free software; you can redistribute it and/or modify |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
12 * it under the terms of the GNU General Public License as published by |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
13 * the Free Software Foundation; under version 3 of the License. |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
14 * |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
18 * GNU General Public License for more details. |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
19 * |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
21 * along with this program. If not, see <http://www.gnu.org/licenses>. |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
22 * |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
23 * The Audacious team does not consider modular code linking to |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
24 * Audacious or using our public API to be a derived work. |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
25 */ |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
26 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
27 #include "ui_skinned_horizontal_slider.h" |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
28 #include "skins_cfg.h" |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
29 #include <math.h> |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
30 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
31 #define UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_horizontal_slider_get_type(), UiSkinnedHorizontalSliderPrivate)) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
32 typedef struct _UiSkinnedHorizontalSliderPrivate UiSkinnedHorizontalSliderPrivate; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
33 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
34 enum { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
35 MOTION, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
36 RELEASE, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
37 DOUBLED, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
38 LAST_SIGNAL |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
39 }; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
40 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
41 struct _UiSkinnedHorizontalSliderPrivate { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
42 SkinPixmapId skin_index; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
43 gboolean scaled; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
44 gint frame, frame_offset, frame_height, min, max; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
45 gint knob_width, knob_height; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
46 gint position; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
47 gint width, height; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
48 gint (*frame_cb) (gint); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
49 }; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
50 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
51 static void ui_skinned_horizontal_slider_class_init (UiSkinnedHorizontalSliderClass *klass); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
52 static void ui_skinned_horizontal_slider_init (UiSkinnedHorizontalSlider *horizontal_slider); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
53 static void ui_skinned_horizontal_slider_destroy (GtkObject *object); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
54 static void ui_skinned_horizontal_slider_realize (GtkWidget *widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
55 static void ui_skinned_horizontal_slider_size_request (GtkWidget *widget, GtkRequisition *requisition); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
56 static void ui_skinned_horizontal_slider_size_allocate (GtkWidget *widget, GtkAllocation *allocation); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
57 static gboolean ui_skinned_horizontal_slider_expose (GtkWidget *widget, GdkEventExpose *event); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
58 static gboolean ui_skinned_horizontal_slider_button_press (GtkWidget *widget, GdkEventButton *event); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
59 static gboolean ui_skinned_horizontal_slider_button_release (GtkWidget *widget, GdkEventButton *event); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
60 static gboolean ui_skinned_horizontal_slider_motion_notify (GtkWidget *widget, GdkEventMotion *event); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
61 static void ui_skinned_horizontal_slider_toggle_scaled (UiSkinnedHorizontalSlider *horizontal_slider); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
62 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
63 static GtkWidgetClass *parent_class = NULL; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
64 static guint horizontal_slider_signals[LAST_SIGNAL] = { 0 }; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
65 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
66 GType ui_skinned_horizontal_slider_get_type() { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
67 static GType horizontal_slider_type = 0; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
68 if (!horizontal_slider_type) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
69 static const GTypeInfo horizontal_slider_info = { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
70 sizeof (UiSkinnedHorizontalSliderClass), |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
71 NULL, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
72 NULL, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
73 (GClassInitFunc) ui_skinned_horizontal_slider_class_init, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
74 NULL, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
75 NULL, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
76 sizeof (UiSkinnedHorizontalSlider), |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
77 0, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
78 (GInstanceInitFunc) ui_skinned_horizontal_slider_init, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
79 }; |
2590 | 80 horizontal_slider_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedHorizontalSlider", &horizontal_slider_info, 0); |
2589
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
81 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
82 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
83 return horizontal_slider_type; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
84 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
85 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
86 static void ui_skinned_horizontal_slider_class_init(UiSkinnedHorizontalSliderClass *klass) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
87 GObjectClass *gobject_class; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
88 GtkObjectClass *object_class; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
89 GtkWidgetClass *widget_class; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
90 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
91 gobject_class = G_OBJECT_CLASS(klass); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
92 object_class = (GtkObjectClass*) klass; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
93 widget_class = (GtkWidgetClass*) klass; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
94 parent_class = gtk_type_class (gtk_widget_get_type ()); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
95 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
96 object_class->destroy = ui_skinned_horizontal_slider_destroy; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
97 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
98 widget_class->realize = ui_skinned_horizontal_slider_realize; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
99 widget_class->expose_event = ui_skinned_horizontal_slider_expose; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
100 widget_class->size_request = ui_skinned_horizontal_slider_size_request; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
101 widget_class->size_allocate = ui_skinned_horizontal_slider_size_allocate; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
102 widget_class->button_press_event = ui_skinned_horizontal_slider_button_press; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
103 widget_class->button_release_event = ui_skinned_horizontal_slider_button_release; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
104 widget_class->motion_notify_event = ui_skinned_horizontal_slider_motion_notify; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
105 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
106 klass->motion = NULL; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
107 klass->release = NULL; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
108 klass->scaled = ui_skinned_horizontal_slider_toggle_scaled; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
109 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
110 horizontal_slider_signals[MOTION] = |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
111 g_signal_new ("motion", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
112 G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, motion), NULL, NULL, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
113 gtk_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
114 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
115 horizontal_slider_signals[RELEASE] = |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
116 g_signal_new ("release", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
117 G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, release), NULL, NULL, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
118 gtk_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
119 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
120 horizontal_slider_signals[DOUBLED] = |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
121 g_signal_new ("toggle-scaled", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
122 G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, scaled), NULL, NULL, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
123 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
124 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
125 g_type_class_add_private (gobject_class, sizeof (UiSkinnedHorizontalSliderPrivate)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
126 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
127 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
128 static void ui_skinned_horizontal_slider_init(UiSkinnedHorizontalSlider *horizontal_slider) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
129 horizontal_slider->pressed = FALSE; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
130 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
131 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
132 GtkWidget* ui_skinned_horizontal_slider_new(GtkWidget *fixed, gint x, gint y, gint w, gint h, gint knx, gint kny, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
133 gint kpx, gint kpy, gint kw, gint kh, gint fh, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
134 gint fo, gint min, gint max, gint(*fcb) (gint), SkinPixmapId si) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
135 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
136 UiSkinnedHorizontalSlider *hs = g_object_new (ui_skinned_horizontal_slider_get_type (), NULL); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
137 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
138 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
139 hs->x = x; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
140 hs->y = y; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
141 priv->width = w; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
142 priv->height = h; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
143 hs->knob_nx = knx; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
144 hs->knob_ny = kny; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
145 hs->knob_px = kpx; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
146 hs->knob_py = kpy; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
147 priv->knob_width = kw; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
148 priv->knob_height = kh; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
149 priv->frame_height = fh; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
150 priv->frame_offset = fo; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
151 priv->min = min; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
152 priv->position = min; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
153 priv->max = max; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
154 priv->frame_cb = fcb; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
155 if (priv->frame_cb) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
156 priv->frame = priv->frame_cb(0); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
157 priv->skin_index = si; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
158 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
159 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(hs), hs->x, hs->y); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
160 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
161 return GTK_WIDGET(hs); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
162 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
163 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
164 static void ui_skinned_horizontal_slider_destroy(GtkObject *object) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
165 UiSkinnedHorizontalSlider *horizontal_slider; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
166 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
167 g_return_if_fail (object != NULL); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
168 g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (object)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
169 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
170 horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER (object); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
171 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
172 if (GTK_OBJECT_CLASS (parent_class)->destroy) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
173 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
174 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
175 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
176 static void ui_skinned_horizontal_slider_realize(GtkWidget *widget) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
177 UiSkinnedHorizontalSlider *horizontal_slider; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
178 GdkWindowAttr attributes; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
179 gint attributes_mask; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
180 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
181 g_return_if_fail (widget != NULL); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
182 g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER(widget)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
183 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
184 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
185 horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
186 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
187 attributes.x = widget->allocation.x; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
188 attributes.y = widget->allocation.y; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
189 attributes.width = widget->allocation.width; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
190 attributes.height = widget->allocation.height; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
191 attributes.wclass = GDK_INPUT_OUTPUT; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
192 attributes.window_type = GDK_WINDOW_CHILD; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
193 attributes.event_mask = gtk_widget_get_events(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
194 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
195 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
196 attributes.visual = gtk_widget_get_visual(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
197 attributes.colormap = gtk_widget_get_colormap(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
198 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
199 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
200 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
201 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
202 widget->style = gtk_style_attach(widget->style, widget->window); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
203 gdk_window_set_user_data(widget->window, widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
204 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
205 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
206 static void ui_skinned_horizontal_slider_size_request(GtkWidget *widget, GtkRequisition *requisition) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
207 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
208 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
209 requisition->width = priv->width*(priv->scaled ? config.scale_factor : 1); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
210 requisition->height = priv->height*(priv->scaled ? config.scale_factor : 1); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
211 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
212 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
213 static void ui_skinned_horizontal_slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
214 UiSkinnedHorizontalSlider *horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER (widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
215 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(horizontal_slider); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
216 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
217 widget->allocation = *allocation; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
218 widget->allocation.x = ceil(widget->allocation.x*(priv->scaled ? config.scale_factor : 1)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
219 widget->allocation.y = ceil(widget->allocation.y*(priv->scaled ? config.scale_factor : 1)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
220 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
221 if (priv->knob_height == priv->height) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
222 priv->knob_height = ceil(allocation->height/(priv->scaled ? config.scale_factor : 1)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
223 priv->width = ceil(allocation->width/(priv->scaled ? config.scale_factor : 1)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
224 priv->height = ceil(allocation->height/(priv->scaled ? config.scale_factor : 1)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
225 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
226 if (GTK_WIDGET_REALIZED (widget)) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
227 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
228 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
229 horizontal_slider->x = ceil(widget->allocation.x/(priv->scaled ? config.scale_factor : 1)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
230 horizontal_slider->y = ceil(widget->allocation.y/(priv->scaled ? config.scale_factor : 1)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
231 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
232 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
233 static gboolean ui_skinned_horizontal_slider_expose(GtkWidget *widget, GdkEventExpose *event) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
234 g_return_val_if_fail (widget != NULL, FALSE); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
235 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
236 g_return_val_if_fail (event != NULL, FALSE); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
237 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
238 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER (widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
239 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
240 g_return_val_if_fail (priv->width > 0 && priv->height > 0, FALSE); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
241 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
242 GdkPixbuf *obj = NULL; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
243 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
244 if (priv->position > priv->max) priv->position = priv->max; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
245 else if (priv->position < priv->min) priv->position = priv->min; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
246 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
247 obj = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, priv->width, priv->height); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
248 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
249 skin_draw_pixbuf(widget, aud_active_skin, obj, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
250 priv->skin_index, priv->frame_offset, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
251 priv->frame * priv->frame_height, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
252 0, 0, priv->width, priv->height); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
253 if (hs->pressed) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
254 skin_draw_pixbuf(widget, aud_active_skin, obj, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
255 priv->skin_index, hs->knob_px, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
256 hs->knob_py, priv->position, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
257 ((priv->height - priv->knob_height) / 2), |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
258 priv->knob_width, priv->knob_height); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
259 else |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
260 skin_draw_pixbuf(widget, aud_active_skin, obj, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
261 priv->skin_index, hs->knob_nx, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
262 hs->knob_ny, priv->position, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
263 ((priv->height - priv->knob_height) / 2), |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
264 priv->knob_width, priv->knob_height); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
265 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
266 ui_skinned_widget_draw(widget, obj, priv->width, priv->height, priv->scaled); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
267 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
268 g_object_unref(obj); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
269 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
270 return FALSE; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
271 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
272 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
273 static gboolean ui_skinned_horizontal_slider_button_press(GtkWidget *widget, GdkEventButton *event) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
274 g_return_val_if_fail (widget != NULL, FALSE); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
275 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
276 g_return_val_if_fail (event != NULL, FALSE); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
277 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
278 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER (widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
279 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
280 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
281 if (event->type == GDK_BUTTON_PRESS) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
282 if (event->button == 1) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
283 gint x; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
284 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
285 x = event->x - (priv->knob_width / (priv->scaled ? 1 : config.scale_factor)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
286 hs->pressed = TRUE; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
287 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
288 priv->position = x/(priv->scaled ? config.scale_factor : 1); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
289 if (priv->position < priv->min) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
290 priv->position = priv->min; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
291 if (priv->position > priv->max) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
292 priv->position = priv->max; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
293 if (priv->frame_cb) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
294 priv->frame = priv->frame_cb(priv->position); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
295 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
296 g_signal_emit_by_name(widget, "motion", priv->position); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
297 gtk_widget_queue_draw(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
298 } else if (event->button == 3) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
299 if (hs->pressed) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
300 hs->pressed = FALSE; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
301 g_signal_emit_by_name(widget, "release", priv->position); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
302 gtk_widget_queue_draw(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
303 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
304 event->x = event->x + hs->x; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
305 event->y = event->y + hs->y; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
306 return FALSE; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
307 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
308 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
309 return TRUE; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
310 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
311 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
312 static gboolean ui_skinned_horizontal_slider_button_release(GtkWidget *widget, GdkEventButton *event) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
313 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
314 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
315 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
316 if (hs->pressed) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
317 hs->pressed = FALSE; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
318 g_signal_emit_by_name(widget, "release", priv->position); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
319 gtk_widget_queue_draw(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
320 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
321 return TRUE; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
322 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
323 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
324 static gboolean ui_skinned_horizontal_slider_motion_notify(GtkWidget *widget, GdkEventMotion *event) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
325 g_return_val_if_fail (widget != NULL, FALSE); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
326 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
327 g_return_val_if_fail (event != NULL, FALSE); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
328 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
329 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
330 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
331 if (hs->pressed) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
332 gint x; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
333 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
334 x = event->x - (priv->knob_width / (priv->scaled ? 1 : config.scale_factor)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
335 priv->position = x/(priv->scaled ? config.scale_factor : 1); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
336 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
337 if (priv->position < priv->min) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
338 priv->position = priv->min; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
339 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
340 if (priv->position > priv->max) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
341 priv->position = priv->max; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
342 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
343 if (priv->frame_cb) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
344 priv->frame = priv->frame_cb(priv->position); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
345 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
346 g_signal_emit_by_name(widget, "motion", priv->position); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
347 gtk_widget_queue_draw(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
348 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
349 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
350 return TRUE; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
351 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
352 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
353 static void ui_skinned_horizontal_slider_toggle_scaled(UiSkinnedHorizontalSlider *horizontal_slider) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
354 GtkWidget *widget = GTK_WIDGET (horizontal_slider); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
355 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(horizontal_slider); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
356 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
357 priv->scaled = !priv->scaled; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
358 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
359 gtk_widget_set_size_request(widget, |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
360 priv->width*(priv->scaled ? config.scale_factor : 1), |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
361 priv->height*(priv->scaled ? config.scale_factor : 1)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
362 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
363 gtk_widget_queue_draw(GTK_WIDGET(horizontal_slider)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
364 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
365 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
366 void ui_skinned_horizontal_slider_set_position(GtkWidget *widget, gint pos) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
367 g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget)); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
368 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
369 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
370 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
371 if (pos == priv->position || hs->pressed) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
372 return; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
373 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
374 priv->position = pos; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
375 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
376 if (priv->frame_cb) |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
377 priv->frame = priv->frame_cb(priv->position); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
378 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
379 gtk_widget_queue_draw(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
380 } |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
381 |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
382 gint ui_skinned_horizontal_slider_get_position(GtkWidget *widget) { |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
383 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), -1); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
384 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget); |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
385 return priv->position; |
edf99201700e
add ui_skinned_horizontal_slider
Tomasz Mon <desowin@gmail.com>
parents:
diff
changeset
|
386 } |