Skip to content

Commit

Permalink
fix(widget): Scrollbar_BindBox() not working after scrollbar initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Feb 20, 2018
1 parent 8c1d105 commit 196f47c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/gui/widget/scrollbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ static void Slider_OnMouseDown( LCUI_Widget slider,
Widget_BindEvent( slider, "mouseup", Slider_OnMouseUp, w, NULL );
}

static void ScrollBar_OnLink( LCUI_Widget w, LCUI_WidgetEvent e, void *arg )
{
LCUI_ScrollBar scrollbar = Widget_GetData( w, self.prototype );
if( !scrollbar->box ) {
ScrollBar_BindBox( w, w->parent );
}
}

static void ScrollBar_OnInit( LCUI_Widget w )
{
LCUI_Widget slider;
Expand All @@ -329,9 +337,9 @@ static void ScrollBar_OnInit( LCUI_Widget w )
InitInertialScrolling( &scrollbar->effect );
Widget_BindEvent( slider, "mousedown",
Slider_OnMouseDown, w, NULL );
Widget_BindEvent( w, "link", ScrollBar_OnLink, NULL, NULL );
Widget_AddClass( slider, "scrollbar-slider" );
Widget_Append( w, slider );
ScrollBar_BindBox( w, w->parent );
}

static void ScrollBar_UpdateSize( LCUI_Widget w )
Expand Down Expand Up @@ -493,8 +501,10 @@ void ScrollBar_BindBox( LCUI_Widget w, LCUI_Widget box )
ScrollBar_OnUpdateSize );
}
scrollbar->box = box;
Widget_BindEvent( box, "resize", ScrollBar_OnUpdateSize, w, NULL );
Widget_BindEvent( box, "setscroll", ScrollBar_OnSetPosition, w, NULL );
if( box ) {
Widget_BindEvent( box, "resize", ScrollBar_OnUpdateSize, w, NULL );
Widget_BindEvent( box, "setscroll", ScrollBar_OnSetPosition, w, NULL );
}
ScrollBar_UpdateSize( w );
}

Expand Down

0 comments on commit 196f47c

Please sign in to comment.