2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #if !defined( INCLUDED_XYWINDOW_H )
23 #define INCLUDED_XYWINDOW_H
25 #include "math/matrix.h"
26 #include "signal/signal.h"
28 #include "gtkutil/cursor.h"
29 #include "gtkutil/window.h"
30 #include "gtkutil/xorrectangle.h"
33 #include "texturelib.h"
35 #include "qerplugin.h"
39 class SelectionSystemWindowObserver;
51 void OnClipMode(bool enabled);
55 inline const char *ViewType_getTitle(VIEWTYPE viewtype)
75 ui::GLArea m_gl_widget;
77 guint m_exposeHandler;
79 DeferredDraw m_deferredDraw;
80 DeferredMotion m_deferred_motion;
84 XYWnd(OpenGLBinding &GL);
90 m_deferredDraw.draw();
93 ui::GLArea GetWidget()
99 SelectionSystemWindowObserver *m_window_observer;
100 XORRectangle m_XORRectangle;
101 WindowPositionTracker m_positionTracker;
103 static void captureStates();
105 static void releaseStates();
107 void PositionView(const Vector3 &position);
109 const Vector3 &GetOrigin();
111 void SetOrigin(const Vector3 &origin);
113 void Scroll(int x, int y);
117 void DrawCameraIcon(const Vector3 &origin, const Vector3 &angles);
119 void XY_DrawBlockGrid();
125 void XY_DrawBackground();
127 void XY_LoadBackgroundImage(const char *name);
129 void XY_DisableBackground();
131 void XY_MouseUp(int x, int y, unsigned int buttons);
133 void XY_MouseDown(int x, int y, unsigned int buttons);
135 void XY_MouseMoved(int x, int y, unsigned int buttons);
137 void NewBrushDrag_Begin(int x, int y);
139 void NewBrushDrag(int x, int y);
141 void NewBrushDrag_End(int x, int y);
143 void XY_ToPoint(int x, int y, Vector3 &point);
145 void XY_SnapToGrid(Vector3 &point);
152 guint m_move_focusOut;
159 guint m_zoom_focusOut;
161 void SetActive(bool b)
171 void Clipper_OnLButtonDown(int x, int y);
173 void Clipper_OnLButtonUp(int x, int y);
175 void Clipper_OnMouseMoved(int x, int y);
177 void Clipper_Crosshair_OnMouseMoved(int x, int y);
179 void DropClipPoint(int pointx, int pointy);
181 void SetViewType(VIEWTYPE n);
185 static ui::Menu m_mnuDrop;
187 int m_chasemouse_current_x, m_chasemouse_current_y;
188 int m_chasemouse_delta_x, m_chasemouse_delta_y;
191 guint m_chasemouse_handler;
195 bool chaseMouseMotion(int pointx, int pointy);
197 void updateModelview();
199 void updateProjection();
201 Matrix4 m_projection;
206 // background image stuff
208 bool m_backgroundActivated;
209 float m_alpha; // vertex alpha
210 float m_xmin, m_ymin, m_xmax, m_ymax;
217 static Shader *m_state_selected;
219 int m_ptCursorX, m_ptCursorY;
221 unsigned int m_buttonstate;
223 int m_nNewBrushPressx;
224 int m_nNewBrushPressy;
225 scene::Node *m_NewBrushDrag;
226 bool m_bNewBrushDrag;
228 Vector3 m_mousePosition;
232 void OriginalButtonUp(guint32 nFlags, int point, int pointy);
234 void OriginalButtonDown(guint32 nFlags, int point, int pointy);
236 void OnContextMenu();
238 void PaintSizeInfo(int nDim1, int nDim2, Vector3 &vMinBounds, Vector3 &vMaxBounds);
240 int m_entityCreate_x, m_entityCreate_y;
244 void ButtonState_onMouseDown(unsigned int buttons)
246 m_buttonstate |= buttons;
249 void ButtonState_onMouseUp(unsigned int buttons)
251 m_buttonstate &= ~buttons;
254 unsigned int getButtonState() const
256 return m_buttonstate;
259 void EntityCreate_MouseDown(int x, int y);
261 void EntityCreate_MouseMove(int x, int y);
263 void EntityCreate_MouseUp(int x, int y);
265 void OnEntityCreate(const char *item);
267 VIEWTYPE GetViewType()
272 void SetScale(float f);
290 Signal3<const WindowVector &, ButtonIdentifier, ModifierFlags> onMouseDown;
292 void mouseDown(const WindowVector &position, ButtonIdentifier button, ModifierFlags modifiers);
294 typedef Member<XYWnd, void(const WindowVector &, ButtonIdentifier,
295 ModifierFlags), &XYWnd::mouseDown> MouseDownCaller;
298 inline void XYWnd_Update(XYWnd &xywnd)
304 struct xywindow_globals_t {
305 Vector3 color_gridback;
306 Vector3 color_gridminor;
307 Vector3 color_gridmajor;
308 Vector3 color_gridblock;
309 Vector3 color_gridtext;
310 Vector3 color_brushes;
311 Vector3 color_selbrushes;
312 Vector3 color_clipper;
313 Vector3 color_viewname;
314 Vector3 color_gridminor_alt;
315 Vector3 color_gridmajor_alt;
323 xywindow_globals_t() :
324 color_gridback(1.f, 1.f, 1.f),
325 color_gridminor(0.75f, 0.75f, 0.75f),
326 color_gridmajor(0.5f, 0.5f, 0.5f),
327 color_gridblock(0.f, 0.f, 1.f),
328 color_gridtext(0.f, 0.f, 0.f),
329 color_brushes(0.f, 0.f, 0.f),
330 color_selbrushes(1.f, 0.f, 0.f),
331 color_clipper(0.f, 0.f, 1.f),
332 color_viewname(0.5f, 0.f, 0.75f),
333 color_gridminor_alt(0.f, 0.f, 0.f),
334 color_gridmajor_alt(0.f, 0.f, 0.f),
336 AxisColorX(1.f, 0.f, 0.f),
337 AxisColorY(0.f, 1.f, 0.f),
338 AxisColorZ(0.f, 0.f, 1.f),
346 extern xywindow_globals_t g_xywindow_globals;
349 VIEWTYPE GlobalXYWnd_getCurrentViewType();
351 void XY_Top_Shown_Construct(ui::Window parent);
353 void YZ_Side_Shown_Construct(ui::Window parent);
355 void XZ_Front_Shown_Construct(ui::Window parent);
357 void XYWindow_Construct();
359 void XYWindow_Destroy();
363 void WXY_BackgroundSelect();
365 void XYShow_registerCommands();
367 void XYWnd_registerShortcuts();