Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/libs/lvgl/lv_objx/lv_cont.c
1476 views
1
/**
2
* @file lv_cont.c
3
*
4
*/
5
6
/*********************
7
* INCLUDES
8
*********************/
9
10
#include "lv_cont.h"
11
#if USE_LV_CONT != 0
12
13
#include <stdint.h>
14
#include <string.h>
15
16
#include "../lv_draw/lv_draw.h"
17
#include "../lv_draw/lv_draw_vbasic.h"
18
#include "../lv_themes/lv_theme.h"
19
#include "../lv_misc/lv_area.h"
20
#include "../lv_misc/lv_color.h"
21
#include "../lv_misc/lv_math.h"
22
23
/*********************
24
* DEFINES
25
*********************/
26
27
/**********************
28
* TYPEDEFS
29
**********************/
30
31
/**********************
32
* STATIC PROTOTYPES
33
**********************/
34
static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param);
35
static void lv_cont_refr_layout(lv_obj_t * cont);
36
static void lv_cont_layout_col(lv_obj_t * cont);
37
static void lv_cont_layout_row(lv_obj_t * cont);
38
static void lv_cont_layout_center(lv_obj_t * cont);
39
static void lv_cont_layout_pretty(lv_obj_t * cont);
40
static void lv_cont_layout_grid(lv_obj_t * cont);
41
static void lv_cont_refr_autofit(lv_obj_t * cont);
42
43
/**********************
44
* STATIC VARIABLES
45
**********************/
46
static lv_signal_func_t ancestor_signal;
47
48
/**********************
49
* MACROS
50
**********************/
51
52
/**********************
53
* GLOBAL FUNCTIONS
54
**********************/
55
56
/**
57
* Create a container objects
58
* @param par pointer to an object, it will be the parent of the new container
59
* @param copy pointer to a container object, if not NULL then the new object will be copied from it
60
* @return pointer to the created container
61
*/
62
lv_obj_t * lv_cont_create(lv_obj_t * par, const lv_obj_t * copy)
63
{
64
65
66
LV_LOG_TRACE("container create started");
67
68
/*Create a basic object*/
69
lv_obj_t * new_cont = lv_obj_create(par, copy);
70
lv_mem_assert(new_cont);
71
if(new_cont == NULL) return NULL;
72
73
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_cont);
74
75
lv_obj_allocate_ext_attr(new_cont, sizeof(lv_cont_ext_t));
76
lv_cont_ext_t * ext = lv_obj_get_ext_attr(new_cont);
77
if(ext == NULL) return NULL;
78
79
lv_mem_assert(ext);
80
ext->hor_fit = 0;
81
ext->ver_fit = 0;
82
ext->layout = LV_LAYOUT_OFF;
83
84
lv_obj_set_signal_func(new_cont, lv_cont_signal);
85
86
/*Init the new container*/
87
if(copy == NULL) {
88
/*Set the default styles*/
89
lv_theme_t * th = lv_theme_get_current();
90
if(th) {
91
lv_cont_set_style(new_cont, th->cont);
92
} else {
93
lv_cont_set_style(new_cont, &lv_style_pretty);
94
}
95
}
96
/*Copy an existing object*/
97
else {
98
lv_cont_ext_t * copy_ext = lv_obj_get_ext_attr(copy);
99
ext->hor_fit = copy_ext->hor_fit;
100
ext->ver_fit = copy_ext->ver_fit;
101
ext->layout = copy_ext->layout;
102
103
/*Refresh the style with new signal function*/
104
lv_obj_refresh_style(new_cont);
105
}
106
107
LV_LOG_INFO("container created");
108
109
110
return new_cont;
111
}
112
113
/*=====================
114
* Setter functions
115
*====================*/
116
117
/**
118
* Set a layout on a container
119
* @param cont pointer to a container object
120
* @param layout a layout from 'lv_cont_layout_t'
121
*/
122
void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout)
123
{
124
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
125
if(ext->layout == layout) return;
126
127
ext->layout = layout;
128
129
/*Send a signal to refresh the layout*/
130
cont->signal_func(cont, LV_SIGNAL_CHILD_CHG, NULL);
131
}
132
133
134
/**
135
* Enable the horizontal or vertical fit.
136
* The container size will be set to involve the children horizontally or vertically.
137
* @param cont pointer to a container object
138
* @param hor_en true: enable the horizontal fit
139
* @param ver_en true: enable the vertical fit
140
*/
141
void lv_cont_set_fit(lv_obj_t * cont, bool hor_en, bool ver_en)
142
{
143
lv_obj_invalidate(cont);
144
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
145
if(ext->hor_fit == hor_en && ext->ver_fit == ver_en) return;
146
147
ext->hor_fit = hor_en == false ? 0 : 1;
148
ext->ver_fit = ver_en == false ? 0 : 1;
149
150
/*Send a signal to refresh the layout*/
151
cont->signal_func(cont, LV_SIGNAL_CHILD_CHG, NULL);
152
}
153
154
/*=====================
155
* Getter functions
156
*====================*/
157
158
/**
159
* Get the layout of a container
160
* @param cont pointer to container object
161
* @return the layout from 'lv_cont_layout_t'
162
*/
163
lv_layout_t lv_cont_get_layout(const lv_obj_t * cont)
164
{
165
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
166
return ext->layout;
167
}
168
169
/**
170
* Get horizontal fit enable attribute of a container
171
* @param cont pointer to a container object
172
* @return true: horizontal fit is enabled; false: disabled
173
*/
174
bool lv_cont_get_hor_fit(const lv_obj_t * cont)
175
{
176
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
177
return ext->hor_fit == 0 ? false : true;
178
}
179
180
/**
181
* Get vertical fit enable attribute of a container
182
* @param cont pointer to a container object
183
* @return true: vertical fit is enabled; false: disabled
184
*/
185
bool lv_cont_get_ver_fit(const lv_obj_t * cont)
186
{
187
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
188
return ext->ver_fit == 0 ? false : true;
189
}
190
191
/**
192
* Get that width reduced by the horizontal padding. Useful if a layout is used.
193
* @param cont pointer to a container object
194
* @return the width which still fits into the container
195
*/
196
lv_coord_t lv_cont_get_fit_width(lv_obj_t * cont)
197
{
198
lv_style_t * style = lv_cont_get_style(cont);
199
200
return lv_obj_get_width(cont) - 2 * style->body.padding.hor;
201
}
202
203
/**
204
* Get that height reduced by the vertical padding. Useful if a layout is used.
205
* @param cont pointer to a container object
206
* @return the height which still fits into the container
207
*/
208
lv_coord_t lv_cont_get_fit_height(lv_obj_t * cont)
209
{
210
lv_style_t * style = lv_cont_get_style(cont);
211
212
return lv_obj_get_height(cont) - 2 * style->body.padding.ver;
213
}
214
215
/**********************
216
* STATIC FUNCTIONS
217
**********************/
218
219
/**
220
* Signal function of the container
221
* @param cont pointer to a container object
222
* @param sign a signal type from lv_signal_t enum
223
* @param param pointer to a signal specific variable
224
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
225
*/
226
static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param)
227
{
228
lv_res_t res;
229
230
/* Include the ancient signal function */
231
res = ancestor_signal(cont, sign, param);
232
if(res != LV_RES_OK) return res;
233
234
if(sign == LV_SIGNAL_STYLE_CHG) { /*Recalculate the padding if the style changed*/
235
lv_cont_refr_layout(cont);
236
lv_cont_refr_autofit(cont);
237
} else if(sign == LV_SIGNAL_CHILD_CHG) {
238
lv_cont_refr_layout(cont);
239
lv_cont_refr_autofit(cont);
240
} else if(sign == LV_SIGNAL_CORD_CHG) {
241
if(lv_obj_get_width(cont) != lv_area_get_width(param) ||
242
lv_obj_get_height(cont) != lv_area_get_height(param)) {
243
lv_cont_refr_layout(cont);
244
lv_cont_refr_autofit(cont);
245
}
246
} else if(sign == LV_SIGNAL_GET_TYPE) {
247
lv_obj_type_t * buf = param;
248
uint8_t i;
249
for(i = 0; i < LV_MAX_ANCESTOR_NUM - 1; i++) { /*Find the last set data*/
250
if(buf->type[i] == NULL) break;
251
}
252
buf->type[i] = "lv_cont";
253
}
254
255
return res;
256
}
257
258
259
/**
260
* Refresh the layout of a container
261
* @param cont pointer to an object which layout should be refreshed
262
*/
263
static void lv_cont_refr_layout(lv_obj_t * cont)
264
{
265
lv_layout_t type = lv_cont_get_layout(cont);
266
267
/*'cont' has to be at least 1 child*/
268
if(lv_obj_get_child(cont, NULL) == NULL) return;
269
270
if(type == LV_LAYOUT_OFF) return;
271
272
if(type == LV_LAYOUT_CENTER) {
273
lv_cont_layout_center(cont);
274
} else if(type == LV_LAYOUT_COL_L || type == LV_LAYOUT_COL_M || type == LV_LAYOUT_COL_R) {
275
lv_cont_layout_col(cont);
276
} else if(type == LV_LAYOUT_ROW_T || type == LV_LAYOUT_ROW_M || type == LV_LAYOUT_ROW_B) {
277
lv_cont_layout_row(cont);
278
} else if(type == LV_LAYOUT_PRETTY) {
279
lv_cont_layout_pretty(cont);
280
} else if(type == LV_LAYOUT_GRID) {
281
lv_cont_layout_grid(cont);
282
}
283
}
284
285
/**
286
* Handle column type layouts
287
* @param cont pointer to an object which layout should be handled
288
*/
289
static void lv_cont_layout_col(lv_obj_t * cont)
290
{
291
lv_layout_t type = lv_cont_get_layout(cont);
292
lv_obj_t * child;
293
294
/*Adjust margin and get the alignment type*/
295
lv_align_t align;
296
lv_style_t * style = lv_obj_get_style(cont);
297
lv_coord_t hpad_corr;
298
299
switch(type) {
300
case LV_LAYOUT_COL_L:
301
hpad_corr = style->body.padding.hor;
302
align = LV_ALIGN_IN_TOP_LEFT;
303
break;
304
case LV_LAYOUT_COL_M:
305
hpad_corr = 0;
306
align = LV_ALIGN_IN_TOP_MID;
307
break;
308
case LV_LAYOUT_COL_R:
309
hpad_corr = -style->body.padding.hor;
310
align = LV_ALIGN_IN_TOP_RIGHT;
311
break;
312
default:
313
hpad_corr = 0;
314
align = LV_ALIGN_IN_TOP_LEFT;
315
break;
316
}
317
318
/* Disable child change action because the children will be moved a lot
319
* an unnecessary child change signals could be sent*/
320
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
321
/* Align the children */
322
lv_coord_t last_cord = style->body.padding.ver;
323
LL_READ_BACK(cont->child_ll, child) {
324
if(lv_obj_get_hidden(child) != false ||
325
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
326
327
lv_obj_align(child, cont, align, hpad_corr, last_cord);
328
last_cord += lv_obj_get_height(child) + style->body.padding.inner;
329
}
330
331
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
332
}
333
334
/**
335
* Handle row type layouts
336
* @param cont pointer to an object which layout should be handled
337
*/
338
static void lv_cont_layout_row(lv_obj_t * cont)
339
{
340
lv_layout_t type = lv_cont_get_layout(cont);
341
lv_obj_t * child;
342
343
/*Adjust margin and get the alignment type*/
344
lv_align_t align;
345
lv_style_t * style = lv_obj_get_style(cont);
346
lv_coord_t vpad_corr = style->body.padding.ver;
347
348
switch(type) {
349
case LV_LAYOUT_ROW_T:
350
vpad_corr = style->body.padding.ver;
351
align = LV_ALIGN_IN_TOP_LEFT;
352
break;
353
case LV_LAYOUT_ROW_M:
354
vpad_corr = 0;
355
align = LV_ALIGN_IN_LEFT_MID;
356
break;
357
case LV_LAYOUT_ROW_B:
358
vpad_corr = -style->body.padding.ver;
359
align = LV_ALIGN_IN_BOTTOM_LEFT;
360
break;
361
default:
362
vpad_corr = 0;
363
align = LV_ALIGN_IN_TOP_LEFT;
364
break;
365
}
366
367
/* Disable child change action because the children will be moved a lot
368
* an unnecessary child change signals could be sent*/
369
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
370
371
/* Align the children */
372
lv_coord_t last_cord = style->body.padding.hor;
373
LL_READ_BACK(cont->child_ll, child) {
374
if(lv_obj_get_hidden(child) != false ||
375
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
376
377
lv_obj_align(child, cont, align, last_cord, vpad_corr);
378
last_cord += lv_obj_get_width(child) + style->body.padding.inner;
379
}
380
381
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
382
}
383
384
/**
385
* Handle the center layout
386
* @param cont pointer to an object which layout should be handled
387
*/
388
static void lv_cont_layout_center(lv_obj_t * cont)
389
{
390
lv_obj_t * child;
391
lv_style_t * style = lv_obj_get_style(cont);
392
uint32_t obj_num = 0;
393
lv_coord_t h_tot = 0;
394
395
LL_READ(cont->child_ll, child) {
396
if(lv_obj_get_hidden(child) != false ||
397
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
398
h_tot += lv_obj_get_height(child) + style->body.padding.inner;
399
obj_num ++;
400
}
401
402
if(obj_num == 0) return;
403
404
h_tot -= style->body.padding.inner;
405
406
/* Disable child change action because the children will be moved a lot
407
* an unnecessary child change signals could be sent*/
408
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
409
410
/* Align the children */
411
lv_coord_t last_cord = - (h_tot / 2);
412
LL_READ_BACK(cont->child_ll, child) {
413
if(lv_obj_get_hidden(child) != false ||
414
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
415
416
lv_obj_align(child, cont, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2);
417
last_cord += lv_obj_get_height(child) + style->body.padding.inner;
418
}
419
420
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
421
}
422
423
/**
424
* Handle the pretty layout. Put as many object as possible in row
425
* then begin a new row
426
* @param cont pointer to an object which layout should be handled
427
*/
428
static void lv_cont_layout_pretty(lv_obj_t * cont)
429
{
430
lv_obj_t * child_rs; /* Row starter child */
431
lv_obj_t * child_rc; /* Row closer child */
432
lv_obj_t * child_tmp; /* Temporary child */
433
lv_style_t * style = lv_obj_get_style(cont);
434
lv_coord_t w_obj = lv_obj_get_width(cont);
435
lv_coord_t act_y = style->body.padding.ver;
436
/* Disable child change action because the children will be moved a lot
437
* an unnecessary child change signals could be sent*/
438
439
child_rs = lv_ll_get_tail(&cont->child_ll); /*Set the row starter child*/
440
if(child_rs == NULL) return; /*Return if no child*/
441
442
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
443
444
child_rc = child_rs; /*Initially the the row starter and closer is the same*/
445
while(child_rs != NULL) {
446
lv_coord_t h_row = 0;
447
lv_coord_t w_row = style->body.padding.hor * 2; /*The width is at least the left+right hpad*/
448
uint32_t obj_num = 0;
449
450
/*Find the row closer object and collect some data*/
451
do {
452
if(lv_obj_get_hidden(child_rc) == false &&
453
lv_obj_is_protected(child_rc, LV_PROTECT_POS) == false) {
454
/*If this object is already not fit then break*/
455
if(w_row + lv_obj_get_width(child_rc) > w_obj) {
456
/*Step back one child because the last already not fit, so the previous is the closer*/
457
if(child_rc != NULL && obj_num != 0) {
458
child_rc = lv_ll_get_next(&cont->child_ll, child_rc);
459
}
460
break;
461
}
462
w_row += lv_obj_get_width(child_rc) + style->body.padding.inner; /*Add the object width + opad*/
463
h_row = LV_MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/
464
obj_num ++;
465
if(lv_obj_is_protected(child_rc, LV_PROTECT_FOLLOW)) break; /*If can not be followed by an other object then break here*/
466
467
}
468
child_rc = lv_ll_get_prev(&cont->child_ll, child_rc); /*Load the next object*/
469
if(obj_num == 0) child_rs = child_rc; /*If the first object was hidden (or too long) then set the next as first */
470
} while(child_rc != NULL);
471
472
/*If the object is too long then align it to the middle*/
473
if(obj_num == 0) {
474
if(child_rc != NULL) {
475
lv_obj_align(child_rc, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
476
h_row = lv_obj_get_height(child_rc); /*Not set previously because of the early break*/
477
}
478
}
479
/*If there is only one object in the row then align it to the middle*/
480
else if(obj_num == 1) {
481
lv_obj_align(child_rs, cont, LV_ALIGN_IN_TOP_MID, 0, act_y);
482
}
483
/*If there are two object in the row then align them proportionally*/
484
else if(obj_num == 2) {
485
lv_obj_t * obj1 = child_rs;
486
lv_obj_t * obj2 = lv_ll_get_prev(&cont->child_ll, child_rs);
487
w_row = lv_obj_get_width(obj1) + lv_obj_get_width(obj2);
488
lv_coord_t pad = (w_obj - w_row) / 3;
489
lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y + (h_row - lv_obj_get_height(obj1)) / 2);
490
lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y + (h_row - lv_obj_get_height(obj2)) / 2);
491
}
492
/* Align the children (from child_rs to child_rc)*/
493
else {
494
w_row -= style->body.padding.inner * obj_num;
495
lv_coord_t new_opad = (w_obj - w_row) / (obj_num - 1);
496
lv_coord_t act_x = style->body.padding.hor; /*x init*/
497
child_tmp = child_rs;
498
while(child_tmp != NULL) {
499
if(lv_obj_get_hidden(child_tmp) == false &&
500
lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) {
501
lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x, act_y + (h_row - lv_obj_get_height(child_tmp)) / 2);
502
act_x += lv_obj_get_width(child_tmp) + new_opad;
503
}
504
if(child_tmp == child_rc) break;
505
child_tmp = lv_ll_get_prev(&cont->child_ll, child_tmp);
506
}
507
508
}
509
510
if(child_rc == NULL) break;
511
act_y += style->body.padding.inner + h_row; /*y increment*/
512
child_rs = lv_ll_get_prev(&cont->child_ll, child_rc); /*Go to the next object*/
513
child_rc = child_rs;
514
}
515
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
516
}
517
518
/**
519
* Handle the grid layout. Align same-sized objects in a grid
520
* @param cont pointer to an object which layout should be handled
521
*/
522
static void lv_cont_layout_grid(lv_obj_t * cont)
523
{
524
lv_obj_t * child;
525
lv_style_t * style = lv_obj_get_style(cont);
526
lv_coord_t w_tot = lv_obj_get_width(cont);
527
lv_coord_t w_obj = lv_obj_get_width(lv_obj_get_child(cont, NULL));
528
lv_coord_t h_obj = lv_obj_get_height(lv_obj_get_child(cont, NULL));
529
uint16_t obj_row = (w_tot - (2 * style->body.padding.hor)) / (w_obj + style->body.padding.inner); /*Obj. num. in a row*/
530
lv_coord_t x_ofs;
531
if(obj_row > 1) {
532
x_ofs = w_obj + (w_tot - (2 * style->body.padding.hor) - (obj_row * w_obj)) / (obj_row - 1);
533
} else {
534
x_ofs = w_tot / 2 - w_obj / 2;
535
}
536
lv_coord_t y_ofs = h_obj + style->body.padding.inner;
537
538
/* Disable child change action because the children will be moved a lot
539
* an unnecessary child change signals could be sent*/
540
lv_obj_set_protect(cont, LV_PROTECT_CHILD_CHG);
541
542
/* Align the children */
543
lv_coord_t act_x = style->body.padding.hor;
544
lv_coord_t act_y = style->body.padding.ver;
545
uint16_t obj_cnt = 0;
546
LL_READ_BACK(cont->child_ll, child) {
547
if(lv_obj_get_hidden(child) != false ||
548
lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue;
549
550
if(obj_row > 1) {
551
lv_obj_set_pos(child, act_x, act_y);
552
act_x += x_ofs;
553
} else {
554
lv_obj_set_pos(child, x_ofs, act_y);
555
}
556
obj_cnt ++;
557
558
if(obj_cnt >= obj_row) {
559
obj_cnt = 0;
560
act_x = style->body.padding.hor;
561
act_y += y_ofs;
562
}
563
}
564
565
lv_obj_clear_protect(cont, LV_PROTECT_CHILD_CHG);
566
}
567
568
/**
569
* Handle auto fit. Set the size of the object to involve all children.
570
* @param cont pointer to an object which size will be modified
571
*/
572
static void lv_cont_refr_autofit(lv_obj_t * cont)
573
{
574
lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont);
575
576
if(ext->hor_fit == 0 &&
577
ext->ver_fit == 0) {
578
return;
579
}
580
581
lv_area_t new_cords;
582
lv_area_t ori;
583
lv_style_t * style = lv_obj_get_style(cont);
584
lv_obj_t * i;
585
lv_coord_t hpad = style->body.padding.hor;
586
lv_coord_t vpad = style->body.padding.ver;
587
588
/*Search the side coordinates of the children*/
589
lv_obj_get_coords(cont, &ori);
590
lv_obj_get_coords(cont, &new_cords);
591
592
new_cords.x1 = LV_COORD_MAX;
593
new_cords.y1 = LV_COORD_MAX;
594
new_cords.x2 = LV_COORD_MIN;
595
new_cords.y2 = LV_COORD_MIN;
596
597
LL_READ(cont->child_ll, i) {
598
if(lv_obj_get_hidden(i) != false) continue;
599
new_cords.x1 = LV_MATH_MIN(new_cords.x1, i->coords.x1);
600
new_cords.y1 = LV_MATH_MIN(new_cords.y1, i->coords.y1);
601
new_cords.x2 = LV_MATH_MAX(new_cords.x2, i->coords.x2);
602
new_cords.y2 = LV_MATH_MAX(new_cords.y2, i->coords.y2);
603
}
604
605
/*If the value is not the init value then the page has >=1 child.*/
606
if(new_cords.x1 != LV_COORD_MAX) {
607
if(ext->hor_fit != 0) {
608
new_cords.x1 -= hpad;
609
new_cords.x2 += hpad;
610
} else {
611
new_cords.x1 = cont->coords.x1;
612
new_cords.x2 = cont->coords.x2;
613
}
614
if(ext->ver_fit != 0) {
615
new_cords.y1 -= vpad;
616
new_cords.y2 += vpad;
617
} else {
618
new_cords.y1 = cont->coords.y1;
619
new_cords.y2 = cont->coords.y2;
620
}
621
622
/*Do nothing if the coordinates are not changed*/
623
if(cont->coords.x1 != new_cords.x1 ||
624
cont->coords.y1 != new_cords.y1 ||
625
cont->coords.x2 != new_cords.x2 ||
626
cont->coords.y2 != new_cords.y2) {
627
628
lv_obj_invalidate(cont);
629
lv_area_copy(&cont->coords, &new_cords);
630
lv_obj_invalidate(cont);
631
632
/*Notify the object about its new coordinates*/
633
cont->signal_func(cont, LV_SIGNAL_CORD_CHG, &ori);
634
635
/*Inform the parent about the new coordinates*/
636
lv_obj_t * par = lv_obj_get_parent(cont);
637
par->signal_func(par, LV_SIGNAL_CHILD_CHG, cont);
638
}
639
}
640
}
641
642
#endif
643
644