示例#1
0
 /// <summary>
 /// Called before the ManipulationStarted event occurs.
 /// </summary>
 /// <param name="e">
 /// Event data for the event.
 /// </param>
 protected override void OnManipulationStarted(ManipulationStartedRoutedEventArgs e)
 {
     base.OnManipulationStarted(e);
     this.touchPan = new PanManipulator(this);
     this.touchPan.Started(new ManipulationEventArgs(e.Position.ToScreenPoint()));
     this.touchZoom = new ZoomManipulator(this);
     this.touchZoom.Started(new ManipulationEventArgs(e.Position.ToScreenPoint()));
     this.touchDownPoint = e.Position;
     e.Handled           = true;
 }
示例#2
0
        public void Init(Timeline timeline, PanManipulator panManipulator, ZoomManipulator zoomManipulator)
        {
            m_TimelineWidget = new TimelineWidget();

            m_PanManipulator  = panManipulator;
            m_ZoomManipulator = zoomManipulator;
            m_TimeArea        = timeline.m_TimelineScrollableArea;

            m_IMGUIContainer = new IMGUIContainer(() =>
            {
                GUILayout.Space(0);
                var lastRect = GUILayoutUtility.GetLastRect();
                Rect rt      = GUILayoutUtility.GetRect(lastRect.width, 22);

                GUI.BeginGroup(rt);

                Rect rect = new Rect(0, 0, rt.width, rt.height);

                if (rect.width > 0 && rect.height > 0)
                {
                    if (!FloatComparer.s_ComparerWithDefaultTolerance.Equals(m_DrawInfo.layout.startTime, m_TimelineWidget.RangeStart) ||
                        !FloatComparer.s_ComparerWithDefaultTolerance.Equals(m_DrawInfo.layout.Duration, m_TimelineWidget.RangeWidth))
                    {
                        m_DrawInfo.layout.startTime = m_TimelineWidget.RangeStart;
                        m_DrawInfo.layout.endTime   = m_TimelineWidget.RangeEnd;
                    }
                    else
                    {
                        DrawRuler(m_IMGUIContainer.layout, m_SampleRate, timeline.TimelineUnits);
                    }

                    ForwardEvents(rect);
                }

                GUI.EndGroup();
            });

            Add(m_IMGUIContainer);

            m_TickHandler = new TickHandler();
            float[] modulos =
            {
                0.0000001f, 0.0000005f, 0.000001f, 0.000005f, 0.00001f, 0.00005f, 0.0001f, 0.0005f,
                0.001f,         0.005f,     0.01f,     0.05f,     0.1f,     0.5f,       1,       5,10, 50, 100, 500,
                1000,             5000,     10000,     50000,   100000,   500000, 1000000, 5000000, 10000000
            };
            m_TickHandler.SetTickModulos(modulos);
        }
示例#3
0
 /// <summary>
 /// Called before the ManipulationStarted event occurs.
 /// </summary>
 /// <param name="e">
 /// Event data for the event.
 /// </param>
 protected override void OnManipulationStarted(ManipulationStartedRoutedEventArgs e)
 {
     base.OnManipulationStarted(e);
     this.touchPan = new PanManipulator(this);
     this.touchPan.Started(new ManipulationEventArgs(e.Position.ToScreenPoint()));
     this.touchZoom = new ZoomManipulator(this);
     this.touchZoom.Started(new ManipulationEventArgs(e.Position.ToScreenPoint()));
     this.touchDownPoint = e.Position;
     e.Handled = true;
 }
示例#4
0
        public void LoadTemplate(VisualElement parentElement)
        {
            UIElements.UIElementsUtils.CloneTemplateInto(k_Template, this);
            UIElements.UIElementsUtils.ApplyStyleSheet(k_Stylesheet, this);
            AddToClassList("flexGrowClass");
            Button button = parentElement.Q <Button>(classes: "viewMode");

            button.clickable = null;
            var manipulator = new ContextualMenuManipulator(ViewToggleMenu);

            manipulator.activators.Add(new ManipulatorActivationFilter {
                button = MouseButton.LeftMouse
            });
            button.AddManipulator(manipulator);

            m_PreviewWarning = parentElement.Q <Image>("warningImage");
            m_PreviewWarning.style.display = DisplayStyle.None;
            m_PreviewWarning.tooltip       = "Debugging using the Asset Builder requires setting a Preview Target before entering Play Mode";

            var previewTargetSelector = parentElement.Q <PreviewSelector>();

            previewTargetSelector.RegisterValueChangedCallback(OnPreviewTargetSelectorChanged);
            PreviewDisposed      += () => previewTargetSelector.SetValueWithoutNotify(null);
            PreviewTargetChanged += (newTarget) => previewTargetSelector.SetValueWithoutNotify(newTarget);

            ConnectToPlayControls(parentElement.Q <PlayControls>());

            m_TimelineWorkArea = this.Q <VisualElement>(k_TimelineWorkAreaName);

            m_TimelineScrollableArea = this.Q <VisualElement>(k_ScrollableTimeAreaName);
            m_TimelineScrollableArea.RegisterCallback <GeometryChangedEvent>(OnGeometryChanged);

            ZoomManipulator zoomManipulator = new ZoomManipulator(m_TimelineScrollableArea);

            zoomManipulator.ScaleChangeEvent += OnTimelineMouseScroll;
            var panManipulator = new PanManipulator(m_TimelineScrollableArea);

            panManipulator.HorizontalOnly = true;
            panManipulator.Panned        += OnTimelinePanned;

            m_ScrollViewContainer = this.Q <VisualElement>("trackScrollViewContainer");
            m_ScrollViewContainer.AddManipulator(panManipulator);
            m_ScrollViewContainer.AddManipulator(zoomManipulator);
            m_ScrollViewContainer.RegisterCallback <GeometryChangedEvent>(OnGeometryChanged);

            m_ActiveTimeField           = parentElement.Q <FloatField>("frameField");
            m_ActiveTimeField.isDelayed = true;
            m_ActiveTimeField.RegisterValueChangedCallback(OnActiveTimeFieldValueChanged);

            UpdateTimeRange();

            m_GutterTracks = this.Q <VisualElement>(classes: "gutter");
            ZoomManipulator gutterZoom = new ZoomManipulator(m_GutterTracks);

            gutterZoom.ScaleChangeEvent += OnTimelineMouseScroll;
            m_GutterTracks.AddManipulator(gutterZoom);
            var gutterPan = new PanManipulator(m_GutterTracks);

            gutterPan.HorizontalOnly = true;
            gutterPan.Panned        += OnTimelinePanned;
            m_GutterTracks.AddManipulator(gutterPan);

            m_Tracks        = m_TimelineScrollableArea.Q <VisualElement>("tracks");
            m_TrackElements = new List <Track>();
            CreateBuiltInTracks();

            if (!EditorApplication.isPlaying)
            {
                SetActiveTime(0f);
            }

            m_ClipArea = new VisualElement();
            m_ClipArea.AddToClassList("clipArea");

            ScrollView sv = m_ScrollViewContainer.Q <ScrollView>();

            sv.Insert(0, m_ClipArea);
            m_TimelineWorkArea.Add(ActiveTick);
            m_TimelineWorkArea.Add(ActiveDebugTick);

            m_ClipLengthBar = this.Q <VisualElement>("clipLength");

            m_TimeRuler = this.Q <TimeRuler>();
            m_TimeRuler.Init(this, panManipulator, zoomManipulator);
            m_TimeRuler.AddManipulator(new PlayheadManipulator(this));

            string storedViewMode = EditorPrefs.GetString(k_TimelineUnitsPreferenceKey);

            if (storedViewMode == string.Empty)
            {
                TimelineUnits = TimelineViewMode.frames;
            }
            else
            {
                int intVal;
                if (int.TryParse(storedViewMode, out intVal))
                {
                    TimelineUnits = (TimelineViewMode)intVal;
                }
                else
                {
                    TimelineUnits = TimelineViewMode.frames;
                }
            }

            Undo.undoRedoPerformed += OnUndoRedoPerformed;

            focusable = true;

            RegisterCallback <KeyDownEvent>(OnKeyDownEvent);
            RegisterCallback <GeometryChangedEvent>(OnGeometryChanged);
        }
示例#5
0
        /// <summary>
        /// Called when the <see cref="E:System.Windows.UIElement.ManipulationStarted"/> event occurs.
        /// </summary>
        /// <param name="e">
        /// The data for the event.
        /// </param>
        protected override void OnManipulationStarted(ManipulationStartedEventArgs e)
        {
            base.OnManipulationStarted(e);
            if (e.Handled)
            {
                return;
            }

            this.touchPan = new PanManipulator(this);
            this.touchPan.Started(new ManipulationEventArgs(e.ManipulationOrigin.ToScreenPoint()));
            this.touchZoom = new ZoomManipulator(this);
            this.touchZoom.Started(new ManipulationEventArgs(e.ManipulationOrigin.ToScreenPoint()));
            this.touchDownPoint = e.ManipulationOrigin;
            this.lastManipulationScale = new Vector(1, 1);
            e.Handled = true;
        }