diff options
author | JF002 <JF002@users.noreply.github.com> | 2020-10-04 12:21:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-04 12:21:22 +0200 |
commit | 39954bbd3afb592a0c3109e3479594183e8d0778 (patch) | |
tree | 58efd04aa38b8dc7989c51fe3c9cdb9a3fb46a54 /src/displayapp/screens/Tab.cpp | |
parent | 5adc97702c326d0252df6da75ce4ac244a4b3553 (diff) | |
parent | 6c86d1d9d706706fcb6f214aba8259e61ed68755 (diff) |
Merge pull request #68 from Avamander/patch-1
Rename folders to follow a consistent style
Diffstat (limited to 'src/displayapp/screens/Tab.cpp')
-rw-r--r-- | src/displayapp/screens/Tab.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/displayapp/screens/Tab.cpp b/src/displayapp/screens/Tab.cpp new file mode 100644 index 00000000..adc32578 --- /dev/null +++ b/src/displayapp/screens/Tab.cpp @@ -0,0 +1,67 @@ +#include <cstdio> +#include <libs/date/includes/date/date.h> +#include <Components/DateTime/DateTimeController.h> +#include <Version.h> +#include <libs/lvgl/src/lv_core/lv_obj.h> +#include <libs/lvgl/src/lv_font/lv_font.h> +#include <libs/lvgl/lvgl.h> +#include <libraries/log/nrf_log.h> +#include "Tab.h" +#include <DisplayApp/DisplayApp.h> + + +using namespace Pinetime::Applications::Screens; + +extern lv_font_t jetbrains_mono_bold_20; + +//static void event_handler(lv_obj_t * obj, lv_event_t event) { +// Tile* screen = static_cast<Tile *>(obj->user_data); +// screen->OnObjectEvent(obj, event); +//} + +Tab::Tab(DisplayApp* app, Pinetime::Components::Gfx &gfx) : Screen(app, gfx) { +/*Create a Tab view object*/ + lv_obj_t *tabview; + tabview = lv_tabview_create(lv_scr_act(), NULL); + + /*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/ + lv_obj_t *tab1 = lv_tabview_add_tab(tabview, "Tab 1"); + lv_obj_t *tab2 = lv_tabview_add_tab(tabview, "Tab 2"); + lv_obj_t *tab3 = lv_tabview_add_tab(tabview, "Tab 3"); + + + /*Add content to the tabs*/ + lv_obj_t * label = lv_label_create(tab1, NULL); + lv_label_set_text(label, "This the first tab\n\n" + "If the content\n" + "of a tab\n" + "become too long\n" + "the it \n" + "automatically\n" + "become\n" + "scrollable."); + + label = lv_label_create(tab2, NULL); + lv_label_set_text(label, "Second tab"); + + label = lv_label_create(tab3, NULL); + lv_label_set_text(label, "Third tab"); + +} + +Tab::~Tab() { + lv_obj_clean(lv_scr_act()); +} + +void Tab::Refresh(bool fullRefresh) { + +} + +void Tab::OnObjectEvent(lv_obj_t *obj, lv_event_t event) { + if(event == LV_EVENT_CLICKED) { + NRF_LOG_INFO("Clicked"); + } + else if(event == LV_EVENT_VALUE_CHANGED) { + NRF_LOG_INFO("Toggled"); + } +} |