Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            _minButton = new DButton(_guiManager, 0, 0, "", SCROLLBAR_WIDTH, SCROLLBAR_WIDTH);
            if (_alignHorizontal)
            {
                _minButton.Text = "<";
                Size = new Vector2(Size.X, SCROLLBAR_WIDTH);
                _maxButton = new DButton(_guiManager, Size.X - SCROLLBAR_WIDTH, 0, "", SCROLLBAR_WIDTH, SCROLLBAR_WIDTH);
                _scrollIndicator = new DPanel(_guiManager, SCROLLBAR_WIDTH, 0, SCROLLBAR_WIDTH, SCROLLBAR_WIDTH);
                _maxButton.Text = ">";
            }
            else
            {
                _minButton.Text = "^";
                Size = new Vector2(SCROLLBAR_WIDTH, Size.Y);
                _maxButton = new DButton(_guiManager, 0, Size.Y - SCROLLBAR_WIDTH, "", SCROLLBAR_WIDTH, SCROLLBAR_WIDTH);
                _scrollIndicator = new DPanel(_guiManager, 0, SCROLLBAR_WIDTH, SCROLLBAR_WIDTH, SCROLLBAR_WIDTH);
                _maxButton.Text = "v";
            }
            //scrollIndicator.BorderColor = Color.SlateGray;

            //maxButton.Parent = this;
            //minButton.Parent = this;
            AddPanel(_minButton);
            AddPanel(_maxButton);
            AddPanel(_scrollIndicator);
            UpdateScrollIndicatorSize();

            _minButton.OnLeftMouseDown += new DButtonEventHandler(minButton_OnLeftMouseDown);
            _minButton.OnLeftMouseUp += new DButtonEventHandler(minButton_OnLeftMouseUp);
            _maxButton.OnLeftMouseDown += new DButtonEventHandler(maxButton_OnLeftMouseDown);
            _maxButton.OnLeftMouseUp += new DButtonEventHandler(maxButton_OnLeftMouseUp);
        }
Exemple #2
0
        void AddToCell(int x, int y, DPanel panel)
        {
            // TODO: Reposition all cells if inserting in the middle
            // separate function probably

            if (x < populatedArray.GetLength(0) && y < populatedArray.GetLength(1))
            {
                populatedArray[x, y] = true;

                float xPos = Position.X;
                float yPos = Position.Y;
                if (cellStyle == DCellStyle.Fixed)
                {
                    xPos = Position.X + (x * (cellWidth + cellPadding));
                    yPos = Position.Y + (y * (cellHeight + cellPadding));
                }
                else if (cellStyle == DCellStyle.Dynamic)
                {
                    xPos = Position.X;
                    yPos = Position.Y;

                    // Calc X dimension
                    for (int i = 0; i < x; i++)
                    {
                        if (populatedArray[i, y] == true)
                            xPos += cellPadding + panelArray[i, y].Width;
                    }

                    // Calc Y dimension
                    for (int i = 0; i < y; i++)
                    {
                        if (populatedArray[x, i] == true)
                            yPos += cellPadding + panelArray[x, i].Height;
                    }
                }

                // Set the top left corner of this cell
                Vector2 cellPosition = new Vector2(xPos, yPos);
                panel.Position = cellPosition;
                panelArray[x, y] = panel;
            }
        }
Exemple #3
0
        public void AddGridPanel(int x, int y, DPanel panel)
        {
            if (x >= 0 && x < _columns && y >= 0 && y < _rows && _panelArray[x, y] == null)
            {
                _panelArray[x, y] = panel;
                panel.Position = GridPosition(x,y);
                panel.Size = new Vector2(_cellWidth, _cellHeight);

                if (panel is DText) //&&
                    //(panel as DText).HorizontalAlignment == DText.DHorizontalAlignment.Center &&
                    //(panel as DText).VerticalAlignment == DText.DVerticalAlignment.Center)
                    panel.Position += new Vector2((float)(_cellWidth / 2), (float)(_cellHeight / 2));

                this.AddPanel(panel);
                //panel.RecreateTexture();
            }
        }
Exemple #4
0
 void _guiManager_OnFocusQueueReject(DPanel panel)
 {
     if (panel == this)
         _hasHoveredBeforeClick = false;
 }
Exemple #5
0
 /// <summary>
 /// Add the panel to the layout.
 /// Position it according to the layout flow and the existing items
 /// </summary>
 /// <param name="panel"></param>
 public void Add(DPanel panel)
 {
     bool added = false;
     if (layoutFlow == DLayoutFlowStyle.Horizontally)
     {
         // y,x iteration
         for (int y = 0; y < maxRows; y++)
         {
             for (int x = 0; x < maxColumns; x++)
             {
                 if (populatedArray[x, y] == false)
                 {
                     AddToCell(x, y, panel);
                     added = true;
                     break;
                 }
             }
             if (added)
                 break;
         }
     }
     else if (layoutFlow == DLayoutFlowStyle.Vertically)
     {
         // x,y iteration
         for (int x = 0; x < maxColumns; x++)
         {
             for (int y = 0; y < maxRows; y++)
             {
                 if (populatedArray[x, y] == false)
                 {
                     AddToCell(x, y, panel);
                     added = true;
                     break;
                 }
             }
             if (added)
                 break;
         }
     }
 }
Exemple #6
0
 public bool HasAncestor(DPanel p)
 {
     return HasAncestorRecursive(this, p, false);
 }
Exemple #7
0
        private bool HasAncestorRecursive(DPanel p, DPanel target, bool result)
        {
            if (p == target)
                result = true;
            if (!result)
            {
                if (p.Parent != null)
                    result = HasAncestorRecursive(p.Parent, target, result);
            }

            return result;
        }
Exemple #8
0
 public void AddPanel(DPanel p)
 {
     p.Initialize();
     p.Parent = this;
     this.Children.Add(p);
 }
Exemple #9
0
        public override void Update(GameTime gameTime)
        {
            if (_sceneGraph != null)
            {
                _sceneGraph.Update(gameTime);
            }

            // Calculate focus based on update index
            DPanel focusedPanel = null;
            foreach (DPanel panel in _focusList)
            {
                if (focusedPanel == null || (panel.AcceptsFocus && panel.UpdateIndex > focusedPanel.UpdateIndex))
                    focusedPanel = panel;
            }

            // Notify of rejctions
            foreach (DPanel panel in _focusList)
            {
                if (OnFocusQueueReject != null)
                    OnFocusQueueReject(panel);
            }

            _focusList.Clear();
            if (focusedPanel != null)
                _focusedControl = focusedPanel;

            base.Update(gameTime);
        }
Exemple #10
0
 /// <summary>
 /// Add this item to the GUI manager's list of items that require focus.
 /// List is evaluated and cleared every update - the highest item receives focus.
 /// All losers are notified so that they can reset mouse state flags for another focus click.
 /// </summary>
 /// <param name="panel"></param>
 public void FocusListEnqueue(DPanel panel)
 {
     if (panel != null)
         _focusList.Add(panel);
 }
Exemple #11
0
 /// <summary>
 /// Add a control to the scenegraph as a foreground item which will be rendered after all controls.
 /// </summary>
 /// <param name="panel"></param>
 public void AddForegroundControl(DPanel panel)
 {
     if (_sceneGraph != null)
     {
         _foregroundSceneNode.Children.Add(panel);
     }
 }
Exemple #12
0
 /// <summary>
 /// Add a control to the manager's main scene graph.
 /// Typically you would add a DForm item with this method and attach controls to the form itself.
 /// </summary>
 /// <param name="panel"></param>
 public void AddControl(DPanel panel)
 {
     if (_sceneGraph != null)
     {
         _controlsSceneNode.Children.Add(panel);
     }
 }