Esempio n. 1
0
 public void AddCellTemplate(ScrollViewCell template)
 {
     if (template != null)
     {
         _cellTemplates.Add(template);
     }
 }
Esempio n. 2
0
 protected void DeactiveCell(ScrollViewCell cell)
 {
     cell.SetTopPositionAndHeight(-999999, 0);
     cell.info = null;
     _cellPools[cell.identifier].Add(cell);
     _activeCells.Remove(cell);
 }
        public override void UpdateData(ScrollViewCell cell)
        {
            _dropdownCell = (BaseDropdownCell)cell;
            _dropdownCell.OnValueChanged = OnValueChanged;

            _dropdownField = null;
            foreach (var dropdownField in _presetDropdownFields)
            {
                if (dropdownField.TryParse(command, variableInfo, out _options))
                {
                    _dropdownField = dropdownField;
                    break;
                }
            }

            if (_dropdownField == null || _options == null || _options.Length == 0)
            {
                throw new System.Exception("There is something wrong!");
            }

            // If the field doesn't have value yet, set it to the first element (0) in options
            int dropdownIndex = _dropdownField.GetDropdownIndex(command, variableInfo, _options);

            if (dropdownIndex == -1)
            {
                _dropdownField.OnValueChanged(command, variableInfo, _options, 0);
            }

            _dropdownCell.SetOptions(_options);
            _dropdownCell.SetIndex(dropdownIndex);
        }
Esempio n. 4
0
        protected void AddActiveCell(ScrollViewCellInfo cellInfo, bool isFirst = false)
        {
            ScrollViewCell cell = _delegate.ScrollCellCreated(cellInfo.index);

            cell.info = cellInfo;

            if (_scrollOrientation == ScrollOrientation.Vertical)
            {
                cell.SetTopPositionAndHeight(cellInfo.position, cellInfo.size);
            }
            else if (_scrollOrientation == ScrollOrientation.Horizontal)
            {
            }

            if (isFirst)
            {
                _activeCells.Insert(0, cell);
            }
            else
            {
                _activeCells.Add(cell);
            }

            _delegate.ScrollCellWillDisplay(cell);
        }
        public override float CellSize(ScrollViewCell cell)
        {
            BaseGenericCell genericCell = (BaseGenericCell)cell;
            float           offset      = LogConsoleSettings.GetTreeViewOffsetByLevel(level);
            bool            hasIcon     = !string.IsNullOrEmpty(icon);

            return(genericCell.GetPreferHeight(DisplayText, hasIcon, offset));
        }
 public override void UpdateData(ScrollViewCell cell)
 {
     _isNumeric = variableInfo.fieldInfo.FieldType.IsNumericType();
     _inputCell = (BaseInputCell)cell;
     _inputCell.OnValueChanged = OnValueChanged;
     _inputCell.SetInput(GetFieldValueAsString());
     _inputCell.SetIsNumeric(_isNumeric);
 }
Esempio n. 7
0
        public ScrollViewCell ScrollCellCreated(int cellIndex)
        {
            if (cellIndex < 0 || cellIndex >= _filterLogInfos.Count)
            {
                throw new Exception("Cell index is out of range: " + cellIndex);
            }

            ScrollViewCell cell = _scrollView.CreateCell("LogCell");

            return(cell);
        }
        public override void UpdateData(ScrollViewCell cell)
        {
            _sliderCell = (BaseSliderCell)cell;
            _sliderCell.OnValueChanged = OnValueChanged;

            var   rangeAttr      = variableInfo.fieldInfo.GetCustomAttribute <RangeAttribute>(false);
            var   relativeAttr   = variableInfo.fieldInfo.GetCustomAttribute <RelativeSliderAttribute>(false);
            bool  isWholeNumbers = variableInfo.fieldInfo.FieldType != typeof(float) && variableInfo.fieldInfo.FieldType != typeof(double);
            float value          = (float)Convert.ChangeType(variableInfo.fieldInfo.GetValue(command), typeof(float));

            _sliderCell.UseRelativeSlider(relativeAttr != null);
            _sliderCell.SetConfig(rangeAttr.min, rangeAttr.max, isWholeNumbers);
            _sliderCell.SetValue(Mathf.Clamp(value, rangeAttr.min, rangeAttr.max));
        }
Esempio n. 9
0
        ScrollViewCell CreateNewCell(string identifier)
        {
            ScrollViewCell cellTemplate = _cellTemplates.Find(template => template.identifier == identifier);

            if (cellTemplate == null)
            {
                throw new Exception("Could not found cell type with identifier: " + identifier);
            }

            ScrollViewCell cell = Instantiate(cellTemplate, _viewContent.transform, false);

            cell.gameObject.SetActive(true);
            cell.transform.localScale = Vector2.one;
            cell.OnCellSelected      += NotifyCellSelected;

            RectTransform rectTransform = cell.GetComponent <RectTransform>();

            rectTransform.anchorMin = new Vector2(0, 1);
            rectTransform.anchorMax = new Vector2(1, 1);

            return(cell);
        }
Esempio n. 10
0
        public ScrollViewCell CreateCell(string identifier)
        {
            if (!_cellPools.ContainsKey(identifier))
            {
                throw new Exception("Could not found cell type with identifier: " + identifier);
            }

            List <ScrollViewCell> cellPool = _cellPools[identifier];
            ScrollViewCell        cell     = null;

            if (cellPool.Count > 0)
            {
                cell = cellPool[0];
                cellPool.Remove(cell);
            }
            else
            {
                cell = CreateNewCell(identifier);
            }

            return(cell);
        }
Esempio n. 11
0
        void UpdateCell(ScrollViewCell cell)
        {
            BaseLogCell logCell = cell as BaseLogCell;
            LogInfo     logInfo = _filterLogInfos[logCell.info.index];

            AssetConfig.SpriteInfo iconConfig = _assetConfig.GetSpriteInfo(LogTypeToIconName(logInfo.type));
            logCell.SetIcon(iconConfig.sprite);
            logCell.SetIconColor(iconConfig.color);
            logCell.SetBackgroundColor(LogConsoleSettings.GetCellColor(logCell.info.index));

            _cachedText.Length = 0;

            if (LogConsoleSettings.Instance.showTimestamp)
            {
                _cachedText.Append(logInfo.time);
            }

            if (LogConsoleSettings.Instance.showLogChannel && logInfo.channelInfo != null)
            {
                _cachedText.Append(logInfo.channelInfo.nameWithColor);
                _cachedText.Append("  ");
            }

            _cachedText.Append(logInfo.shortMessage);
            logCell.SetText(_cachedText.ToString());

            if (LogFilter.Instance.IsCollapse)
            {
                logCell.SetCollapseEnable(true);
                logCell.SetCollapseNumber(logInfo.numInstance);
            }
            else
            {
                logCell.SetCollapseEnable(false);
            }
        }
        public float ScrollCellSize(int cellIndex)
        {
            NodeView nodeView = (NodeView)_filterNodes[cellIndex];

            if (nodeView.resizable)
            {
                string cellIdentifier = nodeView.CellIdentifier();
                if (!_resizableCells.ContainsKey(cellIdentifier))
                {
                    ScrollViewCell cellTemplate = _config.cellTemplates.Find(c => c.identifier == cellIdentifier);
                    ScrollViewCell cell         = Instantiate(cellTemplate, _scrollViewContent);
                    _resizableCells[cellIdentifier] = cell;

                    LayoutRebuilder.ForceRebuildLayoutImmediate(cell.rectTransform);
                    cell.gameObject.SetActive(false);
                }

                return(Mathf.Max(nodeView.CellSize(_resizableCells[cellIdentifier]), 120));
            }
            else
            {
                return(nodeView.CellSize());
            }
        }
 public void ScrollCellWillDisplay(ScrollViewCell cell)
 {
 }
Esempio n. 14
0
 public override void UpdateData(ScrollViewCell cell)
 {
     _checkboxCell = (BaseCheckboxCell)cell;
     _checkboxCell.OnValueChanged = OnValueChanged;
     _checkboxCell.SetToggle((bool)variableInfo.fieldInfo.GetValue(command));
 }
Esempio n. 15
0
 public abstract void UpdateData(ScrollViewCell cell);
Esempio n. 16
0
 protected void NotifyCellSelected(ScrollViewCell cell)
 {
     _delegate.ScrollCellSelected(cell.info.index);
 }
Esempio n. 17
0
 public void ScrollCellWillDisplay(ScrollViewCell cell)
 {
     UpdateCell(cell);
 }