diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-09-13 21:28:42 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-09-13 21:28:42 +0200 |
commit | 4aad1caca1c99b45a17f9137cea8cfb49ac1d761 (patch) | |
tree | 87bc993496e0c24adbec4a2488ea183feb79f160 | |
parent | eb14be53caa2a3b0023527548d10c1b9f46595ee (diff) |
tab scrolling now affects current tab
-rw-r--r-- | plugins/gtkui/ddbtabstrip.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c index fa68759d..7830cb8a 100644 --- a/plugins/gtkui/ddbtabstrip.c +++ b/plugins/gtkui/ddbtabstrip.c @@ -728,7 +728,32 @@ create_plmenu (void) } static void +tabstrip_scroll_to_tab (DdbTabStrip *ts, int tab) { + GtkWidget *widget = GTK_WIDGET (ts); + int w = 0; + int cnt = deadbeef->plt_get_count (); + int boundary = widget->allocation.width - arrow_widget_width*2 + ts->hscrollpos; + for (int idx = 0; idx < cnt; idx++) { + int tab_w = ddb_tabstrip_get_tab_width (ts, idx); + if (idx == tab) { + if (w < ts->hscrollpos) { + ts->hscrollpos = w; + deadbeef->conf_set_int ("gtkui.tabscroll", ts->hscrollpos); + } + else if (w < boundary && w + tab_w >= boundary) { + ts->hscrollpos += (w+tab_w) - boundary; + deadbeef->conf_set_int ("gtkui.tabscroll", ts->hscrollpos); + } + gtk_widget_queue_draw (widget); + break; + } + w += tab_w - tab_overlap_size; + } +} + +static void tabstrip_scroll_left (DdbTabStrip *ts) { +#if 0 // scroll to leftmost border-spanning tab int scrollsize = 0; int w = 0; @@ -749,10 +774,19 @@ tabstrip_scroll_left (DdbTabStrip *ts) { } deadbeef->conf_set_int ("gtkui.tabscroll", ts->hscrollpos); gtk_widget_queue_draw (GTK_WIDGET (ts)); +#endif + int tab = deadbeef->plt_get_curr (); + if (tab > 0) { + tab--; + deadbeef->plt_set_curr (tab); + deadbeef->conf_set_int ("playlist.current", tab); + tabstrip_scroll_to_tab (ts, tab); + } } static void tabstrip_scroll_right (DdbTabStrip *ts) { +#if 0 // scroll to rightmost border-spanning tab GtkWidget *widget = GTK_WIDGET (ts); int scrollsize = 0; @@ -774,6 +808,14 @@ tabstrip_scroll_right (DdbTabStrip *ts) { } deadbeef->conf_set_int ("gtkui.tabscroll", ts->hscrollpos); gtk_widget_queue_draw (widget); +#endif + int tab = deadbeef->plt_get_curr (); + if (tab < deadbeef->plt_get_count ()-1) { + tab++; + deadbeef->plt_set_curr (tab); + deadbeef->conf_set_int ("playlist.current", tab); + tabstrip_scroll_to_tab (ts, tab); + } } gboolean @@ -835,6 +877,11 @@ on_tabstrip_button_press_event (GtkWidget *widget, return FALSE; } + // adjust scroll if clicked tab spans border + if (need_arrows) { + tabstrip_scroll_to_tab (ts, tab_clicked); + } + int hscroll = ts->hscrollpos; if (need_arrows) { hscroll -= arrow_widget_width; |