예제 #1
0
        public static T Get(LW_Graphic graphic, LW_Style style)
        {
            int key    = GetCacheKey(graphic.id, style.id);
            T   buffer = Get(key);

            buffer.graphic = graphic;
            buffer.style   = style;

            return(buffer);
        }
예제 #2
0
 /// <summary>
 /// Inserts a new element at the provided index. If an element already exists at the index. the new element is a copy of the old element.
 /// </summary>
 /// <param name="index"></param>
 public void InsertAt(int index)
 {
     if (m_StylesList != null && index > -1 && index < m_StylesList.Count)
     {
         LW_Style copiedElement = m_StylesList[index].Copy() as LW_Style;
         m_StylesList.Insert(index, copiedElement);
         m_StylesList[index].RegisterCallbacks(OnChildSetElementDirty);
         SetElementDirty();
     }
 }
예제 #3
0
 /// <summary>
 /// Moves an element from the srcIndex to the dstIndex
 /// </summary>
 /// <param name="srcIndex"></param>
 /// <param name="dstIndex"></param>
 public void Move(int srcIndex, int dstIndex)
 {
     if (m_StylesList != null && dstIndex > -1 && dstIndex < m_StylesList.Count)
     {
         LW_Style item = m_StylesList[srcIndex];
         m_StylesList.RemoveAt(srcIndex);
         m_StylesList.Insert(dstIndex, item);
         SetElementDirty();
     }
 }
예제 #4
0
        public static T Get(LW_Graphic graphic, LW_Style style, LW_Canvas canvas)
        {
            int key    = GetCacheKey(graphic.id, style.id, canvas.id);
            T   buffer = Get(key);

            buffer.graphic = graphic;
            buffer.style   = style;
            buffer.canvas  = canvas;

            return(buffer);
        }
예제 #5
0
        internal override void CopyPropertiesFrom(LW_Element element)
        {
            LW_Style style = element as LW_Style;

            if (style != null)
            {
                m_SegmentationMultiplier   = style.m_SegmentationMultiplier;
                m_SimplificationMultiplier = style.m_SimplificationMultiplier;
                m_LateralOffset            = style.m_LateralOffset;
                m_VerticalOffset           = style.m_VerticalOffset;
            }
            base.CopyPropertiesFrom(element);
        }
예제 #6
0
 /// <summary>
 /// Adds an element to the collection
 /// </summary>
 /// <param name="element"></param>
 public void Add(LW_Style item)
 {
     if (m_StylesList == null)
     {
         m_StylesList = new List <LW_Style>();
     }
     if (!m_StylesList.Contains(item))
     {
         m_StylesList.Add(item);
         item.RegisterCallbacks(OnChildSetElementDirty);
         SetElementDirty();
     }
 }
예제 #7
0
 /// <summary>
 /// Removes the provided element from the collection.
 /// </summary>
 /// <param name="element"></param>
 public bool Remove(LW_Style item)
 {
     if (m_StylesList != null && m_StylesList.Contains(item))
     {
         item.UnregisterCallbacks(OnChildSetElementDirty);
         bool result = m_StylesList.Remove(item);
         LW_Utilities.SafeDestroy <LW_Style>(item);
         SetElementDirty();
         return(result);
     }
     else
     {
         return(false);
     }
 }
예제 #8
0
 private static void RemoveStyleFromDict(LW_Style style)
 {
     foreach (KeyValuePair <Material, LW_MaterialBuffer> kvp in s_MaterialDict)
     {
         LW_MaterialBuffer materialBuffer = kvp.Value;
         for (int i = 0; i < materialBuffer.vertexBuffers.Count; i++)
         {
             LW_VertexBuffer buffer = materialBuffer.vertexBuffers[i];
             if (buffer.style == style)
             {
                 if (!materialBuffer.emptyIndices.Contains(i))
                 {
                     materialBuffer.emptyIndices.Push(i);
                 }
             }
         }
     }
 }
예제 #9
0
        internal override void CopyPropertiesFrom(LW_Element element)
        {
            if (element is LW_Styles)
            {
                LW_Styles styles = element as LW_Styles;

                bool stylesMatch = m_StylesList != null && styles.m_StylesList != null && m_StylesList.Count == styles.m_StylesList.Count;
                if (stylesMatch)
                {
                    for (int i = 0; i < m_StylesList.Count; i++)
                    {
                        if (m_StylesList[i].GetType() != styles.m_StylesList[i].GetType() || m_StylesList[i] == styles.m_StylesList[i])
                        {
                            stylesMatch = false;
                            break;
                        }
                    }
                }
                if (stylesMatch)
                {
                    for (int i = 0; i < m_StylesList.Count; i++)
                    {
                        m_StylesList[i].CopyPropertiesFrom(styles.m_StylesList[i]);
                    }
                }
                else
                {
                    if (m_StylesList != null)
                    {
                        for (int i = 0; i < m_StylesList.Count; i++)
                        {
                            if (m_StylesList[i] != null)
                            {
                                LW_Utilities.SafeDestroy(m_StylesList[i]);
                            }
                        }
                        m_StylesList.Clear();
                    }
                    if (styles.m_StylesList != null)
                    {
                        if (m_StylesList == null)
                        {
                            m_StylesList = new List <LW_Style>(styles.m_StylesList.Count);
                        }
                        else if (m_StylesList.Capacity < styles.m_StylesList.Count)
                        {
                            m_StylesList.Capacity = styles.m_StylesList.Count;
                        }

                        for (int i = 0; i < styles.m_StylesList.Count; i++)
                        {
                            if (styles.m_StylesList[i] != null)
                            {
                                LW_Style copiedElement = styles.m_StylesList[i].Copy() as LW_Style;
                                m_StylesList.Add(copiedElement);
                            }
                        }
                    }
                }
            }
            base.CopyPropertiesFrom(element);
        }