-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Adds page indicator to music app #1875
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
Conversation
|
Build size and comparison to main:
|
|
I imagine it could look a little better with a little margin around the buttons. What do you think? |
|
I like the first image where the bar is not touching the button. |
|
PR updated to move the buttons 3px. |
|
I experimented with hiding or deleting the page indicator object when you switch pages. According to the simulator, hiding the object used more lvgl memory than deleting and creating. So I went with deleting. I guess it used more memory as you actually had more objects at any one time, with one of them hidden. |
b3b9a27 to
72bc736
Compare
Just thinking, would it make more sense to have a |
12637b1 to
90601f6
Compare
|
I remember now. Music.cpp doesn't have more than one page. It has a single page and hides/unhides buttons to make it look like two pages. This is the reason I went down this route. Perhaps the best thing to do (which is what I did originally) is to hide and unhide two page indicators? |
I think that already exists: PageIndicator(uint8_t nCurrentScreen, uint8_t nScreens) But won't work for Music.cpp single page with hidden buttons for the "second page". |
|
What I'm suggesting is a new method for PageIndicator that tears down the existing one and redraws at a different position. This way you'd only have one page indicator as a member of the app and you could do |
|
@mark9064 hopefully this implementation of SetCurrentScreen is what you had in mind? Please let me know :-) |
|
Inside it, LVGL objects are created and dropped. Is that a good idea? Would it be better to create a function |
I'm certainly no expert but having looked at the pageindicator code, I can't see an easy way to update some of the properties. If not all of them. Any guidance would be much appreciated. |
|
Well I think the current implementation is pretty fine But if you wanted to be more efficient, pull out const int16_t indicatorSize = LV_VER_RES / nScreens;
const int16_t indicatorPos = indicatorSize * nCurrentScreen;
pageIndicatorPoints[0].x = LV_HOR_RES - 1;
pageIndicatorPoints[0].y = indicatorPos;
pageIndicatorPoints[1].x = LV_HOR_RES - 1;
pageIndicatorPoints[1].y = indicatorPos + indicatorSize;
lv_line_set_points(pageIndicator, pageIndicatorPoints, 2);to a different method (eg This works as you can leave the background stripe, and only want to move the highlight (current position indicator) stripe. |
9cfe584 to
2ac8a00
Compare
2ac8a00 to
d7370ab
Compare
All done :-) |
|
If you move pageIndicator = lv_line_create(lv_scr_act(), nullptr);
lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3);
lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);to |
My bad, I should have noticed that in your earlier message. This (hopefully final) commit is the most efficient in terms of additional program memory required and it certainly (looks to me) cleaner than previous commits. |
|
@mark9064 could you please double check that I have declared everything that I need to, correctly, in PageIndicator.h |
mark9064
left a comment
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.
All LGTM :)
|
Would be superseded by #2337 if merged |
|
I would argue that we still merge this, because it's ready and easy to do. And then we discuss your version 2 on top of that. Do you agree, @mark9064? |
|
Yep, sounds good to me. Once this has a second review I'm happy to merge :) |
JF002
left a comment
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.
LGTM, thanks!
NeroBurner
left a comment
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.
LGTM



Fixes #1391