Mercurial > audlegacy
changeset 2944:3c66c8d03c53 trunk
make what ui_skinned_textbox_resize_relative did in a better way
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Sat, 30 Jun 2007 21:20:49 +0200 |
parents | a8f2c99727eb |
children | 09c216d437b2 9786f55d73a3 |
files | src/audacious/ui_playlist.c src/audacious/ui_skinned_textbox.c src/audacious/ui_skinned_textbox.h |
diffstat | 3 files changed, 31 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/ui_playlist.c Sat Jun 30 19:46:21 2007 +0200 +++ b/src/audacious/ui_playlist.c Sat Jun 30 21:20:49 2007 +0200 @@ -665,7 +665,7 @@ widget_move_relative(WIDGET(playlistwin_slider), dx, 0); widget_resize_relative(WIDGET(playlistwin_slider), 0, dy); - ui_skinned_textbox_resize_relative(playlistwin_sinfo, dx, 0); + UI_SKINNED_TEXTBOX(playlistwin_sinfo)->weight += dx; playlistwin_update_sinfo(playlist_get_active()); ui_skinned_button_move_relative(playlistwin_shade, dx, 0);
--- a/src/audacious/ui_skinned_textbox.c Sat Jun 30 19:46:21 2007 +0200 +++ b/src/audacious/ui_skinned_textbox.c Sat Jun 30 21:20:49 2007 +0200 @@ -48,7 +48,6 @@ struct _UiSkinnedTextboxPrivate { GtkWidget *image; GdkGC *gc; - gint w; SkinPixmapId skin_index; GtkWidget *fixed; gboolean double_size; @@ -269,7 +268,7 @@ textbox->x = x; textbox->y = y; priv->gc = gc; - priv->w = w; + textbox->weight = w; priv->scroll_allowed = allow_scroll; priv->scroll_enabled = TRUE; priv->skin_index = si; @@ -280,7 +279,7 @@ priv->fixed = fixed; priv->double_size = FALSE; - gtk_widget_set_size_request(widget, priv->w, textbox->height); + gtk_widget_set_size_request(widget, textbox->weight, textbox->height); gtk_fixed_put(GTK_FIXED(priv->fixed), widget, textbox->x, textbox->y); } @@ -306,12 +305,12 @@ textbox->x = widget->allocation.x/(priv->double_size ? 2 : 1); textbox->y = widget->allocation.y/(priv->double_size ? 2 : 1); - if (priv->w != widget->allocation.width) { - priv->w = widget->allocation.width; + if (textbox->weight != widget->allocation.width) { + textbox->weight = widget->allocation.width; if (priv->pixmap_text) g_free(priv->pixmap_text); priv->pixmap_text = NULL; priv->offset = 0; - ui_skinned_textbox_redraw(textbox); + textbox->redraw = TRUE; } } @@ -324,7 +323,7 @@ if (event->button == 1) { if (priv->scroll_allowed) { - if ((priv->pixmap_width > priv->w) && priv->is_scrollable) { + if ((priv->pixmap_width > textbox->weight) && priv->is_scrollable) { priv->is_dragging = TRUE; textbox->redraw = TRUE; priv->drag_off = priv->offset; @@ -361,16 +360,17 @@ if (priv->is_dragging) { if (priv->scroll_allowed && - priv->pixmap_width > priv->w) { + priv->pixmap_width > textbox->weight) { priv->offset = priv->drag_off - (event->x - priv->drag_x); while (priv->offset < 0) priv->offset = 0; - while (priv->offset > (priv->pixmap_width - priv->w)) - priv->offset = (priv->pixmap_width - priv->w); + while (priv->offset > (priv->pixmap_width - textbox->weight)) + priv->offset = (priv->pixmap_width - textbox->weight); - ui_skinned_textbox_redraw(textbox); + textbox->redraw = TRUE; + ui_skinned_textbox_paint(textbox); } } @@ -386,7 +386,7 @@ UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (textbox); priv->double_size = !priv->double_size; - gtk_widget_set_size_request(widget, priv->w*(1+priv->double_size), textbox->height*(1+priv->double_size)); + gtk_widget_set_size_request(widget, textbox->weight*(1+priv->double_size), textbox->height*(1+priv->double_size)); gtk_widget_set_uposition(widget, textbox->x*(1+priv->double_size), textbox->y*(1+priv->double_size)); textbox->redraw = TRUE; @@ -410,21 +410,21 @@ priv->skin_id = skin_get_id(); textbox_generate_pixmap(textbox); } - obj = gdk_pixmap_new(NULL, priv->w, textbox->height, gdk_rgb_get_visual()->depth); + obj = gdk_pixmap_new(NULL, textbox->weight, textbox->height, gdk_rgb_get_visual()->depth); src = priv->pixmap; cw = priv->pixmap_width - priv->offset; - if (cw > priv->w) - cw = priv->w; + if (cw > textbox->weight) + cw = textbox->weight; gdk_draw_drawable(obj, priv->gc, src, priv->offset, 0, 0, 0, cw, textbox->height); - if (cw < priv->w) + if (cw < textbox->weight) gdk_draw_drawable(obj, priv->gc, src, 0, 0, textbox->x + cw, textbox->y, - priv->w - cw, textbox->height); + textbox->weight - cw, textbox->height); if (priv->double_size) { GdkImage *img, *img2x; - img = gdk_drawable_get_image(obj, 0, 0, priv->w, textbox->height); + img = gdk_drawable_get_image(obj, 0, 0, textbox->weight, textbox->height); img2x = create_dblsize_image(img); gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL); g_object_unref(img2x); @@ -440,6 +440,11 @@ static void ui_skinned_textbox_redraw(UiSkinnedTextbox *textbox) { textbox->redraw = TRUE; + gint w, h; + UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (textbox); + gtk_widget_get_size_request(GTK_WIDGET(textbox), &w, &h); + if (w != textbox->weight || h != textbox->height) + gtk_widget_set_size_request(GTK_WIDGET(textbox), textbox->weight, textbox->height); ui_skinned_textbox_paint(textbox); } @@ -452,13 +457,13 @@ gint width; text_get_extents(priv->fontname, textbox->text, &width, NULL, NULL, NULL); - if (width <= priv->w) + if (width <= textbox->weight) return FALSE; else return TRUE; } - if (g_utf8_strlen(textbox->text, -1) * bmp_active_skin->properties.textbox_bitmap_font_width > priv->w) + if (g_utf8_strlen(textbox->text, -1) * bmp_active_skin->properties.textbox_bitmap_font_width > textbox->weight) return TRUE; return FALSE; @@ -540,7 +545,7 @@ text_get_extents(priv->fontname, pixmaptext, &width, NULL, NULL, NULL); - priv->pixmap_width = MAX(width, priv->w); + priv->pixmap_width = MAX(width, textbox->weight); priv->pixmap = gdk_pixmap_new(mainwin->window, priv->pixmap_width, textbox->height, gdk_rgb_get_visual()->depth); @@ -588,7 +593,7 @@ if (priv->scroll_back) priv->offset -= 1; else priv->offset += 1; - if (priv->offset >= (priv->pixmap_width - priv->w)) { + if (priv->offset >= (priv->pixmap_width - textbox->weight)) { priv->scroll_back = TRUE; /* There are 1 million microseconds per second */ //g_usleep(1000000); @@ -632,8 +637,8 @@ * wl is the number of (partial) letters visible. Only makes * sense when using skinned font. */ - wl = priv->w / 5; - if (wl * 5 != priv->w) + wl = textbox->weight / 5; + if (wl * 5 != textbox->weight) wl++; length = g_utf8_strlen(textbox->text, -1); @@ -845,9 +850,3 @@ UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (widget); gtk_fixed_move(GTK_FIXED(priv->fixed), widget, t->x+x, t->y+y); } - -void ui_skinned_textbox_resize_relative(GtkWidget *widget, gint w, gint h) { - UiSkinnedTextbox *t = UI_SKINNED_TEXTBOX(widget); - UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (widget); - gtk_widget_set_size_request(widget, priv->w+w, t->height+h); -}
--- a/src/audacious/ui_skinned_textbox.h Sat Jun 30 19:46:21 2007 +0200 +++ b/src/audacious/ui_skinned_textbox.h Sat Jun 30 21:20:49 2007 +0200 @@ -40,7 +40,7 @@ struct _UiSkinnedTextbox { GtkBin bin; GdkWindow *event_window; - gint x, y, height; + gint x, y, weight, height; gboolean redraw; gchar *text; }; @@ -61,6 +61,5 @@ void ui_skinned_textbox_set_xfont(GtkWidget *widget, gboolean use_xfont, const gchar *fontname); void ui_skinned_textbox_set_scroll(GtkWidget *widget, gboolean scroll); void ui_skinned_textbox_move_relative(GtkWidget *widget, gint x, gint y); -void ui_skinned_textbox_resize_relative(GtkWidget *widget, gint w, gint h); #endif