dioxus_use_window/hooks/use_browser/
mod.rs1mod display;
2
3use super::*;
4
5#[derive(Debug)]
7pub struct UseBrowser {
8 inner: UseWindow,
9}
10
11impl UseWindowBuilder {
12 #[inline]
33 pub fn use_browser<'a>(&self, cx: &'a ScopeState) -> &'a mut UseBrowser {
34 let hook = UseBrowser::new(self.use_window_hook(cx));
35 cx.use_hook(|| hook)
36 }
37}
38
39impl UseBrowser {
40 #[inline]
41 pub(crate) fn new(size: UseWindow) -> Self {
42 Self { inner: size }
43 }
44 #[inline]
46 pub fn size(&self) -> (usize, usize) {
47 (self.width(), self.height())
48 }
49 #[inline]
53 pub fn width(&self) -> usize {
54 self.inner.data_ref().outer_width() as usize
55 }
56 #[inline]
60 pub fn height(&self) -> usize {
61 self.inner.data_ref().outer_height() as usize
62 }
63 #[inline]
65 pub fn aspect_radio(&self) -> f64 {
66 self.inner.data_ref().outer_aspect_radio()
67 }
68 #[inline]
70 pub fn resize_to(&self, size: (usize, usize)) -> bool {
71 self.inner.data_ref().resize_outer_size(size.0 as _, size.1 as _).is_some()
72 }
73 #[inline]
75 pub fn resize_delta(&self, size: (i32, i32)) -> bool {
76 self.inner.data_ref().resize_outer_delta(size.0, size.1).is_some()
77 }
78}
79
80impl UseBrowser {
81 #[inline]
83 pub fn is_fullscreen(&self) -> bool {
84 self.inner.data_ref().fullscreen_element().is_some()
85 }
86 #[inline]
88 pub fn fullscreen_toggle(&self) -> bool {
89 self.inner.data_ref().fullscreen_toggle().is_some()
90 }
91 #[inline]
93 pub fn fullscreen_on(&self) -> bool {
94 self.inner.data_ref().fullscreen_set(true).is_some()
95 }
96 #[inline]
98 pub fn fullscreen_off(&self) -> bool {
99 self.inner.data_ref().fullscreen_set(false).is_some()
100 }
101}