Permalink
Browse files

skin: Make list scrollbar focusable

Also when moving the scrollbar, make sure focused item in list follows on

Fixes #1111
  • Loading branch information...
1 parent ddcec93 commit 2e8bb82c1345cbb609c3125e729d2e76df1bf571 @andoma committed Feb 17, 2014
Showing with 29 additions and 3 deletions.
  1. +0 −2 glwskins/default/pages/list.view
  2. +29 −1 src/ui/glw/glw_list.c
@@ -44,9 +44,7 @@ widget(keyintercept, {
bind("list");
width: 4;
focusable: 0.001; // canScroll();
- navFocusable: false;
alpha: iir(canScroll(), 16);
-
widget(quad, {
alpha: iir(0.3 + 0.3 * (isFocused() || isPressed()), 4) + isHovered();
});
View
@@ -489,7 +489,35 @@ glw_list_render_x(glw_t *w, const glw_rctx_t *rc)
static void
glw_list_scroll(glw_list_t *l, glw_scroll_t *gs)
{
- l->current_pos = GLW_MAX(gs->value * (l->total_size - l->page_size), 0);
+ int top = GLW_MAX(gs->value * (l->total_size - l->page_size), 0);
+
+ l->current_pos = top;
+
+ int bottom = top + l->page_size;
+
+ glw_t *c = l->w.glw_focused;
+
+ if(c == NULL)
+ return;
+
+
+ if(c->glw_parent_pos < top) {
+
+ while(c != NULL && c->glw_parent_pos < top) {
+ c = glw_next_widget(c);
+ }
+
+ if(c != NULL)
+ l->w.glw_focused = c;
+ } else if(c->glw_parent_pos > bottom) {
+
+ while(c != NULL && c->glw_parent_pos > bottom) {
+ c = glw_prev_widget(c);
+ }
+
+ if(c != NULL)
+ l->w.glw_focused = c;
+ }
}

0 comments on commit 2e8bb82

Please sign in to comment.