/// <summary> /// Unfocus the current focused drawable if it is no longer in a valid state. /// </summary> /// <returns>true if there is no longer a focus.</returns> private bool unfocusIfNoLongerValid() { if (FocusedDrawable == null) { return(true); } bool stillValid = FocusedDrawable.IsPresent && FocusedDrawable.Parent != null; if (stillValid) { //ensure we are visible CompositeDrawable d = FocusedDrawable.Parent; while (d != null) { if (!d.IsPresent) { stillValid = false; break; } d = d.Parent; } } if (stillValid) { return(false); } ChangeFocus(null); return(true); }
protected virtual void LoadScreen(CompositeDrawable loader, Drawable toLoad, Action continuation) { // If the previous screen has already been exited, do not attempt to load the new one. if ((loader as IScreen)?.ValidForPush == false) { return; } if (toLoad.LoadState >= LoadState.Ready) { continuation?.Invoke(); } else { if (loader.LoadState >= LoadState.Ready) { log($"loading {getTypeString(toLoad)}"); loader.LoadComponentAsync(toLoad, _ => continuation?.Invoke(), scheduler: Scheduler); } else { log($"scheduling load {getTypeString(toLoad)}"); Schedule(() => LoadScreen(loader, toLoad, continuation)); } } }
/// <summary> /// Unfocus the current focused drawable if it is no longer in a valid state. /// </summary> /// <returns>true if there is no longer a focus.</returns> private bool unfocusIfNoLongerValid() { if (FocusedDrawable == null) { return(true); } bool stillValid = FocusedDrawable.IsAlive && FocusedDrawable.IsPresent && FocusedDrawable.Parent != null; if (stillValid) { //ensure we are visible CompositeDrawable d = FocusedDrawable.Parent; while (d != null) { if (!d.IsPresent || !d.IsAlive) { stillValid = false; break; } d = d.Parent; } } if (stillValid) { return(false); } Logger.Log($"Focus on \"{FocusedDrawable}\" no longer valid as a result of {nameof(unfocusIfNoLongerValid)}.", LoggingTarget.Runtime, LogLevel.Debug); ChangeFocus(null); return(true); }
public DrawableOsuBlinds(CompositeDrawable restrictTo, Beatmap <OsuHitObject> beatmap) { this.restrictTo = restrictTo; this.beatmap = beatmap; targetBreakMultiplier = 0; easing = 1; }
public ToolboxComponentButton(Drawable component, CompositeDrawable dependencySource) { this.component = component; this.dependencySource = dependencySource; Enabled.Value = true; RelativeSizeAxes = Axes.X; Height = contracted_size; }
public IncompatibilityDisplayingModButton(Mod mod) : base(mod) { ButtonContent.Add(incompatibleIcon = new IncompatibleIcon { Anchor = Anchor.BottomRight, Origin = Anchor.Centre, Position = new Vector2(-13), }); }
public RigidBodySimulation(CompositeDrawable container) { this.container = container; foreach (Drawable d in container.InternalChildren) { RigidBody body = getRigidBody(d); body.ApplyImpulse(new Vector2(RNG.NextSingle() - 0.5f, RNG.NextSingle() - 0.5f) * 100, body.Centre + new Vector2(RNG.NextSingle() - 0.5f, RNG.NextSingle() - 0.5f) * 100); } }
/// <summary> /// Loads a <see cref="IScreen"/> through a <see cref="CompositeDrawable"/>. /// </summary> /// <param name="loader">The <see cref="CompositeDrawable"/> to load <paramref name="toLoad"/> with.</param> /// <param name="toLoad">The <see cref="IScreen"/> to load.</param> /// <param name="continuation">The <see cref="Action"/> to invoke after <paramref name="toLoad"/> has finished loading.</param> protected virtual void LoadScreen(CompositeDrawable loader, Drawable toLoad, Action continuation) { if (toLoad.LoadState >= LoadState.Ready) { continuation?.Invoke(); } else { loader.LoadComponentAsync(toLoad, _ => continuation?.Invoke(), scheduler: Scheduler); } }
private bool checkScrollIntersection() { IOnScreenOptimisingContainer scroll = null; CompositeDrawable cursor = this; while (scroll == null && (cursor = cursor.Parent) != null) { scroll = cursor as IOnScreenOptimisingContainer; } return(scroll?.ScreenSpaceDrawQuad.Intersects(ScreenSpaceDrawQuad) ?? true); }
private Drawable loadDrawable(JToken data) { if (data.Type == JTokenType.String) { var value = data.Value <string>(); if (string.IsNullOrEmpty(value)) { return(NullDrawable.Instance); } var drawable = GetDrawable(value); if (drawable == NullDrawable.Instance) { throw new InvalidDataException($"Referenced drawable '{value}' must be defined before '{data.Path}'"); } return(drawable); } else if (data.Type == JTokenType.Array) { var composite = new CompositeDrawable(); foreach (var arrayDrawableData in data) { var drawable = loadDrawable(arrayDrawableData); composite.Drawables.Add(drawable); } return(composite); } else { var drawableTypeData = data["_type"]; if (drawableTypeData == null) { throw new InvalidDataException($"Drawable '{data.Path}' must declare a type"); } var drawableTypeName = drawableTypeData.Value <string>(); var drawableType = ResolveDrawableType(drawableTypeName); var drawable = (Drawable)Activator.CreateInstance(drawableType); parseFields(drawable, data, null); return(drawable); } }
private void computeIsIntersecting() { if (OptimisingContainer == null) { CompositeDrawable cursor = this; while (OptimisingContainer == null && (cursor = cursor.Parent) != null) { OptimisingContainer = cursor as IOnScreenOptimisingContainer; } } if (OptimisingContainer == null) { IsIntersecting = true; } else { OptimisingContainer.ScheduleCheckAction(() => IsIntersecting = OptimisingContainer.ScreenSpaceDrawQuad.Intersects(ScreenSpaceDrawQuad)); } }
private bool isDrawableValidForFocus(Drawable drawable) { bool valid = drawable.IsAlive && drawable.IsPresent && drawable.Parent != null; if (valid) { //ensure we are visible CompositeDrawable d = drawable.Parent; while (d != null) { if (!d.IsPresent || !d.IsAlive) { valid = false; break; } d = d.Parent; } } return(valid); }
public DrawableTauBlinds(CompositeDrawable restrictTo, Beatmap <TauHitObject> beatmap) { this.restrictTo = restrictTo; this.beatmap = beatmap; }
public SkinComponentToolbox(CompositeDrawable target = null) : base("Components") { this.target = target; }
public DependencyBorrowingContainer(CompositeDrawable donor) { this.donor = donor; }
public QueryingCompositeDrawableDrawNode(CompositeDrawable source) : base(source) { }
protected OsuManualInputManagerTestScene() { MenuCursorContainer cursorContainer; CompositeDrawable mainContent = cursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }; cursorContainer.Child = content = new OsuTooltipContainer(cursorContainer.Cursor) { RelativeSizeAxes = Axes.Both }; if (CreateNestedActionContainer) { mainContent = new GlobalActionContainer(null).WithChild(mainContent); } base.Content.AddRange(new Drawable[] { InputManager = new ManualInputManager { UseParentInput = true, Child = mainContent }, new Container { AutoSizeAxes = Axes.Both, Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Margin = new MarginPadding(5), CornerRadius = 5, Masking = true, Children = new Drawable[] { new Box { Colour = Color4.Black, RelativeSizeAxes = Axes.Both, Alpha = 0.5f, }, new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Margin = new MarginPadding(5), Spacing = new Vector2(5), Children = new Drawable[] { new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = "Input Priority" }, new FillFlowContainer { AutoSizeAxes = Axes.Both, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Margin = new MarginPadding(5), Spacing = new Vector2(5), Direction = FillDirection.Horizontal, Children = new Drawable[] { buttonLocal = new TriangleButton { Text = "local", Size = new Vector2(50, 30), Action = returnUserInput }, buttonTest = new TriangleButton { Text = "test", Size = new Vector2(50, 30), Action = returnTestInput }, } }, } }, } }, }); }
public CompositeDrawableDrawNode(CompositeDrawable source) : base(source) { }
private int countSearchableText(CompositeDrawable container) { return(container.InternalChildren.Where(t => t is SearchableText || t is FilterableFlowContainer).Count(c => c.IsPresent) + container.InternalChildren.Where(c => c.IsPresent).OfType <CompositeDrawable>().Sum(countSearchableText)); }