Exemplo n.º 1
0
            /// <summary>
            /// Initializes <see cref="RadioButtonGroup"/> properties using values from the attribute bag.
            /// </summary>
            /// <param name="ve">The object to initialize.</param>
            /// <param name="bag">The attribute bag.</param>
            /// <param name="cc">The creation context; unused.</param>
            public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ve, bag, cc);

                var f = (RadioButtonGroup)ve;

                f.choices = ParseChoiceList(m_Choices.GetValueFromBag(bag, cc));
            }
            public override void Init(ref T obj, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ref obj, bag, cc);

                obj.columnName  = m_ColumnName.GetValueFromBag(bag, cc);
                obj.columnIndex = m_ColumnIndex.GetValueFromBag(bag, cc);
                obj.direction   = m_SortDescription.GetValueFromBag(bag, cc);
            }
Exemplo n.º 3
0
            /// <summary>
            /// Initializer for the <see cref="UxmlTraits"/> for the <see cref="TextElement"/>.
            /// </summary>
            /// <param name="ve"><see cref="VisualElement"/> to initialize.</param>
            /// <param name="bag">Bag of attributes where to get the value from.</param>
            /// <param name="cc">Creation Context, not used.</param>
            public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ve, bag, cc);

                var textElement = (TextElement)ve;

                textElement.text                     = m_Text.GetValueFromBag(bag, cc);
                textElement.enableRichText           = m_EnableRichText.GetValueFromBag(bag, cc);
                textElement.displayTooltipWhenElided = m_DisplayTooltipWhenElided.GetValueFromBag(bag, cc);
            }
Exemplo n.º 4
0
            /// <summary>
            /// Initializes <see cref="BaseListView"/> properties using values from the attribute bag.
            /// </summary>
            /// <param name="ve">The object to initialize.</param>
            /// <param name="bag">The attribute bag.</param>
            /// <param name="cc">The creation context; unused.</param>
            public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ve, bag, cc);
                var view = (BaseListView)ve;

                view.reorderMode             = m_ReorderMode.GetValueFromBag(bag, cc);
                view.showFoldoutHeader       = m_ShowFoldoutHeader.GetValueFromBag(bag, cc);
                view.headerTitle             = m_HeaderTitle.GetValueFromBag(bag, cc);
                view.showAddRemoveFooter     = m_ShowAddRemoveFooter.GetValueFromBag(bag, cc);
                view.showBoundCollectionSize = m_ShowBoundCollectionSize.GetValueFromBag(bag, cc);
            }
Exemplo n.º 5
0
            public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ve, bag, cc);
                var dropdownElement = (DropdownField)ve;

                dropdownElement.choices = m_Choices.GetValueFromBag(bag, cc).Split(',').Select(e => e.Trim()).ToList();

                if (dropdownElement.choices.Count > 0)
                {
                    dropdownElement.SetValueWithoutNotify(dropdownElement.choices[0]);
                }
            }
Exemplo n.º 6
0
            public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ve, bag, cc);
                var fixedPaneIndex       = m_FixedPaneIndex.GetValueFromBag(bag, cc);
                var fixedPaneInitialSize = m_FixedPaneInitialSize.GetValueFromBag(bag, cc);
                var orientationStr       = m_Orientation.GetValueFromBag(bag, cc);
                var orientation          = orientationStr == "horizontal"
                    ? Orientation.Horizontal
                    : Orientation.Vertical;

                ((SplitPannel)ve).Init(fixedPaneIndex, fixedPaneInitialSize, orientation);
            }
Exemplo n.º 7
0
            public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ve, bag, cc);

                var f       = (DropdownField)ve;
                var choices = ParseChoiceList(m_Choices.GetValueFromBag(bag, cc));

                if (choices != null)
                {
                    f.choices = choices;
                }
                f.index = m_Index.GetValueFromBag(bag, cc);
            }
Exemplo n.º 8
0
            public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ve, bag, cc);
                string propPath = m_PropertyPath.GetValueFromBag(bag, cc);

                if (!string.IsNullOrEmpty(propPath))
                {
                    var field = ve as IBindable;
                    if (field != null)
                    {
                        field.bindingPath = propPath;
                    }
                }
            }
Exemplo n.º 9
0
            public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ve, bag, cc);
                var bar = ve as AbstractProgressBar;

                bar.lowValue  = m_LowValue.GetValueFromBag(bag, cc);
                bar.highValue = m_HighValue.GetValueFromBag(bag, cc);
                var title = m_Title.GetValueFromBag(bag, cc);

                if (!string.IsNullOrEmpty(title))
                {
                    bar.title = title;
                }
            }
Exemplo n.º 10
0
            /// <summary>
            /// Initialize a uxml object instance with values from the UXML element attributes.
            /// </summary>
            /// <param name="obj">The object to initialize.</param>
            /// <param name="bag">A bag of name-value pairs, one for each attribute of the UXML element.</param>
            /// <param name="cc">Contains information about the uxml objects available in the tree for the initialization step.</param>
            /// <remarks>
            /// UxmlObject are simple data classes or structs.
            /// </remarks>
            public override void Init(ref T obj, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ref obj, bag, cc);

                obj.name    = m_Name.GetValueFromBag(bag, cc);
                obj.title   = m_Text.GetValueFromBag(bag, cc);
                obj.visible = m_Visible.GetValueFromBag(bag, cc);

                obj.width       = ParseLength(m_Width.GetValueFromBag(bag, cc), new Length());
                obj.maxWidth    = ParseLength(m_MaxWidth.GetValueFromBag(bag, cc), new Length(Length.k_MaxValue));
                obj.minWidth    = ParseLength(m_MinWidth.GetValueFromBag(bag, cc), new Length(kDefaultMinWidth));
                obj.sortable    = m_Sortable.GetValueFromBag(bag, cc);
                obj.stretchable = m_Stretch.GetValueFromBag(bag, cc);
                obj.optional    = m_Optional.GetValueFromBag(bag, cc);
                obj.resizable   = m_Resizable.GetValueFromBag(bag, cc);
                var headerTemplateId = m_HeaderTemplateId.GetValueFromBag(bag, cc);

                if (!string.IsNullOrEmpty(headerTemplateId))
                {
                    var asset = cc.visualTreeAsset?.ResolveTemplate(headerTemplateId);
                    obj.makeHeader = () =>
                    {
                        if (asset != null)
                        {
                            return(asset.Instantiate());
                        }
                        return(new Label(Column.k_InvalidTemplateError));
                    };
                }

                var cellTemplateId = m_CellTemplateId.GetValueFromBag(bag, cc);

                if (!string.IsNullOrEmpty(cellTemplateId))
                {
                    var asset = cc.visualTreeAsset?.ResolveTemplate(cellTemplateId);
                    obj.makeCell = () =>
                    {
                        if (asset != null)
                        {
                            return(asset.Instantiate());
                        }
                        return(new Label(Column.k_InvalidTemplateError));
                    };
                }
            }
Exemplo n.º 11
0
            /// <summary>
            /// Initialize <see cref="TemplateContainer"/> properties using values from the attribute bag.
            /// </summary>
            /// <param name="ve">The object to initialize.</param>
            /// <param name="bag">The attribute bag.</param>
            /// <param name="cc">The creation context; unused.</param>
            public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ve, bag, cc);

                TemplateContainer templateContainer = ((TemplateContainer)ve);

                templateContainer.templateId = m_Template.GetValueFromBag(bag, cc);
                VisualTreeAsset vea = cc.visualTreeAsset?.ResolveTemplate(templateContainer.templateId);

                if (vea == null)
                {
                    templateContainer.Add(new Label(string.Format("Unknown Template: '{0}'", templateContainer.templateId)));
                }
                else
                {
                    var bagOverrides     = (bag as TemplateAsset)?.attributeOverrides;
                    var contextOverrides = cc.attributeOverrides;

                    List <TemplateAsset.AttributeOverride> attributeOverrides = null;
                    if (bagOverrides != null || contextOverrides != null)
                    {
                        // We want to add contextOverrides first here, then bagOverrides, as we
                        // want parent instances to always override child instances.
                        attributeOverrides = new List <TemplateAsset.AttributeOverride>();
                        if (contextOverrides != null)
                        {
                            attributeOverrides.AddRange(contextOverrides);
                        }
                        if (bagOverrides != null)
                        {
                            attributeOverrides.AddRange(bagOverrides);
                        }
                    }

                    vea.CloneTree(ve, cc.slotInsertionPoints, attributeOverrides);
                }

                if (vea == null)
                {
                    Debug.LogErrorFormat("Could not resolve template with name '{0}'", templateContainer.templateId);
                }
            }
Exemplo n.º 12
0
            public override void Init(ref T obj, IUxmlAttributes bag, CreationContext cc)
            {
                base.Init(ref obj, bag, cc);

                obj.primaryColumnName = m_PrimaryColumnName.GetValueFromBag(bag, cc);
                obj.stretchMode       = m_StretchMode.GetValueFromBag(bag, cc);
                obj.reorderable       = m_Reorderable.GetValueFromBag(bag, cc);
                obj.resizable         = m_Resizable.GetValueFromBag(bag, cc);
                obj.resizePreview     = m_ResizePreview.GetValueFromBag(bag, cc);

                var columnList = m_Columns.GetValueFromBag(bag, cc);

                if (columnList != null)
                {
                    foreach (var column in columnList)
                    {
                        obj.Add(column);
                    }
                }
            }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes <see cref="Toggle"/> properties using values from the attribute bag.
 /// </summary>
 /// <param name="ve">The object to initialize.</param>
 /// <param name="bag">The attribute bag.</param>
 /// <param name="cc">The creation context; unused.</param>
 public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
 {
     base.Init(ve, bag, cc);
     ((Toggle)ve).text = m_Text.GetValueFromBag(bag, cc);
 }
Exemplo n.º 14
0
 public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
 {
     base.Init(ve, bag, cc);
     ((BaseField <TValueType>)ve).label = m_Label.GetValueFromBag(bag, cc);
 }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes <see cref="RadioButtonGroup"/> properties using values from the attribute bag.
 /// </summary>
 /// <param name="ve">The object to initialize.</param>
 /// <param name="bag">The attribute bag.</param>
 /// <param name="cc">The creation context; unused.</param>
 public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
 {
     // Need to update choices first so that radio buttons are created before the value is set.
     ((RadioButtonGroup)ve).choices = m_Choices.GetValueFromBag(bag, cc).Split(',').Select(e => e.Trim()).ToList();
     base.Init(ve, bag, cc);
 }