예제 #1
0
        //----------------------------------------------------------------------
        public void DrawWithOffset(Point _pOffset)
        {
            var rect = LayoutRect;

            rect.Offset(_pOffset);

            if (Frame != null)
            {
                Screen.DrawBox(Frame, rect, FrameCornerSize, Color.White);
            }

            if (Screen.IsActive && mbIsHovered)
            {
                Screen.DrawBox(Screen.Style.EditBoxHoverOverlay, rect, Screen.Style.EditBoxCornerSize, Color.White);
            }

            Screen.PushScissorRectangle(new Rectangle(rect.X + Padding.Left, rect.Y, rect.Width - Padding.Horizontal, rect.Height));

            if (mstrDisplayedText != "")
            {
                Screen.Game.SpriteBatch.DrawString(mFont, mstrDisplayedText, new Vector2(mpTextPosition.X - miScrollOffset + _pOffset.X, mpTextPosition.Y + mFont.YOffset + _pOffset.Y), TextColor);
            }
            else
            {
                Screen.Game.SpriteBatch.DrawString(mFont, PlaceholderText, new Vector2(mpTextPosition.X - miScrollOffset + _pOffset.X, mpTextPosition.Y + mFont.YOffset + _pOffset.Y), TextColor * 0.5f);
            }

            Screen.PopScissorRectangle();

            const float fBlinkInterval = 0.3f;

            if (SelectionOffset != 0)
            {
                Screen.PushScissorRectangle(new Rectangle(rect.X + Padding.Left, rect.Y + Padding.Top, rect.Width - Padding.Horizontal, rect.Height - Padding.Vertical));

                Rectangle selectionRectangle;
                if (SelectionOffset > 0)
                {
                    selectionRectangle = new Rectangle(mpTextPosition.X + miCaretX - miScrollOffset, rect.Y + Padding.Top, miSelectionX - miCaretX, rect.Height - Padding.Vertical);
                }
                else
                {
                    selectionRectangle = new Rectangle(mpTextPosition.X + miSelectionX - miScrollOffset, rect.Y + Padding.Top, miCaretX - miSelectionX, rect.Height - Padding.Vertical);
                }

                Screen.Game.SpriteBatch.Draw(Screen.Game.WhitePixelTex, selectionRectangle, TextColor * 0.3f);

                Screen.PopScissorRectangle();
            }
            else
            if (Screen.IsActive && HasFocus && mfCaretTimer % (fBlinkInterval * 2) < fBlinkInterval)
            {
                Screen.Game.SpriteBatch.Draw(Screen.Game.WhitePixelTex, new Rectangle(mpTextPosition.X + miCaretX - miScrollOffset, rect.Y + Padding.Top, Screen.Style.CaretWidth, rect.Height - Padding.Vertical), TextColor);
            }
        }
예제 #2
0
        //----------------------------------------------------------------------
        public override void Draw()
        {
            Screen.DrawBox(Screen.Style.EditBoxFrame, LayoutRect, Screen.Style.EditBoxCornerSize, Color.White);

            if (Screen.IsActive && mbIsHovered)
            {
                Screen.DrawBox(Screen.Style.EditBoxHoverOverlay, LayoutRect, Screen.Style.EditBoxCornerSize, Color.White);
            }

            Screen.PushScissorRectangle(new Rectangle(LayoutRect.X + Padding.Left, LayoutRect.Y, LayoutRect.Width - Padding.Horizontal, LayoutRect.Height));

            Screen.Game.SpriteBatch.DrawString(mFont, DisplayedKey, new Vector2(mpTextPosition.X, mpTextPosition.Y + mFont.YOffset), TextColor);

            Screen.PopScissorRectangle();

            if (HasFocus)
            {
                Rectangle selectionRectangle = new Rectangle(mpTextPosition.X, LayoutRect.Y + Padding.Top, miTextWidth, LayoutRect.Height - Padding.Vertical);
                Screen.Game.SpriteBatch.Draw(Screen.Game.WhitePixelTex, selectionRectangle, TextColor * 0.3f);
            }
        }
예제 #3
0
        //----------------------------------------------------------------------
        public override void Draw()
        {
            if (Texture != null)
            {
                Screen.DrawBox(Texture, new Rectangle(LayoutRect.X + Margin.Left, LayoutRect.Y + Margin.Top, LayoutRect.Width - Margin.Horizontal, LayoutRect.Height - Margin.Vertical), CornerSize, Color.White);
            }

            if (DoClipping)
            {
                Screen.PushScissorRectangle(new Rectangle(LayoutRect.X + Padding.Left + Margin.Left, LayoutRect.Y + Padding.Top + Margin.Top, LayoutRect.Width - Padding.Horizontal - Margin.Horizontal, LayoutRect.Height - Padding.Vertical - Margin.Vertical));
            }

            base.Draw();

            if (DoClipping)
            {
                Screen.PopScissorRectangle();
            }

            if (EnableScrolling)
            {
                Scrollbar.Draw();
            }
        }
예제 #4
0
        //----------------------------------------------------------------------
        public override void Draw()
        {
            Screen.DrawBox(Style.ListViewFrame, LayoutRect, Style.ListViewFrameCornerSize, Color.White);

            if (DisplayColumnHeaders)
            {
                int iColX = 0;
                foreach (ListViewColumn col in Columns)
                {
                    Screen.DrawBox(Style.ColumnHeaderFrame, new Rectangle(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top, col.Width, Style.RowHeight), Style.ColumnHeaderCornerSize, Color.White);

                    if (col.Label != null)
                    {
                        col.Label.Draw();
                    }
                    else
                    {
                        col.Image.Draw();
                    }
                    iColX += col.Width + ColSpacing;
                }
            }

            Screen.PushScissorRectangle(new Rectangle(LayoutRect.X + Padding.Left, LayoutRect.Y + Padding.Top + (DisplayColumnHeaders ? Style.RowHeight : 0), LayoutRect.Width - Padding.Horizontal, LayoutRect.Height - Padding.Vertical - (DisplayColumnHeaders ? Style.RowHeight : 0)));

            int iRowIndex = 0;

            foreach (ListViewRow row in Rows)
            {
                int iRowY = GetRowY(iRowIndex);
                if ((iRowY + Style.RowHeight + Style.RowSpacing < 0) || (iRowY > LayoutRect.Height - Padding.Vertical))
                {
                    iRowIndex++;
                    continue;
                }

                if (MergeColumns)
                {
                    Rectangle rowRect = new Rectangle(LayoutRect.X + Padding.Left, LayoutRect.Y + Padding.Top + iRowY, LayoutRect.Width - Padding.Horizontal, Style.RowHeight);

                    Screen.DrawBox(SelectedRow == row ? Style.SelectedCellFrame : Style.CellFrame, rowRect, Style.CellCornerSize, Color.White);

                    if (HasFocus && FocusedRow == row)
                    {
                        if (SelectedRow != row)
                        {
                            Screen.DrawBox(Style.CellFocusOverlay, rowRect, Style.CellCornerSize, Color.White);
                        }
                        else
                        if (Style.SelectedCellFocusOverlay != null)
                        {
                            Screen.DrawBox(Style.SelectedCellFocusOverlay, rowRect, Style.CellCornerSize, Color.White);
                        }
                    }

                    if (HoveredRow == row && !IsDragging)
                    {
                        if (SelectedRow != row)
                        {
                            Screen.DrawBox(Style.CellHoverOverlay, rowRect, Style.CellCornerSize, Color.White);
                        }
                        else
                        if (Style.SelectedCellHoverOverlay != null)
                        {
                            Screen.DrawBox(Style.SelectedCellHoverOverlay, rowRect, Style.CellCornerSize, Color.White);
                        }
                    }
                }

                int iColX = 0;
                for (int i = 0; i < row.Cells.Length; i++)
                {
                    ListViewColumn col     = Columns[i];
                    Rectangle      rowRect = new Rectangle(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top + iRowY, col.Width, Style.RowHeight);

                    if (!MergeColumns)
                    {
                        Screen.DrawBox(SelectedRow == row ? Style.SelectedCellFrame : Style.CellFrame, rowRect, Style.CellCornerSize, Color.White);

                        if (HasFocus && FocusedRow == row)
                        {
                            if (SelectedRow != row)
                            {
                                Screen.DrawBox(Style.CellFocusOverlay, rowRect, Style.CellCornerSize, Color.White);
                            }
                            else
                            if (Style.SelectedCellFocusOverlay != null)
                            {
                                Screen.DrawBox(Style.SelectedCellFocusOverlay, rowRect, Style.CellCornerSize, Color.White);
                            }
                        }

                        if (HoveredRow == row && !IsDragging)
                        {
                            if (SelectedRow != row)
                            {
                                Screen.DrawBox(Style.CellHoverOverlay, rowRect, Style.CellCornerSize, Color.White);
                            }
                            else
                            if (Style.SelectedCellHoverOverlay != null)
                            {
                                Screen.DrawBox(Style.SelectedCellHoverOverlay, rowRect, Style.CellCornerSize, Color.White);
                            }
                        }
                    }

                    row.Cells[i].Draw(new Point(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top + iRowY));

                    iColX += col.Width + ColSpacing;
                }

                iRowIndex++;
            }

            if (NewRowText != null)
            {
                int iRowY = GetRowY(iRowIndex);
                Screen.DrawBox(mbIsHoveringNewRow ? Style.NewRowHoveredFrame : Style.NewRowFrame, new Rectangle(LayoutRect.X + Padding.Left, LayoutRect.Y + Padding.Top + iRowY, LayoutRect.Width - Padding.Horizontal, Style.RowHeight), Style.NewRowFrameCornerSize, Color.White);

                Vector2 vTextPos = new Vector2(LayoutRect.X + Padding.Left + Style.NewRowHorizontalPadding, LayoutRect.Y + Padding.Top + iRowY + Style.RowHeight / 2f - (int)(Screen.Style.MediumFont.LineSpacing * 0.9f / 2f) + Screen.Style.MediumFont.YOffset);
                Screen.Game.SpriteBatch.DrawString(Screen.Style.MediumFont, NewRowText, vTextPos, mbIsHoveringNewRow ? Style.NewRowHoveredTextColor : Style.NewRowTextColor);

                iRowIndex++;
            }

            if (HoveredRow != null && !IsDragging)
            {
                foreach (Button button in ActionButtons)
                {
                    button.Draw();
                }
            }

            if (IsDragging && HitBox.Contains(mHoverPoint))
            {
                int iX     = LayoutRect.X + Padding.Left;
                int iWidth = LayoutRect.Width - Padding.Horizontal;

                if (HoveredRow != null)
                {
                    int iY = LayoutRect.Y + Padding.Top + GetRowY(Rows.IndexOf(HoveredRow) + (mbInsertAfter ? 1 : 0)) - (Style.RowSpacing + Screen.Style.ListRowInsertMarker.Height) / 2;

                    Rectangle markerRect = new Rectangle(iX, iY, iWidth, Screen.Style.ListRowInsertMarker.Height);
                    Screen.DrawBox(Screen.Style.ListRowInsertMarker, markerRect, Screen.Style.ListRowInsertMarkerCornerSize, Color.White);
                }
                else
                if (IsHovered)
                {
                    int iY = LayoutRect.Y + Padding.Top + (mbInsertAfter ? GetRowY(Rows.Count) : 0) - (Style.RowSpacing + Screen.Style.ListRowInsertMarker.Height) / 2;

                    Rectangle markerRect = new Rectangle(iX, iY, iWidth, Screen.Style.ListRowInsertMarker.Height);
                    Screen.DrawBox(Screen.Style.ListRowInsertMarker, markerRect, Screen.Style.ListRowInsertMarkerCornerSize, Color.White);
                }
            }

            Screen.PopScissorRectangle();

            Scrollbar.Draw();
        }