]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/xywindow.cpp
Radiant:
[xonotic/netradiant.git] / radiant / xywindow.cpp
index b094b7744d5f034f57216469357dc65d59068734..bab35a07b354c088e48fa37fa87a27eecd095981 100644 (file)
@@ -110,6 +110,7 @@ void Draw( const char *label, float scale );
 VIEWTYPE g_clip_viewtype;
 bool g_bSwitch = true;
 bool g_clip_useCaulk = false;
+bool g_quick_clipper = false;
 ClipPoint g_Clip1;
 ClipPoint g_Clip2;
 ClipPoint g_Clip3;
@@ -258,6 +259,10 @@ void Clip(){
                g_Clip3.Reset();
                Clip_Update();
                ClipperChangeNotify();
+               if( g_quick_clipper ){
+                       g_quick_clipper = false;
+                       ClipperMode();
+               }
        }
 }
 
@@ -272,6 +277,10 @@ void SplitClip(){
                g_Clip3.Reset();
                Clip_Update();
                ClipperChangeNotify();
+               if( g_quick_clipper ){
+                       g_quick_clipper = false;
+                       ClipperMode();
+               }
        }
 }
 
@@ -342,7 +351,7 @@ struct xywindow_globals_private_t
        bool show_blocks;
        int blockSize;
 
-       bool m_bCamXYUpdate;
+//     bool m_bCamXYUpdate;
        bool m_bChaseMouse;
        bool m_bSizePaint;
 
@@ -350,16 +359,16 @@ struct xywindow_globals_private_t
                d_showgrid( true ),
 
                show_names( false ),
-               show_coordinates( true ),
+               show_coordinates( false ),
                show_angles( true ),
-               show_outline( false ),
+               show_outline( true ),
                show_axis( true ),
 
                d_show_work( false ),
 
                show_blocks( false ),
 
-               m_bCamXYUpdate( true ),
+//             m_bCamXYUpdate( true ),
                m_bChaseMouse( true ),
                m_bSizePaint( true ){
        }
@@ -493,17 +502,17 @@ void XYWnd::SetScale( float f ){
        XYWnd_Update( *this );
 }
 
-void XYWnd_ZoomIn( XYWnd* xy ){
+void XYWnd::ZoomIn(){
        float max_scale = 64;
-       float scale = xy->Scale() * 5.0f / 4.0f;
+       float scale = Scale() * 5.0f / 4.0f;
        if ( scale > max_scale ) {
-               if ( xy->Scale() != max_scale ) {
-                       xy->SetScale( max_scale );
+               if ( Scale() != max_scale ) {
+                       SetScale( max_scale );
                }
        }
        else
        {
-               xy->SetScale( scale );
+               SetScale( scale );
        }
 }
 
@@ -511,17 +520,31 @@ void XYWnd_ZoomIn( XYWnd* xy ){
 // NOTE: the zoom out factor is 4/5, we could think about customizing it
 //  we don't go below a zoom factor corresponding to 10% of the max world size
 //  (this has to be computed against the window size)
-void XYWnd_ZoomOut( XYWnd* xy ){
-       float min_scale = MIN( xy->Width(),xy->Height() ) / ( 1.1f * ( g_MaxWorldCoord - g_MinWorldCoord ) );
-       float scale = xy->Scale() * 4.0f / 5.0f;
+void XYWnd::ZoomOut(){
+       float min_scale = MIN( Width(), Height() ) / ( 1.1f * ( g_MaxWorldCoord - g_MinWorldCoord ) );
+       float scale = Scale() * 4.0f / 5.0f;
        if ( scale < min_scale ) {
-               if ( xy->Scale() != min_scale ) {
-                       xy->SetScale( min_scale );
+               if ( Scale() != min_scale ) {
+                       SetScale( min_scale );
                }
        }
        else
        {
-               xy->SetScale( scale );
+               SetScale( scale );
+       }
+}
+
+void XYWnd::ZoomInWithMouse( int pointx, int pointy ){
+       float old_scale = Scale();
+       ZoomIn();
+       if ( g_xywindow_globals.m_bImprovedWheelZoom ) {
+               float scale_diff = 1.0 / old_scale - 1.0 / Scale();
+               int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
+               int nDim2 = ( m_viewType == XY ) ? 1 : 2;
+               Vector3 origin = GetOrigin();
+               origin[nDim1] += scale_diff * (pointx - 0.5 * Width());
+               origin[nDim2] -= scale_diff * (pointy - 0.5 * Height());
+               SetOrigin( origin );
        }
 }
 
@@ -706,13 +729,24 @@ Shader* XYWnd::m_state_selected = 0;
 
 void xy_update_xor_rectangle( XYWnd& self, rect_t area ){
        if ( GTK_WIDGET_VISIBLE( self.GetWidget() ) ) {
-               self.m_XORRectangle.set( rectangle_from_area( area.min, area.max, self.Width(), self.Height() ) );
+               rectangle_t rect = rectangle_from_area( area.min, area.max, self.Width(), self.Height() );
+//             int nDim1 = ( self.GetViewType() == YZ ) ? 1 : 0;
+//             int nDim2 = ( self.GetViewType() == XY ) ? 1 : 2;
+//             rect.x /= self.Scale();
+//             rect.y /= self.Scale();
+//             rect.w /= self.Scale();
+//             rect.h /= self.Scale();
+//             rect.x += self.GetOrigin()[nDim1];
+//             rect.y += self.GetOrigin()[nDim2];
+               self.m_XORRectangle.set( rect );
        }
 }
 
 gboolean xywnd_button_press( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){
        if ( event->type == GDK_BUTTON_PRESS ) {
-               g_pParentWnd->SetActiveXY( xywnd );
+               if( !xywnd->Active() ){
+                       g_pParentWnd->SetActiveXY( xywnd );
+               }
 
                xywnd->ButtonState_onMouseDown( buttons_for_event_button( event ) );
 
@@ -733,7 +767,9 @@ gboolean xywnd_button_release( GtkWidget* widget, GdkEventButton* event, XYWnd*
 gboolean xywnd_focus_in( GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd ){
        if ( event->type == GDK_FOCUS_CHANGE ) {
                if ( event->in ) {
-                       g_pParentWnd->SetActiveXY( xywnd );
+                       if( !xywnd->Active() ){
+                               g_pParentWnd->SetActiveXY( xywnd );
+                       }
                }
        }
        return FALSE;
@@ -747,11 +783,14 @@ void xywnd_motion( gdouble x, gdouble y, guint state, void* data ){
 }
 
 gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xywnd ){
+       if( !xywnd->Active() ){
+               g_pParentWnd->SetActiveXY( xywnd );
+       }
        if ( event->direction == GDK_SCROLL_UP ) {
-               XYWnd_ZoomIn( xywnd );
+               xywnd->ZoomInWithMouse( (int)event->x, (int)event->y );
        }
        else if ( event->direction == GDK_SCROLL_DOWN ) {
-               XYWnd_ZoomOut( xywnd );
+               xywnd->ZoomOut();
        }
        return FALSE;
 }
@@ -780,9 +819,10 @@ gboolean xywnd_expose( GtkWidget* widget, GdkEventExpose* event, XYWnd* xywnd ){
 
 
 void XYWnd_CameraMoved( XYWnd& xywnd ){
-       if ( g_xywindow_globals_private.m_bCamXYUpdate ) {
-               XYWnd_Update( xywnd );
-       }
+//     if ( g_xywindow_globals_private.m_bCamXYUpdate ) {
+               //XYWnd_Update( xywnd );
+               xywnd.UpdateCameraIcon();
+//     }
 }
 
 XYWnd::XYWnd() :
@@ -836,7 +876,7 @@ XYWnd::XYWnd() :
 
        g_signal_connect( G_OBJECT( m_gl_widget ), "button_press_event", G_CALLBACK( xywnd_button_press ), this );
        g_signal_connect( G_OBJECT( m_gl_widget ), "button_release_event", G_CALLBACK( xywnd_button_release ), this );
-       g_signal_connect( G_OBJECT( m_gl_widget ), "focus_in_event", G_CALLBACK( xywnd_focus_in ), this );
+       g_signal_connect( G_OBJECT( m_gl_widget ), "focus_in_event", G_CALLBACK( xywnd_focus_in ), this );      //works only in floating views layout
        g_signal_connect( G_OBJECT( m_gl_widget ), "motion_notify_event", G_CALLBACK( DeferredMotion::gtk_motion ), &m_deferred_motion );
 
        g_signal_connect( G_OBJECT( m_gl_widget ), "scroll_event", G_CALLBACK( xywnd_wheel_scroll ), this );
@@ -900,6 +940,10 @@ unsigned int Clipper_buttons(){
        return RAD_LBUTTON;
 }
 
+unsigned int Clipper_quick_buttons(){
+       return RAD_LBUTTON | RAD_CONTROL;
+}
+
 void XYWnd::DropClipPoint( int pointx, int pointy ){
        Vector3 point;
 
@@ -953,8 +997,21 @@ void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){
        }
 }
 
+void XYWnd::SetCustomPivotOrigin( int pointx, int pointy ){
+       Vector3 point;
+       XY_ToPoint( pointx, pointy, point );
+       VIEWTYPE viewtype = static_cast<VIEWTYPE>( GetViewType() );
+       const int nDim = ( viewtype == YZ ) ? 0 : ( ( viewtype == XZ ) ? 1 : 2 );
+       //vector3_snap( point, GetSnapGridSize() );
+       point[nDim] = 999999;
+
+       GlobalSelectionSystem().setCustomPivotOrigin( point );
+       SceneChangeNotify();
+}
+
 unsigned int MoveCamera_buttons(){
-       return RAD_CONTROL | ( g_glwindow_globals.m_nMouseType == ETwoButton ? RAD_RBUTTON : RAD_MBUTTON );
+//     return RAD_CONTROL | ( g_glwindow_globals.m_nMouseType == ETwoButton ? RAD_RBUTTON : RAD_MBUTTON );
+       return RAD_CONTROL | RAD_MBUTTON;
 }
 
 void XYWnd_PositionCamera( XYWnd* xywnd, int x, int y, CamWnd& camwnd ){
@@ -965,16 +1022,17 @@ void XYWnd_PositionCamera( XYWnd* xywnd, int x, int y, CamWnd& camwnd ){
 }
 
 unsigned int OrientCamera_buttons(){
-       if ( g_glwindow_globals.m_nMouseType == ETwoButton ) {
-               return RAD_RBUTTON | RAD_SHIFT | RAD_CONTROL;
-       }
+//     if ( g_glwindow_globals.m_nMouseType == ETwoButton ) {
+//             return RAD_RBUTTON | RAD_SHIFT | RAD_CONTROL;
+//     }
        return RAD_MBUTTON;
 }
 
 void XYWnd_OrientCamera( XYWnd* xywnd, int x, int y, CamWnd& camwnd ){
+       //globalOutputStream() << Camera_getAngles( camwnd ) << "  b4\n";
        Vector3 point = g_vector3_identity;
        xywnd->XY_ToPoint( x, y, point );
-       xywnd->XY_SnapToGrid( point );
+       //xywnd->XY_SnapToGrid( point );
        vector3_subtract( point, Camera_getOrigin( camwnd ) );
 
        int n1 = ( xywnd->GetViewType() == XY ) ? 1 : 2;
@@ -983,8 +1041,38 @@ void XYWnd_OrientCamera( XYWnd* xywnd, int x, int y, CamWnd& camwnd ){
        if ( point[n1] || point[n2] ) {
                Vector3 angles( Camera_getAngles( camwnd ) );
                angles[nAngle] = static_cast<float>( radians_to_degrees( atan2( point[n1], point[n2] ) ) );
+               if( angles[CAMERA_YAW] < 0 )
+                       angles[CAMERA_YAW] = angles[CAMERA_YAW] + 360;
+               if ( nAngle == CAMERA_PITCH ){
+                       if( fabs( angles[CAMERA_PITCH] ) > 90 ){
+                               angles[CAMERA_PITCH] = ( angles[CAMERA_PITCH] > 0 ) ? ( -angles[CAMERA_PITCH] + 180 ) : ( -angles[CAMERA_PITCH] - 180 );
+                               if( xywnd->GetViewType() == YZ ){
+                                       if( angles[CAMERA_YAW] < 180 ){
+                                               angles[CAMERA_YAW] = 360 - angles[CAMERA_YAW];
+                                       }
+                               }
+                               else if( angles[CAMERA_YAW] < 90 || angles[CAMERA_YAW] > 270 ){
+                                       angles[CAMERA_YAW] = 180 - angles[CAMERA_YAW];
+                               }
+                       }
+                       else{
+                               if( xywnd->GetViewType() == YZ ){
+                                       if( angles[CAMERA_YAW] > 180 ){
+                                               angles[CAMERA_YAW] = 360 - angles[CAMERA_YAW];
+                                       }
+                               }
+                               else if( angles[CAMERA_YAW] > 90 && angles[CAMERA_YAW] < 270 ){
+                                       angles[CAMERA_YAW] = 180 - angles[CAMERA_YAW];
+                               }
+                       }
+               }
                Camera_setAngles( camwnd, angles );
        }
+       //globalOutputStream() << Camera_getAngles( camwnd ) << "\n";
+}
+
+unsigned int SetCustomPivotOrigin_buttons(){
+       return RAD_MBUTTON | RAD_SHIFT;
 }
 
 /*
@@ -1147,9 +1235,9 @@ void addItem( const char* name, const char* next ){
 };
 
 void XYWnd::OnContextMenu(){
-       if ( g_xywindow_globals.m_bRightClick == false ) {
-               return;
-       }
+//     if ( g_xywindow_globals.m_bRightClick == false ) {
+//             return;
+//     }
 
        if ( m_mnuDrop == 0 ) { // first time, load it up
                GtkMenu* menu = m_mnuDrop = GTK_MENU( gtk_menu_new() );
@@ -1182,18 +1270,18 @@ void XYWnd::Move_Begin(){
                Move_End();
        }
        m_move_started = true;
-       g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), XYWnd_moveDelta, this );
+       g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_moveDelta, this );
        m_move_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this );
 }
 
 void XYWnd::Move_End(){
        m_move_started = false;
-       g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow() );
+       g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), false );
        g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_move_focusOut );
 }
 
 unsigned int Zoom_buttons(){
-       return RAD_RBUTTON | RAD_SHIFT;
+       return RAD_RBUTTON | RAD_ALT;
 }
 
 int g_dragZoom = 0;
@@ -1201,16 +1289,15 @@ int g_dragZoom = 0;
 void XYWnd_zoomDelta( int x, int y, unsigned int state, void* data ){
        if ( y != 0 ) {
                g_dragZoom += y;
-
                while ( abs( g_dragZoom ) > 8 )
                {
                        if ( g_dragZoom > 0 ) {
-                               XYWnd_ZoomOut( reinterpret_cast<XYWnd*>( data ) );
+                               reinterpret_cast<XYWnd*>( data )->ZoomOut();
                                g_dragZoom -= 8;
                        }
                        else
                        {
-                               XYWnd_ZoomIn( reinterpret_cast<XYWnd*>( data ) );
+                               reinterpret_cast<XYWnd*>( data )->ZoomIn();
                                g_dragZoom += 8;
                        }
                }
@@ -1228,13 +1315,13 @@ void XYWnd::Zoom_Begin(){
        }
        m_zoom_started = true;
        g_dragZoom = 0;
-       g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), XYWnd_zoomDelta, this );
+       g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_zoomDelta, this );
        m_zoom_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this );
 }
 
 void XYWnd::Zoom_End(){
        m_zoom_started = false;
-       g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow() );
+       g_xywnd_freezePointer.unfreeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), false );
        g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_zoom_focusOut );
 }
 
@@ -1276,7 +1363,12 @@ void XYWnd::XY_MouseDown( int x, int y, unsigned int buttons ){
        else if ( buttons == Zoom_buttons() ) {
                Zoom_Begin();
        }
-       else if ( ClipMode() && buttons == Clipper_buttons() ) {
+       else if ( ClipMode() && ( buttons == Clipper_buttons() || buttons == Clipper_quick_buttons() ) ) {
+               Clipper_OnLButtonDown( x, y );
+       }
+       else if ( !ClipMode() && buttons == Clipper_quick_buttons() ) {
+               ClipperMode();
+               g_quick_clipper = true;
                Clipper_OnLButtonDown( x, y );
        }
        else if ( buttons == NewBrushDrag_buttons() && GlobalSelectionSystem().countSelected() == 0 ) {
@@ -1290,6 +1382,9 @@ void XYWnd::XY_MouseDown( int x, int y, unsigned int buttons ){
        else if ( buttons == OrientCamera_buttons() ) {
                XYWnd_OrientCamera( this, x, y, *g_pParentWnd->GetCamWnd() );
        }
+       else if ( buttons == SetCustomPivotOrigin_buttons() ) {
+               SetCustomPivotOrigin( x, y );
+       }
        else
        {
                m_window_observer->onMouseDown( WindowVector_forInteger( x, y ), button_for_flags( buttons ), modifiers_for_flags( buttons ) );
@@ -1304,12 +1399,16 @@ void XYWnd::XY_MouseUp( int x, int y, unsigned int buttons ){
        else if ( m_zoom_started ) {
                Zoom_End();
        }
-       else if ( ClipMode() && buttons == Clipper_buttons() ) {
+       else if ( ClipMode() && ( buttons == Clipper_buttons() || buttons == Clipper_quick_buttons() ) ) {
                Clipper_OnLButtonUp( x, y );
        }
        else if ( m_bNewBrushDrag ) {
                m_bNewBrushDrag = false;
                NewBrushDrag_End( x, y );
+               if ( m_NewBrushDrag == 0 ) {
+                       //L button w/o created brush = tunnel selection
+                       m_window_observer->onMouseUp( WindowVector_forInteger( x, y ), button_for_flags( buttons ), modifiers_for_flags( buttons ) );
+               }
        }
        else
        {
@@ -1334,15 +1433,19 @@ void XYWnd::XY_MouseMoved( int x, int y, unsigned int buttons ){
        }
 
        // control mbutton = move camera
-       else if ( getButtonState() == MoveCamera_buttons() ) {
+       else if ( buttons == MoveCamera_buttons() ) {
                XYWnd_PositionCamera( this, x, y, *g_pParentWnd->GetCamWnd() );
        }
 
        // mbutton = angle camera
-       else if ( getButtonState() == OrientCamera_buttons() ) {
+       else if ( buttons == OrientCamera_buttons() ) {
                XYWnd_OrientCamera( this, x, y, *g_pParentWnd->GetCamWnd() );
        }
 
+       else if ( buttons == SetCustomPivotOrigin_buttons() ) {
+               SetCustomPivotOrigin( x, y );
+       }
+
        else
        {
                m_window_observer->onMouseMotion( WindowVector_forInteger( x, y ), modifiers_for_flags( buttons ) );
@@ -1523,8 +1626,14 @@ void XYWnd::XY_DrawAxis( void ){
                const int w = ( m_nWidth / 2 / m_fScale );
                const int h = ( m_nHeight / 2 / m_fScale );
 
-               const Vector3& colourX = ( m_viewType == YZ ) ? g_xywindow_globals.AxisColorY : g_xywindow_globals.AxisColorX;
-               const Vector3& colourY = ( m_viewType == XY ) ? g_xywindow_globals.AxisColorY : g_xywindow_globals.AxisColorZ;
+               Vector3 colourX = ( m_viewType == YZ ) ? g_xywindow_globals.AxisColorY : g_xywindow_globals.AxisColorX;
+               Vector3 colourY = ( m_viewType == XY ) ? g_xywindow_globals.AxisColorY : g_xywindow_globals.AxisColorZ;
+               if( !Active() ){
+                       float grayX = vector3_dot( colourX, Vector3( 0.2989, 0.5870, 0.1140 ) );
+                       float grayY = vector3_dot( colourY, Vector3( 0.2989, 0.5870, 0.1140 ) );
+                       colourX[0] = colourX[1] = colourX[2] = grayX;
+                       colourY[0] = colourY[1] = colourY[2] = grayY;
+               }
 
                // draw two lines with corresponding axis colors to highlight current view
                // horizontal line: nDim1 color
@@ -1556,6 +1665,105 @@ void XYWnd::XY_DrawAxis( void ){
        }
 }
 
+void XYWnd::RenderActive( void ){
+       if ( glwidget_make_current( m_gl_widget ) != FALSE ) {
+               if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) {
+                       GlobalOpenGL_debugAssertNoErrors();
+                       glDrawBuffer( GL_FRONT );
+
+                       if ( g_xywindow_globals_private.show_outline ) {
+                               glMatrixMode( GL_PROJECTION );
+                               glLoadIdentity();
+                               glOrtho( 0, m_nWidth, 0, m_nHeight, 0, 1 );
+
+                               glMatrixMode( GL_MODELVIEW );
+                               glLoadIdentity();
+
+                               if( !Active() ){ //sorta erase
+                                       glColor3fv( vector3_to_array( g_xywindow_globals.color_gridmajor ) );
+                               }
+                               // four view mode doesn't colorize
+                               else if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) {
+                                       glColor3fv( vector3_to_array( g_xywindow_globals.color_viewname ) );
+                               }
+                               else
+                               {
+                                       switch ( m_viewType )
+                                       {
+                                       case YZ:
+                                               glColor3fv( vector3_to_array( g_xywindow_globals.AxisColorX ) );
+                                               break;
+                                       case XZ:
+                                               glColor3fv( vector3_to_array( g_xywindow_globals.AxisColorY ) );
+                                               break;
+                                       case XY:
+                                               glColor3fv( vector3_to_array( g_xywindow_globals.AxisColorZ ) );
+                                               break;
+                                       }
+                               }
+                               glBegin( GL_LINE_LOOP );
+                               glVertex2f( 0.5, 0.5 );
+                               glVertex2f( m_nWidth - 0.5, 1 );
+                               glVertex2f( m_nWidth - 0.5, m_nHeight - 0.5 );
+                               glVertex2f( 0.5, m_nHeight - 0.5 );
+                               glEnd();
+                       }
+                       // we do this part (the old way) only if show_axis is disabled
+                       if ( !g_xywindow_globals_private.show_axis ) {
+                               glMatrixMode( GL_PROJECTION );
+                               glLoadIdentity();
+                               glOrtho( 0, m_nWidth, 0, m_nHeight, 0, 1 );
+
+                               glMatrixMode( GL_MODELVIEW );
+                               glLoadIdentity();
+
+                               if ( Active() ) {
+                                       glColor3fv( vector3_to_array( g_xywindow_globals.color_viewname ) );
+                               }
+                               else{
+                                       glColor4fv( vector4_to_array( Vector4( g_xywindow_globals.color_gridtext, 1.0f ) ) );
+                               }
+
+                               glDisable( GL_BLEND );
+                               glRasterPos2f( 35, m_nHeight - 20 );
+
+                               GlobalOpenGL().drawString( ViewType_getTitle( m_viewType ) );
+                       }
+                       else{
+                               // clear
+                               glViewport( 0, 0, m_nWidth, m_nHeight );
+                               // set up viewpoint
+                               glMatrixMode( GL_PROJECTION );
+                               glLoadMatrixf( reinterpret_cast<const float*>( &m_projection ) );
+
+                               glMatrixMode( GL_MODELVIEW );
+                               glLoadIdentity();
+                               glScalef( m_fScale, m_fScale, 1 );
+                               int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
+                               int nDim2 = ( m_viewType == XY ) ? 1 : 2;
+                               glTranslatef( -m_vOrigin[nDim1], -m_vOrigin[nDim2], 0 );
+
+                               glDisable( GL_LINE_STIPPLE );
+                               glDisableClientState( GL_TEXTURE_COORD_ARRAY );
+                               glDisableClientState( GL_NORMAL_ARRAY );
+                               glDisableClientState( GL_COLOR_ARRAY );
+                               glDisable( GL_TEXTURE_2D );
+                               glDisable( GL_LIGHTING );
+                               glDisable( GL_COLOR_MATERIAL );
+                               glDisable( GL_DEPTH_TEST );
+                               glDisable( GL_TEXTURE_1D );
+                               glDisable( GL_BLEND );
+
+                               XYWnd::XY_DrawAxis();
+                       }
+
+                       glDrawBuffer( GL_BACK );
+                       GlobalOpenGL_debugAssertNoErrors();
+                       glwidget_make_current( m_gl_widget );
+               }
+       }
+}
+
 void XYWnd::XY_DrawBackground( void ){
        glPushAttrib( GL_ALL_ATTRIB_BITS );
 
@@ -1723,16 +1931,19 @@ void XYWnd::XY_DrawGrid( void ) {
                        GlobalOpenGL().drawString( text );
                }
 
+       }
+       // we do this part (the old way) only if show_axis is disabled
+       if ( !g_xywindow_globals_private.show_axis ) {
                if ( Active() ) {
                        glColor3fv( vector3_to_array( g_xywindow_globals.color_viewname ) );
                }
+               else{
+                       glColor4fv( vector4_to_array( Vector4( g_xywindow_globals.color_gridtext, 1.0f ) ) );
+               }
 
-               // we do this part (the old way) only if show_axis is disabled
-               if ( !g_xywindow_globals_private.show_axis ) {
-                       glRasterPos2f( m_vOrigin[nDim1] - w + 35 / m_fScale, m_vOrigin[nDim2] + h - 20 / m_fScale );
+               glRasterPos2f( m_vOrigin[nDim1] - w + 35 / m_fScale, m_vOrigin[nDim2] + h - 20 / m_fScale );
 
-                       GlobalOpenGL().drawString( ViewType_getTitle( m_viewType ) );
-               }
+               GlobalOpenGL().drawString( ViewType_getTitle( m_viewType ) );
        }
 
        XYWnd::XY_DrawAxis();
@@ -1852,47 +2063,108 @@ void XYWnd::XY_DrawBlockGrid(){
 }
 
 void XYWnd::DrawCameraIcon( const Vector3& origin, const Vector3& angles ){
-       float x, y, fov, box;
-       double a;
-
-       fov = 48 / m_fScale;
-       box = 16 / m_fScale;
+       Cam.fov = 48 / m_fScale;
+       Cam.box = 16 / m_fScale;
+//     globalOutputStream() << "pitch " << angles[CAMERA_PITCH] << "   yaw " << angles[CAMERA_YAW] << "\n";
 
        if ( m_viewType == XY ) {
-               x = origin[0];
-               y = origin[1];
-               a = degrees_to_radians( angles[CAMERA_YAW] );
+               Cam.x = origin[0];
+               Cam.y = origin[1];
+               Cam.a = degrees_to_radians( angles[CAMERA_YAW] );
        }
        else if ( m_viewType == YZ ) {
-               x = origin[1];
-               y = origin[2];
-               a = degrees_to_radians( angles[CAMERA_PITCH] );
+               Cam.x = origin[1];
+               Cam.y = origin[2];
+               Cam.a = degrees_to_radians( ( angles[CAMERA_YAW] > 180 ) ? ( 180.0f - angles[CAMERA_PITCH] ) : angles[CAMERA_PITCH] );
        }
        else
        {
-               x = origin[0];
-               y = origin[2];
-               a = degrees_to_radians( angles[CAMERA_PITCH] );
+               Cam.x = origin[0];
+               Cam.y = origin[2];
+               Cam.a = degrees_to_radians( ( angles[CAMERA_YAW] < 270 && angles[CAMERA_YAW] > 90 ) ? ( 180.0f - angles[CAMERA_PITCH] ) : angles[CAMERA_PITCH] );
        }
 
-       glColor3f( 0.0, 0.0, 1.0 );
+       //glColor3f( 0.0, 0.0, 1.0 );
+       glColor3f( 1.0, 1.0, 1.0 );
        glBegin( GL_LINE_STRIP );
-       glVertex3f( x - box,y,0 );
-       glVertex3f( x,y + ( box / 2 ),0 );
-       glVertex3f( x + box,y,0 );
-       glVertex3f( x,y - ( box / 2 ),0 );
-       glVertex3f( x - box,y,0 );
-       glVertex3f( x + box,y,0 );
+       glVertex3f( Cam.x - Cam.box,Cam.y,0 );
+       glVertex3f( Cam.x,Cam.y + ( Cam.box / 2 ),0 );
+       glVertex3f( Cam.x + Cam.box,Cam.y,0 );
+       glVertex3f( Cam.x,Cam.y - ( Cam.box / 2 ),0 );
+       glVertex3f( Cam.x - Cam.box,Cam.y,0 );
+       glVertex3f( Cam.x + Cam.box,Cam.y,0 );
        glEnd();
 
        glBegin( GL_LINE_STRIP );
-       glVertex3f( x + static_cast<float>( fov * cos( a + c_pi / 4 ) ), y + static_cast<float>( fov * sin( a + c_pi / 4 ) ), 0 );
-       glVertex3f( x, y, 0 );
-       glVertex3f( x + static_cast<float>( fov * cos( a - c_pi / 4 ) ), y + static_cast<float>( fov * sin( a - c_pi / 4 ) ), 0 );
+       glVertex3f( Cam.x + static_cast<float>( Cam.fov * cos( Cam.a + c_pi / 4 ) ), Cam.y + static_cast<float>( Cam.fov * sin( Cam.a + c_pi / 4 ) ), 0 );
+       glVertex3f( Cam.x, Cam.y, 0 );
+       glVertex3f( Cam.x + static_cast<float>( Cam.fov * cos( Cam.a - c_pi / 4 ) ), Cam.y + static_cast<float>( Cam.fov * sin( Cam.a - c_pi / 4 ) ), 0 );
        glEnd();
 
 }
 
+void XYWnd::UpdateCameraIcon( void ){
+       if ( glwidget_make_current( m_gl_widget ) != FALSE ) {
+               if ( Map_Valid( g_map ) && ScreenUpdates_Enabled() ) {
+                       GlobalOpenGL_debugAssertNoErrors();
+                       glDrawBuffer( GL_FRONT );
+                       {
+                               // clear
+                               glViewport( 0, 0, m_nWidth, m_nHeight );
+                               // set up viewpoint
+                               glMatrixMode( GL_PROJECTION );
+                               glLoadMatrixf( reinterpret_cast<const float*>( &m_projection ) );
+
+                               glMatrixMode( GL_MODELVIEW );
+                               glLoadIdentity();
+                               glScalef( m_fScale, m_fScale, 1 );
+                               int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
+                               int nDim2 = ( m_viewType == XY ) ? 1 : 2;
+                               glTranslatef( -m_vOrigin[nDim1], -m_vOrigin[nDim2], 0 );
+
+                               glDisable( GL_LINE_STIPPLE );
+                               glDisableClientState( GL_TEXTURE_COORD_ARRAY );
+                               glDisableClientState( GL_NORMAL_ARRAY );
+                               glDisableClientState( GL_COLOR_ARRAY );
+                               glDisable( GL_TEXTURE_2D );
+                               glDisable( GL_LIGHTING );
+                               glDisable( GL_COLOR_MATERIAL );
+                               glDisable( GL_DEPTH_TEST );
+                               glDisable( GL_TEXTURE_1D );
+
+                               glEnable( GL_BLEND );
+                               glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
+
+                               //glColor3f( 0.0, 0.0, 1.0 );
+                               glColor3f( 1.0, 1.0, 1.0 );
+                               glBegin( GL_LINE_STRIP );
+                               glVertex3f( Cam.x - Cam.box,Cam.y,0 );
+                               glVertex3f( Cam.x,Cam.y + ( Cam.box / 2 ),0 );
+                               glVertex3f( Cam.x + Cam.box,Cam.y,0 );
+                               glVertex3f( Cam.x,Cam.y - ( Cam.box / 2 ),0 );
+                               glVertex3f( Cam.x - Cam.box,Cam.y,0 );
+                               glVertex3f( Cam.x + Cam.box,Cam.y,0 );
+                               glEnd();
+
+                               glBegin( GL_LINE_STRIP );
+                               glVertex3f( Cam.x + static_cast<float>( Cam.fov * cos( Cam.a + c_pi / 4 ) ), Cam.y + static_cast<float>( Cam.fov * sin( Cam.a + c_pi / 4 ) ), 0 );
+                               glVertex3f( Cam.x, Cam.y, 0 );
+                               glVertex3f( Cam.x + static_cast<float>( Cam.fov * cos( Cam.a - c_pi / 4 ) ), Cam.y + static_cast<float>( Cam.fov * sin( Cam.a - c_pi / 4 ) ), 0 );
+                               glEnd();
+
+                               XYWnd::DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) );
+
+                               glDisable( GL_BLEND );
+                               glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+                       }
+
+                       glDrawBuffer( GL_BACK );
+                       GlobalOpenGL_debugAssertNoErrors();
+                       glwidget_make_current( m_gl_widget );
+               }
+       }
+}
+
 
 float Betwixt( float f1, float f2 ){
        if ( f1 > f2 ) {
@@ -2327,7 +2599,11 @@ void XYWnd::XY_Draw(){
        glScalef( m_fScale, m_fScale, 1 );
        glTranslatef( -m_vOrigin[nDim1], -m_vOrigin[nDim2], 0 );
 
+       glEnable( GL_BLEND );
+       glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
        DrawCameraIcon( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Camera_getAngles( *g_pParentWnd->GetCamWnd() ) );
+       glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+       glDisable( GL_BLEND );
 
        Feedback_draw2D( m_viewType );
 
@@ -2424,7 +2700,7 @@ void XY_Split_Focus(){
 }
 
 void XY_Focus(){
-       if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) {
+       if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) {
                // cannot do this in a split window
                // do something else that the user may want here
                XY_Split_Focus();
@@ -2435,54 +2711,31 @@ void XY_Focus(){
        XYWnd_Focus( xywnd );
 }
 
-void XY_Top(){
-       if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) {
+void XY_TopFrontSide( VIEWTYPE viewtype ){
+       if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) {
                // cannot do this in a split window
                // do something else that the user may want here
                XY_Split_Focus();
                return;
        }
-
-       XYWnd* xywnd = g_pParentWnd->GetXYWnd();
-       xywnd->SetViewType( XY );
+       XYWnd* xywnd = g_pParentWnd->CurrentStyle() == MainFrame::eFloating ? g_pParentWnd->ActiveXY() : g_pParentWnd->GetXYWnd();
+       xywnd->SetViewType( viewtype );
        XYWnd_Focus( xywnd );
 }
 
-void XY_Side(){
-       if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) {
-               // cannot do this in a split window
-               // do something else that the user may want here
-               XY_Split_Focus();
-               return;
-       }
+void XY_Top(){
+       XY_TopFrontSide( XY );
+}
 
-       XYWnd* xywnd = g_pParentWnd->GetXYWnd();
-       xywnd->SetViewType( XZ );
-       XYWnd_Focus( xywnd );
+void XY_Side(){
+       XY_TopFrontSide( XZ );
 }
 
 void XY_Front(){
-       if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) {
-               // cannot do this in a split window
-               // do something else that the user may want here
-               XY_Split_Focus();
-               return;
-       }
-
-       XYWnd* xywnd = g_pParentWnd->GetXYWnd();
-       xywnd->SetViewType( YZ );
-       XYWnd_Focus( xywnd );
+       XY_TopFrontSide( YZ );
 }
 
-void XY_Next(){
-       if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) {
-               // cannot do this in a split window
-               // do something else that the user may want here
-               XY_Split_Focus();
-               return;
-       }
-
-       XYWnd* xywnd = g_pParentWnd->GetXYWnd();
+void XY_NextView( XYWnd* xywnd ){
        if ( xywnd->GetViewType() == XY ) {
                xywnd->SetViewType( XZ );
        }
@@ -2495,6 +2748,17 @@ void XY_Next(){
        XYWnd_Focus( xywnd );
 }
 
+void XY_Next(){
+       if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) {
+               // cannot do this in a split window
+               // do something else that the user may want here
+               XY_Split_Focus();
+               return;
+       }
+       XYWnd* xywnd = g_pParentWnd->CurrentStyle() == MainFrame::eFloating ? g_pParentWnd->ActiveXY() : g_pParentWnd->GetXYWnd();
+       XY_NextView( xywnd );
+}
+
 void XY_Zoom100(){
        if ( g_pParentWnd->GetXYWnd() ) {
                g_pParentWnd->GetXYWnd()->SetScale( 1 );
@@ -2508,33 +2772,18 @@ void XY_Zoom100(){
 }
 
 void XY_ZoomIn(){
-       XYWnd_ZoomIn( g_pParentWnd->ActiveXY() );
+       g_pParentWnd->ActiveXY()->ZoomIn();
 }
 
 // NOTE: the zoom out factor is 4/5, we could think about customizing it
 //  we don't go below a zoom factor corresponding to 10% of the max world size
 //  (this has to be computed against the window size)
 void XY_ZoomOut(){
-       XYWnd_ZoomOut( g_pParentWnd->ActiveXY() );
+       g_pParentWnd->ActiveXY()->ZoomOut();
 }
 
 
 
-void ToggleShowCrosshair(){
-       g_bCrossHairs ^= 1;
-       XY_UpdateAllWindows();
-}
-
-void ToggleShowSizeInfo(){
-       g_xywindow_globals_private.m_bSizePaint = !g_xywindow_globals_private.m_bSizePaint;
-       XY_UpdateAllWindows();
-}
-
-void ToggleShowGrid(){
-       g_xywindow_globals_private.d_showgrid = !g_xywindow_globals_private.d_showgrid;
-       XY_UpdateAllWindows();
-}
-
 ToggleShown g_xy_top_shown( true );
 
 void XY_Top_Shown_Construct( GtkWindow* parent ){
@@ -2579,112 +2828,134 @@ EntityClassMenu g_EntityClassMenu;
 
 
 
-void ShowNamesToggle(){
-       GlobalEntityCreator().setShowNames( !GlobalEntityCreator().getShowNames() );
-       XY_UpdateAllWindows();
-}
-typedef FreeCaller<ShowNamesToggle> ShowNamesToggleCaller;
 void ShowNamesExport( const BoolImportCallback& importer ){
        importer( GlobalEntityCreator().getShowNames() );
 }
 typedef FreeCaller1<const BoolImportCallback&, ShowNamesExport> ShowNamesExportCaller;
-
-void ShowAnglesToggle(){
-       GlobalEntityCreator().setShowAngles( !GlobalEntityCreator().getShowAngles() );
+ShowNamesExportCaller g_show_names_caller;
+ToggleItem g_show_names( g_show_names_caller );
+void ShowNamesToggle(){
+       GlobalEntityCreator().setShowNames( !GlobalEntityCreator().getShowNames() );
+       g_show_names.update();
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowAnglesToggle> ShowAnglesToggleCaller;
+
 void ShowAnglesExport( const BoolImportCallback& importer ){
        importer( GlobalEntityCreator().getShowAngles() );
 }
 typedef FreeCaller1<const BoolImportCallback&, ShowAnglesExport> ShowAnglesExportCaller;
+ShowAnglesExportCaller g_show_angles_caller;
+ToggleItem g_show_angles( g_show_angles_caller );
+void ShowAnglesToggle(){
+       GlobalEntityCreator().setShowAngles( !GlobalEntityCreator().getShowAngles() );
+       g_show_angles.update();
+       XY_UpdateAllWindows();
+}
 
+BoolExportCaller g_show_blocks_caller( g_xywindow_globals_private.show_blocks );
+ToggleItem g_show_blocks( g_show_blocks_caller );
 void ShowBlocksToggle(){
        g_xywindow_globals_private.show_blocks ^= 1;
+       g_show_blocks.update();
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowBlocksToggle> ShowBlocksToggleCaller;
-void ShowBlocksExport( const BoolImportCallback& importer ){
-       importer( g_xywindow_globals_private.show_blocks );
-}
-typedef FreeCaller1<const BoolImportCallback&, ShowBlocksExport> ShowBlocksExportCaller;
 
+BoolExportCaller g_show_coordinates_caller( g_xywindow_globals_private.show_coordinates );
+ToggleItem g_show_coordinates( g_show_coordinates_caller );
 void ShowCoordinatesToggle(){
        g_xywindow_globals_private.show_coordinates ^= 1;
+       g_show_coordinates.update();
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowCoordinatesToggle> ShowCoordinatesToggleCaller;
-void ShowCoordinatesExport( const BoolImportCallback& importer ){
-       importer( g_xywindow_globals_private.show_coordinates );
-}
-typedef FreeCaller1<const BoolImportCallback&, ShowCoordinatesExport> ShowCoordinatesExportCaller;
 
+BoolExportCaller g_show_outline_caller( g_xywindow_globals_private.show_outline );
+ToggleItem g_show_outline( g_show_outline_caller );
 void ShowOutlineToggle(){
        g_xywindow_globals_private.show_outline ^= 1;
+       g_show_outline.update();
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowOutlineToggle> ShowOutlineToggleCaller;
-void ShowOutlineExport( const BoolImportCallback& importer ){
-       importer( g_xywindow_globals_private.show_outline );
-}
-typedef FreeCaller1<const BoolImportCallback&, ShowOutlineExport> ShowOutlineExportCaller;
 
+BoolExportCaller g_show_axes_caller( g_xywindow_globals_private.show_axis );
+ToggleItem g_show_axes( g_show_axes_caller );
 void ShowAxesToggle(){
        g_xywindow_globals_private.show_axis ^= 1;
+       g_show_axes.update();
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowAxesToggle> ShowAxesToggleCaller;
-void ShowAxesExport( const BoolImportCallback& importer ){
-       importer( g_xywindow_globals_private.show_axis );
-}
-typedef FreeCaller1<const BoolImportCallback&, ShowAxesExport> ShowAxesExportCaller;
 
+
+BoolExportCaller g_show_workzone_caller( g_xywindow_globals_private.d_show_work );
+ToggleItem g_show_workzone( g_show_workzone_caller );
 void ShowWorkzoneToggle(){
        g_xywindow_globals_private.d_show_work ^= 1;
+       g_show_workzone.update();
+       XY_UpdateAllWindows();
+}
+
+/*
+void ShowAxesToggle(){
+       g_xywindow_globals_private.show_axis ^= 1;
        XY_UpdateAllWindows();
 }
-typedef FreeCaller<ShowWorkzoneToggle> ShowWorkzoneToggleCaller;
-void ShowWorkzoneExport( const BoolImportCallback& importer ){
-       importer( g_xywindow_globals_private.d_show_work );
+typedef FreeCaller<ShowAxesToggle> ShowAxesToggleCaller;
+void ShowAxesExport( const BoolImportCallback& importer ){
+       importer( g_xywindow_globals_private.show_axis );
 }
-typedef FreeCaller1<const BoolImportCallback&, ShowWorkzoneExport> ShowWorkzoneExportCaller;
+typedef FreeCaller1<const BoolImportCallback&, ShowAxesExport> ShowAxesExportCaller;
 
-ShowNamesExportCaller g_show_names_caller;
-BoolExportCallback g_show_names_callback( g_show_names_caller );
-ToggleItem g_show_names( g_show_names_callback );
+ShowAxesExportCaller g_show_axes_caller;
+BoolExportCallback g_show_axes_callback( g_show_axes_caller );
+ToggleItem g_show_axes( g_show_axes_callback );
+*/
 
-ShowAnglesExportCaller g_show_angles_caller;
-BoolExportCallback g_show_angles_callback( g_show_angles_caller );
-ToggleItem g_show_angles( g_show_angles_callback );
+/*
+BoolExportCaller g_texdef_movelock_caller( g_brush_texturelock_enabled );
+ToggleItem g_texdef_movelock_item( g_texdef_movelock_caller );
 
-ShowBlocksExportCaller g_show_blocks_caller;
-BoolExportCallback g_show_blocks_callback( g_show_blocks_caller );
-ToggleItem g_show_blocks( g_show_blocks_callback );
+void Texdef_ToggleMoveLock(){
+       g_brush_texturelock_enabled = !g_brush_texturelock_enabled;
+       g_texdef_movelock_item.update();
+}
+*/
 
-ShowCoordinatesExportCaller g_show_coordinates_caller;
-BoolExportCallback g_show_coordinates_callback( g_show_coordinates_caller );
-ToggleItem g_show_coordinates( g_show_coordinates_callback );
+BoolExportCaller g_show_size_caller( g_xywindow_globals_private.m_bSizePaint );
+ToggleItem g_show_size_item( g_show_size_caller );
+void ToggleShowSizeInfo(){
+       g_xywindow_globals_private.m_bSizePaint = !g_xywindow_globals_private.m_bSizePaint;
+       g_show_size_item.update();
+       XY_UpdateAllWindows();
+}
 
-ShowOutlineExportCaller g_show_outline_caller;
-BoolExportCallback g_show_outline_callback( g_show_outline_caller );
-ToggleItem g_show_outline( g_show_outline_callback );
+BoolExportCaller g_show_crosshair_caller( g_bCrossHairs );
+ToggleItem g_show_crosshair_item( g_show_crosshair_caller );
+void ToggleShowCrosshair(){
+       g_bCrossHairs ^= 1;
+       g_show_crosshair_item.update();
+       XY_UpdateAllWindows();
+}
 
-ShowAxesExportCaller g_show_axes_caller;
-BoolExportCallback g_show_axes_callback( g_show_axes_caller );
-ToggleItem g_show_axes( g_show_axes_callback );
+BoolExportCaller g_show_grid_caller( g_xywindow_globals_private.d_showgrid );
+ToggleItem g_show_grid_item( g_show_grid_caller );
+void ToggleShowGrid(){
+       g_xywindow_globals_private.d_showgrid = !g_xywindow_globals_private.d_showgrid;
+       g_show_grid_item.update();
+       XY_UpdateAllWindows();
+}
 
-ShowWorkzoneExportCaller g_show_workzone_caller;
-BoolExportCallback g_show_workzone_callback( g_show_workzone_caller );
-ToggleItem g_show_workzone( g_show_workzone_callback );
 
 void XYShow_registerCommands(){
-       GlobalToggles_insert( "ShowAngles", ShowAnglesToggleCaller(), ToggleItem::AddCallbackCaller( g_show_angles ) );
-       GlobalToggles_insert( "ShowNames", ShowNamesToggleCaller(), ToggleItem::AddCallbackCaller( g_show_names ) );
-       GlobalToggles_insert( "ShowBlocks", ShowBlocksToggleCaller(), ToggleItem::AddCallbackCaller( g_show_blocks ) );
-       GlobalToggles_insert( "ShowCoordinates", ShowCoordinatesToggleCaller(), ToggleItem::AddCallbackCaller( g_show_coordinates ) );
-       GlobalToggles_insert( "ShowWindowOutline", ShowOutlineToggleCaller(), ToggleItem::AddCallbackCaller( g_show_outline ) );
-       GlobalToggles_insert( "ShowAxes", ShowAxesToggleCaller(), ToggleItem::AddCallbackCaller( g_show_axes ) );
-       GlobalToggles_insert( "ShowWorkzone", ShowWorkzoneToggleCaller(), ToggleItem::AddCallbackCaller( g_show_workzone ) );
+       GlobalToggles_insert( "ToggleSizePaint", FreeCaller<ToggleShowSizeInfo>(), ToggleItem::AddCallbackCaller( g_show_size_item ), Accelerator( 'J' ) );
+       GlobalToggles_insert( "ToggleCrosshairs", FreeCaller<ToggleShowCrosshair>(), ToggleItem::AddCallbackCaller( g_show_crosshair_item ), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
+       GlobalToggles_insert( "ToggleGrid", FreeCaller<ToggleShowGrid>(), ToggleItem::AddCallbackCaller( g_show_grid_item ), Accelerator( '0' ) );
+
+       GlobalToggles_insert( "ShowAngles", FreeCaller<ShowAnglesToggle>(), ToggleItem::AddCallbackCaller( g_show_angles ) );
+       GlobalToggles_insert( "ShowNames", FreeCaller<ShowNamesToggle>(), ToggleItem::AddCallbackCaller( g_show_names ) );
+       GlobalToggles_insert( "ShowBlocks", FreeCaller<ShowBlocksToggle>(), ToggleItem::AddCallbackCaller( g_show_blocks ) );
+       GlobalToggles_insert( "ShowCoordinates", FreeCaller<ShowCoordinatesToggle>(), ToggleItem::AddCallbackCaller( g_show_coordinates ) );
+       GlobalToggles_insert( "ShowWindowOutline", FreeCaller<ShowOutlineToggle>(), ToggleItem::AddCallbackCaller( g_show_outline ) );
+       GlobalToggles_insert( "ShowAxes", FreeCaller<ShowAxesToggle>(), ToggleItem::AddCallbackCaller( g_show_axes ) );
+       GlobalToggles_insert( "ShowWorkzone", FreeCaller<ShowWorkzoneToggle>(), ToggleItem::AddCallbackCaller( g_show_workzone ) );
 }
 
 void XYWnd_registerShortcuts(){
@@ -2695,10 +2966,10 @@ void XYWnd_registerShortcuts(){
 
 
 void Orthographic_constructPreferences( PreferencesPage& page ){
-       page.appendCheckBox( "", "Solid selection boxes", g_xywindow_globals.m_bNoStipple );
-       page.appendCheckBox( "", "Display size info", g_xywindow_globals_private.m_bSizePaint );
+       page.appendCheckBox( "", "Solid selection boxes ( no stipple )", g_xywindow_globals.m_bNoStipple );
+       //page.appendCheckBox( "", "Display size info", g_xywindow_globals_private.m_bSizePaint );
        page.appendCheckBox( "", "Chase mouse during drags", g_xywindow_globals_private.m_bChaseMouse );
-       page.appendCheckBox( "", "Update views on camera move", g_xywindow_globals_private.m_bCamXYUpdate );
+//     page.appendCheckBox( "", "Update views on camera move", g_xywindow_globals_private.m_bCamXYUpdate );
 }
 void Orthographic_constructPage( PreferenceGroup& group ){
        PreferencesPage page( group.createPage( "Orthographic", "Orthographic View Preferences" ) );
@@ -2737,9 +3008,9 @@ typedef ConstReferenceCaller1<ToggleShown, const BoolImportCallback&, ToggleShow
 
 
 void XYWindow_Construct(){
-       GlobalCommands_insert( "ToggleCrosshairs", FreeCaller<ToggleShowCrosshair>(), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
-       GlobalCommands_insert( "ToggleSizePaint", FreeCaller<ToggleShowSizeInfo>(), Accelerator( 'J' ) );
-       GlobalCommands_insert( "ToggleGrid", FreeCaller<ToggleShowGrid>(), Accelerator( '0' ) );
+//     GlobalCommands_insert( "ToggleCrosshairs", FreeCaller<ToggleShowCrosshair>(), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
+//     GlobalCommands_insert( "ToggleSizePaint", FreeCaller<ToggleShowSizeInfo>(), Accelerator( 'J' ) );
+//     GlobalCommands_insert( "ToggleGrid", FreeCaller<ToggleShowGrid>(), Accelerator( '0' ) );
 
        GlobalToggles_insert( "ToggleView", ToggleShown::ToggleCaller( g_xy_top_shown ), ToggleItem::AddCallbackCaller( g_xy_top_shown.m_item ), Accelerator( 'V', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
        GlobalToggles_insert( "ToggleSideView", ToggleShown::ToggleCaller( g_yz_side_shown ), ToggleItem::AddCallbackCaller( g_yz_side_shown.m_item ) );
@@ -2755,14 +3026,16 @@ void XYWindow_Construct(){
 
        GlobalPreferenceSystem().registerPreference( "ClipCaulk", BoolImportStringCaller( g_clip_useCaulk ), BoolExportStringCaller( g_clip_useCaulk ) );
 
-       GlobalPreferenceSystem().registerPreference( "NewRightClick", BoolImportStringCaller( g_xywindow_globals.m_bRightClick ), BoolExportStringCaller( g_xywindow_globals.m_bRightClick ) );
+//     GlobalPreferenceSystem().registerPreference( "NewRightClick", BoolImportStringCaller( g_xywindow_globals.m_bRightClick ), BoolExportStringCaller( g_xywindow_globals.m_bRightClick ) );
+       GlobalPreferenceSystem().registerPreference( "ImprovedWheelZoom", BoolImportStringCaller( g_xywindow_globals.m_bImprovedWheelZoom ), BoolExportStringCaller( g_xywindow_globals.m_bImprovedWheelZoom ) );
        GlobalPreferenceSystem().registerPreference( "ChaseMouse", BoolImportStringCaller( g_xywindow_globals_private.m_bChaseMouse ), BoolExportStringCaller( g_xywindow_globals_private.m_bChaseMouse ) );
        GlobalPreferenceSystem().registerPreference( "SizePainting", BoolImportStringCaller( g_xywindow_globals_private.m_bSizePaint ), BoolExportStringCaller( g_xywindow_globals_private.m_bSizePaint ) );
+       GlobalPreferenceSystem().registerPreference( "ShowCrosshair", BoolImportStringCaller( g_bCrossHairs ), BoolExportStringCaller( g_bCrossHairs ) );
        GlobalPreferenceSystem().registerPreference( "NoStipple", BoolImportStringCaller( g_xywindow_globals.m_bNoStipple ), BoolExportStringCaller( g_xywindow_globals.m_bNoStipple ) );
        GlobalPreferenceSystem().registerPreference( "SI_ShowCoords", BoolImportStringCaller( g_xywindow_globals_private.show_coordinates ), BoolExportStringCaller( g_xywindow_globals_private.show_coordinates ) );
        GlobalPreferenceSystem().registerPreference( "SI_ShowOutlines", BoolImportStringCaller( g_xywindow_globals_private.show_outline ), BoolExportStringCaller( g_xywindow_globals_private.show_outline ) );
        GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", BoolImportStringCaller( g_xywindow_globals_private.show_axis ), BoolExportStringCaller( g_xywindow_globals_private.show_axis ) );
-       GlobalPreferenceSystem().registerPreference( "CamXYUpdate", BoolImportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ), BoolExportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ) );
+//     GlobalPreferenceSystem().registerPreference( "CamXYUpdate", BoolImportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ), BoolExportStringCaller( g_xywindow_globals_private.m_bCamXYUpdate ) );
        GlobalPreferenceSystem().registerPreference( "ShowWorkzone", BoolImportStringCaller( g_xywindow_globals_private.d_show_work ), BoolExportStringCaller( g_xywindow_globals_private.d_show_work ) );
 
        GlobalPreferenceSystem().registerPreference( "SI_AxisColors0", Vector3ImportStringCaller( g_xywindow_globals.AxisColorX ), Vector3ExportStringCaller( g_xywindow_globals.AxisColorX ) );
@@ -2774,7 +3047,9 @@ void XYWindow_Construct(){
        GlobalPreferenceSystem().registerPreference( "SI_Colors6", Vector3ImportStringCaller( g_xywindow_globals.color_gridblock ), Vector3ExportStringCaller( g_xywindow_globals.color_gridblock ) );
        GlobalPreferenceSystem().registerPreference( "SI_Colors7", Vector3ImportStringCaller( g_xywindow_globals.color_gridtext ), Vector3ExportStringCaller( g_xywindow_globals.color_gridtext ) );
        GlobalPreferenceSystem().registerPreference( "SI_Colors8", Vector3ImportStringCaller( g_xywindow_globals.color_brushes ), Vector3ExportStringCaller( g_xywindow_globals.color_brushes ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors14", Vector3ImportStringCaller( g_xywindow_globals.color_gridmajor_alt ), Vector3ExportStringCaller( g_xywindow_globals.color_gridmajor_alt ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors9", Vector3ImportStringCaller( g_xywindow_globals.color_viewname ), Vector3ExportStringCaller( g_xywindow_globals.color_viewname ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors10", Vector3ImportStringCaller( g_xywindow_globals.color_clipper ), Vector3ExportStringCaller( g_xywindow_globals.color_clipper ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors11", Vector3ImportStringCaller( g_xywindow_globals.color_selbrushes ), Vector3ExportStringCaller( g_xywindow_globals.color_selbrushes ) );
 
 
        GlobalPreferenceSystem().registerPreference( "XZVIS", makeBoolStringImportCallback( ToggleShownImportBoolCaller( g_xz_front_shown ) ), makeBoolStringExportCallback( ToggleShownExportBoolCaller( g_xz_front_shown ) ) );