1.. _lv_tabview: 2 3===================== 4Tab View (lv_tabview) 5===================== 6 7 8Overview 9******** 10 11The Tab View Widget can be used to organize content in tabs. The Tab 12View is built from other Widgets: 13 14- Main container: :ref:`base_widget` 15- Tab buttons: an :ref:`base_widget` with :ref:`lv_button` 16- Container for the tabs: :ref:`base_widget` 17- Content of the tabs: :ref:`base_widget` 18 19The tab buttons can be positioned on the top, bottom, left and right 20side of the Tab View. 21 22A new tab can be selected either by clicking on a tab button or by 23sliding horizontally on the content. 24 25 26 27.. _lv_tabview_parts_and_styles: 28 29 30Parts and Styles 31**************** 32 33There are no special parts on the Tab View but the :ref:`base_widget` and 34:ref:`lv_button` Widgets are used to create the Tab View. 35 36 37 38.. _lv_tabview_usage: 39 40Usage 41***** 42 43Creating a Tab View 44------------------- 45 46:cpp:expr:`lv_tabview_create(parent)` creates a new empty Tab View. 47 48Adding tabs 49----------- 50 51New tabs can be added with :cpp:expr:`lv_tabview_add_tab(tabview, "Tab name")`. 52This will return a pointer to a :ref:`base_widget` where 53the tab's content can be created. 54 55Renaming tabs 56------------- 57 58A tab can be renamed with 59:cpp:expr:`lv_tabview_rename_tab(tabview, tab_id, "New Name")`. 60 61Navigating to a new tab 62----------------------- 63 64To select a new tab you can: 65 66- Click on its tab button 67- Slide horizontally 68- Use :cpp:expr:`lv_tabview_set_active(tabview, tab_id, LV_ANIM_ON / OFF)` function 69 70 71Setting tab bar position 72------------------------ 73 74Using the :cpp:expr:`lv_tabview_set_tab_bar_position(tabview, LV_DIR_LEFT/RIGHT/TOP/BOTTOM)` 75the tab bar can be moved to any side. 76 77Setting tab bar size 78-------------------- 79 80The size of the tab bar can be adjusted by :cpp:expr:`lv_tabview_set_tab_bar_size(tabview, size)` 81When tabs are on the top or bottom, this means the height of the tab bar, and when 82they are on the sides, it means the width. 83 84Accessing the parts 85------------------- 86 87- :cpp:expr:`lv_tabview_get_content(tabview)` returns a pointer to the container for 88 tabs content (a :ref:`base_widget`) 89- :cpp:expr:`lv_tabview_get_tab_bar(tabview)` returns a pointer to the container for 90 tab buttons (a :ref:`base_widget`) 91 92 93 94.. _lv_tabview_events: 95 96Events 97****** 98 99- :cpp:enumerator:`LV_EVENT_VALUE_CHANGED` Sent when a new tab is selected by sliding 100 or clicking the tab button. :cpp:expr:`lv_tabview_get_tab_active(tabview)` 101 returns the zero based index of the current tab. 102 103.. admonition:: Further Reading 104 105 Learn more about :ref:`lv_obj_events` emitted by all Widgets. 106 107 Learn more about :ref:`events`. 108 109 110 111.. _lv_tabview_keys: 112 113Keys 114**** 115 116Keys have effect only on the tab buttons. 117Programmatically add these buttons to a group if required. 118 119.. admonition:: Further Reading 120 121 Learn more about :ref:`indev_keys`. 122 123 124 125.. _lv_tabview_example: 126 127Example 128******* 129 130.. include:: ../../examples/widgets/tabview/index.rst 131 132 133 134.. _lv_tabview_api: 135 136API 137*** 138