Ejemplo n.º 1
0
        public SliderDrawable(Texture2D slider, Texture2D border, Texture2D filling, Region borderRegion, AlignmentContext alignment, float percentageStep)
        {
            this.percentageStep = percentageStep;
            this.alignment      = alignment;
            this.slider         = new SliderItem(slider, new Region(borderRegion.Position.X,
                                                                    borderRegion.Position.Y + (borderRegion.Size.Y / 2) - slider.Height / 2,
                                                                    slider.Width,
                                                                    slider.Height));
            this.border  = new SliderItem(border, borderRegion);
            this.filling = new SliderItem(filling, new Region(borderRegion.Position.X, borderRegion.Position.Y, 0, 0));

            this.slider.Region.onPositionChange += (sender, args) => this.filling.Region.Size = new Vector2(this.slider.Region.Position.X - this.border.Region.Position.X,
                                                                                                            this.border.Region.Size.Y);

            SmoothStep = (time) =>
            {
                if (destinationX == unreachableDestination)
                {
                    return(0.0f);
                }
                float distance = (destinationX - this.slider.Region.Position.X);
                return((Math.Abs(distance) <= stepInterpolation) ?
                       distance :
                       distance *MathHelper.Min(1.0f, (float)time * 10));
            };
        }
Ejemplo n.º 2
0
 public ListView CreateListView(Texture2D texture,
                                Region region,
                                Orientation orientation,
                                AlignmentContext alignment,
                                ReadOnlyCollection <AControl> controls)
 {
     return(new ListView(texture,
                         alignment,
                         orientation,
                         region,
                         controls));
 }
Ejemplo n.º 3
0
 internal Label(string text,
                SpriteFont font,
                Texture2D texture,
                Region region,
                Color textcolor,
                AlignmentContext alignmentContext)
     : base(texture, region, new NoStyle())
 {
     this.Text = new StandardText(font, Vector2.Zero, string.Empty, alignmentContext);
     this.Text.OnTextChanged         += (sender, args) => this.Align(Configuration.Settings.ViewRegion);
     this.Text.Value                  = text;
     this.Text.RenderParameters.Color = textcolor;
     this.Options.IsFocusEnabled      = false;
     this.Options.IsHoverEnabled      = false;
 }
Ejemplo n.º 4
0
 public StandardText(SpriteFont font, Vector2 position, string value, AlignmentContext alignment = null)
 {
     this.font             = font;
     this.RenderParameters = new RenderParameters();
     this.Region           = new Region(position, Font.MeasureString(value ?? defaultSize) * RenderParameters.Scale);
     this.Value            = value ?? string.Empty;
     this.Alignment        = alignment ?? AlignmentContext.Default;
     this.RenderStyle      = new NoStyle();
     this.Padding          = Padding.Zero;
     this.OnTextChanged   += (sender, args) =>
     {
         string textToMeasure = (String.IsNullOrEmpty(args.NewText)) ? defaultSize : args.NewText;
         Region.Size = Font.MeasureString(textToMeasure) * Configuration.Settings.Scale;
     };
 }
Ejemplo n.º 5
0
        internal Scrollable(Texture2D texture,
                            AlignmentContext alignment,
                            Orientation orientation,
                            Region region,
                            ReadOnlyCollection <AControl> controls)
            : base(texture, region, new NoStyle())
        {
            this.listView = new ListView(texture, alignment, orientation, region, controls);

            area = new ControlCamera(region.Position,
                                     region.Frame,
                                     new Rectangle(region.Frame.X, region.Frame.Y,
                                                   (int)listView.VirtualSize.X, (int)listView.VirtualSize.Y));

            region.SetPositionTransformer(position => area.Position - position);

            throw new NotImplementedException();
        }
Ejemplo n.º 6
0
        internal ListView(Texture2D texture,
                          AlignmentContext alignment,
                          Orientation orientation,
                          Region region,
                          ReadOnlyCollection <AControl> controls)
            : base(texture, region, new NoStyle())
        {
            this.ControlAlignment = alignment;
            this.controls         = controls;
            this.orientation      = orientation;

            if (orientation == Orientation.LandScape)
            {
                AlignControls = AlignAsLandscape;
            }
            else
            {
                AlignControls = AlignAsPortrait;
            }

            this.Align(Gem.Gui.Configuration.Settings.ViewRegion);
            this.Options.IsFocusEnabled = false;
        }
Ejemplo n.º 7
0
        internal TextField(TextAppenderHelper appender,
                           SpriteFont font,
                           Texture2D texture,
                           Region region,
                           Color textcolor,
                           ARenderStyle style,
                           string hint,
                           AlignmentContext alignmentContext)
            : base(texture, region, style)
        {
            int padding = 5;

            this.font         = font;
            this.appender     = appender;
            Events.LostFocus += (sender, args) => ShouldProcessInput = false;
            Events.GotFocus  += (sender, args) => ShouldProcessInput = true;

            timer          = new Timer();
            timer.Elapsed += new ElapsedEventHandler((sender, args) => showCursor = !showCursor);
            timer.Interval = appender.CursorFlickInterval;
            timer.Enabled  = true;

            this.hint = new StandardText(font, Vector2.Zero, hint, alignmentContext);
            this.hint.RenderParameters.Color = new Color(textcolor.R, textcolor.G, textcolor.B, 0.4f);
            Text = new StandardText(font, Vector2.Zero, null, alignmentContext);
            Text.RenderParameters.Color = textcolor;
            Text.Padding.Left           = padding;
            Text.Padding.Right          = padding;
            this.hint.Padding.Left      = padding;
            SetupCursor();

            //check if the buffer is not full
            appender.ShouldHandleKey += (key, keyToChar) =>
                                        ((Text.Region.Frame.Right + Text.Padding.Left + Text.Padding.Right
                                          + (font.MeasureString(keyToChar.ToString()).X) * Configuration.Settings.Scale.X)
                                         < (this.Region.Frame.Right));
        }
Ejemplo n.º 8
0
        internal CheckBox(Texture2D texture,
                          Region region,
                          ARenderStyle style,
                          AlignmentContext checkBoxAlignment,
                          Texture2D checkedTexture,
                          Texture2D unCheckedTexture,
                          string text,
                          SpriteFont font)
            : base(texture, region, style)
        {
            int offset = 3;

            this.RenderStyle = style;
            checkBox         = new Button(unCheckedTexture, new Region(0, 0, unCheckedTexture.Width, unCheckedTexture.Height), Style.NoStyle, this.Region);
            checkBox.ScreenAlignment.HorizontalAlignment = checkBoxAlignment.HorizontalAlignment;
            checkBox.ScreenAlignment.VerticalAlignment   = checkBoxAlignment.VerticalAlignment;
            checkBox.Padding.Left = offset;
            checkBox.ScreenAlignment.Transition = checkBoxAlignment.Transition;
            checkBox.Sprite.Add("checked", checkedTexture);
            this.Events.Clicked += (sender, args) =>
            {
                IsChecked = !IsChecked;
                if (IsChecked)
                {
                    checkBox.Sprite.SwitchSprite("checked");
                }
                else
                {
                    checkBox.Sprite.SwitchSprite();
                }
            };
            Text = new StandardText(font, Vector2.Zero, text);
            Text.Alignment.HorizontalAlignment = HorizontalAlignment.RelativeTo(() => (checkBox.Region.Frame.Right) + offset * Configuration.Settings.Scale.X);
            Text.Alignment.VerticalAlignment   = checkBoxAlignment.VerticalAlignment;
            checkBox.Region.onPositionChange  += (args, sender) => Text.Align(this.Region);
        }
Ejemplo n.º 9
0
 public HomeController(AlignmentContext context)
 {
     _context = context;
 }