Example #1
0
 public TangentHandle(CurveKey key)
 {
     Key              = key;
     Scale            = ScaleMode.StretchToFill;
     TintColor        = TangentColor;
     WantsMouseEvents = true;
 }
Example #2
0
 public void RebuildKeys()
 {
     Controls.Clear();
     Keyframe[] keys = Curve.keys;
     if (keys != null && keys.Length > 0)
     {
         for (int i = 0; i < keys.Length; i++)
         {
             var k = new CurveKey(this, i)
             {
                 ContextMenu = CurveKeyContextMenu.Instance
             };
             Controls.Add(k);
         }
     }
 }
Example #3
0
        internal void KeyDrag(CurveKey key, Vector2 delta, bool snap)
        {
            if (Selection.Contains(key))
            {
                if (!_DragStarted)
                {
                    foreach (var item in Selection)
                    {
                        item.StartDrag.x = item.X;
                        item.StartDrag.y = item.Y;
                    }
                    _DeltaDrag   = Vector3.zero;
                    _DragStarted = true;
                }
                _DeltaDrag += delta;

                delta = _DeltaDrag;
                if (snap)
                {
                    float x    = key.StartDrag.x + delta.x;
                    float time = GetSnappedValue(key.Track.GetTime(x, true), _TimeLine.TimeBar.SmallStep);
                    x       = key.Track.GetX(time, true);
                    delta.x = x - key.StartDrag.x - (key.Width * 0.5f);

                    float y     = key.StartDrag.y + delta.y;
                    float value = GetSnappedValue(key.Track.GetValue(y, true), _Grid.SmallStep);
                    y       = key.Track.GetY(value, true);
                    delta.y = y - key.StartDrag.y - (key.Height * 0.5f);
                }
                foreach (var item in Selection)
                {
                    item.X = item.StartDrag.x + delta.x;
                    item.Y = item.StartDrag.y + delta.y;
                }

                OnChanged();
            }
            else
            {
                Selection.Select(key);
            }
        }
Example #4
0
 public CurveKeyDragThumb(CurveKey key)
 {
     this._Key = key;
 }
Example #5
0
 public TangentHandleLeft(CurveKey key)
     : base(key)
 {
 }
Example #6
0
 public TangentHandleRight(CurveKey key)
     : base(key)
 {
 }
Example #7
0
        void _MnuRightTangent_Linear_Click(object sender, System.EventArgs e)
        {
            CurveKey key = Owner as CurveKey;

            key.Track.View.Editor.SetRightLinear();
        }
Example #8
0
        void _MnuBothTangent_Constant_Click(object sender, System.EventArgs e)
        {
            CurveKey key = Owner as CurveKey;

            key.Track.View.Editor.SetBothConstant();
        }
Example #9
0
        void _MnuBroken_Click(object sender, System.EventArgs e)
        {
            CurveKey key = Owner as CurveKey;

            key.Track.View.Editor.SetBroken();
        }
Example #10
0
        void _MnuLeftTangent_Free_Click(object sender, System.EventArgs e)
        {
            CurveKey key = Owner as CurveKey;

            key.Track.View.Editor.SetLeftEditable();
        }
Example #11
0
        void _MnuFreeSmooth_Click(object sender, System.EventArgs e)
        {
            CurveKey key = Owner as CurveKey;

            key.Track.View.Editor.SetEditable();
        }
Example #12
0
        void _MnuAuto_Click(object sender, System.EventArgs e)
        {
            CurveKey key = Owner as CurveKey;

            key.Track.View.Editor.SetSmooth();
        }
Example #13
0
        void _MnuDelete_Click(object sender, System.EventArgs e)
        {
            CurveKey key = Owner as CurveKey;

            key.Track.View.Editor.RemoveSelection();
        }
Example #14
0
        protected override void BeginShow()
        {
            CurveKey key = Owner as CurveKey;

            var state = key.Track.View.Editor.GetSelectionState();

            string deleteName = null;

            if (state.SelectionCount > 1)
            {
                deleteName = "Delete Keys";
            }
            else
            {
                deleteName = "Delete key";
            }

            if (!deleteName.Equals(_MnuDelete.Name))
            {
                _MnuDelete.Name = deleteName;
                OnChanged();
            }

            if (state.SelectionCount > 0)
            {
                _MnuDelete.IsEnabled     = true;
                _MnuAuto.IsEnabled       = true; _MnuAuto.IsChecked = state.Auto;
                _MnuFreeSmooth.IsEnabled = true; _MnuFreeSmooth.IsChecked = state.FreeSmooth;
                _MnuFlat.IsEnabled       = true; _MnuFlat.IsChecked = state.Flat;
                _MnuBroken.IsEnabled     = true; _MnuBroken.IsChecked = state.Broken;

                _MnuLeftTangent.IsEnabled          = true;
                _MnuLeftTangent_Free.IsChecked     = state.LeftFree;
                _MnuLeftTangent_Linear.IsChecked   = state.LeftLinear;
                _MnuLeftTangent_Constant.IsChecked = state.LeftConstant;

                _MnuRightTangent.IsEnabled          = true;
                _MnuRightTangent_Free.IsChecked     = state.RightFree;
                _MnuRightTangent_Linear.IsChecked   = state.RightLinear;
                _MnuRightTangent_Constant.IsChecked = state.RightConstant;

                _MnuBothTangent.IsEnabled          = true;
                _MnuBothTangent_Free.IsChecked     = state.LeftFree && state.RightFree;
                _MnuBothTangent_Linear.IsChecked   = state.LeftLinear && state.RightLinear;
                _MnuBothTangent_Constant.IsChecked = state.LeftConstant && state.RightConstant;
            }
            else
            {
                _MnuDelete.IsEnabled     = false;
                _MnuAuto.IsEnabled       = false; _MnuAuto.IsChecked = false;
                _MnuFreeSmooth.IsEnabled = false; _MnuFreeSmooth.IsChecked = false;
                _MnuFlat.IsEnabled       = false; _MnuFlat.IsChecked = false;
                _MnuBroken.IsEnabled     = false; _MnuBroken.IsChecked = false;

                _MnuLeftTangent.IsEnabled          = false;
                _MnuLeftTangent_Free.IsChecked     = false;
                _MnuLeftTangent_Linear.IsChecked   = false;
                _MnuLeftTangent_Constant.IsChecked = false;

                _MnuRightTangent.IsEnabled          = false;
                _MnuRightTangent_Free.IsChecked     = false;
                _MnuRightTangent_Linear.IsChecked   = false;
                _MnuRightTangent_Constant.IsChecked = false;

                _MnuBothTangent.IsEnabled          = false;
                _MnuBothTangent_Free.IsChecked     = false;
                _MnuBothTangent_Linear.IsChecked   = false;
                _MnuBothTangent_Constant.IsChecked = false;
            }

            base.BeginShow();
        }
Example #15
0
 public CurveKeyProperties(CurveKey key)
     : base(key)
 {
 }