Esempio n. 1
0
 /// <summary>
 /// Sets the scale for top or bottom handle
 /// </summary>
 /// <param name="handle"></param>
 /// <param name="scale"></param>
 private void SetScale(ScaleHandle handle, double scale)
 {
     scale           = (scale > MAX_SCALE) ? MAX_SCALE : scale;
     scale           = (scale < MIN_SCALE) ? MIN_SCALE : scale;
     handle.Position = Scale2Position(scale);
     handle.Scale    = scale;
     Scale2TextBox(handle);
 }
Esempio n. 2
0
        private void Awake()
        {
            camera = Camera.main;

            m_Target = transform;

            m_PositionHandle = new PositionHandle(this);
            m_RotationHandle = new RotationHandle(this);
            m_ScaleHandle    = new ScaleHandle(this);
            m_CurrentHandle  = m_PositionHandle;
        }
Esempio n. 3
0
 /// <summary>
 /// Shows current scale at the textbox
 /// </summary>
 /// <param name="handle"></param>
 private void Scale2TextBox(ScaleHandle handle)
 {
     if (handle.Type == HandleType.Top)
     {
         txtMaxScale.Text = String.Format("{0:F1}", _topHandle.Scale);
         txtMaxScale.Refresh();
     }
     if (handle.Type == HandleType.Bottom)
     {
         txtMinScale.Text = String.Format("{0:F1}", _bottomHandle.Scale);
         txtMinScale.Refresh();
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Draws the top handle
        /// </summary>
        /// <param name="g">Graphics object to draw upon</param>
        /// <param name="handle">A handle to draw.</param>
        private void DrawHandle(Graphics g, ScaleHandle handle)
        {
            // -------------------------------------------------
            // drawing top handle
            // -------------------------------------------------
            PointF[] points = new PointF[4];

            RectangleF r = new RectangleF();

            r.X      = BAND_OFFSET_X + BAND_WIDTH + 5;
            r.Y      = handle.Position;
            r.Width  = HANDLE_WIDTH;
            r.Height = HANDLE_HEIGHT;

            if (handle.Type == HandleType.Top)
            {
                points[0].X = 0.0f; points[0].Y = r.Height;
                points[1].X = r.Width / 3.0f; points[1].Y = 0.0f;
                points[2].X = r.Width; points[2].Y = 0.0f;
                points[3].X = r.Width; points[3].Y = r.Height;
                r.Y        -= (int)r.Height;
            }
            else
            {
                points[0].X = 0.0f; points[0].Y = 0.0f;
                points[1].X = r.Width; points[1].Y = 0.0f;
                points[2].X = r.Width; points[2].Y = r.Height;
                points[3].X = 1.0f / 3.0f * r.Width; points[3].Y = r.Height;
            }

            Matrix mtx = new Matrix();

            mtx.Translate(BAND_OFFSET_X + BAND_WIDTH + 5, r.Y);
            g.Transform = mtx;

            Color color     = handle.Selected ? _colorSelection : _colorOutline;
            Color colorFill = handle.Selected ? Color.FromKnownColor(KnownColor.Control) : Color.FromKnownColor(KnownColor.ControlLight);

            float width = handle.Selected ? 1.0f : 1.0f;

            g.FillPolygon(new SolidBrush(colorFill), points);
            g.DrawPolygon(new Pen(color, width), points);
            g.ResetTransform();

            // storing the rectangle
            handle.Rectangle = r;
        }
Esempio n. 5
0
        /// <summary>
        /// Start the dragging operation in case user has clicked a handle
        /// </summary>
        /// <param name="e"></param>
        protected override void  OnMouseDown(MouseEventArgs e)
        {
            ScaleHandle handle;

            for (int i = 0; i < 2; i++)
            {
                handle = (i == 0) ? _topHandle : _bottomHandle;
                RectangleF rect = handle.Rectangle;

                if (e.X >= rect.X && e.X <= rect.X + rect.Width &&
                    e.Y >= rect.Y && e.Y <= rect.Y + rect.Height)
                {
                    _draggingIsPerformed = true;
                    _draggedHandle       = (i == 0) ? _topHandle : _bottomHandle;
                    _draggingInitY       = e.Y;
                }
            }
        }
Esempio n. 6
0
        private void Awake()
        {
            if (Camera == null)
            {
                Camera = Camera.main;
            }

            if (Run.Instance == null)
            {
                GameObject runGO = new GameObject();
                runGO.name = "Run";
                runGO.AddComponent <Run>();
            }
            RuntimeTools.Current = RuntimeTool.View;
            GameObject positionHandle = new GameObject();

            positionHandle.name = "PositionHandle";
            positionHandle.transform.SetParent(transform, false);
            m_positionHandle = positionHandle.AddComponent <PositionHandle>();
            positionHandle.SetActive(false);

            GameObject rotationHandle = new GameObject();

            rotationHandle.name = "RotationHandle";
            rotationHandle.transform.SetParent(transform, false);
            m_rotationHandle = rotationHandle.AddComponent <RotationHandle>();
            rotationHandle.SetActive(false);

            GameObject scaleHandle = new GameObject();

            scaleHandle.name = "ScaleHandle";
            scaleHandle.transform.SetParent(transform, false);
            m_scaleHandle = scaleHandle.AddComponent <ScaleHandle>();
            scaleHandle.SetActive(false);

            RuntimeSelection.SelectionChanged    += OnRuntimeSelectionChanged;
            RuntimeTools.ToolChanged             += OnRuntimeToolChanged;
            RuntimeTools.CameraEulerChanged      += OnCameraEulerChanged;
            UnityEditorToolsListener.ToolChanged += OnUnityEditorToolChanged;
            RuntimeTools.Current = RuntimeTool.Move;

            Camera.fieldOfView = 60;
            OnProjectionChanged();
        }