HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
subpixel_orientation.hpp
1// Copyright Take Vos 2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
8#pragma once
9
10#include "../geometry/geometry.hpp"
11#include "../utility/utility.hpp"
12#include "../macros.hpp"
13#include <format>
14
15hi_export_module(hikogui.settings.subpixel_orientation);
16
17hi_export namespace hi::inline v1 {
18
22 unknown,
23 horizontal_rgb,
24 horizontal_bgr,
25 vertical_rgb,
26 vertical_bgr,
27};
28
29// clang-format off
30constexpr auto subpixel_orientation_metadata = enum_metadata{
31 subpixel_orientation::unknown, "unknown",
32 subpixel_orientation::horizontal_rgb, "horizontal RGB",
33 subpixel_orientation::horizontal_bgr, "horizontal BGR",
34 subpixel_orientation::vertical_rgb, "vertical RGB",
35 subpixel_orientation::vertical_bgr, "vertical BGR",
36};
37// clang-format on
38
41[[nodiscard]] constexpr extent2 sub_pixel_size(subpixel_orientation orientation) noexcept
42{
43 switch (orientation) {
44 case subpixel_orientation::vertical_rgb:
45 case subpixel_orientation::vertical_bgr: return extent2{1.0f, 1.0f / 3.0f};
46 case subpixel_orientation::horizontal_bgr:
47 case subpixel_orientation::horizontal_rgb: return extent2{1.0f / 3.0f, 1.0f};
48 default: return extent2{1.0f, 1.0f};
49 }
50}
51
52} // namespace hi::inline v1
53
54// XXX #617 MSVC bug does not handle partial specialization in modules.
55hi_export template<>
56struct std::formatter<hi::subpixel_orientation, char> : std::formatter<std::string_view, char> {
57 auto format(hi::subpixel_orientation const &t, auto &fc) const
58 {
59 return std::formatter<std::string_view, char>::format(hi::subpixel_orientation_metadata[t], fc);
60 }
61};
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
constexpr extent2 sub_pixel_size(subpixel_orientation orientation) noexcept
Get the size of a sub-pixel based on the sub-pixel orientation.
Definition subpixel_orientation.hpp:41
subpixel_orientation
The orientation of the RGB sub-pixels of and LCD/LED panel.
Definition subpixel_orientation.hpp:21