mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-06 17:58:05 +02:00
New GridContainer capabilities and customizable tooltips (#1395)
* #272 avoid mouse overlapping tooltip when near edges, change tooltip colors to match mockups * #272 WIP customizable tooltips, old approach currently working still * #272 WIP customizable tooltips, old approach currently working still * #272 ensure tooltips go away when disposing control * #272 implement row-oriented GridContainer * #272 generalize GridContainer to support rows or cols * #272 improve readability in new GridContainer logic * #272 GridContainer can expand in opposite direction * #272 GridContainer can expand in opposite direction * #272 GridContainer can expand in opposite direction, fix test * #272 add GridContainer capability to limit by size rather than count * #272 add some clarifications about ui scale and vp / rp * #272 don't spam showtooltip event, calculate tooltip positioning using combined minimum size
This commit is contained in:
@@ -78,6 +78,7 @@ namespace Robust.Client.UserInterface
|
||||
private bool _rendering = true;
|
||||
private float _tooltipTimer;
|
||||
private Tooltip _tooltip = default!;
|
||||
private bool showingTooltip;
|
||||
private const float TooltipDelay = 1;
|
||||
|
||||
private readonly Queue<Control> _styleUpdateQueue = new Queue<Control>();
|
||||
@@ -692,8 +693,20 @@ namespace Robust.Client.UserInterface
|
||||
|
||||
private void _clearTooltip()
|
||||
{
|
||||
if (!showingTooltip) return;
|
||||
_tooltip.Visible = false;
|
||||
CurrentlyHovered?.PerformHideTooltip();
|
||||
_resetTooltipTimer();
|
||||
showingTooltip = false;
|
||||
}
|
||||
|
||||
|
||||
public void HideTooltipFor(Control control)
|
||||
{
|
||||
if (CurrentlyHovered == control)
|
||||
{
|
||||
_clearTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
private void _resetTooltipTimer()
|
||||
@@ -703,27 +716,23 @@ namespace Robust.Client.UserInterface
|
||||
|
||||
private void _showTooltip()
|
||||
{
|
||||
if (showingTooltip) return;
|
||||
showingTooltip = true;
|
||||
var hovered = CurrentlyHovered;
|
||||
if (hovered == null || string.IsNullOrWhiteSpace(hovered.ToolTip))
|
||||
if (hovered == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_tooltip.Visible = true;
|
||||
_tooltip.Text = hovered.ToolTip;
|
||||
LayoutContainer.SetPosition(_tooltip, MousePositionScaled);
|
||||
|
||||
var (right, bottom) = _tooltip.Position + _tooltip.Size;
|
||||
|
||||
if (right > RootControl.Size.X)
|
||||
// show simple tooltip if there is one
|
||||
if (!String.IsNullOrWhiteSpace(hovered.ToolTip))
|
||||
{
|
||||
LayoutContainer.SetPosition(_tooltip, (RootControl.Size.X - _tooltip.Size.X, _tooltip.Position.Y));
|
||||
_tooltip.Visible = true;
|
||||
_tooltip.Text = hovered.ToolTip;
|
||||
Tooltips.PositionTooltip(_tooltip);
|
||||
}
|
||||
|
||||
if (bottom > RootControl.Size.Y)
|
||||
{
|
||||
LayoutContainer.SetPosition(_tooltip, (_tooltip.Position.X, RootControl.Size.Y - _tooltip.Size.Y));
|
||||
}
|
||||
hovered.PerformShowTooltip();
|
||||
}
|
||||
|
||||
private void _uiScaleChanged(float newValue)
|
||||
|
||||
Reference in New Issue
Block a user