//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public NavRoot GetRoot() { if (vRootLevel == null) { vRootLevel = new NavLevel(GetChildItems); vRoot.Build(vRootLevel); } return(vRoot); }
/*--------------------------------------------------------------------------------------------*/ private void SetNewLevel(NavLevel pNewLevel, int pDirection) { if (vCurrLevel != null) { vCurrLevel.OnItemSelected -= HandleItemSelected; vCurrLevel.SetActiveOnLevelChange(false, pDirection); } vCurrLevel = pNewLevel; vCurrLevel.OnItemSelected += HandleItemSelected; vCurrLevel.SetActiveOnLevelChange(true, pDirection); OnLevelChange(pDirection); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void HandleItemSelected(NavLevel pLevel, NavItem pItem) { vDelgate.HandleItemSelection(pLevel, pItem); if (pItem.Type == NavItem.ItemType.Parent) { vHistory.Push(vCurrLevel); SetNewLevel(pItem.ChildLevel, 1); return; } if (pItem.NavigateBackUponSelect) { Back(); } }
/*--------------------------------------------------------------------------------------------*/ public string GetLevelTitle() { NavLevel level = GetParentLevel(); return(level == null ? vDelgate.GetTopLevelTitle() : level.LastSelectedParentItem.Label); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public NavItemParent(string pLabel, float pRelativeSize = 1) : base(ItemType.Parent, pLabel, pRelativeSize) { ChildLevel = new NavLevel(); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public NavItemParent(Func <NavItem[]> pGetItems) : base(ItemType.Parent) { ChildLevel = new NavLevel(pGetItems); }
/*--------------------------------------------------------------------------------------------*/ public void Build(NavLevel pRootLevel) { SetNewLevel(pRootLevel, 0); }