Exemple #1
0
        //----------------------------------------------------------------------
        public Panel( Screen _screen, Texture2D _texture, int _iCornerSize )
            : base(_screen)
        {
            Texture     = _texture;
            CornerSize  = _iCornerSize;
            Padding     = new Box( CornerSize );

            Scrollbar   = new Scrollbar( _screen );
            Scrollbar.Parent = this;
        }
Exemple #2
0
        //----------------------------------------------------------------------
        public DropDownBox( Screen _screen, List<DropDownItem> _lItems, int _iInitialValueIndex )
            : base(_screen)
        {
            mCurrentItemLabel = new Label( Screen, _anchor: Anchor.Start );

            Items = new ObservableList<DropDownItem>( _lItems );

            Items.ListChanged += delegate( object _source, ObservableList<DropDownItem>.ListChangedEventArgs _args )
            {
                if( _args.Added )
                {
                    _args.Item.DropDownBox = this;
                }

                if( SelectedItemIndex == -1 )
                {
                    if( _args.Added )
                    {
                        SelectedItemIndex = _args.Index;
                    }
                }
                else
                if( _args.Index <= SelectedItemIndex )
                {
                    SelectedItemIndex = Math.Min( Items.Count - 1, Math.Max( 0, SelectedItemIndex + ( _args.Added ? 1 : -1 ) ) );
                }
            };

            Items.ListCleared += delegate( object _source, EventArgs _args )
            {
                SelectedItemIndex = -1;
            };

            SelectedItemIndex = _iInitialValueIndex;
            mScrollbar = new Scrollbar( _screen );
            mScrollbar.Parent = this;

            ScrollItemOffset = Math.Max( 0, Math.Min( SelectedItemIndex, Items.Count - siMaxLineDisplayed ) );
            mScrollbar.LerpOffset = mScrollbar.Offset;

            Padding = new Box( 10 );
            TextPadding = new Box( 5 );

            mPressedAnim    = new SmoothValue( 1f, 0f, 0.2f );
            mPressedAnim.SetTime( mPressedAnim.Duration );

            ButtonFrame         = Screen.Style.ButtonFrame;
            ButtonFrameDown     = Screen.Style.ButtonFrameDown;
            ButtonFrameHover    = Screen.Style.ButtonHover;
            ButtonFramePressed  = Screen.Style.ButtonPress;

            UpdateContentSize();
        }
Exemple #3
0
        //----------------------------------------------------------------------
        public ListView( Screen _screen )
            : base(_screen)
        {
            Columns = new List<ListViewColumn>();

            Rows    = new ObservableList<ListViewRow>();

            Rows.ListCleared += delegate {
                SelectedRow         = null;
                HoveredRow          = null;
                FocusedRow          = null;

                mHoveredActionButton = null;
                mbIsHoveredActionButtonDown = false;
            };

            Rows.ListChanged += delegate( object _source, ObservableList<ListViewRow>.ListChangedEventArgs _args )
            {
                if( ! _args.Added )
                {
                    if( _args.Item == SelectedRow )
                    {
                        SelectedRow = null;
                    }

                    if( _args.Item == HoveredRow )
                    {
                        UpdateHoveredRow();
                    }

                    if( _args.Item == FocusedRow )
                    {
                        FocusedRow = null;
                        IsDragging = false;
                    }
                }
            };

            SelectedRow     = null;
            FocusedRow      = null;
            HoveredRow      = null;
            TextColor = Screen.Style.DefaultTextColor;

            Style.ListFrame             = Screen.Style.ListFrame;
            Style.FrameSelected         = Screen.Style.GridBoxFrameSelected;
            Style.FrameSelectedHover    = Screen.Style.GridBoxFrameSelectedHover;
            Style.FrameSelectedFocus    = Screen.Style.GridBoxFrameSelectedFocus;

            Scrollbar = new Scrollbar( _screen );
            Scrollbar.Parent = this;

            ActionButtons = new List<Button>();

            UpdateContentSize();
        }
Exemple #4
0
        //----------------------------------------------------------------------
        public RichTextArea( Screen _screen )
        : base( _screen )
        {
            Caret           = new RichTextCaret( this );
            TextBlocks       = new List<TextBlock>();
            TextBlocks.Add( new TextBlock( this, "" ) );

            RemoteCaretsById = new Dictionary<UInt16,RemoteRichTextCaret>();

            Padding         = new Box(20);

            Scrollbar       = new Scrollbar( _screen );
            Scrollbar.Parent = this;

            PanelTex        = Screen.Style.ListFrame;
        }
Exemple #5
0
 public override Widget HitTest(Point _point)
 {
     return(Scrollbar.HitTest(_point) ?? base.HitTest(_point) ?? (HitBox.Contains(_point) ? this : null));
 }
Exemple #6
0
 //----------------------------------------------------------------------
 public override Widget HitTest(Point _point)
 {
     return(Scrollbar.HitTest(_point) ?? base.HitTest(_point));
 }
Exemple #7
0
        //----------------------------------------------------------------------
        public override void DoLayout(Rectangle _rect)
        {
            base.DoLayout(_rect);
            HitBox = new Rectangle(LayoutRect.X + Padding.Left, LayoutRect.Y + Padding.Top, LayoutRect.Width - Padding.Horizontal, LayoutRect.Height - Padding.Vertical);

            int iColX     = 0;
            int iColIndex = 0;

            foreach (ListViewColumn col in Columns)
            {
                if (col.Label != null)
                {
                    col.Label.DoLayout(new Rectangle(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top, col.Width, Style.RowHeight));
                }
                else
                {
                    col.Image.DoLayout(new Rectangle(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top, col.Width, Style.RowHeight));
                }

                int iRowIndex = 0;
                foreach (ListViewRow row in Rows)
                {
                    int iRowY = GetRowY(iRowIndex);
                    row.Cells[iColIndex].DoLayout(new Rectangle(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top + iRowY, col.Width, Style.RowHeight + Style.RowSpacing), iColIndex, col, row);

                    iRowIndex++;
                }

                iColIndex++;

                iColX += col.Width + ColSpacing;
            }

            //------------------------------------------------------------------
            if (HoveredRow != null)
            {
                int iRight = LayoutRect.Right - Padding.Right - Style.CellHorizontalPadding;
                if (ActionButtonsColumn != -1)
                {
                    iRight = LayoutRect.Left + Padding.Left + Columns.Take(ActionButtonsColumn + 1).Sum(x => x.Width);
                }

                int iButtonX = Style.ActionButtonsRightPadding;
                foreach (Button button in ActionButtons.Reverse <Button>())
                {
                    button.DoLayout(new Rectangle(
                                        iRight - iButtonX - button.ContentWidth,
                                        LayoutRect.Y + Padding.Top + GetRowY(Rows.IndexOf(HoveredRow)) + Style.RowHeight / 2 - button.ContentHeight / 2,
                                        button.ContentWidth, button.ContentHeight)
                                    );

                    iButtonX += button.ContentWidth + Style.CellHorizontalPadding;
                }
            }

            //------------------------------------------------------------------
            ContentHeight = Padding.Vertical + Rows.Count * (Style.RowHeight + Style.RowSpacing) - Style.RowSpacing;
            if (NewRowText != null)
            {
                ContentHeight += Style.RowHeight;
            }

            Scrollbar.DoLayout(LayoutRect, ContentHeight);
        }
Exemple #8
0
        //----------------------------------------------------------------------
        public ListView(Screen _screen)
            : base(_screen)
        {
            Columns = new List <ListViewColumn>();

            Rows = new ObservableList <ListViewRow>();

            Rows.ListCleared += delegate {
                SelectedRow = null;
                HoveredRow  = null;
                FocusedRow  = null;

                mHoveredActionButton        = null;
                mbIsHoveredActionButtonDown = false;
            };

            Rows.ListChanged += delegate(object _source, ObservableList <ListViewRow> .ListChangedEventArgs _args)
            {
                if (!_args.Added)
                {
                    if (_args.Item == SelectedRow)
                    {
                        SelectedRow = null;
                    }

                    if (_args.Item == HoveredRow)
                    {
                        UpdateHoveredRow();
                    }

                    if (_args.Item == FocusedRow)
                    {
                        FocusedRow = null;
                        IsDragging = false;
                    }
                }
            };

            SelectedRow = null;
            FocusedRow  = null;
            HoveredRow  = null;
            TextColor   = Screen.Style.DefaultTextColor;

            Padding = Screen.Style.ListViewPadding;
            Style   = Screen.Style.ListViewStyle;

            Scrollbar        = new Scrollbar(_screen);
            Scrollbar.Parent = this;

            ActionButtons = new ObservableList <Button>();

            ActionButtons.ListCleared += delegate {
                mHoveredActionButton = null;
            };

            ActionButtons.ListChanged += delegate {
                if (mHoveredActionButton != null && !ActionButtons.Contains(mHoveredActionButton))
                {
                    mHoveredActionButton = null;
                }
            };

            UpdateContentSize();
        }
Exemple #9
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();
        }
Exemple #10
0
        //----------------------------------------------------------------------
        public TextArea( Screen _screen )
        : base( _screen )
        {
            Font            = Screen.Style.MediumFont;
            Text            = "";
            mbWrapTextNeeded = true;
            Caret           = new TextCaret( this );
            RemoteCaretsById = new Dictionary<UInt16,RemoteTextCaret>();

            Padding         = new Box(20);

            Scrollbar       = new Scrollbar( _screen );
            Scrollbar.Parent = this;

            PanelTex        = Screen.Style.ListFrame;
        }