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

Move UI components to helix-view and keep rendering logic in helix-term #711

Closed

Conversation

sudormrfbin
Copy link
Member

This PR keeps the rendering logic of components ("widgets") like FilePicker, EditorView, etc in helix-term and moves the structs themselves to helix-view. This is being done with the end goal of separating Compositor out to a trait (see #39 (comment) for why this is necessary) which will unblock the path to a GUI implementation.

The specific design I'm thinking of following is described in #618 (comment). Even if the proposed design (for the end goal for a Compositor trait) is not the best one, I think there is value in separating the rendering logic from everything else. Different frontends will want to do rendering their own way, but we still need to provide a base set of components that the editor will use and the frontends can implement. This PR attempts to move those base components into helix-view and leaves the rendering logic open to implementation (one such implementation will be helix-term, and others will be GUIs in the future).

Note: A single commit will move only a single component so as to make reviewing easier.

The Info struct and Component impl were already separate,
only some renames were required.
@archseer
Copy link
Member

archseer commented Sep 5, 2021

I was considering this but I wasn't sure if this is the right approach. Different frontends will likely need to store different data for rendering, for example while a pop-up might have character grid coordinates for term, it would use pixel positions on a skia frontend.

@archseer
Copy link
Member

archseer commented Sep 5, 2021

We could make the components associated types on the trait maybe? Compositor::Prompt etc

@sudormrfbin
Copy link
Member Author

Different frontends will likely need to store different data for rendering, for example while a pop-up might have character grid coordinates for term, it would use pixel positions on a skia frontend.

I was thinking of something like this:

// crate helix-gui

use helix_view::ui::Popup; // only the `Popup` struct and it's bare impl
use helix_view::compositor::Component;

struct GuiPopup { // wrapper struct
	inner: Popup,
	// other gui specific data
}

impl GuiPopup {
	fn new(popup: Popup) -> Self { /* ... */ }
	// ...
}

impl Component for GuiPopup { /* ... */ }

Popup will have the row and column on which to render it, and GuiPopup can convert it into pixel positions, store it and use it at render time.

If we were instead to have something akin to associated types on Compositor like Compositor::Popup, each frontend will have to re-implement a lot of component boilerplate that will be common to all frontends, for example scoring the items in a Picker (most of the bare impl blocks on components actually).

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