Esempio n. 1
0
        private void OnMotionNotifyEvent(object sender, MotionNotifyEventArgs a)
        {
            Gdk.EventMotion ev = a.Event;

            //if ((ev.State & Gdk.ModifierType.Button1Mask) != 0) {
            if (button1Pressed)
            {
                mouseMode        = GLWidget.MouseOpMode.Drag;
                GdkWindow.Cursor = cursorDrag;
            }
            else
            {
                mouseMode        = GLWidget.MouseOpMode.None;
                GdkWindow.Cursor = cursorCross;
            }

            /*
             * testX = (float) (ev.X - width / 2f) / width *2f ;
             * testY = (float) -(ev.Y - height/ 2f) / height*2f ;
             * Console.WriteLine("state: "+ev.State.ToString());
             */

            switch (mouseMode)
            {
            case MouseOpMode.Drag:

                int    ix, iy;
                double x, y;

                Gdk.ModifierType m;

                // Find the current mouse X and Y positions
                if (ev.IsHint)
                {
                    ev.Window.GetPointer(out ix, out iy, out m);
                    x = (double)ix;
                    y = (double)iy;
                }
                else
                {
                    x = ev.X;
                    y = ev.Y;
                }

                cameraAngleX += (float)(x - beginX);
                cameraAngleY += (float)(y - beginY);
                // Reset the "old" X and Y positions
                beginX = x;
                beginY = y;
                break;
            }
            mX = ev.X;
            mY = ev.Y;
            Redraw();
        }
Esempio n. 2
0
        private void OnMotionNotifyEvent(object sender, MotionNotifyEventArgs a)
        {
            Gdk.EventMotion ev = a.Event;

            //if ((ev.State & Gdk.ModifierType.Button1Mask) != 0) {
            if (button1Pressed) {
                mouseMode = GLWidget.MouseOpMode.Drag;
                GdkWindow.Cursor = cursorDrag;
            } else {
                mouseMode = GLWidget.MouseOpMode.None;
                GdkWindow.Cursor = cursorCross;
            }

            /*
            testX = (float) (ev.X - width / 2f) / width *2f ;
            testY = (float) -(ev.Y - height/ 2f) / height*2f ;
            Console.WriteLine("state: "+ev.State.ToString());
            */

            switch (mouseMode) {
                case MouseOpMode.Drag:

                    int ix, iy;
                    double x, y;

                    Gdk.ModifierType m;

                    // Find the current mouse X and Y positions
                    if (ev.IsHint) {
                        ev.Window.GetPointer (out ix, out iy, out m);
                        x = (double)ix;
                        y = (double)iy;
                    } else {
                        x = ev.X;
                        y = ev.Y;
                    }

                    cameraAngleX += (float)(x - beginX);
                    cameraAngleY += (float)(y - beginY);
                    // Reset the "old" X and Y positions
                    beginX = x;
                    beginY = y;
                    break;
            }
            mX = ev.X;
            mY = ev.Y;
            Redraw ();
        }