Ejemplo n.º 1
0
 public Input()
 {
     Key = new Dictionary<Keyboard.Key, KeyEvent>();
     MouseButton = new Dictionary<Mouse.Button, MouseButtonEvent>();
     Text = null;
     MouseWheel = null;
     MouseMove = null;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns event position of MouseMoveEvent where it would be if the window wasn't resized
 /// See Terminology above
 /// </summary>
 public MouseMoveEventArgs EventToWindowPos(MouseMoveEventArgs mouseMoveEvent)
 {
     Vector2i windowPos = (Vector2i)_window.MapPixelToCoords(
         new Vector2i((int)mouseMoveEvent.X, (int)mouseMoveEvent.Y), _interfaceView);
     mouseMoveEvent.X = (int)windowPos.X;
     mouseMoveEvent.Y = (int)windowPos.Y;
     MouseMoveEvent newMouseEvent = new MouseMoveEvent();
     newMouseEvent.X = windowPos.X;
     newMouseEvent.Y = windowPos.Y;
     MouseMoveEventArgs eventArgsWindowPos = new MouseMoveEventArgs(newMouseEvent);
     return eventArgsWindowPos;
 }
Ejemplo n.º 3
0
        private void Manager_MouseMoved(object sender, SFML.Window.MouseMoveEvent e)
        {
            if (hovered && !boundingbox.Contains(e.X, e.Y))
            {
                OnExited();
                hovered = false;
            }

            if (!hovered && boundingbox.Contains(e.X, e.Y))
            {
                OnEntered();
                hovered = true;
            }
        }
Ejemplo n.º 4
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Tells the widget that the left mouse has been pressed on top of the widget
        /// </summary>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        protected internal override void OnLeftMousePressed(MouseButtonEventArgs e)
        {
            // Set the mouse down flag
            m_MouseDown = true;

            // Change the value of the knob depending on where you clicked
            MouseMoveEvent move = new MouseMoveEvent();
            move.X = e.X;
            move.Y = e.Y;
            OnMouseMoved (new MouseMoveEventArgs(move));
        }
        public override void MouseMove(MouseMoveEventArgs e)
        {
            if (disposing || !IsVisible()) return;
            scrollbarH.MouseMove(e);
            scrollbarV.MouseMove(e);

            MouseMoveEvent mme= new MouseMoveEvent();
            mme.X = e.X-(Position.X + (int) scrollbarH.Value);
            mme.Y = e.Y-(Position.Y + (int) scrollbarV.Value);
            MouseMoveEventArgs modArgs = new MouseMoveEventArgs(mme);

            foreach (GuiComponent component in components)
                component.MouseMove(modArgs);

            return;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Construct the mouse move arguments from a mouse move event
 /// </summary>
 /// <param name="e">Mouse move event</param>
 ////////////////////////////////////////////////////////////
 public MouseMoveEventArgs(MouseMoveEvent e)
 {
     X = e.X;
     Y = e.Y;
 }
Ejemplo n.º 7
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Tells the widget that the left mouse has been pressed on top of the widget
        /// </summary>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        protected internal override void OnLeftMousePressed(MouseButtonEventArgs e)
        {
            m_MouseDown = true;

            // Refresh the value
            MouseMoveEvent move = new MouseMoveEvent();
            move.X = e.X;
            move.Y = e.Y;
            OnMouseMoved (new MouseMoveEventArgs(move));
        }
Ejemplo n.º 8
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Tells the widget that the left mouse has been pressed on top of the widget
        /// </summary>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        protected internal override void OnLeftMousePressed(MouseButtonEventArgs e)
        {
            m_MouseDown = true;
            m_MouseDownOnArrow = false;

            // Make sure you didn't click on one of the arrows
            if (m_VerticalScroll)
            {
                float scalingX;
                if (m_VerticalImage == m_VerticalScroll)
                    scalingX = m_Size.X / m_TextureTrackNormal_M.Size.X;
                else
                    scalingX = m_Size.X / m_TextureTrackNormal_M.Size.Y;

                // Check if the arrows are drawn at full size
                if (m_Size.Y > (m_TextureArrowUpNormal.Size.Y + m_TextureArrowDownNormal.Size.Y) * scalingX)
                {
                    // Check if you clicked on one of the arrows
                    if (e.Y < Position.Y + (m_TextureArrowUpNormal.Size.Y * scalingX))
                        m_MouseDownOnArrow = true;
                    else if (e.Y > Position.Y + m_Size.Y - (m_TextureArrowUpNormal.Size.Y * scalingX))
                        m_MouseDownOnArrow = true;
                }
                else // The arrows are not drawn at full size (there is no track)
                    m_MouseDownOnArrow = true;
            }
            else // The scrollbar lies horizontal
            {
                float scalingY;
                if (m_VerticalImage == m_VerticalScroll)
                    scalingY = m_Size.Y / m_TextureTrackNormal_M.Size.Y;
                else
                    scalingY = m_Size.Y / m_TextureTrackNormal_M.Size.X;

                // Check if the arrows are drawn at full size
                if (m_Size.X > (m_TextureArrowUpNormal.Size.Y + m_TextureArrowDownNormal.Size.Y) * scalingY)
                {
                    // Check if you clicked on one of the arrows
                    if (e.X < Position.X + (m_TextureArrowUpNormal.Size.Y * scalingY))
                        m_MouseDownOnArrow = true;
                    else if (e.X > Position.X + m_Size.X - (m_TextureArrowUpNormal.Size.Y * scalingY))
                        m_MouseDownOnArrow = true;
                }
                else // The arrows are not drawn at full size (there is no track)
                    m_MouseDownOnArrow = true;
            }

            FloatRect thumbRect = GetThumbRect();

            // Check if the mouse is on top of the thumb
            if (new FloatRect(Position.X + thumbRect.Left, Position.Y + thumbRect.Top, thumbRect.Width, thumbRect.Height).Contains(e.X, e.Y))
            {
                m_MouseDownOnThumbPos.X = e.X - Position.X - thumbRect.Left;
                m_MouseDownOnThumbPos.Y = e.Y - Position.Y - thumbRect.Top;

                m_MouseDownOnThumb = true;
            }
            else // The mouse is not on top of the thumb
                m_MouseDownOnThumb = false;

            // Refresh the scrollbar value
            if (m_MouseDownOnArrow == false)
            {
                MouseMoveEvent move = new MouseMoveEvent();
                move.X = e.X;
                move.Y = e.Y;
                OnMouseMoved (new MouseMoveEventArgs(move));
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Handles when the <see cref="IGUIManager.IsEnabled"/> property changes.
 /// </summary>
 /// <param name="isEnabled">True if the <see cref="IGUIManager"/> has become enabled; otherwise false.</param>
 protected virtual void OnEnabledChanged(bool isEnabled)
 {
     if (!isEnabled)
     {
         // If we had a control under the cursor, get rid of it
         if (_underCursor != null)
         {
             var mme = new MouseMoveEvent { X = (int)CursorPosition.X, Y = (int)CursorPosition.Y };
             var mmeArgs = new MouseMoveEventArgs(mme);
             _underCursor.SendMouseLeaveEvent(mmeArgs);
         }
     }
 }
Ejemplo n.º 10
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Construct the mouse move arguments from a mouse move event
 /// </summary>
 /// <param name="e">Mouse move event</param>
 ////////////////////////////////////////////////////////////
 public MouseMoveEventArgs(MouseMoveEvent e)
 {
     X = e.X;
     Y = e.Y;
 }