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
Grid menu #123
Conversation
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.
Pretty good, but would be better off based on BaseListBackgroundableUIElement
(less code duplication and more features).
ui/grid_menu.py
Outdated
new_x = self.selected_option['x'] + x_mod | ||
new_y = self.selected_option['y'] + y_mod | ||
|
||
if new_x >= 1 and new_x <= 3: |
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.
3 is a magic number in this and next rows, care to replace with a const?
if new_x >= 1 and new_x <= 3: | |
if new_x >= 1 and new_x <= self.GRID_WIDTH: | |
if new_y >= 1 and new_y <= self.GRID_HEIGHT: |
ui/grid_menu.py
Outdated
def refresh(self): | ||
self.draw_menu() | ||
|
||
def _move_cursor(self, x_mod, y_mod): |
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.
This lacks navigation when pressing RIGHT on the last column (or LEFT on first). Feel free to borrow the code from the calendar =)
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.
or, if based on BaseListBackgroundableUIElement
, its nav functions will work (but move_up
/down
will need to be defined as move_left
/right
and proper move_up
/down
will need to be added)
ui/grid_menu.py
Outdated
|
||
class GridMenu(BaseUIElement): | ||
|
||
GRID_WIDTH = 3 |
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.
be able to define it as an init() argument? seems like a good base UI element that we could later move, say, DatePicker
to, I will think about it more.
ui/grid_menu.py
Outdated
from base_ui import BaseUIElement | ||
from canvas import Canvas | ||
|
||
class GridMenu(BaseUIElement): |
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.
Consider defining your own validate_contents(self, contents)
. If someone passes contents that isn't a width
xheight
array of entries, I imagine it can break in subtle ways - better warn the developer about it first =D
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.
or, if you base it off BaseListBackgroundableUIElement
, its validate_contents
will be more than suitable
|
Codecov Report
@@ Coverage Diff @@
## devel #123 +/- ##
==========================================
+ Coverage 40.56% 40.64% +0.07%
==========================================
Files 248 251 +3
Lines 19950 20276 +326
==========================================
+ Hits 8093 8241 +148
- Misses 11857 12035 +178
Continue to review full report at Codecov.
|
…throw an exception, for now)
…SB port testing function but haven't finished it yet
…t app changes, no time to split)
Hi! Thank you for the work, currently building the main menu from it. Some feedback:
Working further - got an idea in my head of how it all could work, hope you like how it turns out =) |
Also, do check how other UI elements work, it doesn't make sense to break conventions - i.e. making |
…own, making sure they don't refresh more than once per call
…a view mixin. WIP - out-of-screen entry navigation doesn't yet work properly, might need to adjust first_displayed_entry better.
…emoving it out of pyavrdude because can't test it yet
…n't yet fully working
…ased UI elements; adding tests for it
@derivmug thank you! |
This branch adds a 3x3 grid menu.