Exemplo n.º 1
0
        public Vector3PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorX = editorParams.NumericEditBoxFactory()),
                    (editorY = editorParams.NumericEditBoxFactory()),
                    (editorZ = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            var currentX = CoalescedPropertyComponentValue(v => v.X);
            var currentY = CoalescedPropertyComponentValue(v => v.Y);
            var currentZ = CoalescedPropertyComponentValue(v => v.Z);

            editorX.Submitted += text => SetComponent(editorParams, 0, editorX, currentX.GetValue());
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, currentY.GetValue());
            editorZ.Submitted += text => SetComponent(editorParams, 2, editorZ, currentZ.GetValue());
            editorX.AddChangeWatcher(currentX, v => editorX.Text = v.ToString("0.###"));
            editorY.AddChangeWatcher(currentY, v => editorY.Text = v.ToString("0.###"));
            editorZ.AddChangeWatcher(currentZ, v => editorZ.Text = v.ToString("0.###"));
        }
Exemplo n.º 2
0
        public QuaternionPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorX = editorParams.NumericEditBoxFactory()),
                    (editorY = editorParams.NumericEditBoxFactory()),
                    (editorZ = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            var current = CoalescedPropertyValue();

            editorX.Submitted += text => SetComponent(editorParams, 0, editorX, current.GetValue());
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, current.GetValue());
            editorZ.Submitted += text => SetComponent(editorParams, 2, editorZ, current.GetValue());
            editorX.AddChangeWatcher(current, v => {
                var ea       = v.ToEulerAngles() * Mathf.RadToDeg;
                editorX.Text = RoundAngle(ea.X).ToString("0.###");
                editorY.Text = RoundAngle(ea.Y).ToString("0.###");
                editorZ.Text = RoundAngle(ea.Z).ToString("0.###");
            });
        }
Exemplo n.º 3
0
        public ThicknessPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorLeft   = editorParams.NumericEditBoxFactory()),
                    (editorRight  = editorParams.NumericEditBoxFactory()),
                    (editorTop    = editorParams.NumericEditBoxFactory()),
                    (editorBottom = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            var current = CoalescedPropertyValue();

            editorLeft.Submitted   += text => SetComponent(editorParams, 0, editorLeft, current.GetValue());
            editorRight.Submitted  += text => SetComponent(editorParams, 1, editorRight, current.GetValue());
            editorTop.Submitted    += text => SetComponent(editorParams, 2, editorTop, current.GetValue());
            editorBottom.Submitted += text => SetComponent(editorParams, 3, editorBottom, current.GetValue());
            editorLeft.AddChangeWatcher(current, v => {
                editorLeft.Text   = v.Left.ToString("0.###");
                editorRight.Text  = v.Right.ToString("0.###");
                editorTop.Text    = v.Top.ToString("0.###");
                editorBottom.Text = v.Bottom.ToString("0.###");
            });
        }
Exemplo n.º 4
0
        public FloatPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor = editorParams.NumericEditBoxFactory();
            EditorContainer.AddNode(editor);
            EditorContainer.AddNode(Spacer.HStretch());
            var current = CoalescedPropertyValue();

            editor.Submitted += text => SetComponent(text, current);
            editor.AddChangeWatcher(current, v => editor.Text = v.ToString("0.###"));
        }
Exemplo n.º 5
0
        public DoublePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor = editorParams.NumericEditBoxFactory();
            EditorContainer.AddNode(editor);
            var current = CoalescedPropertyValue();

            editor.Submitted += text => {
                if (Parser.TryParse(text, out double newValue))
                {
                    SetProperty(newValue);
                }
                editor.Text = current.GetValue().ToString("0.###");
            };
            editor.AddChangeWatcher(current, v => editor.Text = v.ToString("0.###"));
        }
Exemplo n.º 6
0
        public FloatPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor = editorParams.NumericEditBoxFactory();
            ContainerWidget.AddNode(editor);
            var current = CoalescedPropertyValue();

            editor.Submitted += text => {
                float newValue;
                if (float.TryParse(text, out newValue))
                {
                    SetProperty(newValue);
                }

                editor.Text = current.GetValue().ToString();
            };
            editor.AddChangeWatcher(current, v => editor.Text = v.ToString());
        }
Exemplo n.º 7
0
        public NumericRangePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ContainerWidget.AddNode(new Widget {
                Layout = new HBoxLayout {
                    CellDefaults = new LayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (medEditor  = editorParams.NumericEditBoxFactory()),
                    (dispEditor = editorParams.NumericEditBoxFactory()),
                }
            });
            var currentMed  = CoalescedPropertyComponentValue(v => v.Median);
            var currentDisp = CoalescedPropertyComponentValue(v => v.Dispersion);

            medEditor.Submitted  += text => SetComponent(editorParams, 0, medEditor, currentMed.GetValue());
            dispEditor.Submitted += text => SetComponent(editorParams, 1, dispEditor, currentDisp.GetValue());
            medEditor.AddChangeWatcher(currentMed, v => medEditor.Text    = v.ToString());
            dispEditor.AddChangeWatcher(currentDisp, v => dispEditor.Text = v.ToString());
        }
Exemplo n.º 8
0
        public Vector2PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ContainerWidget.AddNode(new Widget {
                Layout = new HBoxLayout {
                    CellDefaults = new LayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorX = editorParams.NumericEditBoxFactory()),
                    (editorY = editorParams.NumericEditBoxFactory())
                }
            });
            var currentX = CoalescedPropertyComponentValue(v => v.X);
            var currentY = CoalescedPropertyComponentValue(v => v.Y);

            editorX.Submitted += text => SetComponent(editorParams, 0, editorX, currentX.GetValue());
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, currentY.GetValue());
            editorX.AddChangeWatcher(currentX, v => editorX.Text = v.ToString());
            editorY.AddChangeWatcher(currentY, v => editorY.Text = v.ToString());
        }
Exemplo n.º 9
0
            public BlendingPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
            {
                editor             = editorParams.NumericEditBoxFactory();
                editor.Step        = 1f;
                editor.MinMaxWidth = 80;
                editor.LayoutCell  = new LayoutCell(Alignment.Center);
                EditorContainer.AddNode(editor);
                var current = CoalescedPropertyValue();

                editor.Submitted += text => {
                    if (int.TryParse(text, out var newValue))
                    {
                        SetProperty(new BlendingOption(newValue));
                    }
                    else
                    {
                        editor.Text = current.GetValue().Frames.ToString();
                    }
                };
                editor.AddChangeWatcher(current, v => editor.Text = v?.Frames.ToString() ?? "0");
            }