Exemple #1
0
        public Vector2 Transform(IControl parent)
        {
            if (parent is IStaticContainerControl container && container.UseRenderTarget)
            {
                // If the container is using render targets, we must apply view offset
                // to the mouse states position as transformation. This transformation
                // must be inverse relative to the parent as the parent control does
                // normal transformation.
                return(UiCanvas.ToLocalUnits(CurrentLocalPosition.X - container.ViewOffset.X,
                                             CurrentLocalPosition.Y - container.ViewOffset.Y));
            }

            return(CurrentLocalPosition);
        }
Exemple #2
0
        protected override void InternalUpdate(IGameEngineTime time, IMouseDevice device)
        {
            // If no click has happened we don't update focus.
            // Focus requires a click to be applied.
            if (!device.IsButtonPressed(MouseButton.Left))
            {
                return;
            }

            // Defocus keyboards focus if mouse is gaining the focus.
            Context.Keyboard?.Defocus();

            // Find next focused control.
            Focus(Root, new Rectf(UiCanvas.ToLocalUnits(device.GetPosition().ToVector2()), UiCanvas.ToLocalUnits(Vector2.One)));
        }
Exemple #3
0
        public override void Update(IGameEngineTime time, IMouseDevice device)
        {
            Pressed  = device.GetButtonsPressed();
            Down     = device.GetButtonsDown();
            Released = device.GetButtonsReleased();
            Up       = device.GetButtonsUp();

            base.Update(time, device);

            CurrentLocalPosition = UiCanvas.ToLocalUnits(device.GetPosition().ToVector2());
            LastLocalPosition    = UiCanvas.ToLocalUnits(device.GetPosition(1).ToVector2());

            CurrentScrollValue = device.GetScrollWheelValue();
            LastScrollValue    = device.GetScrollWheelValue(1);
        }
Exemple #4
0
        private Vector2 GetCollapsedSize()
        {
            var size = Size;

            size.X = ActualSize.X;

            var itemSource = Style.Get <Rectangle>($"{UiStyleKeys.Target.ListBox}\\{UiStyleKeys.Source.Text}");
            var tuples     = GetItemTuples();

            var itemAreaTop    = tuples.First().Rectangle.Bottom;
            var itemAreaBottom = tuples.Last().Rectangle.Bottom;
            var itemArea       = itemAreaBottom - itemAreaTop - itemSource.Y;

            size += UiCanvas.ToLocalUnits(itemArea * Vector2.UnitY);

            return(size);
        }
Exemple #5
0
 public bool IsHovering(Rectf area)
 => Rectf.Intersects(area, new Rectf(CurrentLocalPosition, UiCanvas.ToLocalUnits(Vector2.One)));