X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fxywindow.cpp;h=7352b38665e9cccb8c8f51aab7570fa4fe8ced6b;hb=6b70522a4b2e76e6c5c714fb10e5070b65ebd30d;hp=857e7b998a43db68f4603de491161ef2d1d0f2bd;hpb=c4d9df0a2c16b5b2a8b4a67f0139dc78c245de6c;p=xonotic%2Fnetradiant.git diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 857e7b99..7352b386 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -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(data)->chaseMouseMotion(static_cast(x), static_cast(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); @@ -2580,9 +2589,12 @@ 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() @@ -2953,9 +2965,9 @@ void XYWindow_Construct() GlobalCommands_insert("NextView", FreeCaller(), Accelerator(GDK_Tab, (GdkModifierType)GDK_CONTROL_MASK)); GlobalCommands_insert("ZoomIn", FreeCaller(), Accelerator(GDK_Delete)); GlobalCommands_insert("ZoomOut", FreeCaller(), Accelerator(GDK_Insert)); - GlobalCommands_insert("ViewTop", FreeCaller()); - GlobalCommands_insert("ViewSide", FreeCaller()); - GlobalCommands_insert("ViewFront", FreeCaller()); + GlobalCommands_insert("ViewTop", FreeCaller(), Accelerator(GDK_KP_Home)); + GlobalCommands_insert("ViewSide", FreeCaller(), Accelerator(GDK_KP_Page_Down)); + GlobalCommands_insert("ViewFront", FreeCaller(), Accelerator(GDK_KP_End)); GlobalCommands_insert("Zoom100", FreeCaller()); GlobalCommands_insert("CenterXYView", FreeCaller(), Accelerator(GDK_Tab, (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK)));