private VisualisedDrawable createVisualisedDrawable(VisualisedDrawable parent, Drawable target) { var vis = new VisualisedDrawable(parent, target, treeContainer) { RequestTarget = delegate { Target = target; } }; vis.HoverGained = delegate { hoveredDrawables.Add(vis); updateHoveredDrawable(); }; vis.HoverLost = delegate { hoveredDrawables.Remove(vis); updateHoveredDrawable(); }; vis.HighlightTarget = delegate { propertyDisplay.State = Visibility.Visible; // Either highlight or dehighlight the target, depending on whether // it is currently highlighted setHighlight(vis); }; return(vis); }
private void addChild(Drawable drawable) { // Make sure to never add the DrawVisualiser (recursive scenario) if (drawable is DrawVisualiser) { return; } // Don't add individual characters of SpriteText if (Target is SpriteText) { return; } VisualisedDrawable vis; if (!visCache.TryGetValue(drawable, out vis)) { vis = visCache[drawable] = new VisualisedDrawable(drawable, tree) { RequestTarget = d => RequestTarget?.Invoke(d), HighlightTarget = d => HighlightTarget?.Invoke(d) }; } flow.Add(vis); }
private void removeRootVisualisedDrawable() { if (targetDrawable != null) { treeContainer.Remove(targetDrawable); targetDrawable.Dispose(); targetDrawable = null; } }
private void visualise(IDrawable d, VisualisedDrawable vis) { if (d == this) { return; } vis.CheckExpiry(); var drawables = vis.Flow.Children.Cast <VisualisedDrawable>(); foreach (var dd in drawables) { if (!dd.CheckExpiry()) { visualise(dd.Target, dd); } } Container dContainer = d as Container; if (d is SpriteText) { return; } if (dContainer == null) { return; } foreach (var c in dContainer.Children) { var dr = drawables.FirstOrDefault(x => x.Target == c); if (dr == null) { var cLocal = c; dr = new VisualisedDrawable(cLocal) { HoverGained = delegate { hoveredDrawables.Add(cLocal); showOverlayFor(cLocal); }, HoverLost = delegate { hoveredDrawables.Remove(cLocal); showOverlayFor(hoveredDrawables.Count > 0 ? hoveredDrawables.Last() : null); }, RequestTarget = delegate { Target = cLocal; } }; vis.Flow.Add(dr); } visualise(c, dr); } }
private void createRootVisualisedDrawable() { removeRootVisualisedDrawable(); if (target != null) { targetDrawable = createVisualisedDrawable(null, target as Drawable); treeContainer.Add(targetDrawable); runUpdate(); // run an initial update to immediately show the selected hierarchy. } }
void IContainVisualisedDrawables.RemoveVisualiser(VisualisedDrawable visualiser) { target = null; targetVisualiser = null; treeContainer.Target = null; if (Target == null) { propertyDisplay.Hide(); } }
void IContainVisualisedDrawables.RemoveVisualiser(VisualisedDrawable visualiser) { target = null; targetVisualiser = null; treeContainer.Remove(visualiser); if (Target == null) { propertyDisplay.State = Visibility.Hidden; } }
private void createRootVisualisedDrawable() { removeRootVisualisedDrawable(target == null); if (target != null) { targetDrawable = createVisualisedDrawable(target); treeContainer.Add(targetDrawable); runUpdate(); // run an initial update to immediately show the selected hierarchy. // Set highlight and update setHighlight(targetDrawable); } }
private void visualise(IDrawable d, VisualisedDrawable vis) { if (d == this) { return; } vis.CheckExpiry(); var drawables = vis.Flow.Children.Cast <VisualisedDrawable>(); foreach (var dd in drawables) { if (!dd.CheckExpiry()) { visualise(dd.Target, dd); } } var dContainer = d as IContainerEnumerable <Drawable>; if (d is SpriteText) { return; } if (dContainer == null) { return; } foreach (var c in dContainer.InternalChildren) { var dr = drawables.FirstOrDefault(x => x.Target == c); if (dr == null) { var cLocal = c; dr = createVisualisedDrawable(cLocal); vis.Flow.Add(dr); } visualise(c, dr); } }
private VisualisedDrawable createVisualisedDrawable(Drawable target) { var vis = new VisualisedDrawable(target, treeContainer) { RequestTarget = delegate { Target = target; } }; vis.HighlightTarget = delegate { propertyDisplay.State = Visibility.Visible; // Either highlight or dehighlight the target, depending on whether // it is currently highlighted setHighlight(vis); }; return(vis); }
private VisualisedDrawable findVisualised(Drawable d, VisualisedDrawable root) { foreach (VisualisedDrawable child in root.Flow.InternalChildren.OfType <VisualisedDrawable>()) { if (child.Target == d) { return(child); } VisualisedDrawable found = findVisualised(d, child); if (found != null) { return(found); } } return(null); }
private void removeRootVisualisedDrawable(bool hideProperties = true) { if (hideProperties) { propertyDisplay.State = Visibility.Hidden; } if (targetDrawable != null) { if (targetDrawable.Parent != null) { // targetDrawable may have gotten purged from the TreeContainer treeContainer.Remove(targetDrawable); targetDrawable.Dispose(); } targetDrawable = null; } }
private VisualisedDrawable createVisualisedDrawable(VisualisedDrawable parent, Drawable target) { var vis = new VisualisedDrawable(parent, target, treeContainer) { RequestTarget = delegate { Target = target; } }; vis.HoverGained = delegate { hoveredDrawables.Add(vis); updateHoveredDrawable(); }; vis.HoverLost = delegate { hoveredDrawables.Remove(vis); updateHoveredDrawable(); }; return(vis); }
void IContainVisualisedDrawables.AddVisualiser(VisualisedDrawable visualiser) { visualiser.RequestTarget = d => { Target = d; targetVisualiser.ExpandAll(); }; visualiser.HighlightTarget = d => { propertyDisplay.State = Visibility.Visible; // Either highlight or dehighlight the target, depending on whether // it is currently highlighted setHighlight(d); }; visualiser.Depth = 0; treeContainer.Child = targetVisualiser = visualiser; }
private void createRootVisualisedDrawable() { removeRootVisualisedDrawable(target == null); if (target == null) { return; } targetDrawable = new VisualisedDrawable(target, treeContainer) { RequestTarget = d => Target = d, HighlightTarget = d => { propertyDisplay.State = Visibility.Visible; // Either highlight or dehighlight the target, depending on whether // it is currently highlighted setHighlight(d); } }; treeContainer.Add(targetDrawable); }
private void setHighlight(VisualisedDrawable newHighlight) { if (highlightedTarget != null) { // Dehighlight the lastly highlighted target highlightedTarget.IsHighlighted = false; highlightedTarget = null; } if (newHighlight == null) { propertyDisplay.UpdateFrom(null); return; } // Only update when property display is visible if (propertyDisplay.State == Visibility.Visible) { highlightedTarget = newHighlight; newHighlight.IsHighlighted = true; propertyDisplay.UpdateFrom(newHighlight.Target); } }
public DrawVisualiser() { RelativeSizeAxes = Axes.Both; Children = new Drawable[] { overlay = new InfoOverlay(), treeContainer = new TreeContainer { State = { BindTarget = State }, ChooseTarget = () => { Searching = true; Target = null; }, GoUpOneParent = delegate { Drawable lastHighlight = highlightedTarget?.Target; var parent = Target?.Parent; if (parent != null) { var lastVisualiser = targetVisualiser; Target = parent; lastVisualiser.SetContainer(targetVisualiser); targetVisualiser.Expand(); } // Rehighlight the last highlight if (lastHighlight != null) { VisualisedDrawable visualised = targetVisualiser.FindVisualisedDrawable(lastHighlight); if (visualised != null) { propertyDisplay.Show(); setHighlight(visualised); } } }, ToggleProperties = delegate { if (targetVisualiser == null) { return; } propertyDisplay.ToggleVisibility(); if (propertyDisplay.State.Value == Visibility.Visible) { setHighlight(targetVisualiser); } }, }, new CursorContainer() }; propertyDisplay = treeContainer.PropertyDisplay; propertyDisplay.State.ValueChanged += v => { switch (v.NewValue) { case Visibility.Hidden: // Dehighlight everything automatically if property display is closed setHighlight(null); break; } }; }
public DrawVisualiser() { RelativeSizeAxes = Axes.Both; Children = new Drawable[] { overlay = new InfoOverlay(), treeContainer = new TreeContainer { ChooseTarget = chooseTarget, GoUpOneParent = delegate { Drawable lastHighlight = highlightedTarget?.Target; var parent = Target?.Parent; if (parent?.Parent != null) { Target = Target?.Parent; } // Rehighlight the last highlight if (lastHighlight != null) { VisualisedDrawable visualised = findVisualised(lastHighlight, targetDrawable); if (visualised != null) { propertyDisplay.State = Visibility.Visible; setHighlight(visualised); } } }, ToggleProperties = delegate { if (targetDrawable == null) { return; } propertyDisplay.ToggleVisibility(); if (propertyDisplay.State == Visibility.Visible) { setHighlight(targetDrawable); } }, }, new CursorContainer() }; propertyDisplay = treeContainer.PropertyDisplay; propertyDisplay.StateChanged += (display, visibility) => { switch (visibility) { case Visibility.Hidden: // Dehighlight everything automatically if property display is closed setHighlight(null); break; } }; }
public VisualisedDrawable(VisualisedDrawable parent, Drawable d, TreeContainer tree) { this.tree = tree; nestingDepth = (parent?.nestingDepth ?? 0) + 1; Target = d; attachEvents(); var sprite = Target as Sprite; AutoSizeAxes = Axes.Both; Add(new[] { activityInvalidate = new Box { Colour = Color4.Yellow, Size = new Vector2(2, line_height), Position = new Vector2(6, 0), Alpha = 0 }, activityLayout = new Box { Colour = Color4.Orange, Size = new Vector2(2, line_height), Position = new Vector2(3, 0), Alpha = 0 }, activityAutosize = new Box { Colour = Color4.Red, Size = new Vector2(2, line_height), Position = new Vector2(0, 0), Alpha = 0 }, previewBox = sprite?.Texture == null ? previewBox = new Box { Colour = Color4.White } : new Sprite { Texture = sprite.Texture, Scale = new Vector2(sprite.Texture.DisplayWidth / sprite.Texture.DisplayHeight, 1), }, new Container { AutoSizeAxes = Axes.Both, Position = new Vector2(24, -3), Children = new Drawable[] { textBg = new Box { RelativeSizeAxes = Axes.Both, Size = new Vector2(1, 0.8f), Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Colour = Color4.Transparent, }, text = new SpriteText { Scale = new Vector2(0.9f), }, } }, Flow = new FillFlowContainer <VisualisedDrawable> { Direction = FillDirection.Vertical, AutoSizeAxes = Axes.Both, Position = new Vector2(10, 14) }, }); previewBox.Position = new Vector2(9, 0); previewBox.Size = new Vector2(line_height, line_height); updateSpecifics(); }