Example #1
0
 public override void CursorPressed(Mogre.Vector2 cursorPos)
 {
     if (listener != null && IsCursorOver(element, cursorPos, 3f))
     {
         listener.labelHit(this);
     }
 }
Example #2
0
        public override void ProcessParameters(Mogre.NameValuePairList parameters)
        {
            Mogre.NameValuePairList.Iterator ni;

            if ((ni = parameters.Find("Name")) != parameters.End())
            {
                this.name = ni.Value;
            }

            if ((ni = parameters.Find("Position")) != parameters.End())
            {
                this.position = Mogre.StringConverter.ParseVector3(ni.Value);
            }

            if ((ni = parameters.Find("Orientation")) != parameters.End())
            {
                this.orientation = Mogre.StringConverter.ParseQuaternion(ni.Value);
            }

            if ((ni = parameters.Find("ClipDistance")) != parameters.End())
            {
                this.clipDistance = MogreX.StringConverter.ParseVector2(ni.Value);
            }

            if ((ni = parameters.Find("FOV")) != parameters.End())
            {
                this.fov = Mogre.StringConverter.ParseReal(ni.Value);
            }
        }
Example #3
0
 public override void CursorPressed(Mogre.Vector2 cursorPos)
 {
     if (IsCursorOver(element, cursorPos, 4))
     {
         SetState(ButtonState.BS_DOWN);
     }
 }
Example #4
0
 public override void CursorPressed(Mogre.Vector2 cursorPos)
 {
     if (isCursorOver && listener != null)
     {
         Toggle();
     }
 }
Example #5
0
        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            base.OnMouseWheel(e);

            //if (!IsFocused)
            //    Focus();

            Mogre.Vector2 pos = new Mogre.Vector2((float)e.GetPosition(this).X, (float)e.GetPosition(this).Y);
            MogitorsRoot.Instance.OnMouseWheel(pos, e.Delta, e.MouseDevice);
        }
Example #6
0
        public void OnMouseMiddleDown(Mogre.Vector2 point, MouseDevice mouseDevice)
        {
            ViewportEditor vp = GetViewportEditorFromPoint(point);

            if (vp != null)
            {
                ActiveViewport = vp;

                Mogre.Vector4 rect = new Mogre.Vector4();
                ActiveViewport.GetRect(ref rect);
                ActiveViewport.OnMouseMiddleDown(point - new Mogre.Vector2(rect.x, rect.y), mouseDevice);
            }
        }
Example #7
0
        public void OnMouseMiddleUp(Mogre.Vector2 point, MouseDevice mouseDevice)
        {
            if (ActiveViewport == null)
            {
                return;
            }

            Mogre.Vector4 rect = new Mogre.Vector4();
            ActiveViewport.GetRect(ref rect);
            if (PointIsInRect(point, rect))
            {
                ActiveViewport.OnMouseMiddleUp(point - new Mogre.Vector2(rect.x, rect.y), mouseDevice);
            }
        }
Example #8
0
 public override void CursorReleased(Mogre.Vector2 cursorPos)
 {
     if (state == ButtonState.BS_DOWN)
     {
         SetState(ButtonState.BS_OVER);
         if (listener != null)
         {
             listener.buttonHit(this);
         }
         if (OnClick != null)
         {
             OnClick(this);
         }
     }
 }
Example #9
0
        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            base.OnMouseUp(e);

            //if (!IsFocused)
            //    Focus();

            Mogre.Vector2 pos = new Mogre.Vector2((float)e.GetPosition(this).X, (float)e.GetPosition(this).Y);

            if (e.ChangedButton == MouseButton.Left)
                MogitorsRoot.Instance.OnMouseLeftUp(pos, e.MouseDevice);
            else if (e.ChangedButton == MouseButton.Right)
                MogitorsRoot.Instance.OnMouseRightUp(pos, e.MouseDevice);
            else if (e.ChangedButton == MouseButton.Middle)
                MogitorsRoot.Instance.OnMouseMiddleUp(pos, e.MouseDevice);
        }
Example #10
0
 /** Todo
  */
 public Mogre.Vector2[] GetControlPoints()
 {
     try
     {
         int             bufSize = DynamicAttributeCurved_GetControlPointsCount(nativePointer);
         Mogre.Vector2[] floats  = new Mogre.Vector2[bufSize];
         DynamicAttributeCurved_GetControlPoints(nativePointer, floats, bufSize);
         return(floats);
     }
     catch (Exception e) { if (printDebug)
                           {
                               Console.WriteLine(e.Message + "@" + e.Source);
                           }
     }
     return(null);
 }
Example #11
0
 public override void CursorMoved(Mogre.Vector2 cursorPos)
 {
     if (IsCursorOver(element, cursorPos, 4f))
     {
         if (state == ButtonState.BS_UP)
         {
             SetState(ButtonState.BS_OVER);
         }
     }
     else
     {
         if (state != ButtonState.BS_UP)
         {
             SetState(ButtonState.BS_UP);
         }
     }
 }
        public void OnDragDrop(IDataObject data, Point pt)
        {
            Mogre.Vector4 drect = new Mogre.Vector4();
            ActiveViewport.GetRect(ref drect);
            Mogre.Vector2 dropPos = new Mogre.Vector2((float)(pt.X - drect.x) / drect.z, (float)(pt.Y - drect.y) / drect.w);

            DragData dragData = data.GetData(typeof(DragData)) as DragData;
            foreach (KeyValuePair<object, IDragDropHandler> handler in this.dragDropHandlers)
            {
                if (handler.Key == dragData.Source)
                {
                    handler.Value.OnDragDrop(dragData, ActiveViewport.Handle as Mogre.Viewport, dropPos);
                    break;
                }
            }
            this.activeDragData = null;
        }
        public void OnDragDrop(IDataObject data, Point pt)
        {
            Mogre.Vector4 drect = new Mogre.Vector4();
            ActiveViewport.GetRect(ref drect);
            Mogre.Vector2 dropPos = new Mogre.Vector2((float)(pt.X - drect.x) / drect.z, (float)(pt.Y - drect.y) / drect.w);

            DragData dragData = data.GetData(typeof(DragData)) as DragData;

            foreach (KeyValuePair <object, IDragDropHandler> handler in this.dragDropHandlers)
            {
                if (handler.Key == dragData.Source)
                {
                    handler.Value.OnDragDrop(dragData, ActiveViewport.Handle as Mogre.Viewport, dropPos);
                    break;
                }
            }
            this.activeDragData = null;
        }
Example #14
0
        private ViewportEditor GetViewportEditorFromPoint(Mogre.Vector2 point)
        {
            Mogre.Vector4 rect = new Mogre.Vector4();

            ViewportEditor vp     = null;
            int            zOrder = -1000;

            foreach (var it in this.namesByType[(int)EditorType.Viewport])
            {
                int order = (it.Value as ViewportEditor).GetRect(ref rect);
                if (PointIsInRect(point, rect) && (order > zOrder))
                {
                    zOrder = order;
                    vp     = it.Value as ViewportEditor;
                }
            }
            return(vp);
        }
Example #15
0
 public override void CursorMoved(Mogre.Vector2 cursorPos)
 {
     if (IsCursorOver(squareElement, cursorPos, 5f))
     {
         if (!isCursorOver)
         {
             isCursorOver = true;
             squareElement.MaterialName       = ("SdkTrays/MiniTextBox/Over");
             squareElement.BorderMaterialName = ("SdkTrays/MiniTextBox/Over");
         }
     }
     else
     {
         if (isCursorOver)
         {
             isCursorOver = false;
             squareElement.MaterialName       = ("SdkTrays/MiniTextBox");
             squareElement.BorderMaterialName = ("SdkTrays/MiniTextBox");
         }
     }
 }
        public bool OnDragOver(IDataObject data, Point pt)
        {
            Mogre.Vector4  rect = new Mogre.Vector4();
            ViewportEditor vp   = null;

            int ZOrder = -1000;

            foreach (KeyValuePair <string, BaseEditor> it in GetObjectsByType(EditorType.Viewport))
            {
                int order = ((it.Value) as ViewportEditor).GetRect(ref rect);
                if ((rect.x <= pt.X) && (rect.y <= pt.Y) && ((rect.y + rect.w) >= pt.Y) && (order > ZOrder))
                {
                    ZOrder = order;
                    vp     = (it.Value) as ViewportEditor;
                }
            }

            if (vp != null)
            {
                ActiveViewport = vp;
                ActiveViewport.GetRect(ref rect);

                DragData dragData = data.GetData(typeof(DragData)) as DragData;

                foreach (KeyValuePair <object, IDragDropHandler> handler in this.dragDropHandlers)
                {
                    if (handler.Key == dragData.Source)
                    {
                        Mogre.Vector2 point = new Mogre.Vector2((float)(pt.X - rect.x) / rect.z, (float)(pt.Y - rect.y) / rect.w);
                        return(handler.Value.OnDragOver(dragData, ActiveViewport.Handle as Mogre.Viewport, point));
                    }
                }
                return(true);
            }
            return(false);
        }
Example #17
0
        public void OnMouseWheel(Mogre.Vector2 point, float delta, MouseDevice mouseDevice)
        {
            if (ActiveViewport == null)
            {
                return;
            }

            Mogre.Vector4 rect = new Mogre.Vector4();
            ActiveViewport.GetRect(ref rect);

            if (this.activeDragData != null)
            {
                foreach (KeyValuePair <object, IDragDropHandler> handler in this.dragDropHandlers)
                {
                    if (handler.Key == this.activeDragData.Source)
                    {
                        handler.Value.OnDragWheel(this.activeDragData, ActiveViewport.Handle as Mogre.Viewport, delta);
                        return;
                    }
                }
            }

            ActiveViewport.OnMouseWheel(point - new Mogre.Vector2(rect.x, rect.y), delta, mouseDevice);
        }
Example #18
0
        bool MogitorsRoot.IDragDropHandler.OnDragOver(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position)
        {
            if (dragData.Object == null)
            {
                return(false);
            }

            Mogre.Ray mouseRay = vp.Camera.GetCameraToViewportRay(position.x, position.y);

            EntityEditor entity = dragData.Object as EntityEditor;

            bool hitFound = false;

            if (!hitFound)
            {
                if (entity.Position.x == 999999 && entity.Position.y == 999999 && entity.Position.z == 999999)
                {
                    entity.Position = mouseRay.Origin + mouseRay.Direction * 40.0f;
                }
                else
                {
                    entity.Position = MogitorsRoot.Instance.GetGizmoIntersectCameraPlane(entity, mouseRay);
                }
            }

            return(true);
        }
        public bool OnDragOver(IDataObject data, Point pt)
        {
            Mogre.Vector4 rect = new Mogre.Vector4();
            ViewportEditor vp = null;

            int ZOrder = -1000;
            foreach (KeyValuePair<string, BaseEditor> it in GetObjectsByType(EditorType.Viewport))
            {
                int order = ((it.Value) as ViewportEditor).GetRect(ref rect);
                if ((rect.x <= pt.X) && (rect.y <= pt.Y) && ((rect.y + rect.w) >= pt.Y) && (order > ZOrder))
                {
                    ZOrder = order;
                    vp = (it.Value) as ViewportEditor;
                }
            }

            if (vp != null)
            {
                ActiveViewport = vp;
                ActiveViewport.GetRect(ref rect);

                DragData dragData = data.GetData(typeof(DragData)) as DragData;

                foreach (KeyValuePair<object, IDragDropHandler> handler in this.dragDropHandlers)
                {
                    if (handler.Key == dragData.Source)
                    {
                        Mogre.Vector2 point = new Mogre.Vector2((float)(pt.X - rect.x) / rect.z, (float)(pt.Y - rect.y) / rect.w);
                        return handler.Value.OnDragOver(dragData, ActiveViewport.Handle as Mogre.Viewport, point);
                    }
                }
                return true;
            }
            return false;
        }
Example #20
0
 private static bool PointIsInRect(Mogre.Vector2 point, Mogre.Vector4 rect)
 {
     return((rect.x <= point.x) && (rect.y <= point.y) && ((rect.x + rect.z) >= point.x) && ((rect.y + rect.w) >= point.y));
 }
Example #21
0
        public override void ProcessParameters(Mogre.NameValuePairList parameters)
        {
            Mogre.NameValuePairList.Iterator ni;

            if ((ni = parameters.Find("Name")) != parameters.End())
                this.name = ni.Value;

            if ((ni = parameters.Find("Position")) != parameters.End())
                this.position = Mogre.StringConverter.ParseVector3(ni.Value);

            if ((ni = parameters.Find("Orientation")) != parameters.End())
                this.orientation = Mogre.StringConverter.ParseQuaternion(ni.Value);

            if ((ni = parameters.Find("ClipDistance")) != parameters.End())
                this.clipDistance = MogreX.StringConverter.ParseVector2(ni.Value);

            if ((ni = parameters.Find("FOV")) != parameters.End())
                this.fov = Mogre.StringConverter.ParseReal(ni.Value);
        }
Example #22
0
        void MogitorsRoot.IDragDropHandler.OnDragDrop(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position)
        {
            if (dragData.Object != null)
            {
                Mogre.NameValuePairList parameters = new Mogre.NameValuePairList();
                dragData.Object.GetObjectProperties(parameters);
                dragData.Object.Destroy(false);
                dragData.Object = null;

                dragData.Parameters["Position"] = parameters["Position"];

                MogitorsRoot.Instance.CreateEditorObject(null, dragData.ObjectType, dragData.Parameters, true, true);
            }

            dragData.Parameters.Clear();
            dragData.ObjectType = "";
            dragData.Object     = null;
        }
Example #23
0
        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            base.OnMouseUp(e);

            //if (!IsFocused)
            //    Focus();

            Mogre.Vector2 pos = new Mogre.Vector2((float)e.GetPosition(this).X, (float)e.GetPosition(this).Y);

            if (e.ChangedButton == MouseButton.Left)
                MogitorsRoot.Instance.OnMouseLeftUp(pos, e.MouseDevice);
            else if (e.ChangedButton == MouseButton.Right)
                MogitorsRoot.Instance.OnMouseRightUp(pos, e.MouseDevice);
            else if (e.ChangedButton == MouseButton.Middle)
                MogitorsRoot.Instance.OnMouseMiddleUp(pos, e.MouseDevice);
        }
Example #24
0
        public void SetMousePosition(Mogre.Vector2 position)
        {
            Point pos = TransformToScreen(new Point(position.x, position.y), this.renderViewControl);

            NativeMethods.SetCursorPos((int)pos.X, (int)pos.Y);
        }
Example #25
0
        bool MogitorsRoot.IDragDropHandler.OnDragOver(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position)
        {
            if (dragData.ObjectType == "")
            {
                return(false);
            }

            if (dragData.Object == null)
            {
                return(true);
            }

            Mogre.Ray mouseRay;
            mouseRay = vp.Camera.GetCameraToViewportRay(position.x, position.y);

            Mogre.Vector3 vPos = Mogre.Vector3.ZERO;
            PropertyInfo  prop = dragData.Object.GetType().GetProperty("Position");

            if (prop != null)
            {
                vPos = (Mogre.Vector3)prop.GetValue(dragData.Object, null);
            }

            if (vPos.x == 999999 && vPos.y == 999999 && vPos.z == 999999)
            {
                vPos = mouseRay.Origin + (mouseRay.Direction * 40.0f);
            }
            else
            {
                vPos = MogitorsRoot.Instance.GetGizmoIntersectCameraPlane(dragData.Object, mouseRay);
            }

            if (prop != null)
            {
                prop.SetValue(dragData.Object, vPos, null);
            }

            return(true);
        }
Example #26
0
        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            base.OnMouseWheel(e);

            //if (!IsFocused)
            //    Focus();

            Mogre.Vector2 pos = new Mogre.Vector2((float)e.GetPosition(this).X, (float)e.GetPosition(this).Y);
            MogitorsRoot.Instance.OnMouseWheel(pos, e.Delta, e.MouseDevice);
        }