예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AnimationPreview"/> class.
        /// </summary>
        /// <param name="useWidgets">if set to <c>true</c> use widgets.</param>
        public AnimationPreview(bool useWidgets)
            : base(useWidgets)
        {
            PlayAnimation         = true;
            PlayAnimationChanged += OnPlayAnimationChanged;

            // Playback Speed
            {
                var playbackSpeed      = ViewWidgetButtonMenu.AddButton("Playback Speed");
                var playbackSpeedValue = new FloatValueBox(-1, 90, 2, 70.0f, 0.0f, 10000.0f, 0.001f)
                {
                    Parent = playbackSpeed
                };
                playbackSpeedValue.ValueChanged     += () => PlaySpeed = playbackSpeedValue.Value;
                ViewWidgetButtonMenu.VisibleChanged += control => playbackSpeedValue.Value = PlaySpeed;
            }

            // Play/Pause widget
            {
                var playPauseWidget = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight);
                _playPauseButton = new ViewportWidgetButton(null, Editor.Instance.Icons.Pause64)
                {
                    TooltipText = "Animation playback play (F5) or pause (F6)",
                    Parent      = playPauseWidget,
                };
                _playPauseButton.Clicked += button => PlayAnimation = !PlayAnimation;
                playPauseWidget.Parent    = this;
            }

            // Enable shadows
            PreviewLight.ShadowsMode     = ShadowsCastingMode.All;
            PreviewLight.CascadeCount    = 2;
            PreviewLight.ShadowsDistance = 1000.0f;
            Task.ViewFlags |= ViewFlags.Shadows;
        }
예제 #2
0
        public Control Create(InputBox box, ref Rectangle bounds)
        {
            var value   = GetValue(box).EulerAngles;
            var control = new ContainerControl(bounds.X, bounds.Y, 22 * 3 - 2, bounds.Height)
            {
                ClipChildren = false,
                AutoFocus    = false,
                Parent       = box.Parent,
                Tag          = box,
            };
            var floatX = new FloatValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
            {
                Height = bounds.Height,
                Parent = control,
            };

            floatX.BoxValueChanged += OnQuaternionValueChanged;
            var floatY = new FloatValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
            {
                Height = bounds.Height,
                Parent = control,
            };

            floatY.BoxValueChanged += OnQuaternionValueChanged;
            var floatZ = new FloatValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
            {
                Height = bounds.Height,
                Parent = control,
            };

            floatZ.BoxValueChanged += OnQuaternionValueChanged;
            return(control);
        }
예제 #3
0
        private ContextMenu OnViewDropdownPopupCreate(ComboBox comboBox)
        {
            var menu = new ContextMenu();

            var showFileExtensionsButton = menu.AddButton("Show file extensions", () => View.ShowFileExtensions = !View.ShowFileExtensions);

            showFileExtensionsButton.Checked   = View.ShowFileExtensions;
            showFileExtensionsButton.AutoCheck = true;

            var viewScale  = menu.AddButton("View Scale");
            var scaleValue = new FloatValueBox(1, 75, 2, 50.0f, 0.3f, 3.0f, 0.01f);

            scaleValue.Parent        = viewScale;
            scaleValue.ValueChanged += () => View.ViewScale = scaleValue.Value;
            menu.VisibleChanged     += control => { scaleValue.Value = View.ViewScale; };

            var viewType = menu.AddChildMenu("View Type");

            viewType.ContextMenu.AddButton("Tiles", OnViewTypeButtonClicked).Tag = ContentViewType.Tiles;
            viewType.ContextMenu.AddButton("List", OnViewTypeButtonClicked).Tag  = ContentViewType.List;
            viewType.ContextMenu.VisibleChanged += control =>
            {
                if (!control.Visible)
                {
                    return;
                }
                foreach (var item in ((ContextMenu)control).Items)
                {
                    if (item is ContextMenuButton button)
                    {
                        button.Checked = View.ViewType == (ContentViewType)button.Tag;
                    }
                }
            };

            var filters = menu.AddChildMenu("Filters");

            for (int i = 0; i < _viewDropdown.Items.Count; i++)
            {
                var filterButton = filters.ContextMenu.AddButton(_viewDropdown.Items[i], OnFilterClicked);
                filterButton.Tag = i;
            }
            filters.ContextMenu.VisibleChanged += control =>
            {
                if (!control.Visible)
                {
                    return;
                }
                foreach (var item in ((ContextMenu)control).Items)
                {
                    if (item is ContextMenuButton filterButton)
                    {
                        filterButton.Checked = _viewDropdown.IsSelected(filterButton.Text);
                    }
                }
            };

            return(menu);
        }
예제 #4
0
파일: Tools.cs 프로젝트: kingland/FlaxAPI
            /// <inheritdoc />
            public override void OnSurfaceLoaded()
            {
                base.OnSurfaceLoaded();

                var   upperLeft      = GetBox(0).BottomLeft;
                var   upperRight     = GetBox(1).BottomRight;
                float gradientMargin = 20.0f;

                _gradient = new Gradient
                {
                    Node   = this,
                    Bounds = new Rectangle(upperLeft + new Vector2(gradientMargin, 10.0f), upperRight.X - upperLeft.X - gradientMargin * 2.0f, 40.0f),
                    Parent = this,
                };

                var controlsLevel = _gradient.Bottom + 4.0f + 20.0f + 40.0f;

                _labelValue = new Label(_gradient.Left, controlsLevel - 20.0f, 70.0f, 20.0f)
                {
                    Text = "Selected:",
                    VerticalAlignment   = TextAlignment.Center,
                    HorizontalAlignment = TextAlignment.Near,
                    Parent = this
                };

                _timeValue = new FloatValueBox(0.0f, _gradient.Left, controlsLevel, 100.0f, 0.0f, 1.0f, 0.001f)
                {
                    Parent = this
                };
                _timeValue.ValueChanged += OnTimeValueChanged;

                _colorValue = new ColorValueBox(Color.Black, _timeValue.Right + 4.0f, controlsLevel)
                {
                    Height = _timeValue.Height,
                    Parent = this
                };
                _colorValue.ValueChanged += OnColorValueChanged;

                _removeButton = new Button(_colorValue.Right + 4.0f, controlsLevel, 20, 20)
                {
                    Text        = "-",
                    TooltipText = "Remove selected gradient stop",
                    Parent      = this
                };
                _removeButton.Clicked += OnRemoveButtonClicked;

                _addButton = new Button(_gradient.Right - 20.0f, controlsLevel, 20, 20)
                {
                    Text        = "+",
                    TooltipText = "Add gradient stop",
                    Parent      = this
                };
                _addButton.Clicked += OnAddButtonClicked;

                UpdateStops();
            }
예제 #5
0
        /// <summary>
        /// Creates the default value editor control.
        /// </summary>
        private void CreateDefaultEditor()
        {
            if (_defaultValueEditor != null || Archetype.ValueIndex == -1)
            {
                return;
            }

            var   style  = Style.Current;
            float x      = X + Width + 8 + style.FontSmall.MeasureText(Archetype.Text).X;
            float y      = Y;
            float height = Height;

            switch (CurrentType)
            {
            case ConnectionType.Bool:
            {
                bool value   = (bool)ParentNode.Values[Archetype.ValueIndex];
                var  control = new CheckBox(x, y, value, height)
                {
                    Parent = Parent
                };
                control.StateChanged += OnCheckBoxChanged;
                _defaultValueEditor   = control;
                break;
            }

            case ConnectionType.Integer:
            {
                int value   = IntegerValue.Get(ParentNode, Archetype);
                var control = new IntValueBox(value, x, y, 40, int.MinValue, int.MaxValue, 0.01f)
                {
                    Height = height,
                    Parent = Parent
                };
                control.ValueChanged += OnIntValueBoxChanged;
                _defaultValueEditor   = control;
                break;
            }

            case ConnectionType.Float:
            {
                float value   = FloatValue.Get(ParentNode, Archetype);
                var   control = new FloatValueBox(value, x, y, 40, float.MinValue, float.MaxValue, 0.01f)
                {
                    Height = height,
                    Parent = Parent
                };
                control.ValueChanged += OnFloatValueBoxChanged;
                _defaultValueEditor   = control;
                break;
            }
            }
        }
예제 #6
0
        public Control Create(InputBox box, ref Rectangle bounds)
        {
            var value   = FloatValue.Get(box.ParentNode, box.Archetype, box.Value);
            var control = new FloatValueBox(value, bounds.X, bounds.Y, 40, float.MinValue, float.MaxValue, 0.01f)
            {
                Height = bounds.Height,
                Parent = box.Parent,
                Tag    = box,
            };

            control.BoxValueChanged += OnFloatValueBoxChanged;
            return(control);
        }
예제 #7
0
            /// <inheritdoc />
            public MultiBlend(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch)
                : base(id, context, nodeArch, groupArch)
            {
                var layoutOffsetY = FlaxEditor.Surface.Constants.LayoutOffsetY;

                _selectedAnimationLabel = new Label(300, 3 * layoutOffsetY, 120.0f, layoutOffsetY)
                {
                    HorizontalAlignment = TextAlignment.Near,
                    Text   = "Selected Animation:",
                    Parent = this
                };

                _selectedAnimation = new ComboBox(_selectedAnimationLabel.X, 4 * layoutOffsetY, _selectedAnimationLabel.Width)
                {
                    Parent = this
                };

                _selectedAnimation.PopupShowing         += OnSelectedAnimationPopupShowing;
                _selectedAnimation.SelectedIndexChanged += OnSelectedAnimationChanged;

                var items = new List <string>(MaxAnimationsCount);

                while (items.Count < MaxAnimationsCount)
                {
                    items.Add(string.Empty);
                }
                _selectedAnimation.Items = items;

                _animationPicker = new AssetPicker(new ScriptType(typeof(FlaxEngine.Animation)), new Vector2(_selectedAnimation.Left, _selectedAnimation.Bottom + 4))
                {
                    Parent = this
                };
                _animationPicker.SelectedItemChanged += OnAnimationPickerItemChanged;

                _animationSpeedLabel = new Label(_animationPicker.Left, _animationPicker.Bottom + 4, 40, TextBox.DefaultHeight)
                {
                    HorizontalAlignment = TextAlignment.Near,
                    Text   = "Speed:",
                    Parent = this
                };

                _animationSpeed = new FloatValueBox(1.0f, _animationSpeedLabel.Right + 4, _animationSpeedLabel.Y, _selectedAnimation.Right - _animationSpeedLabel.Right - 4)
                {
                    SlideSpeed = 0.01f,
                    Parent     = this
                };
                _animationSpeed.ValueChanged += OnAnimationSpeedValueChanged;
            }
예제 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FloatValueElement"/> class.
 /// </summary>
 public FloatValueElement()
 {
     FloatValue = new FloatValueBox(0);
 }
예제 #9
0
        /// <summary>
        /// Creates the default value editor control.
        /// </summary>
        private void CreateDefaultEditor()
        {
            if (_defaultValueEditor != null || Archetype.ValueIndex == -1)
            {
                return;
            }

            var   style  = Style.Current;
            float x      = X + Width + 8 + style.FontSmall.MeasureText(Archetype.Text).X;
            float y      = Y;
            float height = Height;

            switch (CurrentType)
            {
            case ConnectionType.Bool:
            {
                bool value   = BoolValue.Get(ParentNode, Archetype);
                var  control = new CheckBox(x, y, value, height)
                {
                    Parent = Parent
                };
                control.StateChanged += OnCheckBoxChanged;
                _defaultValueEditor   = control;
                break;
            }

            case ConnectionType.Integer:
            case ConnectionType.UnsignedInteger:
            {
                int value   = IntegerValue.Get(ParentNode, Archetype);
                var control = new IntValueBox(value, x, y, 40, CurrentType == ConnectionType.UnsignedInteger ? 0 : int.MinValue, int.MaxValue, 0.01f)
                {
                    Height = height,
                    Parent = Parent
                };
                control.ValueChanged += OnIntValueBoxChanged;
                _defaultValueEditor   = control;
                break;
            }

            case ConnectionType.Float:
            {
                float value   = FloatValue.Get(ParentNode, Archetype);
                var   control = new FloatValueBox(value, x, y, 40, float.MinValue, float.MaxValue, 0.01f)
                {
                    Height = height,
                    Parent = Parent
                };
                control.ValueChanged += OnFloatValueBoxChanged;
                _defaultValueEditor   = control;
                break;
            }

            case ConnectionType.Vector2:
            {
                Vector2 value   = GetValueVector2(ParentNode, Archetype);
                var     control = new ContainerControl(x, y, 22 * 2 - 2, height)
                {
                    ClipChildren = false,
                    AutoFocus    = false,
                    Parent       = Parent
                };
                var floatX = new FloatValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatX.ValueChanged += OnVector2ValueChanged;
                var floatY = new FloatValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatY.ValueChanged += OnVector2ValueChanged;
                _defaultValueEditor  = control;
                break;
            }

            case ConnectionType.Vector3:
            {
                Vector3 value   = GetValueVector3(ParentNode, Archetype);
                var     control = new ContainerControl(x, y, 22 * 3 - 2, height)
                {
                    ClipChildren = false,
                    AutoFocus    = false,
                    Parent       = Parent
                };
                var floatX = new FloatValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatX.ValueChanged += OnVector3ValueChanged;
                var floatY = new FloatValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatY.ValueChanged += OnVector3ValueChanged;
                var floatZ = new FloatValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatZ.ValueChanged += OnVector3ValueChanged;
                _defaultValueEditor  = control;
                break;
            }

            case ConnectionType.Vector4:
            {
                Vector4 value   = GetValueVector4(ParentNode, Archetype);
                var     control = new ContainerControl(x, y, 22 * 4 - 2, height)
                {
                    ClipChildren = false,
                    AutoFocus    = false,
                    Parent       = Parent
                };
                var floatX = new FloatValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatX.ValueChanged += OnVector4ValueChanged;
                var floatY = new FloatValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatY.ValueChanged += OnVector4ValueChanged;
                var floatZ = new FloatValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatZ.ValueChanged += OnVector4ValueChanged;
                var floatW = new FloatValueBox(value.W, 66, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatW.ValueChanged += OnVector4ValueChanged;
                _defaultValueEditor  = control;
                break;
            }
            }
        }