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;
48 void OnClipMode( bool enabled );
51 inline const char* ViewType_getTitle( VIEWTYPE viewtype ){
52 if ( viewtype == XY ) {
55 if ( viewtype == XZ ) {
58 if ( viewtype == YZ ) {
66 ui::GLArea m_gl_widget;
68 guint m_exposeHandler;
70 DeferredDraw m_deferredDraw;
71 DeferredMotion m_deferred_motion;
78 m_deferredDraw.draw();
80 ui::GLArea GetWidget(){
85 SelectionSystemWindowObserver* m_window_observer;
86 XORRectangle m_XORRectangle;
87 WindowPositionTracker m_positionTracker;
89 static void captureStates();
90 static void releaseStates();
92 void PositionView( const Vector3& position );
93 const Vector3& GetOrigin();
94 void SetOrigin( const Vector3& origin );
95 void Scroll( int x, int y );
98 void DrawCameraIcon( const Vector3& origin, const Vector3& angles );
99 void XY_DrawBlockGrid();
102 void XY_DrawBackground();
103 void XY_LoadBackgroundImage( const char *name );
104 void XY_DisableBackground();
106 void XY_MouseUp( int x, int y, unsigned int buttons );
107 void XY_MouseDown( int x, int y, unsigned int buttons );
108 void XY_MouseMoved( int x, int y, unsigned int buttons );
110 void NewBrushDrag_Begin( int x, int y );
111 void NewBrushDrag( int x, int y );
112 void NewBrushDrag_End( int x, int y );
114 void XY_ToPoint( int x, int y, Vector3& point );
115 void XY_SnapToGrid( Vector3& point );
120 guint m_move_focusOut;
125 guint m_zoom_focusOut;
129 void ZoomInWithMouse( int pointx, int pointy );
135 void SetActive( bool b ){
143 void Clipper_OnLButtonDown( int x, int y );
144 void Clipper_OnLButtonUp( int x, int y );
145 void Clipper_OnMouseMoved( int x, int y );
146 void Clipper_Crosshair_OnMouseMoved( int x, int y );
147 void DropClipPoint( int pointx, int pointy );
149 void SetCustomPivotOrigin( int pointx, int pointy );
151 void SetViewType( VIEWTYPE n );
154 static ui::Menu m_mnuDrop;
156 int m_chasemouse_current_x, m_chasemouse_current_y;
157 int m_chasemouse_delta_x, m_chasemouse_delta_y;
160 guint m_chasemouse_handler;
162 bool chaseMouseMotion( int pointx, int pointy );
164 void updateModelview(bool reconstruct = true);
165 void updateProjection(bool reconstruct = true);
166 Matrix4 m_projection;
171 // background image stuff
173 bool m_backgroundActivated;
174 float m_alpha; // vertex alpha
175 float m_xmin, m_ymin, m_xmax, m_ymax;
182 static Shader* m_state_selected;
184 int m_ptCursorX, m_ptCursorY;
186 unsigned int m_buttonstate;
188 int m_nNewBrushPressx;
189 int m_nNewBrushPressy;
190 scene::Node* m_NewBrushDrag;
191 bool m_bNewBrushDrag;
193 Vector3 m_mousePosition;
197 void OriginalButtonUp( guint32 nFlags, int point, int pointy );
198 void OriginalButtonDown( guint32 nFlags, int point, int pointy );
200 void OnContextMenu();
201 void PaintSizeInfo( int nDim1, int nDim2, Vector3& vMinBounds, Vector3& vMaxBounds );
203 int m_entityCreate_x, m_entityCreate_y;
207 void ButtonState_onMouseDown( unsigned int buttons ){
208 m_buttonstate |= buttons;
210 void ButtonState_onMouseUp( unsigned int buttons ){
211 m_buttonstate &= ~buttons;
213 unsigned int getButtonState() const {
214 return m_buttonstate;
216 void EntityCreate_MouseDown( int x, int y );
217 void EntityCreate_MouseMove( int x, int y );
218 void EntityCreate_MouseUp( int x, int y );
220 void OnEntityCreate( const char* item );
221 VIEWTYPE GetViewType(){
224 void SetScale( float f );
236 Signal3<const WindowVector&, ButtonIdentifier, ModifierFlags> onMouseDown;
237 void mouseDown( const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers );
238 typedef Member<XYWnd, void(const WindowVector&, ButtonIdentifier, ModifierFlags), &XYWnd::mouseDown> MouseDownCaller;
241 inline void XYWnd_Update( XYWnd& xywnd ){
246 struct xywindow_globals_t
248 Vector3 color_gridback;
249 Vector3 color_gridminor;
250 Vector3 color_gridmajor;
251 Vector3 color_gridblock;
252 Vector3 color_gridtext;
253 Vector3 color_brushes;
254 Vector3 color_selbrushes;
255 Vector3 color_clipper;
256 Vector3 color_viewname;
257 Vector3 color_gridminor_alt;
258 Vector3 color_gridmajor_alt;
265 bool m_bImprovedWheelZoom;
267 xywindow_globals_t() :
268 color_gridback( 0.77f, 0.77f, 0.77f ),
269 color_gridminor( 0.83f, 0.83f, 0.83f ),
270 color_gridmajor( 0.89f, 0.89f, 0.89f ),
271 color_gridblock( 1.0f, 1.0f, 1.0f ),
272 color_gridtext( 0.f, 0.f, 0.f ),
273 color_brushes( 0.f, 0.f, 0.f ),
274 color_selbrushes( 1.f, 0.f, 0.f ),
275 color_clipper( 0.f, 0.f, 1.f ),
276 color_viewname( 0.5f, 0.f, 0.75f ),
277 color_gridminor_alt( 0.f, 0.f, 0.f ),
278 color_gridmajor_alt( 0.f, 0.f, 0.f ),
280 AxisColorX( 1.f, 0.f, 0.f ),
281 AxisColorY( 0.f, 1.f, 0.f ),
282 AxisColorZ( 0.f, 0.f, 1.f ),
283 m_bRightClick( true ),
284 m_bNoStipple( true ),
285 m_bImprovedWheelZoom( true ){
290 extern xywindow_globals_t g_xywindow_globals;
293 VIEWTYPE GlobalXYWnd_getCurrentViewType();
295 void XY_Top_Shown_Construct( ui::Window parent );
296 void YZ_Side_Shown_Construct( ui::Window parent );
297 void XZ_Front_Shown_Construct( ui::Window parent );
299 void XYWindow_Construct();
300 void XYWindow_Destroy();
303 void WXY_BackgroundSelect();
305 void XYShow_registerCommands();
306 void XYWnd_registerShortcuts();