/*--------------------------------------------------------------------------------------------*/ public virtual void TreeUpdate() { HoverItem hoverItem = GetComponent <HoverItem>(); DestroyRenderersIfNecessary(); TryRebuildWithItemType(hoverItem.ItemType); //// HoverItemHighlightState highState = GetComponent <HoverItemHighlightState>(); HoverItemSelectionState selState = GetComponent <HoverItemSelectionState>(); HoverRenderer activeRenderer = ((HoverRenderer)ButtonRenderer ?? SliderRenderer); UpdateRenderer(activeRenderer, hoverItem); UpdateRendererCanvas(activeRenderer, hoverItem); UpdateRendererIndicator(activeRenderer, highState, selState); if (ButtonRenderer != null) { UpdateButtonSettings(highState); } if (SliderRenderer != null) { UpdateSliderSettings(hoverItem); UpdateSliderSettings(hoverItem, highState); } Controllers.TryExpireControllers(); }
/*--------------------------------------------------------------------------------------------*/ private void UpdateRendererCanvas(HoverRenderer pRenderer, HoverItem pHoverItem) { HoverCanvasDataUpdater canvasUp = pRenderer.GetCanvasDataUpdater(); if (canvasUp == null) { return; } IItemData data = pHoverItem.Data; IItemDataCheckbox checkboxData = (data as IItemDataCheckbox); IItemDataRadio radioData = (data as IItemDataRadio); IItemDataSelector selectorData = (data as IItemDataSelector); IItemDataSticky stickyData = (data as IItemDataSticky); IItemDataSlider sliderData = (data as IItemDataSlider); var icon = HoverCanvasDataUpdater.IconPairType.Unspecified; if (checkboxData != null) { icon = (checkboxData.Value ? HoverCanvasDataUpdater.IconPairType.CheckboxOn : HoverCanvasDataUpdater.IconPairType.CheckboxOff); } else if (radioData != null) { icon = (radioData.Value ? HoverCanvasDataUpdater.IconPairType.RadioOn : HoverCanvasDataUpdater.IconPairType.RadioOff); } else if (selectorData != null) { if (selectorData.Action == SelectorActionType.NavigateIn) { icon = HoverCanvasDataUpdater.IconPairType.NavigateIn; } else if (selectorData.Action == SelectorActionType.NavigateOut) { icon = HoverCanvasDataUpdater.IconPairType.NavigateOut; } } else if (stickyData != null) { icon = HoverCanvasDataUpdater.IconPairType.Sticky; } else if (sliderData != null) { icon = HoverCanvasDataUpdater.IconPairType.Slider; } canvasUp.Controllers.Set(HoverCanvasDataUpdater.LabelTextName, this); canvasUp.Controllers.Set(HoverCanvasDataUpdater.IconTypeName, this); canvasUp.LabelText = (sliderData == null ? data.Label : sliderData.GetFormattedLabel(sliderData)); canvasUp.IconType = icon; }
/*--------------------------------------------------------------------------------------------*/ private void UpdateRendererIndicator(HoverRenderer pRenderer, HoverItemHighlightState pHighState, HoverItemSelectionState pSelState) { HoverIndicator rendInd = pRenderer.GetIndicator(); rendInd.Controllers.Set(HoverIndicator.HighlightProgressName, this); rendInd.Controllers.Set(HoverIndicator.SelectionProgressName, this); rendInd.HighlightProgress = pHighState.MaxHighlightProgress; rendInd.SelectionProgress = pSelState.SelectionProgress; if (pSelState.WasSelectedThisFrame) { rendInd.LatestSelectionTime = DateTime.UtcNow; } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void UpdateRenderer(HoverRenderer pRenderer, HoverItem pHoverItem) { pRenderer.Controllers.Set(HoverRenderer.IsEnabledName, this); pRenderer.IsEnabled = pHoverItem.Data.IsEnabled; }