cogl/auto/
output.rs

1use crate::{Object, SubpixelOrder};
2
3use glib::translate::*;
4use std::fmt;
5
6glib_wrapper! {
7    pub struct Output(Object<ffi::CoglOutput, OutputClass>) @extends Object;
8
9    match fn {
10        get_type => || ffi::cogl_output_get_gtype(),
11    }
12}
13
14impl Output {
15    /// Gets the height of the output in pixels.
16    ///
17    /// # Returns
18    ///
19    /// the height of the output in pixels
20    pub fn get_height(&self) -> i32 {
21        unsafe { ffi::cogl_output_get_height(self.to_glib_none().0) }
22    }
23
24    /// Gets the physical height of the output. In some cases (such as
25    /// as a projector), the value returned here might correspond to
26    /// nominal resolution rather than the actual physical size of the
27    /// output device.
28    ///
29    /// # Returns
30    ///
31    /// the height of the output in millimeters. A value
32    ///  of 0 indicates that the height is unknown
33    pub fn get_mm_height(&self) -> i32 {
34        unsafe { ffi::cogl_output_get_mm_height(self.to_glib_none().0) }
35    }
36
37    /// Gets the physical width of the output. In some cases (such as
38    /// as a projector), the value returned here might correspond to
39    /// nominal resolution rather than the actual physical size of the
40    /// output device.
41    ///
42    /// # Returns
43    ///
44    /// the height of the output in millimeters. A value
45    ///  of 0 indicates the width is unknown
46    pub fn get_mm_width(&self) -> i32 {
47        unsafe { ffi::cogl_output_get_mm_width(self.to_glib_none().0) }
48    }
49
50    /// Gets the number of times per second that the output device refreshes
51    /// the display contents.
52    ///
53    /// # Returns
54    ///
55    /// the refresh rate of the output device. A value of zero
56    ///  indicates that the refresh rate is unknown.
57    pub fn get_refresh_rate(&self) -> f32 {
58        unsafe { ffi::cogl_output_get_refresh_rate(self.to_glib_none().0) }
59    }
60
61    /// For an output device where each pixel is made up of smaller components
62    /// with different colors, returns the layout of the subpixel
63    /// components.
64    ///
65    /// # Returns
66    ///
67    /// the order of subpixel components for the output device
68    pub fn get_subpixel_order(&self) -> SubpixelOrder {
69        unsafe { from_glib(ffi::cogl_output_get_subpixel_order(self.to_glib_none().0)) }
70    }
71
72    /// Gets the width of the output in pixels.
73    ///
74    /// # Returns
75    ///
76    /// the width of the output in pixels
77    pub fn get_width(&self) -> i32 {
78        unsafe { ffi::cogl_output_get_width(self.to_glib_none().0) }
79    }
80
81    /// Gets the X position of the output with respect to the coordinate
82    /// system of the screen.
83    ///
84    /// # Returns
85    ///
86    /// the X position of the output as a pixel offset
87    ///  from the left side of the screen coordinate space
88    pub fn get_x(&self) -> i32 {
89        unsafe { ffi::cogl_output_get_x(self.to_glib_none().0) }
90    }
91
92    /// Gets the Y position of the output with respect to the coordinate
93    /// system of the screen.
94    ///
95    /// # Returns
96    ///
97    /// the Y position of the output as a pixel offset
98    ///  from the top side of the screen coordinate space
99    pub fn get_y(&self) -> i32 {
100        unsafe { ffi::cogl_output_get_y(self.to_glib_none().0) }
101    }
102}
103
104impl fmt::Display for Output {
105    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
106        write!(f, "Output")
107    }
108}