neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
device_metrics.hpp
Go to the documentation of this file.
1// device_metrics.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2018, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
23
25
26namespace neogfx
27{
28 constexpr dimension STANDARD_DPI_PPI = 96.0;
29 constexpr dimension HIGH_DPI_PPI = 144.0;
30 constexpr dimension DPI_DIVISOR = 48.0;
31
33 {
34 return static_cast<dimension>(static_cast<int32_t>(aPpi / HIGH_DPI_PPI) + 1.0);
35 }
36
38 {
39 return static_cast<dimension>(static_cast<int32_t>(aPpi / (DPI_DIVISOR + 1.0)) + 1) * (DPI_DIVISOR / STANDARD_DPI_PPI);
40 }
41
42 enum class dpi_scale_type
43 {
44 X2,
45 XN
46 };
47
49 {
50 thread_local dpi_scale_type tDs = dpi_scale_type::X2;
51 return tDs;
52 }
53
55 {
56 public:
66 private:
67 dpi_scale_type iPrevious;
68 };
69
71 {
72 public:
73 virtual dimension horizontal_dpi() const = 0;
74 virtual dimension vertical_dpi() const = 0;
75 virtual dimension ppi() const = 0;
76 };
77
79 {
80 public:
81 virtual bool metrics_available() const = 0;
82 virtual size extents() const = 0;
83 virtual dimension em_size() const = 0;
84 };
85}
virtual bool metrics_available() const =0
virtual size extents() const =0
virtual dimension em_size() const =0
virtual dimension ppi() const =0
virtual dimension horizontal_dpi() const =0
virtual dimension vertical_dpi() const =0
scoped_dpi_scale_type(dpi_scale_type aDpiScale=dpi_scale_type::X2)
constexpr dimension HIGH_DPI_PPI
constexpr dimension STANDARD_DPI_PPI
default_geometry_value_type dimension
dimension x2_dpi_scale_factor(dimension aPpi)
dpi_scale_type & dpi_scale_type_for_thread()
constexpr dimension DPI_DIVISOR
dimension xn_dpi_scale_factor(dimension aPpi)