]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/xywindow.cpp
Merge commit '54a2bda443aace9c00a1615af10cc1dc8b1f0cd1' into master-merge
[xonotic/netradiant.git] / radiant / xywindow.cpp
index 5e67ecf2813394ebc4c881e16c647b3636fcc633..c7d1d6cbf1560f01c7637493c3e88c46eceb3bc0 100644 (file)
@@ -113,6 +113,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;
@@ -138,7 +139,9 @@ void ClipPoint::Draw( const char *label, float scale ){
 
        // draw label
        glRasterPos3f( m_ptClip[0] + offset, m_ptClip[1] + offset, m_ptClip[2] + offset );
-       glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, label );
+       //glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, label );   //fails with GCC
+       //glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, reinterpret_cast<const GLubyte*>( label ) );       //worx
+       GlobalOpenGL().drawString( label );
 }
 
 float fDiff( float f1, float f2 ){
@@ -261,6 +264,10 @@ void Clip(){
                g_Clip3.Reset();
                Clip_Update();
                ClipperChangeNotify();
+               if( g_quick_clipper ){
+                       g_quick_clipper = false;
+                       ClipperMode();
+               }
        }
 }
 
@@ -275,6 +282,10 @@ void SplitClip(){
                g_Clip3.Reset();
                Clip_Update();
                ClipperChangeNotify();
+               if( g_quick_clipper ){
+                       g_quick_clipper = false;
+                       ClipperMode();
+               }
        }
 }
 
@@ -345,7 +356,7 @@ struct xywindow_globals_private_t
        bool show_blocks;
        int blockSize;
 
-       bool m_bCamXYUpdate;
+//     bool m_bCamXYUpdate;
        bool m_bChaseMouse;
        bool m_bSizePaint;
 
@@ -355,16 +366,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 ),
 
@@ -536,7 +547,7 @@ void XYWnd::ZoomOut(){
 void XYWnd::ZoomInWithMouse( int pointx, int pointy ){
        float old_scale = Scale();
        ZoomIn();
-       if ( g_xywindow_globals.m_bImprovedWheelZoom ) {
+       if ( g_xywindow_globals.m_bZoomInToPointer ) {
                float scale_diff = 1.0 / old_scale - 1.0 / Scale();
                int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
                int nDim2 = ( m_viewType == XY ) ? 1 : 2;
@@ -739,13 +750,26 @@ Shader* XYWnd::m_state_selected = 0;
 
 void xy_update_xor_rectangle( XYWnd& self, rect_t area ){
        if ( self.GetWidget().visible() ) {
-               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( ui::Widget widget, GdkEventButton* event, XYWnd* xywnd ){
        if ( event->type == GDK_BUTTON_PRESS ) {
-               g_pParentWnd->SetActiveXY( xywnd );
+               gtk_widget_grab_focus( xywnd->GetWidget() );
+
+               if( !xywnd->Active() ){
+                       g_pParentWnd->SetActiveXY( xywnd );
+               }
 
                xywnd->ButtonState_onMouseDown( buttons_for_event_button( event ) );
 
@@ -766,7 +790,9 @@ gboolean xywnd_button_release( ui::Widget widget, GdkEventButton* event, XYWnd*
 gboolean xywnd_focus_in( ui::Widget 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;
@@ -780,6 +806,14 @@ void xywnd_motion( gdouble x, gdouble y, guint state, void* data ){
 }
 
 gboolean xywnd_wheel_scroll( ui::Widget widget, GdkEventScroll* event, XYWnd* xywnd ){
+       gtk_widget_grab_focus( xywnd->GetWidget() );
+       ui::Window window = xywnd->m_parent ? xywnd->m_parent : MainFrame_getWindow();
+       if( !gtk_window_is_active( window ) )
+               gtk_window_present( window );
+
+       if( !xywnd->Active() ){
+               g_pParentWnd->SetActiveXY( xywnd );
+       }
        if ( event->direction == GDK_SCROLL_UP ) {
                xywnd->ZoomInWithMouse( (int)event->x, (int)event->y );
        }
@@ -803,9 +837,10 @@ gboolean xywnd_expose( ui::Widget 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() :
@@ -815,7 +850,7 @@ XYWnd::XYWnd() :
        m_parent( ui::null ),
        m_window_observer( NewWindowObserver() ),
        m_XORRectangle( m_gl_widget ),
-       m_chasemouse_handler( 0 ) {
+       m_chasemouse_handler( 0 ){
 
        m_bActive = false;
        m_buttonstate = 0;
@@ -860,7 +895,7 @@ XYWnd::XYWnd() :
 
        m_gl_widget.connect( "button_press_event", G_CALLBACK( xywnd_button_press ), this );
        m_gl_widget.connect( "button_release_event", G_CALLBACK( xywnd_button_release ), this );
-       m_gl_widget.connect( "focus_in_event", G_CALLBACK( xywnd_focus_in ), this );
+       m_gl_widget.connect( "focus_in_event", G_CALLBACK( xywnd_focus_in ), this );    //works only in floating views layout
        m_gl_widget.connect( "motion_notify_event", G_CALLBACK( DeferredMotion::gtk_motion ), &m_deferred_motion );
 
        m_gl_widget.connect( "scroll_event", G_CALLBACK( xywnd_wheel_scroll ), this );
@@ -927,6 +962,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;
 
@@ -965,20 +1004,58 @@ void XYWnd::Clipper_OnMouseMoved( int x, int y ){
        }
 }
 
+//#include "gtkutil/image.h"
+
+/* is called on every mouse move fraction; ain't good! */
 void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){
        Vector3 mousePosition;
        XY_ToPoint( x, y, mousePosition );
+#if 0 // NetRadiantCustom
+       if ( ClipMode() ) {
+               if( GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ) != 0 ){
+                       GdkCursor *cursor;
+                       cursor = gdk_cursor_new( GDK_CROSSHAIR );
+                       //cursor = gdk_cursor_new( GDK_FLEUR );
+                       gdk_window_set_cursor( gtk_widget_get_window(m_gl_widget), cursor );
+                       gdk_cursor_unref( cursor );
+               }
+               else{
+                       GdkCursor *cursor;
+                       cursor = gdk_cursor_new( GDK_HAND2 );
+//                     GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.png" );
+//                     cursor = gdk_cursor_new_from_pixbuf( gdk_display_get_default(), pixbuf, 0, 0 );
+//                     g_object_unref( pixbuf );
+                       gdk_window_set_cursor( gtk_widget_get_window(m_gl_widget), cursor );
+                       gdk_cursor_unref( cursor );
+
+               }
+       }
+#else
        if ( ClipMode() && GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ) != 0 ) {
                set_cursor ( m_gl_widget, GDK_CROSSHAIR );
        }
+#endif
        else
        {
                default_cursor( m_gl_widget );
        }
 }
 
+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 ){
@@ -989,16 +1066,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;
@@ -1007,8 +1085,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;
 }
 
 /*
@@ -1026,7 +1134,6 @@ void XYWnd::NewBrushDrag_Begin( int x, int y ){
        m_nNewBrushPressy = y;
 
        m_bNewBrushDrag = true;
-       GlobalUndoSystem().start();
 }
 
 void XYWnd::NewBrushDrag_End( int x, int y ){
@@ -1064,6 +1171,7 @@ void XYWnd::NewBrushDrag( int x, int y ){
        }
 
        if ( m_NewBrushDrag == 0 ) {
+               GlobalUndoSystem().start();
                NodeSmartReference node( GlobalBrushCreator().createBrush() );
                Node_getTraversable( Map_FindOrInsertWorldspawn( g_map ) )->insert( node );
 
@@ -1092,9 +1200,9 @@ void entitycreate_activated( ui::Widget item ){
        else {
                GlobalRadiant().m_pfnMessageBox( MainFrame_getWindow(),
                        "There's already a worldspawn in your map!",
-                       "Info",
-                       eMB_OK,
-                       eMB_ICONDEFAULT );
+                                                                                "Info",
+                                                                                eMB_OK,
+                                                                                eMB_ICONDEFAULT );
        }
 }
 
@@ -1171,9 +1279,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 ) { // first time, load it up
                auto menu = m_mnuDrop = ui::Menu(ui::New);
@@ -1206,21 +1314,27 @@ void XYWnd::Move_Begin(){
                Move_End();
        }
        m_move_started = true;
+       /* NetRadiantCustom did this instead:
+       g_xywnd_freezePointer.freeze_pointer( m_parent  ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_moveDelta, this ); */
        g_xywnd_freezePointer.freeze_pointer( m_gl_widget, XYWnd_moveDelta, this );
        m_move_focusOut = m_gl_widget.connect( "focus_out_event", G_CALLBACK( XYWnd_Move_focusOut ), this );
 }
 
 void XYWnd::Move_End(){
        m_move_started = false;
-       g_xywnd_freezePointer.unfreeze_pointer( m_gl_widget );
+       /* NetRadiant did this instead:
+       g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), false ); */
+       g_xywnd_freezePointer.unfreeze_pointer( m_gl_widget, 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;
+int g_zoom2x = 0;
+int g_zoom2y = 0;
 
 void XYWnd_zoomDelta( int x, int y, unsigned int state, void* data ){
        if ( y != 0 ) {
@@ -1233,7 +1347,12 @@ void XYWnd_zoomDelta( int x, int y, unsigned int state, void* data ){
                        }
                        else
                        {
+                               if ( g_xywindow_globals.m_bZoomInToPointer ) {
+                                       reinterpret_cast<XYWnd*>( data )->ZoomInWithMouse( g_zoom2x, g_zoom2y );
+                               }
+                               else{
                                reinterpret_cast<XYWnd*>( data )->ZoomIn();
+                               }
                                g_dragZoom += 8;
                        }
                }
@@ -1245,19 +1364,23 @@ gboolean XYWnd_Zoom_focusOut( ui::Widget widget, GdkEventFocus* event, XYWnd* xy
        return FALSE;
 }
 
-void XYWnd::Zoom_Begin(){
+void XYWnd::Zoom_Begin( int x, int y ){
        if ( m_zoom_started ) {
                Zoom_End();
        }
        m_zoom_started = true;
        g_dragZoom = 0;
+       g_zoom2x = x;
+       g_zoom2y = y;
+       /* NetRadiantCustom did this instead:
+       g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_zoomDelta, this ); */
        g_xywnd_freezePointer.freeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), XYWnd_zoomDelta, this );
        m_zoom_focusOut = m_gl_widget.connect( "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this );
 }
 
 void XYWnd::Zoom_End(){
        m_zoom_started = false;
-       g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow() );
+       g_xywnd_freezePointer.unfreeze_pointer( m_parent ? m_parent : MainFrame_getWindow(), false );
        g_signal_handler_disconnect( G_OBJECT( m_gl_widget ), m_zoom_focusOut );
 }
 
@@ -1297,9 +1420,14 @@ void XYWnd::XY_MouseDown( int x, int y, unsigned int buttons ){
                EntityCreate_MouseDown( x, y );
        }
        else if ( buttons == Zoom_buttons() ) {
-               Zoom_Begin();
+               Zoom_Begin( x, y );
        }
-       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 ) {
@@ -1313,6 +1441,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 ) );
@@ -1327,12 +1458,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
        {
@@ -1357,15 +1492,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 ) );
@@ -1554,8 +1693,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
@@ -1587,6 +1732,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 );
 
@@ -1754,16 +1998,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();
@@ -1883,47 +2130,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 ) {
@@ -2153,8 +2461,8 @@ void XYWnd::updateProjection( bool reconstruct ){
        m_projection[15] = 1.0f;
 
        if (reconstruct) {
-               m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight );
-       }
+       m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight );
+}
 }
 
 // note: modelview matrix must have a uniform scale, otherwise strange things happen when rendering the rotation manipulator.
@@ -2215,7 +2523,7 @@ void XYWnd::updateModelview( bool reconstruct ){
        m_modelview[15] = 1;
 
        if (reconstruct) {
-               m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight );
+       m_view.Construct( m_projection, m_modelview, m_nWidth, m_nHeight );
        }
 }
 
@@ -2362,7 +2670,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 );
 
@@ -2459,7 +2771,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();
@@ -2470,54 +2782,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 );
        }
@@ -2530,6 +2819,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 );
@@ -2612,82 +2912,167 @@ void unrealise(){
 EntityClassMenu g_EntityClassMenu;
 
 
-
-
+// Names
 void ShowNamesToggle(){
        GlobalEntityCreator().setShowNames( !GlobalEntityCreator().getShowNames() );
        XY_UpdateAllWindows();
 }
+
 typedef FreeCaller<void(), ShowNamesToggle> ShowNamesToggleCaller;
+
 void ShowNamesExport( const Callback<void(bool)> & importer ){
        importer( GlobalEntityCreator().getShowNames() );
 }
+
 typedef FreeCaller<void(const Callback<void(bool)> &), ShowNamesExport> ShowNamesExportCaller;
 
+// TargetNames
+void ShowTargetNamesToggle(){
+       GlobalEntityCreator().setShowTargetNames( !GlobalEntityCreator().getShowTargetNames() );
+       XY_UpdateAllWindows();
+}
+
+typedef FreeCaller<void(), ShowTargetNamesToggle> ShowTargetNamesToggleCaller;
+
+void ShowTargetNamesExport( const Callback<void(bool)> & importer ){
+       importer( GlobalEntityCreator().getShowTargetNames() );
+}
+
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowTargetNamesExport> ShowTargetNamesExportCaller;
+
+// Angles
 void ShowAnglesToggle(){
        GlobalEntityCreator().setShowAngles( !GlobalEntityCreator().getShowAngles() );
        XY_UpdateAllWindows();
 }
+
 typedef FreeCaller<void(), ShowAnglesToggle> ShowAnglesToggleCaller;
+
 void ShowAnglesExport( const Callback<void(bool)> & importer ){
        importer( GlobalEntityCreator().getShowAngles() );
 }
 typedef FreeCaller<void(const Callback<void(bool)> &), ShowAnglesExport> ShowAnglesExportCaller;
 
+// Blocks
 void ShowBlocksToggle(){
        g_xywindow_globals_private.show_blocks ^= 1;
        XY_UpdateAllWindows();
 }
+
 typedef FreeCaller<void(), ShowBlocksToggle> ShowBlocksToggleCaller;
+
 void ShowBlocksExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_blocks );
 }
+
 typedef FreeCaller<void(const Callback<void(bool)> &), ShowBlocksExport> ShowBlocksExportCaller;
 
+// Coordinates
 void ShowCoordinatesToggle(){
        g_xywindow_globals_private.show_coordinates ^= 1;
        XY_UpdateAllWindows();
 }
+
 typedef FreeCaller<void(), ShowCoordinatesToggle> ShowCoordinatesToggleCaller;
+
 void ShowCoordinatesExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_coordinates );
 }
+
 typedef FreeCaller<void(const Callback<void(bool)> &), ShowCoordinatesExport> ShowCoordinatesExportCaller;
 
+// Outlines
 void ShowOutlineToggle(){
        g_xywindow_globals_private.show_outline ^= 1;
        XY_UpdateAllWindows();
 }
+
 typedef FreeCaller<void(), ShowOutlineToggle> ShowOutlineToggleCaller;
+
 void ShowOutlineExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_outline );
 }
+
 typedef FreeCaller<void(const Callback<void(bool)> &), ShowOutlineExport> ShowOutlineExportCaller;
 
+// Axes
 void ShowAxesToggle(){
        g_xywindow_globals_private.show_axis ^= 1;
        XY_UpdateAllWindows();
 }
 typedef FreeCaller<void(), ShowAxesToggle> ShowAxesToggleCaller;
+
 void ShowAxesExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.show_axis );
 }
+
 typedef FreeCaller<void(const Callback<void(bool)> &), ShowAxesExport> ShowAxesExportCaller;
 
+// Workzone
 void ShowWorkzoneToggle(){
        g_xywindow_globals_private.d_show_work ^= 1;
        XY_UpdateAllWindows();
 }
 typedef FreeCaller<void(), ShowWorkzoneToggle> ShowWorkzoneToggleCaller;
+
 void ShowWorkzoneExport( const Callback<void(bool)> & importer ){
        importer( g_xywindow_globals_private.d_show_work );
 }
+
 typedef FreeCaller<void(const Callback<void(bool)> &), ShowWorkzoneExport> ShowWorkzoneExportCaller;
 
+/*
+BoolExportCaller g_texdef_movelock_caller( g_brush_texturelock_enabled );
+ToggleItem g_texdef_movelock_item( g_texdef_movelock_caller );
+
+void Texdef_ToggleMoveLock(){
+       g_brush_texturelock_enabled = !g_brush_texturelock_enabled;
+       g_texdef_movelock_item.update();
+}
+*/
+
+// Size
+void ShowSizeToggle(){
+       g_xywindow_globals_private.m_bSizePaint = !g_xywindow_globals_private.m_bSizePaint;
+       XY_UpdateAllWindows();
+}
+typedef FreeCaller<void(), ShowSizeToggle> ShowSizeToggleCaller;
+void ShowSizeExport( const Callback<void(bool)> & importer ){
+       importer( g_xywindow_globals_private.m_bSizePaint );
+}
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowSizeExport> ShowSizeExportCaller;
+
+// Crosshair
+void ShowCrosshairToggle(){
+       g_xywindow_globals_private.g_bCrossHairs ^= 1;
+       XY_UpdateAllWindows();
+}
+typedef FreeCaller<void(), ShowCrosshairToggle> ShowCrosshairToggleCaller;
+void ShowCrosshairExport( const Callback<void(bool)> & importer ){
+       importer( g_xywindow_globals_private.g_bCrossHairs );
+}
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowCrosshairExport> ShowCrosshairExportCaller;
+
+// Grid
+void ShowGridToggle(){
+       g_xywindow_globals_private.d_showgrid = !g_xywindow_globals_private.d_showgrid;
+       XY_UpdateAllWindows();
+}
+typedef FreeCaller<void(), ShowGridToggle> ShowGridToggleCaller;
+void ShowGridTExport( const Callback<void(bool)> & importer ){
+       importer( g_xywindow_globals_private.d_showgrid );
+}
+typedef FreeCaller<void(const Callback<void(bool)> &), ShowSizeExport> ShowGridExportCaller;
+
+
 ShowNamesExportCaller g_show_names_caller;
 Callback<void(const Callback<void(bool)> &)> g_show_names_callback( g_show_names_caller );
 ToggleItem g_show_names( g_show_names_callback );
 
+ShowTargetNamesExportCaller g_show_targetnames_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_targetnames_callback( g_show_targetnames_caller );
+ToggleItem g_show_targetnames( g_show_targetnames_callback );
+
 ShowAnglesExportCaller g_show_angles_caller;
 Callback<void(const Callback<void(bool)> &)> g_show_angles_callback( g_show_angles_caller );
 ToggleItem g_show_angles( g_show_angles_callback );
@@ -2712,9 +3097,27 @@ ShowWorkzoneExportCaller g_show_workzone_caller;
 Callback<void(const Callback<void(bool)> &)> g_show_workzone_callback( g_show_workzone_caller );
 ToggleItem g_show_workzone( g_show_workzone_callback );
 
+ShowSizeExportCaller g_show_size_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_size_callback( g_show_size_caller );
+ToggleItem g_show_size( g_show_size_callback );
+
+ShowCrosshairExportCaller g_show_crosshair_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_crosshair_callback( g_show_crosshair_caller );
+ToggleItem g_show_crosshair( g_show_crosshair_callback );
+
+ShowGridExportCaller g_show_grid_caller;
+Callback<void(const Callback<void(bool)> &)> g_show_grid_callback( g_show_grid_caller );
+ToggleItem g_show_grid( g_show_grid_callback );
+
+
 void XYShow_registerCommands(){
+       GlobalToggles_insert( "ToggleSizePaint", ShowSizeToggleCaller(), ToggleItem::AddCallbackCaller( g_show_size ), Accelerator( 'J' ) );
+       GlobalToggles_insert( "ToggleCrosshairs", ShowCrosshairToggleCaller(), ToggleItem::AddCallbackCaller( g_show_crosshair ), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
+       GlobalToggles_insert( "ToggleGrid", ShowGridToggleCaller(), ToggleItem::AddCallbackCaller( g_show_grid ), Accelerator( '0' ) );
+
        GlobalToggles_insert( "ShowAngles", ShowAnglesToggleCaller(), ToggleItem::AddCallbackCaller( g_show_angles ) );
        GlobalToggles_insert( "ShowNames", ShowNamesToggleCaller(), ToggleItem::AddCallbackCaller( g_show_names ) );
+       GlobalToggles_insert( "ShowTargetNames", ShowTargetNamesToggleCaller(), ToggleItem::AddCallbackCaller( g_show_targetnames ) );
        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 ) );
@@ -2730,10 +3133,11 @@ 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 );
+       page.appendCheckBox( "", "Zoom In to Mouse pointer", g_xywindow_globals.m_bZoomInToPointer );
 }
 void Orthographic_constructPage( PreferenceGroup& group ){
        PreferencesPage page( group.createPage( "Orthographic", "Orthographic View Preferences" ) );
@@ -2771,9 +3175,9 @@ struct ToggleShown_Bool {
 
 
 void XYWindow_Construct(){
-       GlobalCommands_insert( "ToggleCrosshairs", makeCallbackF(ToggleShowCrosshair), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
-       GlobalCommands_insert( "ToggleSizePaint", makeCallbackF(ToggleShowSizeInfo), Accelerator( 'J' ) );
-       GlobalCommands_insert( "ToggleGrid", makeCallbackF(ToggleShowGrid), Accelerator( '0' ) );
+//     GlobalCommands_insert( "ToggleCrosshairs", makeCallbackF(ToggleShowCrosshair), Accelerator( 'X', (GdkModifierType)GDK_SHIFT_MASK ) );
+//     GlobalCommands_insert( "ToggleSizePaint", makeCallbackF(ToggleShowSizeInfo), Accelerator( 'J' ) );
+//     GlobalCommands_insert( "ToggleGrid", makeCallbackF(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 ) );
@@ -2789,8 +3193,8 @@ void XYWindow_Construct(){
 
        GlobalPreferenceSystem().registerPreference( "ClipCaulk", make_property_string( g_clip_useCaulk ) );
 
-       GlobalPreferenceSystem().registerPreference( "NewRightClick", make_property_string( g_xywindow_globals.m_bRightClick ) );
-       GlobalPreferenceSystem().registerPreference( "ImprovedWheelZoom", make_property_string( g_xywindow_globals.m_bImprovedWheelZoom ) );
+//     GlobalPreferenceSystem().registerPreference( "NewRightClick", make_property_string( g_xywindow_globals.m_bRightClick ) );
+       GlobalPreferenceSystem().registerPreference( "2DZoomInToPointer", make_property_string( g_xywindow_globals.m_bZoomInToPointer ) );
        GlobalPreferenceSystem().registerPreference( "ChaseMouse", make_property_string( g_xywindow_globals_private.m_bChaseMouse ) );
        GlobalPreferenceSystem().registerPreference( "SizePainting", make_property_string( g_xywindow_globals_private.m_bSizePaint ) );
        GlobalPreferenceSystem().registerPreference( "ShowCrosshair", make_property_string( g_xywindow_globals_private.g_bCrossHairs ) );
@@ -2798,7 +3202,7 @@ void XYWindow_Construct(){
        GlobalPreferenceSystem().registerPreference( "SI_ShowCoords", make_property_string( g_xywindow_globals_private.show_coordinates ) );
        GlobalPreferenceSystem().registerPreference( "SI_ShowOutlines", make_property_string( g_xywindow_globals_private.show_outline ) );
        GlobalPreferenceSystem().registerPreference( "SI_ShowAxis", make_property_string( g_xywindow_globals_private.show_axis ) );
-       GlobalPreferenceSystem().registerPreference( "CamXYUpdate", make_property_string( g_xywindow_globals_private.m_bCamXYUpdate ) );
+//     GlobalPreferenceSystem().registerPreference( "CamXYUpdate", make_property_string( g_xywindow_globals_private.m_bCamXYUpdate ) );
        GlobalPreferenceSystem().registerPreference( "ShowWorkzone", make_property_string( g_xywindow_globals_private.d_show_work ) );
 
        GlobalPreferenceSystem().registerPreference( "SI_AxisColors0", make_property_string( g_xywindow_globals.AxisColorX ) );
@@ -2810,7 +3214,11 @@ void XYWindow_Construct(){
        GlobalPreferenceSystem().registerPreference( "SI_Colors6", make_property_string( g_xywindow_globals.color_gridblock ) );
        GlobalPreferenceSystem().registerPreference( "SI_Colors7", make_property_string( g_xywindow_globals.color_gridtext ) );
        GlobalPreferenceSystem().registerPreference( "SI_Colors8", make_property_string( g_xywindow_globals.color_brushes ) );
-       GlobalPreferenceSystem().registerPreference( "SI_Colors14", make_property_string( g_xywindow_globals.color_gridmajor_alt ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors9", make_property_string( g_xywindow_globals.color_viewname ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors10", make_property_string( g_xywindow_globals.color_clipper ) );
+       GlobalPreferenceSystem().registerPreference( "SI_Colors11", make_property_string( g_xywindow_globals.color_selbrushes ) );
+
+
 
 
        GlobalPreferenceSystem().registerPreference( "XZVIS", make_property_string<ToggleShown_Bool>( g_xz_front_shown ) );