Skip to content

Commit

Permalink
Make it so tooltip creation could be customized
Browse files Browse the repository at this point in the history
  • Loading branch information
rds1983 committed Nov 8, 2023
1 parent 39e4afe commit a16bfb6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Myra/Graphics2D/UI/Desktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,12 @@ public void ShowContextMenu(Widget menu, Point position) =>

public void ShowTooltip(Widget widget, string text, Point position)
{
var tooltip = new Label(null)
if (string.IsNullOrEmpty(widget.Tooltip))
{
Text = text,
Tag = widget
};

tooltip.ApplyLabelStyle(Stylesheet.Current.TooltipStyle);
return;
}

var tooltip = MyraEnvironment.TooltipCreator(widget);
ShowOverWidget(tooltip, OverWidgetType.Tooltip, position);
}

Expand Down
12 changes: 12 additions & 0 deletions src/Myra/MyraEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,18 @@ public static AssetManager DefaultAssetManager
public static bool DisableClipping { get; set; }
public static int TooltipDelayInMs { get; set; } = 500;
public static Point TooltipOffset { get; set; } = new Point(0, 20);

Check failure on line 228 in src/Myra/MyraEnvironment.cs

View workflow job for this annotation

GitHub Actions / BuildAndPublish

The type or namespace name 'Point' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 228 in src/Myra/MyraEnvironment.cs

View workflow job for this annotation

GitHub Actions / BuildAndPublish

The type or namespace name 'Point' could not be found (are you missing a using directive or an assembly reference?)
public static Func<Widget, Widget> TooltipCreator { get; set; } = w =>
{
var tooltip = new Label(null)
{
Text = w.Tooltip,
Tag = w
};
tooltip.ApplyLabelStyle(Stylesheet.Current.TooltipStyle);
return tooltip;
};

/// <summary>
/// Makes the text rendering more smooth(especially when scaling) for the cost of sacrificing some performance
Expand Down

0 comments on commit a16bfb6

Please sign in to comment.