Improved mousewheel zoom-in

This commit is contained in:
neumond 2014-03-24 06:57:46 +04:00
parent 73b5b0dca7
commit 09c0da616c
8 changed files with 18 additions and 10 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

@ -1784,7 +1784,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,17 @@ 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 ) {
// 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->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();