X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fxywindow.cpp;h=6b3d893b7f44dfcfe73264ac538c9c0db9cc7cd6;hb=59d46c47dd0d80a344748773bd4c92b619bf4f63;hp=62e4c61cf9922c6fb3cd4f9ed559787725247867;hpb=1644eeece07040927ced5628e3922774576c64c9;p=xonotic%2Fnetradiant.git diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 62e4c61c..6b3d893b 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -58,6 +58,7 @@ #include "gtkutil/widget.h" #include "gtkutil/glwidget.h" #include "gtkutil/filechooser.h" +#include "gtkutil/cursor.h" #include "gtkmisc.h" #include "select.h" #include "csg.h" @@ -555,6 +556,19 @@ void XYWnd::ZoomInWithMouse( int pointx, int pointy ){ } } +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() ); @@ -809,20 +823,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 ); @@ -838,6 +842,7 @@ XYWnd::XYWnd() : m_window_observer( NewWindowObserver() ), m_XORRectangle( m_gl_widget ), m_chasemouse_handler( 0 ){ + m_bActive = false; m_buttonstate = 0; @@ -888,8 +893,11 @@ XYWnd::XYWnd() : Map_addValidCallback( g_map, DeferredDrawOnMapValidChangedCaller( m_deferredDraw ) ); - updateProjection(); - updateModelview(); + // This reconstruct=false argument is used to avoid a circular dependency + // between modelview and projection initialization and a valgrind complaint + updateProjection( false ); + updateModelview( false ); + m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight ); AddSceneChangeCallback( ReferenceCaller( *this ) ); AddCameraMovedCallback( ReferenceCaller( *this ) ); @@ -991,14 +999,11 @@ void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){ Vector3 mousePosition; XY_ToPoint( x, y, mousePosition ); if ( ClipMode() && GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ) != 0 ) { - GdkCursor *cursor; - cursor = gdk_cursor_new( GDK_CROSSHAIR ); - gdk_window_set_cursor( gtk_widget_get_window(m_gl_widget), cursor ); - gdk_cursor_unref( cursor ); + set_cursor ( m_gl_widget, GDK_CROSSHAIR ); } else { - gdk_window_set_cursor( gtk_widget_get_window(m_gl_widget), 0 ); + default_cursor( m_gl_widget ); } } @@ -1159,8 +1164,8 @@ void entitycreate_activated( ui::Widget item ){ g_pParentWnd->ActiveXY()->OnEntityCreate( entity_name ); } else { - GlobalRadiant().m_pfnMessageBox( MainFrame_getWindow(), "There's already a worldspawn in your map!" - "", + GlobalRadiant().m_pfnMessageBox( MainFrame_getWindow(), + "There's already a worldspawn in your map!", "Info", eMB_OK, eMB_ICONDEFAULT ); @@ -1275,13 +1280,17 @@ void XYWnd::Move_Begin(){ Move_End(); } m_move_started = true; - g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_moveDelta, this ); + /* NetRadiantCustom did this instead: + g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_moveDelta, this ); */ + g_xywnd_freezePointer.freeze_pointer( m_gl_widget, XYWnd_moveDelta, this ); m_move_focusOut = m_gl_widget.connect( "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this ); } void XYWnd::Move_End(){ m_move_started = false; - g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), false ); + /* NetRadiant did this instead: + g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), false ); */ + g_xywnd_freezePointer.unfreeze_pointer( m_gl_widget, false ); g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_move_focusOut ); } @@ -1320,7 +1329,9 @@ void XYWnd::Zoom_Begin(){ } m_zoom_started = true; g_dragZoom = 0; - g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_zoomDelta, this ); + /* NetRadiantCustom did this instead: + g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_zoomDelta, this ); */ + g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), XYWnd_zoomDelta, this ); m_zoom_focusOut = m_gl_widget.connect( "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this ); } @@ -1592,17 +1603,25 @@ void XYWnd::XY_DisableBackground( void ){ void WXY_BackgroundSelect( void ){ bool brushesSelected = Scene_countSelectedBrushes( GlobalSceneGraph() ) != 0; + + ui::Window main_window = MainFrame_getWindow(); + if ( !brushesSelected ) { - ui::alert( ui::root, "You have to select some brushes to get the bounding box for.\n", + ui::alert( main_window, "You have to select some brushes to get the bounding box for.\n", "No selection", ui::alert_type::OK, ui::alert_icon::Error ); return; } - const char *filename = MainFrame_getWindow().file_dialog( TRUE, "Background Image", NULL, NULL ); + const char *filename = main_window.file_dialog( TRUE, "Background Image", NULL, NULL ); + g_pParentWnd->ActiveXY()->XY_DisableBackground(); + if ( filename ) { g_pParentWnd->ActiveXY()->XY_LoadBackgroundImage( filename ); } + + // Draw the background image immediately (do not wait for user input). + g_pParentWnd->ActiveXY()->Redraw(); } /* @@ -2375,7 +2394,7 @@ RenderStateFlags m_globalstate; Shader* m_state_selected; }; -void XYWnd::updateProjection(){ +void XYWnd::updateProjection( bool reconstruct ){ m_projection[0] = 1.0f / static_cast( m_nWidth / 2 ); m_projection[5] = 1.0f / static_cast( m_nHeight / 2 ); m_projection[10] = 1.0f / ( g_MaxWorldCoord * m_fScale ); @@ -2398,11 +2417,13 @@ void XYWnd::updateProjection(){ m_projection[15] = 1.0f; + if (reconstruct) { m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight ); } +} // note: modelview matrix must have a uniform scale, otherwise strange things happen when rendering the rotation manipulator. -void XYWnd::updateModelview(){ +void XYWnd::updateModelview( bool reconstruct ){ int nDim1 = ( m_viewType == YZ ) ? 1 : 0; int nDim2 = ( m_viewType == XY ) ? 1 : 2; @@ -2458,7 +2479,9 @@ void XYWnd::updateModelview(){ m_modelview[3] = m_modelview[7] = m_modelview[11] = 0; m_modelview[15] = 1; + if (reconstruct) { m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight ); + } } /*