Esempio n. 1
0
        public static string GetPropertyName(StyleProperty property)
        {
            string name;

            s_NameMap.TryGetValue((int)property.propertyId, out name);
            return(name);
        }
Esempio n. 2
0
        internal void ClearPropertyMap()
        {
            // when clearing the property map we want to retain the styles that we have inherited from elsewhere
            // to do this, we need to read in the inherited values, store them, clear the map, then write the values back
            LightList <StyleProperty> inherited = LightList <StyleProperty> .Get();

            inherited.EnsureCapacity(StyleUtil.InheritedProperties.Count);
            StyleProperty[] inheritedArray = inherited.Array;
            for (int i = 0; i < StyleUtil.InheritedProperties.Count; i++)
            {
                int key = BitUtil.SetHighLowBits(1, (int)StyleUtil.InheritedProperties[i]);
                if (propertyMap.TryGetValue(key, out StyleProperty inheritedValue))
                {
                    inherited.AddUnchecked(inheritedValue);
                }
            }

            propertyMap.Clear();
            // re-apply values
            for (int i = 0; i < inherited.Count; i++)
            {
                int key = BitUtil.SetHighLowBits(1, (int)inheritedArray[i].propertyId);
                propertyMap.Add(key, inheritedArray[i]);
            }

            LightList <StyleProperty> .Release(ref inherited);
        }
Esempio n. 3
0
        private T GetResource <T>(int id, IntMap <AssetEntry <T> > map) where T : UnityEngine.Object
        {
            AssetEntry <T> entry;

            map.TryGetValue(id, out entry);
            return(entry.asset);
        }
Esempio n. 4
0
        private T AddResource <T>(string path, T resource, IntMap <AssetEntry <T> > map) where T : UnityEngine.Object
        {
            if (resource == null || path == null)
            {
                return(null);
            }

            int pathId = path.GetHashCode();
            int id     = resource.GetHashCode();

            AssetEntry <T> pathEntry;
            AssetEntry <T> idEntry;

            if (map.TryGetValue(pathId, out pathEntry))
            {
                return(resource);
            }

            idEntry.id         = id;
            idEntry.linkedId   = pathId;
            idEntry.asset      = resource;
            pathEntry.id       = id;
            pathEntry.linkedId = id;
            pathEntry.asset    = resource;
            map.Add(pathId, pathEntry);
            map.Add(id, idEntry);
            return(resource);
        }
Esempio n. 5
0
        private void RemoveResource <T>(T resource, IntMap <AssetEntry <T> > map) where T : UnityEngine.Object
        {
            if (resource == null)
            {
                return;
            }
            int            id = resource.GetHashCode();
            AssetEntry <T> entry;

            if (map.TryGetValue(id, out entry))
            {
                map.Remove(entry.linkedId);
                map.Remove(id);
            }
        }
Esempio n. 6
0
        private void RemoveResource <T>(string path, IntMap <AssetEntry <T> > map) where T : UnityEngine.Object
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            int            pathId = path.GetHashCode();
            AssetEntry <T> entry;

            if (map.TryGetValue(pathId, out entry))
            {
                map.Remove(entry.linkedId);
                map.Remove(pathId);
            }
        }
Esempio n. 7
0
        private T AddResource <T>(T resource, IntMap <AssetEntry <T> > map) where T : UnityEngine.Object
        {
            int            id = resource.GetHashCode();
            AssetEntry <T> entry;

            if (map.TryGetValue(id, out entry))
            {
                return(resource);
            }

            entry.id       = id;
            entry.linkedId = -1;
            entry.asset    = resource;
            map.Add(id, entry);
            return(resource);
        }
Esempio n. 8
0
        internal FontFaceLayoutInfo(Text.TextInterface.Font font)
        {
            _fontTechnologyInitialized           = false;
            _typographyAvailabilitiesInitialized = false;
            _gsubInitialized            = false;
            _gposInitialized            = false;
            _gdefInitialized            = false;
            _embeddingRightsInitialized = false;
            _gsubCache = null;
            _gposCache = null;
            _gsub      = null;
            _gpos      = null;
            _gdef      = null;

            _font = font;
            _cmap = new IntMap(_font);
            _cmap.TryGetValue(' ', out _blankGlyphIndex);
        }
Esempio n. 9
0
        private T GetResource <T>(string path, IntMap <AssetEntry <T> > map) where T : UnityEngine.Object
        {
            T resource;

            if (path == null)
            {
                return(null);
            }

            AssetEntry <T> pathEntry;
            int            pathId = path.GetHashCode();

            if (map.TryGetValue(pathId, out pathEntry))
            {
                return(pathEntry.asset);
            }
            else
            {
                // this might be null, but we want to mark the map to show that we tried to load it
                // during the lifecycle of an application we can expect Resources not to be updated
                resource           = Resources.Load <T>(path);
                pathEntry.id       = pathId;
                pathEntry.asset    = resource;
                pathEntry.linkedId = -1;
                if (resource != null)
                {
                    // see if we already have it loaded by id and update linkedId accordingly
                    int            resourceId = resource.GetHashCode();
                    AssetEntry <T> idEntry;
                    idEntry.id       = resourceId;
                    idEntry.linkedId = pathId;
                    idEntry.asset    = resource;
                    map[idEntry.id]  = idEntry;

                    pathEntry.linkedId = idEntry.id;
                }

                map.Add(pathId, pathEntry);
            }

            return(resource);
        }
Esempio n. 10
0
    protected override void RowGUI(RowGUIArgs args)
    {
        ElementTreeItem item      = (ElementTreeItem)args.item;
        GUIStyleState   textStyle = s_ElementNameStyle.normal;

        bool isTemplateRoot = (item.element.flags & UIElementFlags.TemplateRoot) != 0;

        Color mainColor = isTemplateRoot
            ? UIForiaEditorTheme.mainColorTemplateRoot
            : UIForiaEditorTheme.mainColorRegularChild;

        if (item.element.style.LayoutBehavior == LayoutBehavior.TranscludeChildren)
        {
            mainColor = UIForiaEditorTheme.mainColorChildrenElement;
        }

        textStyle.textColor = AdjustColor(mainColor, item.element);

        float indent   = GetContentIndent(args.item);
        float rowWidth = args.rowRect.width;

        args.rowRect.x     += indent;
        args.rowRect.width -= indent;
        s_Content.text      = item.element.GetDisplayName();

        if (showLayoutStats)
        {
            s_Content.text += $"w: {item.element.layoutBox.cacheHit}, {item.element.layoutBox.cacheMiss}";
        }

        if (item.element.isEnabled && item.element.renderBox != null)
        {
            if (item.element.renderBox.overflowX != Overflow.Visible || item.element.renderBox.overflowY != Overflow.Visible)
            {
                s_Content.text += " [Clipper]";
            }
        }

        if ((item.element.flags & UIElementFlags.DebugLayout) != 0)
        {
            s_Content.text = "{Debug Layout} " + s_Content.text;
        }

        Vector2 v = s_ElementNameStyle.CalcSize(s_Content);
        Rect    r = new Rect(args.rowRect);

        GUI.Label(args.rowRect, s_Content, s_ElementNameStyle);
        r.x     += v.x + 5f;
        r.width -= v.x + 5f;

        List <string> names = ListPool <string> .Get();

        item.element.style.GetStyleNameList(names);
        string styleName = string.Empty;

        for (int i = 0; i < names.Count; i++)
        {
            styleName += names[i] + " ";
        }

        ListPool <string> .Release(ref names);

        if (styleName.Length > 0)
        {
            styleName = '[' + styleName.TrimEnd() + "] ";
        }

        s_Content.text = styleName; // + "(children: " + box.children.Count + ", id: " + item.element.id + ")";

        if (showChildrenAndId)
        {
            s_Content.text += "(id: " + item.element?.id + ")";
        }

        textStyle.textColor = AdjustColor(UIForiaEditorTheme.elementStyleNormal, item.element);

        GUI.Label(r, s_Content, s_ElementNameStyle);

        v        = s_ElementNameStyle.CalcSize(s_Content);
        r.x     += v.x + 5f;
        r.width -= v.x + 5f;

        r = DrawAdditionalInfo(item.element, r);

        if (!isTemplateRoot)
        {
            return;
        }

        ViewState viewState;

        m_ViewState.TryGetValue(item.element.id, out viewState);

        r.x            = rowWidth - 16;
        r.width        = 16;
        s_Content.text = viewState.showTemplateContents ? "+" : "-";
        GUI.Label(r, s_Content);

        if (Event.current.type == EventType.MouseDown)
        {
            if (r.Contains(Event.current.mousePosition))
            {
                viewState.showTemplateContents = !viewState.showTemplateContents;
                m_ViewState[item.element.id]   = viewState;
                needsReload = true;
            }
        }
    }