-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
The character on cursor is hidden by it. #67
Comments
Yea, that's for bring this up. Unfortunately the way sugarloaf is built now, consider cursor as a sugar so it would replace a text block, it would work for Block cursors but not for other cases. For fix this issue I was thinking in few possibilities:
|
I kinda of like SugarLayer cause it simplify stuff (the way we consider Rects for example). Maybe something like this: pub struct SugarLayer {
pub layers: Vec<char>
}
#[derive(Debug)]
pub struct Sugar {
pub content: SugarLayer,
pub foreground_color: [f32; 4],
pub background_color: [f32; 4],
pub style: Option<SugarStyle>,
} Then in the renderer it would check layers length and iterate Text on it. |
hmmm I think is due to the alignment configuration, we do centralize characters in the Sugar. Maybe we can add a property alignment that reflects in the OwnedText alignment: https://docs.rs/wgpu_glyph/latest/wgpu_glyph/enum.HorizontalAlign.html |
How about thinking of the cursor as decoration on the glyph box of the character by Rect? Here is example implementation. |
Hmm, SugarDecoration would be a representation of Rect to a specific Sugar right? One concern I have with that is when comes to create the underline style that doesn't exist yet, so cursor and underline style doesn't conflict, but underline doesn't necessarily need to use same solution. |
Yes. Rendering cursor by Rect does not depend on fonts, and We can know position of cursor by rendering cursor and the character at the same time. It is also possible to think of decoration as a layer whose origin is the top-left position of the letter. But as you say, it is not clear whether this method should be used in rendering underlines. It may be necessary to consider whether it should be a special parameter for the cursor or a generic one. |
Have been thinking about it, I actually am sold to cursor being rendered by sugarloaf, because when you change fonts, you don't want the cursor dimensions to change or rely on that. I think underline can coexist with the "underline cursor" as well. Let me know you want to add the implementation for that in the sugarloaf , would be great @niuez |
Closing after #74 merge. |
Hi, I want to use rio with beam cursor, but the cursor hide the character. Other kind cursors also do.
Because the cursor is rendered to replace the character to cursor character.
It should be like this.
my opinion
I think rendering the cursor by Sugarloaf's Rect is one of the solutions. The image above was created by this code. Cursors are considered to be associated with characters, so I defined new SugarStyle `on_cursor`.https://github.com/niuez/rio/blob/0ea71b80d30af2038fa0a361b4d73b4d92be6b24/sugarloaf/src/sugarloaf.rs#L299-L307
But there are some problems.
The text was updated successfully, but these errors were encountered: