MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / HitTest

Method HitTest

Source/Editor/GUI/Docking/DockPanel.cs:308–344  ·  view source on GitHub ↗

Performs hit test over dock panel Screen space position to test Dock panel that has been hit or null if nothing found

(ref Float2 position)

Source from the content-addressed store, hash-verified

306 /// <param name="position">Screen space position to test</param>
307 /// <returns>Dock panel that has been hit or null if nothing found</returns>
308 public DockPanel HitTest(ref Float2 position)
309 {
310 // Get parent window and transform point position into local coordinates system
311 var parentWin = Root;
312 if (parentWin == null)
313 return null;
314 var clientPos = parentWin.PointFromScreen(position);
315 var localPos = PointFromWindow(clientPos);
316
317 // Early out
318 if (localPos.X < 0 || localPos.Y < 0)
319 return null;
320 if (localPos.X > Width || localPos.Y > Height)
321 return null;
322
323 // Test all docked controls (find the smallest one)
324 float sizeLengthSquared = float.MaxValue;
325 DockPanel result = null;
326 for (int i = 0; i < _childPanels.Count; i++)
327 {
328 var panel = _childPanels[i].HitTest(ref position);
329 if (panel != null)
330 {
331 var sizeLen = panel.Size.LengthSquared;
332 if (sizeLen < sizeLengthSquared)
333 {
334 sizeLengthSquared = sizeLen;
335 result = panel;
336 }
337 }
338 }
339 if (result != null)
340 return result;
341
342 // Itself
343 return this;
344 }
345
346 /// <summary>
347 /// Try get panel dock state

Callers 1

UpdateRectsMethod · 0.45

Calls 1

PointFromScreenMethod · 0.45

Tested by

no test coverage detected