X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fxywindow.cpp;h=b59384bc435721986f1fe93c1fbcea7b2c35850a;hb=48e07ba5f5d55250e7cc77ee92fdebe2697f57ee;hp=d80787d60681ea32d65b1b6ede374bfda267ae9d;hpb=24230bb3a8b7c4b0451f0ec84a278d78bb695a8e;p=xonotic%2Fnetradiant.git diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index d80787d6..b59384bc 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -40,6 +40,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "generic/callback.h" #include "string/string.h" #include "stream/stringstream.h" + #include "scenelib.h" #include "eclasslib.h" #include "renderer.h" @@ -422,6 +423,29 @@ inline ModifierFlags modifiers_for_flags(unsigned int flags) return modifiers; } +inline unsigned int buttons_for_button_and_modifiers(ButtonIdentifier button, ModifierFlags flags) +{ + unsigned int buttons = 0; + + switch (button.get()) + { + case ButtonEnumeration::LEFT: buttons |= RAD_LBUTTON; break; + case ButtonEnumeration::MIDDLE: buttons |= RAD_MBUTTON; break; + case ButtonEnumeration::RIGHT: buttons |= RAD_RBUTTON; break; + } + + if(bitfield_enabled(flags, c_modifierControl)) + buttons |= RAD_CONTROL; + + if(bitfield_enabled(flags, c_modifierShift)) + buttons |= RAD_SHIFT; + + if(bitfield_enabled(flags, c_modifierAlt)) + buttons |= RAD_ALT; + + return buttons; +} + inline unsigned int buttons_for_event_button(GdkEventButton* event) { unsigned int flags = 0; @@ -474,6 +498,7 @@ inline unsigned int buttons_for_state(guint state) void XYWnd::SetScale(float f) { m_fScale = f; + updateProjection(); updateModelview(); XYWnd_Update(*this); } @@ -722,7 +747,11 @@ gboolean xywnd_button_press(GtkWidget* widget, GdkEventButton* event, XYWnd* xyw { if(event->type == GDK_BUTTON_PRESS) { - xywnd->XY_MouseDown(static_cast(event->x), static_cast(event->y), buttons_for_event_button(event)); + g_pParentWnd->SetActiveXY(xywnd); + + xywnd->ButtonState_onMouseDown(buttons_for_event_button(event)); + + xywnd->onMouseDown(WindowVector(event->x, event->y), button_for_button(event->button), modifiers_for_state(event->state)); } return FALSE; } @@ -732,6 +761,8 @@ gboolean xywnd_button_release(GtkWidget* widget, GdkEventButton* event, XYWnd* x if(event->type == GDK_BUTTON_RELEASE) { xywnd->XY_MouseUp(static_cast(event->x), static_cast(event->y), buttons_for_event_button(event)); + + xywnd->ButtonState_onMouseUp(buttons_for_event_button(event)); } return FALSE; } @@ -844,16 +875,21 @@ XYWnd::XYWnd() : Map_addValidCallback(g_map, DeferredDrawOnMapValidChangedCaller(m_deferredDraw)); + updateProjection(); updateModelview(); AddSceneChangeCallback(ReferenceCaller(*this)); AddCameraMovedCallback(ReferenceCaller(*this)); PressedButtons_connect(g_pressedButtons, m_gl_widget); + + onMouseDown.connectLast(makeSignalHandler3(MouseDownCaller(), *this)); } XYWnd::~XYWnd() { + onDestroyed(); + if(m_mnuDrop != 0) { gtk_widget_destroy(GTK_WIDGET(m_mnuDrop)); @@ -1152,7 +1188,7 @@ public: { popMenu(); } - pushMenu(CopiedString(name, underscore)); + pushMenu(CopiedString(StringRange(name, underscore))); } else if(m_stack.size() == 2) { @@ -1306,12 +1342,12 @@ inline WindowVector WindowVector_forInteger(int x, int y) return WindowVector(static_cast(x), static_cast(y)); } +void XYWnd::mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers) +{ + XY_MouseDown(static_cast(position.x()), static_cast(position.y()), buttons_for_button_and_modifiers(button, modifiers)); +} void XYWnd::XY_MouseDown (int x, int y, unsigned int buttons) { - g_pParentWnd->SetActiveXY(this); - - ButtonState_onMouseDown(buttons); - if(buttons == Move_buttons()) { Move_Begin(); @@ -1369,8 +1405,6 @@ void XYWnd::XY_MouseUp(int x, int y, unsigned int buttons) { m_window_observer->onMouseUp(WindowVector_forInteger(x, y), button_for_flags(buttons), modifiers_for_flags(buttons)); } - - ButtonState_onMouseUp(buttons); } void XYWnd::XY_MouseMoved (int x, int y, unsigned int buttons) @@ -2086,7 +2120,7 @@ void XYWnd::updateProjection() { m_projection[0] = 1.0f / static_cast(m_nWidth / 2); m_projection[5] = 1.0f / static_cast(m_nHeight / 2); - m_projection[10] = 1.0f / g_MaxWorldCoord; + m_projection[10] = 1.0f / (g_MaxWorldCoord * m_fScale); m_projection[12] = 0.0f; m_projection[13] = 0.0f; @@ -2109,6 +2143,7 @@ void XYWnd::updateProjection() 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. void XYWnd::updateModelview() { int nDim1 = (m_viewType == YZ) ? 1 : 0; @@ -2117,7 +2152,7 @@ void XYWnd::updateModelview() // translation m_modelview[12] = -m_vOrigin[nDim1] * m_fScale; m_modelview[13] = -m_vOrigin[nDim2] * m_fScale; - m_modelview[14] = static_cast(g_MaxWorldCoord); + m_modelview[14] = g_MaxWorldCoord * m_fScale; // axis base switch(m_viewType) @@ -2133,7 +2168,7 @@ void XYWnd::updateModelview() m_modelview[8] = 0; m_modelview[9] = 0; - m_modelview[10] = -1.0; + m_modelview[10] = -m_fScale; break; case XZ: m_modelview[0] = m_fScale; @@ -2142,7 +2177,7 @@ void XYWnd::updateModelview() m_modelview[4] = 0; m_modelview[5] = 0; - m_modelview[6] = 1.0; + m_modelview[6] = m_fScale; m_modelview[8] = 0; m_modelview[9] = m_fScale; @@ -2151,7 +2186,7 @@ void XYWnd::updateModelview() case YZ: m_modelview[0] = 0; m_modelview[1] = 0; - m_modelview[2] = -1.0; + m_modelview[2] = -m_fScale; m_modelview[4] = m_fScale; m_modelview[5] = 0; @@ -2219,7 +2254,7 @@ void XYWnd::XY_Draw() glLoadMatrixf(reinterpret_cast(&m_modelview)); - unsigned int globalstate = RENDER_COLOUR | RENDER_COLOURWRITE; + unsigned int globalstate = RENDER_COLOURARRAY | RENDER_COLOURWRITE | RENDER_POLYGONSMOOTH | RENDER_LINESMOOTH; if(!g_xywindow_globals.m_bNoStipple) { globalstate |= RENDER_LINESTIPPLE;