/// <summary> /// Adds an existing <see cref="GUIContainer"/> to this GUI /// </summary> /// <param name="c">The GUIContainer which should be added</param> /// <returns>The given GUIContainer</returns> public GUIContainer Add(GUIContainer c) { if (c == null) throw new ArgumentException("Given GUIContainer must not be null"); c.SetGUIStuff(_spriteBatch, _graphics, this); _container.Add(c); _focusList.Add(c); _changedFocus = true; return c; }
internal void AcquireFocus(GUIContainer c) { if (!c.CanAcquireFocus) return; if (_focusList.IndexOf(c) == _focusList.Count - 1) return; lock (_focusList) { _focusList.Remove(c); _focusList.Add(c); _changedFocus = true; } }
public bool IsMouseOverContainer(GUIContainer c) { lock (_focusList) { MouseState ms = Mouse.GetState(); for (int i = _focusList.Count - 1; i >= 0; --i) { Container test = _focusList[i]; if (!test.Visible) // Window is not visible, skip continue; if (test == c) // Window found return true; if (Util.MouseInRectangle(ms, test.ScreenRectangle)) // Mouse is over another Window which has a higher focus return false; } return false; // Window not found and all other windows weren't obscuring the view, should never happen } }