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)
70 ui::GLArea m_gl_widget;
72 guint m_exposeHandler;
74 DeferredDraw m_deferredDraw;
75 DeferredMotion m_deferred_motion;
85 m_deferredDraw.draw();
88 ui::GLArea GetWidget()
94 SelectionSystemWindowObserver *m_window_observer;
95 XORRectangle m_XORRectangle;
96 WindowPositionTracker m_positionTracker;
98 static void captureStates();
100 static void releaseStates();
102 void PositionView(const Vector3 &position);
104 const Vector3 &GetOrigin();
106 void SetOrigin(const Vector3 &origin);
108 void Scroll(int x, int y);
112 void DrawCameraIcon(const Vector3 &origin, const Vector3 &angles);
114 void XY_DrawBlockGrid();
120 void XY_DrawBackground();
122 void XY_LoadBackgroundImage(const char *name);
124 void XY_DisableBackground();
126 void XY_MouseUp(int x, int y, unsigned int buttons);
128 void XY_MouseDown(int x, int y, unsigned int buttons);
130 void XY_MouseMoved(int x, int y, unsigned int buttons);
132 void NewBrushDrag_Begin(int x, int y);
134 void NewBrushDrag(int x, int y);
136 void NewBrushDrag_End(int x, int y);
138 void XY_ToPoint(int x, int y, Vector3 &point);
140 void XY_SnapToGrid(Vector3 &point);
147 guint m_move_focusOut;
154 guint m_zoom_focusOut;
156 void SetActive(bool b)
166 void Clipper_OnLButtonDown(int x, int y);
168 void Clipper_OnLButtonUp(int x, int y);
170 void Clipper_OnMouseMoved(int x, int y);
172 void Clipper_Crosshair_OnMouseMoved(int x, int y);
174 void DropClipPoint(int pointx, int pointy);
176 void SetViewType(VIEWTYPE n);
180 static ui::Menu m_mnuDrop;
182 int m_chasemouse_current_x, m_chasemouse_current_y;
183 int m_chasemouse_delta_x, m_chasemouse_delta_y;
186 guint m_chasemouse_handler;
190 bool chaseMouseMotion(int pointx, int pointy);
192 void updateModelview();
194 void updateProjection();
196 Matrix4 m_projection;
201 // background image stuff
203 bool m_backgroundActivated;
204 float m_alpha; // vertex alpha
205 float m_xmin, m_ymin, m_xmax, m_ymax;
212 static Shader *m_state_selected;
214 int m_ptCursorX, m_ptCursorY;
216 unsigned int m_buttonstate;
218 int m_nNewBrushPressx;
219 int m_nNewBrushPressy;
220 scene::Node *m_NewBrushDrag;
221 bool m_bNewBrushDrag;
223 Vector3 m_mousePosition;
227 void OriginalButtonUp(guint32 nFlags, int point, int pointy);
229 void OriginalButtonDown(guint32 nFlags, int point, int pointy);
231 void OnContextMenu();
233 void PaintSizeInfo(int nDim1, int nDim2, Vector3 &vMinBounds, Vector3 &vMaxBounds);
235 int m_entityCreate_x, m_entityCreate_y;
239 void ButtonState_onMouseDown(unsigned int buttons)
241 m_buttonstate |= buttons;
244 void ButtonState_onMouseUp(unsigned int buttons)
246 m_buttonstate &= ~buttons;
249 unsigned int getButtonState() const
251 return m_buttonstate;
254 void EntityCreate_MouseDown(int x, int y);
256 void EntityCreate_MouseMove(int x, int y);
258 void EntityCreate_MouseUp(int x, int y);
260 void OnEntityCreate(const char *item);
262 VIEWTYPE GetViewType()
267 void SetScale(float f);
285 Signal3<const WindowVector &, ButtonIdentifier, ModifierFlags> onMouseDown;
287 void mouseDown(const WindowVector &position, ButtonIdentifier button, ModifierFlags modifiers);
289 typedef Member<XYWnd, void(const WindowVector &, ButtonIdentifier,
290 ModifierFlags), &XYWnd::mouseDown> MouseDownCaller;
293 inline void XYWnd_Update(XYWnd &xywnd)
299 struct xywindow_globals_t {
300 Vector3 color_gridback;
301 Vector3 color_gridminor;
302 Vector3 color_gridmajor;
303 Vector3 color_gridblock;
304 Vector3 color_gridtext;
305 Vector3 color_brushes;
306 Vector3 color_selbrushes;
307 Vector3 color_clipper;
308 Vector3 color_viewname;
309 Vector3 color_gridminor_alt;
310 Vector3 color_gridmajor_alt;
318 xywindow_globals_t() :
319 color_gridback(1.f, 1.f, 1.f),
320 color_gridminor(0.75f, 0.75f, 0.75f),
321 color_gridmajor(0.5f, 0.5f, 0.5f),
322 color_gridblock(0.f, 0.f, 1.f),
323 color_gridtext(0.f, 0.f, 0.f),
324 color_brushes(0.f, 0.f, 0.f),
325 color_selbrushes(1.f, 0.f, 0.f),
326 color_clipper(0.f, 0.f, 1.f),
327 color_viewname(0.5f, 0.f, 0.75f),
328 color_gridminor_alt(0.f, 0.f, 0.f),
329 color_gridmajor_alt(0.f, 0.f, 0.f),
331 AxisColorX(1.f, 0.f, 0.f),
332 AxisColorY(0.f, 1.f, 0.f),
333 AxisColorZ(0.f, 0.f, 1.f),
341 extern xywindow_globals_t g_xywindow_globals;
344 VIEWTYPE GlobalXYWnd_getCurrentViewType();
346 void XY_Top_Shown_Construct(ui::Window parent);
348 void YZ_Side_Shown_Construct(ui::Window parent);
350 void XZ_Front_Shown_Construct(ui::Window parent);
352 void XYWindow_Construct();
354 void XYWindow_Destroy();
358 void WXY_BackgroundSelect();
360 void XYShow_registerCommands();
362 void XYWnd_registerShortcuts();