2024-01-04 07:25:13 +01:00
|
|
|
.. _lv_tabview:
|
|
|
|
|
|
|
|
====================
|
2023-04-27 06:42:02 -06:00
|
|
|
Tabview (lv_tabview)
|
|
|
|
====================
|
|
|
|
|
|
|
|
Overview
|
|
|
|
********
|
|
|
|
|
|
|
|
The Tab view object can be used to organize content in tabs. The Tab
|
|
|
|
view is built from other widgets:
|
|
|
|
|
2024-01-04 07:25:13 +01:00
|
|
|
- Main container: :ref:`lv_obj`
|
|
|
|
- Tab buttons: an :ref:`lv_obj` with :ref:`lv_button`
|
|
|
|
- Container for the tabs: :ref:`lv_obj`
|
|
|
|
- Content of the tabs: :ref:`lv_obj`
|
2023-04-27 06:42:02 -06:00
|
|
|
|
|
|
|
The tab buttons can be positioned on the top, bottom, left and right
|
|
|
|
side of the Tab view.
|
|
|
|
|
|
|
|
A new tab can be selected either by clicking on a tab button or by
|
|
|
|
sliding horizontally on the content.
|
|
|
|
|
2024-01-04 07:25:13 +01:00
|
|
|
.. _lv_tabview_parts_and_styles:
|
|
|
|
|
2023-04-27 06:42:02 -06:00
|
|
|
Parts and Styles
|
|
|
|
****************
|
|
|
|
|
|
|
|
There are no special parts on the Tab view but the ``lv_obj`` and
|
2023-12-11 18:15:51 +01:00
|
|
|
``lv_button`` widgets are used to create the Tab view.
|
2023-04-27 06:42:02 -06:00
|
|
|
|
2024-01-04 07:25:13 +01:00
|
|
|
.. _lv_tabview_usage:
|
|
|
|
|
2023-04-27 06:42:02 -06:00
|
|
|
Usage
|
|
|
|
*****
|
|
|
|
|
|
|
|
Create a Tab view
|
|
|
|
-----------------
|
|
|
|
|
2024-01-04 07:25:13 +01:00
|
|
|
:cpp:expr:`lv_tabview_create(parent)` creates a new empty Tab view.
|
|
|
|
|
2023-04-27 06:42:02 -06:00
|
|
|
Add tabs
|
|
|
|
--------
|
|
|
|
|
|
|
|
New tabs can be added with :cpp:expr:`lv_tabview_add_tab(tabview, "Tab name")`.
|
2024-01-04 07:25:13 +01:00
|
|
|
This will return a pointer to an :ref:`lv_obj` object where
|
2023-04-27 11:47:13 -06:00
|
|
|
the tab's content can be created.
|
2023-04-27 06:42:02 -06:00
|
|
|
|
|
|
|
Rename tabs
|
|
|
|
-----------
|
|
|
|
|
|
|
|
A tab can be renamed with
|
|
|
|
:cpp:expr:`lv_tabview_rename_tab(tabview, tab_id, "New Name")`.
|
|
|
|
|
|
|
|
Change tab
|
|
|
|
----------
|
|
|
|
|
|
|
|
To select a new tab you can:
|
|
|
|
|
|
|
|
- Click on its tab button
|
|
|
|
- Slide horizontally
|
2023-10-31 19:13:45 +01:00
|
|
|
- Use :cpp:expr:`lv_tabview_set_active(tabview, id, LV_ANIM_ON)` function
|
2023-04-27 06:42:02 -06:00
|
|
|
|
2023-12-11 18:15:51 +01:00
|
|
|
|
|
|
|
Set tab bar position
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
Using the :cpp:expr:`lv_tabview_set_tab_bar_position(tabview, LV_DIR_LEFT/RIGHT/TOP/BOTTOM)`
|
|
|
|
the tab bar can be moved to any sides.
|
|
|
|
|
2024-02-05 08:56:08 +01:00
|
|
|
Set tab bar size
|
2023-12-11 18:15:51 +01:00
|
|
|
----------------
|
|
|
|
|
2024-02-05 08:56:08 +01:00
|
|
|
The size of the tab bar can be adjusted by :cpp:expr:`lv_tabview_set_tab_bar_size(tabview, size)`
|
2023-12-11 18:15:51 +01:00
|
|
|
In case of vertical arrangement is means the height of the tab bar, and in horizontal
|
|
|
|
arrangement it means the width.
|
|
|
|
|
2023-04-27 06:42:02 -06:00
|
|
|
Get the parts
|
|
|
|
-------------
|
|
|
|
|
2024-02-05 08:56:08 +01:00
|
|
|
- :cpp:expr:`lv_tabview_get_content(tabview)` returns the container for tabs content
|
|
|
|
- :cpp:expr:`lv_tabview_get_tab_bar(tabview)` returns the container for tabs buttons
|
2024-01-04 07:25:13 +01:00
|
|
|
|
|
|
|
.. _lv_tabview_events:
|
2023-04-27 06:42:02 -06:00
|
|
|
|
|
|
|
Events
|
|
|
|
******
|
|
|
|
|
|
|
|
- :cpp:enumerator:`LV_EVENT_VALUE_CHANGED` Sent when a new tab is selected by sliding
|
2023-10-31 19:13:45 +01:00
|
|
|
or clicking the tab button. :cpp:expr:`lv_tabview_get_tab_active(tabview)`
|
2023-04-27 06:42:02 -06:00
|
|
|
returns the zero based index of the current tab.
|
|
|
|
|
|
|
|
Learn more about :ref:`events`.
|
|
|
|
|
2024-01-04 07:25:13 +01:00
|
|
|
.. _lv_tabview_keys:
|
|
|
|
|
2023-04-27 06:42:02 -06:00
|
|
|
Keys
|
|
|
|
****
|
|
|
|
|
2024-02-05 08:56:08 +01:00
|
|
|
Keys have effect only on the tab buttons.
|
|
|
|
Add manually to a group if required.
|
2023-04-27 06:42:02 -06:00
|
|
|
|
|
|
|
Learn more about :ref:`indev_keys`.
|
|
|
|
|
2024-01-04 07:25:13 +01:00
|
|
|
.. _lv_tabview_example:
|
|
|
|
|
2023-04-27 06:42:02 -06:00
|
|
|
Example
|
|
|
|
*******
|
|
|
|
|
|
|
|
.. include:: ../examples/widgets/tabview/index.rst
|
|
|
|
|
2024-01-04 07:25:13 +01:00
|
|
|
.. _lv_tabview_api:
|
|
|
|
|
2023-04-27 06:42:02 -06:00
|
|
|
API
|
|
|
|
***
|