diff options
Diffstat (limited to 'src/gui/textbox.cpp')
| -rw-r--r-- | src/gui/textbox.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp index 0a9745f..edf2a30 100644 --- a/src/gui/textbox.cpp +++ b/src/gui/textbox.cpp @@ -14,7 +14,7 @@ struct GUI_TEXTBOX_KEY_RESULT { static I32 gui_textbox_line_height() { GL_FONT* font = _gui.fonts.jpn12.glfnt; return font - ? max<I32>( 1, (I32)font->char_height ) + ? max( 1, (I32)font->char_height ) : 1; } @@ -35,11 +35,11 @@ static U8 gui_textbox_has_selection( const GUI_TEXTBOX* tb ) { } static U32 gui_textbox_selection_start( const GUI_TEXTBOX* tb ) { - return min<U32>( tb->cursorin, tb->cursorout ); + return min( tb->cursorin, tb->cursorout ); } static U32 gui_textbox_selection_end( const GUI_TEXTBOX* tb ) { - return max<U32>( tb->cursorin, tb->cursorout ); + return max( tb->cursorin, tb->cursorout ); } static U8 gui_textbox_shift_down( const GUI_TEXTBOX* tb ) { @@ -120,8 +120,8 @@ static U32 gui_textbox_nearest_cursor_x( static void gui_textbox_update_cursor_metrics( GUI_TEXTBOX* tb ) { U32 length = (U32)strlen( tb->value ); - tb->cursorin = min<U32>( tb->cursorin, length ); - tb->cursorout = min<U32>( tb->cursorout, length ); + tb->cursorin = min( tb->cursorin, length ); + tb->cursorout = min( tb->cursorout, length ); U32 line_start_in = gui_textbox_line_start( tb->value, tb->cursorin ); U32 line_start_out = gui_textbox_line_start( tb->value, tb->cursorout ); @@ -150,7 +150,7 @@ static void gui_textbox_set_cursor( U8 preserve_vertical_goal = 0 ) { U32 length = (U32)strlen( tb->value ); - tb->cursorout = min<U32>( cursor, length ); + tb->cursorout = min( cursor, length ); if( !extend_selection ) tb->cursorin = tb->cursorout; @@ -169,7 +169,7 @@ static U32 gui_textbox_cursor_from_point( I32 line_height = gui_textbox_line_height(); I32 line_count = gui_textbox_line_count( tb->value, length ); I32 row = local_y / line_height; - row = m_clamp<I32>( row, 0, line_count - 1 ); + row = m_clamp( row, 0, line_count - 1 ); U32 line_start = gui_textbox_line_start_from_row( tb->value, length, row ); @@ -180,7 +180,7 @@ static U32 gui_textbox_cursor_from_point( tb->value, line_start, line_end, - max<I32>( 0, local_x ) + max( 0, local_x ) ); } @@ -239,11 +239,11 @@ static U8 gui_textbox_delete_selection( GUI_TEXTBOX* tb ) { return 0; U32 length = (U32)strlen( tb->value ); - U32 start = min<U32>( + U32 start = min( gui_textbox_selection_start( tb ), length ); - U32 end = min<U32>( + U32 end = min( gui_textbox_selection_end( tb ), length ); @@ -275,13 +275,13 @@ static U32 gui_textbox_insert_bytes( return 0; U32 length = (U32)strlen( tb->value ); - U32 limit = min<U32>( tb->maxlen, GUI_TEXTBOX_MAX ); + U32 limit = min( tb->maxlen, GUI_TEXTBOX_MAX ); - U32 start = min<U32>( + U32 start = min( gui_textbox_selection_start( tb ), length ); - U32 end = min<U32>( + U32 end = min( gui_textbox_selection_end( tb ), length ); @@ -293,7 +293,7 @@ static U32 gui_textbox_insert_bytes( return 0; U32 available = limit - 1 - remaining; - count = min<U32>( count, available ); + count = min( count, available ); if( !count ) return 0; @@ -321,7 +321,7 @@ static U8 gui_textbox_backspace( GUI_TEXTBOX* tb ) { return 1; U32 length = (U32)strlen( tb->value ); - U32 cursor = min<U32>( tb->cursorout, length ); + U32 cursor = min( tb->cursorout, length ); if( !cursor ) return 0; @@ -343,7 +343,7 @@ static U8 gui_textbox_delete_forward( GUI_TEXTBOX* tb ) { return 1; U32 length = (U32)strlen( tb->value ); - U32 cursor = min<U32>( tb->cursorout, length ); + U32 cursor = min( tb->cursorout, length ); if( cursor >= length ) return 0; @@ -369,7 +369,7 @@ void gui_textbox_draw_blinker( GUI_TEXTBOX* tb, I32 x, I32 y, CLR clr ) { } if( tb->blink ) { - I32 caret_h = max<I32>( 1, + I32 caret_h = max( 1, gui_textbox_line_height() - 2 ); gui_draw_frect( @@ -386,7 +386,7 @@ static I32 gui_textbox_newline_width() { if( !font ) return 1; - return max<I32>( 1, + return max( 1, (I32)( font->glyphs[(U8)' '].advance_x + 0.5f ) ); } @@ -401,10 +401,10 @@ static void gui_textbox_draw_selection( return; U32 length = (U32)strlen( tb->value ); - U32 selection_start = min<U32>( + U32 selection_start = min( gui_textbox_selection_start( tb ), length ); - U32 selection_end = min<U32>( + U32 selection_end = min( gui_textbox_selection_end( tb ), length ); @@ -421,10 +421,10 @@ static void gui_textbox_draw_selection( tb->value, length, line_start ); - U32 range_start = max<U32>( + U32 range_start = max( selection_start, line_start ); - U32 range_end = min<U32>( + U32 range_end = min( selection_end, line_end ); @@ -466,8 +466,8 @@ static void gui_textbox_draw_frame( gui_draw_frect( x, y, tb->w, tb->h, border ); gui_draw_frect( x + 1, y + 1, - max<I32>( 0, tb->w - 2 ), - max<I32>( 0, tb->h - 2 ), + max( 0, tb->w - 2 ), + max( 0, tb->h - 2 ), ui_clr.bg_sec ); } @@ -486,7 +486,7 @@ static void gui_textbox_update_scroll( "%s", tb->value ); - text_h = max<I32>( text_h, + text_h = max( text_h, tb->cursorpy + line_height ); @@ -495,11 +495,11 @@ static void gui_textbox_update_scroll( else if( tb->cursorpxout + 1 > tb->scrollpx + content_w ) tb->scrollpx = tb->cursorpxout + 1 - content_w; - I32 max_scroll_x = max<I32>( 0, - max<I32>( text_w, tb->cursorpxout + 1 ) - content_w + I32 max_scroll_x = max( 0, + max( text_w, tb->cursorpxout + 1 ) - content_w ); - tb->scrollpx = m_clamp<I32>( + tb->scrollpx = m_clamp( tb->scrollpx, 0, max_scroll_x ); @@ -514,10 +514,10 @@ static void gui_textbox_update_scroll( else if( tb->cursorpy + line_height > tb->scrollpy + content_h ) tb->scrollpy = tb->cursorpy + line_height - content_h; - tb->scrollpy = m_clamp<I32>( + tb->scrollpy = m_clamp( tb->scrollpy, 0, - max<I32>( 0, text_h - content_h ) + max( 0, text_h - content_h ) ); } @@ -532,8 +532,8 @@ static void gui_textbox_draw_content( gui_draw_push_clip( x + 1, y + 1, - max<I32>( 0, tb->w - 2 ), - max<I32>( 0, tb->h - 2 ) + max( 0, tb->w - 2 ), + max( 0, tb->h - 2 ) ); gui_textbox_draw_selection( tb, @@ -573,8 +573,8 @@ void gui_textbox_draw_fn( void* ptr ) { gui_textbox_draw_frame( tb, x, y ); gui_textbox_update_cursor_metrics( tb ); gui_textbox_update_scroll( tb, - max<I32>( 1, tb->w - 4 ), - max<I32>( 1, tb->h - 4 ), + max( 1, tb->w - 4 ), + max( 1, tb->h - 4 ), line_height ); @@ -822,8 +822,8 @@ static U8 gui_textbox_key_repeatable( void gui_textbox_loop_keys( GUI_TEXTBOX* tb ) { U32 length = strlen( tb->value ); - tb->cursorin = min<U32>( tb->cursorin, length ); - tb->cursorout = min<U32>( tb->cursorout, length ); + tb->cursorin = min( tb->cursorin, length ); + tb->cursorout = min( tb->cursorout, length ); U8 extend_selection = gui_textbox_shift_down( tb ); for( U32 idx = 0; idx < 0x100; ++idx ) { |
