Ejemplo n.º 1
0
 private void UpdateGroupSizes(GridLayouter g)
 {
     if (g.ListMode)
     {
         g.LayoutParams.FixedWidth           = m_VisibleRect.width;
         g.LayoutParams.ItemSize             = new Vector2(m_VisibleRect.width, 16f);
         g.LayoutParams.TopMargin            = 0.0f;
         g.LayoutParams.BottomMargin         = 0.0f;
         g.LayoutParams.LeftMargin           = 0.0f;
         g.LayoutParams.RightMargin          = 0.0f;
         g.LayoutParams.VerticalSpacing      = 0.0f;
         g.LayoutParams.MinHorizontalSpacing = 0.0f;
         g.LayoutParams.CalculateLayoutParams(g.ItemCount, g.ItemsWantedShown);
     }
     else
     {
         g.LayoutParams.FixedWidth           = m_TotalRect.width;
         g.LayoutParams.ItemSize             = new Vector2(GridSize, GridSize + 14);
         g.LayoutParams.TopMargin            = 10;
         g.LayoutParams.BottomMargin         = 10;
         g.LayoutParams.LeftMargin           = 10;
         g.LayoutParams.RightMargin          = 10;
         g.LayoutParams.VerticalSpacing      = 15f;
         g.LayoutParams.MinHorizontalSpacing = 12f;
         g.LayoutParams.CalculateLayoutParams(g.ItemCount, g.LayoutParams.CalculateRows(g.ItemsWantedShown));
     }
 }
Ejemplo n.º 2
0
        public void BeginPing(int itemId)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            var index = m_DataSource.GetItemIndexByItemId(itemId);

            if (index != -1)
            {
                var    item     = m_DataSource.ItemList[index];
                string fullText = item.DisplayName;
                if (fullText != null)
                {
                    m_Ping.m_TimeStart      = Time.realtimeSinceStartup;
                    m_Ping.m_AvailableWidth = m_VisibleRect.width;
                    m_pingIndex             = index;
                    GUIContent content = new GUIContent(!m_GridLayouter.ListMode ? GetCroppedLabelText(itemId, fullText, m_WidthUsedForCroppingName) : fullText);

                    if (m_GridLayouter.ListMode)
                    {
                        m_Ping.m_PingStyle = s_Styles.ping;
                        Vector2 vector = m_Ping.m_PingStyle.CalcSize(content);
                        m_Ping.m_ContentRect.width  = vector.x + 16f;
                        m_Ping.m_ContentRect.height = vector.y;
                        m_LeftPaddingForPinging     = item.IsChildItem ? 0x1c : 16;
                        m_Ping.m_ContentDraw        = (rect) =>
                        {
                            GridLayouter.DrawIconAndLabel(rect, item.DisplayName, (Texture2D)item.Texture, false, false);
                        };
                    }
                    else
                    {
                        m_Ping.m_PingStyle = s_Styles.miniPing;
                        Vector2 vector2 = m_Ping.m_PingStyle.CalcSize(content);
                        m_Ping.m_ContentRect.width  = vector2.x;
                        m_Ping.m_ContentRect.height = vector2.y;
                        m_Ping.m_ContentDraw        = (rect) =>
                        {
                            TextAnchor alignment = s_Styles.resultsGridLabel.alignment;
                            s_Styles.resultsGridLabel.alignment = TextAnchor.UpperLeft;
                            s_Styles.resultsGridLabel.Draw(rect, content.text, false, false, false, false);
                            s_Styles.resultsGridLabel.alignment = alignment;
                        };
                    }

                    Vector2 vector3 = CalculatePingPosition();
                    m_Ping.m_ContentRect.x = vector3.x;
                    m_Ping.m_ContentRect.y = vector3.y;
                    Repaint();
                }
            }
        }
Ejemplo n.º 3
0
 public GridView(ViewGroupManager owner, GridLayouter gridLayouter, GridViewHandler viewHandler = null) : base(owner)
 {
     m_ViewConfig      = new GridViewConfig();
     m_GridLayouter    = gridLayouter;
     m_DataSource      = m_GridLayouter.DataSource;
     m_GridViewHandler = viewHandler;
     if (m_GridViewHandler == null)
     {
         m_GridViewHandler = new GridViewHandler(m_DataSource);
     }
     m_GridLayouter.Owner = this;
     m_RenameOverlay.Clear();
 }