commit 672f56fe661af07cb429142d22f227bc26cd8524
parent a0540824ccfbb0631b136de0536d9eb834e8aee5
Author: Michael Savage <mikejsavage@gmail.com>
Date: Sat, 8 Sep 2018 17:40:52 +0300
Redo the layout when font changes
Diffstat:
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/ui.cc b/src/ui.cc
@@ -282,19 +282,10 @@ void ui_chat_print( const char * str, size_t len, Colour fg, Colour bg, bool bol
textbox_add( &chat_text, str, len, fg, bg, bold );
}
-void ui_resize( int width, int height ) {
+void ui_update_layout() {
int fw, fh;
ui_get_font_size( &fw, &fh );
- int old_width = window_width;
- int old_height = window_height;
-
- window_width = width;
- window_height = height;
-
- if( window_width == old_width && window_height == old_height )
- return;
-
textbox_set_pos( &chat_text, PADDING, PADDING );
textbox_set_size( &chat_text, window_width - ( 2 * PADDING ), ( fh + SPACING ) * CHAT_ROWS );
@@ -308,6 +299,19 @@ void ui_resize( int width, int height ) {
input_set_size( window_width - PADDING * 2, fh );
}
+void ui_resize( int width, int height ) {
+ int old_width = window_width;
+ int old_height = window_height;
+
+ window_width = width;
+ window_height = height;
+
+ if( window_width == old_width && window_height == old_height )
+ return;
+
+ ui_update_layout();
+}
+
void ui_scroll( int offset ) {
textbox_scroll( &main_text, offset );
}
diff --git a/src/ui.h b/src/ui.h
@@ -36,6 +36,7 @@ void ui_draw_char( int left, int top, char c, Colour colour, bool bold, bool for
void ui_redraw_dirty();
void ui_redraw_everything();
+void ui_update_layout();
void ui_resize( int width, int height );
void ui_scroll( int offset );
diff --git a/src/win32.cc b/src/win32.cc
@@ -214,6 +214,7 @@ bool ui_set_font( const char * name, int size ) {
Style.font.width = metrics.tmAveCharWidth;
Style.font.ascent = metrics.tmAscent;
+ ui_update_layout();
ui_redraw_everything();
return true;