Skip to content
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

Merged
merged 17 commits into from May 15, 2024

Conversation

TridentTD
Copy link
Contributor

Description of the feature or fix

image

When msgbox is resized, such as:

lv_obj_set_size(msgbox, lv_pct(80), lv_pct(80));

the height of the msgbox's content will automatically adjust,
and the scrollable feature will be removed from msgbox's buttons.

Notes

- 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.
@TridentTD TridentTD changed the title [feat] Automatically adjust msgbox's content height. fix: Automatically adjust msgbox's content height. May 4, 2024
@TridentTD TridentTD changed the title fix: Automatically adjust msgbox's content height. fix(lv_msgbox): Automatically adjust msgbox's content height. May 4, 2024
@@ -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);
Copy link
Contributor

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 🤔

Copy link
Contributor Author

@TridentTD TridentTD May 6, 2024

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?

Copy link
Contributor

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);

Copy link
Member

@kisvegabor kisvegabor left a 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");
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use /**/ comments:

Suggested change
// 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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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() */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

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.

image

But when the command

lv_obj_update_content(msgbox); 

is added, an error occurs.

image

I don't know what caused the error in test_msgbox.c.

@kisvegabor
Copy link
Member

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
@TridentTD
Copy link
Contributor Author

TridentTD commented May 8, 2024

Thank you for fixing the crash.
I have already updated the test_msgbox (at commit 9d4269d).

(I apologize for accidentally uploading the wrong commit
since after commit 687691a.
Looks like deleting unwanted commits needs to be done through git command line.
However, due to my network's inability to fully git clone lvgl,
a mid-process failure occurred.
So I can't delete unwanted commits using git command line.)

@kisvegabor kisvegabor force-pushed the auto-msgbox's-content-height branch from 7b93777 to 687691a Compare May 8, 2024 21:50
@kisvegabor
Copy link
Member

No problem, I've reset it to the 687691a.

@TridentTD
Copy link
Contributor Author

Thank you.

@kisvegabor kisvegabor requested a review from PGNetHun May 14, 2024 09:49
@XuNeo XuNeo merged commit ec3d979 into lvgl:master May 15, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants