Пример #1
0
        private Style GetCheckBoxStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .TemplateBinding(Control.BackgroundProperty, Control.BackgroundProperty)
                           .TemplateBinding(Control.BorderBrushProperty, Control.BorderThicknessProperty)
                           .TemplateBinding(Control.BorderThicknessProperty, Control.BorderThicknessProperty)
                           .Contains <StackPanel>()
                           .Set(StackPanel.OrientationProperty, Orientation.Horizontal)
                           .Contains(TemplateExtensions.Create <Ellipse>()
                                     .Size(8, 8)
                                     .TemplateBinding(Shape.FillProperty, Control.ForegroundProperty))
                           .Contains(TemplateExtensions.Create <ContentPresenter>()
                                     .Center())
                           .AsControlTemplate <CheckBox>();

            return(StyleExtensions.Create()
                   .Set(Control.ForegroundProperty, colors.Text.Normal)
                   .When(TriggerExtensions.Property(ToggleButton.IsCheckedProperty)
                         .Is(true)
                         .Then(Control.FontWeightProperty, FontWeights.Bold)
                         .Then(Control.ForegroundProperty, colors.Control.Selected))
                   .When(TriggerExtensions.Property(UIElement.IsMouseOverProperty)
                         .Is(true)
                         .Then(Control.BackgroundProperty, colors.Control.Over))
                   .When(TriggerExtensions.Property(FrameworkElement.TagProperty)
                         .Is("test")
                         .Then(ContentControl.ContentProperty, null))
                   .Template(template)
                   .AsStyle <CheckBox>());
        }
Пример #2
0
 private Style GetTextBlockStyle(IThemeColors colors)
 {
     return(StyleExtensions.Create()
            .Set(Control.FontSizeProperty, 16d)
            .Set(Control.ForegroundProperty, colors.Text.Normal)
            .AsStyle <TextBlock>());
 }
Пример #3
0
        private Style GetExpanderStyle(IThemeColors colors)
        {
            if (HambergerMenu == null)
            {
                var hambergerTemplate = TemplateExtensions.Create <StackPanel>()
                                        .Contains(TemplateExtensions.Create <DockPanel>()
                                                  .Set(Control.BackgroundProperty, colors.Control.Normal)
                                                  .Contains(TemplateExtensions.Create <ToggleButton>()
                                                            .Set(ContentControl.ContentProperty, "☰")
                                                            .Set(FrameworkElement.MarginProperty, new Thickness(4))
                                                            .Set(Control.FontFamilyProperty, new FontFamily("Segoe UI Symbol"))
                                                            .Set(DockPanel.DockProperty, Dock.Left)
                                                            .Set(Control.FontSizeProperty, 18d)
                                                            .TemplateBinding(ToggleButton.IsCheckedProperty, Expander.IsExpandedProperty))
                                                  .Contains(TemplateExtensions.Create <ContentPresenter>()
                                                            .Set(FrameworkElement.MarginProperty, new Thickness(4))
                                                            .Set(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center)
                                                            .Set(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center)
                                                            .Set(ContentPresenter.ContentSourceProperty, "Header")))
                                        .Contains(TemplateExtensions.Create <ContentPresenter>()
                                                  .Set(ContentPresenter.ContentSourceProperty, "Content")
                                                  .TemplateBinding(UIElement.VisibilityProperty, Expander.IsExpandedProperty, new BooleanToVisibilityConverter()))
                                        .AsControlTemplate <Expander>();

                HambergerMenu = StyleExtensions.Create()
                                .Template(hambergerTemplate)
                                .AsStyle <Expander>();
            }
            return(null);
        }
Пример #4
0
 private Style GetListBoxStyle(IThemeColors colors)
 {
     return(StyleExtensions.Create()
            .Set(Control.PaddingProperty, new Thickness(0, 4, 0, 0))
            .Set(Control.BackgroundProperty, colors.Control.Normal)
            .Set(Control.BorderBrushProperty, colors.Control.Accent1)
            .Set(Control.BorderThicknessProperty, new Thickness(0, 1, 0, 0))
            .AsStyle <ListBox>());
 }
Пример #5
0
        internal void InitialiseWithConfiguration(AssetListConfiguration configuration)
        {
            rootVisualElement.Clear();

            bool changedConfiguration = this.configuration != configuration;

            this.configuration = configuration;
            objects            = AssetListUtility.LoadAssetsByTypeName(configuration.TypeString, out type, out isComponent, configuration.AssetContext);
            GUIContent objectContent = EditorGUIUtility.ObjectContent(null, type);

            titleContent = new GUIContent(configuration.name, objectContent.image);

            if (treeViewState == null)
            {
                treeViewState = new TreeViewState();
            }

            var headerState = new MultiColumnHeaderState(GetColumnsFromConfiguration(configuration));

            if (MultiColumnHeaderState.CanOverwriteSerializedFields(multiColumnHeaderState, headerState))
            {
                MultiColumnHeaderState.OverwriteSerializedFields(multiColumnHeaderState, headerState);
            }

            if (changedConfiguration)
            {
                initialisedSizes       = false;
                multiColumnHeaderState = headerState;
            }

            var multiColumnHeader = new MultiColumnHeader(headerState);

            treeView = new MultiColumnTreeView(treeViewState, multiColumnHeader, this);

            (StyleSheet styleSheet, VisualTreeAsset uxml) = StyleExtensions.GetStyleSheetAndUXML("AssetList");
            uxml.CloneTree(rootVisualElement);
            rootVisualElement.styleSheets.Add(styleSheet);

            var    toolbarSearchField = rootVisualElement.Q <ToolbarSearchField>("SearchField");
            string searchString       = treeView.searchString;

            if (searchString != null)
            {
                toolbarSearchField.SetValueWithoutNotify(treeView.searchString);
            }
            toolbarSearchField.RegisterValueChangedCallback(evt => treeView.searchString = evt.newValue);

            var toolbarMenu = rootVisualElement.Q <ToolbarMenu>("ExportMenu");

            toolbarMenu.menu.AppendAction("TSV", action => ExportToTSV());

            assetListContainer = rootVisualElement.Q <IMGUIContainer>("AssetList");
            assetListContainer.onGUIHandler = MultiColumnListGUI;
        }
Пример #6
0
        private Style GetTabControlStyle(IThemeColors colors)
        {
            /*var template = TemplateExtensions.Create<ItemsPresenter>()
             * .AsControlTemplate<TabControl>();*/

            return(StyleExtensions.Create()
                   .Set(Control.PaddingProperty, new Thickness(0))
                   .Set(Control.BorderThicknessProperty, new Thickness(0))
                   .Set(Control.BackgroundProperty, colors.Control.Normal)
                   .AsStyle <TabControl>());
        }
Пример #7
0
        private Style GetToggleButtonStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .TemplateBinding(Border.BackgroundProperty, ToggleButton.BackgroundProperty)
                           .Contains(TemplateExtensions.Create <ContentPresenter>())
                           .AsControlTemplate <ToggleButton>();

            return(StyleExtensions.Create()
                   .Set(Control.ForegroundProperty, colors.Text.Normal)
                   .Set(Control.BackgroundProperty, new SolidColorBrush(Colors.Transparent))
                   .When(TriggerExtensions.Property(UIElement.IsMouseOverProperty)
                         .Is(true)
                         .Then(Control.BackgroundProperty, colors.Control.Over))
                   .Template(template)
                   .AsStyle <ToggleButton>());
        }
Пример #8
0
        private void InitialiseWithoutConfiguration()
        {
            rootVisualElement.Clear();

            var data = StyleExtensions.GetStyleSheetAndUXML("BlankAssetList");

            data.Item2.CloneTree(rootVisualElement);
            rootVisualElement.styleSheets.Add(data.Item1);
            rootVisualElement.Q <DragAndDropBox>("DropTarget").RegisterSingle(CreateNewWindow);
            var container = rootVisualElement.Q <VisualElement>("ListViewContainer");

            AssetListConfiguration[] configurations = EditorUtils.LoadAssetsOfType <AssetListConfiguration>();
            if (configurations.Length == 0)
            {
                container.RemoveFromHierarchy();
            }
            else
            {
                var listView = container.Q <ListView>("ListView");
                foreach (AssetListConfiguration configAsset in configurations)
                {
                    var button = new Button(() => InitialiseWithConfiguration(configAsset))
                    {
                        text = configAsset.name
                    };
                    button.AddToClassList("listViewButton");
                    listView.Add(button);
                }
            }

            void CreateNewWindow(Object o)
            {
                AssetListConfiguration listConfiguration = CreateInstance <AssetListConfiguration>();

                listConfiguration.Configure(o);
                string name = o.GetType().Name;
                string path = EditorUtility.SaveFilePanelInProject($"Create New {name} List Configuration", $"{name} List", "asset", $"Save a Configuration asset for {name} List");

                if (string.IsNullOrEmpty(path))
                {
                    return;
                }
                AssetDatabase.CreateAsset(listConfiguration, path);
                InitialiseWithConfiguration(listConfiguration);
            }
        }
Пример #9
0
        private Style GetContextMenuStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .TemplateBinding(Control.BackgroundProperty, Control.BackgroundProperty)
                           .TemplateBinding(Control.BorderBrushProperty, Control.BorderBrushProperty)
                           .TemplateBinding(Control.BorderThicknessProperty, Control.BorderThicknessProperty)
                           .Contains(TemplateExtensions.Create <StackPanel>()
                                     .Set(Panel.IsItemsHostProperty, true))
                           .AsControlTemplate <ContextMenu>();

            return(StyleExtensions.Create()
                   .Set(Control.ForegroundProperty, colors.Text.Normal)
                   .Set(Control.BackgroundProperty, colors.Control.Accent1)
                   .Set(Control.BorderBrushProperty, colors.Control.Accent1)
                   .Set(Control.BorderThicknessProperty, new Thickness(1))
                   .Template(template)
                   .AsStyle <ContextMenu>());
        }
Пример #10
0
        public override bool Contains(Path file)
        {
            if (IsCSSOnly)
            {
                return(file == location);
            }
            else
            {
                if (!Folder.Contains(file))
                {
                    return(false);
                }

                string extension = file.Extension;

                return(StyleExtensions.Contains(extension) || Files.Manager.ImageExtensions.Contains(extension));
            }
        }
Пример #11
0
        private Style GetMenuItemStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .TemplateBinding(Control.BackgroundProperty, MenuItem.BackgroundProperty)
                           .Contains(TemplateExtensions.Create <ContentPresenter>()
                                     .Set(Control.MarginProperty, new Thickness(8))
                                     .Set(ContentPresenter.ContentSourceProperty, "Header"))
                           .AsControlTemplate <MenuItem>();

            return(StyleExtensions.Create()
                   .Set(Control.ForegroundProperty, colors.Text.Normal)
                   .Set(Control.BackgroundProperty, colors.Control.Normal)
                   .When(TriggerExtensions
                         .Property(Control.IsMouseOverProperty)
                         .Is(true)
                         .Then(Control.BackgroundProperty, colors.Control.Over))
                   .Template(template)
                   .AsStyle <MenuItem>());
        }
Пример #12
0
        private Style GetDropDownButtonStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .TemplateBinding(Control.BackgroundProperty, Control.BackgroundProperty)
                           .TemplateBinding(Border.PaddingProperty, Button.PaddingProperty)
                           .Contains(TemplateExtensions.Create <ContentPresenter>()
                                     .Set(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center)
                                     .Set(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center)
                                     .TemplateBinding(ContentPresenter.ContentProperty, ContentControl.ContentProperty))
                           .AsControlTemplate <DropDownButton>();

            return(StyleExtensions.Create()
                   .Set(Control.BackgroundProperty, new SolidColorBrush(Colors.Transparent))
                   .Set(Control.PaddingProperty, new Thickness(8, 4, 8, 4))
                   .When(TriggerExtensions.Property(UIElement.IsMouseOverProperty)
                         .Is(true)
                         .Then(Control.BackgroundProperty, colors.Control.Accent1))
                   .Template(template)
                   .AsStyle <DropDownButton>());
        }
        private Style GetHeaderContentControlStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <DockPanel>()
                           .Contains(TemplateExtensions.Create <Border>()
                                     //.Set(Border.CornerRadiusProperty, new CornerRadius(3, 3, 0, 0))
                                     .Set(Control.BackgroundProperty, colors.Control.Accent1)
                                     //.Set(Border.BorderBrushProperty, colors.Outline.Normal)
                                     //.Set(Border.BorderThicknessProperty, new Thickness(1,1,1,0))
                                     .Set(DockPanel.DockProperty, Dock.Top)
                                     .Contains(TemplateExtensions.Create <ContentPresenter>()
                                               .Set(ContentPresenter.ContentSourceProperty, "Header")
                                               .Set(FrameworkElement.MarginProperty, new Thickness(4))))
                           .Contains(TemplateExtensions.Create <Border>()
                                     .Set(Control.BackgroundProperty, colors.Control.Accent2)
                                     .Set(Border.BorderBrushProperty, colors.Outline.Normal)
                                     .Set(Border.BorderThicknessProperty, new Thickness(1, 1, 1, 1))
                                     .Contains(TemplateExtensions.Create <ContentPresenter>()))
                           .AsControlTemplate <HeaderedContentControl>();

            return(StyleExtensions.Create()
                   .Template(template)
                   .AsStyle <HeaderedContentControl>());
        }
Пример #14
0
        private Style GetListBoxItemStyle(IThemeColors colors)
        {
            var template = TemplateExtensions.Create <Border>()
                           .Set(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Stretch)
                           .Contains(TemplateExtensions.Create <ContentPresenter>())
                           .TemplateBinding(Border.BackgroundProperty, ListBoxItem.BackgroundProperty)
                           .AsControlTemplate <ListBoxItem>();

            return(StyleExtensions.Create()
                   .Template(template)
                   .Set(Control.PaddingProperty, new Thickness(0, 4, 0, 0))
                   .Set(Control.BackgroundProperty, colors.Control.Normal)
                   .Set(Control.BorderBrushProperty, colors.Control.Accent1)
                   .Set(Control.BorderThicknessProperty, new Thickness(0, 1, 0, 0))
                   .When(TriggerExtensions
                         .Property(ListBoxItem.IsMouseOverProperty)
                         .Is(true)
                         .Then(ListBoxItem.BackgroundProperty, colors.Control.Over))
                   .When(TriggerExtensions
                         .Property(ListBoxItem.IsSelectedProperty)
                         .Is(true)
                         .Then(ListBoxItem.BackgroundProperty, colors.Control.Selected))
                   .AsStyle <ListBoxItem>());
        }
Пример #15
0
        public SearchView()
        {
            var bmp = new BitmapImage(new Uri(@"pack://application:,,,/Resources/no-artist.png", UriKind.Absolute));

            var dataTemplate = TemplateExtensions.Create <DockPanel>()
                               .Contains(TemplateExtensions.Create <Image>()
                                         .Set(DockPanel.DockProperty, Dock.Left)
                                         .Set(Control.HeightProperty, 25d)
                                         .Set(Control.WidthProperty, 25d)
                                         .Bind(Image.SourceProperty, nameof(IArtist.PictureUri), null, bmp))
                               .Contains(TemplateExtensions.Create <TextBlock>()
                                         .Set(Control.MarginProperty, new Thickness(8, 0, 0, 0))
                                         .Set(Control.VerticalAlignmentProperty, VerticalAlignment.Center)
                                         .Set(Control.MaxWidthProperty, 250d)
                                         .Set(Control.HorizontalAlignmentProperty, HorizontalAlignment.Left)
                                         .Set(TextBlock.TextWrappingProperty, TextWrapping.WrapWithOverflow)
                                         .Bind(TextBlock.TextProperty, nameof(IArtist.Name)))
                               .AsDataTemplate <IArtist>();

            var navigationButtonStyle = StyleExtensions.Create()
                                        .BasedOn <Button>()
                                        .Set(Control.HorizontalAlignmentProperty, HorizontalAlignment.Left)
                                        .Set(FrameworkElement.MarginProperty, new Thickness(4))
                                        .Set(Control.FontSizeProperty, 18d)
                                        .Set(Control.FontFamilyProperty, new FontFamily("Segoe UI symbol"))
                                        .When(TriggerExtensions
                                              .Property(FrameworkElement.IsEnabledProperty)
                                              .Is(false)
                                              .Then(FrameworkElement.VisibilityProperty, Visibility.Hidden))
                                        .AsStyle <Button>();

            this.fluentItem = this.AsFluent <TabItem>()
                              .Bind(BindingExtensions
                                    .OneTime(FrameworkElement.DataContextProperty)
                                    .With(nameof(RootViewModel.Search)))
                              .Set(FrameworkElement.VisibilityProperty, Visibility.Collapsed)
                              .Contains(new Grid()
                                        .AsFluent()
                                        .Margin(0, 25, 0, 0)
                                        .Cell(GridCellExtensions.Create()
                                              .Contains(new Button()
                                                        .AsFluent()
                                                        .UseStyle(navigationButtonStyle)
                                                        .Contains("")
                                                        .SubDataContext(nameof(SearchViewModel.NavigationViewModel))
                                                        .Bind(BindingExtensions
                                                              .OneTime(ButtonBase.CommandProperty)
                                                              .With(nameof(SearchNavigationViewModel.GoBackCommand)))))
                                        .Cell(GridCellExtensions.Create()
                                              .Column(1).AutoWidth()
                                              .Contains(new TextBlock()
                                                        .AsFluent()
                                                        .Set(FrameworkElement.MarginProperty, new Thickness(4))
                                                        .Set(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center)
                                                        .Set(TextBlock.TextProperty, "Search")))
                                        .Cell(GridCellExtensions.Create()
                                              .Column(2).Width("*")
                                              .Contains(new TextBox()
                                                        .AsFluent()
                                                        .Bind(BindingExtensions
                                                              .TwoWay(TextBox.TextProperty)
                                                              .With(nameof(SearchViewModel.Search)))
                                                        .Set(FrameworkElement.MarginProperty, new Thickness(4))
                                                        .Set(TextBox.VerticalContentAlignmentProperty, VerticalAlignment.Center)
                                                        .On(TextBoxBase.KeyUpEvent, OnTextChanged)))
                                        .Cell(GridCellExtensions.Create()
                                              .Column(3).AutoWidth()
                                              .Contains(new DropDownButton()
                                                        .AsFluent()
                                                        .Contains("⋮")
                                                        .Set(Control.FontFamilyProperty, new FontFamily("Segoe UI symbol"))
                                                        .Set(Control.FontSizeProperty, 18d)
                                                        .Set(Control.ContextMenuProperty, SearchContextMenuBuilder.Create())))
                                        .Cell(GridCellExtensions.Create()
                                              .Row(1).Span(1, 4).Height("*")
                                              .Contains(new ListBox()
                                                        .AsFluent()
                                                        .Set(ListBox.MarginProperty, new Thickness(4))
                                                        .Set(ListBox.ItemTemplateProperty, dataTemplate)
                                                        .Bind(BindingExtensions
                                                              .OneWay(ListBox.ItemsSourceProperty)
                                                              .With(nameof(SearchViewModel.Artists)))
                                                        ))
                                        );
        }
Пример #16
0
        public override VisualElement CreateInspectorGUI()
        {
            (StyleSheet styleSheet, VisualTreeAsset uxml) = StyleExtensions.GetStyleSheetAndUXML("PackageUpdater");
            packageItemUXML = StyleExtensions.GetUXML("PackageItem");

            root = new VisualElement();
            root.styleSheets.Add(styleSheet);
            root.styleSheets.Add(StyleExtensions.GetStyleSheet("VertxShared"));
            uxml.CloneTree(root);

            packageRoot  = root.Q("Packages Root");
            addRoot      = root.Q("Add Root");
            addContainer = addRoot.Q("Add Container");
            search       = addContainer.Q <ToolbarSearchField>("Search");
            search.RegisterCallback <ChangeEvent <string> >(Search);

            if (updatingPackages.arraySize == 0)
            {
                AddHelpBox();
            }
            else
            {
                for (int i = 0; i < updatingPackages.arraySize; i++)
                {
                    AddTrackedPackage(i);
                }
            }

            //-----------------------------------------------------
            addButton = addRoot.Q <Button>("Add Button");
            addButton.SetEnabled(false);
            addButton.clickable.clicked += PopulateAdd;
            listView = addRoot.Q <ListView>("Add Contents");
            // List view configuration
            listView.makeItem = () =>
            {
                Label button = new Label();
                button.AddToClassList("addPackageItemButton");
                return(button);
            };
            listView.bindItem = (element, i) =>
            {
                string packageName = (string)listView.itemsSource[i];
                ((Label)element).text = packageName;
            };
                        #if UNITY_2020_1_OR_NEWER
            listView.onItemsChosen += objects =>
            {
                int c = untrackedPackages.Count;
                foreach (var o in objects)
                {
                    //Add package so it can be tracked by the Package Updater.
                    string packageName = (string)o;
                    int    index       = updatingPackages.arraySize++;
                    updatingPackages.GetArrayElementAtIndex(index).FindPropertyRelative(ignoreProp).stringValue = null;
                    AddTrackedPackage(index, packageName);
                    serializedObject.ApplyModifiedProperties();
                    listView.Clear();
                    addContainer.AddToClassList(hiddenStyle);
                    c--;
                }

                //Disable the add button if there will be no more packages.
                if (c <= 0)
                {
                    DisableAddButton();
                }
                else
                {
                    EnableAddButton();
                }
            };
                        #else
            listView.onItemChosen += o =>
            {
                //Disable the add button if there will be no more packages.
                if (untrackedPackages.Count <= 1)
                {
                    DisableAddButton();
                }
                else
                {
                    EnableAddButton();
                }

                //Add package so it can be tracked by the Package Updater.
                string packageName = (string)o;
                int    index       = updatingPackages.arraySize++;
                AddTrackedPackage(index, packageName);
                serializedObject.ApplyModifiedProperties();
                listView.Clear();
                addContainer.AddToClassList(hiddenStyle);
            };
                        #endif
            addContainer.AddToClassList(hiddenStyle);
            //-----------------------------------------------------

            updateButton = root.Q <Button>("Update Button");
            updateButton.SetEnabled(false);
            updateButton.clickable.clicked += DoUpdate;

            var helpBox = root.Q <HelpBox>("Auto Update Help Box");
            helpBox.Q <Label>(className: HelpBox.uSSLabelClassName).text
                = NUtilitiesPreferences.AutoUpdatePackages ? "Auto-Update is enabled." : "Auto-Update is disabled.";
            helpBox.RegisterCallback <MouseUpEvent>(evt => SettingsService.OpenUserPreferences(NUtilitiesPreferences.PreferencesPath));

            ValidateAddButton();
            ValidatePackages();

            return(root);
        }
Пример #17
0
 private Style GetWindowStyle(IThemeColors colors)
 {
     return(StyleExtensions.Create()
            .Set(Control.BackgroundProperty, colors.Control.Normal)
            .AsStyle <Window>());
 }
Пример #18
0
 public HelpBox()
 {
     styleSheets.Add(StyleExtensions.GetStyleSheet("HelpBox"));
     AddToClassList(uSSClassName);
 }