mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
Merge branch 'master' of https://github.com/ali-rostami/lvgl into ali-rostami-master
This commit is contained in:
commit
363304f53e
@ -78,6 +78,8 @@ 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;
|
||||
#if USE_LV_MULTI_LANG
|
||||
ext->lang_txt_id = LV_LANG_TXT_ID_NONE;
|
||||
#endif
|
||||
@ -235,6 +237,52 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
@ -325,6 +373,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;
|
||||
|
@ -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)*/
|
||||
#if USE_LV_MULTI_LANG
|
||||
@ -103,6 +103,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
|
||||
|
Loading…
x
Reference in New Issue
Block a user