From b5d69f41b4480f1309008333bef98a197c25b31d Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 20 Mar 2021 23:21:03 +0100 Subject: [PATCH] radiant/xywindow: make glarea redraw code reusable, force redraw on background selection --- radiant/xywindow.cpp | 28 +++++++++++++++++----------- radiant/xywindow.h | 2 ++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index a39fed7b..ab1e8ee9 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -529,6 +529,19 @@ void XYWnd_ZoomOut( XYWnd* xy ){ } } +void XYWnd::Redraw() { + if ( glwidget_make_current( m_gl_widget ) != FALSE ) { + if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) { + GlobalOpenGL_debugAssertNoErrors(); + XY_Draw(); + GlobalOpenGL_debugAssertNoErrors(); + + m_XORRectangle.set( rectangle_t() ); + } + glwidget_swap_buffers( m_gl_widget ); + } +} + VIEWTYPE GlobalXYWnd_getCurrentViewType(){ ASSERT_NOTNULL( g_pParentWnd ); ASSERT_NOTNULL( g_pParentWnd->ActiveXY() ); @@ -769,20 +782,10 @@ gboolean xywnd_size_allocate( ui::Widget widget, GtkAllocation* allocation, XYWn } gboolean xywnd_expose( ui::Widget widget, GdkEventExpose* event, XYWnd* xywnd ){ - if ( glwidget_make_current( xywnd->GetWidget() ) != FALSE ) { - if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) { - GlobalOpenGL_debugAssertNoErrors(); - xywnd->XY_Draw(); - GlobalOpenGL_debugAssertNoErrors(); - - xywnd->m_XORRectangle.set( rectangle_t() ); - } - glwidget_swap_buffers( xywnd->GetWidget() ); - } + xywnd->Redraw(); return FALSE; } - void XYWnd_CameraMoved( XYWnd& xywnd ){ if ( g_xywindow_globals_private.m_bCamXYUpdate ) { XYWnd_Update( xywnd ); @@ -1501,6 +1504,9 @@ void WXY_BackgroundSelect( void ){ if ( filename ) { g_pParentWnd->ActiveXY()->XY_LoadBackgroundImage( filename ); } + + // Draw the background image immediately (do not wait for user input). + g_pParentWnd->ActiveXY()->Redraw(); } /* diff --git a/radiant/xywindow.h b/radiant/xywindow.h index 0b762d45..ee434833 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -124,6 +124,8 @@ void Zoom_End(); bool m_zoom_started; guint m_zoom_focusOut; +void Redraw(); + void SetActive( bool b ){ m_bActive = b; }; -- 2.39.2