Skip to content

Conversation

@domportera
Copy link
Contributor

tooltips had a habit of easily flowing off-screen, so I added a naive approach to making sure that doesnt happen (assuming they fit within the confines of the screen in the first place)

Comment on lines +52 to +60
if (rect.X < left)
rect.X = left;
else if(rect.Right > right)
rect.X -= rect.Right - right;

if (rect.Top > top)
rect.Y -= rect.Top - top;
else if (rect.Bottom < bottom)
rect.Y -= rect.Bottom - bottom;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a function that does exactly the same ImRectUtility.Clamp, although its naming kind of misleading.

var rect = new ImRect(position.x, gui.Style.Tooltip.AboveCursor ? position.y : position.y - height, width, height);

// fit rect to screen
var bounds = gui.Canvas.ScreenRect;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's preferably to use Canvas.SafeScreenRect for this case.

@domportera
Copy link
Contributor Author

excellent to know - I will modify the changes when I can and ping you when it's ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants