| 1 |
/* File: pencil_size.inl; Copyright and License: see below */ |
| 2 |
|
| 3 |
#include "u8/u8_log.h" |
| 4 |
#include <assert.h> |
| 5 |
|
| 6 |
static inline void pencil_size_init( pencil_size_t *this_, double width, double height ) |
| 7 |
{ |
| 8 |
pencil_size_init_empty( this_ ); |
| 9 |
pencil_size_reinit( this_, width, height); |
| 10 |
} |
| 11 |
|
| 12 |
static inline void pencil_size_destroy( pencil_size_t *this_ ) |
| 13 |
{ |
| 14 |
pango_font_description_free ( (*this_).footnote_font_description ); |
| 15 |
(*this_).footnote_font_description = NULL; |
| 16 |
pango_font_description_free ( (*this_).standard_font_description ); |
| 17 |
(*this_).standard_font_description = NULL; |
| 18 |
pango_font_description_free ( (*this_).title_font_description ); |
| 19 |
(*this_).title_font_description = NULL; |
| 20 |
} |
| 21 |
|
| 22 |
static const char *PENCIL_SIZE_FONT_FAMILY = "Sans"; |
| 23 |
|
| 24 |
static inline void pencil_size_init_empty( pencil_size_t *this_ ) |
| 25 |
{ |
| 26 |
(*this_).standard_color.red = 0.0; |
| 27 |
(*this_).standard_color.green = 0.0; |
| 28 |
(*this_).standard_color.blue = 0.0; |
| 29 |
(*this_).standard_color.alpha = 1.0; |
| 30 |
|
| 31 |
(*this_).select_color.red = 1.0; |
| 32 |
(*this_).select_color.green = 0.3; |
| 33 |
(*this_).select_color.blue = 0.8; |
| 34 |
(*this_).select_color.alpha = 1.0; |
| 35 |
|
| 36 |
(*this_).highlight_color.red = 0.0; |
| 37 |
(*this_).highlight_color.green = 0.6; |
| 38 |
(*this_).highlight_color.blue = 0.4; |
| 39 |
(*this_).highlight_color.alpha = 1.0; |
| 40 |
|
| 41 |
(*this_).focus_color.red = 0.9; |
| 42 |
(*this_).focus_color.green = 0.85; |
| 43 |
(*this_).focus_color.blue = 0.0; |
| 44 |
(*this_).focus_color.alpha = 1.0; |
| 45 |
|
| 46 |
(*this_).emphasized_bgcolor.red = 1.0; |
| 47 |
(*this_).emphasized_bgcolor.green = 1.0; |
| 48 |
(*this_).emphasized_bgcolor.blue = 0.3; |
| 49 |
(*this_).emphasized_bgcolor.alpha = 1.0; |
| 50 |
|
| 51 |
(*this_).gray_out_color.red = 0.7; |
| 52 |
(*this_).gray_out_color.green = 0.7; |
| 53 |
(*this_).gray_out_color.blue = 0.7; |
| 54 |
(*this_).gray_out_color.alpha = 1.0; |
| 55 |
|
| 56 |
/* guess some default values: */ |
| 57 |
(*this_).footnote_font_size = 9.0; |
| 58 |
(*this_).footnote_font_description = pango_font_description_new (); |
| 59 |
pango_font_description_set_family_static ( (*this_).footnote_font_description, PENCIL_SIZE_FONT_FAMILY ); |
| 60 |
pango_font_description_set_style ( (*this_).footnote_font_description, PANGO_STYLE_NORMAL ); |
| 61 |
pango_font_description_set_weight ( (*this_).footnote_font_description, PANGO_WEIGHT_MEDIUM ); |
| 62 |
pango_font_description_set_stretch ( (*this_).footnote_font_description, PANGO_STRETCH_NORMAL ); |
| 63 |
pango_font_description_set_size ( (*this_).footnote_font_description, 9 * PANGO_SCALE ); |
| 64 |
|
| 65 |
(*this_).standard_font_size = 12.0; |
| 66 |
(*this_).standard_font_description = pango_font_description_new (); |
| 67 |
pango_font_description_set_family_static ( (*this_).standard_font_description, PENCIL_SIZE_FONT_FAMILY ); |
| 68 |
pango_font_description_set_style ( (*this_).standard_font_description, PANGO_STYLE_NORMAL ); |
| 69 |
pango_font_description_set_weight ( (*this_).standard_font_description, PANGO_WEIGHT_MEDIUM ); |
| 70 |
pango_font_description_set_stretch ( (*this_).standard_font_description, PANGO_STRETCH_NORMAL ); |
| 71 |
pango_font_description_set_size ( (*this_).standard_font_description, 12 * PANGO_SCALE ); |
| 72 |
|
| 73 |
(*this_).title_font_size = 14.0; |
| 74 |
(*this_).title_font_description = pango_font_description_new (); |
| 75 |
pango_font_description_set_family_static ( (*this_).title_font_description, PENCIL_SIZE_FONT_FAMILY ); |
| 76 |
pango_font_description_set_style ( (*this_).title_font_description, PANGO_STYLE_NORMAL ); |
| 77 |
pango_font_description_set_weight ( (*this_).title_font_description, PANGO_WEIGHT_BOLD ); |
| 78 |
pango_font_description_set_stretch ( (*this_).title_font_description, PANGO_STRETCH_NORMAL ); |
| 79 |
pango_font_description_set_size ( (*this_).title_font_description, 14 * PANGO_SCALE ); |
| 80 |
|
| 81 |
(*this_).standard_line_width = 1.0; |
| 82 |
(*this_).bold_line_width = 2.0; |
| 83 |
(*this_).line_dash_length = 5.0; |
| 84 |
(*this_).standard_object_border = 4.0; |
| 85 |
(*this_).arrow_stroke_length = 10.0; |
| 86 |
(*this_).arrow_stroke_087_length = 8.66; |
| 87 |
(*this_).preferred_object_distance = 20.0; |
| 88 |
(*this_).classifier_symbol_height = 24.0; |
| 89 |
} |
| 90 |
|
| 91 |
static inline void pencil_size_reinit( pencil_size_t *this_, double width, double height ) |
| 92 |
{ |
| 93 |
double smaller_border = (width<height) ? width : height; |
| 94 |
|
| 95 |
(*this_).footnote_font_size = smaller_border/80.0; |
| 96 |
if ( (*this_).footnote_font_size < 1.0 ) |
| 97 |
{ |
| 98 |
(*this_).footnote_font_size = 1.0; |
| 99 |
} |
| 100 |
pango_font_description_set_size ( (*this_).footnote_font_description, ((int)((*this_).footnote_font_size * PANGO_SCALE) )); |
| 101 |
|
| 102 |
(*this_).standard_font_size = smaller_border/56.0; |
| 103 |
if ( (*this_).standard_font_size < 1.0 ) |
| 104 |
{ |
| 105 |
(*this_).standard_font_size = 1.0; |
| 106 |
} |
| 107 |
pango_font_description_set_size ( (*this_).standard_font_description, ((int)((*this_).standard_font_size * PANGO_SCALE) )); |
| 108 |
|
| 109 |
(*this_).title_font_size = smaller_border/48.0; |
| 110 |
if ( (*this_).title_font_size < 1.0 ) |
| 111 |
{ |
| 112 |
(*this_).title_font_size = 1.0; |
| 113 |
} |
| 114 |
pango_font_description_set_size ( (*this_).title_font_description, ((int)((*this_).title_font_size * PANGO_SCALE) )); |
| 115 |
|
| 116 |
(*this_).standard_line_width = smaller_border/800.0; |
| 117 |
(*this_).bold_line_width = smaller_border/400.0; |
| 118 |
(*this_).line_dash_length = smaller_border/80.0; |
| 119 |
(*this_).standard_object_border = smaller_border/200.0; |
| 120 |
(*this_).arrow_stroke_length = smaller_border/67; |
| 121 |
(*this_).arrow_stroke_087_length = (*this_).arrow_stroke_length*0.866025403784; /* =sqrt(0.75) */ |
| 122 |
(*this_).preferred_object_distance = smaller_border/33.0; |
| 123 |
(*this_).classifier_symbol_height = smaller_border/20.0; |
| 124 |
} |
| 125 |
|
| 126 |
static inline double pencil_size_get_footnote_font_size( const pencil_size_t *this_ ) |
| 127 |
{ |
| 128 |
return (*this_).footnote_font_size; |
| 129 |
} |
| 130 |
|
| 131 |
static inline const PangoFontDescription *pencil_size_get_footnote_font_description( const pencil_size_t *this_ ) |
| 132 |
{ |
| 133 |
return (*this_).footnote_font_description; |
| 134 |
} |
| 135 |
|
| 136 |
static inline double pencil_size_get_standard_font_size( const pencil_size_t *this_ ) |
| 137 |
{ |
| 138 |
return (*this_).standard_font_size; |
| 139 |
} |
| 140 |
|
| 141 |
static inline const PangoFontDescription *pencil_size_get_standard_font_description( const pencil_size_t *this_ ) |
| 142 |
{ |
| 143 |
return (*this_).standard_font_description; |
| 144 |
} |
| 145 |
|
| 146 |
static inline double pencil_size_get_title_font_size( const pencil_size_t *this_ ) |
| 147 |
{ |
| 148 |
return (*this_).title_font_size; |
| 149 |
} |
| 150 |
|
| 151 |
static inline const PangoFontDescription *pencil_size_get_title_font_description( const pencil_size_t *this_ ) |
| 152 |
{ |
| 153 |
return (*this_).title_font_description; |
| 154 |
} |
| 155 |
|
| 156 |
static inline double pencil_size_get_font_tab_size( const pencil_size_t *this_ ) |
| 157 |
{ |
| 158 |
return 3.0 * (*this_).standard_font_size; |
| 159 |
} |
| 160 |
|
| 161 |
static inline double pencil_size_get_font_line_gap( const pencil_size_t *this_ ) |
| 162 |
{ |
| 163 |
return (*this_).standard_line_width; /* equals the standard line width */ |
| 164 |
} |
| 165 |
|
| 166 |
static inline double pencil_size_get_standard_line_width( const pencil_size_t *this_ ) |
| 167 |
{ |
| 168 |
return (*this_).standard_line_width; |
| 169 |
} |
| 170 |
|
| 171 |
static inline double pencil_size_get_bold_line_width( const pencil_size_t *this_ ) |
| 172 |
{ |
| 173 |
return (*this_).bold_line_width; |
| 174 |
} |
| 175 |
|
| 176 |
static inline double pencil_size_get_line_dash_length( const pencil_size_t *this_ ) |
| 177 |
{ |
| 178 |
return (*this_).line_dash_length; |
| 179 |
} |
| 180 |
|
| 181 |
static inline double pencil_size_get_standard_object_border( const pencil_size_t *this_ ) |
| 182 |
{ |
| 183 |
return (*this_).standard_object_border; |
| 184 |
} |
| 185 |
|
| 186 |
static inline double pencil_size_get_arrow_stroke_length( const pencil_size_t *this_ ) |
| 187 |
{ |
| 188 |
return (*this_).arrow_stroke_length; |
| 189 |
} |
| 190 |
|
| 191 |
static inline double pencil_size_get_arrow_stroke_087_length( const pencil_size_t *this_ ) |
| 192 |
{ |
| 193 |
return (*this_).arrow_stroke_087_length; |
| 194 |
} |
| 195 |
|
| 196 |
static inline double pencil_size_get_preferred_object_distance( const pencil_size_t *this_ ) |
| 197 |
{ |
| 198 |
return (*this_).preferred_object_distance; |
| 199 |
} |
| 200 |
|
| 201 |
static inline double pencil_size_get_classifier_symbol_height( const pencil_size_t *this_ ) |
| 202 |
{ |
| 203 |
return (*this_).classifier_symbol_height; |
| 204 |
} |
| 205 |
|
| 206 |
static inline GdkRGBA pencil_size_get_standard_color( const pencil_size_t *this_ ) |
| 207 |
{ |
| 208 |
return (*this_).standard_color; |
| 209 |
} |
| 210 |
|
| 211 |
static inline GdkRGBA pencil_size_get_select_color( const pencil_size_t *this_ ) |
| 212 |
{ |
| 213 |
return (*this_).select_color; |
| 214 |
} |
| 215 |
|
| 216 |
static inline GdkRGBA pencil_size_get_highlight_color( const pencil_size_t *this_ ) |
| 217 |
{ |
| 218 |
return (*this_).highlight_color; |
| 219 |
} |
| 220 |
|
| 221 |
static inline GdkRGBA pencil_size_get_focus_color( const pencil_size_t *this_ ) |
| 222 |
{ |
| 223 |
return (*this_).focus_color; |
| 224 |
} |
| 225 |
|
| 226 |
static inline GdkRGBA pencil_size_get_emphasized_bgcolor( const pencil_size_t *this_ ) |
| 227 |
{ |
| 228 |
return (*this_).emphasized_bgcolor; |
| 229 |
} |
| 230 |
|
| 231 |
static inline GdkRGBA pencil_size_get_gray_out_color( const pencil_size_t *this_ ) |
| 232 |
{ |
| 233 |
return (*this_).gray_out_color; |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
/* |
| 238 |
Copyright 2016-2026 Andreas Warnke |
| 239 |
|
| 240 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 241 |
you may not use this file except in compliance with the License. |
| 242 |
You may obtain a copy of the License at |
| 243 |
|
| 244 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 245 |
|
| 246 |
Unless required by applicable law or agreed to in writing, software |
| 247 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 248 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 249 |
See the License for the specific language governing permissions and |
| 250 |
limitations under the License. |
| 251 |
*/ |