New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(lv_msgbox): Automatically adjust msgbox's content height. #6176
Conversation
- auto msgbox's content-height - remove scrollable for buttons, header, footer
- add test_cases for msgbox change size, msgbox's content will auto change height.
@@ -145,6 +146,7 @@ lv_obj_t * lv_msgbox_add_title(lv_obj_t * obj, const char * title) | |||
lv_obj_set_size(mbox->header, lv_pct(100), lv_display_get_dpi(lv_obj_get_display(obj)) / 3); | |||
lv_obj_set_flex_flow(mbox->header, LV_FLEX_FLOW_ROW); | |||
lv_obj_set_flex_align(mbox->header, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); | |||
lv_obj_remove_flag(mbox->header, LV_OBJ_FLAG_SCROLLABLE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think scroll for header and footer should be disable by default 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review.
If the header of the msgbox is scrollable,
I noticed that when accidentally touched directly on the header,
it will have a similar appearance to this clip.
https://www.veed.io/view/047f1414-a8e6-4d1b-952d-c507a0349ff0?panel=quality-survey
I still can't recall of an example of a case
where the header (or titlebar) of msgbox has a scrollbar.
Could you provide an example of a titlebar/header with a scrollbar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just thinking about a scrollbar on a little screen with a lot of buttons (bad interface, but still capable of).
Since elements can be retrieved by using lv_msgbox_get_header
, maybe the scrollbar flag can be removed by the user himself.
Maybe Core reviewers have something different in mind but even the lv_obj_set_flex_grow(mbox->content, 1);
can be resolved by doing:
lv_obj_t* mbox = lv_msgbox_create(NULL);
lv_obj_set_flex_grow(lv_msgbox_get_content(mbox), 1);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
Thanks for the suggestion.
I've just tested it, but with this update lv_example_msgbox_1
is not working as the default LV_SIZE_CONTENT
height of the message box and flex_grow
on an element is conflicting. (It's a circular dependency)
I would like to keep the current set-height-to-the-content behaviour, but I also see the value in your suggestion. What about creating a new example, where some controls are added to the message box (slider, text input, etc) and the height is set manually?
I agree with removing the SCROLLABLE flag.
@@ -44,7 +44,7 @@ void test_msgbox_creation_successful_with_close_button(void) | |||
|
|||
TEST_ASSERT_NOT_NULL(msgbox); | |||
|
|||
TEST_ASSERT_EQUAL_SCREENSHOT("widgets/msgbox_ok_with_close_btn.png"); | |||
TEST_ASSERT_EQUAL_SCREENSHOT("ref_imgs/widgets/msgbox_ok_with_close_btn.png"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"ref_imgs/" is appended automatically here so the original path should be correct.
@@ -144,4 +144,38 @@ void test_msgbox_close_async_modal(void) | |||
TEST_ASSERT_NOT_NULL(msgbox); | |||
} | |||
|
|||
void test_msgbox_content_auto_height(void) | |||
{ | |||
// If parent is NULL the message box will be modal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use /**/
comments:
// If parent is NULL the message box will be modal | |
/* If parent is NULL the message box will be modal */ |
|
||
TEST_ASSERT_EQUAL(h_obj_content, h_msgbox_element_sum); | ||
|
||
// Since msgbox has no parent, it won´t be clean up at tearDown() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Since msgbox has no parent, it won´t be clean up at tearDown() | |
/* Since msgbox has no parent, it won´t be clean up at tearDown() */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now , support both msgbox's default size (by LV_SIZE_CONTENT) and msgbox' manual size.
However, for test_msgbox.c
in the test_cases
folder,
when I tested whether the msgbox's height is set to LV_SIZE_CONTENT or not,
it's OK.
But when the command
lv_obj_update_content(msgbox);
is added, an error occurs.
I don't know what caused the error in test_msgbox.c
.
msgbox with fixed size
support - default height : LV_SIZE_CONTENT - manual height : fixed height or height by lv_pct(...)
- add lv_obj_update_layout(msgbox); but TEST error ?
Thank you for adding the test. I fixed the crash and few other minor things in 17c9fdc |
- remove pad_top =0 of the container - adjust position of content's scrollbar
- Check the size comparison of the msgbox, both default size and manual size
Thank you for fixing the crash. (I apologize for accidentally uploading the wrong commit |
7b93777
to
687691a
Compare
No problem, I've reset it to the |
Thank you. |
Description of the feature or fix
When msgbox is resized, such as:
the height of the msgbox's content will automatically adjust,
and the scrollable feature will be removed from msgbox's buttons.
Notes
lv_conf_template.h
run lv_conf_internal_gen.py and update Kconfig.scripts/code-format.py
(astyle version v3.4.12 needs to be installed) and follow the Code Conventions.