예제 #1
0
        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('/');
            });
        }
예제 #2
0
            public MarkerRow(
                Model3DAttachment.MarkerData marker,
                ObservableCollection <Model3DAttachment.MarkerData> markers) : base(marker, markers)
            {
                Layout = new HBoxLayout();
                var markerIdPropEditor = new StringPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        Source.Marker,
                        nameof(Marker.Id))
                {
                    ShowLabel = false
                });

                markerIdPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth;

                var framePropEditor = new IntPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        Source.Marker,
                        nameof(Marker.Frame))
                {
                    ShowLabel = false
                });

                var actionPropEditor = new EnumPropertyEditor <MarkerAction>(
                    new PropertyEditorParams(
                        Header,
                        Source.Marker,
                        nameof(Marker.Action))
                {
                    ShowLabel = false
                });

                actionPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.ControlWidth;

                var jumpToPropEditor = new StringPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        Source.Marker,
                        nameof(Marker.JumpTo))
                {
                    ShowLabel = false
                });

                jumpToPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.ControlWidth;
                Header.AddNode(new BlendingCell(Source, nameof(Model3DAttachment.MarkerData.Blending)));
            }
예제 #3
0
            public NodeRow(Model3DAttachment.NodeData source, ObservableCollection <Model3DAttachment.NodeData> sourceCollection) : base(source, sourceCollection)
            {
                Layout  = new HBoxLayout();
                Padding = new Thickness(AttachmentMetrics.Spacing);
                var nodeIdPropEditor = new StringPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        source,
                        nameof(Model3DAttachment.NodeData.Id))
                {
                    ShowLabel = false
                });

                nodeIdPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth;
                Presenter = Presenters.StripePresenter;
            }
예제 #4
0
        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);
        }
예제 #5
0
            public MaterialEffectRow(
                Model3DAttachment.MaterialEffect source,
                ObservableCollection <Model3DAttachment.MaterialEffect> sourceCollection) : base(source, sourceCollection)
            {
                Layout = new HBoxLayout();
                var namePropEditor = new StringPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        Source,
                        nameof(Model3DAttachment.MaterialEffect.Name))
                {
                    ShowLabel = false
                });

                namePropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.ControlWidth;

                var materialNamePropEditor = new StringPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        Source,
                        nameof(Model3DAttachment.MaterialEffect.MaterialName))
                {
                    ShowLabel = false
                });

                materialNamePropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.ControlWidth;

                var pathPropEditor = new StringPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        Source,
                        nameof(Model3DAttachment.MaterialEffect.Path))
                {
                    ShowLabel = false
                });

                pathPropEditor.ContainerWidget.MinMaxWidth = 2 * AttachmentMetrics.EditorWidth;

                Header.AddNode(new BlendingCell(Source, nameof(Model3DAttachment.MaterialEffect.Blending)));
            }
예제 #6
0
            public MeshRow(Model3DAttachment.MeshOption mesh, ObservableCollection <Model3DAttachment.MeshOption> options) : base(mesh, options)
            {
                Layout  = new VBoxLayout();
                Padding = new Thickness(AttachmentMetrics.Spacing);
                var meshIdPropEditor = new StringPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        mesh,
                        nameof(Model3DAttachment.MeshOption.Id))
                {
                    ShowLabel = false
                });

                meshIdPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth;

                var cullModePropEditor = new EnumPropertyEditor <CullMode>(
                    new PropertyEditorParams(
                        Header,
                        mesh,
                        nameof(Model3DAttachment.MeshOption.CullMode))
                {
                    ShowLabel = false
                });

                cullModePropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth;

                var hitPropEditor = new BooleanPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        mesh,
                        nameof(Model3DAttachment.MeshOption.HitTestTarget))
                {
                    ShowLabel = false
                });

                hitPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.ControlWidth;
                CompoundPresenter.Add(Presenters.StripePresenter);
            }
예제 #7
0
            public MarkerBlendingRow(Model3DAttachment.MarkerBlendingData source, ObservableCollection <Model3DAttachment.MarkerBlendingData> sourceCollection) : base(source, sourceCollection)
            {
                Layout = new HBoxLayout();
                var destMarkerPropEditor = new StringPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        Source,
                        nameof(Model3DAttachment.MarkerBlendingData.DestMarkerId))
                {
                    ShowLabel = false
                });

                destMarkerPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth;

                var sourceMarkerPropEditor = new StringPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        Source,
                        nameof(Model3DAttachment.MarkerBlendingData.SourceMarkerId))
                {
                    ShowLabel = false
                });

                sourceMarkerPropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth;

                var blendingOptionEditBox = new BlendingPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        Source,
                        nameof(Model3DAttachment.MarkerBlendingData.Blending))
                {
                    ShowLabel = false
                });

                blendingOptionEditBox.ContainerWidget.MinMaxWidth = AttachmentMetrics.ControlWidth;
            }
예제 #8
0
            public AnimationRow(Model3DAttachment.Animation animation, ObservableCollection <Model3DAttachment.Animation> options)
                : base(animation, options)
            {
                var isDefault = animation.Name == Model3DAttachment.DefaultAnimationName;

                deleteButton.Visible = !isDefault;
                Layout = new VBoxLayout();
                var expandedButton = new ThemedExpandButton {
                    MinMaxSize = new Vector2(AttachmentMetrics.ExpandButtonSize),
                    Anchors    = Anchors.Left
                };

                Padding = new Thickness(AttachmentMetrics.Spacing);
                Header.Nodes.Add(expandedButton);

                var animationNamePropEditor = new StringPropertyEditor(
                    new PropertyEditorParams(
                        Header,
                        animation,
                        nameof(Model3DAttachment.Animation.Name))
                {
                    ShowLabel = false
                });

                animationNamePropEditor.ContainerWidget.MinMaxWidth = AttachmentMetrics.EditorWidth;

                Header.AddNode(new BlendingCell(Source, nameof(Model3DAttachment.Animation.Blending)));

                var expandableContentWrapper = new Widget {
                    Layout = new VBoxLayout {
                        Spacing = AttachmentMetrics.Spacing
                    },
                    LayoutCell = new LayoutCell {
                        StretchY = 0
                    },
                    Padding = new Thickness {
                        Left   = AttachmentMetrics.ExpandContentPadding,
                        Top    = AttachmentMetrics.Spacing,
                        Bottom = AttachmentMetrics.Spacing
                    },
                    Visible = false,
                };

                BuildList <Model3DAttachment.MarkerData, MarkerRow>(
                    animation.Markers,
                    expandableContentWrapper,
                    "Markers",
                    () => new Model3DAttachment.MarkerData {
                    Marker = new Marker {
                        Id    = "Marker",
                        Frame = 0,
                    }
                },
                    MarkerRow.CreateHeader());

                BuildList <Model3DAttachment.MarkerBlendingData, MarkerBlendingRow>(
                    animation.MarkersBlendings,
                    expandableContentWrapper,
                    "Marker Blendings",
                    () => new Model3DAttachment.MarkerBlendingData {
                    SourceMarkerId = "Marker2",
                    DestMarkerId   = "Marker1"
                },
                    MarkerBlendingRow.CreateHeader());
                if (!isDefault)
                {
                    BuildList <Model3DAttachment.NodeData, NodeRow>(
                        animation.Nodes,
                        expandableContentWrapper,
                        "Nodes",
                        () => new Model3DAttachment.NodeData {
                        Id = "NodeId"
                    },
                        NodeRow.CreateHeader());

                    BuildList <Model3DAttachment.NodeData, NodeRow>(
                        animation.IgnoredNodes,
                        expandableContentWrapper,
                        "Ignored Nodes",
                        () => new Model3DAttachment.NodeData {
                        Id = "NodeId"
                    },
                        NodeRow.CreateHeader());
                }


                Nodes.Add(expandableContentWrapper);
                expandableContentWrapper.AddChangeWatcher(
                    () => expandedButton.Expanded,
                    (v) => expandableContentWrapper.Visible = v);
                CompoundPresenter.Add(Presenters.StripePresenter);
            }