2020-05-28 13:21:20 +02:00
|
|
|
module gx
|
|
|
|
|
2021-09-13 23:05:30 +02:00
|
|
|
// TODO: remove these, and use the enum everywhere
|
2021-02-03 09:17:13 +01:00
|
|
|
pub const (
|
|
|
|
align_left = HorizontalAlign.left
|
2020-08-19 07:10:42 +02:00
|
|
|
align_right = HorizontalAlign.right
|
2020-05-28 13:21:20 +02:00
|
|
|
)
|
|
|
|
|
2021-09-13 23:05:30 +02:00
|
|
|
[params]
|
2020-05-28 13:21:20 +02:00
|
|
|
pub struct TextCfg {
|
|
|
|
pub:
|
2020-08-19 07:10:42 +02:00
|
|
|
color Color = black
|
2021-02-03 09:17:13 +01:00
|
|
|
size int = 16
|
2020-08-19 07:10:42 +02:00
|
|
|
align HorizontalAlign = .left
|
2021-02-03 09:17:13 +01:00
|
|
|
vertical_align VerticalAlign = .top
|
2020-08-19 07:10:42 +02:00
|
|
|
max_width int
|
|
|
|
family string
|
|
|
|
bold bool
|
|
|
|
mono bool
|
|
|
|
italic bool
|
2020-05-28 13:21:20 +02:00
|
|
|
}
|
2021-12-22 11:26:52 +01:00
|
|
|
|
|
|
|
pub fn (cfg TextCfg) to_css_string() string {
|
|
|
|
mut font_style := ''
|
|
|
|
if cfg.bold {
|
|
|
|
font_style += 'bold '
|
|
|
|
}
|
|
|
|
if cfg.mono {
|
|
|
|
font_style += 'mono '
|
|
|
|
}
|
|
|
|
if cfg.italic {
|
|
|
|
font_style += 'italic '
|
|
|
|
}
|
|
|
|
return '$font_style ${cfg.size}px $cfg.family'
|
|
|
|
}
|