Mercurial > audlegacy
comparison src/audacious/ui_skinned_horizontal_slider.c @ 3095:5a7dea5211f3
branch merge
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Tue, 17 Jul 2007 18:33:49 +0900 |
parents | 4b076ad636e6 |
children | 1faf842dea49 |
comparison
equal
deleted
inserted
replaced
3094:7fbe8ada95ca | 3095:5a7dea5211f3 |
---|---|
23 */ | 23 */ |
24 | 24 |
25 #include "widgets/widgetcore.h" | 25 #include "widgets/widgetcore.h" |
26 #include "ui_skinned_horizontal_slider.h" | 26 #include "ui_skinned_horizontal_slider.h" |
27 #include "main.h" | 27 #include "main.h" |
28 #include "util.h" | |
28 #include <gtk/gtkmain.h> | 29 #include <gtk/gtkmain.h> |
29 #include <gtk/gtkmarshal.h> | 30 #include <gtk/gtkmarshal.h> |
30 #include <gtk/gtkimage.h> | 31 #include <gtk/gtkimage.h> |
31 | 32 |
32 #define UI_TYPE_SKINNED_HORIZONTAL_SLIDER (ui_skinned_horizontal_slider_get_type()) | 33 #define UI_TYPE_SKINNED_HORIZONTAL_SLIDER (ui_skinned_horizontal_slider_get_type()) |
194 attributes.height = widget->allocation.height; | 195 attributes.height = widget->allocation.height; |
195 attributes.wclass = GDK_INPUT_OUTPUT; | 196 attributes.wclass = GDK_INPUT_OUTPUT; |
196 attributes.window_type = GDK_WINDOW_CHILD; | 197 attributes.window_type = GDK_WINDOW_CHILD; |
197 attributes.event_mask = gtk_widget_get_events(widget); | 198 attributes.event_mask = gtk_widget_get_events(widget); |
198 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | | 199 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | |
199 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | | 200 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; |
200 GDK_POINTER_MOTION_HINT_MASK; | |
201 attributes.visual = gtk_widget_get_visual(widget); | 201 attributes.visual = gtk_widget_get_visual(widget); |
202 attributes.colormap = gtk_widget_get_colormap(widget); | 202 attributes.colormap = gtk_widget_get_colormap(widget); |
203 | 203 |
204 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; | 204 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; |
205 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); | 205 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask); |
206 | 206 |
207 widget->style = gtk_style_attach(widget->style, widget->window); | |
207 gdk_window_set_user_data(widget->window, widget); | 208 gdk_window_set_user_data(widget->window, widget); |
208 } | 209 } |
209 | 210 |
210 static void ui_skinned_horizontal_slider_size_request(GtkWidget *widget, GtkRequisition *requisition) { | 211 static void ui_skinned_horizontal_slider_size_request(GtkWidget *widget, GtkRequisition *requisition) { |
211 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget); | 212 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget); |
236 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER (widget); | 237 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER (widget); |
237 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs); | 238 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs); |
238 | 239 |
239 GdkPixmap *obj = NULL; | 240 GdkPixmap *obj = NULL; |
240 GdkGC *gc; | 241 GdkGC *gc; |
242 | |
243 if (priv->position > priv->max) priv->position = priv->max; | |
244 else if (priv->position < priv->min) priv->position = priv->min; | |
241 | 245 |
242 obj = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth); | 246 obj = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth); |
243 gc = gdk_gc_new(obj); | 247 gc = gdk_gc_new(obj); |
244 | 248 |
245 skin_draw_pixmap(bmp_active_skin, obj, gc, | 249 skin_draw_pixmap(bmp_active_skin, obj, gc, |
257 priv->skin_index, hs->knob_nx, | 261 priv->skin_index, hs->knob_nx, |
258 hs->knob_ny, priv->position, | 262 hs->knob_ny, priv->position, |
259 ((priv->height - priv->knob_height) / 2), | 263 ((priv->height - priv->knob_height) / 2), |
260 priv->knob_width, priv->knob_height); | 264 priv->knob_width, priv->knob_height); |
261 | 265 |
262 GdkPixmap *image; | 266 GdkPixmap *image = NULL; |
263 image = gdk_pixmap_new(NULL, priv->width*(1+priv->double_size), | |
264 priv->height*(1+priv->double_size), | |
265 gdk_rgb_get_visual()->depth); | |
266 | 267 |
267 if (priv->double_size) { | 268 if (priv->double_size) { |
268 GdkPixbuf *img, *img2x; | 269 image = create_dblsize_pixmap(obj); |
269 GdkColormap *colormap = gdk_colormap_get_system(); | 270 } else { |
270 img = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, priv->width, priv->height); | 271 image = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth); |
271 gdk_pixbuf_get_from_drawable(img, obj, colormap, 0, 0, 0, 0, priv->width, priv->height); | |
272 img2x = gdk_pixbuf_scale_simple(img, priv->width*2, priv->height*2, GDK_INTERP_NEAREST); | |
273 gdk_draw_pixbuf (image, gc, img2x, 0, 0, 0, 0, priv->width*2, priv->height*2, GDK_RGB_DITHER_NONE, 0, 0); | |
274 g_object_unref(img); | |
275 g_object_unref(img2x); | |
276 g_object_unref(colormap); | |
277 } else | |
278 gdk_draw_drawable (image, gc, obj, 0, 0, 0, 0, priv->width, priv->height); | 272 gdk_draw_drawable (image, gc, obj, 0, 0, 0, 0, priv->width, priv->height); |
279 | 273 } |
280 | 274 |
281 g_object_unref(obj); | 275 g_object_unref(obj); |
282 | 276 |
283 gdk_draw_drawable (widget->window, gc, image, 0, 0, 0, 0, | 277 gdk_draw_drawable (widget->window, gc, image, 0, 0, 0, 0, |
284 priv->width*(1+priv->double_size), priv->height*(1+priv->double_size)); | 278 priv->width*(1+priv->double_size), priv->height*(1+priv->double_size)); |
298 | 292 |
299 if (event->type == GDK_BUTTON_PRESS) { | 293 if (event->type == GDK_BUTTON_PRESS) { |
300 if (event->button == 1) { | 294 if (event->button == 1) { |
301 gint x; | 295 gint x; |
302 | 296 |
303 x = event->x - priv->knob_width / 2; | 297 x = event->x - (priv->knob_width / (priv->double_size ? 1 : 2)); |
304 hs->pressed = TRUE; | 298 hs->pressed = TRUE; |
305 | 299 |
306 priv->position = x; | 300 priv->position = x/(1+priv->double_size); |
307 if (priv->position < priv->min) | 301 if (priv->position < priv->min) |
308 priv->position = priv->min; | 302 priv->position = priv->min; |
309 if (priv->position > priv->max) | 303 if (priv->position > priv->max) |
310 priv->position = priv->max; | 304 priv->position = priv->max; |
311 if (priv->frame_cb) | 305 if (priv->frame_cb) |
338 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget); | 332 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget); |
339 | 333 |
340 if (hs->pressed) { | 334 if (hs->pressed) { |
341 gint x; | 335 gint x; |
342 | 336 |
343 x = event->x; | 337 x = event->x - (priv->knob_width / (priv->double_size ? 1 : 2)); |
344 priv->position = x; | 338 priv->position = x/(1+priv->double_size); |
345 | 339 |
346 if (priv->position < priv->min) | 340 if (priv->position < priv->min) |
347 priv->position = priv->min; | 341 priv->position = priv->min; |
348 | 342 |
349 if (priv->position > priv->max) | 343 if (priv->position > priv->max) |