Exemple #1
0
        private void AddItemByIndex(TabItemData itemData, int index)
        {
            if (null == itemData)
            {
                return;
            }
            int h        = 0;
            int topSpace = (int)Style.ItemPadding.Top;

            if (Style.UnderLine != null && Style.UnderLine.Size != null)
            {
                h = (int)Style.UnderLine.Size.Height;
            }

            Tab.TabItem item = new TabItem();
            item.TextItem.ApplyStyle(Style.Text);

            item.Text          = itemData.Text;
            item.Size2D.Height = Size2D.Height - h - topSpace;
            item.Position2D.Y  = topSpace;
            item.TouchEvent   += ItemTouchEvent;
            Add(item);

            if (index >= itemList.Count)
            {
                itemList.Add(item);
            }
            else
            {
                itemList.Insert(index, item);
            }

            UpdateItems();
        }
Exemple #2
0
        /// <summary>
        /// タブ追加
        /// </summary>
        /// <param name="tabItem">タブ表示データ</param>
        private void AddTabItem(TabItemData tabItem)
        {
            TabItems.Add(tabItem);

            SelectedTabIndex = TabItems.Count - 1;
            CallPropertyChanged("CallSelectedTabItem");
        }
Exemple #3
0
        private void AddItemByIndex(TabItemData itemData, int index)
        {
            int h        = 0;
            int topSpace = (int)tabAttributes.Space.Z;

            if (tabAttributes.UnderLineAttributes != null && tabAttributes.UnderLineAttributes.Size2D != null)
            {
                h = tabAttributes.UnderLineAttributes.Size2D.Height;
            }
            Tab.TabItem item = new TabItem();
            ApplyAttributes(item.TextItem, tabAttributes.TextAttributes);
            item.TextItem.Text = itemData.Text;
            item.Size2D.Height = Size2D.Height - h - topSpace;
            item.Position2D.Y  = topSpace;
            item.TouchEvent   += ItemTouchEvent;
            Add(item);

            if (index >= itemList.Count)
            {
                itemList.Add(item);
            }
            else
            {
                itemList.Insert(index, item);
            }

            UpdateItems();
        }
Exemple #4
0
 /// <summary>
 /// 数据绑定
 /// </summary>
 /// <param name="itemData"></param>
 void BindTabItem(TabItemData itemData)
 {
     itemData.TabTitle.group = m_ToggleGroup;
     itemData.TabTitle.isOn  = false;
     itemData.TabContent.SetActive(false);
     itemData.TabTitle.onValueChanged.AddListener((isOn) => TitleItem_OnValueChanged(isOn, itemData));
 }
Exemple #5
0
    /// <summary>
    /// 添加一个Tab页
    /// </summary>
    /// <param name="key"></param>
    /// <param name="tabToggle"></param>
    /// <param name="content"></param>
    public void AddTabItem(int key, Toggle tabToggle, GameObject content)
    {
        if (tabToggle == null || content == null)
        {
            Debug.LogErrorFormat("Can't add null value in tab control to gameObject name[{0}], please check it!", name);
            return;
        }

        TabItemData itemData = new TabItemData(key, tabToggle, content);

        BindTabItem(itemData);
    }
Exemple #6
0
 /// <summary>
 /// TitleItem 状态变化
 /// </summary>
 /// <param name="isOn"></param>
 /// <param name="itemData"></param>
 void TitleItem_OnValueChanged(bool isOn, TabItemData itemData)
 {
     if (isOn)
     {
         int preKey = m_CurrentKey;
         m_CurrentKey = itemData.Key;
         itemData.TabContent.SetActive(true);
         NotifyEvent(preKey, m_CurrentKey);
     }
     else
     {
         itemData.TabContent.SetActive(false);
     }
 }
Exemple #7
0
    /// <summary>
    /// 重置控件定位到那个元素上
    /// </summary>
    /// <param name="key"></param>
    public bool ResetTabOnItem(int key)
    {
        TabItemData findItem = m_TabItemDataList.Find(item => item.Key == key);

        if (findItem != null)
        {
            findItem.TabTitle.isOn = true;
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemple #8
0
        public void TabAddItem()
        {
            tlog.Debug(tag, $"TabAddItem START");

            var testingTarget = new Tab();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <Tab>(testingTarget, "Should return Tab instance.");

            try
            {
                TabItemData item1 = new TabItemData();
                testingTarget.AddItem(item1);
                TabItemData item2 = new TabItemData();
                testingTarget.InsertItem(item2, 1);

                testingTarget.SelectedItemIndex = 1;

                try
                {
                    testingTarget.DeleteItem(0);
                }
                catch (Exception e)
                {
                    tlog.Debug(tag, e.Message.ToString());
                    Assert.Fail("Caught Exception : Failed!");
                }
            }
            catch (Exception e)
            {
                tlog.Debug(tag, e.Message.ToString());
                Assert.Fail("Caught Exception : Failed!");
            }

            testingTarget.Dispose();
            tlog.Debug(tag, $"TabAddItem END (OK)");
        }
Exemple #9
0
    private void Awake()
    {
        m_ToggleGroup = GetComponent <ToggleGroup>();
        if (m_ToggleGroup == null)
        {
            m_ToggleGroup = gameObject.AddComponent <ToggleGroup>();
        }
        m_ToggleGroup.allowSwitchOff = false;

        if (m_TabItemDataList.Count > 0)
        {
            for (int i = 0; i < m_TabItemDataList.Count; i++)
            {
                TabItemData itemData = m_TabItemDataList[i];
                if (itemData == null)
                {
                    continue;
                }
                if (itemData.TabTitle == null || itemData.TabContent == null)
                {
                    Debug.LogErrorFormat("Some tab item data contains null value, please check it, in TabControl script whit gameObject name[{0}]", name);
                    continue;
                }
                BindTabItem(itemData);
            }

            // 设置默认页签
            if (!ResetTabOnItem(m_CurrentKey))
            {
                if (m_TabItemDataList.Count > 0)
                {
                    m_TabItemDataList[0].TabTitle.isOn = true;
                }
            }
        }
    }
Exemple #10
0
 /// <summary>
 /// Insert tab item by item data. The inserted item will be added to the special position by index automatically.
 /// </summary>
 /// <param name="itemData">Item data which will apply to tab item view.</param>
 /// <param name="index">Position index where will be inserted.</param>
 /// <since_tizen> 6 </since_tizen>
 public void InsertItem(TabItemData itemData, int index)
 {
     AddItemByIndex(itemData, index);
 }
Exemple #11
0
 /// <summary>
 /// Add tab item by item data. The added item will be added to end of all items automatically.
 /// </summary>
 /// <param name="itemData">Item data which will apply to tab item view.</param>
 /// <since_tizen> 6 </since_tizen>
 public void AddItem(TabItemData itemData)
 {
     AddItemByIndex(itemData, itemList.Count);
 }
Exemple #12
0
 /// <summary>
 /// タブを閉じる
 /// </summary>
 /// <param name="tabItem">タブ表示データ</param>
 private void CloseTabItem(TabItemData tabItem)
 {
     TabItems.Remove(tabItem);
 }