/// <summary> /// Sets the settings data to build nav tabs based on. /// </summary> public void SetSettingsData(ISettingsData data) { if (data == null) { Cleanup(); return; } if (this.settingsData == data) { return; } Cleanup(); this.settingsData = data; InvokeAfterTransformed(1, () => { CellSize = new Vector2(Width, Height / data.TabCount); foreach (var tabData in data.GetTabs()) { var tabButton = CreateChild <NavTab>("tab-" + tabData.Name, tabs.Count); tabButton.SetTabData(tabData); tabs.Add(tabButton); tabButton.OnTriggered += () => { OnTabFocused?.Invoke(tabData); }; } }); }
/// <summary> /// Sets the settings data to display content for. /// </summary> public void SetSettingsData(ISettingsData settingsData) { if (settingsData == null) { Cleanup(); return; } else if (this.settingsData == settingsData) { return; } Cleanup(); this.settingsData = settingsData; InvokeAfterTransformed(1, () => { scrollviewHeight = Height; // Create content groups. ResetPosition(); container.Height = containerHeight = 0f; foreach (var tab in settingsData.GetTabs()) { var group = container.CreateChild <ContentGroup>(tab.Name); { group.Anchor = AnchorType.TopStretch; group.Pivot = PivotType.Top; group.Y = -container.Height; group.SetOffsetHorizontal(0f); } group.SetTabData(tab); groups.Add(group); container.Height = (containerHeight += group.Height); } maxScrollPos = Math.Max(containerHeight - scrollviewHeight, 0f); // Cache position progress of each group for tab focus feature. if (maxScrollPos > 0f) { foreach (var group in groups) { group.PositionProgress = -group.Y / containerHeight; } } }); }