Skip to content

feat(backend): add CellSized trait for querying cell dimensions in physical and CSS pixels#165

Open
junkdog wants to merge 5 commits intoratatui:mainfrom
junkdog:cell-sized-trait-for-backends
Open

feat(backend): add CellSized trait for querying cell dimensions in physical and CSS pixels#165
junkdog wants to merge 5 commits intoratatui:mainfrom
junkdog:cell-sized-trait-for-backends

Conversation

@junkdog
Copy link
Member

@junkdog junkdog commented Mar 4, 2026

enabler for properly handling mouse wheel scroll events in #142

revolves around the CellSized trait, implemented by all backends.

pub trait CellSized {
    /// Returns the size of a cell in physical (device) pixels as `(width, height)`.
    fn cell_size_px(&self) -> (f32, f32);

    /// Returns the size of a cell in CSS (logical) pixels as `(width, height)`.
    fn cell_size_css_px(&self) -> (f32, f32);
}

@junkdog junkdog marked this pull request as draft March 4, 2026 20:23
@junkdog junkdog force-pushed the cell-sized-trait-for-backends branch 2 times, most recently from af75cf3 to 5a92e02 Compare March 4, 2026 20:24
@junkdog junkdog marked this pull request as ready for review March 4, 2026 20:26
@junkdog junkdog changed the title Draft: feat(backend): add CellSized trait for querying cell dimensions in physical and CSS pixels feat(backend): add CellSized trait for querying cell dimensions in physical and CSS pixels Mar 4, 2026
@junkdog junkdog force-pushed the cell-sized-trait-for-backends branch from 5a92e02 to f553cba Compare March 4, 2026 20:30
@junkdog junkdog force-pushed the cell-sized-trait-for-backends branch from f553cba to 8f256fe Compare March 4, 2026 20:35
@junkdog junkdog marked this pull request as draft March 4, 2026 21:42
@junkdog junkdog marked this pull request as ready for review March 7, 2026 12:00
@junkdog
Copy link
Member Author

junkdog commented Mar 7, 2026

hmm, tested with the "minimal" example: the offset bug when zooming in the webgl2 backend has returned... it's unrelated to these changes, as it exhibits the same buggy behavior one main. i'll fix it separately (+ add some form of integration test...)

@junkdog
Copy link
Member Author

junkdog commented Mar 10, 2026

the offset bug when zooming in the webgl2 backend has returned

fixed it in beamterm - which also translated to simplified mouse handling in ratzilla (-35 loc)

@junkdog junkdog added DOM DOM backend related canvas Canvas backend related wegl2 WebGL2 Backend related labels Mar 11, 2026
@orhun
Copy link
Member

orhun commented Mar 11, 2026

Cool, is this ready for review?

@junkdog
Copy link
Member Author

junkdog commented Mar 11, 2026

Cool, is this ready for review?

it is now; and the offset bug was fixed after merging main into the branch.

Copy link
Member

@orhun orhun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should include this trait in either util module or move it under backend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

canvas Canvas backend related DOM DOM backend related wegl2 WebGL2 Backend related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants