Merge pull request #261 from neumond/imzoom

Improved mousewheel zoom-in
This commit is contained in:
Timothee "TTimo" Besset 2015-03-08 10:23:43 -05:00
commit f555e3d13e
10 changed files with 34 additions and 11 deletions

View File

@ -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 );
}

View File

@ -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:

View File

@ -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

View File

@ -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 ); }

View File

@ -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.

View File

@ -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

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -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();