atomic14 / diy-esp32-epub-reader

An ESP32 e-reader
MIT License
340 stars 47 forks source link

Improve and refactor `EpubIndex` #69

Closed cgreening closed 2 years ago

cgreening commented 2 years ago

Rename to EpubToc and make the cell height adjustable so that it's more compact

martinberlin commented 2 years ago

Related to this, when rendering the Toc, we should add a left margin of 10px or more to the list otherwise the selection box touches the font.

martinberlin commented 2 years ago

@cgreening additional weird bug here. Opening first index, usually cover, and then pressing previous page button generates a never ending loop of madness. As a normal behavior before implementing this it went back to List view. Question is what it should do now? Go back to TOC view?

Will use at(index) to throw and catch an exception if we call a vector out of it's limits.

The function automatically checks whether n is within the bounds of valid elements in the vector, throwing an out_of_range exception if it is not (i.e., if n is greater or equal than its size). This is in contrast with member operator[], that does not check against bounds.

cgreening commented 2 years ago

Yeah, should probably go back to the TOC view.

We could have the prev and next functions return true or false depending on if they succeed - and then trigger navigation based on that.

martinberlin commented 2 years ago

@cgreening check the last commit, probably you will do it more elegantly, but now it does not reboot forever just because there is a vector that goes out of range.

martinberlin commented 2 years ago

make the cell height adjustable

@cgreening about this nice thought, what will be your idea to implement this? Because if I'm thinking this right, then we will need to store what is the height of each cell for each TOC item, or that is not needed? It will also make more complicated the UX because the rectangle select box needs to adapt to this right? It sounds complicated at least in the first round of thought. But maybe you see it differently.

Another more easier approach, is to render 6 instead of 5 items, making the separation smaller. Not sure how this will adapt to each display, but sounds much easier to implement, and does not need that we remember what height has each item.