changeset 2968:83f03505f819 trunk

add support for one-way text scroll.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Mon, 02 Jul 2007 21:02:49 +0900
parents 53ebe56cb0ac
children 9fe0d8b6d1b5
files src/audacious/main.c src/audacious/main.h src/audacious/ui_skinned_textbox.c
diffstat 3 files changed, 70 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/main.c	Mon Jul 02 12:50:26 2007 +0200
+++ b/src/audacious/main.c	Mon Jul 02 21:02:49 2007 +0900
@@ -221,6 +221,7 @@
     FALSE,          /* internal: whether or not to terminate */
     TRUE,           /* whether show progress bar in filepopup or not */
     TRUE,           /* close jtf dialog on jump */
+    FALSE,          /* use back and forth scroll */
 };
 
 typedef struct bmp_cfg_boolent_t {
@@ -323,6 +324,7 @@
     {"use_extension_probing", &cfg.use_extension_probing, TRUE},
     {"filepopup_showprogressbar", &cfg.filepopup_showprogressbar, TRUE},
     {"close_jtf_dialog", &cfg.close_jtf_dialog, TRUE},
+    {"twoway_scroll", &cfg.twoway_scroll, TRUE},
 };
 
 static gint ncfgbent = G_N_ELEMENTS(bmp_boolents);
--- a/src/audacious/main.h	Mon Jul 02 12:50:26 2007 +0200
+++ b/src/audacious/main.h	Mon Jul 02 21:02:49 2007 +0900
@@ -125,6 +125,7 @@
     gboolean terminate;
     gboolean filepopup_showprogressbar;
     gboolean close_jtf_dialog;
+    gboolean twoway_scroll;
 };
 
 typedef struct _BmpConfig BmpConfig;
--- a/src/audacious/ui_skinned_textbox.c	Mon Jul 02 12:50:26 2007 +0200
+++ b/src/audacious/ui_skinned_textbox.c	Mon Jul 02 21:02:49 2007 +0900
@@ -433,24 +433,56 @@
             }
             obj = gdk_pixmap_new(NULL, textbox->width, textbox->height, gdk_rgb_get_visual()->depth);
 
-            cw = priv->pixmap_width - priv->offset;
-            if (cw > textbox->width)
-                cw = textbox->width;
-            gdk_draw_drawable(obj, priv->gc, priv->pixmap, priv->offset, 0, 0, 0, cw, textbox->height);
-            if (cw < textbox->width)
-                gdk_draw_drawable(obj, priv->gc, priv->pixmap, 0, 0,
-                                  textbox->x + cw, textbox->y,
-                                  textbox->width - cw, textbox->height);
+            if(cfg.twoway_scroll) { // twoway scroll
+                cw = priv->pixmap_width - priv->offset;
+                if (cw > textbox->width)
+                    cw = textbox->width;
+                gdk_draw_drawable(obj, priv->gc, priv->pixmap, priv->offset, 0, 0, 0, cw, textbox->height);
+                if (cw < textbox->width)
+                    gdk_draw_drawable(obj, priv->gc, priv->pixmap, 0, 0,
+                                      textbox->x + cw, textbox->y,
+                                      textbox->width - cw, textbox->height);
+
+                if (priv->double_size) {
+                    GdkImage *img, *img2x;
+                    img = gdk_drawable_get_image(obj, 0, 0, textbox->width, textbox->height);
+                    img2x = create_dblsize_image(img);
+                    gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL);
+                    g_object_unref(img2x);
+                    g_object_unref(img);
+                } else
+                    gtk_image_set_from_pixmap(GTK_IMAGE(priv->image), obj, NULL);
+            }
+            else { // oneway scroll
+                int cw1, cw2;
 
-            if (priv->double_size) {
-                GdkImage *img, *img2x;
-                img = gdk_drawable_get_image(obj, 0, 0, textbox->width, textbox->height);
-                img2x = create_dblsize_image(img);
-                gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL);
-                g_object_unref(img2x);
-                g_object_unref(img);
-            } else
-                gtk_image_set_from_pixmap(GTK_IMAGE(priv->image), obj, NULL);
+                if(priv->offset >= priv->pixmap_width)
+                    priv->offset = 0;
+
+                if(priv->pixmap_width - priv->offset > textbox->width){ // case1
+                    cw1 = textbox->width;
+                    gdk_draw_drawable(obj, priv->gc, priv->pixmap, priv->offset, 0,
+                                      0, 0, cw1, textbox->height);
+                }
+                else { // case 2
+                    cw1 = priv->pixmap_width - priv->offset;
+                    gdk_draw_drawable(obj, priv->gc, priv->pixmap, priv->offset, 0,
+                                      0, 0, cw1, textbox->height);
+                    cw2 = textbox->width - cw1;
+                    gdk_draw_drawable(obj, priv->gc, priv->pixmap, 0, 0, cw1, 0, cw2, textbox->height);
+                }
+
+                if (priv->double_size) {
+                    GdkImage *img, *img2x;
+                    img = gdk_drawable_get_image(obj, 0, 0, textbox->width, textbox->height);
+                    img2x = create_dblsize_image(img);
+                    gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL);
+                    g_object_unref(img2x);
+                    g_object_unref(img);
+                } else {
+                    gtk_image_set_from_pixmap(GTK_IMAGE(priv->image), obj, NULL);
+                }
+            }
 
             g_object_unref(obj);
             gtk_widget_queue_resize(widget);
@@ -615,19 +647,29 @@
     UiSkinnedTextboxPrivate *priv = UI_SKINNED_TEXTBOX_GET_PRIVATE (data);
 
     if (!priv->is_dragging) {
-        if (priv->scroll_dummy < TEXTBOX_SCROLL_WAIT) priv->scroll_dummy++;
+        if (priv->scroll_dummy < TEXTBOX_SCROLL_WAIT)
+            priv->scroll_dummy++;
         else {
-            if (priv->scroll_back) priv->offset -= 1;
-            else priv->offset += 1;
+            if(cfg.twoway_scroll) {
+                if (priv->scroll_back)
+                    priv->offset -= 1;
+                else
+                    priv->offset += 1;
 
-            if (priv->offset >= (priv->pixmap_width - textbox->width)) {
-                priv->scroll_back = TRUE;
-                priv->scroll_dummy = 0;
+                if (priv->offset >= (priv->pixmap_width - textbox->width)) {
+                    priv->scroll_back = TRUE;
+                    priv->scroll_dummy = 0;
+                }
+                if (priv->offset <= 0) {
+                    priv->scroll_back = FALSE;
+                    priv->scroll_dummy = 0;
+                }
             }
-            if (priv->offset <= 0) {
+            else { // oneway scroll
                 priv->scroll_back = FALSE;
-                priv->scroll_dummy = 0;
+                priv->offset += 1;
             }
+
             textbox->redraw = TRUE;
             gtk_widget_queue_draw(GTK_WIDGET(textbox));
         }