]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/xywindow.h
Merge pull request #19 from merlin1991/scons-update
[xonotic/netradiant.git] / radiant / xywindow.h
index 317ec591ae0fb7af27f8a1c51c2e0df1f256466d..31bfbedad42ac096a23b892af192183587009e25 100644 (file)
 /*
-Copyright (C) 1999-2006 Id Software, Inc. and contributors.
-For a list of contributors, see the accompanying CONTRIBUTORS file.
+   Copyright (C) 1999-2007 id Software, Inc. and contributors.
+   For a list of contributors, see the accompanying CONTRIBUTORS file.
 
-This file is part of GtkRadiant.
+   This file is part of GtkRadiant.
 
-GtkRadiant is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-GtkRadiant is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   GtkRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with GtkRadiant; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
-#if !defined(INCLUDED_XYWINDOW_H)
-#define INCLUDED_XYWINDOW_H
+#ifndef _XYWINDOW_H_
+#define _XYWINDOW_H_
 
-#include "math/matrix.h"
-#include "signal/signal.h"
+#include "qe3.h"
+#include "camwindow.h"
+#include "glwindow.h"
 
-#include "gtkutil/cursor.h"
-#include "gtkutil/window.h"
-#include "gtkutil/xorrectangle.h"
-#include "view.h"
-#include "map.h"
+const int SCALE_X = 0x01;
+const int SCALE_Y = 0x02;
+const int SCALE_Z = 0x04;
 
-#include "qerplugin.h"
-
-class Shader;
-class SelectionSystemWindowObserver;
-namespace scene
+typedef void ( PFNPathCallback )( bool, int );
+// as i didn't really encapsulate anything this
+// should really be a struct..
+class ClipPoint
 {
-  class Node;
-}
-typedef struct _GtkWindow GtkWindow;
-typedef struct _GtkMenu GtkMenu;
-
-
-void FlipClip();
-void SplitClip();
-void Clip();
-void OnClipMode(bool enabled);
-bool ClipMode();
+public:
+ClipPoint(){ Reset(); };
+void Reset(){ m_ptClip[0] = m_ptClip[1] = m_ptClip[2] = 0.0; m_bSet = false; m_pVec3 = NULL; };
+bool Set(){ return m_bSet; };
+void Set( bool b ) { m_bSet = b; };
+void UpdatePointPtr() {
+       if ( m_pVec3 ) {
+               VectorCopy( m_ptClip, *m_pVec3 );
+       }
+};
+void SetPointPtr( vec3_t* p ) { m_pVec3 = p; };
+vec3_t m_ptClip;        // the 3d point
+vec3_t* m_pVec3;        // optional ptr for 3rd party updates
+int m_ptScreenX, m_ptScreenY;      // the onscreen xy point (for mousability)
+bool m_bSet;
+operator vec3_t&() {
+       return m_ptClip;
+};
+operator vec3_t*() {
+       return &m_ptClip;
+};
 
-inline const char* ViewType_getTitle(VIEWTYPE viewtype)
-{
-  if(viewtype == XY)
-  {
-    return "XY Top";
-  }
-  if(viewtype == XZ)
-  {
-    return "XZ Front";
-  }
-  if(viewtype == YZ)
-  {
-    return "YZ Side";
-  }
-  return "";
-}
+/*! Draw clip/path point with rasterized number label */
+void Draw( float fScale, int num );
+/*! Draw clip/path point with rasterized string label */
+void Draw( float fScale, const char *label );
+};
 
-class XYWnd
+class XYWnd : public GLWindow
 {
-  GtkWidget* m_gl_widget;
-  guint m_sizeHandler;
-  guint m_exposeHandler;
-
-  DeferredDraw m_deferredDraw;
-  DeferredMotion m_deferred_motion;
 public:
-  GtkWindow* m_parent;
-  XYWnd();
-  ~XYWnd();
-
-  void queueDraw()
-  {
-    m_deferredDraw.draw();
-  }
-  GtkWidget* GetWidget()
-  {
-    return m_gl_widget;
-  }
+XYWnd();
+virtual ~XYWnd() { }
 
 public:
-  SelectionSystemWindowObserver* m_window_observer;
-  XORRectangle m_XORRectangle;
-  WindowPositionTracker m_positionTracker;
-
-  static void captureStates();
-  static void releaseStates();
-
-  void PositionView(const Vector3& position);
-  const Vector3& GetOrigin();
-  void SetOrigin(const Vector3& origin);
-  void Scroll(int x, int y);
-
-  void XY_Draw();
-  void DrawCameraIcon(const Vector3& origin, const Vector3& angles);
-  void XY_DrawBlockGrid();
-  void XY_DrawGrid();
-
-  void XY_MouseUp(int x, int y, unsigned int buttons);
-  void XY_MouseDown(int x, int y, unsigned int buttons);
-  void XY_MouseMoved(int x, int y, unsigned int buttons);
-
-  void NewBrushDrag_Begin(int x, int y);
-  void NewBrushDrag(int x, int y);
-  void NewBrushDrag_End(int x, int y);
-
-  void XY_ToPoint(int x, int y, Vector3& point);
-  void XY_SnapToGrid(Vector3& point);
-
-  void Move_Begin();
-  void Move_End();
-  bool m_move_started;
-  guint m_move_focusOut;
-
-  void Zoom_Begin();
-  void Zoom_End();
-  bool m_zoom_started;
-  guint m_zoom_focusOut;
-
-  void SetActive(bool b)
-  {
-    m_bActive = b;
-  };
-  bool Active()
-  {
-    return m_bActive;
-  };
-
-  void Clipper_OnLButtonDown(int x, int y);
-  void Clipper_OnLButtonUp(int x, int y);
-  void Clipper_OnMouseMoved(int x, int y);
-  void Clipper_Crosshair_OnMouseMoved(int x, int y);
-  void DropClipPoint(int pointx, int pointy);
-
-  void SetViewType(VIEWTYPE n);
-  bool m_bActive;
-
-  static GtkMenu* m_mnuDrop;
-
-  int m_chasemouse_current_x, m_chasemouse_current_y;
-  int m_chasemouse_delta_x, m_chasemouse_delta_y;
-  
-
-  guint m_chasemouse_handler;
-  void ChaseMouse();
-  bool chaseMouseMotion(int pointx, int pointy);
-
-  void updateModelview();
-  void updateProjection();
-  Matrix4 m_projection;
-  Matrix4 m_modelview;
+bool AreaSelectOK();
+vec3_t& RotateOrigin();
+vec3_t& Rotation();
+void UndoClear();
+bool UndoAvailable();
+void KillPathMode();
+void Undo();
+void UndoCopy();
+void Copy();
+void Paste();
+void Redraw( unsigned int nBits );
+void VectorCopyXY( vec3_t in, vec3_t out );
+void PositionView();
+void FlipClip();
+void SplitClip();
+void Clip();
+vec3_t& GetOrigin();
+void SetOrigin( vec3_t org );       // PGM
+void XY_Init();
+void XY_Overlay();
+void XY_Draw();
+void DrawZIcon();
+void DrawRotateIcon();
+void DrawCameraIcon();
+void XY_DrawBlockGrid();
+void XY_DrawGrid();
+void XY_MouseMoved( int x, int y, int buttons );
+// TTimo: FIXME: was experimental stuff to track possible endless loop issues
+//  void XY_MouseMovedRec (int x, int y, int buttons);
+void NewBrushDrag( int x, int y );
+qboolean DragDelta( int x, int y, vec3_t move );
+void XY_MouseUp( int x, int y, int buttons );
+void XY_MouseDown( int x, int y, int buttons );
+void XY_ToGridPoint( int x, int y, vec3_t point );
+void XY_ToPoint( int x, int y, vec3_t point );
+void SnapToPoint( int x, int y, vec3_t point );
+void SetActive( bool b ) {m_bActive = b; };
+bool Active() {return m_bActive; };
+
+void DropClipPoint( guint32 nFlags, int pointx, int pointy );
+bool RogueClipMode();
+bool ClipMode();
+void SetClipMode( bool bMode );
+void RetainClipMode( bool bMode );
+
+bool RotateMode();
+bool SetRotateMode( bool bMode );
+bool ScaleMode();
+void SetScaleMode( bool bMode );
+
+bool PathMode();
+void DropPathPoint( guint32 nFlags, int pointx, int pointy );
+bool PointMode();
+//  void AddPointPoint(guint32 nFlags, vec3_t* pVec);
+void SetPointMode( bool b );
+
+void SetViewType( int n );
+bool m_bActive;
+
+protected:
+int m_nUpdateBits;
+int m_nWidth;
+int m_nHeight;
+bool m_bTiming;
+float m_fScale;
+float m_TopClip;
+float m_BottomClip;
+bool m_bDirty;
+vec3_t m_vOrigin;
+
+int m_ptCursorX, m_ptCursorY;
+bool m_bRButtonDown;
+
+int m_nButtonstate;
+int m_nPressx;
+int m_nPressy;
+vec3_t m_vPressdelta;
+bool m_bPress_selection;
+
+friend class CamWnd;
 
-  int m_nWidth;
-  int m_nHeight;
 private:
-  float        m_fScale;
-  Vector3 m_vOrigin;
-
-
-  View m_view;
-  static Shader* m_state_selected;
-
-  int m_ptCursorX, m_ptCursorY;
+// this is unique for all views
+static GtkWidget* m_mnuDrop;
 
-  unsigned int m_buttonstate;
+int m_nViewType;
 
-  int m_nNewBrushPressx;
-  int m_nNewBrushPressy;
-  scene::Node* m_NewBrushDrag;
-  bool m_bNewBrushDrag;
+int m_nScrollFlags;
+int m_ptDragX, m_ptDragY;
+int m_ptDragAdjX, m_ptDragAdjY;
+int m_ptDragTotalX, m_ptDragTotalY;
 
-  Vector3 m_mousePosition;
+void OriginalButtonUp( guint32 nFlags, int point, int pointy );
+void OriginalButtonDown( guint32 nFlags, int point, int pointy );
+//  void ProduceSplits(brush_t** pFront, brush_t** pBack);
+void PlanePointsFromClipPoints( vec3_t planepts[3], brush_t * pBrush );
+void ProduceSplitLists();
+void HandleDrop();
+void PaintSizeInfo( int nDim1, int nDim2, vec3_t vMinBounds, vec3_t vMaxBounds );
 
-  VIEWTYPE m_viewType;
-
-  void OriginalButtonUp(guint32 nFlags, int point, int pointy);
-  void OriginalButtonDown(guint32 nFlags, int point, int pointy);
-
-  void OnContextMenu();
-  void PaintSizeInfo(int nDim1, int nDim2, Vector3& vMinBounds, Vector3& vMaxBounds);
-
-  int m_entityCreate_x, m_entityCreate_y;
-  bool m_entityCreate;
+int m_ptDownX, m_ptDownY;
 
 public:
-  void ButtonState_onMouseDown(unsigned int buttons)
-  {
-    m_buttonstate |= buttons;
-  }
-  void ButtonState_onMouseUp(unsigned int buttons)
-  {
-    m_buttonstate &= ~buttons;
-  }
-  unsigned int getButtonState() const
-  {
-    return m_buttonstate;
-  }
-  void EntityCreate_MouseDown(int x, int y);
-  void EntityCreate_MouseMove(int x, int y);
-  void EntityCreate_MouseUp(int x, int y);
-
-  void OnEntityCreate(const char* item);
-  VIEWTYPE GetViewType()
-  {
-    return m_viewType;
-  }
-  void SetScale(float f);
-  float Scale()
-  {
-    return m_fScale;
-  }
-  int Width()
-  {
-    return m_nWidth;
-  }
-  int Height()
-  {
-    return m_nHeight;
-  }
-
-  Signal3<const WindowVector&, ButtonIdentifier, ModifierFlags> onMouseDown;
-  void mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers);
-  typedef Member3<XYWnd, const WindowVector&, ButtonIdentifier, ModifierFlags, void, &XYWnd::mouseDown> MouseDownCaller;
-};
-
-inline void XYWnd_Update(XYWnd& xywnd)
-{
-  xywnd.queueDraw();
-}
-
-
-struct xywindow_globals_t
-{
-  Vector3 color_gridback;
-  Vector3 color_gridminor;
-  Vector3 color_gridmajor;
-  Vector3 color_gridblock;
-  Vector3 color_gridtext;
-  Vector3 color_brushes;
-  Vector3 color_selbrushes;
-  Vector3 color_clipper;
-  Vector3 color_viewname;
-  Vector3 color_gridminor_alt;
-  Vector3 color_gridmajor_alt;
-  Vector3 AxisColorX;
-  Vector3 AxisColorY;
-  Vector3 AxisColorZ;
-
-  bool m_bRightClick;
-  bool m_bNoStipple;
-
-  xywindow_globals_t() :
-    color_gridback(1.f, 1.f, 1.f),
-    color_gridminor(0.75f, 0.75f, 0.75f),
-    color_gridmajor(0.5f, 0.5f, 0.5f),
-    color_gridblock(0.f, 0.f, 1.f),
-    color_gridtext(0.f, 0.f, 0.f),
-    color_brushes(0.f, 0.f, 0.f),
-    color_selbrushes(1.f, 0.f, 0.f),
-    color_clipper(0.f, 0.f, 1.f),
-    color_viewname(0.5f, 0.f, 0.75f),
-    color_gridminor_alt(0.f, 0.f, 0.f),
-    color_gridmajor_alt(0.f, 0.f, 0.f),
-
-    AxisColorX(1.f, 0.f, 0.f),
-    AxisColorY(0.f, 1.f, 0.f),
-    AxisColorZ(0.f, 0.f, 1.f),
-    m_bRightClick(true),
-    m_bNoStipple(false)
-  {
-  }
+void OnEntityCreate( const char* item );
+int GetViewType() {return m_nViewType; }
+void SetScale( float f ) {m_fScale = f; }
+float Scale() {return m_fScale; }
+int Width() {return m_nWidth; }
+int Height() {return m_nHeight; }
+
+protected:
+
+void OnCreate();
+void OnExpose();
+void OnLButtonDown( guint32 flags, int pointx, int pointy );
+void OnRButtonDown( guint32 flags, int pointx, int pointy );
+void OnMButtonDown( guint32 flags, int pointx, int pointy );
+void OnLButtonUp( guint32 flags, int pointx, int pointy );
+void OnRButtonUp( guint32 flags, int pointx, int pointy );
+void OnMButtonUp( guint32 flags, int pointx, int pointy );
+void OnMouseMove( guint32 nFlags, int pointx, int pointy );
+void OnMouseWheel( bool bUp );
+void OnSize( int cx, int cy );
+void OnTimer();
 
+private:
+XORRectangle m_XORRectangle;
 };
 
-extern xywindow_globals_t g_xywindow_globals;
-
-
-VIEWTYPE GlobalXYWnd_getCurrentViewType();
-
-typedef struct _GtkWindow GtkWindow;
-void XY_Top_Shown_Construct(GtkWindow* parent);
-void YZ_Side_Shown_Construct(GtkWindow* parent);
-void XZ_Front_Shown_Construct(GtkWindow* parent);
-
-void XYWindow_Construct();
-void XYWindow_Destroy();
-
-void XYShow_registerCommands();
-void XYWnd_registerShortcuts();
-
-#endif
+#endif // _XYWINDOW_H_