2016-06-08 07:25:08 +02:00
|
|
|
/**
|
|
|
|
* @file lv_page.c
|
2018-06-19 09:49:58 +02:00
|
|
|
*
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2018-07-07 11:53:22 +02:00
|
|
|
#include "../lv_objx/lv_page.h"
|
2016-06-08 07:25:08 +02:00
|
|
|
#if USE_LV_PAGE != 0
|
|
|
|
|
2017-11-30 11:35:33 +01:00
|
|
|
#include "../lv_core/lv_group.h"
|
2016-10-04 09:45:39 +02:00
|
|
|
#include "../lv_draw/lv_draw.h"
|
2017-11-16 15:32:33 +01:00
|
|
|
#include "../lv_themes/lv_theme.h"
|
2017-11-30 11:35:33 +01:00
|
|
|
#include "../lv_core/lv_refr.h"
|
2017-11-23 20:42:14 +01:00
|
|
|
#include "../lv_misc/lv_anim.h"
|
|
|
|
#include "../lv_misc/lv_math.h"
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
2017-11-05 00:48:57 +01:00
|
|
|
#define LV_PAGE_SB_MIN_SIZE (LV_DPI / 8)
|
2018-10-05 17:22:49 +02:00
|
|
|
#define LV_PAGE_SCROLL_ANIM_TIME 200 /*[ms] Scroll anim time on `lv_page_scroll_up/down/left/rigth`*/
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC PROTOTYPES
|
|
|
|
**********************/
|
2016-10-07 11:15:46 +02:00
|
|
|
static void lv_page_sb_refresh(lv_obj_t * main);
|
2017-12-02 20:50:05 +01:00
|
|
|
static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mode_t mode);
|
2017-11-23 21:28:36 +01:00
|
|
|
static bool lv_scrl_design(lv_obj_t * scrl, const lv_area_t * mask, lv_design_mode_t mode);
|
2017-11-05 00:48:57 +01:00
|
|
|
static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param);
|
|
|
|
static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* STATIC VARIABLES
|
|
|
|
**********************/
|
2017-11-05 00:48:57 +01:00
|
|
|
static lv_design_func_t ancestor_design;
|
2017-11-11 14:23:05 +01:00
|
|
|
static lv_signal_func_t ancestor_signal;
|
2016-10-04 15:19:07 +02:00
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL FUNCTIONS
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a page objects
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param par pointer to an object, it will be the parent of the new page
|
|
|
|
* @param copy pointer to a page object, if not NULL then the new object will be copied from it
|
2016-06-08 07:25:08 +02:00
|
|
|
* @return pointer to the created page
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2018-10-05 17:22:49 +02:00
|
|
|
LV_LOG_TRACE("page create started");
|
2018-07-25 17:57:08 +02:00
|
|
|
|
2016-10-04 09:45:39 +02:00
|
|
|
/*Create the ancestor object*/
|
2017-04-13 16:12:03 +02:00
|
|
|
lv_obj_t * new_page = lv_cont_create(par, copy);
|
2017-11-26 11:38:28 +01:00
|
|
|
lv_mem_assert(new_page);
|
2018-07-25 13:33:53 +02:00
|
|
|
if(new_page == NULL) return NULL;
|
|
|
|
|
2017-11-05 00:48:57 +01:00
|
|
|
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_page);
|
|
|
|
if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_func(new_page);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-04 09:45:39 +02:00
|
|
|
/*Allocate the object type specific extended data*/
|
2017-10-20 10:17:02 +02:00
|
|
|
lv_page_ext_t * ext = lv_obj_allocate_ext_attr(new_page, sizeof(lv_page_ext_t));
|
2017-11-26 11:38:28 +01:00
|
|
|
lv_mem_assert(ext);
|
2018-07-25 13:33:53 +02:00
|
|
|
if(ext == NULL) return NULL;
|
|
|
|
|
2017-01-02 14:10:32 +01:00
|
|
|
ext->scrl = NULL;
|
|
|
|
ext->pr_action = NULL;
|
|
|
|
ext->rel_action = NULL;
|
2017-11-05 00:48:57 +01:00
|
|
|
ext->sb.hor_draw = 0;
|
|
|
|
ext->sb.ver_draw = 0;
|
|
|
|
ext->sb.style = &lv_style_pretty;
|
2017-11-18 00:18:19 +01:00
|
|
|
ext->sb.mode = LV_SB_MODE_AUTO;
|
2018-07-12 23:38:27 +02:00
|
|
|
ext->arrow_scroll = 0;
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2016-10-04 09:45:39 +02:00
|
|
|
/*Init the new page object*/
|
2016-10-07 11:15:46 +02:00
|
|
|
if(copy == NULL) {
|
2018-06-19 09:49:58 +02:00
|
|
|
ext->scrl = lv_cont_create(new_page, NULL);
|
|
|
|
lv_obj_set_signal_func(ext->scrl, lv_page_scrollable_signal);
|
2017-11-05 00:48:57 +01:00
|
|
|
lv_obj_set_design_func(ext->scrl, lv_scrl_design);
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_obj_set_drag(ext->scrl, true);
|
|
|
|
lv_obj_set_drag_throw(ext->scrl, true);
|
|
|
|
lv_obj_set_protect(ext->scrl, LV_PROTECT_PARENT | LV_PROTECT_PRESS_LOST);
|
|
|
|
lv_cont_set_fit(ext->scrl, false, true);
|
2017-04-21 09:15:39 +02:00
|
|
|
|
2018-06-19 09:49:58 +02:00
|
|
|
/* Add the signal function only if 'scrolling' is created
|
|
|
|
* because everything has to be ready before any signal is received*/
|
|
|
|
lv_obj_set_signal_func(new_page, lv_page_signal);
|
|
|
|
lv_obj_set_design_func(new_page, lv_page_design);
|
2017-11-15 15:50:33 +01:00
|
|
|
|
2017-11-05 00:48:57 +01:00
|
|
|
lv_page_set_sb_mode(new_page, ext->sb.mode);
|
2017-11-16 15:32:33 +01:00
|
|
|
|
|
|
|
/*Set the default styles*/
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_theme_t * th = lv_theme_get_current();
|
2017-11-16 15:32:33 +01:00
|
|
|
if(th) {
|
2018-06-19 09:49:58 +02:00
|
|
|
if(par == NULL) { /*Different styles if it is screen*/
|
2017-11-30 14:46:16 +01:00
|
|
|
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->bg);
|
|
|
|
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_transp);
|
|
|
|
} else {
|
|
|
|
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, th->page.bg);
|
|
|
|
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, th->page.scrl);
|
|
|
|
|
|
|
|
}
|
2017-11-16 15:32:33 +01:00
|
|
|
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, th->page.sb);
|
|
|
|
} else {
|
|
|
|
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, &lv_style_pretty_color);
|
|
|
|
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, &lv_style_pretty);
|
|
|
|
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, &lv_style_pretty_color);
|
|
|
|
}
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
} else {
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_page_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
|
|
|
|
ext->scrl = lv_cont_create(new_page, copy_ext->scrl);
|
|
|
|
lv_obj_set_signal_func(ext->scrl, lv_page_scrollable_signal);
|
2016-10-04 09:45:39 +02:00
|
|
|
|
2017-12-11 23:11:15 +01:00
|
|
|
lv_page_set_pr_action(new_page, copy_ext->pr_action);
|
|
|
|
lv_page_set_rel_action(new_page, copy_ext->rel_action);
|
2017-11-05 00:48:57 +01:00
|
|
|
lv_page_set_sb_mode(new_page, copy_ext->sb.mode);
|
2018-07-12 23:38:27 +02:00
|
|
|
lv_page_set_arrow_scroll(new_page, copy_ext->arrow_scroll);
|
|
|
|
|
2017-11-15 15:50:33 +01:00
|
|
|
|
|
|
|
lv_page_set_style(new_page, LV_PAGE_STYLE_BG, lv_page_get_style(copy, LV_PAGE_STYLE_BG));
|
|
|
|
lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy, LV_PAGE_STYLE_SCRL));
|
|
|
|
lv_page_set_style(new_page, LV_PAGE_STYLE_SB, lv_page_get_style(copy, LV_PAGE_STYLE_SB));
|
2017-01-08 13:06:41 +01:00
|
|
|
|
2018-06-19 09:49:58 +02:00
|
|
|
/* Add the signal function only if 'scrolling' is created
|
|
|
|
* because everything has to be ready before any signal is received*/
|
|
|
|
lv_obj_set_signal_func(new_page, lv_page_signal);
|
|
|
|
lv_obj_set_design_func(new_page, lv_page_design);
|
2017-01-02 14:10:32 +01:00
|
|
|
|
2017-01-08 13:06:41 +01:00
|
|
|
/*Refresh the style with new signal function*/
|
2017-10-20 10:17:02 +02:00
|
|
|
lv_obj_refresh_style(new_page);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
2018-06-19 09:49:58 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
lv_page_sb_refresh(new_page);
|
2018-06-19 09:49:58 +02:00
|
|
|
|
2018-10-05 17:22:49 +02:00
|
|
|
LV_LOG_INFO("page created");
|
2018-07-25 17:57:08 +02:00
|
|
|
|
2016-10-07 11:15:46 +02:00
|
|
|
return new_page;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
2018-03-16 11:53:27 -04:00
|
|
|
/**
|
|
|
|
* Delete all children of the scrl object, without deleting scrl child.
|
|
|
|
* @param obj pointer to an object
|
|
|
|
*/
|
2018-09-07 17:09:09 +02:00
|
|
|
void lv_page_clean(lv_obj_t * obj)
|
2018-03-16 11:53:27 -04:00
|
|
|
{
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_obj_t * scrl = lv_page_get_scrl(obj);
|
2018-03-16 11:53:27 -04:00
|
|
|
lv_obj_clean(scrl);
|
|
|
|
}
|
|
|
|
|
2016-10-04 15:29:52 +02:00
|
|
|
/*=====================
|
|
|
|
* Setter functions
|
|
|
|
*====================*/
|
|
|
|
|
2016-12-18 22:07:03 +01:00
|
|
|
/**
|
|
|
|
* Set a release action for the page
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @param rel_action a function to call when the page is released
|
|
|
|
*/
|
2017-12-11 23:11:15 +01:00
|
|
|
void lv_page_set_rel_action(lv_obj_t * page, lv_action_t rel_action)
|
2016-12-18 22:07:03 +01:00
|
|
|
{
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
|
|
|
ext->rel_action = rel_action;
|
2016-12-18 22:07:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a press action for the page
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @param pr_action a function to call when the page is pressed
|
|
|
|
*/
|
2017-12-11 23:11:15 +01:00
|
|
|
void lv_page_set_pr_action(lv_obj_t * page, lv_action_t pr_action)
|
2016-12-18 22:07:03 +01:00
|
|
|
{
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
|
|
|
ext->pr_action = pr_action;
|
2016-12-18 22:07:03 +01:00
|
|
|
}
|
|
|
|
|
2017-04-13 10:20:35 +02:00
|
|
|
/**
|
|
|
|
* Set the scroll bar mode on a page
|
|
|
|
* @param page pointer to a page object
|
2018-07-12 23:38:27 +02:00
|
|
|
* @param sb_mode the new mode from 'lv_page_sb.mode_t' enum
|
2017-04-13 10:20:35 +02:00
|
|
|
*/
|
2017-11-18 00:18:19 +01:00
|
|
|
void lv_page_set_sb_mode(lv_obj_t * page, lv_sb_mode_t sb_mode)
|
2017-04-13 10:20:35 +02:00
|
|
|
{
|
2017-10-20 10:17:02 +02:00
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
2018-05-16 23:09:30 +02:00
|
|
|
if(ext->sb.mode == sb_mode) return;
|
|
|
|
|
2018-10-05 17:22:49 +02:00
|
|
|
if(sb_mode == LV_SB_MODE_HIDE) ext->sb.mode |= LV_SB_MODE_HIDE; /*Set the hidden flag*/
|
|
|
|
else if(sb_mode == LV_SB_MODE_UNHIDE) ext->sb.mode &= (~LV_SB_MODE_HIDE); /*Clear the hidden flag*/
|
2018-08-10 01:11:20 +02:00
|
|
|
else {
|
2018-10-05 17:22:49 +02:00
|
|
|
if(ext->sb.mode & LV_SB_MODE_HIDE) sb_mode |= LV_SB_MODE_HIDE;
|
|
|
|
ext->sb.mode = sb_mode;
|
2018-08-10 01:11:20 +02:00
|
|
|
}
|
2018-08-10 01:04:20 +02:00
|
|
|
|
2017-11-05 00:48:57 +01:00
|
|
|
ext->sb.hor_draw = 0;
|
|
|
|
ext->sb.ver_draw = 0;
|
2018-08-10 01:04:20 +02:00
|
|
|
|
2017-11-05 00:48:57 +01:00
|
|
|
lv_page_sb_refresh(page);
|
2017-10-20 10:17:02 +02:00
|
|
|
lv_obj_invalidate(page);
|
2017-04-13 10:20:35 +02:00
|
|
|
}
|
|
|
|
|
2018-07-12 23:38:27 +02:00
|
|
|
/**
|
|
|
|
* Enable/Disable scrolling with arrows if the page is in group (arrows: LV_GROUP_KEY_LEFT/RIGHT/UP/DOWN)
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @param en true: enable scrolling with arrows
|
|
|
|
*/
|
|
|
|
void lv_page_set_arrow_scroll(lv_obj_t * page, bool en)
|
|
|
|
{
|
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
|
|
|
ext->arrow_scroll = en ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2017-04-13 10:20:35 +02:00
|
|
|
/**
|
2017-11-15 15:50:33 +01:00
|
|
|
* Set a style of a page
|
2017-04-13 10:20:35 +02:00
|
|
|
* @param page pointer to a page object
|
2017-11-15 15:50:33 +01:00
|
|
|
* @param type which style should be set
|
|
|
|
* @param style pointer to a style
|
|
|
|
* */
|
2018-06-19 09:49:58 +02:00
|
|
|
void lv_page_set_style(lv_obj_t * page, lv_page_style_t type, lv_style_t * style)
|
2017-04-13 10:20:35 +02:00
|
|
|
{
|
2017-10-20 10:17:02 +02:00
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
2017-11-15 15:50:33 +01:00
|
|
|
|
2018-06-19 09:49:58 +02:00
|
|
|
switch(type) {
|
2017-11-15 15:50:33 +01:00
|
|
|
case LV_PAGE_STYLE_BG:
|
|
|
|
lv_obj_set_style(page, style);
|
|
|
|
break;
|
|
|
|
case LV_PAGE_STYLE_SCRL:
|
|
|
|
lv_obj_set_style(ext->scrl, style);
|
|
|
|
break;
|
|
|
|
case LV_PAGE_STYLE_SB:
|
|
|
|
ext->sb.style = style;
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_area_set_height(&ext->sb.hor_area, ext->sb.style->body.padding.inner);
|
|
|
|
lv_area_set_width(&ext->sb.ver_area, ext->sb.style->body.padding.inner);
|
2017-11-15 15:50:33 +01:00
|
|
|
lv_page_sb_refresh(page);
|
2017-11-07 14:31:35 +01:00
|
|
|
lv_obj_refresh_ext_size(page);
|
2017-11-15 15:50:33 +01:00
|
|
|
lv_obj_invalidate(page);
|
|
|
|
break;
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
2017-11-15 15:50:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*=====================
|
|
|
|
* Getter functions
|
|
|
|
*====================*/
|
2017-11-05 00:48:57 +01:00
|
|
|
|
2017-11-15 15:50:33 +01:00
|
|
|
/**
|
|
|
|
* Get the scrollable object of a page
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @return pointer to a container which is the scrollable part of the page
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_obj_t * lv_page_get_scrl(const lv_obj_t * page)
|
2017-11-15 15:50:33 +01:00
|
|
|
{
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
2017-11-15 15:50:33 +01:00
|
|
|
|
2018-06-19 09:49:58 +02:00
|
|
|
return ext->scrl;
|
2017-04-13 10:20:35 +02:00
|
|
|
}
|
2016-12-18 22:07:03 +01:00
|
|
|
|
2018-08-13 19:09:27 +02:00
|
|
|
/**
|
|
|
|
* Get the press action of the page
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @return a function to call when the page is pressed
|
|
|
|
*/
|
|
|
|
lv_action_t lv_page_get_pr_action(lv_obj_t * page)
|
|
|
|
{
|
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
|
|
|
return ext->pr_action;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the release action of the page
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @return a function to call when the page is released
|
|
|
|
*/
|
|
|
|
lv_action_t lv_page_get_rel_action(lv_obj_t * page)
|
|
|
|
{
|
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
|
|
|
return ext->rel_action;
|
|
|
|
}
|
|
|
|
|
2017-11-15 15:50:33 +01:00
|
|
|
/**
|
|
|
|
* Set the scroll bar mode on a page
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @return the mode from 'lv_page_sb.mode_t' enum
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_sb_mode_t lv_page_get_sb_mode(const lv_obj_t * page)
|
2017-11-15 15:50:33 +01:00
|
|
|
{
|
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
|
|
|
return ext->sb.mode;
|
|
|
|
}
|
|
|
|
|
2018-07-12 23:38:27 +02:00
|
|
|
/**
|
|
|
|
* Get the the scrolling with arrows (LV_GROUP_KEY_LEFT/RIGHT/UP/DOWN) is enabled or not
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @return true: scrolling with arrows is enabled
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
bool lv_page_get_arrow_scroll(const lv_obj_t * page)
|
2018-07-12 23:38:27 +02:00
|
|
|
{
|
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
|
|
|
return ext->arrow_scroll ? true : false;
|
|
|
|
}
|
|
|
|
|
2018-10-17 05:42:27 +02:00
|
|
|
/**
|
|
|
|
* Get that width which can be set to the children to still not cause overflow (show scrollbars)
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @return the width which still fits into the page
|
|
|
|
*/
|
|
|
|
lv_coord_t lv_page_get_fit_width(lv_obj_t * page)
|
|
|
|
{
|
|
|
|
lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
|
|
|
lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
|
|
|
|
|
|
|
return lv_obj_get_width(page) - 2 * (bg_style->body.padding.hor + scrl_style->body.padding.hor);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get that height which can be set to the children to still not cause overflow (show scrollbars)
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @return the height which still fits into the page
|
|
|
|
*/
|
|
|
|
lv_coord_t lv_page_get_fit_height(lv_obj_t * page)
|
|
|
|
{
|
|
|
|
lv_style_t * bg_style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
|
|
|
lv_style_t * scrl_style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
|
|
|
|
|
|
|
return lv_obj_get_height(page) - 2 * (bg_style->body.padding.ver + scrl_style->body.padding.ver);
|
|
|
|
}
|
|
|
|
|
2017-11-15 15:50:33 +01:00
|
|
|
/**
|
|
|
|
* Get a style of a page
|
|
|
|
* @param page pointer to page object
|
|
|
|
* @param type which style should be get
|
|
|
|
* @return style pointer to a style
|
|
|
|
* */
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_style_t * lv_page_get_style(const lv_obj_t * page, lv_page_style_t type)
|
2017-11-15 15:50:33 +01:00
|
|
|
{
|
2018-11-05 22:21:20 -06:00
|
|
|
lv_style_t * style = NULL;
|
2017-11-15 15:50:33 +01:00
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
|
|
|
|
2018-06-19 09:49:58 +02:00
|
|
|
switch(type) {
|
|
|
|
case LV_PAGE_STYLE_BG:
|
2018-11-05 22:21:20 -06:00
|
|
|
style = lv_obj_get_style(page);
|
|
|
|
break;
|
2018-06-19 09:49:58 +02:00
|
|
|
case LV_PAGE_STYLE_SCRL:
|
2018-11-05 22:21:20 -06:00
|
|
|
style = lv_obj_get_style(ext->scrl);
|
|
|
|
break;
|
2018-06-19 09:49:58 +02:00
|
|
|
case LV_PAGE_STYLE_SB:
|
2018-11-05 22:21:20 -06:00
|
|
|
style = ext->sb.style;
|
|
|
|
break;
|
2018-06-19 09:49:58 +02:00
|
|
|
default:
|
2018-11-05 22:21:20 -06:00
|
|
|
style = NULL;
|
|
|
|
break;
|
2017-11-15 15:50:33 +01:00
|
|
|
}
|
|
|
|
|
2018-11-05 22:21:20 -06:00
|
|
|
return style;
|
2017-11-15 15:50:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*=====================
|
|
|
|
* Other functions
|
|
|
|
*====================*/
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**
|
|
|
|
* Glue the object to the page. After it the page can be moved (dragged) with this object too.
|
2016-12-17 10:50:28 +01:00
|
|
|
* @param obj pointer to an object on a page
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param glue true: enable glue, false: disable glue
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-12-17 10:50:28 +01:00
|
|
|
void lv_page_glue_obj(lv_obj_t * obj, bool glue)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2016-12-17 10:50:28 +01:00
|
|
|
lv_obj_set_drag_parent(obj, glue);
|
|
|
|
lv_obj_set_drag(obj, glue);
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
|
|
|
|
2016-12-17 21:22:16 +01:00
|
|
|
/**
|
|
|
|
* Focus on an object. It ensures that the object will be visible on the page.
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @param obj pointer to an object to focus (must be on the page)
|
2017-05-12 16:09:37 +02:00
|
|
|
* @param anim_time scroll animation time in milliseconds (0: no animation)
|
2016-12-17 21:22:16 +01:00
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time)
|
2016-12-17 21:22:16 +01:00
|
|
|
{
|
2018-07-03 14:27:53 +02:00
|
|
|
|
2018-10-15 19:00:03 +02:00
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
|
|
|
|
2018-07-03 14:27:53 +02:00
|
|
|
#if USE_LV_ANIMATION == 0
|
2018-07-06 17:12:06 +03:00
|
|
|
anim_time = 0;
|
2018-07-06 16:29:45 +03:00
|
|
|
#else
|
2018-07-06 17:12:06 +03:00
|
|
|
/* Be sure there is no position changing animation in progress
|
|
|
|
* because it can overide the current changes*/
|
|
|
|
lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_y);
|
|
|
|
lv_anim_del(page, (lv_anim_fp_t)lv_obj_set_pos);
|
2018-10-15 19:00:03 +02:00
|
|
|
lv_anim_del(ext->scrl, (lv_anim_fp_t)lv_obj_set_y);
|
|
|
|
lv_anim_del(ext->scrl, (lv_anim_fp_t)lv_obj_set_pos);
|
2018-07-03 14:27:53 +02:00
|
|
|
#endif
|
|
|
|
|
2017-11-15 15:50:33 +01:00
|
|
|
lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
|
|
|
lv_style_t * style_scrl = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);
|
2016-12-17 21:22:16 +01:00
|
|
|
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_coord_t obj_y = obj->coords.y1 - ext->scrl->coords.y1;
|
|
|
|
lv_coord_t obj_h = lv_obj_get_height(obj);
|
|
|
|
lv_coord_t scrlable_y = lv_obj_get_y(ext->scrl);
|
|
|
|
lv_coord_t page_h = lv_obj_get_height(page);
|
2016-12-17 21:22:16 +01:00
|
|
|
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_coord_t top_err = -(scrlable_y + obj_y);
|
|
|
|
lv_coord_t bot_err = scrlable_y + obj_y + obj_h - page_h;
|
2016-12-19 11:58:11 +01:00
|
|
|
|
2017-11-15 15:50:33 +01:00
|
|
|
/*If obj is higher then the page focus where the "error" is smaller*/
|
2017-11-05 00:48:57 +01:00
|
|
|
|
2017-11-15 15:50:33 +01:00
|
|
|
/*Out of the page on the top*/
|
|
|
|
if((obj_h <= page_h && top_err > 0) ||
|
2018-06-19 09:49:58 +02:00
|
|
|
(obj_h > page_h && top_err < bot_err)) {
|
2017-11-15 15:50:33 +01:00
|
|
|
/*Calculate a new position and let some space above*/
|
|
|
|
scrlable_y = -(obj_y - style_scrl->body.padding.ver - style->body.padding.ver);
|
|
|
|
scrlable_y += style_scrl->body.padding.ver;
|
|
|
|
}
|
|
|
|
/*Out of the page on the bottom*/
|
|
|
|
else if((obj_h <= page_h && bot_err > 0) ||
|
|
|
|
(obj_h > page_h && top_err >= bot_err)) {
|
2017-11-05 00:48:57 +01:00
|
|
|
/*Calculate a new position and let some space below*/
|
2018-06-11 16:00:30 -07:00
|
|
|
scrlable_y = -(obj_y + style_scrl->body.padding.ver + style->body.padding.ver);
|
2017-10-26 21:20:10 +02:00
|
|
|
scrlable_y -= style_scrl->body.padding.ver;
|
2018-06-11 16:00:30 -07:00
|
|
|
scrlable_y += page_h - obj_h;
|
2017-11-15 15:50:33 +01:00
|
|
|
} else {
|
|
|
|
/*Already in focus*/
|
|
|
|
return;
|
|
|
|
}
|
2016-12-17 21:22:16 +01:00
|
|
|
|
2017-05-02 00:16:48 +02:00
|
|
|
if(anim_time == 0) {
|
2017-11-15 15:50:33 +01:00
|
|
|
lv_obj_set_y(ext->scrl, scrlable_y);
|
2017-12-07 19:22:23 +01:00
|
|
|
#if USE_LV_ANIMATION
|
2018-07-06 16:29:45 +03:00
|
|
|
} else {
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_anim_t a;
|
2017-05-02 00:16:48 +02:00
|
|
|
a.act_time = 0;
|
|
|
|
a.start = lv_obj_get_y(ext->scrl);
|
|
|
|
a.end = scrlable_y;
|
2017-05-03 15:06:32 +02:00
|
|
|
a.time = anim_time;
|
2017-05-02 00:16:48 +02:00
|
|
|
a.end_cb = NULL;
|
|
|
|
a.playback = 0;
|
|
|
|
a.repeat = 0;
|
|
|
|
a.var = ext->scrl;
|
2017-12-17 01:54:09 +01:00
|
|
|
a.path = lv_anim_path_linear;
|
2017-11-23 21:28:36 +01:00
|
|
|
a.fp = (lv_anim_fp_t) lv_obj_set_y;
|
|
|
|
lv_anim_create(&a);
|
2017-11-27 17:48:54 +01:00
|
|
|
#endif
|
2017-05-02 00:16:48 +02:00
|
|
|
}
|
2016-12-17 21:22:16 +01:00
|
|
|
}
|
2016-10-04 15:29:52 +02:00
|
|
|
|
2018-08-04 21:48:40 +02:00
|
|
|
/**
|
2018-08-10 01:04:20 +02:00
|
|
|
* Scroll the page horizontally
|
2018-08-04 21:48:40 +02:00
|
|
|
* @param page pointer to a page object
|
2018-08-10 01:04:20 +02:00
|
|
|
* @param dist the distance to scroll (< 0: scroll right; > 0 scroll left)
|
2018-08-04 21:48:40 +02:00
|
|
|
*/
|
2018-08-10 01:04:20 +02:00
|
|
|
void lv_page_scroll_hor(lv_obj_t * page, lv_coord_t dist)
|
2018-08-04 21:48:40 +02:00
|
|
|
{
|
2018-10-05 17:22:49 +02:00
|
|
|
lv_obj_t * scrl = lv_page_get_scrl(page);
|
2018-08-04 21:48:40 +02:00
|
|
|
|
|
|
|
#if USE_LV_ANIMATION
|
2018-10-05 17:22:49 +02:00
|
|
|
lv_anim_t a;
|
|
|
|
a.var = scrl;
|
|
|
|
a.start = lv_obj_get_x(scrl);
|
|
|
|
a.end = a.start + dist;
|
|
|
|
a.fp = (lv_anim_fp_t)lv_obj_set_x;
|
|
|
|
a.path = lv_anim_path_linear;
|
|
|
|
a.end_cb = NULL;
|
|
|
|
a.act_time = 0;
|
|
|
|
a.time = LV_PAGE_SCROLL_ANIM_TIME;
|
|
|
|
a.playback = 0;
|
|
|
|
a.playback_pause = 0;
|
|
|
|
a.repeat = 0;
|
|
|
|
a.repeat_pause = 0;
|
|
|
|
lv_anim_create(&a);
|
2018-08-04 21:48:40 +02:00
|
|
|
#else
|
2018-10-05 17:22:49 +02:00
|
|
|
lv_obj_set_x(scrl, lv_obj_get_x(scrl) + dist);
|
2018-08-04 21:48:40 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-08-10 01:04:20 +02:00
|
|
|
* Scroll the page vertically
|
2018-08-04 21:48:40 +02:00
|
|
|
* @param page pointer to a page object
|
2018-08-10 01:04:20 +02:00
|
|
|
* @param dist the distance to scroll (< 0: scroll down; > 0 scroll up)
|
2018-08-04 21:48:40 +02:00
|
|
|
*/
|
2018-08-10 01:04:20 +02:00
|
|
|
void lv_page_scroll_ver(lv_obj_t * page, lv_coord_t dist)
|
2018-08-04 21:48:40 +02:00
|
|
|
{
|
2018-10-05 17:22:49 +02:00
|
|
|
lv_obj_t * scrl = lv_page_get_scrl(page);
|
2018-08-10 01:04:20 +02:00
|
|
|
|
2018-08-04 21:48:40 +02:00
|
|
|
#if USE_LV_ANIMATION
|
2018-10-05 17:22:49 +02:00
|
|
|
lv_anim_t a;
|
|
|
|
a.var = scrl;
|
|
|
|
a.start = lv_obj_get_y(scrl);
|
|
|
|
a.end = a.start + dist;
|
|
|
|
a.fp = (lv_anim_fp_t)lv_obj_set_y;
|
|
|
|
a.path = lv_anim_path_linear;
|
|
|
|
a.end_cb = NULL;
|
|
|
|
a.act_time = 0;
|
|
|
|
a.time = LV_PAGE_SCROLL_ANIM_TIME;
|
|
|
|
a.playback = 0;
|
|
|
|
a.playback_pause = 0;
|
|
|
|
a.repeat = 0;
|
|
|
|
a.repeat_pause = 0;
|
|
|
|
lv_anim_create(&a);
|
2018-08-04 21:48:40 +02:00
|
|
|
#else
|
2018-10-05 17:22:49 +02:00
|
|
|
lv_obj_set_y(scrl, lv_obj_get_x(scrl) + dist);
|
2018-08-04 21:48:40 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**********************
|
|
|
|
* STATIC FUNCTIONS
|
|
|
|
**********************/
|
|
|
|
|
2016-10-04 09:45:39 +02:00
|
|
|
/**
|
|
|
|
* Handle the drawing related tasks of the pages
|
2016-10-07 11:15:46 +02:00
|
|
|
* @param page pointer to an object
|
2016-10-04 09:45:39 +02:00
|
|
|
* @param mask the object will be drawn only in this area
|
|
|
|
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
|
|
|
* (return 'true' if yes)
|
|
|
|
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
|
|
|
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
|
|
|
* @param return true/false, depends on 'mode'
|
|
|
|
*/
|
2017-12-02 20:50:05 +01:00
|
|
|
static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mode_t mode)
|
2016-10-04 09:45:39 +02:00
|
|
|
{
|
|
|
|
if(mode == LV_DESIGN_COVER_CHK) {
|
2018-06-19 09:49:58 +02:00
|
|
|
return ancestor_design(page, mask, mode);
|
2016-10-04 09:45:39 +02:00
|
|
|
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
2017-12-02 20:50:05 +01:00
|
|
|
/*Draw without border*/
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
2017-12-02 20:50:05 +01:00
|
|
|
lv_coord_t border_width_tmp = style->body.border.width;
|
|
|
|
style->body.border.width = 0;
|
2018-06-14 13:08:19 +02:00
|
|
|
lv_draw_rect(&page->coords, mask, style, lv_obj_get_opa_scale(page));
|
2017-12-02 20:50:05 +01:00
|
|
|
style->body.border.width = border_width_tmp;
|
|
|
|
|
2018-06-19 09:49:58 +02:00
|
|
|
} else if(mode == LV_DESIGN_DRAW_POST) { /*Draw the scroll bars finally*/
|
2017-12-02 20:50:05 +01:00
|
|
|
|
|
|
|
/*Draw only a border*/
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_BG);
|
2017-12-02 20:50:05 +01:00
|
|
|
lv_coord_t shadow_width_tmp = style->body.shadow.width;
|
|
|
|
uint8_t empty_tmp = style->body.empty;
|
|
|
|
style->body.shadow.width = 0;
|
|
|
|
style->body.empty = 1;
|
2018-06-14 13:08:19 +02:00
|
|
|
lv_draw_rect(&page->coords, mask, style, lv_obj_get_opa_scale(page));
|
2017-12-02 20:50:05 +01:00
|
|
|
style->body.shadow.width = shadow_width_tmp;
|
|
|
|
style->body.empty = empty_tmp;
|
|
|
|
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
2016-10-04 09:45:39 +02:00
|
|
|
|
2018-06-19 09:49:58 +02:00
|
|
|
/*Draw the scrollbars*/
|
|
|
|
lv_area_t sb_area;
|
2018-08-10 01:04:20 +02:00
|
|
|
if(ext->sb.hor_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) {
|
2018-06-19 09:49:58 +02:00
|
|
|
/*Convert the relative coordinates to absolute*/
|
2017-11-28 16:15:13 +01:00
|
|
|
lv_area_copy(&sb_area, &ext->sb.hor_area);
|
2018-06-19 09:49:58 +02:00
|
|
|
sb_area.x1 += page->coords.x1;
|
2017-12-02 20:50:05 +01:00
|
|
|
sb_area.y1 += page->coords.y1;
|
|
|
|
sb_area.x2 += page->coords.x1;
|
|
|
|
sb_area.y2 += page->coords.y1;
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_draw_rect(&sb_area, mask, ext->sb.style, lv_obj_get_opa_scale(page));
|
|
|
|
}
|
2016-10-04 09:45:39 +02:00
|
|
|
|
2018-08-10 01:04:20 +02:00
|
|
|
if(ext->sb.ver_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) {
|
2017-01-04 11:54:39 +01:00
|
|
|
/*Convert the relative coordinates to absolute*/
|
2017-11-28 16:15:13 +01:00
|
|
|
lv_area_copy(&sb_area, &ext->sb.ver_area);
|
2017-12-02 20:50:05 +01:00
|
|
|
sb_area.x1 += page->coords.x1;
|
|
|
|
sb_area.y1 += page->coords.y1;
|
|
|
|
sb_area.x2 += page->coords.x1;
|
|
|
|
sb_area.y2 += page->coords.y1;
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_draw_rect(&sb_area, mask, ext->sb.style, lv_obj_get_opa_scale(page));
|
|
|
|
}
|
|
|
|
}
|
2016-10-04 09:45:39 +02:00
|
|
|
|
2018-06-19 09:49:58 +02:00
|
|
|
return true;
|
2016-10-04 09:45:39 +02:00
|
|
|
}
|
2017-11-05 00:48:57 +01:00
|
|
|
|
2017-07-20 01:09:20 +02:00
|
|
|
/**
|
|
|
|
* Handle the drawing related tasks of the scrollable object
|
|
|
|
* @param scrl pointer to an object
|
|
|
|
* @param mask the object will be drawn only in this area
|
|
|
|
* @param mode LV_DESIGN_COVER_CHK: only check if the object fully covers the 'mask_p' area
|
|
|
|
* (return 'true' if yes)
|
|
|
|
* LV_DESIGN_DRAW: draw the object (always return 'true')
|
|
|
|
* LV_DESIGN_DRAW_POST: drawing after every children are drawn
|
|
|
|
* @param return true/false, depends on 'mode'
|
|
|
|
*/
|
2017-11-23 21:28:36 +01:00
|
|
|
static bool lv_scrl_design(lv_obj_t * scrl, const lv_area_t * mask, lv_design_mode_t mode)
|
2017-07-20 01:09:20 +02:00
|
|
|
{
|
|
|
|
if(mode == LV_DESIGN_COVER_CHK) {
|
2017-11-05 00:48:57 +01:00
|
|
|
return ancestor_design(scrl, mask, mode);
|
2017-07-20 01:09:20 +02:00
|
|
|
} else if(mode == LV_DESIGN_DRAW_MAIN) {
|
2017-12-07 19:22:23 +01:00
|
|
|
#if USE_LV_GROUP
|
2018-09-23 23:27:28 +02:00
|
|
|
/* If the page is focused in a group and
|
2018-10-05 10:10:16 +02:00
|
|
|
* the background object is not visible (transparent or empty)
|
2018-09-23 23:27:28 +02:00
|
|
|
* then "activate" the style of the scrollable*/
|
2018-10-05 10:10:16 +02:00
|
|
|
lv_style_t * style_scrl_ori = lv_obj_get_style(scrl);
|
2017-07-20 01:09:20 +02:00
|
|
|
lv_obj_t * page = lv_obj_get_parent(scrl);
|
|
|
|
lv_style_t * style_page = lv_obj_get_style(page);
|
|
|
|
lv_group_t * g = lv_obj_get_group(page);
|
2018-10-28 23:18:22 +01:00
|
|
|
if((style_page->body.empty || style_page->body.opa == LV_OPA_TRANSP) && style_page->body.border.width == 0) { /*Is the background visible?*/
|
2017-07-25 09:02:21 +02:00
|
|
|
if(lv_group_get_focused(g) == page) {
|
2017-07-20 01:09:20 +02:00
|
|
|
lv_style_t * style_mod;
|
2018-10-05 10:10:16 +02:00
|
|
|
style_mod = lv_group_mod_style(g, style_scrl_ori);
|
2017-07-20 01:09:20 +02:00
|
|
|
scrl->style_p = style_mod; /*Temporally change the style to the activated */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2017-11-05 00:48:57 +01:00
|
|
|
ancestor_design(scrl, mask, mode);
|
2017-07-20 01:09:20 +02:00
|
|
|
|
2017-12-07 19:22:23 +01:00
|
|
|
#if USE_LV_GROUP
|
2018-10-05 10:10:16 +02:00
|
|
|
scrl->style_p = style_scrl_ori; /*Revert the style*/
|
2017-07-20 01:09:20 +02:00
|
|
|
#endif
|
|
|
|
} else if(mode == LV_DESIGN_DRAW_POST) {
|
2017-11-05 00:48:57 +01:00
|
|
|
ancestor_design(scrl, mask, mode);
|
2017-07-20 01:09:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-05 00:48:57 +01:00
|
|
|
/**
|
|
|
|
* Signal function of the page
|
|
|
|
* @param page pointer to a page object
|
|
|
|
* @param sign a signal type from lv_signal_t enum
|
|
|
|
* @param param pointer to a signal specific variable
|
|
|
|
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
|
|
|
|
*/
|
|
|
|
static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
|
|
|
|
{
|
|
|
|
lv_res_t res;
|
|
|
|
|
|
|
|
/* Include the ancient signal function */
|
|
|
|
res = ancestor_signal(page, sign, param);
|
2017-11-07 17:00:55 +01:00
|
|
|
if(res != LV_RES_OK) return res;
|
2017-11-05 00:48:57 +01:00
|
|
|
|
2017-11-07 17:00:55 +01:00
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
|
|
|
lv_style_t * style = lv_obj_get_style(page);
|
|
|
|
lv_obj_t * child;
|
|
|
|
if(sign == LV_SIGNAL_CHILD_CHG) { /*Automatically move children to the scrollable object*/
|
|
|
|
child = lv_obj_get_child(page, NULL);
|
|
|
|
while(child != NULL) {
|
|
|
|
if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) {
|
|
|
|
lv_obj_t * tmp = child;
|
|
|
|
child = lv_obj_get_child(page, child); /*Get the next child before move this*/
|
|
|
|
lv_obj_set_parent(tmp, ext->scrl);
|
|
|
|
} else {
|
|
|
|
child = lv_obj_get_child(page, child);
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
|
|
|
}
|
2018-06-19 09:49:58 +02:00
|
|
|
} else if(sign == LV_SIGNAL_STYLE_CHG) {
|
2017-11-07 17:00:55 +01:00
|
|
|
/*If no hor_fit enabled set the scrollable's width to the page's width*/
|
|
|
|
if(lv_cont_get_hor_fit(ext->scrl) == false) {
|
|
|
|
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.padding.hor);
|
|
|
|
} else {
|
|
|
|
ext->scrl->signal_func(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*The scrollbars are important only if they are visible now*/
|
|
|
|
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
|
|
|
|
|
|
|
|
/*Refresh the ext. size because the scrollbars might be positioned out of the page*/
|
|
|
|
lv_obj_refresh_ext_size(page);
|
2018-06-19 09:49:58 +02:00
|
|
|
} else if(sign == LV_SIGNAL_CORD_CHG) {
|
2017-11-07 17:00:55 +01:00
|
|
|
/*Refresh the scrollbar and notify the scrl if the size is changed*/
|
2017-11-28 16:15:13 +01:00
|
|
|
if(ext->scrl != NULL && (lv_obj_get_width(page) != lv_area_get_width(param) ||
|
2018-06-19 09:49:58 +02:00
|
|
|
lv_obj_get_height(page) != lv_area_get_height(param))) {
|
2017-11-05 00:48:57 +01:00
|
|
|
/*If no hor_fit enabled set the scrollable's width to the page's width*/
|
|
|
|
if(lv_cont_get_hor_fit(ext->scrl) == false) {
|
|
|
|
lv_obj_set_width(ext->scrl, lv_obj_get_width(page) - 2 * style->body.padding.hor);
|
|
|
|
}
|
|
|
|
|
2017-11-07 17:00:55 +01:00
|
|
|
ext->scrl->signal_func(ext->scrl, LV_SIGNAL_CORD_CHG, &ext->scrl->coords);
|
|
|
|
|
2017-11-05 00:48:57 +01:00
|
|
|
/*The scrollbars are important only if they are visible now*/
|
|
|
|
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
|
|
|
|
}
|
2018-06-19 09:49:58 +02:00
|
|
|
} else if(sign == LV_SIGNAL_PRESSED) {
|
2017-11-07 17:00:55 +01:00
|
|
|
if(ext->pr_action != NULL) {
|
2018-10-15 19:33:34 +02:00
|
|
|
res = ext->pr_action(page);
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
2018-06-19 09:49:58 +02:00
|
|
|
} else if(sign == LV_SIGNAL_RELEASED) {
|
2017-11-07 17:00:55 +01:00
|
|
|
if(lv_indev_is_dragging(lv_indev_get_act()) == false) {
|
|
|
|
if(ext->rel_action != NULL) {
|
2018-10-15 19:33:34 +02:00
|
|
|
res = ext->rel_action(page);
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
|
|
|
}
|
2018-06-19 09:49:58 +02:00
|
|
|
} else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
|
2017-11-07 17:00:55 +01:00
|
|
|
/*Ensure ext. size for the scrollbars if they are out of the page*/
|
|
|
|
if(page->ext_size < (-ext->sb.style->body.padding.hor)) page->ext_size = -ext->sb.style->body.padding.hor;
|
|
|
|
if(page->ext_size < (-ext->sb.style->body.padding.ver)) page->ext_size = -ext->sb.style->body.padding.ver;
|
2018-07-03 14:19:04 +02:00
|
|
|
} else if(sign == LV_SIGNAL_CONTROLL) {
|
2018-07-06 17:12:06 +03:00
|
|
|
uint32_t c = *((uint32_t *) param);
|
2018-07-12 23:38:27 +02:00
|
|
|
|
2018-08-10 01:04:20 +02:00
|
|
|
if((c == LV_GROUP_KEY_DOWN) && ext->arrow_scroll) {
|
2018-10-05 17:22:49 +02:00
|
|
|
lv_page_scroll_ver(page, - lv_obj_get_height(page) / 4);
|
2018-08-10 01:04:20 +02:00
|
|
|
} else if((c == LV_GROUP_KEY_UP) && ext->arrow_scroll) {
|
2018-10-05 17:22:49 +02:00
|
|
|
lv_page_scroll_ver(page, lv_obj_get_height(page) / 4);
|
2018-08-10 01:04:20 +02:00
|
|
|
} else if((c == LV_GROUP_KEY_RIGHT) && ext->arrow_scroll) {
|
2018-09-26 14:21:39 +02:00
|
|
|
/*If the page can be scrolled horizontally because it's not wide enough then scroll it vertically*/
|
|
|
|
if(lv_page_get_scrl_width(page) < lv_obj_get_width(page)) lv_page_scroll_ver(page, - lv_obj_get_height(page) / 4);
|
|
|
|
else lv_page_scroll_hor(page, - lv_obj_get_width(page) / 4);
|
2018-08-10 01:04:20 +02:00
|
|
|
} else if((c == LV_GROUP_KEY_LEFT) && ext->arrow_scroll) {
|
2018-09-26 14:21:39 +02:00
|
|
|
/*If the page can be scrolled horizontally because it's not wide enough then scroll it vertically*/
|
|
|
|
if(lv_page_get_scrl_width(page) < lv_obj_get_width(page)) lv_page_scroll_ver(page, lv_obj_get_height(page) / 4);
|
|
|
|
else lv_page_scroll_hor(page, lv_obj_get_width(page) / 4);
|
2018-07-06 17:12:06 +03:00
|
|
|
}
|
2018-07-25 21:52:50 +02:00
|
|
|
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
|
2018-10-05 17:22:49 +02:00
|
|
|
bool * editable = (bool *)param;
|
|
|
|
*editable = lv_page_get_arrow_scroll(page);
|
2018-07-06 17:12:06 +03:00
|
|
|
} else if(sign == LV_SIGNAL_GET_TYPE) {
|
2018-02-28 15:37:41 +01:00
|
|
|
lv_obj_type_t * buf = param;
|
|
|
|
uint8_t i;
|
|
|
|
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
|
|
|
|
if(buf->type[i] == NULL) break;
|
|
|
|
}
|
|
|
|
buf->type[i] = "lv_page";
|
|
|
|
}
|
2017-11-05 00:48:57 +01:00
|
|
|
|
2017-11-15 15:50:33 +01:00
|
|
|
return res;
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Signal function of the scrollable part of a page
|
|
|
|
* @param scrl pointer to the scrollable object
|
|
|
|
* @param sign a signal type from lv_signal_t enum
|
|
|
|
* @param param pointer to a signal specific variable
|
|
|
|
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
|
|
|
|
*/
|
|
|
|
static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void * param)
|
|
|
|
{
|
|
|
|
lv_res_t res;
|
|
|
|
|
|
|
|
/* Include the ancient signal function */
|
|
|
|
res = ancestor_signal(scrl, sign, param);
|
2017-11-07 17:00:55 +01:00
|
|
|
if(res != LV_RES_OK) return res;
|
2017-11-05 00:48:57 +01:00
|
|
|
|
2017-11-07 17:00:55 +01:00
|
|
|
lv_obj_t * page = lv_obj_get_parent(scrl);
|
|
|
|
lv_style_t * page_style = lv_obj_get_style(page);
|
|
|
|
lv_page_ext_t * page_ext = lv_obj_get_ext_attr(page);
|
2017-11-05 00:48:57 +01:00
|
|
|
|
2017-11-07 17:00:55 +01:00
|
|
|
if(sign == LV_SIGNAL_CORD_CHG) {
|
|
|
|
/*Limit the position of the scrollable object to be always visible
|
|
|
|
* (Do not let its edge inner then its parent respective edge)*/
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_coord_t new_x;
|
|
|
|
lv_coord_t new_y;
|
2017-11-07 17:00:55 +01:00
|
|
|
bool refr_x = false;
|
|
|
|
bool refr_y = false;
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_area_t page_cords;
|
|
|
|
lv_area_t scrl_cords;
|
|
|
|
lv_coord_t hpad = page_style->body.padding.hor;
|
|
|
|
lv_coord_t vpad = page_style->body.padding.ver;
|
2017-11-07 17:00:55 +01:00
|
|
|
|
|
|
|
new_x = lv_obj_get_x(scrl);
|
|
|
|
new_y = lv_obj_get_y(scrl);
|
|
|
|
lv_obj_get_coords(scrl, &scrl_cords);
|
|
|
|
lv_obj_get_coords(page, &page_cords);
|
|
|
|
|
|
|
|
/*scrollable width smaller then page width? -> align to left*/
|
2017-11-28 16:15:13 +01:00
|
|
|
if(lv_area_get_width(&scrl_cords) + 2 * hpad < lv_area_get_width(&page_cords)) {
|
2017-11-07 17:00:55 +01:00
|
|
|
if(scrl_cords.x1 != page_cords.x1 + hpad) {
|
|
|
|
new_x = hpad;
|
|
|
|
refr_x = true;
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
2017-11-07 17:00:55 +01:00
|
|
|
} else {
|
|
|
|
/*The edges of the scrollable can not be in the page (minus hpad) */
|
|
|
|
if(scrl_cords.x2 < page_cords.x2 - hpad) {
|
2018-06-19 09:49:58 +02:00
|
|
|
new_x = lv_area_get_width(&page_cords) - lv_area_get_width(&scrl_cords) - hpad; /* Right align */
|
|
|
|
refr_x = true;
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
2018-06-19 09:49:58 +02:00
|
|
|
if(scrl_cords.x1 > page_cords.x1 + hpad) {
|
2017-11-07 17:00:55 +01:00
|
|
|
new_x = hpad; /*Left align*/
|
|
|
|
refr_x = true;
|
|
|
|
}
|
|
|
|
}
|
2017-11-05 00:48:57 +01:00
|
|
|
|
2017-11-07 17:00:55 +01:00
|
|
|
/*scrollable height smaller then page height? -> align to left*/
|
2017-11-28 16:15:13 +01:00
|
|
|
if(lv_area_get_height(&scrl_cords) + 2 * vpad < lv_area_get_height(&page_cords)) {
|
2017-11-07 17:00:55 +01:00
|
|
|
if(scrl_cords.y1 != page_cords.y1 + vpad) {
|
|
|
|
new_y = vpad;
|
|
|
|
refr_y = true;
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
2017-11-07 17:00:55 +01:00
|
|
|
} else {
|
|
|
|
/*The edges of the scrollable can not be in the page (minus vpad) */
|
|
|
|
if(scrl_cords.y2 < page_cords.y2 - vpad) {
|
2018-06-19 09:49:58 +02:00
|
|
|
new_y = lv_area_get_height(&page_cords) - lv_area_get_height(&scrl_cords) - vpad; /* Bottom align */
|
|
|
|
refr_y = true;
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
2018-06-19 09:49:58 +02:00
|
|
|
if(scrl_cords.y1 > page_cords.y1 + vpad) {
|
2017-11-07 17:00:55 +01:00
|
|
|
new_y = vpad; /*Top align*/
|
|
|
|
refr_y = true;
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
|
|
|
}
|
2017-11-07 17:00:55 +01:00
|
|
|
if(refr_x != false || refr_y != false) {
|
|
|
|
lv_obj_set_pos(scrl, new_x, new_y);
|
|
|
|
}
|
|
|
|
|
|
|
|
lv_page_sb_refresh(page);
|
2018-06-19 09:49:58 +02:00
|
|
|
} else if(sign == LV_SIGNAL_DRAG_END) {
|
2017-11-07 17:00:55 +01:00
|
|
|
/*Hide scrollbars if required*/
|
2017-11-18 00:18:19 +01:00
|
|
|
if(page_ext->sb.mode == LV_SB_MODE_DRAG) {
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_area_t sb_area_tmp;
|
2017-11-07 17:00:55 +01:00
|
|
|
if(page_ext->sb.hor_draw) {
|
2017-11-28 16:15:13 +01:00
|
|
|
lv_area_copy(&sb_area_tmp, &page_ext->sb.hor_area);
|
2017-11-07 17:00:55 +01:00
|
|
|
sb_area_tmp.x1 += page->coords.x1;
|
|
|
|
sb_area_tmp.y1 += page->coords.y1;
|
2018-07-12 17:16:14 +02:00
|
|
|
sb_area_tmp.x2 += page->coords.x1;
|
|
|
|
sb_area_tmp.y2 += page->coords.y1;
|
2017-11-07 17:00:55 +01:00
|
|
|
lv_inv_area(&sb_area_tmp);
|
|
|
|
page_ext->sb.hor_draw = 0;
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
2017-11-07 17:00:55 +01:00
|
|
|
if(page_ext->sb.ver_draw) {
|
2017-11-28 16:15:13 +01:00
|
|
|
lv_area_copy(&sb_area_tmp, &page_ext->sb.ver_area);
|
2017-11-07 17:00:55 +01:00
|
|
|
sb_area_tmp.x1 += page->coords.x1;
|
|
|
|
sb_area_tmp.y1 += page->coords.y1;
|
2018-07-12 17:16:14 +02:00
|
|
|
sb_area_tmp.x2 += page->coords.x1;
|
|
|
|
sb_area_tmp.y2 += page->coords.y1;
|
2017-11-07 17:00:55 +01:00
|
|
|
lv_inv_area(&sb_area_tmp);
|
|
|
|
page_ext->sb.ver_draw = 0;
|
|
|
|
}
|
|
|
|
}
|
2018-06-19 09:49:58 +02:00
|
|
|
} else if(sign == LV_SIGNAL_PRESSED) {
|
2017-11-07 17:00:55 +01:00
|
|
|
if(page_ext->pr_action != NULL) {
|
2018-10-15 19:33:34 +02:00
|
|
|
res = page_ext->pr_action(page);
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
2018-06-19 09:49:58 +02:00
|
|
|
} else if(sign == LV_SIGNAL_RELEASED) {
|
2017-11-07 17:00:55 +01:00
|
|
|
if(lv_indev_is_dragging(lv_indev_get_act()) == false) {
|
|
|
|
if(page_ext->rel_action != NULL) {
|
2018-10-15 19:33:34 +02:00
|
|
|
res = page_ext->rel_action(page);
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-15 15:50:33 +01:00
|
|
|
return res;
|
2017-11-05 00:48:57 +01:00
|
|
|
}
|
2017-07-20 01:09:20 +02:00
|
|
|
|
2016-10-04 09:45:39 +02:00
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**
|
2016-10-07 11:15:46 +02:00
|
|
|
* Refresh the position and size of the scroll bars.
|
|
|
|
* @param page pointer to a page object
|
2016-06-08 07:25:08 +02:00
|
|
|
*/
|
2016-10-07 11:15:46 +02:00
|
|
|
static void lv_page_sb_refresh(lv_obj_t * page)
|
2016-06-08 07:25:08 +02:00
|
|
|
{
|
2017-01-01 22:56:09 +01:00
|
|
|
|
2017-10-20 10:17:02 +02:00
|
|
|
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
|
2017-04-13 10:20:35 +02:00
|
|
|
lv_style_t * style = lv_obj_get_style(page);
|
|
|
|
lv_obj_t * scrl = ext->scrl;
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_coord_t size_tmp;
|
|
|
|
lv_coord_t scrl_w = lv_obj_get_width(scrl);
|
|
|
|
lv_coord_t scrl_h = lv_obj_get_height(scrl);
|
|
|
|
lv_coord_t hpad = style->body.padding.hor;
|
|
|
|
lv_coord_t vpad = style->body.padding.ver;
|
|
|
|
lv_coord_t obj_w = lv_obj_get_width(page);
|
|
|
|
lv_coord_t obj_h = lv_obj_get_height(page);
|
2016-10-07 11:15:46 +02:00
|
|
|
|
2017-11-05 00:48:57 +01:00
|
|
|
/*Always let 'scrollbar width' padding above, under, left and right to the scrollbars
|
|
|
|
* else:
|
|
|
|
* - horizontal and vertical scrollbars can overlap on the corners
|
|
|
|
* - if the page has radius the scrollbar can be out of the radius */
|
2017-11-24 17:48:47 +01:00
|
|
|
lv_coord_t sb_hor_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.hor);
|
|
|
|
lv_coord_t sb_ver_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.ver);
|
2016-12-21 14:49:23 +01:00
|
|
|
|
2017-11-18 00:18:19 +01:00
|
|
|
if(ext->sb.mode == LV_SB_MODE_OFF) return;
|
2017-11-05 00:48:57 +01:00
|
|
|
|
2017-11-18 00:18:19 +01:00
|
|
|
if(ext->sb.mode == LV_SB_MODE_ON) {
|
2017-11-05 00:48:57 +01:00
|
|
|
ext->sb.hor_draw = 1;
|
|
|
|
ext->sb.ver_draw = 1;
|
2017-01-04 11:54:39 +01:00
|
|
|
}
|
|
|
|
|
2016-12-21 14:49:23 +01:00
|
|
|
/*Invalidate the current (old) scrollbar areas*/
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_area_t sb_area_tmp;
|
2017-11-05 00:48:57 +01:00
|
|
|
if(ext->sb.hor_draw != 0) {
|
2017-11-28 16:15:13 +01:00
|
|
|
lv_area_copy(&sb_area_tmp, &ext->sb.hor_area);
|
2017-10-20 10:17:02 +02:00
|
|
|
sb_area_tmp.x1 += page->coords.x1;
|
|
|
|
sb_area_tmp.y1 += page->coords.y1;
|
2018-07-12 17:16:14 +02:00
|
|
|
sb_area_tmp.x2 += page->coords.x1;
|
|
|
|
sb_area_tmp.y2 += page->coords.y1;
|
2017-01-04 11:54:39 +01:00
|
|
|
lv_inv_area(&sb_area_tmp);
|
|
|
|
}
|
2017-11-05 00:48:57 +01:00
|
|
|
if(ext->sb.ver_draw != 0) {
|
2017-11-28 16:15:13 +01:00
|
|
|
lv_area_copy(&sb_area_tmp, &ext->sb.ver_area);
|
2017-10-20 10:17:02 +02:00
|
|
|
sb_area_tmp.x1 += page->coords.x1;
|
|
|
|
sb_area_tmp.y1 += page->coords.y1;
|
2018-07-12 17:16:14 +02:00
|
|
|
sb_area_tmp.x2 += page->coords.x1;
|
|
|
|
sb_area_tmp.y2 += page->coords.y1;
|
2017-01-04 11:54:39 +01:00
|
|
|
lv_inv_area(&sb_area_tmp);
|
|
|
|
}
|
2016-10-04 09:45:39 +02:00
|
|
|
|
2017-11-05 00:48:57 +01:00
|
|
|
|
2017-11-18 00:18:19 +01:00
|
|
|
if(ext->sb.mode == LV_SB_MODE_DRAG && lv_indev_is_dragging(lv_indev_get_act()) == false) {
|
2017-11-05 00:48:57 +01:00
|
|
|
ext->sb.hor_draw = 0;
|
|
|
|
ext->sb.ver_draw = 0;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*Horizontal scrollbar*/
|
2017-01-01 22:56:09 +01:00
|
|
|
if(scrl_w <= obj_w - 2 * hpad) { /*Full sized scroll bar*/
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_area_set_width(&ext->sb.hor_area, obj_w - 2 * sb_hor_pad);
|
|
|
|
lv_area_set_pos(&ext->sb.hor_area, sb_hor_pad, obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.ver);
|
2017-11-18 00:18:19 +01:00
|
|
|
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.hor_draw = 0;
|
2016-10-04 09:45:39 +02:00
|
|
|
} else {
|
2017-11-05 00:48:57 +01:00
|
|
|
size_tmp = (obj_w * (obj_w - (2 * sb_hor_pad))) / (scrl_w + 2 * hpad);
|
|
|
|
if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE;
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_area_set_width(&ext->sb.hor_area, size_tmp);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_area_set_pos(&ext->sb.hor_area, sb_hor_pad +
|
2018-06-19 09:49:58 +02:00
|
|
|
(-(lv_obj_get_x(scrl) - hpad) * (obj_w - size_tmp - 2 * sb_hor_pad)) /
|
|
|
|
(scrl_w + 2 * hpad - obj_w),
|
|
|
|
obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.ver);
|
2017-01-04 12:07:55 +01:00
|
|
|
|
2017-11-18 00:18:19 +01:00
|
|
|
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.hor_draw = 1;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
2018-06-19 09:49:58 +02:00
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*Vertical scrollbar*/
|
2017-01-01 22:56:09 +01:00
|
|
|
if(scrl_h <= obj_h - 2 * vpad) { /*Full sized scroll bar*/
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_area_set_height(&ext->sb.ver_area, obj_h - 2 * sb_ver_pad);
|
|
|
|
lv_area_set_pos(&ext->sb.ver_area, obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.hor, sb_ver_pad);
|
2017-11-18 00:18:19 +01:00
|
|
|
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 0;
|
2016-06-08 07:25:08 +02:00
|
|
|
} else {
|
2017-11-05 00:48:57 +01:00
|
|
|
size_tmp = (obj_h * (obj_h - (2 * sb_ver_pad))) / (scrl_h + 2 * vpad);
|
|
|
|
if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE;
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_area_set_height(&ext->sb.ver_area, size_tmp);
|
2016-06-08 07:25:08 +02:00
|
|
|
|
2017-11-23 21:28:36 +01:00
|
|
|
lv_area_set_pos(&ext->sb.ver_area, obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.hor,
|
2018-06-19 09:49:58 +02:00
|
|
|
sb_ver_pad +
|
|
|
|
(-(lv_obj_get_y(scrl) - vpad) * (obj_h - size_tmp - 2 * sb_ver_pad)) /
|
|
|
|
(scrl_h + 2 * vpad - obj_h));
|
2017-01-04 12:07:55 +01:00
|
|
|
|
2017-11-18 00:18:19 +01:00
|
|
|
if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 1;
|
2016-06-08 07:25:08 +02:00
|
|
|
}
|
2016-12-21 14:49:23 +01:00
|
|
|
|
|
|
|
/*Invalidate the new scrollbar areas*/
|
2017-11-05 00:48:57 +01:00
|
|
|
if(ext->sb.hor_draw != 0) {
|
2017-11-28 16:15:13 +01:00
|
|
|
lv_area_copy(&sb_area_tmp, &ext->sb.hor_area);
|
2017-10-20 10:17:02 +02:00
|
|
|
sb_area_tmp.x1 += page->coords.x1;
|
|
|
|
sb_area_tmp.y1 += page->coords.y1;
|
2018-07-12 17:16:14 +02:00
|
|
|
sb_area_tmp.x2 += page->coords.x1;
|
|
|
|
sb_area_tmp.y2 += page->coords.y1;
|
2017-01-04 11:54:39 +01:00
|
|
|
lv_inv_area(&sb_area_tmp);
|
|
|
|
}
|
2017-11-05 00:48:57 +01:00
|
|
|
if(ext->sb.ver_draw != 0) {
|
2017-11-28 16:15:13 +01:00
|
|
|
lv_area_copy(&sb_area_tmp, &ext->sb.ver_area);
|
2017-10-20 10:17:02 +02:00
|
|
|
sb_area_tmp.x1 += page->coords.x1;
|
|
|
|
sb_area_tmp.y1 += page->coords.y1;
|
2018-07-12 17:16:14 +02:00
|
|
|
sb_area_tmp.x2 += page->coords.x1;
|
|
|
|
sb_area_tmp.y2 += page->coords.y1;
|
2017-01-04 11:54:39 +01:00
|
|
|
lv_inv_area(&sb_area_tmp);
|
|
|
|
}
|
2016-10-04 15:19:07 +02:00
|
|
|
}
|
2016-10-04 09:45:39 +02:00
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
#endif
|