1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

Merge branch 'dev-6.0' of https://github.com/littlevgl/lvgl into dev-6.0

This commit is contained in:
Gabor Kiss-Vamosi 2019-03-09 05:51:46 +01:00
commit 2640727b29
5 changed files with 126 additions and 7 deletions

View File

@ -185,7 +185,7 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in t
* LV_OBJ SETTINGS
*==================*/
typedef void * lv_obj_user_data_t; /*Declare the type of the user data of object (can be e.g. `void *`, `int`, `struct`)*/
#define LV_OBJ_REALIGN 0 /*Enable `lv_obj_realaign()` based on `lv_obj_align()` parameters*/
#define LV_OBJ_REALIGN 0 /*Enable `lv_obj_realign()` based on `lv_obj_align()` parameters*/
/*==================
* LV OBJ X USAGE

View File

@ -285,7 +285,7 @@ lv_indev_feedback_t lv_indev_get_feedback(const lv_indev_t *indev)
*/
void lv_indev_wait_release(lv_indev_t * indev)
{
indev->proc.types.pointer.wait_unil_release = 1;
indev->proc.types.pointer.wait_until_release = 1;
}
/**********************
@ -644,7 +644,7 @@ static void indev_proc_press(lv_indev_proc_t * proc)
{
lv_obj_t * pr_obj = proc->types.pointer.act_obj;
if(proc->types.pointer.wait_unil_release != 0) return;
if(proc->types.pointer.wait_until_release != 0) return;
lv_disp_t * disp = indev_act->driver.disp;
@ -782,12 +782,12 @@ static void indev_proc_press(lv_indev_proc_t * proc)
*/
static void indev_proc_release(lv_indev_proc_t * proc)
{
if(proc->types.pointer.wait_unil_release != 0) {
if(proc->types.pointer.wait_until_release != 0) {
proc->types.pointer.act_obj = NULL;
proc->types.pointer.last_obj = NULL;
proc->pr_timestamp = 0;
proc->longpr_rep_timestamp = 0;
proc->types.pointer.wait_unil_release = 0;
proc->types.pointer.wait_until_release = 0;
}
/*Forget the act obj and send a released signal */

View File

@ -99,7 +99,7 @@ typedef struct _lv_indev_proc_t {
/*Flags*/
uint8_t drag_limit_out :1;
uint8_t drag_in_prog :1;
uint8_t wait_unil_release :1;
uint8_t wait_until_release :1;
}pointer;
struct { /*Keypad data*/
lv_indev_state_t last_state;

View File

@ -76,6 +76,9 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy)
ext->w = lv_obj_get_width(new_img);
ext->h = lv_obj_get_height(new_img);
ext->auto_size = 1;
ext->offset.x = 0;
ext->offset.y = 0;
/*Init the new object*/
lv_obj_set_signal_cb(new_img, lv_img_signal);
@ -214,6 +217,56 @@ void lv_img_set_auto_size(lv_obj_t * img, bool en)
ext->auto_size = (en == false ? 0 : 1);
}
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
* @param img pointer to an image
* @param x: the new offset along x axis.
* @param y: the new offset along y axis.
*/
void lv_img_set_offset(lv_obj_t *img, lv_coord_t x, lv_coord_t y)
{
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
if((x < ext->w - 1) && (y < ext->h - 1)) {
ext->offset.x = x;
ext->offset.y = y;
lv_obj_invalidate(img);
}
}
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
* @param img pointer to an image
* @param x: the new offset along x axis.
*/
void lv_img_set_offset_x(lv_obj_t *img, lv_coord_t x)
{
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
if(x < ext->w - 1) {
ext->offset.x = x;
lv_obj_invalidate(img);
}
}
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
* @param img pointer to an image
* @param y: the new offset along y axis.
*/
void lv_img_set_offset_y(lv_obj_t *img, lv_coord_t y)
{
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
if(y < ext->h - 1) {
ext->offset.y = y;
lv_obj_invalidate(img);
}
}
/*=====================
* Getter functions
@ -257,6 +310,30 @@ bool lv_img_get_auto_size(const lv_obj_t * img)
return ext->auto_size == 0 ? false : true;
}
/**
* Get the offset.x attribute of the img object.
* @param img pointer to an image
* @return offset.x value.
*/
lv_coord_t lv_img_get_offset_x(lv_obj_t *img)
{
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
return ext->offset.x;
}
/**
* Get the offset.y attribute of the img object.
* @param img pointer to an image
* @return offset.y value.
*/
lv_coord_t lv_img_get_offset_y(lv_obj_t *img)
{
lv_img_ext_t * ext = lv_obj_get_ext_attr(img);
return ext->offset.y;
}
/**********************
* STATIC FUNCTIONS
**********************/
@ -291,6 +368,9 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode
lv_obj_get_coords(img, &coords);
if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_VARIABLE) {
coords.x1 -= ext->offset.x;
coords.y1 -= ext->offset.y;
LV_LOG_TRACE("lv_img_design: start to draw image");
lv_area_t cords_tmp;
cords_tmp.y1 = coords.y1;

View File

@ -40,7 +40,7 @@ typedef struct
/*No inherited ext. because inherited from the base object*/ /*Ext. of ancestor*/
/*New data for this type */
const void * src; /*Image source: Pointer to an array or a file or a symbol*/
lv_point_t offset;
lv_coord_t w; /*Width of the image (Handled by the library)*/
lv_coord_t h; /*Height of the image (Handled by the library)*/
uint8_t src_type :2; /*See: lv_img_src_t*/
@ -91,6 +91,31 @@ static inline void lv_img_set_file(lv_obj_t * img, const char * fn)
*/
void lv_img_set_auto_size(lv_obj_t * img, bool autosize_en);
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
* @param img pointer to an image
* @param x: the new offset along x axis.
* @param y: the new offset along y axis.
*/
void lv_img_set_offset(lv_obj_t *img, lv_coord_t x, lv_coord_t y);
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
* @param img pointer to an image
* @param x: the new offset along x axis.
*/
void lv_img_set_offset_x(lv_obj_t *img, lv_coord_t x);
/**
* Set an offset for the source of an image.
* so the image will be displayed from the new origin.
* @param img pointer to an image
* @param y: the new offset along y axis.
*/
void lv_img_set_offset_y(lv_obj_t *img, lv_coord_t y);
/**
* Set the style of an image
* @param img pointer to an image object
@ -137,6 +162,20 @@ const char * lv_img_get_file_name(const lv_obj_t * img);
*/
bool lv_img_get_auto_size(const lv_obj_t * img);
/**
* Get the offset.x attribute of the img object.
* @param img pointer to an image
* @return offset.x value.
*/
lv_coord_t lv_img_get_offset_x(lv_obj_t *img);
/**
* Get the offset.y attribute of the img object.
* @param img pointer to an image
* @return offset.y value.
*/
lv_coord_t lv_img_get_offset_y(lv_obj_t *img);
/**
* Get the style of an image object
* @param img pointer to an image object