Example #1
0
        protected override void Draw(ref Parameters.UiViewDrawParameters parameters)
        {
            float opacity = parameters.Opacity;

            if (opacity == 0)
            {
                return;
            }

            var batch = parameters.DrawBatch;

            var drawInfo = new DrawButtonInfo();

            drawInfo.Text        = _text;
            drawInfo.ButtonState = ButtonState;

            drawInfo.Target       = ScreenBounds;
            drawInfo.Opacity      = opacity;
            drawInfo.EllapsedTime = parameters.EllapsedTime;
            drawInfo.Icon         = Icon.Value;

            for (int idx = 0; idx < _drawables.Count; ++idx)
            {
                var drawable = _drawables[idx];
                drawable.Draw(batch, drawInfo);
            }
        }
Example #2
0
        protected override void Draw(ref UiViewDrawParameters parameters)
        {
            float opacity = parameters.Opacity;

            if (opacity == 0)
            {
                return;
            }

            int spacing = _spacing.Compute(_vertical ? Bounds.Width : Bounds.Height);

            Rectangle rect = GetFirstRect();

            int size     = _vertical ? rect.Height : rect.Width;
            int selected = _element.SelectedIndex;

            int count = _element.Count;

            var drawInfo = new DrawButtonInfo();

            drawInfo.Opacity      = opacity;
            drawInfo.EllapsedTime = parameters.EllapsedTime;

            for (int idx = 0; idx < count; ++idx)
            {
                _element.GetText(_text, idx);

                drawInfo.ButtonState = ButtonState.None;
                if (idx == _pushedIndex)
                {
                    drawInfo.ButtonState |= ButtonState.Pushed;
                }

                if (idx == selected)
                {
                    drawInfo.ButtonState |= ButtonState.Checked;
                }

                drawInfo.Text   = _text;
                drawInfo.Target = rect;

                for (int di = 0; di < _drawables.Count; ++di)
                {
                    _drawables[di].DontForceRedraw();
                    _drawables[di].Draw(parameters.DrawBatch, drawInfo);
                }

                if (_vertical)
                {
                    rect.Y += size + spacing;
                }
                else
                {
                    rect.X += size + spacing;
                }
            }
        }
Example #3
0
        protected override void Draw(ref Parameters.UiViewDrawParameters parameters)
        {
            float opacity = parameters.Opacity;

            if (opacity == 0)
            {
                return;
            }

            var batch = parameters.DrawBatch;

            bool hint     = _text.Length == 0;
            bool password = _inputType == TextInputType.Password;

            if (password)
            {
                if (_password.Length != _text.Length)
                {
                    _password.Clear();
                    for (int idx = 0; idx < _text.Length; ++idx)
                    {
                        _password.Append("●");
                    }
                }
            }

            var drawInfo = new DrawButtonInfo();

            drawInfo.Text = hint ? Hint : (password ? _password : _text);

            drawInfo.ButtonState = ButtonState;

            drawInfo.Target       = ScreenBounds;
            drawInfo.Opacity      = opacity;
            drawInfo.EllapsedTime = parameters.EllapsedTime;
            drawInfo.Icon         = Icon.Value;
            drawInfo.Additional   = _carretPosition;

            if (Focused)
            {
                AppMain.RedrawNextFrame();
            }

            if (hint)
            {
                drawInfo.ButtonState |= ButtonDrawables.ButtonState.Special;
            }

            for (int idx = 0; idx < _drawables.Count; ++idx)
            {
                var drawable = _drawables[idx];
                drawable.Draw(batch, drawInfo);
            }
        }
Example #4
0
        protected override void Draw(ref UiViewDrawParameters parameters)
        {
            float opacity = parameters.Opacity;

            if (opacity == 0)
            {
                return;
            }
            Rectangle screen = ScreenBounds;
            Rectangle thumb  = ThumbRect;

            if (thumb != screen || _alwaysVisible)
            {
                var batch = parameters.DrawBatch;

                var drawInfo = new DrawButtonInfo();
                drawInfo.Text        = null;
                drawInfo.ButtonState = _touchId != 0 ? ButtonState.Pushed : ButtonState.None;

                if (thumb == screen)
                {
                    drawInfo.ButtonState = ButtonState.Disabled;
                }

                drawInfo.Target       = screen;
                drawInfo.Opacity      = opacity;
                drawInfo.EllapsedTime = parameters.EllapsedTime;

                for (int idx = 0; idx < _trackDrawables.Count; ++idx)
                {
                    var drawable = _trackDrawables[idx];
                    drawable.Draw(batch, drawInfo);
                }

                drawInfo.Target = thumb;

                for (int idx = 0; idx < _thumbDrawables.Count; ++idx)
                {
                    var drawable = _thumbDrawables[idx];
                    drawable.Draw(batch, drawInfo);
                }
            }
        }
Example #5
0
        void OnTouchDown(int id, Vector2 pos)
        {
            if (Focused)
            {
                if (!IsPointInsideView(pos))
                {
                    AppMain.Current.ReleaseFocus(_textInput);
                }
                else
                {
                    var drawInfo = new DrawButtonInfo();

                    drawInfo.Text        = _text;
                    drawInfo.ButtonState = ButtonState;

                    drawInfo.Target       = ScreenBounds;
                    drawInfo.Opacity      = 0;
                    drawInfo.EllapsedTime = 0;
                    drawInfo.Icon         = Icon.Value;
                    drawInfo.Additional   = 0;

                    int clickPosition = (int)pos.X;

                    for (int idx = 0; idx < _drawables.Count; ++idx)
                    {
                        var    drawable = _drawables[idx];
                        object ret      = drawable.OnAction(drawInfo, clickPosition);

                        if (ret != null)
                        {
                            _carretPosition = (int)ret;
                        }
                    }
                }
            }
        }
Example #6
0
        protected override void Draw(ref UiViewDrawParameters parameters)
        {
            base.Draw(ref parameters);

            AdvancedDrawBatch batch  = parameters.DrawBatch;
            Rectangle         bounds = ScreenBounds;

            _selectedPosition = bounds.Center.Y + _selectedPositionOffset.Compute(bounds.Height);

            int size = _elementHeight.Compute(bounds.Height) + _spacing.Compute();

            int start  = 0;
            int center = _selectedPosition + (int)(_scroll * size);

            Rectangle rect = bounds;

            rect.Height = _elementHeight.Compute(bounds.Height);

            while (center > bounds.Top - size / 2)
            {
                center -= size;
                start--;
            }

            rect.Y = center - _elementHeight.Compute(bounds.Height) / 2;

            DrawButtonInfo drawInfo = new DrawButtonInfo();

            drawInfo.Icon         = null;
            drawInfo.Opacity      = parameters.Opacity;
            drawInfo.EllapsedTime = parameters.EllapsedTime;
            drawInfo.Text         = _captionText;

            while (rect.Bottom <= bounds.Bottom + size)
            {
                ButtonState state = _touchId != 0 ? ButtonState.Pushed : ButtonState.None;

                if (center == _selectedPosition && !_isScrolling && float.IsNaN(_scrollTo))
                {
                    state |= ButtonState.Checked;
                }

                if (start == (int)((_scroll > 0 ? -0.5 : 0.5) - _scroll))
                {
                    state |= ButtonState.Checked;
                }

                bool enabled = false;
                _context.GetData(start, _captionText.StringBuilder, out enabled);

                if (!enabled)
                {
                    state |= ButtonState.Disabled;
                    state &= ~ButtonState.Pushed;
                }

                drawInfo.Target      = rect;
                drawInfo.ButtonState = state;

                for (int idx = 0; idx < _drawables.Count; ++idx)
                {
                    var drawable = _drawables[idx];
                    drawable.Draw(batch, drawInfo);
                }

                start++;
                center += size;
                rect.Y += size;
            }
        }