public override void SetDataToCell(CacheObjectCell cell) { base.SetDataToCell(cell); var kvpCell = cell as CacheKeyValuePairCell; kvpCell.NameLabel.text = $"{DictIndex}:"; kvpCell.Image.color = DictIndex % 2 == 0 ? CacheListEntryCell.EvenColor : CacheListEntryCell.OddColor; if (KeyInputWanted) { kvpCell.KeyInputField.UIRoot.SetActive(true); kvpCell.KeyInputTypeLabel.gameObject.SetActive(true); kvpCell.KeyLabel.gameObject.SetActive(false); kvpCell.KeyInspectButton.Component.gameObject.SetActive(false); kvpCell.KeyInputField.Text = KeyInputText; kvpCell.KeyInputTypeLabel.text = KeyInputTypeText; } else { kvpCell.KeyInputField.UIRoot.SetActive(false); kvpCell.KeyInputTypeLabel.gameObject.SetActive(false); kvpCell.KeyLabel.gameObject.SetActive(true); kvpCell.KeyInspectButton.Component.gameObject.SetActive(InspectWanted); kvpCell.KeyLabel.text = KeyLabelText; } }
protected override void SetValueState(CacheObjectCell cell, ValueStateArgs args) { base.SetValueState(cell, args); //var memCell = cell as CacheMemberCell; //memCell.UpdateToggle.gameObject.SetActive(ShouldAutoEvaluate); }
// Helper so that this doesn't need to be copy+pasted between each implementation of the interface public static void SetCell(CacheObjectCell cell, int index, IList cachedEntries, Action <CacheObjectCell> onDataSetToCell) { if (index < 0 || index >= cachedEntries.Count) { if (cell.Occupant != null) { cell.Occupant.UnlinkFromView(); } cell.Disable(); return; } var entry = (CacheObjectBase)cachedEntries[index]; if (entry.CellView != null && entry.CellView != cell) { entry.UnlinkFromView(); } if (cell.Occupant != null && cell.Occupant != entry) { cell.Occupant.UnlinkFromView(); } if (entry.CellView != cell) { entry.SetView(cell); } entry.SetDataToCell(cell); onDataSetToCell?.Invoke(cell); }
public override void SetDataToCell(CacheObjectCell cell) { base.SetDataToCell(cell); var listCell = cell as CacheListEntryCell; listCell.NameLabel.text = $"{ListIndex}:"; listCell.Image.color = ListIndex % 2 == 0 ? CacheListEntryCell.EvenColor : CacheListEntryCell.OddColor; }
private void SetCellLayout(CacheObjectCell cell) { cell.NameLayout.minWidth = LeftGroupWidth; cell.RightGroupLayout.minWidth = RightGroupWidth; if (cell.Occupant?.IValue != null) { cell.Occupant.IValue.SetLayout(); } }
private void SetCellLayout(CacheObjectCell objcell) { var cell = objcell as CacheKeyValuePairCell; cell.KeyGroupLayout.minWidth = cell.AdjustedWidth * 0.44f; cell.RightGroupLayout.minWidth = cell.AdjustedWidth * 0.55f; if (cell.Occupant?.IValue != null) { cell.Occupant.IValue.SetLayout(); } }
protected override bool SetCellEvaluateState(CacheObjectCell objectcell) { var cell = objectcell as CacheMemberCell; cell.EvaluateHolder.SetActive(!ShouldAutoEvaluate); if (!ShouldAutoEvaluate) { //cell.UpdateToggle.gameObject.SetActive(false); cell.EvaluateButton.Component.gameObject.SetActive(true); if (HasArguments) { if (!Evaluating) { cell.EvaluateButton.ButtonText.text = $"Evaluate ({Arguments.Length + GenericArguments.Length})"; } else { cell.EvaluateButton.ButtonText.text = "Hide"; Evaluator.UIRoot.transform.SetParent(cell.EvaluateHolder.transform, false); RuntimeProvider.Instance.SetColorBlock(cell.EvaluateButton.Component, evalEnabledColor, evalEnabledColor * 1.3f); } } else { cell.EvaluateButton.ButtonText.text = "Evaluate"; } if (!Evaluating) { RuntimeProvider.Instance.SetColorBlock(cell.EvaluateButton.Component, evalDisabledColor, evalDisabledColor * 1.3f); } } //else //{ // cell.UpdateToggle.gameObject.SetActive(true); // cell.UpdateToggle.isOn = AutoUpdateWanted; //} if (State == ValueState.NotEvaluated && !ShouldAutoEvaluate) { SetValueState(cell, ValueStateArgs.Default); cell.RefreshSubcontentButton(); return(true); } if (State == ValueState.NotEvaluated) { Evaluate(); } return(false); }
protected virtual void SetValueState(CacheObjectCell cell, ValueStateArgs args) { // main value label if (args.valueActive) { cell.ValueLabel.text = ValueLabelText; cell.ValueLabel.supportRichText = args.valueRichText; cell.ValueLabel.color = args.valueColor; } else { cell.ValueLabel.text = ""; } // Type label (for primitives) cell.TypeLabel.gameObject.SetActive(args.typeLabelActive); if (args.typeLabelActive) { cell.TypeLabel.text = SignatureHighlighter.Parse(LastValueType, false); } // toggle for bools cell.Toggle.gameObject.SetActive(args.toggleActive); if (args.toggleActive) { cell.Toggle.interactable = CanWrite; cell.Toggle.isOn = (bool)Value; cell.ToggleText.text = Value.ToString(); } // inputfield for numbers cell.InputField.UIRoot.SetActive(args.inputActive); if (args.inputActive) { cell.InputField.Text = ParseUtility.ToStringForInput(Value, LastValueType); cell.InputField.Component.readOnly = !CanWrite; } // apply for bool and numbers cell.ApplyButton.Component.gameObject.SetActive(args.applyActive); // Inspect button only if last value not null. if (cell.InspectButton != null) { cell.InspectButton.Component.gameObject.SetActive(args.inspectActive && !LastValueWasNull); } // allow IValue for null strings though cell.SubContentButton.Component.gameObject.SetActive(args.subContentButtonActive && (!LastValueWasNull || State == ValueState.String)); }
protected override bool TryAutoEvaluateIfUnitialized(CacheObjectCell cell) => true;
protected override bool SetCellEvaluateState(CacheObjectCell cell) { // not needed return(false); }
public virtual void SetDataToCell(CacheObjectCell cell) { cell.NameLabel.text = NameLabelText; if (cell.HiddenNameLabel != null) { cell.HiddenNameLabel.Text = NameLabelTextRaw ?? string.Empty; } cell.ValueLabel.gameObject.SetActive(true); cell.SubContentHolder.gameObject.SetActive(SubContentShowWanted); if (IValue != null) { IValue.UIRoot.transform.SetParent(cell.SubContentHolder.transform, false); IValue.SetLayout(); } bool evaluated = TryAutoEvaluateIfUnitialized(cell); if (cell.CopyButton != null) { bool hasEvaluated = State != ValueState.NotEvaluated && State != ValueState.Exception; cell.CopyButton.Component.gameObject.SetActive(hasEvaluated); cell.PasteButton.Component.gameObject.SetActive(hasEvaluated && this.CanWrite); } if (!evaluated) { return; } // The following only executes if the object has evaluated. // For members and properties with args, they will return by default now. switch (State) { case ValueState.Exception: SetValueState(cell, ValueStateArgs.Default); break; case ValueState.Boolean: SetValueState(cell, new ValueStateArgs(false, toggleActive: true, applyActive: CanWrite)); break; case ValueState.Number: SetValueState(cell, new ValueStateArgs(false, typeLabelActive: true, inputActive: true, applyActive: CanWrite)); break; case ValueState.String: if (LastValueWasNull) { SetValueState(cell, new ValueStateArgs(true, subContentButtonActive: true)); } else { SetValueState(cell, new ValueStateArgs(true, false, SignatureHighlighter.StringOrange, subContentButtonActive: true)); } break; case ValueState.Enum: SetValueState(cell, new ValueStateArgs(true, subContentButtonActive: CanWrite)); break; case ValueState.Color: case ValueState.ValueStruct: if (ParseUtility.CanParse(LastValueType)) { SetValueState(cell, new ValueStateArgs(false, false, null, true, false, true, CanWrite, true, true)); } else { SetValueState(cell, new ValueStateArgs(true, inspectActive: true, subContentButtonActive: true)); } break; case ValueState.Collection: case ValueState.Dictionary: SetValueState(cell, new ValueStateArgs(true, inspectActive: !LastValueWasNull, subContentButtonActive: !LastValueWasNull)); break; case ValueState.Unsupported: SetValueState(cell, new ValueStateArgs(true, inspectActive: !LastValueWasNull)); break; } cell.RefreshSubcontentButton(); }
// Setting cell state from our model /// <summary>Return false if SetCell should abort, true if it should continue.</summary> protected abstract bool TryAutoEvaluateIfUnitialized(CacheObjectCell cell);
public virtual void SetView(CacheObjectCell cellView) { this.CellView = cellView; cellView.Occupant = this; }
protected override bool SetCellEvaluateState(CacheObjectCell cell) => false;
public virtual void SetDataToCell(CacheObjectCell cell) { cell.NameLabel.text = NameLabelText; cell.ValueLabel.gameObject.SetActive(true); cell.SubContentHolder.gameObject.SetActive(SubContentShowWanted); if (IValue != null) { IValue.UIRoot.transform.SetParent(cell.SubContentHolder.transform, false); IValue.SetLayout(); } if (SetCellEvaluateState(cell)) { return; } switch (State) { case ValueState.Exception: SetValueState(cell, ValueStateArgs.Default); break; case ValueState.Boolean: SetValueState(cell, new ValueStateArgs(false, toggleActive: true, applyActive: CanWrite)); break; case ValueState.Number: SetValueState(cell, new ValueStateArgs(false, typeLabelActive: true, inputActive: true, applyActive: CanWrite)); break; case ValueState.String: if (LastValueWasNull) { SetValueState(cell, new ValueStateArgs(true, subContentButtonActive: true)); } else { SetValueState(cell, new ValueStateArgs(true, false, SignatureHighlighter.StringOrange, subContentButtonActive: true)); } break; case ValueState.Enum: SetValueState(cell, new ValueStateArgs(true, subContentButtonActive: CanWrite)); break; case ValueState.Color: case ValueState.ValueStruct: if (ParseUtility.CanParse(LastValueType)) { SetValueState(cell, new ValueStateArgs(false, false, null, true, false, true, CanWrite, true, true)); } else { SetValueState(cell, new ValueStateArgs(true, inspectActive: true, subContentButtonActive: true)); } break; case ValueState.Collection: case ValueState.Dictionary: SetValueState(cell, new ValueStateArgs(true, inspectActive: !LastValueWasNull, subContentButtonActive: !LastValueWasNull)); break; case ValueState.Unsupported: SetValueState(cell, new ValueStateArgs(true, inspectActive: !LastValueWasNull)); break; } cell.RefreshSubcontentButton(); }
// Setting cell state from our model /// <summary>Return true if SetCell should abort, false if it should continue.</summary> protected abstract bool SetCellEvaluateState(CacheObjectCell cell);