コード例 #1
0
        /// <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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 internal static void CaptureComponent(UIBaseComponent component)
 {
     lock (lockObj)
     {
         CapturedComponent = component;
     }
 }
コード例 #4
0
 internal static void CaptureKeyboardFocus(UIBaseComponent component)
 {
     lock (lockObj)
     {
         CapturedKeyboardComponent = component;
     }
 }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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;
        }
コード例 #8
0
 /// <summary>
 /// Called after the component is removed as a subcomponent.
 /// </summary>
 protected virtual void DidRemoveComponent(UIBaseComponent newComp)
 {
 }
コード例 #9
0
 /// <summary>
 /// Called after the component is added as a subcomponent.
 /// </summary>
 protected virtual void DidAddComponent(UIBaseComponent newComp)
 {
 }
コード例 #10
0
 /// <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);
 }
コード例 #11
0
 private void DismissButton_OnPointerUpInside(UIBaseComponent sender, Vector2 position, GameTime gameTime)
 {
     Close();
 }