]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
radiant/xywindow: make glarea redraw code reusable, force redraw on background selection
authorThomas Debesse <dev@illwieckz.net>
Sat, 20 Mar 2021 22:21:03 +0000 (23:21 +0100)
committerThomas Debesse <dev@illwieckz.net>
Sun, 21 Mar 2021 19:44:18 +0000 (20:44 +0100)
radiant/xywindow.cpp
radiant/xywindow.h

index a39fed7b0e1243f4159ff334b6c4fe7cb90fce1c..ab1e8ee9d823d3b338f14383552760086b5bf35b 100644 (file)
@@ -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();
 }
 
 /*
index 0b762d45a8daeca7d0d802a382c52f7f6296351c..ee434833bb05f3e950bb7360372a09b72213c1e5 100644 (file)
@@ -124,6 +124,8 @@ void Zoom_End();
 bool m_zoom_started;
 guint m_zoom_focusOut;
 
+void Redraw();
+
 void SetActive( bool b ){
        m_bActive = b;
 };