split is_mobile to is_narrow and is_oled

is_mobile doesn't really make sense for android tablets. We were
overloading this variable to mean "is_narrow". What we really want is
is_oled for mobile devices and is_narrow for if its phone-like.

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-09-06 21:53:42 -07:00
parent 772bfbad5f
commit 4a4fb06425
9 changed files with 46 additions and 42 deletions

View File

@@ -72,3 +72,14 @@ pub fn is_compiled_as_mobile() -> bool {
false
}
}
/// Determine if the screen is narrow. This is useful for detecting mobile
/// contexts, but with the nuance that we may also have a wide android tablet.
pub fn is_narrow(ctx: &egui::Context) -> bool {
let screen_size = ctx.input(|c| c.screen_rect().size());
screen_size.x < 550.0
}
pub fn is_oled() -> bool {
is_compiled_as_mobile()
}