Esempio n. 1
0
        public Inspector(Widget panelWidget)
        {
            PanelWidget = panelWidget;
            RootWidget  = new Widget {
                Layout = new VBoxLayout()
            };
            var toolbarArea = new Widget {
                Layout = new StackLayout(), Padding = new Thickness(4, 0)
            };

            contentWidget = new ThemedScrollView();
            RootWidget.AddNode(toolbarArea);
            RootWidget.AddNode(contentWidget);
            RootWidget.Gestures.Add(DropFilesGesture = new DropFilesGesture());
            contentWidget.Content.Layout             = new VBoxLayout();
            Toolbar = new ToolbarView(toolbarArea, GetToolbarLayout());
            Objects = new List <object>();
            content = new InspectorContent(contentWidget.Content)
            {
                Footer = new Widget {
                    MinHeight = 300.0f
                },
                History = Document.Current.History
            };
            DropFilesGesture.Recognized += content.DropFiles;
            CreateWatchersToRebuild();
            OnCreate?.Invoke(this);
        }
Esempio n. 2
0
        public Menu(Widget container, int layer)
        {
            worldContainer = container;
            topContainer   = new Frame {
                Anchors = Anchors.LeftRightTopBottom,
                Size    = container.Size - Vector2.One * 80
            };
            var listContainer = (Frame)topContainer.Clone();
            var back          = new Widget {
                Anchors   = Anchors.LeftRightTopBottom,
                Size      = topContainer.Size + Vector2.One * 20,
                Shader    = ShaderId.Silhuette,
                Color     = Color4.DarkGray,
                Presenter = new WidgetFlatFillPresenter(Color4.Gray.Transparentify(0.3f))
            };

            topContainer.Layer = layer;
            var w = new Widget()
            {
                Layout = new VBoxLayout(), Size = topContainer.Size, Anchors = Anchors.LeftRightTopBottom
            };

            w.AddNode(listContainer);
            w.AddNode(CreateToolPanel());
            topContainer.AddNode(w);
            topContainer.AddNode(back);
            back.CenterOnParent();
            listView = new ScrollView(listContainer);
            listView.Content.Layout = new VBoxLayout();
            topContainer.LateTasks.Add(ExitTask);
            topContainer.SetFocus();
        }
Esempio n. 3
0
            /// <summary>
            /// Creates basic UI elements, but lefts bundle list empty. To fill it, call <see cref="CreateBundlesList"/>
            /// </summary>
            public BundlePickerWidget(BundlePicker bundlePicker)
            {
                this.bundlePicker = bundlePicker;

                Layout = new VBoxLayout {
                    Spacing = 6
                };
                MaxWidth = 250f;

                checkboxes = new Dictionary <string, ThemedCheckBox>();
                lines      = new Dictionary <string, Widget>();
                scrollView = new ThemedScrollView();
                scrollView.CompoundPostPresenter.Add(new WidgetBoundsPresenter(Lime.Theme.Colors.ControlBorder));
                scrollView.Content.Layout = new VBoxLayout {
                    Spacing = 6
                };
                scrollView.Content.Padding = new Thickness(6);
                scrollView.CompoundPresenter.Add(new WidgetFlatFillPresenter(Color4.White));

                selectButton = new ThemedButton {
                    Text    = "Select all",
                    Clicked = SelectButtonClickHandler
                };

                refreshButton = new ThemedButton {
                    Text    = "Refresh",
                    Clicked = Refresh,
                };

                filter = new ThemedEditBox();
                filter.Tasks.Add(FilterBundlesTask);

                infoText = new ThemedSimpleText("Selected action uses all bundles.")
                {
                    Color        = Theme.Colors.BlackText,
                    MinMaxHeight = Theme.Metrics.DefaultEditBoxSize.Y,
                    Visible      = false,
                    VAlignment   = VAlignment.Center,
                };

                AddNode(filter);
                AddNode(infoText);
                AddNode(scrollView);

                var buttonLine = new Widget {
                    Layout = new HBoxLayout {
                        Spacing = 6
                    }
                };

                AddNode(buttonLine);
                buttonLine.AddNode(new Widget {
                    LayoutCell = new LayoutCell {
                        StretchX = float.MaxValue
                    }, MaxHeight = 0
                });
                buttonLine.AddNode(refreshButton);
                buttonLine.AddNode(selectButton);
                selectButton.Tasks.Add(UpdateTextOfSelectButtonTask());
            }
Esempio n. 4
0
        private Widget CreateFooterSection()
        {
            var container = new Widget {
                Layout = new HBoxLayout {
                    Spacing = 5
                },
            };

            actionPicker = new ThemedDropDownList();
            foreach (var menuItem in The.MenuController.GetVisibleAndSortedItems())
            {
                actionPicker.Items.Add(new CommonDropDownList.Item(menuItem.Label, menuItem.Action));
            }
            actionPicker.Index = 0;
            container.AddNode(actionPicker);

            goButton          = new ThemedButton("Go");
            goButton.Clicked += () => Execute((Func <string>)actionPicker.Value);
            container.AddNode(goButton);

            abortButton = new ThemedButton("Abort")
            {
                Enabled = false,
                Visible = false
            };
            abortButton.Clicked += () => AssetCooker.CancelCook();
            container.AddNode(abortButton);

            return(container);
        }
Esempio n. 5
0
 public RollPane()
 {
     RootWidget = new Frame {
         Id     = nameof(RollPane),
         Layout = new StackLayout {
             VerticallySizeable = true
         },
         ClipChildren  = ClipMethod.ScissorTest,
         HitTestTarget = true,
         Input         = { AcceptMouseThroughDescendants = true },
     };
     ContentWidget = new Widget {
         Padding = new Thickness {
             Top = 1, Bottom = 1
         },
         Width   = RootWidget.Width,
         Height  = 0,
         Anchors = Anchors.LeftRight,
         Layout  = new VBoxLayout {
             Spacing = TimelineMetrics.RowSpacing
         },
         Presenter = new SyncDelegatePresenter <Node>(RenderBackground)
     };
     OverlayWidget = new Widget {
         Presenter = new SyncDelegatePresenter <Widget>(w => OnRenderOverlay?.Invoke(w))
     };
     RootWidget.AddNode(OverlayWidget);
     RootWidget.AddNode(ContentWidget);
     ContentWidget.Updating += _ => ContentWidget.Y = -Timeline.Instance.Offset.Y;
     RootWidget.Gestures.Add(new ClickGesture(1, ShowContextMenu));
 }
Esempio n. 6
0
        public OrangeInterface()
        {
            var windowSize = new Vector2(500, 400);

            window = new Window(new WindowOptions {
                ClientSize = windowSize,
                FixedSize  = false,
                Title      = "Orange",
#if WIN
                Icon = new System.Drawing.Icon(new EmbeddedResource("Orange.GUI.Resources.Orange.ico", "Orange.GUI").GetResourceStream()),
#endif // WIN
            });
            window.Closed += The.Workspace.Save;
            windowWidget   = new ThemedInvalidableWindowWidget(window)
            {
                Id     = "MainWindow",
                Layout = new HBoxLayout {
                    Spacing = 6
                },
                Padding = new Thickness(6),
                Size    = windowSize
            };
            var mainVBox = new Widget {
                Layout = new VBoxLayout {
                    Spacing = 6
                }
            };
            mainVBox.AddNode(CreateHeaderSection());
            mainVBox.AddNode(CreateVcsSection());
            mainVBox.AddNode(CreateTextView());
            mainVBox.AddNode(CreateFooterSection());
            windowWidget.AddNode(mainVBox);
        }
Esempio n. 7
0
 public RollPane()
 {
     RootWidget = new Frame {
         Id     = nameof(RollPane),
         Layout = new StackLayout {
             VerticallySizeable = true
         },
         MinWidth      = TimelineMetrics.ToolbarMinWidth,
         ClipChildren  = ClipMethod.ScissorTest,
         HitTestTarget = true,
     };
     ContentWidget = new Widget {
         Padding = new Thickness {
             Top = 1, Bottom = 1
         },
         Width   = RootWidget.Width,
         Height  = 0,
         Anchors = Anchors.LeftRight,
         Layout  = new VBoxLayout {
             Spacing = TimelineMetrics.RowSpacing
         },
         Presenter = new SyncDelegatePresenter <Node>(RenderBackground)
     };
     OverlayWidget = new Widget {
         Presenter = new SyncDelegatePresenter <Widget>(w => OnRenderOverlay?.Invoke(w))
     };
     RootWidget.AddNode(OverlayWidget);
     RootWidget.AddNode(ContentWidget);
     ContentWidget.Updating += delta => ContentWidget.Y = -Timeline.Instance.Offset.Y;
 }
Esempio n. 8
0
        private void Initialize()
        {
            Nodes.Clear();
            availableCommands = CreateListBox();
            usedCommands      = CreateListBox();
            panelList         = CreateListBox();
            CreatePanelControls();
            AddNode(new Widget {
                Layout = new HBoxLayout {
                    Spacing = 10
                },
                Nodes =
                {
                    CreateCategoryList(),
                    CreateSearchBox()
                }
            });
            var widget = new Widget {
                Layout = new HBoxLayout()
            };

            AddNode(widget);
            widget.AddNode(AddLabel(availableCommands, "Available commands:"));
            widget.AddNode(CreateCommandControls());
            widget.AddNode(AddLabel(usedCommands, "Used commands:"));
            RefreshAvailableCommands();
            RefreshUsedCommands();
        }
Esempio n. 9
0
 public void Rebuild()
 {
     widget.Nodes.Clear();
     for (var i = 0; i < toolbarModel.Rows.Count; ++i)
     {
         var row       = toolbarModel.Rows[i];
         var rowWidget = new Widget {
             MinMaxHeight = Metrics.ToolbarHeight,
             LayoutCell   = new LayoutCell {
                 StretchY = 0
             },
             Layout = new HBoxLayout()
         };
         for (var j = 0; j < row.Panels.Count; ++j)
         {
             var panel       = row.Panels[j];
             var panelWidget = new Widget {
                 Layout = new HBoxLayout {
                     Spacing = 1, DefaultCell = new DefaultLayoutCell(Alignment.LeftCenter)
                 },
                 LayoutCell = new LayoutCell(Alignment.LeftCenter)
                 {
                     StretchY = 0
                 },
             };
             if (panel.Draggable)
             {
                 var rowIndex   = i;
                 var panelIndex = j;
                 panelWidget.Awoke += n => {
                     PanelAwake(n, rowIndex, panelIndex);
                 };
             }
             foreach (var id in panel.CommandIds)
             {
                 if (!CommandRegistry.TryGetCommandInfo(id, out var commandInfo))
                 {
                     continue;
                 }
                 var command = commandInfo.Command;
                 var button  =
                     command.Icon != null ?
                     new ToolbarButton(command.Icon.AsTexture) :
                     new ToolbarButton(commandInfo.Title);
                 button.Clicked  += () => CommandQueue.Instance.Add((Command)command);
                 button.Updating += _ => {
                     button.Texture = command.Icon.AsTexture;
                     button.Checked = command.Checked;
                     button.Enabled = command.Enabled;
                     button.Tip     = button.Text = command.Text;
                 };
                 panelWidget.AddNode(button);
             }
             rowWidget.AddNode(panelWidget);
         }
         rowWidget.AddNode(new Widget());
         widget.AddNode(rowWidget);
     }
 }
Esempio n. 10
0
        Widget CreateGeneralPane()
        {
            var parent = new Widget();

            parent.Layout = new VBoxLayout {
                Spacing = 0
            };
            parent.Padding = contentPadding;
            var platform = new Widget();

            platform.Layout = new HBoxLayout {
                Spacing = 4, DefaultCell = new DefaultLayoutCell(Alignment.Center)
            };
            platform.Padding = contentPadding;
            platform.AddNode(new ThemedSimpleText("Target platform"));
            var platformPicker = (Orange.The.UI as OrangeInterface).PlatformPicker;

            platformPicker.Unlink();
            platform.AddNode(platformPicker);
            parent.AddNode(platform);
            var pane = new ThemedScrollView();

            pane.Content.Layout = new VBoxLayout {
                Spacing = 4
            };
            pane.Content.Padding = contentPadding;
            editors.AddRange(new IPropertyEditor[] {
                new BooleanPropertyEditor(
                    new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.ReloadModifiedFiles), displayName: "Reload modified files")),
                new Vector2PropertyEditor(
                    new PreferencesPropertyEditorParams(pane.Content, Tangerine.AppUserPreferences.Instance, propertyName: nameof(Tangerine.AppUserPreferences.DefaultSceneDimensions), displayName: "Default scene dimensions")),
                new BooleanPropertyEditor(
                    new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.AutoKeyframes), displayName: "Automatic keyframes")),
                new IntPropertyEditor(
                    new PreferencesPropertyEditorParams(pane.Content, Tangerine.AppUserPreferences.Instance, propertyName: nameof(Tangerine.AppUserPreferences.AutosaveDelay), displayName: "Autosave delay")),
                new BooleanPropertyEditor(
                    new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.StopAnimationOnCurrentFrame), displayName: "Stop animaion on current frame")),
                new BooleanPropertyEditor(
                    new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.ShowSceneThumbnail), displayName: "Show scene thumbnail")),
                new BooleanPropertyEditor(
                    new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.ShowSplinesGlobally), displayName: "Show splines globally")),
                new BooleanPropertyEditor(
                    new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.DontPasteAtMouse), displayName: "Don't paste at mouse pointer")),
                new BooleanPropertyEditor(
                    new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.InverseShiftKeyframeDrag), displayName: "Inverse Shift behaviour when dragging keyframes")),
                new BooleanPropertyEditor(
                    new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.SwapMouseButtonsForKeyframeSwitch), displayName: "Swap mouse buttons for keyframe switch")),
            });
            var boneWidthPropertyEditor =
                new FloatPropertyEditor(
                    new PreferencesPropertyEditorParams(pane.Content, UI.SceneView.SceneUserPreferences.Instance, propertyName: nameof(UI.SceneView.SceneUserPreferences.DefaultBoneWidth), displayName: "Bone Width"));

            boneWidthPropertyEditor.ContainerWidget.AddChangeWatcher(
                () => UI.SceneView.SceneUserPreferences.Instance.DefaultBoneWidth, (v) => Application.InvalidateWindows());
            new EnumPropertyEditor <KeyFunction>(
                new PreferencesPropertyEditorParams(pane.Content, CoreUserPreferences.Instance, propertyName: nameof(CoreUserPreferences.DefaultKeyFunction), displayName: "Default interpolation"));
            parent.AddNode(pane);
            return(parent);
        }
Esempio n. 11
0
 public void Attach()
 {
     Instance = this;
     Panel.AddNode(ShowNodeDecorationsPanelButton);
     Panel.AddNode(ZoomWidget);
     Panel.AddNode(RulersWidget);
     Panel.AddNode(Frame);
 }
 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();
 }
Esempio n. 13
0
        private Widget CreateToolPanel()
        {
            const float Height = 50.0f;
            var         w      = new Widget {
                Height    = Height,
                MinHeight = Height,
                MaxHeight = Height,
                Layout    = new HBoxLayout()
                {
                    Spacing = 8.0f
                }
            };
            var btnClose     = CreateItemButton();
            var btnFoldAll   = CreateItemButton();
            var btnUnfoldAll = CreateItemButton();

            btnClose.Id     = "cheat_menu_close";
            btnFoldAll.Id   = "cheat_menu_fold_all";
            btnUnfoldAll.Id = "cheat_menu_unfold_all";
            Helper.DecorateButton(btnClose, NiceColors.DarkerGray, Color4.White);
            Helper.DecorateButton(btnFoldAll, NiceColors.DarkerGray, Color4.White);
            Helper.DecorateButton(btnUnfoldAll, NiceColors.DarkerGray, Color4.White);
            btnClose.MaxHeight     = Height;
            btnFoldAll.MaxHeight   = Height;
            btnUnfoldAll.MaxHeight = Height;
            btnClose.Text          = "X";
            btnFoldAll.Text        = "FoldAll";
            btnUnfoldAll.Text      = "UnfoldAll";
            w.AddNode(btnFoldAll);
            w.AddNode(btnUnfoldAll);
            w.AddNode(btnClose);
            btnClose.Clicked = Hide;
            Action <bool> fold = (foldOrUnfold) => {
                for (var i = 0; i < foldButtons.Count; i++)
                {
                    var fb = foldButtons[i];
                    if (fb == null)
                    {
                        continue;
                    }
                    var panel = itemPanels[i];
                    if (panel.Visible ^ foldOrUnfold)
                    {
                        fb.Clicked();
                    }
                }
            };

            btnFoldAll.Clicked   = () => { fold(false); };
            btnUnfoldAll.Clicked = () => { fold(true); };
            return(w);
        }
 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));
     }
 }
Esempio n. 15
0
 public CommonPropertyEditor(IPropertyEditorParams editorParams)
 {
     EditorParams    = editorParams;
     ContainerWidget = new Widget {
         Layout = new HBoxLayout {
             IgnoreHidden = false
         },
         LayoutCell = new LayoutCell {
             StretchY = 0
         },
     };
     //ContainerWidget.CompoundPostPresenter.Add(new LayoutDebugPresenter(Color4.Red, 2.0f));
     editorParams.InspectorPane.AddNode(ContainerWidget);
     if (editorParams.ShowLabel)
     {
         LabelContainer = new Widget {
             Layout     = new HBoxLayout(),
             LayoutCell = new LayoutCell {
                 StretchX = 1.0f
             },
             Nodes =
             {
                 (PropertyLabel     = new ThemedSimpleText {
                     Text           = editorParams.DisplayName ?? editorParams.PropertyName,
                     VAlignment     = VAlignment.Center,
                     LayoutCell     = new LayoutCell(Alignment.LeftCenter),
                     ForceUncutText = false,
                     Padding        = new Thickness(left: 5.0f),
                     HitTestTarget  = true,
                     TabTravesable  = new TabTraversable()
                 })
             }
         };
         PropertyLabel.Tasks.Add(ManageLabelTask());
         ContainerWidget.Tasks.Add(Tip.ShowTipOnMouseOverTask(PropertyLabel, () => PropertyLabel.Text));
         ContainerWidget.AddNode(LabelContainer);
         EditorContainer = new Widget {
             Layout     = new HBoxLayout(),
             LayoutCell = new LayoutCell {
                 StretchX = 2.0f
             },
         };
         ContainerWidget.AddNode(EditorContainer);
     }
     else
     {
         LabelContainer = EditorContainer = ContainerWidget;
     }
 }
Esempio n. 16
0
        public AlertDialog(string text, params string[] buttons)
        {
            if (buttons.Length == 0)
            {
                buttons = new[] { "Ok" };
            }
            window = new Window(new WindowOptions {
                FixedSize = true,
                Title     = "Tangerine",
                Visible   = false,
                Style     = WindowStyle.Dialog
            });
            rootWidget = new ThemedInvalidableWindowWidget(window)
            {
                LayoutBasedWindowSize = true,
                Padding = new Thickness(8),
                Layout  = new VBoxLayout {
                    Spacing = 16
                },
                Nodes =
                {
                    new ThemedSimpleText(text)
                    {
                        Padding = new Thickness(4)
                    },
                    (buttonsPanel = new Widget{
                        Layout = new HBoxLayout{
                            Spacing = 8
                        },
                        LayoutCell = new LayoutCell(Alignment.RightCenter, 1, 0),
                    })
                }
            };
            rootWidget.FocusScope = new KeyboardFocusScope(rootWidget);
            var cancelIndex = buttons.ToList().IndexOf("Cancel");

            if (cancelIndex >= 0)
            {
                result = cancelIndex;
                rootWidget.LateTasks.AddLoop(() => {
                    if (rootWidget.Input.ConsumeKeyPress(Key.Escape))
                    {
                        Close(cancelIndex);
                    }
                });
            }
            for (int i = 0; i < buttons.Length; i++)
            {
                var button = new ThemedButton {
                    Text = buttons[i]
                };
                int j = i;
                button.Clicked += () => Close(j);
                buttonsPanel.AddNode(button);
                if (i == 0)
                {
                    button.SetFocus();
                }
            }
        }
Esempio n. 17
0
        private void AddGroupHeader(string text, Widget widget)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            var label = new Widget {
                LayoutCell = new LayoutCell {
                    StretchY = 0
                },
                Layout    = new StackLayout(),
                MinHeight = Theme.Metrics.DefaultButtonSize.Y,
                Nodes     =
                {
                    new ThemedSimpleText {
                        Text           = text,
                        Padding        = new Thickness(12, 0),
                        VAlignment     = VAlignment.Center,
                        ForceUncutText = false,
                        FontHeight     = 14
                    }
                }
            };

            label.CompoundPresenter.Add(new WidgetFlatFillPresenter(ColorTheme.Current.Inspector.GroupHeaderLabelBackground));
            widget.AddNode(label);
        }
Esempio n. 18
0
            private static void BuildList(ObservableCollection <Lime.NodeComponent> source, Widget container)
            {
                var list = new Widget {
                    Layout = new VBoxLayout {
                        Spacing = 5
                    },
                    Padding = new Thickness {
                        Top = AttachmentMetrics.Spacing
                    },
                };

                container.AddNode(list);
                var validComponents = Project.Current.RegisteredComponentTypes
                                      .Where(t => NodeCompositionValidator.ValidateComponentType(typeof(Node3D), t)).ToList();
                var widgetFactory = new AttachmentWidgetFactory <NodeComponent>(w => new NodeComponentRow(w, source), source);
                var footer        = DeletableRow <NodeComponentRow> .CreateFooter(() => {
                    var menu = new Menu();
                    foreach (var type in validComponents.Except(GetExceptedTypes(source)))
                    {
                        ICommand command = new Command(CamelCaseToLabel(type.Name), () => {
                            var constructor = type.GetConstructor(Type.EmptyTypes);
                            history.DoTransaction(() => Core.Operations.InsertIntoList.Perform(
                                                      source, source.Count, constructor.Invoke(new object[] { })));
                        });
                        menu.Add(command);
                    }
                    menu.Popup();
                });

                footer.AddChangeWatcher(() => validComponents.Except(GetExceptedTypes(source)).Any(), any => footer.Visible = any);
                widgetFactory.AddFooter(footer);
                list.Components.Add(widgetFactory);
            }
Esempio n. 19
0
 public GridPane(Timeline timeline)
 {
     this.timeline           = timeline;
     timeline.OffsetChanged += value => ContentWidget.Position = -value;
     RootWidget              = new Frame {
         Id     = nameof(GridPane),
         Layout = new StackLayout {
             HorizontallySizeable = true, VerticallySizeable = true
         },
         ClipChildren  = ClipMethod.ScissorTest,
         HitTestTarget = true,
     };
     ContentWidget = new Widget {
         Id      = nameof(GridPane) + "Content",
         Padding = new Thickness {
             Top = 1, Bottom = 1
         },
         Layout = new VBoxLayout {
             Spacing = TimelineMetrics.RowSpacing
         },
         Presenter     = new DelegatePresenter <Node>(RenderBackgroundAndGrid),
         PostPresenter = new DelegatePresenter <Widget>(w => OnPostRender(w))
     };
     RootWidget.AddNode(ContentWidget);
     RootWidget.AddChangeWatcher(() => RootWidget.Size,
                                 // Some document operation processors (e.g. ColumnCountUpdater) require up-to-date timeline dimensions.
                                 _ => Core.Operations.Dummy.Perform());
     OnPostRender += RenderCursor;
     OnPostRender += RenderSelection;
     RootWidget.Tasks.Add(HandleRightClickTask);
 }
Esempio n. 20
0
 public CommonPropertyEditor(IPropertyEditorParams editorParams)
 {
     EditorParams    = editorParams;
     ContainerWidget = new Widget {
         Layout = new HBoxLayout {
             IgnoreHidden = false
         },
         LayoutCell = new LayoutCell {
             StretchY = 0
         },
     };
     editorParams.InspectorPane.AddNode(ContainerWidget);
     if (editorParams.ShowLabel)
     {
         PropertyLabel = new ThemedSimpleText {
             Text           = editorParams.DisplayName ?? editorParams.PropertyName,
             VAlignment     = VAlignment.Center,
             LayoutCell     = new LayoutCell(Alignment.LeftCenter, stretchX: 0),
             ForceUncutText = false,
             MinWidth       = 120,
             OverflowMode   = TextOverflowMode.Minify,
             HitTestTarget  = true,
             TabTravesable  = new TabTraversable()
         };
         PropertyLabel.Tasks.Add(ManageLabelTask());
         ContainerWidget.AddNode(PropertyLabel);
     }
 }
Esempio n. 21
0
        public Item Item(string text, Action action, Func <bool> enabled = null)
        {
            var b = Menu.CreateItemButton();

            Helper.DecorateButton(b, NiceColors.BasicColor(colorIndex));
            b.Id = Helper.TrimTextForId(text);
            var item = new Item(b)
            {
                Text    = text,
                Action  = action,
                Enabled = enabled ?? (() => true),
                Parent  = this
            };

            Menu.RegisterCheatButton(item.CheatIdText(), b);
            {
                b.Text = item.Text;
                Helper.UpdateButtonSizeConstraints(b);
            }
            b.Clicked = () => {
                item.Action();
                Menu.Hide();
            };
            b.Enabled = item.Enabled();
            ItemPanel.AddNode(b);
            return(item);
        }
Esempio n. 22
0
 private void RefreshLabels(Widget widget, AnimationTrack track)
 {
     widget.Nodes.Clear();
     foreach (var clip in track.Clips)
     {
         var clipLabel   = clip.AnimationId;
         var beginMarker = clip.FindAnimation()?.Markers.GetByFrame(clip.InFrame);
         var endMarker   = clip.FindAnimation()?.Markers.GetByFrame(clip.InFrame + clip.DurationInFrames);
         if (beginMarker != null || endMarker != null)
         {
             clipLabel +=
                 " (" + (beginMarker?.Id ?? clip.InFrame.ToString()) + ".." +
                 (endMarker?.Id ?? (clip.InFrame + clip.DurationInFrames).ToString()) + ")";
         }
         widget.AddNode(new SimpleText {
             Position     = new Vector2((clip.BeginFrame + 0.5f) * TimelineMetrics.ColWidth, 0),
             Size         = new Vector2((clip.DurationInFrames + 0.5f) * TimelineMetrics.ColWidth, widget.Height),
             Localizable  = false,
             Text         = clipLabel,
             Padding      = new Thickness(4),
             VAlignment   = VAlignment.Center,
             OverflowMode = TextOverflowMode.Ellipsis,
             Color        = ColorTheme.Current.TimelineGrid.AnimationClipLabel
         });
     }
 }
        private void CheckWarnings()
        {
            bool IsBoneWeightValid(float weight) => weight == Mathf.Clamp(weight, 0, 1);

            bool isOutOfRange = false;

            foreach (var slider in weightsSliders)
            {
                isOutOfRange |= !IsBoneWeightValid(slider.Value);
            }
            if (isOutOfRange)
            {
                if (customWarningsContainer.Nodes.Count == 0)
                {
                    customWarningsContainer.AddNode(
                        CommonPropertyEditor.CreateWarning(
                            message: "Bone weight should be in the range [0, 1].",
                            validationResult: ValidationResult.Warning));
                }
            }
            else
            {
                customWarningsContainer.Nodes.Clear();
            }
        }
Esempio n. 24
0
 public void TestSetUp()
 {
     root = new Widget {
         Id = "Root"
     };
     child1 = new Widget {
         Id = "Child1"
     };
     child2 = new Widget {
         Id = "Child2"
     };
     grandChild = new Widget {
         Id = "Grandchild"
     };
     root.AddNode(child1);
     root.AddNode(child2);
     child1.AddNode(grandChild);
 }
Esempio n. 25
0
            public VisualHintEditor(VisualHint hint, float leftOffset = 0f)
            {
                this.hint = hint;
                Layout    = new VBoxLayout();

                if (hint.Command != null)
                {
                    BooleanEditor = new BooleanEditor(hint.Command);
                }
                else
                {
                    BooleanEditor = new BooleanEditor(hint.Title);
                }
                BooleanEditor.Changed       += e => CheckHandle(e);
                BooleanEditor.Checked        = hint.Enabled;
                BooleanEditor.CommandIssued += () => CheckSelfAndChildren(BooleanEditor.Checked);

                var rowWidget = new Widget {
                    Layout  = new HBoxLayout(),
                    Padding = new Thickness {
                        Left = leftOffset
                    }
                };

                rowWidget.AddNode(hint.SubHints.Count > 0 ? (button = CreateExpandButton()) : offsetWidget.Clone());
                rowWidget.AddNode(BooleanEditor);
                AddNode(rowWidget);
                container = new Widget {
                    Layout = new VBoxLayout()
                };
                foreach (var subHint in hint.SubHints.Values)
                {
                    if (subHint.Hidden)
                    {
                        continue;
                    }
                    container.AddNode(new VisualHintEditor(subHint, leftOffset + 23)
                    {
                        parent = this
                    });
                }
                rowWidget.AddChangeWatcher(() => hint.Expanded, _ => HandleExpanded());
                TryCheckAll(traverseParents: false);
            }
Esempio n. 26
0
 void InitializeWidgets()
 {
     RootWidget.AddChangeWatcher(() => selection.Version, Selection_Changed);
     scrollView.Content.Layout = new FlowLayout {
         Spacing = 1.0f
     };
     scrollView.Content.Padding = new Thickness(5.0f);
     scrollView.Content.CompoundPostPresenter.Insert(0, new DelegatePresenter <Widget>(RenderFilesWidgetRectSelection));
     scrollView.Updated          += ScrollViewUpdated;
     scrollView.Content.Presenter = new DelegatePresenter <Widget>((w) => {
         w.PrepareRendererState();
         var wp = w.ParentWidget;
         var p  = wp.Padding;
         Renderer.DrawRect(-w.Position + Vector2.Zero - new Vector2(p.Left, p.Top),
                           -w.Position + wp.Size + new Vector2(p.Right, p.Bottom), Theme.Colors.WhiteBackground);
     });
     RootWidget.AddChangeWatcher(() => dragState, (ds) => Window.Current.Invalidate());
     RootWidget.AddChangeWatcher(() => dragEndPosition, WhenSelectionRectChanged);
     RootWidget.AddChangeWatcher(() => WidgetContext.Current.NodeUnderMouse, (value) => {
         if (value != null && scrollView.Content == value.Parent)
         {
             Window.Current.Invalidate();
         }
     });
     RootWidget.AddChangeWatcher(() => model.CurrentPath, (p) => {
         var up  = RootWidget.Components.Get <ViewNodeComponent>().ViewNode as FSViewNode;
         up.Path = p;
         AddToNavHystory(p);
         selection.Clear();
         InvalidateView(p);
         InvalidateFSWatcher(p);
         preview.ClearTextureCache();
         lastKeyboardSelectedFilesystemItem = scrollView.Content.FirstChild as FilesystemItem;
     });
     RootWidget.Layout = new VBoxLayout();
     RootWidget.AddNode((cookingRulesSplitter = new ThemedHSplitter {
         Nodes =
         {
             (new Widget {
                 Layout = new VBoxLayout(),
                 Nodes =
                 {
                     toolbar,
                     (selectionPreviewSplitter = new ThemedVSplitter{
                         Nodes =
                         {
                             scrollView,
                             preview.RootWidget,
                         }
                     })
                 }
             }),
             crEditor.RootWidget,
         }
     }));
 }
Esempio n. 27
0
            static Frame CreateItemFrame(int index, Widget canvas, Vector2 cellSize)
            {
                var rect  = GetPlacementRect(index, cellSize, canvas.Size);
                var frame = new Frame {
                    Position = rect.A, Size = cellSize
                };

                canvas.AddNode(frame);
                return(frame);
            }
Esempio n. 28
0
 protected void Rebuild()
 {
     widgetCache.Clear();
     Container.Nodes.Clear();
     foreach (var item in Source)
     {
         var row = rowBuilder(item);
         widgetCache.Add(item, row);
         Container.AddNode(row);
     }
 }
Esempio n. 29
0
        private void AddComponentsMenu(IReadOnlyList <Node> nodes, Widget widget)
        {
            if (nodes.Any(n => !string.IsNullOrEmpty(n.ContentsPath)))
            {
                return;
            }

            var nodesTypes = nodes.Select(n => n.GetType()).ToList();
            var types      = new List <Type>();

            foreach (var type in Project.Current.RegisteredComponentTypes)
            {
                if (
                    !nodes.All(n => n.Components.Contains(type)) &&
                    nodesTypes.All(t => NodeCompositionValidator.ValidateComponentType(t, type))
                    )
                {
                    types.Add(type);
                }
            }
            types.Sort((a, b) => a.Name.CompareTo(b.Name));

            var label = new Widget {
                LayoutCell = new LayoutCell {
                    StretchY = 0
                },
                Layout    = new HBoxLayout(),
                MinHeight = Theme.Metrics.DefaultButtonSize.Y,
                Nodes     =
                {
                    new ThemedAddButton  {
                        Clicked = () =>  {
                            var menu = new Menu();
                            foreach (var type in types)
                            {
                                ICommand command = new Command(CamelCaseToLabel(type.Name), () => CreateComponent(type, nodes));
                                menu.Add(command);
                            }
                            menu.Popup();
                        },
                        Enabled = types.Count > 0
                    },
                    new ThemedSimpleText {
                        Text           = "Add Component",
                        Padding        = new Thickness(4, 0),
                        VAlignment     = VAlignment.Center,
                        ForceUncutText = false,
                    }
                }
            };

            label.CompoundPresenter.Add(new WidgetFlatFillPresenter(ColorTheme.Current.Inspector.CategoryLabelBackground));
            widget.AddNode(label);
        }
Esempio n. 30
0
		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());
		}