@@ -106,7 +106,7 @@ public ScrollBarView (View host, bool isVertical, bool showBothScrollIndicator =
106106 OtherScrollBarView . X = OtherScrollBarView . IsVertical ? Pos . Right ( host ) - 1 : Pos . Left ( host ) ;
107107 OtherScrollBarView . Y = OtherScrollBarView . IsVertical ? Pos . Top ( host ) : Pos . Bottom ( host ) - 1 ;
108108 OtherScrollBarView . Host . SuperView . Add ( OtherScrollBarView ) ;
109- OtherScrollBarView . showScrollIndicator = true ;
109+ OtherScrollBarView . ShowScrollIndicator = true ;
110110 }
111111 ShowScrollIndicator = true ;
112112 contentBottomRightCorner = new View ( " " ) { Visible = host . Visible } ;
@@ -116,6 +116,7 @@ public ScrollBarView (View host, bool isVertical, bool showBothScrollIndicator =
116116 contentBottomRightCorner . Width = 1 ;
117117 contentBottomRightCorner . Height = 1 ;
118118 contentBottomRightCorner . MouseClick += ContentBottomRightCorner_MouseClick ;
119+ ClearOnVisibleFalse = false ;
119120 }
120121
121122 private void Host_VisibleChanged ( )
@@ -188,11 +189,9 @@ public bool IsVertical {
188189 public int Size {
189190 get => size ;
190191 set {
191- if ( hosted || ( otherScrollBarView != null && otherScrollBarView . hosted ) ) {
192- size = value + 1 ;
193- } else {
194- size = value ;
195- }
192+ size = value ;
193+ SetRelativeLayout ( Bounds ) ;
194+ ShowHideScrollBars ( false ) ;
196195 SetNeedsDisplay ( ) ;
197196 }
198197 }
@@ -220,9 +219,6 @@ public int Position {
220219 position = Math . Max ( position + max , 0 ) ;
221220 }
222221 var s = GetBarsize ( vertical ) ;
223- if ( position + s == size && ( hosted || ( otherScrollBarView != null && otherScrollBarView . hosted ) ) ) {
224- position ++ ;
225- }
226222 OnChangedPosition ( ) ;
227223 SetNeedsDisplay ( ) ;
228224 }
@@ -327,11 +323,13 @@ public virtual void Refresh ()
327323 ShowHideScrollBars ( ) ;
328324 }
329325
330- void ShowHideScrollBars ( )
326+ void ShowHideScrollBars ( bool redraw = true )
331327 {
332328 if ( ! hosted || ( hosted && ! autoHideScrollBars ) ) {
333329 if ( contentBottomRightCorner != null && contentBottomRightCorner . Visible ) {
334330 contentBottomRightCorner . Visible = false ;
331+ } else if ( otherScrollBarView != null && otherScrollBarView . contentBottomRightCorner != null && otherScrollBarView . contentBottomRightCorner . Visible ) {
332+ otherScrollBarView . contentBottomRightCorner . Visible = false ;
335333 }
336334 return ;
337335 }
@@ -350,24 +348,34 @@ void ShowHideScrollBars ()
350348 if ( showBothScrollIndicator ) {
351349 if ( contentBottomRightCorner != null ) {
352350 contentBottomRightCorner . Visible = true ;
351+ } else if ( otherScrollBarView != null && otherScrollBarView . contentBottomRightCorner != null ) {
352+ otherScrollBarView . contentBottomRightCorner . Visible = true ;
353353 }
354354 } else if ( ! showScrollIndicator ) {
355355 if ( contentBottomRightCorner != null ) {
356356 contentBottomRightCorner . Visible = false ;
357+ } else if ( otherScrollBarView != null && otherScrollBarView . contentBottomRightCorner != null ) {
358+ otherScrollBarView . contentBottomRightCorner . Visible = false ;
357359 }
358360 if ( Application . mouseGrabView != null && Application . mouseGrabView == this ) {
359361 Application . UngrabMouse ( ) ;
360362 }
361- } else {
363+ } else if ( contentBottomRightCorner != null ) {
362364 contentBottomRightCorner . Visible = false ;
365+ } else if ( otherScrollBarView != null && otherScrollBarView . contentBottomRightCorner != null ) {
366+ otherScrollBarView . contentBottomRightCorner . Visible = false ;
363367 }
364368 if ( Host ? . Visible == true && showScrollIndicator && ! Visible ) {
365369 Visible = true ;
366370 }
367- if ( Host ? . Visible == true && otherScrollBarView != null && otherScrollBarView . showScrollIndicator
368- && ! otherScrollBarView . Visible ) {
371+ if ( Host ? . Visible == true && otherScrollBarView ? . showScrollIndicator == true && ! otherScrollBarView . Visible ) {
369372 otherScrollBarView . Visible = true ;
370373 }
374+
375+ if ( ! redraw ) {
376+ return ;
377+ }
378+
371379 if ( showScrollIndicator ) {
372380 Redraw ( Bounds ) ;
373381 }
@@ -384,24 +392,39 @@ bool CheckBothScrollBars (ScrollBarView scrollBarView, bool pending = false)
384392 if ( scrollBarView . showScrollIndicator ) {
385393 scrollBarView . ShowScrollIndicator = false ;
386394 }
395+ if ( scrollBarView . Visible ) {
396+ scrollBarView . Visible = false ;
397+ }
387398 } else if ( barsize > 0 && barsize == scrollBarView . size && scrollBarView . OtherScrollBarView != null && pending ) {
388399 if ( scrollBarView . showScrollIndicator ) {
389400 scrollBarView . ShowScrollIndicator = false ;
390401 }
402+ if ( scrollBarView . Visible ) {
403+ scrollBarView . Visible = false ;
404+ }
391405 if ( scrollBarView . OtherScrollBarView != null && scrollBarView . showBothScrollIndicator ) {
392406 scrollBarView . OtherScrollBarView . ShowScrollIndicator = false ;
393407 }
408+ if ( scrollBarView . OtherScrollBarView . Visible ) {
409+ scrollBarView . OtherScrollBarView . Visible = false ;
410+ }
394411 } else if ( barsize > 0 && barsize == size && scrollBarView . OtherScrollBarView != null && ! pending ) {
395412 pending = true ;
396413 } else {
397414 if ( scrollBarView . OtherScrollBarView != null && pending ) {
398415 if ( ! scrollBarView . showBothScrollIndicator ) {
399416 scrollBarView . OtherScrollBarView . ShowScrollIndicator = true ;
400417 }
418+ if ( ! scrollBarView . OtherScrollBarView . Visible ) {
419+ scrollBarView . OtherScrollBarView . Visible = true ;
420+ }
401421 }
402422 if ( ! scrollBarView . showScrollIndicator ) {
403423 scrollBarView . ShowScrollIndicator = true ;
404424 }
425+ if ( ! scrollBarView . Visible ) {
426+ scrollBarView . Visible = true ;
427+ }
405428 }
406429
407430 return pending ;
@@ -418,7 +441,7 @@ void SetWidthHeight ()
418441 } else if ( showScrollIndicator ) {
419442 Width = vertical ? 1 : Dim . Width ( Host ) - 0 ;
420443 Height = vertical ? Dim . Height ( Host ) - 0 : 1 ;
421- } else if ( otherScrollBarView != null && otherScrollBarView . showScrollIndicator ) {
444+ } else if ( otherScrollBarView ? . showScrollIndicator == true ) {
422445 otherScrollBarView . Width = otherScrollBarView . vertical ? 1 : Dim . Width ( Host ) - 0 ;
423446 otherScrollBarView . Height = otherScrollBarView . vertical ? Dim . Height ( Host ) - 0 : 1 ;
424447 }
@@ -432,7 +455,10 @@ void SetWidthHeight ()
432455 ///<inheritdoc/>
433456 public override void Redraw ( Rect region )
434457 {
435- if ( ColorScheme == null || Size == 0 ) {
458+ if ( ColorScheme == null || ( ( ! showScrollIndicator || Size == 0 ) && AutoHideScrollBars && Visible ) ) {
459+ if ( ( ! showScrollIndicator || Size == 0 ) && AutoHideScrollBars && Visible ) {
460+ ShowHideScrollBars ( false ) ;
461+ }
436462 return ;
437463 }
438464
@@ -578,6 +604,8 @@ public override void Redraw (Rect region)
578604
579605 if ( contentBottomRightCorner != null && hosted && showBothScrollIndicator ) {
580606 contentBottomRightCorner . Redraw ( contentBottomRightCorner . Bounds ) ;
607+ } else if ( otherScrollBarView != null && otherScrollBarView . contentBottomRightCorner != null && otherScrollBarView . hosted && otherScrollBarView . showBothScrollIndicator ) {
608+ otherScrollBarView . contentBottomRightCorner . Redraw ( otherScrollBarView . contentBottomRightCorner . Bounds ) ;
581609 }
582610 }
583611
0 commit comments