Exemplo n.º 1
0
        /// <inheritdoc />
        protected override void BuildPartUI(VisualElement container)
        {
            if (!(m_Model is INodeModel nodeModel))
            {
                return;
            }

            m_Root = new VisualElement {
                name = PartName
            };
            m_Root.AddToClassList(ussClassName);
            m_Root.AddToClassList(m_ParentClassName.WithUssElement(PartName));

            TitleContainer = new VisualElement();
            TitleContainer.AddToClassList(ussClassName.WithUssElement("title-container"));
            TitleContainer.AddToClassList(m_ParentClassName.WithUssElement("title-container"));
            m_Root.Add(TitleContainer);

            var icon = new VisualElement();

            icon.AddToClassList(ussClassName.WithUssElement("icon"));
            icon.AddToClassList(m_ParentClassName.WithUssElement("icon"));
            if (!string.IsNullOrEmpty(nodeModel.IconTypeString))
            {
                icon.AddToClassList(ussClassName.WithUssElement("icon").WithUssModifier(nodeModel.IconTypeString));
                icon.AddToClassList(m_ParentClassName.WithUssElement("icon").WithUssModifier(nodeModel.IconTypeString));
            }
            TitleContainer.Add(icon);

            if (HasEditableLabel)
            {
                TitleLabel = new EditableLabel {
                    name = titleLabelName
                };
                TitleLabel.RegisterCallback <ChangeEvent <string> >(OnRename);
            }
            else
            {
                TitleLabel = new Label {
                    name = titleLabelName
                };
            }

            TitleLabel.AddToClassList(ussClassName.WithUssElement("title"));
            TitleLabel.AddToClassList(m_ParentClassName.WithUssElement("title"));
            TitleContainer.Add(TitleLabel);

            if (nodeModel is IHasProgress hasProgress && hasProgress.HasProgress)
            {
                CoroutineProgressBar = new ProgressBar();
                CoroutineProgressBar.AddToClassList(ussClassName.WithUssElement("progress-bar"));
                CoroutineProgressBar.AddToClassList(m_ParentClassName.WithUssElement("progress-bar"));
                TitleContainer.Add(CoroutineProgressBar);
            }

            container.Add(m_Root);
        }
        /// <inheritdoc />
        protected override void BuildPartUI(VisualElement container)
        {
            if (m_Model is IStickyNoteModel)
            {
                TextLabel = new EditableLabel {
                    name = PartName
                };
                TextLabel.multiline = true;
                TextLabel.RegisterCallback <ChangeEvent <string> >(OnRename);
                TextLabel.AddToClassList(m_ParentClassName.WithUssElement(PartName));

                container.Add(TextLabel);
            }
        }