X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fxywindow.cpp;h=7352b38665e9cccb8c8f51aab7570fa4fe8ced6b;hb=772c8fda0fbbf99451d471f99b7db6715ad88490;hp=dfc0c25bf28d021a9e6f4aa1dfc6dda84ef95e0e;hpb=107765f0e4b543dfc346851ee5b4605cc17eb1c6;p=xonotic%2Fnetradiant.git diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index dfc0c25b..7352b386 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -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(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); @@ -966,7 +977,7 @@ void XYWnd::DropClipPoint(int pointx, int pointy) g_clip_viewtype = static_cast(GetViewType()); const int nDim = (g_clip_viewtype == YZ ) ? 0 : ( (g_clip_viewtype == XZ) ? 1 : 2 ); point[nDim] = mid[nDim]; - vector3_snap(point, GetGridSize()); + vector3_snap(point, GetSnapGridSize()); NewClipPoint(point); } @@ -1093,8 +1104,8 @@ void XYWnd::NewBrushDrag(int x, int y) int nDim = (m_viewType == XY) ? 2 : (m_viewType == YZ) ? 0 : 1; - mins[nDim] = float_snapped(Select_getWorkZone().d_work_min[nDim], GetGridSize()); - maxs[nDim] = float_snapped(Select_getWorkZone().d_work_max[nDim], GetGridSize()); + mins[nDim] = float_snapped(Select_getWorkZone().d_work_min[nDim], GetSnapGridSize()); + maxs[nDim] = float_snapped(Select_getWorkZone().d_work_max[nDim], GetSnapGridSize()); if (maxs[nDim] <= mins[nDim]) maxs[nDim] = mins[nDim] + GetGridSize(); @@ -1555,18 +1566,18 @@ void XYWnd::XY_SnapToGrid(Vector3& point) { if (m_viewType == XY) { - point[0] = float_snapped(point[0], GetGridSize()); - point[1] = float_snapped(point[1], GetGridSize()); + point[0] = float_snapped(point[0], GetSnapGridSize()); + point[1] = float_snapped(point[1], GetSnapGridSize()); } else if (m_viewType == YZ) { - point[1] = float_snapped(point[1], GetGridSize()); - point[2] = float_snapped(point[2], GetGridSize()); + point[1] = float_snapped(point[1], GetSnapGridSize()); + point[2] = float_snapped(point[2], GetSnapGridSize()); } else { - point[0] = float_snapped(point[0], GetGridSize()); - point[2] = float_snapped(point[2], GetGridSize()); + point[0] = float_snapped(point[0], GetSnapGridSize()); + point[2] = float_snapped(point[2], GetSnapGridSize()); } } @@ -1737,7 +1748,7 @@ void XYWnd::XY_DrawBackground(void) void XYWnd::XY_DrawGrid(void) { float x, y, xb, xe, yb, ye; - float w, h; + float w, h, a; char text[32]; float step, minor_step, stepx, stepy; step = minor_step = stepx = stepy = GetGridSize(); @@ -1760,6 +1771,7 @@ void XYWnd::XY_DrawGrid(void) { while ((stepy * m_fScale) <= 32.0f) // text step y must be at least 32 stepy *= 2; + a = ((GetSnapGridSize() > 0.0f) ? 1.0f : 0.3f); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_1D); @@ -1800,9 +1812,12 @@ void XYWnd::XY_DrawGrid(void) { // djbob // draw minor blocks - if (g_xywindow_globals_private.d_showgrid) { + if (g_xywindow_globals_private.d_showgrid || a < 1.0f) { + if(a < 1.0f) + glEnable(GL_BLEND); + if (COLORS_DIFFER(g_xywindow_globals.color_gridminor, g_xywindow_globals.color_gridback)) { - glColor3fv(vector3_to_array(g_xywindow_globals.color_gridminor)); + glColor4fv(vector4_to_array(Vector4(g_xywindow_globals.color_gridminor, a))); glBegin (GL_LINES); int i = 0; @@ -1823,8 +1838,8 @@ void XYWnd::XY_DrawGrid(void) { } // draw major blocks - if (COLORS_DIFFER(g_xywindow_globals.color_gridmajor, g_xywindow_globals.color_gridback)) { - glColor3fv(vector3_to_array(g_xywindow_globals.color_gridmajor)); + if (COLORS_DIFFER(g_xywindow_globals.color_gridmajor, g_xywindow_globals.color_gridminor)) { + glColor4fv(vector4_to_array(Vector4(g_xywindow_globals.color_gridmajor, a))); glBegin (GL_LINES); for (x = xb ; x <= xe ; x += step) { @@ -1837,12 +1852,16 @@ void XYWnd::XY_DrawGrid(void) { } glEnd(); } + + if(a < 1.0f) + glDisable(GL_BLEND); } // draw coordinate text if needed if ( g_xywindow_globals_private.show_coordinates) { - glColor3fv(vector3_to_array(g_xywindow_globals.color_gridtext)); - float offx = m_vOrigin[nDim2] + h - 6 / m_fScale, offy = m_vOrigin[nDim1] - w + 1 / m_fScale; + glColor4fv(vector4_to_array(Vector4(g_xywindow_globals.color_gridtext, 1.0f))); + 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); @@ -1870,7 +1889,7 @@ void XYWnd::XY_DrawGrid(void) { // show current work zone? // the work zone is used to place dropped points and brushes if (g_xywindow_globals_private.d_show_work) { - glColor3f( 1.0f, 0.0f, 0.0f ); + glColor4f( 1.0f, 0.0f, 0.0f, 1.0f ); glBegin( GL_LINES ); glVertex2f( xb, Select_getWorkZone().d_work_min[nDim2] ); glVertex2f( xe, Select_getWorkZone().d_work_min[nDim2] ); @@ -2512,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(); } } @@ -2570,19 +2589,38 @@ 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) + { + // 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_Focus(xywnd); } void XY_Top() { + 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(XY); XYWnd_Focus(xywnd); @@ -2590,6 +2628,14 @@ void XY_Top() 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; + } + XYWnd* xywnd = g_pParentWnd->GetXYWnd(); xywnd->SetViewType(XZ); XYWnd_Focus(xywnd); @@ -2597,12 +2643,29 @@ void XY_Side() void XY_Front() { - g_pParentWnd->GetXYWnd()->SetViewType(YZ); - XYWnd_Focus(g_pParentWnd->GetXYWnd()); + 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); } 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(); if (xywnd->GetViewType() == XY) xywnd->SetViewType(XZ); @@ -2902,11 +2965,10 @@ 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("CenterXYViews", FreeCaller(), Accelerator(GDK_Tab, (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK))); GlobalCommands_insert("CenterXYView", FreeCaller(), Accelerator(GDK_Tab, (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK))); GlobalPreferenceSystem().registerPreference("ClipCaulk", BoolImportStringCaller(g_clip_useCaulk), BoolExportStringCaller(g_clip_useCaulk)); @@ -2930,10 +2992,6 @@ 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_Colors9", Vector3ImportStringCaller(g_xywindow_globals.color_selbrushes), Vector3ExportStringCaller(g_xywindow_globals.color_selbrushes)); - 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_viewname), Vector3ExportStringCaller(g_xywindow_globals.color_viewname)); - GlobalPreferenceSystem().registerPreference("SI_Colors13", Vector3ImportStringCaller(g_xywindow_globals.color_gridminor_alt), Vector3ExportStringCaller(g_xywindow_globals.color_gridminor_alt)); GlobalPreferenceSystem().registerPreference("SI_Colors14", Vector3ImportStringCaller(g_xywindow_globals.color_gridmajor_alt), Vector3ExportStringCaller(g_xywindow_globals.color_gridmajor_alt));