libabigail
Loading...
Searching...
No Matches
abg-viz-common.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2// -*- mode: C++ -*-
3//
4// Copyright (C) 2013-2024 Red Hat, Inc.
5
6/// @file
7
8#ifndef __ABG_VIZ_COMMON_H__
9#define __ABG_VIZ_COMMON_H__
10
11#include <sstream> //stringstream
12#include <string>
13#include <tuple>
14#include <array>
15
16namespace abigail
17{
18
19/// Utility function, like regex_replace.
20void
21string_replace(std::string&, const std::string&, const std::string&);
22
23
24/// Measurement abstraction type, conversion function.
25enum class units
26{
27 // NB: 1 pixel = .264583 mm
28 millimeter, // mm
29 pixel // px
30};
31
32std::string
33units_to_string(units);
34
35typedef unsigned short units_type;
36
37
38/**
39 Page/Canvas/Drawing area description.
40 Size, origin location in 2D (x,y), heigh, width
41
42 ANSI Letter mm == (units::millimeter, 215.9, 279.4);
43 ANSI Letter pixels == (units::pixel, 765, 990);
44 ISO A4 mm == (units::millimeter, 210, 297);
45 ISO A4 pixels == (units::pixel, 744.09, 1052.36);
46 */
47struct canvas
48{
49 units _M_units;
50 units_type _M_width;
51 units_type _M_height;
52};
53
54/// Useful canvas constants.
55extern const canvas ansi_letter_canvas;
56extern const canvas iso_a4_canvas;
57
58
59/// Color, conversion function.
60enum class color
61{
62 white,
63 gray25, // gainsboro
64 gray75, // slategray
65 black
66};
67
68std::string
69color_to_string(color);
70
71
72/**
73 Character rendering, type, fonts, styles.
74
75 Expect to keep changing the output, so use this abstraction to set
76 styling defaults, so that one can just assign types instead of doing
77 a bunch of search-and-replace operations when changing type
78 characteristics.
79 */
81{
82 enum anchor { start, middle };
83
84 std::string _M_face; // System font name
85 unsigned short _M_size; // Display size
86 color _M_color;
87 std::string _M_attributes; // Any other attributes
88
89 std::string
90 to_attribute(anchor) const;
91
92 std::string
93 anchor_to_string(anchor) const;
94};
95
96/// Useful typography constants.
97extern const typography arial_typo;
98extern const typography source_code_pro_typo;
99extern const typography roboto_light_typo;
100
101
102/// Datum consolidating style preferences.
103struct style
104{
105 color _M_text_color;
106 color _M_fill_color;
107 std::string _M_attributes;
108};
109
110
111}// end namespace abigail
112
113#endif //__ABG_VIZ_COMMON_H__
Toplevel namespace for libabigail.
const canvas ansi_letter_canvas
Useful canvas constants.
units
Measurement abstraction type, conversion function.
const typography arial_typo
Useful typography constants.
color
Color, conversion function.
void string_replace(std::string &target, const std::string &match, const std::string &replace)
Utility function, like regex_replace.
Datum consolidating style preferences.