コード例 #1
0
ファイル: G2DScrollPane.cs プロジェクト: NinjaSteph/SureShot
        public G2DScrollPane(G2DComponent scrollableContent, ScrollBarPolicy horizontalPolicy, ScrollBarPolicy verticalPolicy)
        {
            if (!(scrollableContent is Scrollable))
                throw new ArgumentException("The scrollableContent has to implement Scrollable interface");

            this.scrollableContent = scrollableContent;

            enableWheelScroll = true;

            drawBackground = false;

            hBarPolicy = horizontalPolicy;
            vBarPolicy = verticalPolicy;

            hScrollBar = new G2DScrollBar(GoblinEnums.Orientation.Horizontal, 0, 2, 2);
            vScrollBar = new G2DScrollBar(GoblinEnums.Orientation.Vertical, 2, 2, 2);

            if (vBarPolicy == ScrollBarPolicy.Always)
                showVScroll = true;
            else
                showVScroll = false;

            if (hBarPolicy == ScrollBarPolicy.Always)
                showHScroll = true;
            else
                showHScroll = false;
        }
コード例 #2
0
ファイル: G2DPanel.cs プロジェクト: ARLM-Attic/goblin-xna
        /// <summary>
        /// Removes a child component from this panel if already added.
        /// </summary>
        /// <param name="comp">A 2D component to be removed</param>
        /// <returns>Whether removal succeeded</returns>
        public virtual bool RemoveChild(G2DComponent comp)
        {
            bool removed = children.Remove(comp);

            if (removed)
            {
                comp.Parent = null;
                comp.RemoveKeyInput();
                comp.RemoveMouseInput();

                InvokeComponentRemovedEvent(this, comp);
            }

            return(removed);
        }
コード例 #3
0
ファイル: G2DPanel.cs プロジェクト: ARLM-Attic/goblin-xna
 /// <summary>
 /// Gets the parent right before reaching the root
 /// </summary>
 /// <param name="comp"></param>
 /// <returns></returns>
 protected virtual G2DPanel GetPreRootParent(G2DComponent comp)
 {
     if (comp.HasParent && ((G2DPanel)comp.Parent).HasParent)
     {
         return(GetPreRootParent((G2DComponent)comp.Parent));
     }
     else
     {
         if (comp is G2DPanel)
         {
             return((G2DPanel)comp);
         }
         else
         {
             return(null);
         }
     }
 }
コード例 #4
0
ファイル: G2DPanel.cs プロジェクト: ARLM-Attic/goblin-xna
        /*/// <summary>
         * /// Set the border to be a titled border with a title
         * /// </summary>
         * /// <param name="title"></param>
         * public virtual void SetTitledBorder(String title)
         * {
         *  this.title = title;
         *  this.border = GoblinEnums.BorderFactory.TitledBorder;
         * }*/
        #endregion

        #region Action Methods
        /// <summary>
        /// Adds a child component to this panel.
        /// </summary>
        /// <remarks>
        /// Note that when you add a child component, the child component will automatically inherit the following
        /// properties from this panel: Transparency, TextTransparency, Visible, and Enabled. If you want to have
        /// a different value for these properties, then you should set these property values of the child component
        /// after adding to this panel.
        /// </remarks>
        /// <param name="comp">A 2D component to be added</param>
        public virtual void AddChild(G2DComponent comp)
        {
            if (comp.Parent != null)
            {
                throw new GoblinException("This G2DComponent already has a parent");
            }

            if (comp != null && !children.Contains(comp))
            {
                comp.Parent           = this;
                comp.Transparency     = Transparency;
                comp.TextTransparency = TextTransparency;
                comp.Visible          = Visible;
                comp.Enabled          = Enabled;
                comp.RegisterKeyInput();
                comp.RegisterMouseInput();
                children.Add(comp);

                G2DPanel root = (G2DPanel)comp.RootParent;

                InvokeComponentAddedEvent(this, comp);
            }
        }
コード例 #5
0
        public G2DScrollPane(G2DComponent scrollableContent, ScrollBarPolicy horizontalPolicy, ScrollBarPolicy verticalPolicy)
        {
            if (!(scrollableContent is Scrollable))
            {
                throw new ArgumentException("The scrollableContent has to implement Scrollable interface");
            }

            this.scrollableContent = scrollableContent;

            enableWheelScroll = true;

            drawBackground = false;

            hBarPolicy = horizontalPolicy;
            vBarPolicy = verticalPolicy;

            hScrollBar = new G2DScrollBar(GoblinEnums.Orientation.Horizontal, 0, 2, 2);
            vScrollBar = new G2DScrollBar(GoblinEnums.Orientation.Vertical, 2, 2, 2);

            if (vBarPolicy == ScrollBarPolicy.Always)
            {
                showVScroll = true;
            }
            else
            {
                showVScroll = false;
            }

            if (hBarPolicy == ScrollBarPolicy.Always)
            {
                showHScroll = true;
            }
            else
            {
                showHScroll = false;
            }
        }
コード例 #6
0
 public G2DScrollPane(G2DComponent scrollableContent)
     : this(scrollableContent, ScrollBarPolicy.Never, ScrollBarPolicy.AsNeeded)
 {
 }
コード例 #7
0
ファイル: G2DScrollPane.cs プロジェクト: NinjaSteph/SureShot
 public G2DScrollPane(G2DComponent scrollableContent) 
     : this(scrollableContent, ScrollBarPolicy.Never, ScrollBarPolicy.AsNeeded) { }
コード例 #8
0
ファイル: UIRenderer.cs プロジェクト: NinjaSteph/SureShot
 /// <summary>
 /// Removes a 2D UI component from the rendering process.
 /// </summary>
 /// <param name="comp2d"></param>
 public void Remove2DComponent(G2DComponent comp2d)
 {
     comp2Ds.Remove(comp2d);
     comp2d.RemoveKeyInput();
     comp2d.RemoveMouseInput();
 }
コード例 #9
0
ファイル: UIRenderer.cs プロジェクト: NinjaSteph/SureShot
 /// <summary>
 /// Adds a 2D UI component to be rendered on the screen.
 /// </summary>
 /// <remarks>You should only add top-level components that do not have a parent component.</remarks>
 /// <param name="comp2d">A top-level G2DComponent object</param>
 public void Add2DComponent(G2DComponent comp2d)
 {
     if (!comp2Ds.Contains(comp2d))
     {
         if (comp2d.HasParent)
             throw new GoblinException("You should only add root components to this list. "
                 + "Any component with parents are automatically rendered by its parent " +
                 "component");
         else
         {
             comp2Ds.Add(comp2d);
             comp2d.RegisterKeyInput();
             comp2d.RegisterMouseInput();
         }
     }
 }
コード例 #10
0
ファイル: G2DPanel.cs プロジェクト: NinjaSteph/SureShot
 /// <summary>
 /// Gets the parent right before reaching the root
 /// </summary>
 /// <param name="comp"></param>
 /// <returns></returns>
 protected virtual G2DPanel GetPreRootParent(G2DComponent comp)
 {
     if (comp.HasParent && ((G2DPanel)comp.Parent).HasParent)
         return GetPreRootParent((G2DComponent)comp.Parent);
     else
     {
         if (comp is G2DPanel)
             return (G2DPanel)comp;
         else
             return null;
     }
 }
コード例 #11
0
ファイル: G2DPanel.cs プロジェクト: NinjaSteph/SureShot
        /// <summary>
        /// Removes a child component from this panel if already added.
        /// </summary>
        /// <param name="comp">A 2D component to be removed</param>
        /// <returns>Whether removal succeeded</returns>
        public virtual bool RemoveChild(G2DComponent comp)
        {
            bool removed = children.Remove(comp);
            if (removed)
            {
                comp.Parent = null;
                comp.RemoveKeyInput();
                comp.RemoveMouseInput();

                InvokeComponentRemovedEvent(this, comp);
            }

            return removed;
        }
コード例 #12
0
ファイル: G2DPanel.cs プロジェクト: NinjaSteph/SureShot
        /*/// <summary>
        /// Set the border to be a titled border with a title
        /// </summary>
        /// <param name="title"></param>
        public virtual void SetTitledBorder(String title)
        {
            this.title = title;
            this.border = GoblinEnums.BorderFactory.TitledBorder;
        }*/
        #endregion

        #region Action Methods
        /// <summary>
        /// Adds a child component to this panel.
        /// </summary>
        /// <remarks>
        /// Note that when you add a child component, the child component will automatically inherit the following
        /// properties from this panel: Transparency, TextTransparency, Visible, and Enabled. If you want to have
        /// a different value for these properties, then you should set these property values of the child component 
        /// after adding to this panel. 
        /// </remarks>
        /// <param name="comp">A 2D component to be added</param>
        public virtual void AddChild(G2DComponent comp)
        {
            if (comp.Parent != null)
                throw new GoblinException("This G2DComponent already has a parent");

            if (comp != null && !children.Contains(comp))
            {
                comp.Parent = this;
                comp.Transparency = Transparency;
                comp.TextTransparency = TextTransparency;
                comp.Visible = Visible;
                comp.Enabled = Enabled;
                comp.RegisterKeyInput();
                comp.RegisterMouseInput();
                children.Add(comp);

                G2DPanel root = (G2DPanel)comp.RootParent;

                InvokeComponentAddedEvent(this, comp);
            }
        }