-
Notifications
You must be signed in to change notification settings - Fork 8
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
Feat: PopUps #95
Closed
Closed
Feat: PopUps #95
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4903a85
to
75a913e
Compare
6f575c7
to
bd3aff7
Compare
The PopUp trait defines the model for how patch-hub handles PopUps The app holds an `Option` for the current popup being displayed. The app renders the popup on top of every component. Also when a popup is being displayed it hijacks the keyevents (except for the ESC key which always closes the popup) A popup implementing PopUp must: - define its size so the app can produce a centralized Rect for it - define its rendering method which receives a Rect of the given size - define how it handles key events Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
7ea57d9
to
8cb74f1
Compare
The help popup implements the `PopUp` trait and shall be instanced by each screen to manually define it's help page by listing keybinds, a title and a description. Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
Signed-off-by: OJarrisonn <j.h.m.t.v.10@gmail.com>
8cb74f1
to
ae6ca30
Compare
Nice PR! Great work on the pop up. |
Hey @OJarrisonn, thanks so much for this great PR! Change merged into the unstable branch 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is focused on the frontend of patch-hub implementing a PopUp system.
This is still a draft since I'm planning to turn implement a pop-up stack (more explanation below)
The PopUp
PopUp is defined as a trait (this is something @davidbtadokoro and I discussed offline for the future architecture of patch-hub screens) with 3 basic functions:
Since it's a trait, to each new kind of pop-up one must create a type for it and
impl PopUp for
itThe basic life-cycle of a pop-up is:
Box<dyn PopUp>
PopUp::dimensions
(currently the dimensions are a percentage)PopUp::render
passing the frame and the created rect so the pop-up has freedom to draw it the way it wantsESC
closes the pop-up)The Help Pop-Up
This pop-up is both a utility and a blueprint for anyone who needs to create a new pop-up type. It uses a builder to simplify the instantiation. A help pop-up contains:
For each screen, I've created a function to simplify the instantiation of a help pop-up to it (in the
src/handler/
) exactly in the same place where the key events for the screen are defined. I then just added a new key event for the key?
which instantiates a new help pop-up and pushes it to the app "pop-up stack" (it's just anOption
atm).The help pop-up draws all the textual content into a
Paragraph
and uses movement keys to pan the text around in case it doesn't fit the screen. Currentl the help pop-up consumes 50% of screen width and heightWhat's next
To complete this PR i just plan to implement an actual pop-up stack in the app but some points that can be worked out in the future for help pop-ups are: