/// <summary> /// Adds the component. /// </summary> /// <returns><c>true</c>, if component was added, <c>false</c> otherwise.</returns> public bool AddComponent(UIBaseComponent newComp) { if (newComp == null) { return(false); } if (WillAddComponent(newComp) == false) { return(false); } if (newComp.ParentComponent != null) { newComp.ParentComponent.RemoveComponent(newComp); } newComp.ParentComponent = this; components.Add(newComp); newComp.PerformLayout(); DidAddComponent(newComp); return(true); }
public bool InsertComponent(UIBaseComponent newComp, int atPosition) { if (newComp == null) { return(false); } if (WillAddComponent(newComp) == false) { return(false); } if (newComp.ParentComponent != null) { newComp.ParentComponent.RemoveComponent(newComp); } newComp.ParentComponent = this; components.Insert(atPosition, newComp); newComp.PerformLayout(); DidAddComponent(newComp); return(true); }
internal static void CaptureComponent(UIBaseComponent component) { lock (lockObj) { CapturedComponent = component; } }
internal static void CaptureKeyboardFocus(UIBaseComponent component) { lock (lockObj) { CapturedKeyboardComponent = component; } }
/// <summary> /// Switches the parent component while keeping the screen /// position the same. /// </summary> /// <param name="newParent">New parent.</param> public void SwitchParentComponent(UIBaseComponent newParent) { Vector2 newLocalPos = newParent.ScreenToLocalCoords(this.ScreenPosition); ParentComponent.RemoveComponent(this); newParent.AddComponent(this); this.X = newLocalPos.X; this.Y = newLocalPos.Y; }
public bool RemoveComponent(UIBaseComponent comp) { if (comp == null) { return(false); } if (WillRemoveComponent(comp) == false) { return(false); } if (components.Contains(comp)) { components.Remove(comp); } comp.ParentComponent = null; comp.PerformLayout(); DidRemoveComponent(comp); return(true); }
public UIBaseComponent(IRenderConfiguration setRenderConfig) { if (setRenderConfig == null) { throw new ArgumentNullException(nameof(setRenderConfig)); } widthSizeMode = UISizeMode.Fixed; heightSizeMode = UISizeMode.Fixed; isPerformingLayout = false; suppressPerformLayout = false; customLayoutHooks = new Dictionary <string, ModifyLayout>(); components = new List <UIBaseComponent>(); animations = new List <UIAnimation>(); renderConfig = setRenderConfig; parentComponent = null; Focusable = false; PositionAnchor = UIPositionAnchor.TopLeft; BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.0f); UserInteractionEnabled = true; Visible = true; Alpha = 1.0f; Rotation = 0.0f; }
/// <summary> /// Called after the component is removed as a subcomponent. /// </summary> protected virtual void DidRemoveComponent(UIBaseComponent newComp) { }
/// <summary> /// Called after the component is added as a subcomponent. /// </summary> protected virtual void DidAddComponent(UIBaseComponent newComp) { }
/// <summary> /// Called before the component is removed as a subcomponent. /// /// Base implementation returns true /// </summary> /// <returns>Return false to prevent the component from being removed</returns> protected virtual bool WillRemoveComponent(UIBaseComponent newComp) { return(true); }
private void DismissButton_OnPointerUpInside(UIBaseComponent sender, Vector2 position, GameTime gameTime) { Close(); }