mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2024-11-10 07:11:54 +00:00
Improved mousewheel zoom-in
This commit is contained in:
parent
73b5b0dca7
commit
09c0da616c
8 changed files with 18 additions and 10 deletions
|
@ -168,7 +168,7 @@ void CamWnd::OnMouseMove( guint32 flags, int pointx, int pointy ){
|
||||||
update_xor_rectangle( m_XORRectangle );
|
update_xor_rectangle( m_XORRectangle );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CamWnd::OnMouseWheel( bool bUp ){
|
void CamWnd::OnMouseWheel( bool bUp, int pointx, int pointy ){
|
||||||
if ( bUp ) {
|
if ( bUp ) {
|
||||||
VectorMA( m_Camera.origin, g_PrefsDlg.m_nMoveSpeed, m_Camera.forward, m_Camera.origin );
|
VectorMA( m_Camera.origin, g_PrefsDlg.m_nMoveSpeed, m_Camera.forward, m_Camera.origin );
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ void OnLButtonUp( guint32 flags, int pointx, int pointy );
|
||||||
void OnRButtonUp( guint32 flags, int pointx, int pointy );
|
void OnRButtonUp( guint32 flags, int pointx, int pointy );
|
||||||
void OnMButtonUp( guint32 flags, int pointx, int pointy );
|
void OnMButtonUp( guint32 flags, int pointx, int pointy );
|
||||||
void OnMouseMove( 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 );
|
void OnSize( int cx, int cy );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -79,8 +79,8 @@ static void button_press( GtkWidget *widget, GdkEventButton *event, gpointer dat
|
||||||
case 2: flags |= MK_MBUTTON; break;
|
case 2: flags |= MK_MBUTTON; break;
|
||||||
case 3: flags |= MK_RBUTTON; break;
|
case 3: flags |= MK_RBUTTON; break;
|
||||||
#if !GTK_CHECK_VERSION( 1,3,0 )
|
#if !GTK_CHECK_VERSION( 1,3,0 )
|
||||||
case 4: wnd->OnMouseWheel( true ); break;
|
case 4: wnd->OnMouseWheel( true, (int)event->x, (int)event->y ); break;
|
||||||
case 5: wnd->OnMouseWheel( false ); break;
|
case 5: wnd->OnMouseWheel( false, (int)event->x, (int)event->y ); break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ static gint scroll_event( GtkWidget *widget,
|
||||||
GdkEventScroll *event,
|
GdkEventScroll *event,
|
||||||
gpointer data ){
|
gpointer data ){
|
||||||
GLWindow *wnd = (GLWindow*)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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
virtual void OnSize( int cx, int cy ) { }
|
virtual void OnSize( int cx, int cy ) { }
|
||||||
virtual void OnTimer() { }
|
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 ); }
|
void RedrawWindow() { gtk_widget_queue_draw( m_pWidget ); }
|
||||||
|
|
||||||
|
|
|
@ -1784,7 +1784,7 @@ void TexWnd::FocusEdit() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TexWnd::OnMouseWheel( bool bUp ){
|
void TexWnd::OnMouseWheel( bool bUp, int pointx, int pointy ){
|
||||||
if ( bUp ) {
|
if ( bUp ) {
|
||||||
if ( g_qeglobals.d_texturewin.originy < 0 ) {
|
if ( g_qeglobals.d_texturewin.originy < 0 ) {
|
||||||
g_qeglobals.d_texturewin.originy += g_PrefsDlg.m_nWheelInc;
|
g_qeglobals.d_texturewin.originy += g_PrefsDlg.m_nWheelInc;
|
||||||
|
|
|
@ -50,7 +50,7 @@ void OnMButtonUp( guint32 flags, int pointx, int pointy );
|
||||||
void OnMouseMove( guint32 flags, int pointx, int pointy );
|
void OnMouseMove( guint32 flags, int pointx, int pointy );
|
||||||
void OnSize( int cx, int cy );
|
void OnSize( int cx, int cy );
|
||||||
|
|
||||||
void OnMouseWheel( bool bUp );
|
void OnMouseWheel( bool bUp, int pointx, int pointy );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void OnVScroll();
|
void OnVScroll();
|
||||||
|
|
|
@ -1156,9 +1156,17 @@ void XYWnd::OnMouseMove( guint32 nFlags, int pointx, int pointy ){
|
||||||
update_xor_rectangle_xy( m_XORRectangle );
|
update_xor_rectangle_xy( m_XORRectangle );
|
||||||
}
|
}
|
||||||
|
|
||||||
void XYWnd::OnMouseWheel( bool bUp ){
|
void XYWnd::OnMouseWheel( bool bUp, int pointx, int pointy ){
|
||||||
if ( bUp ) {
|
if ( bUp ) {
|
||||||
|
// improved zoom-in
|
||||||
|
// frame coverges to part of window where the cursor currently resides
|
||||||
|
float old_scale = m_fScale;
|
||||||
g_pParentWnd->OnViewZoomin();
|
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{
|
else{
|
||||||
g_pParentWnd->OnViewZoomout();
|
g_pParentWnd->OnViewZoomout();
|
||||||
|
|
|
@ -191,7 +191,7 @@ void OnLButtonUp( guint32 flags, int pointx, int pointy );
|
||||||
void OnRButtonUp( guint32 flags, int pointx, int pointy );
|
void OnRButtonUp( guint32 flags, int pointx, int pointy );
|
||||||
void OnMButtonUp( guint32 flags, int pointx, int pointy );
|
void OnMButtonUp( guint32 flags, int pointx, int pointy );
|
||||||
void OnMouseMove( guint32 nFlags, 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 OnSize( int cx, int cy );
|
||||||
void OnTimer();
|
void OnTimer();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue