]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/xywindow.cpp
in "GimpRadiant" mode, make the focused XY view the current one for nudgeSelection
[xonotic/netradiant.git] / radiant / xywindow.cpp
index 78206940556389a74394ddbcc8234ea0a21a7bf1..ff7852e72ad58bdb027faeb9f6acd3038431e15b 100644 (file)
@@ -390,7 +390,7 @@ struct xywindow_globals_private_t
 
     m_bCamXYUpdate(true),
     m_bChaseMouse(true),
-    m_bSizePaint(false)
+    m_bSizePaint(true)
   {
   }
 
@@ -775,6 +775,16 @@ gboolean xywnd_button_release(GtkWidget* widget, GdkEventButton* event, XYWnd* x
   return FALSE;
 }
 
+gboolean xywnd_focus_in(GtkWidget* widget, GdkEventFocus* event, XYWnd* xywnd)
+{
+       if(event->type == GDK_FOCUS_CHANGE)
+       {
+               if(event->in)
+                       g_pParentWnd->SetActiveXY(xywnd);
+       }
+       return FALSE;
+}
+
 void xywnd_motion(gdouble x, gdouble y, guint state, void* data)
 {
   if(reinterpret_cast<XYWnd*>(data)->chaseMouseMotion(static_cast<int>(x), static_cast<int>(y)))
@@ -884,6 +894,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), "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);
@@ -1849,10 +1860,8 @@ void XYWnd::XY_DrawGrid(void) {
        // draw coordinate text if needed
        if ( g_xywindow_globals_private.show_coordinates) {
                glColor4fv(vector4_to_array(Vector4(g_xywindow_globals.color_gridtext, 1.0f)));
-               // why does this not work on windows:
-               //   float offx = m_vOrigin[nDim2] + h - (1 + GlobalOpenGL().m_fontAscent) / m_fScale;
-               float offx = m_vOrigin[nDim2] + h - 13                                / m_fScale;
-               float offy = m_vOrigin[nDim1] - w +  1                                / m_fScale;
+               float offx = m_vOrigin[nDim2] + h - (4 + GlobalOpenGL().m_font->getPixelAscent()) / m_fScale;
+               float offy = m_vOrigin[nDim1] - w +  4                                            / m_fScale;
                for (x = xb - fmod(xb, stepx); x <= xe ; x += stepx) {
                        glRasterPos2f (x, offx);
                        sprintf (text, "%g", x);
@@ -2522,10 +2531,10 @@ void XYWnd::XY_Draw()
         }
       }
       glBegin (GL_LINE_LOOP);
-      glVertex2i (0, 0);
-      glVertex2i (m_nWidth-1, 0);
-      glVertex2i (m_nWidth-1, m_nHeight-1);
-      glVertex2i (0, m_nHeight-1);
+      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();
     }
   }
@@ -2580,14 +2589,17 @@ void XY_Split_Focus()
 {
   Vector3 position;
   GetFocusPosition(position);
-  g_pParentWnd->GetXYWnd()->PositionView(position);
-  g_pParentWnd->GetXZWnd()->PositionView(position);
-  g_pParentWnd->GetYZWnd()->PositionView(position);
+  if(g_pParentWnd->GetXYWnd())
+         g_pParentWnd->GetXYWnd()->PositionView(position);
+  if(g_pParentWnd->GetXZWnd())
+         g_pParentWnd->GetXZWnd()->PositionView(position);
+  if(g_pParentWnd->GetYZWnd())
+         g_pParentWnd->GetYZWnd()->PositionView(position);
 }
 
 void XY_Focus()
 {
-  if (g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating)
+  if (g_pParentWnd->CurrentStyle() == MainFrame::eSplit)
   {
          // cannot do this in a split window
          // do something else that the user may want here