Exemplo n.º 1
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 currentLeft   = CoalescedPropertyComponentValue(v => v.Left);
            var currentRight  = CoalescedPropertyComponentValue(v => v.Right);
            var currentTop    = CoalescedPropertyComponentValue(v => v.Top);
            var currentBottom = CoalescedPropertyComponentValue(v => v.Bottom);

            editorLeft.Submitted   += text => SetComponent(editorParams, 0, editorLeft, currentLeft.GetValue());
            editorRight.Submitted  += text => SetComponent(editorParams, 1, editorRight, currentRight.GetValue());
            editorTop.Submitted    += text => SetComponent(editorParams, 2, editorTop, currentTop.GetValue());
            editorBottom.Submitted += text => SetComponent(editorParams, 3, editorBottom, currentBottom.GetValue());
            editorLeft.AddChangeLateWatcher(currentLeft, v => editorLeft.Text       = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorRight.AddChangeLateWatcher(currentRight, v => editorRight.Text    = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorTop.AddChangeLateWatcher(currentTop, v => editorTop.Text          = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorBottom.AddChangeLateWatcher(currentBottom, v => editorBottom.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            ManageManyValuesOnFocusChange(editorLeft, currentLeft);
            ManageManyValuesOnFocusChange(editorRight, currentRight);
            ManageManyValuesOnFocusChange(editorTop, currentTop);
            ManageManyValuesOnFocusChange(editorBottom, currentBottom);
        }
Exemplo n.º 2
0
        public Vector2PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    //new SimpleText { Text = "X" },
                    (editorX = editorParams.NumericEditBoxFactory()),
                    // new SimpleText { Text = "Y" },
                    (editorY = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            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.AddChangeLateWatcher(currentX, v => editorX.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            editorY.AddChangeLateWatcher(currentY, v => editorY.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            ManageManyValuesOnFocusChange(editorX, currentX);
            ManageManyValuesOnFocusChange(editorY, currentY);
        }
        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().Value, q => q.ToEulerAngles().X);
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, current.GetValue().Value, q => q.ToEulerAngles().Y);
            editorZ.Submitted += text => SetComponent(editorParams, 2, editorZ, current.GetValue().Value, q => q.ToEulerAngles().Z);
            editorX.AddChangeLateWatcher(current, v => {
                var ea       = v.Value.ToEulerAngles() * Mathf.RadToDeg;
                editorX.Text = SameComponentValues(q => q.ToEulerAngles().X) ? RoundAngle(ea.X).ToString("0.###") : ManyValuesText;
                editorY.Text = SameComponentValues(q => q.ToEulerAngles().Y) ? RoundAngle(ea.Y).ToString("0.###") : ManyValuesText;
                editorZ.Text = SameComponentValues(q => q.ToEulerAngles().Z) ? RoundAngle(ea.Z).ToString("0.###") : ManyValuesText;
            });
        }
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.GetValue());
            editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            ManageManyValuesOnFocusChange(editor, current);
        }
Exemplo n.º 5
0
        public SBytePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor = editorParams.NumericEditBoxFactory();
            // TODO: move IsReadOnly to IPropertyEditor
            editor.IsReadOnly = editorParams.PropertyInfo.GetCustomAttribute <TangerineReadOnlyAttribute>(true) != null;
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            EditorContainer.AddNode(editor);
            EditorContainer.AddNode(Spacer.HStretch());
            var current = CoalescedPropertyValue();

            editor.Submitted += text => SetComponent(text, current.GetValue());
            editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value.ToString() : ManyValuesText);
            ManageManyValuesOnFocusChange(editor, current);
        }
Exemplo n.º 6
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);
                }
                else
                {
                    var currentValue = current.GetValue();
                    editor.Text = currentValue.IsDefined ? currentValue.Value.ToString("0.###") : ManyValuesText;
                }
            };
            editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            ManageManyValuesOnFocusChange(editor, current);
        }
        public NumericRangePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout {
                    DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (medEditor  = editorParams.NumericEditBoxFactory()),
                    (dispEditor = editorParams.NumericEditBoxFactory()),
                    Spacer.HStretch(),
                }
            });
            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.AddChangeLateWatcher(currentMed, v => medEditor.Text    = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            dispEditor.AddChangeLateWatcher(currentDisp, v => dispEditor.Text = v.IsDefined ? v.Value.ToString("0.###") : ManyValuesText);
            ManageManyValuesOnFocusChange(medEditor, currentMed);
            ManageManyValuesOnFocusChange(dispEditor, currentDisp);
        }