Skip to content

Commit d5f4a26

Browse files
authored
Merge pull request #6636 from Joehuu/truncate-class-name-draw-vis
Truncate drawable class names so that position and size are always visible in draw visualiser
2 parents d3039c3 + 83c7bc6 commit d5f4a26

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

osu.Framework/Graphics/Visualisation/ToolWindow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ protected ToolWindow(string title, string keyHelpText, bool supportsSearch = fal
129129
ScrollContent = new BasicScrollContainer<Drawable>
130130
{
131131
RelativeSizeAxes = Axes.Both,
132+
ScrollbarOverlapsContent = false,
132133
Child = SearchContainer = new SearchContainer
133134
{
134135
AutoSizeAxes = Axes.Y,

osu.Framework/Graphics/Visualisation/VisualisedDrawable.cs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using osu.Framework.Allocation;
1616
using osu.Framework.Extensions.Color4Extensions;
1717
using osu.Framework.Extensions.IEnumerableExtensions;
18+
using osu.Framework.Graphics.Cursor;
1819
using osu.Framework.Graphics.Textures;
1920
using osu.Framework.Input;
2021
using osu.Framework.Input.Events;
@@ -25,6 +26,7 @@ namespace osu.Framework.Graphics.Visualisation
2526
internal partial class VisualisedDrawable : Container, IContainVisualisedDrawables, IFilterable
2627
{
2728
private const int line_height = 12;
29+
private const float text_x_pos = 30;
2830

2931
public Drawable Target { get; }
3032

@@ -72,7 +74,7 @@ public bool MatchingFilter
7274
public Action<VisualisedDrawable> HighlightTarget;
7375

7476
private Box background;
75-
private SpriteText text;
77+
private TooltipSpriteText text;
7678
private SpriteText text2;
7779
private Drawable previewBox;
7880
private Drawable activityInvalidate;
@@ -112,11 +114,13 @@ private void load()
112114
Direction = FillDirection.Vertical,
113115
RelativeSizeAxes = Axes.X,
114116
AutoSizeAxes = Axes.Y,
115-
Position = new Vector2(row_width, row_height)
117+
Position = new Vector2(0, row_height),
118+
Padding = new MarginPadding { Left = row_width },
116119
},
117120
new Container
118121
{
119-
AutoSizeAxes = Axes.Both,
122+
RelativeSizeAxes = Axes.X,
123+
AutoSizeAxes = Axes.Y,
120124
Children = new[]
121125
{
122126
background = new Box
@@ -195,13 +199,13 @@ private void load()
195199
},
196200
new FillFlowContainer
197201
{
198-
AutoSizeAxes = Axes.Both,
202+
RelativeSizeAxes = Axes.X,
203+
AutoSizeAxes = Axes.Y,
199204
Direction = FillDirection.Horizontal,
200-
Spacing = new Vector2(5),
201-
Position = new Vector2(30, 0),
205+
Position = new Vector2(text_x_pos, 0),
202206
Children = new Drawable[]
203207
{
204-
text = new SpriteText { Font = FrameworkFont.Regular },
208+
text = new TooltipSpriteText { Font = FrameworkFont.Regular },
205209
text2 = new SpriteText { Font = FrameworkFont.Regular },
206210
}
207211
},
@@ -465,7 +469,7 @@ private void updateSpecifics()
465469
int childCount = (Target as CompositeDrawable)?.InternalChildren.Count ?? 0;
466470

467471
text.Text = Target.ToString();
468-
text2.Text = $"({Target.DrawPosition.X:#,0},{Target.DrawPosition.Y:#,0}) {Target.DrawSize.X:#,0}x{Target.DrawSize.Y:#,0}"
472+
text2.Text = $" ({Target.DrawPosition.X:#,0},{Target.DrawPosition.Y:#,0}) {Target.DrawSize.X:#,0}x{Target.DrawSize.Y:#,0}"
469473
+ (!isExpanded && childCount > 0 ? $@" ({childCount} children)" : string.Empty);
470474

471475
Alpha = Target.IsPresent ? 1 : 0.3f;
@@ -474,6 +478,7 @@ private void updateSpecifics()
474478
protected override void Update()
475479
{
476480
updateSpecifics();
481+
text.MaxWidth = DrawWidth - text_x_pos - text2.DrawWidth - 5;
477482
base.Update();
478483
}
479484

@@ -504,5 +509,17 @@ private partial class VisualisedDrawableFlow : FillFlowContainer<VisualisedDrawa
504509
{
505510
public override IEnumerable<Drawable> FlowingChildren => AliveInternalChildren.Where(d => d.IsPresent).OrderBy(d => -d.Depth).ThenBy(d => ((VisualisedDrawable)d).Target.ChildID);
506511
}
512+
513+
private partial class TooltipSpriteText : SpriteText, IHasTooltip
514+
{
515+
public LocalisableString TooltipText => Text;
516+
517+
public override bool HandlePositionalInput => IsTruncated;
518+
519+
public TooltipSpriteText()
520+
{
521+
Truncate = true;
522+
}
523+
}
507524
}
508525
}

0 commit comments

Comments
 (0)