worldspawn/src/xywindow.h

367 lines
6.8 KiB
C
Raw Permalink Normal View History

2020-11-17 03:16:16 -08:00
/*
Copyright (C) 1999-2006 Id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
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 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
*/
#if !defined( INCLUDED_XYWINDOW_H )
#define INCLUDED_XYWINDOW_H
#include "math/matrix.h"
#include "signal/signal.h"
#include "gtkutil/cursor.h"
#include "gtkutil/window.h"
#include "gtkutil/xorrectangle.h"
#include "view.h"
#include "map.h"
#include "texturelib.h"
#include "qerplugin.h"
class Shader;
class SelectionSystemWindowObserver;
namespace scene {
2021-08-04 13:23:18 -07:00
class Node;
2020-11-17 03:16:16 -08:00
}
void FlipClip();
void SplitClip();
void Clip();
void OnClipMode(bool enabled);
bool ClipMode();
inline const char *ViewType_getTitle(VIEWTYPE viewtype)
{
2021-08-04 13:23:18 -07:00
if (viewtype == XY) {
return "XY Top";
}
if (viewtype == XZ) {
return "XZ Front";
}
if (viewtype == YZ) {
return "YZ Side";
}
return "";
2020-11-17 03:16:16 -08:00
}
class XYWnd {
2021-08-04 13:23:18 -07:00
ui::GLArea m_gl_widget;
guint m_sizeHandler;
guint m_exposeHandler;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
DeferredDraw m_deferredDraw;
DeferredMotion m_deferred_motion;
2020-11-17 03:16:16 -08:00
public:
2021-08-04 13:23:18 -07:00
ui::Window m_parent;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
XYWnd();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
~XYWnd();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void queueDraw()
{
m_deferredDraw.draw();
}
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
ui::GLArea GetWidget()
{
return m_gl_widget;
}
2020-11-17 03:16:16 -08:00
public:
2021-08-04 13:23:18 -07:00
SelectionSystemWindowObserver *m_window_observer;
XORRectangle m_XORRectangle;
WindowPositionTracker m_positionTracker;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
static void captureStates();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
static void releaseStates();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void PositionView(const Vector3 &position);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
const Vector3 &GetOrigin();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void SetOrigin(const Vector3 &origin);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void Scroll(int x, int y);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_Draw();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void DrawCameraIcon(const Vector3 &origin, const Vector3 &angles);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_DrawBlockGrid();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_DrawAxis();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_DrawGrid();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_DrawBackground();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_LoadBackgroundImage(const char *name);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_DisableBackground();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_MouseUp(int x, int y, unsigned int buttons);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_MouseDown(int x, int y, unsigned int buttons);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_MouseMoved(int x, int y, unsigned int buttons);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void NewBrushDrag_Begin(int x, int y);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void NewBrushDrag(int x, int y);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void NewBrushDrag_End(int x, int y);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_ToPoint(int x, int y, Vector3 &point);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void XY_SnapToGrid(Vector3 &point);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void Move_Begin();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void Move_End();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
bool m_move_started;
guint m_move_focusOut;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void Zoom_Begin();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void Zoom_End();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
bool m_zoom_started;
guint m_zoom_focusOut;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void SetActive(bool b)
{
m_bActive = b;
};
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
bool Active()
{
return m_bActive;
};
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void Clipper_OnLButtonDown(int x, int y);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void Clipper_OnLButtonUp(int x, int y);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void Clipper_OnMouseMoved(int x, int y);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void Clipper_Crosshair_OnMouseMoved(int x, int y);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void DropClipPoint(int pointx, int pointy);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void SetViewType(VIEWTYPE n);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
bool m_bActive;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
static ui::Menu m_mnuDrop;
static ui::Menu m_mnuDropSingle;
static ui::Menu m_mnuDropMultiple;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
int m_chasemouse_current_x, m_chasemouse_current_y;
int m_chasemouse_delta_x, m_chasemouse_delta_y;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
guint m_chasemouse_handler;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void ChaseMouse();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
bool chaseMouseMotion(int pointx, int pointy);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void updateModelview();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void updateProjection();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
Matrix4 m_projection;
Matrix4 m_modelview;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
int m_nWidth;
int m_nHeight;
2020-11-17 03:16:16 -08:00
// background image stuff
2021-08-04 13:23:18 -07:00
qtexture_t *m_tex;
bool m_backgroundActivated;
float m_alpha; // vertex alpha
float m_xmin, m_ymin, m_xmax, m_ymax;
2020-11-17 03:16:16 -08:00
private:
2021-08-04 13:23:18 -07:00
float m_fScale;
Vector3 m_vOrigin;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
View m_view;
static Shader *m_state_selected;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
int m_ptCursorX, m_ptCursorY;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
unsigned int m_buttonstate;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
int m_nNewBrushPressx;
int m_nNewBrushPressy;
scene::Node *m_NewBrushDrag;
bool m_bNewBrushDrag;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
Vector3 m_mousePosition;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
VIEWTYPE m_viewType;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void OriginalButtonUp(guint32 nFlags, int point, int pointy);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void OriginalButtonDown(guint32 nFlags, int point, int pointy);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void OnContextMenu();
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void PaintSizeInfo(int nDim1, int nDim2, Vector3 &vMinBounds, Vector3 &vMaxBounds);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
int m_entityCreate_x, m_entityCreate_y;
bool m_entityCreate;
2020-11-17 03:16:16 -08:00
public:
2021-08-04 13:23:18 -07:00
void ButtonState_onMouseDown(unsigned int buttons)
{
m_buttonstate |= buttons;
}
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void ButtonState_onMouseUp(unsigned int buttons)
{
m_buttonstate &= ~buttons;
}
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
unsigned int getButtonState() const
{
return m_buttonstate;
}
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void EntityCreate_MouseDown(int x, int y);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void EntityCreate_MouseMove(int x, int y);
2021-08-04 13:23:18 -07:00
void EntityCreate_MouseUp(int x, int y);
2021-08-04 13:23:18 -07:00
void OnEntityCreate(const char *item);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
VIEWTYPE GetViewType()
{
return m_viewType;
}
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void SetScale(float f);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
float Scale()
{
return m_fScale;
}
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
int Width()
{
return m_nWidth;
}
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
int Height()
{
return m_nHeight;
}
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
Signal0 onDestroyed;
Signal3<const WindowVector &, ButtonIdentifier, ModifierFlags> onMouseDown;
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
void mouseDown(const WindowVector &position, ButtonIdentifier button, ModifierFlags modifiers);
2020-11-17 03:16:16 -08:00
2021-08-04 13:23:18 -07:00
typedef Member<XYWnd, void (const WindowVector &, ButtonIdentifier,
ModifierFlags), &XYWnd::mouseDown> MouseDownCaller;
2020-11-17 03:16:16 -08:00
};
inline void XYWnd_Update(XYWnd &xywnd)
{
2021-08-04 13:23:18 -07:00
xywnd.queueDraw();
2020-11-17 03:16:16 -08:00
}
struct xywindow_globals_t {
2021-08-04 13:23:18 -07:00
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() :
2020-11-17 03:16:16 -08:00
color_gridback(0.0f, 0.0f, 0.0f),
color_gridmajor(0.45f, 0.45f, 0.45f),
color_gridminor(0.2f, 0.2f, 0.2f),
color_gridblock(0.39f, 0.18f, 0.0f),
color_gridtext(0.0f, 0.0f, 0.0f),
color_brushes(0.55f, 0.55f, 0.55f),
color_selbrushes(1.0f, 0.0f, 0.0f),
color_clipper(0.0f, 0.0f, 1.0f),
color_viewname(0.7f, 0.7f, 0.0f),
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)
2021-08-04 13:23:18 -07:00
{
}
2020-11-17 03:16:16 -08:00
};
extern xywindow_globals_t g_xywindow_globals;
VIEWTYPE GlobalXYWnd_getCurrentViewType();
void XY_Top_Shown_Construct(ui::Window parent);
void YZ_Side_Shown_Construct(ui::Window parent);
void XZ_Front_Shown_Construct(ui::Window parent);
void XYWindow_Construct();
void XYWindow_Destroy();
void WXY_Print();
void WXY_BackgroundSelect();
void XYShow_registerCommands();
void XYWnd_registerShortcuts();
#endif