gui2/text_box: Add a monospace font variation
This requires communicating the font family to the internal renderer, so it's not just a WML change.
This commit is contained in:
parent
5e535a7bac
commit
3ddbeb0b1e
2 changed files with 25 additions and 4 deletions
|
@ -37,6 +37,8 @@
|
|||
#enddef
|
||||
|
||||
#define _GUI_DRAW_TEXT SIZE COLOR
|
||||
#arg FONT_FAMILY
|
||||
#endarg
|
||||
[rectangle]
|
||||
x = "(text_x_offset + selection_offset)"
|
||||
y = "(text_y_offset)"
|
||||
|
@ -54,6 +56,7 @@
|
|||
h = "(text_height)"
|
||||
maximum_width = "(text_maximum_width)"
|
||||
font_size = {SIZE}
|
||||
font_family = {FONT_FAMILY}
|
||||
color = {COLOR}
|
||||
text = "(text)"
|
||||
[/text]
|
||||
|
@ -70,6 +73,8 @@
|
|||
128, 128, 128, 255 #enddef
|
||||
|
||||
#define _GUI_DRAW_TEXT_OR_HINT SIZE COLOR
|
||||
#arg FONT_FAMILY
|
||||
#endarg
|
||||
[rectangle]
|
||||
x = "(text_x_offset + selection_offset)"
|
||||
y = "(text_y_offset)"
|
||||
|
@ -92,6 +97,7 @@
|
|||
hint_size = {GUI_FONT_SIZE_SMALL},
|
||||
reg_size = {SIZE}
|
||||
)"
|
||||
font_family = {FONT_FAMILY}
|
||||
|
||||
color = "(
|
||||
if(text = '' and hint_text != '', hint_color, reg_color) where
|
||||
|
@ -131,6 +137,8 @@
|
|||
#enddef
|
||||
|
||||
#define _GUI_RESOLUTION RESOLUTION MIN_WIDTH DEFAULT_WIDTH HEIGHT X_OFFSET EXTRA_WIDTH FONT_SIZE BACKGROUND_ENABLED BACKGROUND_DISABLED
|
||||
#arg FONT_FAMILY
|
||||
#endarg
|
||||
[resolution]
|
||||
|
||||
{RESOLUTION}
|
||||
|
@ -145,6 +153,7 @@
|
|||
max_height = {HEIGHT}
|
||||
|
||||
text_font_size = {FONT_SIZE}
|
||||
text_font_family = {FONT_FAMILY}
|
||||
text_x_offset = {X_OFFSET}
|
||||
text_y_offset = "(if(text_font_height <= height, (height - text_font_height) / 2, 0))"
|
||||
text_extra_width = {EXTRA_WIDTH}
|
||||
|
@ -159,7 +168,7 @@
|
|||
|
||||
{_GUI_DRAW_BORDER ({GUI__BORDER_COLOR_DARK}) }
|
||||
|
||||
{_GUI_DRAW_TEXT_OR_HINT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__DEFAULT}) }
|
||||
{_GUI_DRAW_TEXT_OR_HINT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__DEFAULT}) FONT_FAMILY={FONT_FAMILY} }
|
||||
|
||||
[/draw]
|
||||
|
||||
|
@ -173,7 +182,7 @@
|
|||
|
||||
{_GUI_DRAW_BORDER ({GUI__FONT_COLOR_DISABLED_DARK__DEFAULT}) }
|
||||
|
||||
{_GUI_DRAW_TEXT_OR_HINT ({FONT_SIZE}) ({GUI__FONT_COLOR_DISABLED__DEFAULT}) }
|
||||
{_GUI_DRAW_TEXT_OR_HINT ({FONT_SIZE}) ({GUI__FONT_COLOR_DISABLED__DEFAULT}) FONT_FAMILY={FONT_FAMILY} }
|
||||
|
||||
[/draw]
|
||||
|
||||
|
@ -188,7 +197,7 @@
|
|||
{_GUI_DRAW_BORDER ({GUI__BORDER_COLOR_BRIGHT}) }
|
||||
|
||||
# We never draw the hint text or image if focused
|
||||
{_GUI_DRAW_TEXT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__DEFAULT}) }
|
||||
{_GUI_DRAW_TEXT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__DEFAULT}) FONT_FAMILY={FONT_FAMILY} }
|
||||
|
||||
{_GUI_DRAW_CURSOR ({X_OFFSET}) }
|
||||
|
||||
|
@ -204,7 +213,7 @@
|
|||
|
||||
{_GUI_DRAW_BORDER ({GUI__BORDER_COLOR}) }
|
||||
|
||||
{_GUI_DRAW_TEXT_OR_HINT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__DEFAULT}) }
|
||||
{_GUI_DRAW_TEXT_OR_HINT ({FONT_SIZE}) ({GUI__FONT_COLOR_ENABLED__DEFAULT}) FONT_FAMILY={FONT_FAMILY} }
|
||||
|
||||
[/draw]
|
||||
|
||||
|
@ -230,6 +239,14 @@
|
|||
|
||||
[/text_box_definition]
|
||||
|
||||
[text_box_definition]
|
||||
id = "verbatim"
|
||||
description = "Monospace text box for command inputs"
|
||||
|
||||
{_GUI_RESOLUTION () 40 250 30 5 10 ({GUI_FONT_SIZE_DEFAULT}) ({_GUI_TEXTBOX_BACKGROUND_ENABLED}) ({_GUI_TEXTBOX_BACKGROUND_DISABLED}) FONT_FAMILY=monospace}
|
||||
|
||||
[/text_box_definition]
|
||||
|
||||
#undef _GUI_RESOLUTION
|
||||
#undef _GUI_DRAW_CURSOR
|
||||
#undef _GUI_DRAW_TEXT
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "cursor.hpp"
|
||||
#include "desktop/clipboard.hpp"
|
||||
#include "gui/core/gui_definition.hpp"
|
||||
#include "gui/core/log.hpp"
|
||||
#include "gui/core/timer.hpp"
|
||||
#include "serialization/unicode.hpp"
|
||||
|
@ -45,6 +46,9 @@ text_box_base::text_box_base(const implementation::builder_styled_widget& builde
|
|||
, cursor_blink_rate_ms_(750)
|
||||
, text_changed_callback_()
|
||||
{
|
||||
auto cfg = get_control(control_type, builder.definition);
|
||||
text_.set_family_class(cfg->text_font_family);
|
||||
|
||||
#ifdef __unix__
|
||||
// pastes on UNIX systems.
|
||||
connect_signal<event::MIDDLE_BUTTON_CLICK>(std::bind(
|
||||
|
|
Loading…
Add table
Reference in a new issue