diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 4e3b8c0b..8a952be0 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -168,7 +168,7 @@ void CamWnd::OnMouseMove( guint32 flags, int pointx, int pointy ){ update_xor_rectangle( m_XORRectangle ); } -void CamWnd::OnMouseWheel( bool bUp ){ +void CamWnd::OnMouseWheel( bool bUp, int pointx, int pointy ){ if ( bUp ) { VectorMA( m_Camera.origin, g_PrefsDlg.m_nMoveSpeed, m_Camera.forward, m_Camera.origin ); } diff --git a/radiant/camwindow.h b/radiant/camwindow.h index 0978e683..674df16f 100644 --- a/radiant/camwindow.h +++ b/radiant/camwindow.h @@ -148,7 +148,7 @@ void OnLButtonUp( guint32 flags, int pointx, int pointy ); void OnRButtonUp( guint32 flags, int pointx, int pointy ); void OnMButtonUp( guint32 flags, int pointx, int pointy ); void OnMouseMove( guint32 flags, int pointx, int pointy ); -void OnMouseWheel( bool bUp ); +void OnMouseWheel( bool bUp, int pointx, int pointy ); void OnSize( int cx, int cy ); protected: diff --git a/radiant/glwindow.cpp b/radiant/glwindow.cpp index 92ae7c8b..92679836 100644 --- a/radiant/glwindow.cpp +++ b/radiant/glwindow.cpp @@ -79,8 +79,8 @@ static void button_press( GtkWidget *widget, GdkEventButton *event, gpointer dat case 2: flags |= MK_MBUTTON; break; case 3: flags |= MK_RBUTTON; break; #if !GTK_CHECK_VERSION( 1,3,0 ) - case 4: wnd->OnMouseWheel( true ); break; - case 5: wnd->OnMouseWheel( false ); break; + case 4: wnd->OnMouseWheel( true, (int)event->x, (int)event->y ); break; + case 5: wnd->OnMouseWheel( false, (int)event->x, (int)event->y ); break; #endif } @@ -177,7 +177,7 @@ static gint scroll_event( GtkWidget *widget, GdkEventScroll *event, gpointer data ){ GLWindow *wnd = (GLWindow*)data; - wnd->OnMouseWheel( ( event->direction == GDK_SCROLL_UP ) ? true : false ); + wnd->OnMouseWheel( ( event->direction == GDK_SCROLL_UP ) ? true : false, (int)event->x, (int)event->y ); return TRUE; } #endif diff --git a/radiant/glwindow.h b/radiant/glwindow.h index d5f6c732..f0903534 100644 --- a/radiant/glwindow.h +++ b/radiant/glwindow.h @@ -58,7 +58,7 @@ public: virtual void OnSize( int cx, int cy ) { } virtual void OnTimer() { } - virtual void OnMouseWheel( bool bUp ) { } + virtual void OnMouseWheel( bool bUp, int pointx, int pointy ) { } void RedrawWindow() { gtk_widget_queue_draw( m_pWidget ); } diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index f77e319d..88ac2e13 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -102,6 +102,7 @@ #define ROTATION_KEY "Rotation" #define BUGGYICD_KEY "BuggyICD" #define CHASEMOUSE_KEY "ChaseMouse" +#define MOUSEWHEELZOOM_KEY "MousewheelZoom" #define ENTITYSHOW_KEY "EntityShow" #define TEXTURESCALE_KEY "TextureScale" #define TEXTURESCROLLBAR_KEY "TextureScrollbar" @@ -620,6 +621,7 @@ PrefsDlg::PrefsDlg (){ m_strUserPath = ""; m_nRotation = 0; m_bChaseMouse = FALSE; + m_bMousewheelZoom = FALSE; m_bTextureScrollbar = TRUE; m_bDisplayLists = TRUE; m_bAntialiasedPointsAndLines = FALSE; // Fishman - Add antialiazed points and lines support. 09/03/00 @@ -2271,6 +2273,12 @@ void PrefsDlg::BuildDialog(){ gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 ); AddDialogData( check, &m_bALTEdge, DLG_CHECK_BOOL ); + // Imroved mouse wheel zoom in + check = gtk_check_button_new_with_label( _( "Improved mousewheel zoom-in" ) ); + gtk_widget_show( check ); + gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 ); + AddDialogData( check, &m_bMousewheelZoom, DLG_CHECK_BOOL ); + // Mouse wheel increments // container hbox2 = gtk_hbox_new( FALSE, 5 ); @@ -2996,6 +3004,7 @@ void PrefsDlg::LoadPrefs(){ mLocalPrefs.GetPref( USERINI_KEY, &m_strUserPath, "" ); mLocalPrefs.GetPref( ROTATION_KEY, &m_nRotation, 45 ); mLocalPrefs.GetPref( CHASEMOUSE_KEY, &m_bChaseMouse, TRUE ); + mLocalPrefs.GetPref( MOUSEWHEELZOOM_KEY, &m_bMousewheelZoom, FALSE ); mLocalPrefs.GetPref( ENTITYSHOW_KEY, &m_nEntityShowState, ENTITY_SKINNED_BOXED ); // this will probably need to be 75 or 100 for Q1. diff --git a/radiant/preferences.h b/radiant/preferences.h index fe6e6f04..5f05e816 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -619,6 +619,7 @@ bool m_bSnap; Str m_strUserPath; int m_nRotation; bool m_bChaseMouse; +bool m_bMousewheelZoom; bool m_bTextureScrollbar; bool m_bDisplayLists; bool m_bAntialiasedPointsAndLines; // Fishman - Add antialiazed points and lines support. 09/03/00 diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 2c20028f..a542e4dc 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -1794,7 +1794,7 @@ void TexWnd::FocusEdit() { } } -void TexWnd::OnMouseWheel( bool bUp ){ +void TexWnd::OnMouseWheel( bool bUp, int pointx, int pointy ){ if ( bUp ) { if ( g_qeglobals.d_texturewin.originy < 0 ) { g_qeglobals.d_texturewin.originy += g_PrefsDlg.m_nWheelInc; diff --git a/radiant/texwindow.h b/radiant/texwindow.h index da794345..ae01183a 100644 --- a/radiant/texwindow.h +++ b/radiant/texwindow.h @@ -50,7 +50,7 @@ void OnMButtonUp( guint32 flags, int pointx, int pointy ); void OnMouseMove( guint32 flags, int pointx, int pointy ); void OnSize( int cx, int cy ); -void OnMouseWheel( bool bUp ); +void OnMouseWheel( bool bUp, int pointx, int pointy ); public: void OnVScroll(); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index e4f0b27e..c8734cc0 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -1156,9 +1156,22 @@ void XYWnd::OnMouseMove( guint32 nFlags, int pointx, int pointy ){ update_xor_rectangle_xy( m_XORRectangle ); } -void XYWnd::OnMouseWheel( bool bUp ){ +void XYWnd::OnMouseWheel( bool bUp, int pointx, int pointy ){ if ( bUp ) { - g_pParentWnd->OnViewZoomin(); + if ( g_PrefsDlg.m_bMousewheelZoom == TRUE ) { + // improved zoom-in + // frame coverges to part of window where the cursor currently resides + float old_scale = m_fScale; + g_pParentWnd->OnViewZoomin(); + float scale_diff = 1.0 / old_scale - 1.0 / m_fScale; + int nDim1 = ( m_nViewType == YZ ) ? 1 : 0; + int nDim2 = ( m_nViewType == XY ) ? 1 : 2; + m_vOrigin[nDim1] += scale_diff * (pointx - 0.5 * m_nWidth); + m_vOrigin[nDim2] -= scale_diff * (pointy - 0.5 * m_nHeight); + } + else{ + g_pParentWnd->OnViewZoomin(); + } } else{ g_pParentWnd->OnViewZoomout(); diff --git a/radiant/xywindow.h b/radiant/xywindow.h index 31bfbeda..5f903d57 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -191,7 +191,7 @@ void OnLButtonUp( guint32 flags, int pointx, int pointy ); void OnRButtonUp( guint32 flags, int pointx, int pointy ); void OnMButtonUp( guint32 flags, int pointx, int pointy ); void OnMouseMove( guint32 nFlags, int pointx, int pointy ); -void OnMouseWheel( bool bUp ); +void OnMouseWheel( bool bUp, int pointx, int pointy ); void OnSize( int cx, int cy ); void OnTimer();