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

Fine tune of navigation paging buttons #2459

Closed
wants to merge 3 commits into from

Conversation

zxkmm
Copy link
Contributor

@zxkmm zxkmm commented Dec 31, 2024

tuned

  • fix the situation when the page is not fulfilled with tile (found by HTotoo)
  • tune the layout of buttons, in 3 raw grid, align the first line (the next page button align to row 2 and 3)

side notes

  • Also implemented the feature that when last icon is on left, hide page down to align (like image shows), but this have to set_dirty() and that would make screen flicker, so i gave up, but here's the code and we can put it back when set_dirty not flicker anymore:

BEFORE:
image

AFTER:
image
BEFORE:
image
AFTER:
image

void BtnGridView::show_hide_arrows() {
    portapack::async_tx_enabled = true;
    if (highlighted_item == 0) {
        set_arrow_up_enabled(false);
    } else {
        set_arrow_up_enabled(true);
    }
    if (highlighted_item == (menu_items.size() - 1) || menu_items.size() < displayed_max) {
        /* ^ when at the last tile of this screen          ^ if the tiles isn't fullfilled this screen */
        set_arrow_down_enabled(false);
    } else {
        set_arrow_down_enabled(true);
    }

    if (menu_items.size() < displayed_max) {  // if the tiles isn't fullfilled this screen
        button_pgup.hidden(true);
        button_pgdown.hidden(true);
    } else {
        button_pgup.hidden(false);
        button_pgdown.hidden(false);
    }

    if (highlighted_item == menu_items.size() - 1) {
        UsbSerialAsyncmsg::asyncmsg("last icon");
        if (rows_ == 2) {
            UsbSerialAsyncmsg::asyncmsg("if 2 row");
            // last icon is left
            if ((highlighted_item + 1) % 2 == 1) {
                button_pgdown.hidden(true);
                set_dirty();
            }
        } else if (rows_ == 3) {
            UsbSerialAsyncmsg::asyncmsg("if 3 row");
            int position_in_row = (highlighted_item + 1) % 3;
            if (position_in_row == 1) {
                UsbSerialAsyncmsg::asyncmsg("if 3 row, last one is left");
                // last icon is left AKA 1
                button_pgdown.hidden(true);
            } else if (position_in_row == 2) {
                UsbSerialAsyncmsg::asyncmsg("if 3 row, last one is middle");
                // last icon is middle AKA 2
                button_pgdown.hidden(false);
                // button_pgdown.set_parent_rect({((rows_ == 2) ? 120 : 80),
                //                                (Coord)(displayed_max * button_h),
                //                                ((rows_ == 2) ? 120 : 80),
                //                                16});
            }
        }
    } else {
        UsbSerialAsyncmsg::asyncmsg("not last icon");
        if (rows_ == 3) {
            UsbSerialAsyncmsg::asyncmsg("if 3 row, not last one");
            // button_pgdown.set_parent_rect({((rows_ == 2) ? 120 : 80),
            //                                (Coord)(displayed_max * button_h),
            //                                ((rows_ == 2) ? 120 : 160),
            //                                16});
        }
    }
}

@zxkmm zxkmm marked this pull request as ready for review December 31, 2024 03:41
@zxkmm zxkmm requested a review from gullradriel December 31, 2024 03:46
@gullradriel
Copy link
Member

fix the situation when the page is not fulfilled with tile (found by HTotoo)

I didn't modify this because it's allowing to go from first to last tile in one touch

tune the layout of buttons, in 3 raw grid, align the first line (the next page button align to row 2 and 3)

I don't like the tuning, it's making the zone harder to click.

@gullradriel
Copy link
Member

Also implemented the feature that when last icon is on left, hide page down to align (like image shows), but this have to set_dirty() and that would make screen flicker, so i gave up, but here's the code and we can put it back when set_dirty not flicker anymore

I already stated in the PR that hiding the buttons isn't working fine and make the screen flicker. AT first I did that approach and it was so boring to see the screen flicker that I went back to the classic button set_text hack, which does not make the screen flicker.

At some point I even asked myself if there was a need at all to hide anything, and just keep the buttons displayed. Finally I decided to keep the text hiding behavior so it's indicating the start and the end of the list.

@@ -60,6 +60,8 @@ BtnGridView::BtnGridView(

add_child(&button_pgup);
add_child(&button_pgdown);

show_hide_arrows();
Copy link
Member

Choose a reason for hiding this comment

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

Why is it needed here ?

@@ -78,8 +80,15 @@ void BtnGridView::set_parent_rect(const Rect new_parent_rect) {

displayed_max = (parent_rect().size().height() / button_h);

button_pgup.set_parent_rect({0, (Coord)(displayed_max * button_h), 120, 16});
button_pgdown.set_parent_rect({120, (Coord)(displayed_max * button_h), 120, 16});
button_pgup.set_parent_rect({0,
Copy link
Member

Choose a reason for hiding this comment

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

I'm not for it. It's making the buttons too little

((rows_ == 2) ? 120 : 80),
16});

button_pgdown.set_parent_rect({((rows_ == 2) ? 120 : 80),
Copy link
Member

Choose a reason for hiding this comment

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

I'm not for it. It's making the buttons too little

@@ -183,16 +192,26 @@ void BtnGridView::insert_item(const GridItem& new_item, size_t position, bool in
}

void BtnGridView::show_hide_arrows() {
portapack::async_tx_enabled = true;
Copy link
Member

Choose a reason for hiding this comment

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

When debug is done, remove it from code please

button_pgup.hidden(true);
button_pgdown.hidden(true);
} else {
button_pgup.hidden(false);
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it going to force the display of both arrows whatever the highlighted position is, just because the menu_item.size is bigger than the displayed size ?

Copy link
Member

Choose a reason for hiding this comment

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

I think that else is superfluous

set_arrow_down_enabled(false);
} else {
set_arrow_down_enabled(true);
}

if (menu_items.size() < displayed_max) { // if the tiles isn't fullfilled this screen
Copy link
Member

@gullradriel gullradriel Dec 31, 2024

Choose a reason for hiding this comment

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

See my comment in the PR. Plus it's double checked. See, you're already checking it on line 201

Copy link
Member

Choose a reason for hiding this comment

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

But ok, we can keep this one. Without the else.

if (highlighted_item == 0) {
set_arrow_up_enabled(false);
} else {
set_arrow_up_enabled(true);
}
if (highlighted_item == (menu_items.size() - 1)) {
if (highlighted_item == (menu_items.size() - 1) || menu_items.size() < displayed_max) {
Copy link
Member

Choose a reason for hiding this comment

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

Remove menu_items.size() < displayed_max from here, you are checking it just after

@zxkmm zxkmm marked this pull request as draft January 1, 2025 00:58
@zxkmm
Copy link
Contributor Author

zxkmm commented Jan 1, 2025

Thanks for the review!

I didn't modify this because it's allowing to go from first to last tile in one touch

I see, since you designed on purpose then let's keep it

I don't like the tuning, it's making the zone harder to click.

Sure, it looks a bit better but yes it could be hard to touch

Since this PR mainly has these two changes and i think I can close this for now

@zxkmm zxkmm closed this Jan 1, 2025
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.

2 participants