Пример #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);
        }
Пример #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.###");
            });
        }
Пример #3
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.###"));
        }
Пример #4
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 SkinningWeightsPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     editorParams.DefaultValueGetter = () => new SkinningWeights();
     indexEditors   = new NumericEditBox[4];
     weigthsEditors = new NumericEditBox[4];
     foreach (var o in editorParams.Objects)
     {
         var prop = new Property <SkinningWeights>(o, editorParams.PropertyName).Value;
     }
     for (var i = 0; i <= 3; i++)
     {
         indexEditors[i]      = editorParams.NumericEditBoxFactory();
         indexEditors[i].Step = 1;
         weigthsEditors[i]    = editorParams.NumericEditBoxFactory();
         var wrapper = new Widget {
             Padding = new Thickness {
                 Left = 20
             },
             Layout     = new HBoxLayout(),
             LayoutCell = new LayoutCell {
                 StretchY = 0
             }
         };
         var propertyLabel = new ThemedSimpleText {
             Text           = $"Bone { char.ConvertFromUtf32(65 + i) }",
             VAlignment     = VAlignment.Center,
             LayoutCell     = new LayoutCell(Alignment.LeftCenter, 0),
             ForceUncutText = false,
             MinWidth       = 140,
             OverflowMode   = TextOverflowMode.Minify,
             HitTestTarget  = true,
             TabTravesable  = new TabTraversable(),
         };
         wrapper.AddNode(propertyLabel);
         wrapper.AddNode(new Widget {
             Layout = new HBoxLayout {
                 DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4
             },
             Nodes =
             {
                 indexEditors[i],
                 weigthsEditors[i]
             }
         });
         ExpandableContent.AddNode(wrapper);
         var j = i;
         SetLink(i, CoalescedPropertyComponentValue(sw => sw[j].Index), CoalescedPropertyComponentValue(sw => sw[j].Weight));
     }
 }
 public SkinningWeightsPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     editorParams.DefaultValueGetter = () => new SkinningWeights();
     indexEditors   = new NumericEditBox[4];
     weightsSliders = new ThemedAreaSlider[4];
     foreach (var o in editorParams.Objects)
     {
         var prop = new Property <SkinningWeights>(o, editorParams.PropertyName).Value;
     }
     for (var i = 0; i <= 3; i++)
     {
         indexEditors[i]      = editorParams.NumericEditBoxFactory();
         indexEditors[i].Step = 1;
         weightsSliders[i]    = new ThemedAreaSlider(range: new Vector2(0, 1), labelFormat: "0.00000");
         var wrapper = new Widget {
             Layout     = new HBoxLayout(),
             LayoutCell = new LayoutCell {
                 StretchY = 0
             }
         };
         var propertyLabel = new ThemedSimpleText {
             Text       = $"Bone { char.ConvertFromUtf32(65 + i) }",
             VAlignment = VAlignment.Center,
             Padding    = new Thickness {
                 Left = 20
             },
             LayoutCell = new LayoutCell {
                 StretchX = 1.0f
             },
             ForceUncutText = false,
             OverflowMode   = TextOverflowMode.Minify,
             HitTestTarget  = false
         };
         wrapper.AddNode(propertyLabel);
         wrapper.AddNode(new Widget {
             Layout = new HBoxLayout {
                 Spacing = 4
             },
             LayoutCell = new LayoutCell {
                 StretchX = 2.0f
             },
             Nodes =
             {
                 indexEditors[i],
                 weightsSliders[i]
             }
         });
         ExpandableContent.AddNode(wrapper);
         customWarningsContainer = new Widget {
             Layout = new VBoxLayout()
         };
         ContainerWidget.AddNode(customWarningsContainer);
         var j = i;
         SetLink(i, CoalescedPropertyComponentValue(sw => sw[j].Index), CoalescedPropertyComponentValue(sw => sw[j].Weight));
     }
     CheckWarnings();
 }
Пример #7
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.###"));
        }
Пример #8
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());
        }
Пример #9
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());
        }
Пример #10
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);
        }
Пример #11
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);
        }
        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);
        }
Пример #13
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.###"));
        }
Пример #14
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());
        }
Пример #15
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);
        }
Пример #16
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");
            }