tauri_runtime/
dpi.rs

1// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
2// SPDX-License-Identifier: Apache-2.0
3// SPDX-License-Identifier: MIT
4
5pub use dpi::*;
6use serde::Serialize;
7
8/// A rectangular region.
9#[derive(Clone, Copy, Debug, Serialize)]
10pub struct Rect {
11  /// Rect position.
12  pub position: dpi::Position,
13  /// Rect size.
14  pub size: dpi::Size,
15}
16
17impl Default for Rect {
18  fn default() -> Self {
19    Self {
20      position: Position::Logical((0, 0).into()),
21      size: Size::Logical((0, 0).into()),
22    }
23  }
24}
25
26/// A rectangular region in physical pixels.
27#[derive(Clone, Copy, Debug, Serialize)]
28pub struct PhysicalRect<P: dpi::Pixel, S: dpi::Pixel> {
29  /// Rect position.
30  pub position: dpi::PhysicalPosition<P>,
31  /// Rect size.
32  pub size: dpi::PhysicalSize<S>,
33}
34
35impl<P: dpi::Pixel, S: dpi::Pixel> Default for PhysicalRect<P, S> {
36  fn default() -> Self {
37    Self {
38      position: (0, 0).into(),
39      size: (0, 0).into(),
40    }
41  }
42}
43
44/// A rectangular region in logical pixels.
45#[derive(Clone, Copy, Debug, Serialize)]
46pub struct LogicalRect<P: dpi::Pixel, S: dpi::Pixel> {
47  /// Rect position.
48  pub position: dpi::LogicalPosition<P>,
49  /// Rect size.
50  pub size: dpi::LogicalSize<S>,
51}
52
53impl<P: dpi::Pixel, S: dpi::Pixel> Default for LogicalRect<P, S> {
54  fn default() -> Self {
55    Self {
56      position: (0, 0).into(),
57      size: (0, 0).into(),
58    }
59  }
60}