diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-09-14 20:40:03 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-09-14 20:40:03 +0200 |
commit | dcc779557804cffabd17360059b22dedc74e3a10 (patch) | |
tree | ee00f2ea3ce36ffb32af2cfba2c90bd0625e4b8a | |
parent | dd29827bd606e831a6d9cf30dbcbca962654e69c (diff) |
few improvements to tabstrip autoscroll
-rw-r--r-- | plugins/gtkui/ddbtabstrip.c | 65 |
1 files changed, 38 insertions, 27 deletions
diff --git a/plugins/gtkui/ddbtabstrip.c b/plugins/gtkui/ddbtabstrip.c index 315d947e..d28efd58 100644 --- a/plugins/gtkui/ddbtabstrip.c +++ b/plugins/gtkui/ddbtabstrip.c @@ -388,6 +388,43 @@ tabstrip_need_arrows (DdbTabStrip *ts) { return 0; } +static void +tabstrip_scroll_to_tab_int (DdbTabStrip *ts, int tab, int redraw) { + 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 == cnt-1) { + tab_w += 3; + } + if (idx == tab) { + if (w < ts->hscrollpos) { + ts->hscrollpos = w; + deadbeef->conf_set_int ("gtkui.tabscroll", ts->hscrollpos); + if (redraw) { + gtk_widget_queue_draw (widget); + } + } + else if (w + tab_w >= boundary) { + ts->hscrollpos += (w+tab_w) - boundary; + deadbeef->conf_set_int ("gtkui.tabscroll", ts->hscrollpos); + if (redraw) { + gtk_widget_queue_draw (widget); + } + } + break; + } + w += tab_w - tab_overlap_size; + } +} + +static void +tabstrip_scroll_to_tab (DdbTabStrip *ts, int tab) { + tabstrip_scroll_to_tab_int (ts, tab, 1); +} + void tabstrip_adjust_hscroll (DdbTabStrip *ts) { GtkWidget *widget = GTK_WIDGET (ts); @@ -405,6 +442,7 @@ tabstrip_adjust_hscroll (DdbTabStrip *ts) { ts->hscrollpos = w - (widget->allocation.width - arrow_widget_width*2); deadbeef->conf_set_int ("gtkui.tabscroll", ts->hscrollpos); } + tabstrip_scroll_to_tab_int (ts, deadbeef->plt_get_curr (), 0); } else { ts->hscrollpos = 0; @@ -728,33 +766,6 @@ 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 == cnt-1) { - tab_w += 3; - } - 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 |