Пример #1
0
        /// <summary>
        /// Renders the name of a model variation in the variation dropdown.
        /// </summary>
        /// <param name="cellLayout">The layout of the cell.</param>
        /// <param name="cell">The cell.</param>
        /// <param name="model">The model of the combobox.</param>
        /// <param name="iter">The iter pointing to the rendered row.</param>
        public static void RenderModelVariationName(ICellLayout cellLayout, CellRenderer cell, ITreeModel model, TreeIter iter)
        {
            CellRendererText cellText = cell as CellRendererText;

            if (cellText == null)
            {
                return;
            }

            string storedText = (string)model.GetValue(iter, 0);

            // Builtin override for the standard set name
            if (storedText.ToLowerInvariant().Contains("set_$defaultglobal"))
            {
                cellText.Text = "Default";
                return;
            }

            string transientText = storedText.FastReplaceCaseInsensitive("set_", string.Empty);

            // Insert spaces between words and abbreviations
            transientText = Regex.Replace(transientText, @"(\B[A-Z0-9]+?(?=[A-Z][^A-Z])|\B[A-Z0-9]+?(?=[^A-Z]))", " $1");

            cellText.Text = transientText;
        }
Пример #2
0
        public static void CellDataHandler(ICellLayout layout, CellRenderer cell, ITreeModel model, TreeIter iter)
        {
            SourceRowRenderer renderer = cell as SourceRowRenderer;

            if (renderer == null)
            {
                return;
            }

            var type = model.GetValue(iter, (int)SourceModel.Columns.Type);

            if (type == null || (SourceModel.EntryType)type != SourceModel.EntryType.Source)
            {
                renderer.Visible = false;
                return;
            }

            Source source = model.GetValue(iter, 0) as Source;

            renderer.Source = source;
            renderer.Iter   = iter;

            if (source == null)
            {
                return;
            }

            renderer.Visible   = true;
            renderer.Text      = source.Name;
            renderer.Sensitive = source.CanActivate;
        }
        private static void Func(ICellLayout cellLayout, CellRenderer cell, ITreeModel model, TreeIter iter)
        {
            var item = (Category)model.GetValue(iter, 0);

            if (cell is CellRendererText value)
            {
                value.Text = item.CategoryName;
            }
        }
Пример #4
0
        static public void ComboBoxCellFunc(ICellLayout cell_layout, CellRenderer cell, ITreeModel tree_model, TreeIter iter)
        {
            string name = (string)tree_model.GetValue(iter, 0);

            (cell as CellRendererText).Text = name;
        }
Пример #5
0
        public static void CellDataHandler(ICellLayout layout, CellRenderer cell, ITreeModel model, TreeIter iter)
        {
            SourceRowRenderer renderer = cell as SourceRowRenderer;
            if (renderer == null) {
                return;
            }

            var type = model.GetValue (iter, (int)SourceModel.Columns.Type);
            if (type == null || (SourceModel.EntryType) type != SourceModel.EntryType.Source) {
                renderer.Visible = false;
                return;
            }

            Source source = model.GetValue (iter, 0) as Source;
            renderer.Source = source;
            renderer.Iter = iter;

            if (source == null) {
                return;
            }

            renderer.Visible = true;
            renderer.Text = source.Name;
            renderer.Sensitive = source.CanActivate;
        }
Пример #6
0
    // The parent needs to be specified in advance for the CellPool
    public CellLayout InstantiateCellLayout(GameObject cellLayoutPrefab, int requiredPoolSize = 24)
    {
        // Get or create cell pool
        CellPool cellPool = null;

        CellLayoutPrefabsToCellPools.TryGetValue(cellLayoutPrefab, out cellPool);

        if (!cellPool)
        {
            // InstantiateCellPool()
            cellPool = ResourceCache.Inst.Create("CellPool").GetComponent <CellPool>();
            cellPool.gameObject.SetActive(true);
            cellPool.gameObject.name = cellPool.GetType().Name + "[" + cellLayoutPrefab.name + "](Clone)";
            cellPool.InitializePool();
            cellPool.ScrollRecycler = this;
            cellPool.transform.SetParent(ScrollRect.content.parent, false); // Sibling of ScrollRecycfler
            CellLayoutPrefabsToCellPools[cellLayoutPrefab] = cellPool;
        }
        cellPool.SetRequiredPoolSize(requiredPoolSize);

        // Initialize recycler layout
        GameObject  cellLayoutGO = UnityEngine.Object.Instantiate(cellLayoutPrefab);
        ICellLayout iCellLayout  = cellLayoutGO.GetComponent <ICellLayout>();

        ICellLayouts.Add(iCellLayout);

        cellLayoutGO.transform.SetParent(ScrollRect.content, false);
        iCellLayout.CellLayout.CellPool       = cellPool;
        iCellLayout.CellLayout.ScrollRecycler = this;
        if (iCellLayout.CellLayout.CellPool.CellPrefab == null)
        {
            iCellLayout.CellLayout.CellPool.CellPrefab = iCellLayout.CellLayout.CellPrefab;
        }
        cellLayoutGO.SetActive(true);

        if (!cellPool.CellProxy)
        {
            // TODO: Evaluate how we want to use this
            // InstantiateCellLayoutProxy()
            //var layoutProxyRoot = new GameObject();
            //{ // Copy the layout elements and rect size of the ScrollRect.content
            //    layoutProxyRoot.transform.SetParent(ScrollRect.content, false);
            //    var layoutProxyRootRtx = layoutProxyRoot.AddComponent<RectTransform>();
            //    layoutProxyRootRtx.CopyFromRectTransform(ScrollRect.content);
            //    layoutProxyRoot.AddComponent<LayoutElement>().ignoreLayout = true; // Ignores topmost layout calculations
            //    LayoutUtil.DuplicateLayoutElements(ScrollRect.content.gameObject, layoutProxyRoot);
            //    layoutProxyRoot.name += "(LayoutProxy)";
            //}

            cellPool.CellProxy = Instantiate(iCellLayout.CellLayout.CellPrefab);
            cellPool.CellProxy.gameObject.SetActive(true);
            cellPool.CellProxy.name = iCellLayout.CellLayout.CellPrefab.name + "(ProxyCell)";
            cellPool.CellProxy.transform.SetParent(cellLayoutGO.transform, false);
            cellPool.CellProxy.transform.localPosition = Vector2.zero;

            var cellProxyCG = cellPool.CellProxy.GetComponent <CanvasGroup>();
            if (!cellProxyCG)
            {
                cellProxyCG = cellPool.CellProxy.AddComponent <CanvasGroup>();
            }
            cellProxyCG.alpha = 0.0f;

            var cellProxyLE = cellPool.CellProxy.GetComponent <LayoutElement>();
            if (!cellProxyLE)
            {
                cellProxyLE = cellPool.CellProxy.AddComponent <LayoutElement>();
            }
        }

        return(iCellLayout.CellLayout);
    }