Exemplo n.º 1
0
        //----------------------------------------------------------------------
        public Button( Screen _screen, ButtonStyle _style, string _strText = "", Texture2D _iconTex = null, Anchor _anchor = Anchor.Center, string _strTooltipText="", object _tag=null )
            : base(_screen)
        {
            Style = _style;

            mPadding    = new Box(5, 0);
            mMargin     = new Box(0);

            mLabel          = new Label( _screen );

            mIcon           = new Image( _screen );
            mIcon.Texture   = _iconTex;
            mIcon.Padding   = new Box( Style.VerticalPadding, 0, Style.VerticalPadding, Style.HorizontalPadding );

            Text            = _strText;
            TextColor       = Screen.Style.DefaultTextColor;

            Anchor          = _anchor;

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

            mTooltip        = new Tooltip( Screen, "" );

            TooltipText     = _strTooltipText;
            Tag             = _tag;

            UpdateContentSize();
        }
Exemplo n.º 2
0
        //----------------------------------------------------------------------
        public KeyBox( Screen _screen, Keys _key )
            : base(_screen)
        {
            mKey        = _key;
            mFont       = _screen.Style.MediumFont;
            mPadding    = new Box( 15 );

            UpdateContentSize();
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        //----------------------------------------------------------------------
        public EditBox( Screen _screen, string _strText = "", Func<char,bool> _textEnteredHandler = null )
            : base(_screen)
        {
            mstrText    = _strText;
            mFont       = _screen.Style.MediumFont;
            mPadding    = new Box( 15 );
            TextEnteredHandler = _textEnteredHandler;

            Frame               = Screen.Style.EditBoxFrame;
            FrameCornerSize     = Screen.Style.EditBoxCornerSize;

            UpdateContentSize();
        }
Exemplo n.º 6
0
        //----------------------------------------------------------------------
        public Label( Screen _screen, string _strText, Anchor _anchor, Color _color )
            : base(_screen)
        {
            mstrText            = _strText;
            mstrDisplayedText   = mstrText;
            mFont               = _screen.Style.MediumFont;
            mPadding            = new Box( 10 );
            mAnchor             = _anchor;

            Color               = _color;
            OutlineRadius       = Screen.Style.BlurRadius;
            OutlineColor        = _color * 0.5f;

            UpdateContentSize();
        }
Exemplo n.º 7
0
        //----------------------------------------------------------------------
        public override void Draw()
        {
            if( mfTooltipTimer < sfTooltipDelay || string.IsNullOrEmpty( Text ) ) return;

            UIFont font = Screen.Style.MediumFont;

            Box padding = new Box( 10, 10 );

            Vector2 vSize = font.MeasureString( Text );
            int iWidth  = (int)vSize.X;
            int iHeight = (int)vSize.Y;

            Point topLeft = new Point(
                Math.Min( Screen.Game.InputMgr.MouseState.X, Screen.Width - iWidth - padding.Horizontal ),
                Math.Min( Screen.Game.InputMgr.MouseState.Y + 20, Screen.Height - iHeight - padding.Vertical ) );

            Screen.DrawBox( Screen.Style.TooltipFrame, new Rectangle( topLeft.X, topLeft.Y, iWidth + padding.Horizontal, iHeight + padding.Vertical ), Screen.Style.TooltipCornerSize, Color.White );
            Screen.Game.SpriteBatch.DrawString( font, Text, new Vector2( topLeft.X + padding.Left, topLeft.Y + padding.Top + font.YOffset ), Screen.Style.TooltipTextColor );
        }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
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;
        }