private void updateSelectionState() { if (!IsLoaded) { return; } switch (Button.Bindable.Value) { case TernaryState.Indeterminate: icon.Colour = selectedBubbleColour.Darken(0.5f); BackgroundColour = selectedBackgroundColour.Darken(0.5f); break; case TernaryState.False: icon.Colour = defaultBubbleColour; BackgroundColour = defaultBackgroundColour; break; case TernaryState.True: icon.Colour = selectedBubbleColour; BackgroundColour = selectedBackgroundColour; break; } }
protected virtual void UpdateState() { float targetWidth = Active.Value ? EXPANDED_SWITCH_WIDTH : IDLE_SWITCH_WIDTH; double transitionDuration = TRANSITION_DURATION; Colour4 textBackgroundColour = Active.Value ? activeColour : (Colour4)ColourProvider.Background2; Colour4 mainBackgroundColour = Active.Value ? activeColour.Darken(0.3f) : (Colour4)ColourProvider.Background3; Colour4 textColour = Active.Value ? (Colour4)ColourProvider.Background6 : Colour4.White; // Hover affects colour of button background if (IsHovered) { textBackgroundColour = textBackgroundColour.Lighten(0.1f); mainBackgroundColour = mainBackgroundColour.Lighten(0.1f); } // Mouse down adds a halfway tween of the movement if (mouseDown) { targetWidth = (float)Interpolation.Lerp(IDLE_SWITCH_WIDTH, EXPANDED_SWITCH_WIDTH, 0.5f); transitionDuration *= 4; } Content.TransformTo(nameof(BorderColour), ColourInfo.GradientVertical(mainBackgroundColour, textBackgroundColour), transitionDuration, Easing.OutQuint); Background.FadeColour(mainBackgroundColour, transitionDuration, Easing.OutQuint); SwitchContainer.ResizeWidthTo(targetWidth, transitionDuration, Easing.OutQuint); MainContentContainer.TransformTo(nameof(Padding), new MarginPadding { Left = targetWidth, Right = CORNER_RADIUS }, transitionDuration, Easing.OutQuint); TextBackground.FadeColour(textBackgroundColour, transitionDuration, Easing.OutQuint); TextFlow.FadeColour(textColour, transitionDuration, Easing.OutQuint); }
private void transformFillColour(Colour4 colour, double duration) { Disc.FadeAccent(colour, duration); Background.FadeAccent(colour.Darken(1), duration); Ticks.FadeAccent(colour, duration); circle.FadeColour(colour, duration); glow.FadeColour(colour, duration); }
private void load(OsuColour colours) { defaultBackgroundColour = colours.Gray3; defaultBubbleColour = defaultBackgroundColour.Darken(0.5f); selectedBackgroundColour = colours.BlueDark; selectedBubbleColour = selectedBackgroundColour.Lighten(0.5f); Content.EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Shadow, Radius = 2, Offset = new Vector2(0, 1), Colour = Colour4.Black.Opacity(0.5f) }; Add(icon = (Button.CreateIcon?.Invoke() ?? new Circle()).With(b => { b.Blending = BlendingParameters.Additive; b.Anchor = Anchor.CentreLeft; b.Origin = Anchor.CentreLeft; b.Size = new Vector2(20); b.X = 10; })); }