public EnumPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { Selector = editorParams.DropDownListFactory(); Selector.LayoutCell = new LayoutCell(Alignment.Center); EditorContainer.AddNode(Selector); var propType = editorParams.PropertyInfo.PropertyType; var fields = propType.GetFields(BindingFlags.Public | BindingFlags.Static); var allowedFields = fields.Where(f => !Attribute.IsDefined((MemberInfo)f, typeof(TangerineIgnoreAttribute))); foreach (var field in allowedFields) { Selector.Items.Add(new CommonDropDownList.Item(field.Name, field.GetValue(null))); } Selector.Changed += a => { if (a.ChangedByUser) { SetProperty((T)Selector.Items[a.Index].Value); } }; Selector.AddChangeLateWatcher(CoalescedPropertyValue(), v => { if (v.IsDefined) { Selector.Value = v.Value; } else { Selector.Text = ManyValuesText; } }); }
public TextPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { EditorContainer.AddNode(new Widget { Layout = new HBoxLayout(), Nodes = { (editor = editorParams.EditBoxFactory()), Spacer.HSpacer(4), (button = new ThemedButton { Text = "...", MinMaxWidth = 20, LayoutCell = new LayoutCell(Alignment.Center) }) } }); editor.LayoutCell = new LayoutCell(Alignment.Center); editor.Editor.EditorParams.MaxLines = maxLines; editor.MinHeight += editor.TextWidget.FontHeight * (maxLines - 1); editor.Submitted += text => SetProperty(text); editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v); button.Clicked += () => { var window = new TextEditorDialog(editorParams.DisplayName ?? editorParams.PropertyName, editor.Text, (s) => { SetProperty(s); }); }; }
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.###"); }); }
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.###")); }
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 TextPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { ThemedButton button; EditorContainer.AddNode(new Widget { Layout = new HBoxLayout(), Nodes = { (editor = editorParams.EditBoxFactory()), Spacer.HSpacer(4), (button = new ThemedButton { Text = "...", MinMaxWidth = 20, LayoutCell = new LayoutCell(Alignment.Center) }) } }); editor.LayoutCell = new LayoutCell(Alignment.Center); editor.Editor.EditorParams.MaxLines = maxLines; editor.MinHeight += editor.TextWidget.FontHeight * (maxLines - 1); var first = true; var submitted = false; var current = CoalescedPropertyValue(); editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value : ManyValuesText); button.Clicked += () => { var window = new TextEditorDialog(editorParams.DisplayName ?? editorParams.PropertyName, editor.Text, (s) => { SetProperty(s); }); }; editor.Submitted += text => Submit(); editor.AddChangeLateWatcher(() => editor.Text, text => { if (first) { first = false; return; } if (!editor.IsFocused()) { return; } if (submitted) { Document.Current.History.Undo(); } submitted = true; Submit(); }); editor.AddChangeLateWatcher(() => editor.IsFocused(), focused => { if (submitted) { Document.Current.History.Undo(); } if (!focused) { submitted = false; } }); ManageManyValuesOnFocusChange(editor, current); }
public TriggerPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams) { comboBox = new ThemedComboBox { LayoutCell = new LayoutCell(Alignment.Center) }; EditorContainer.AddNode(comboBox); EditorContainer.AddNode(Spacer.HStretch()); comboBox.Changed += ComboBox_Changed; foreach (var obj in editorParams.Objects) { var node = (Node)obj; foreach (var a in node.Animations) { foreach (var m in a.Markers.Where(i => i.Action != MarkerAction.Jump && !string.IsNullOrEmpty(i.Id))) { var id = a.Id != null ? m.Id + '@' + a.Id : m.Id; if (!comboBox.Items.Any(i => i.Text == id)) { comboBox.Items.Add(new DropDownList.Item(id)); } } } } comboBox.AddChangeWatcher(CoalescedPropertyValue(), v => comboBox.Text = v); }
public DictionaryPropertyEditor(IPropertyEditorParams editorParams, Func <Type, PropertyEditorParams, Widget, object, IEnumerable <IPropertyEditor> > populateEditors) : base(editorParams) { if (EditorParams.Objects.Skip(1).Any()) { EditorContainer.AddNode(new Widget() { Layout = new HBoxLayout(), Nodes = { new ThemedSimpleText { Text = "Edit of dictionary properties isn't supported for multiple selection.", ForceUncutText = false } }, Presenter = new WidgetFlatFillPresenter(Theme.Colors.WarningBackground) }); return; } this.populateEditors = populateEditors; dictionary = PropertyValue(EditorParams.Objects.First()).GetValue(); var addButton = new ThemedAddButton { Clicked = () => { if (dictionary == null) { var pi = EditorParams.PropertyInfo; var o = EditorParams.Objects.First(); pi.SetValue(o, dictionary = Activator.CreateInstance <TDictionary>()); } if (dictionary.ContainsKey(keyValueToAdd.Key)) { AddWarning($"Key \"{keyValueToAdd.Key}\" already exists.", ValidationResult.Warning); return; } using (Document.Current.History.BeginTransaction()) { InsertIntoDictionary <TDictionary, string, TValue> .Perform(dictionary, keyValueToAdd.Key, keyValueToAdd.Value); ExpandableContent.Nodes.Add(CreateDefaultKeyValueEditor(keyValueToAdd.Key, keyValueToAdd.Value)); Document.Current.History.CommitTransaction(); } keyValueToAdd.Value = DefaultValue; keyValueToAdd.Key = string.Empty; }, LayoutCell = new LayoutCell(Alignment.LeftCenter), }; var keyEditorContainer = CreateKeyEditor(editorParams, keyValueToAdd, s => keyValueToAdd.Key = s, addButton); ExpandableContent.Nodes.Add(keyEditorContainer); ExpandableContent.Nodes.Add(CreateValueEditor(editorParams, keyValueToAdd, populateEditors)); Rebuild(); EditorContainer.Tasks.AddLoop(() => { if (dictionary != null && ((ICollection)dictionary).Count != pairs.Count) { Rebuild(); } }); var current = PropertyValue(EditorParams.Objects.First()); ContainerWidget.AddChangeWatcher(() => current.GetValue(), d => { dictionary = d; Rebuild(); }); }
public FontPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { selector = editorParams.DropDownListFactory(); selector.LayoutCell = new LayoutCell(Alignment.Center); EditorContainer.AddNode(selector); var propType = editorParams.PropertyInfo.PropertyType; var items = AssetBundle.Current.EnumerateFiles(defaultFontDirectory). Where(i => i.EndsWith(".fnt") || i.EndsWith(".tft") || i.EndsWith(".cft")). Select(i => new DropDownList.Item(FontPool.ExtractFontNameFromPath(i, defaultFontDirectory))); foreach (var i in items) { selector.Items.Add(i); } var current = CoalescedPropertyValue().GetValue(); selector.Text = current.IsDefined ? GetFontName(current.Value) : ManyValuesText; selector.Changed += a => { SetProperty(new SerializableFont((string)a.Value)); }; selector.AddChangeLateWatcher(CoalescedPropertyValue(), i => { selector.Text = i.IsDefined ? GetFontName(i.Value): ManyValuesText; }); }
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); }
protected FilePropertyEditor(IPropertyEditorParams editorParams, string[] allowedFileTypes) : base(editorParams) { EditorContainer.AddNode(new Widget { Layout = new HBoxLayout(), Nodes = { (editor = editorParams.EditBoxFactory()), Spacer.HSpacer(4), (button = new ThemedButton { Text = "...", MinMaxWidth = 20, LayoutCell = new LayoutCell(Alignment.Center) }) } }); editor.LayoutCell = new LayoutCell(Alignment.Center); editor.Submitted += text => SetComponent(text); bool textValid = true; editor.AddChangeWatcher(() => editor.Text, text => textValid = IsValid(text)); editor.CompoundPostPresenter.Add(new SyncDelegatePresenter <EditBox>(editBox => { if (!textValid) { editBox.PrepareRendererState(); Renderer.DrawRect(Vector2.Zero, editBox.Size, Color4.Red.Transparentify(0.8f)); } })); button.Clicked += () => { var dlg = new FileDialog { AllowedFileTypes = allowedFileTypes, Mode = FileDialogMode.Open, InitialDirectory = Directory.Exists(LastOpenedDirectory) ? LastOpenedDirectory : Project.Current.GetSystemDirectory(Document.Current.Path), }; if (dlg.RunModal()) { SetFilePath(dlg.FileName); LastOpenedDirectory = Project.Current.GetSystemDirectory(dlg.FileName); } }; ExpandableContent.Padding = new Thickness(24, 10, 2, 2); var prefixEditor = new StringPropertyEditor(new PropertyEditorParams(ExpandableContent, prefix, nameof(PrefixData.Prefix)) { LabelWidth = 180 }); prefix.Prefix = GetLongestCommonPrefix(GetPaths()); ContainerWidget.AddChangeWatcher(() => prefix.Prefix, v => { string oldPrefix = GetLongestCommonPrefix(GetPaths()); if (oldPrefix == v) { return; } SetPathPrefix(oldPrefix, v); prefix.Prefix = v.Trim('/'); }); }
public NodeIdPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams) { editor = editorParams.EditBoxFactory(); editor.LayoutCell = new LayoutCell(Alignment.Center); editor.Editor.EditorParams.MaxLines = 1; EditorContainer.AddNode(editor); editor.Submitted += SetValue; editor.AddChangeLateWatcher(CoalescedPropertyValue(), v => editor.Text = v.IsDefined ? v.Value : ManyValuesText); ManageManyValuesOnFocusChange(editor, CoalescedPropertyValue()); }
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.###")); }
public StringPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams) { editor = editorParams.EditBoxFactory(); editor.LayoutCell = new LayoutCell(Alignment.Center); editor.Editor.EditorParams.MaxLines = multiline ? maxLines : 1; editor.MinHeight += multiline ? editor.TextWidget.FontHeight * (maxLines - 1) : 0; EditorContainer.AddNode(editor); editor.Submitted += text => SetProperty(text); editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v); }
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); }
public RenderTexturePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { editor = editorParams.EditBoxFactory(); editor.IsReadOnly = true; editor.LayoutCell = new LayoutCell(Alignment.Center); EditorContainer.AddNode(editor); editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v == null ? "RenderTexture (null)" : $"RenderTexture ({v.ImageSize.Width}x{v.ImageSize.Height})" ); }
public BezierEasingPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { EditorContainer.AddNode(new EasingEditorPanel(this, CoalescedPropertyValue(), (BezierEasing p) => SetProperty(p)).Widget); EditorContainer.Gestures.Add(new ClickGesture(1, () => { var reset = new Command("Reset", () => { DoTransaction(() => SetProperty <BezierEasing>(_ => BezierEasing.Default)); }); new Menu { reset }.Popup(); })); }
public AnchorsPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { group = new Widget { Layout = new HBoxLayout { DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4 } }; EditorContainer.AddNode(group); firstButton = AddButton(Anchors.Left, "Anchor to the left"); AddButton(Anchors.Right, "Anchor to the right"); AddButton(Anchors.Top, "Anchor to the top"); AddButton(Anchors.Bottom, "Anchor to the bottom"); AddButton(Anchors.CenterH, "Anchor to the center horizontally"); AddButton(Anchors.CenterV, "Anchor to the center vertically"); group.AddNode(Spacer.HStretch()); }
public AlignmentPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { EditorContainer.AddNode(new Widget { Layout = new HBoxLayout { DefaultCell = new DefaultLayoutCell(Alignment.Center), Spacing = 4 }, Nodes = { (selectorH = editorParams.DropDownListFactory()), (selectorV = editorParams.DropDownListFactory()) } }); var items = new [] {
public StringPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams) { editor = editorParams.EditBoxFactory(); editor.LayoutCell = new LayoutCell(Alignment.Center); editor.Editor.EditorParams.MaxLines = multiline ? maxLines : 1; editor.MinHeight += multiline ? editor.TextWidget.FontHeight * (maxLines - 1) : 0; EditorContainer.AddNode(editor); editor.Submitted += text => SetProperty(text); var current = CoalescedPropertyValue(); editor.AddChangeLateWatcher(current, v => editor.Text = v.IsDefined ? v.Value : ManyValuesText); ManageManyValuesOnFocusChange(editor, current); }
public RenderTexturePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { var editor = editorParams.EditBoxFactory(); editor.IsReadOnly = true; editor.LayoutCell = new LayoutCell(Alignment.Center); EditorContainer.AddNode(editor); var current = CoalescedPropertyValue(); editor.AddChangeLateWatcher(current, v => editor.Text = v.Value == null ? "RenderTexture (null)" : $"RenderTexture ({v.Value.ImageSize.Width}x{v.Value.ImageSize.Height})" ); ManageManyValuesOnFocusChange(editor, current); }
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 Color4PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { ColorBoxButton colorBox; var panel = new ColorPickerPanel(); var currentColor = CoalescedPropertyValue(Color4.White).DistinctUntilChanged(); EditorContainer.AddNode(new Widget { Layout = new HBoxLayout { DefaultCell = new DefaultLayoutCell(Alignment.Center) }, Nodes = { (editor = editorParams.EditBoxFactory()), Spacer.HSpacer(4), (colorBox = new ColorBoxButton(currentColor)), CreatePipetteButton(), Spacer.HStretch(), }, }); ExpandableContent.AddNode(panel.Widget); panel.Widget.Padding = panel.Widget.Padding + new Thickness(right: 12.0f); panel.Widget.Tasks.Add(currentColor.Consume(v => { if (panel.Color != v) { panel.Color = v; } Changed?.Invoke(); })); panel.Changed += () => { EditorParams.History?.RollbackTransaction(); SetProperty(panel.Color); }; panel.DragStarted += () => { EditorParams.History?.BeginTransaction(); lastColor = panel.Color; }; panel.DragEnded += () => { if (panel.Color != lastColor) { EditorParams.History?.CommitTransaction(); } EditorParams.History?.EndTransaction(); }; colorBox.Clicked += () => Expanded = !Expanded; var currentColorString = currentColor.Select(i => i.ToString(Color4.StringPresentation.Dec)); editor.Submitted += text => SetComponent(text, currentColorString); editor.Tasks.Add(currentColorString.Consume(v => editor.Text = v)); editor.AddChangeWatcher(() => editor.Text, value => CheckEditorText(value, editor)); }
public NodeReferencePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { var propName = editorParams.PropertyName; if (propName.EndsWith("Ref")) { PropertyLabel.Text = propName.Substring(0, propName.Length - 3); } editor = editorParams.EditBoxFactory(); editor.LayoutCell = new LayoutCell(Alignment.Center); EditorContainer.AddNode(editor); editor.Submitted += text => SetComponent(text); editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v?.Id); }
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.###")); }
public BooleanPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { checkBox = new ThemedCheckBox { LayoutCell = new LayoutCell(Alignment.LeftCenter) }; EditorContainer.AddNode(checkBox); EditorContainer.AddNode(Spacer.HStretch()); checkBox.Changed += args => { if (args.ChangedByUser) { SetProperty(args.Value); } }; checkBox.AddChangeWatcher(CoalescedPropertyValue(), v => checkBox.Checked = v); }
protected FilePropertyEditor(IPropertyEditorParams editorParams, string[] allowedFileTypes) : base(editorParams) { ThemedButton button; this.allowedFileTypes = allowedFileTypes; EditorContainer.AddNode(new Widget { Layout = new HBoxLayout(), Nodes = { (editor = editorParams.EditBoxFactory()), Spacer.HSpacer(4), (button = new ThemedButton { Text = "...", MinMaxWidth = 20, LayoutCell = new LayoutCell(Alignment.Center) }) } }); editor.LayoutCell = new LayoutCell(Alignment.Center); editor.Submitted += text => SetComponent(text); button.Clicked += OnSelectClicked; ExpandableContent.Padding = new Thickness(24, 10, 2, 2); var prefixEditor = new StringPropertyEditor(new PropertyEditorParams(ExpandableContent, prefix, nameof(PrefixData.Prefix)) { LabelWidth = 180 }); prefix.Prefix = GetLongestCommonPrefix(GetPaths()); ContainerWidget.AddChangeWatcher(() => prefix.Prefix, v => { string oldPrefix = GetLongestCommonPrefix(GetPaths()); if (oldPrefix == v) { return; } SetPathPrefix(oldPrefix, v); prefix.Prefix = v.Trim('/'); }); ContainerWidget.AddChangeWatcher(() => ShowPrefix, show => { Expanded = show && Expanded; ExpandButton.Visible = show; }); var current = CoalescedPropertyValue(); editor.AddChangeLateWatcher(current, v => editor.Text = ValueToStringConverter(v.Value) ?? ""); ManageManyValuesOnFocusChange(editor, current); }
public BooleanPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { var checkBox = new ThemedCheckBox { LayoutCell = new LayoutCell(Alignment.LeftCenter) }; EditorContainer.AddNode(checkBox); EditorContainer.AddNode(Spacer.HStretch()); checkBox.Changed += args => { if (args.ChangedByUser) { SetProperty(args.Value); } }; checkBox.AddChangeLateWatcher(CoalescedPropertyValue(), v => checkBox.State = v.IsDefined ? v.Value ? CheckBoxState.Checked : CheckBoxState.Unchecked : CheckBoxState.Indeterminate); }
public NodeReferencePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams) { var propName = editorParams.PropertyName; if (propName.EndsWith("Ref")) { PropertyLabel.Text = propName.Substring(0, propName.Length - 3); } editor = editorParams.EditBoxFactory(); editor.LayoutCell = new LayoutCell(Alignment.Center); EditorContainer.AddNode(editor); editor.Submitted += SetComponent; var current = CoalescedPropertyValue(); editor.AddChangeLateWatcher(current, v => { editor.Text = v.IsDefined ? v.Value?.Id: ManyValuesText; }); ManageManyValuesOnFocusChange(editor, current); }
public ListPropertyEditor(IPropertyEditorParams editorParams, Func <PropertyEditorParams, Widget, IList, IEnumerable <IPropertyEditor> > onAdd) : base(editorParams) { this.onAdd = onAdd; if (EditorParams.Objects.Skip(1).Any()) { // Dont create editor interface if > 1 objects are selected EditorContainer.AddNode(new Widget() { Layout = new HBoxLayout(), Nodes = { new ThemedSimpleText { Text = "Edit of list properties isnt supported for multiple selection.", ForceUncutText = false } }, // TODO: move color to theme Presenter = new WidgetFlatFillPresenter(Theme.Colors.WarningBackground) }); return; } ExpandableContent.Padding = new Thickness(left: 4.0f, right: 0.0f, top: 4.0f, bottom: 4.0f); list = (IList)EditorParams.PropertyInfo.GetValue(EditorParams.Objects.First()); var addButton = new ThemedAddButton() { Clicked = () => { Expanded = true; if (list == null) { var pi = EditorParams.PropertyInfo; var o = EditorParams.Objects.First(); pi.SetValue(o, list = new TList()); } var newElement = typeof(TElement) == typeof(string) ? (TElement)(object)string.Empty : Activator.CreateInstance <TElement>(); using (Document.Current.History.BeginTransaction()) { int newIndex = list.Count; InsertIntoList.Perform(list, newIndex, newElement); Document.Current.History.CommitTransaction(); } } }; EditorContainer.AddNode(addButton); ContainerWidget.Updating += _ => removeCallback?.Invoke(); ContainerWidget.AddChangeWatcher(() => list?.Count ?? 0, Build); }