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"
38 class SelectionSystemWindowObserver;
43 typedef struct _GtkWindow GtkWindow;
44 typedef struct _GtkMenu GtkMenu;
50 void OnClipMode( bool enabled );
53 inline const char* ViewType_getTitle( VIEWTYPE viewtype ){
54 if ( viewtype == XY ) {
57 if ( viewtype == XZ ) {
60 if ( viewtype == YZ ) {
68 GtkWidget* m_gl_widget;
70 guint m_exposeHandler;
72 DeferredDraw m_deferredDraw;
73 DeferredMotion m_deferred_motion;
80 m_deferredDraw.draw();
82 GtkWidget* GetWidget(){
87 SelectionSystemWindowObserver* m_window_observer;
88 XORRectangle m_XORRectangle;
89 WindowPositionTracker m_positionTracker;
91 static void captureStates();
92 static void releaseStates();
94 void PositionView( const Vector3& position );
95 const Vector3& GetOrigin();
96 void SetOrigin( const Vector3& origin );
97 void Scroll( int x, int y );
100 void DrawCameraIcon( const Vector3& origin, const Vector3& angles );
101 void XY_DrawBlockGrid();
104 void XY_DrawBackground();
105 void XY_LoadBackgroundImage( const char *name );
106 void XY_DisableBackground();
108 void XY_MouseUp( int x, int y, unsigned int buttons );
109 void XY_MouseDown( int x, int y, unsigned int buttons );
110 void XY_MouseMoved( int x, int y, unsigned int buttons );
112 void NewBrushDrag_Begin( int x, int y );
113 void NewBrushDrag( int x, int y );
114 void NewBrushDrag_End( int x, int y );
116 void XY_ToPoint( int x, int y, Vector3& point );
117 void XY_SnapToGrid( Vector3& point );
122 guint m_move_focusOut;
127 guint m_zoom_focusOut;
129 void SetActive( bool b ){
136 void Clipper_OnLButtonDown( int x, int y );
137 void Clipper_OnLButtonUp( int x, int y );
138 void Clipper_OnMouseMoved( int x, int y );
139 void Clipper_Crosshair_OnMouseMoved( int x, int y );
140 void DropClipPoint( int pointx, int pointy );
142 void SetViewType( VIEWTYPE n );
145 static GtkMenu* m_mnuDrop;
147 int m_chasemouse_current_x, m_chasemouse_current_y;
148 int m_chasemouse_delta_x, m_chasemouse_delta_y;
151 guint m_chasemouse_handler;
153 bool chaseMouseMotion( int pointx, int pointy );
155 void updateModelview();
156 void updateProjection();
157 Matrix4 m_projection;
162 // background image stuff
164 bool m_backgroundActivated;
165 float m_alpha; // vertex alpha
166 float m_xmin, m_ymin, m_xmax, m_ymax;
173 static Shader* m_state_selected;
175 int m_ptCursorX, m_ptCursorY;
177 unsigned int m_buttonstate;
179 int m_nNewBrushPressx;
180 int m_nNewBrushPressy;
181 scene::Node* m_NewBrushDrag;
182 bool m_bNewBrushDrag;
184 Vector3 m_mousePosition;
188 void OriginalButtonUp( guint32 nFlags, int point, int pointy );
189 void OriginalButtonDown( guint32 nFlags, int point, int pointy );
191 void OnContextMenu();
192 void PaintSizeInfo( int nDim1, int nDim2, Vector3& vMinBounds, Vector3& vMaxBounds );
194 int m_entityCreate_x, m_entityCreate_y;
198 void ButtonState_onMouseDown( unsigned int buttons ){
199 m_buttonstate |= buttons;
201 void ButtonState_onMouseUp( unsigned int buttons ){
202 m_buttonstate &= ~buttons;
204 unsigned int getButtonState() const {
205 return m_buttonstate;
207 void EntityCreate_MouseDown( int x, int y );
208 void EntityCreate_MouseMove( int x, int y );
209 void EntityCreate_MouseUp( int x, int y );
211 void OnEntityCreate( const char* item );
212 VIEWTYPE GetViewType(){
215 void SetScale( float f );
227 Signal3<const WindowVector&, ButtonIdentifier, ModifierFlags> onMouseDown;
228 void mouseDown( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers );
229 typedef Member3<XYWnd, const WindowVector&, ButtonIdentifier, ModifierFlags, void, &XYWnd::mouseDown> MouseDownCaller;
232 inline void XYWnd_Update( XYWnd& xywnd ){
237 struct xywindow_globals_t
239 Vector3 color_gridback;
240 Vector3 color_gridminor;
241 Vector3 color_gridmajor;
242 Vector3 color_gridblock;
243 Vector3 color_gridtext;
244 Vector3 color_brushes;
245 Vector3 color_selbrushes;
246 Vector3 color_clipper;
247 Vector3 color_viewname;
248 Vector3 color_gridminor_alt;
249 Vector3 color_gridmajor_alt;
257 xywindow_globals_t() :
258 color_gridback( 1.f, 1.f, 1.f ),
259 color_gridminor( 0.75f, 0.75f, 0.75f ),
260 color_gridmajor( 0.5f, 0.5f, 0.5f ),
261 color_gridblock( 0.f, 0.f, 1.f ),
262 color_gridtext( 0.f, 0.f, 0.f ),
263 color_brushes( 0.f, 0.f, 0.f ),
264 color_selbrushes( 1.f, 0.f, 0.f ),
265 color_clipper( 0.f, 0.f, 1.f ),
266 color_viewname( 0.5f, 0.f, 0.75f ),
267 color_gridminor_alt( 0.f, 0.f, 0.f ),
268 color_gridmajor_alt( 0.f, 0.f, 0.f ),
270 AxisColorX( 1.f, 0.f, 0.f ),
271 AxisColorY( 0.f, 1.f, 0.f ),
272 AxisColorZ( 0.f, 0.f, 1.f ),
273 m_bRightClick( true ),
274 m_bNoStipple( false ){
279 extern xywindow_globals_t g_xywindow_globals;
282 VIEWTYPE GlobalXYWnd_getCurrentViewType();
284 typedef struct _GtkWindow GtkWindow;
285 void XY_Top_Shown_Construct( GtkWindow* parent );
286 void YZ_Side_Shown_Construct( GtkWindow* parent );
287 void XZ_Front_Shown_Construct( GtkWindow* parent );
289 void XYWindow_Construct();
290 void XYWindow_Destroy();
293 void WXY_BackgroundSelect();
295 void XYShow_registerCommands();
296 void XYWnd_registerShortcuts();