@@ -302,7 +302,7 @@ private partial class DrawableUserTag : OsuAnimatedButton
302
302
303
303
protected OsuSpriteText TagCategoryText { get ; private set ; } = null ! ;
304
304
protected OsuSpriteText TagNameText { get ; private set ; } = null ! ;
305
- protected OsuSpriteText VoteCountText { get ; private set ; } = null ! ;
305
+ protected VoteCountText VoteCountText { get ; private set ; } = null ! ;
306
306
307
307
private readonly bool showVoteCount ;
308
308
@@ -382,7 +382,8 @@ private void load()
382
382
showVoteCount
383
383
? new Container
384
384
{
385
- AutoSizeAxes = Axes . Both ,
385
+ RelativeSizeAxes = Axes . Y ,
386
+ AutoSizeAxes = Axes . X ,
386
387
Anchor = Anchor . CentreLeft ,
387
388
Origin = Anchor . CentreLeft ,
388
389
Children = new Drawable [ ]
@@ -391,9 +392,9 @@ private void load()
391
392
{
392
393
RelativeSizeAxes = Axes . Both ,
393
394
} ,
394
- VoteCountText = new OsuSpriteText
395
+ VoteCountText = new VoteCountText ( voteCount )
395
396
{
396
- Margin = new MarginPadding { Horizontal = 6 , Vertical = 3 , } ,
397
+ Margin = new MarginPadding { Horizontal = 6 } ,
397
398
} ,
398
399
}
399
400
}
@@ -418,7 +419,6 @@ protected override void LoadComplete()
418
419
{
419
420
voteCount . BindValueChanged ( _ =>
420
421
{
421
- VoteCountText . Text = voteCount . Value . ToLocalisableString ( ) ;
422
422
confirmed . Value = voteCount . Value >= 10 ;
423
423
} , true ) ;
424
424
voted . BindValueChanged ( v =>
@@ -731,5 +731,54 @@ protected override void LoadComplete()
731
731
}
732
732
}
733
733
}
734
+
735
+ private partial class VoteCountText : CompositeDrawable
736
+ {
737
+ private OsuSpriteText ? text ;
738
+
739
+ private readonly Bindable < int > voteCount ;
740
+
741
+ public VoteCountText ( Bindable < int > voteCount )
742
+ {
743
+ RelativeSizeAxes = Axes . Y ;
744
+ AutoSizeAxes = Axes . X ;
745
+
746
+ this . voteCount = voteCount . GetBoundCopy ( ) ;
747
+ }
748
+
749
+ protected override void LoadComplete ( )
750
+ {
751
+ base . LoadComplete ( ) ;
752
+
753
+ voteCount . BindValueChanged ( count =>
754
+ {
755
+ OsuSpriteText ? previousText = text ;
756
+
757
+ AddInternal ( text = new OsuSpriteText
758
+ {
759
+ Anchor = Anchor . CentreLeft ,
760
+ Origin = Anchor . CentreLeft ,
761
+ Font = OsuFont . GetFont ( weight : FontWeight . SemiBold ) ,
762
+ Text = voteCount . Value . ToLocalisableString ( ) ,
763
+ } ) ;
764
+
765
+ if ( previousText != null )
766
+ {
767
+ const double transition_duration = 500 ;
768
+
769
+ bool isIncrease = count . NewValue > count . OldValue ;
770
+
771
+ text . MoveToY ( isIncrease ? 20 : - 20 )
772
+ . MoveToY ( 0 , transition_duration , Easing . OutExpo ) ;
773
+
774
+ previousText . BypassAutoSizeAxes = Axes . Both ;
775
+ previousText . MoveToY ( isIncrease ? - 20 : 20 , transition_duration , Easing . OutExpo ) . Expire ( ) ;
776
+
777
+ AutoSizeDuration = 300 ;
778
+ AutoSizeEasing = Easing . OutQuint ;
779
+ }
780
+ } , true ) ;
781
+ }
782
+ }
734
783
}
735
784
}
0 commit comments