docs
Loading...
Searching...
No Matches
Monitor.h
Go to the documentation of this file.
1///
2/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3/// A license is required for commercial use. https://ultralig.ht
4///
5#pragma once
6#include "Defines.h"
7
8namespace ultralight {
9
10///
11/// A platform-specific monitor.
12///
13/// ## Coordinate Systems
14///
15/// A monitor may have a device scale applied by the OS (for example, a Retina display on macOS
16/// may have a 2x or 3x DPI scale).
17///
18/// Unadorned dimensions in this API are logical pixels (device-scale independent). The device_*
19/// accessors report physical device pixels. The two are related by scale():
20///
21/// ```
22/// device_pixels = round(logical_pixels * scale)
23/// ```
24///
26public:
27 virtual ~Monitor() {}
28
29 ///
30 /// Get the unique display ID of the monitor.
31 ///
32 /// The renderer uses this ID to identify which monitor a View is on (ViewConfig::display_id).
33 ///
34 /// The App tracks the refresh of each monitor it enumerates and automatically calls
35 /// Renderer::RefreshDisplay() with this ID to drive animation in the corresponding View%s.
36 ///
37 /// @see App::monitor()
38 ///
39 virtual uint32_t display_id() const = 0;
40
41 ///
42 /// Get the DPI scale (1.0 = 100%).
43 ///
44 virtual double scale() const = 0;
45
46 ///
47 /// Get the width of the monitor (in logical pixels).
48 ///
49 virtual double width() const = 0;
50
51 ///
52 /// Get the height of the monitor (in logical pixels).
53 ///
54 virtual double height() const = 0;
55
56 ///
57 /// Get the width of the monitor (in device pixels).
58 ///
59 virtual uint32_t device_width() const = 0;
60
61 ///
62 /// Get the height of the monitor (in device pixels).
63 ///
64 virtual uint32_t device_height() const = 0;
65
66 ///
67 /// Get the refresh rate of the monitor (in Hz).
68 ///
69 /// This is the nominal rate of the monitor's current display mode (60 when the rate is
70 /// unavailable). A variable-refresh display reports its maximum rate.
71 ///
72 virtual uint32_t refresh_rate() const = 0;
73};
74
75} // namespace ultralight
#define AExport
Definition Defines.h:41
A platform-specific monitor.
Definition Monitor.h:25
virtual ~Monitor()
Definition Monitor.h:27
virtual double scale() const =0
Get the DPI scale (1.0 = 100%).
virtual uint32_t device_height() const =0
Get the height of the monitor (in device pixels).
virtual double width() const =0
Get the width of the monitor (in logical pixels).
virtual double height() const =0
Get the height of the monitor (in logical pixels).
virtual uint32_t device_width() const =0
Get the width of the monitor (in device pixels).
virtual uint32_t refresh_rate() const =0
Get the refresh rate of the monitor (in Hz).
virtual uint32_t display_id() const =0
Get the unique display ID of the monitor.
Root namespace for every public Ultralight type, function, and enumeration.