summaryrefslogtreecommitdiff
path: root/common/view.cpp
blob: 237a3985288976a83293bf20aca3421ca00a9a84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//
// View the project contents
//

#include <stdlib.h>
#include "project.h"
#include "view.h"
#include "system.h"

View::View(Project *pProject, GLWindow *share)
	: GLWindow(share)
{
	m_Project = pProject;
}

View::~View()
{
	if (m_Project != NULL)
		m_Project->RemoveView(this);
}

LC_CURSOR_TYPE View::GetCursor(int Ptx, int Pty) const
{
	// TODO: check if we're the focused window and return just the default arrow if we aren't.

	switch (m_Project->GetAction())
	{
		case LC_ACTION_SELECT:
			if (Sys_KeyDown(KEY_CONTROL))
				return LC_CURSOR_SELECT_GROUP;
			else
				return LC_CURSOR_SELECT;

		case LC_ACTION_INSERT:
			return LC_CURSOR_BRICK;

		case LC_ACTION_LIGHT:
			return LC_CURSOR_LIGHT;

		case LC_ACTION_SPOTLIGHT:
			return LC_CURSOR_SPOTLIGHT;

		case LC_ACTION_CAMERA:
			return LC_CURSOR_CAMERA;

		case LC_ACTION_MOVE:
			return LC_CURSOR_MOVE;

		case LC_ACTION_ROTATE:
			return LC_CURSOR_ROTATE;

		case LC_ACTION_ERASER:
			return LC_CURSOR_DELETE;

		case LC_ACTION_PAINT:
			return LC_CURSOR_PAINT;

		case LC_ACTION_ZOOM:
			return LC_CURSOR_ZOOM;

		case LC_ACTION_ZOOM_REGION:
			return LC_CURSOR_ZOOM_REGION;

		case LC_ACTION_PAN:
			return LC_CURSOR_PAN;

		case LC_ACTION_ROTATE_VIEW:
			switch (m_Project->GetOverlayMode())
			{
				case LC_OVERLAY_X: return LC_CURSOR_ROTATEX;
				case LC_OVERLAY_Y: return LC_CURSOR_ROTATEY;
				case LC_OVERLAY_Z: return LC_CURSOR_ROLL;
				case LC_OVERLAY_XYZ: return LC_CURSOR_ROTATE_VIEW;
				default:
					LC_ASSERT_FALSE("Unknown cursor type.");
					return LC_CURSOR_NONE;
			}

		case LC_ACTION_ROLL:
			return LC_CURSOR_ROLL;

		case LC_ACTION_CURVE:
		default:
			LC_ASSERT_FALSE("Unknown cursor type.");
			return LC_CURSOR_NONE;
	}
}

void View::OnDraw()
{
	MakeCurrent();

	m_Project->SetViewSize(m_nWidth, m_nHeight);
	m_Project->Render(false);

	SwapBuffers();
}

void View::OnInitialUpdate()
{
	GLWindow::OnInitialUpdate();
	m_Project->AddView(this);
}

void View::OnLeftButtonDown(int x, int y, bool bControl, bool bShift)
{
	m_Project->SetViewSize(m_nWidth, m_nHeight);
	m_Project->OnLeftButtonDown(x, y, bControl, bShift);
}

void View::OnLeftButtonUp(int x, int y, bool bControl, bool bShift)
{
	m_Project->SetViewSize(m_nWidth, m_nHeight);
	m_Project->OnLeftButtonUp(x, y, bControl, bShift);
}

void View::OnLeftButtonDoubleClick(int x, int y, bool bControl, bool bShift)
{
	m_Project->SetViewSize(m_nWidth, m_nHeight);
	m_Project->OnLeftButtonDoubleClick(x, y, bControl, bShift);
}

void View::OnRightButtonDown(int x, int y, bool bControl, bool bShift)
{
	m_Project->SetViewSize(m_nWidth, m_nHeight);
	m_Project->OnRightButtonDown(x, y, bControl, bShift);
}

void View::OnRightButtonUp(int x, int y, bool bControl, bool bShift)
{
	m_Project->SetViewSize(m_nWidth, m_nHeight);
	m_Project->OnRightButtonUp(x, y, bControl, bShift);
}

void View::OnMouseMove(int x, int y, bool bControl, bool bShift)
{
	m_Project->SetViewSize(m_nWidth, m_nHeight);
	m_Project->OnMouseMove(x, y, bControl, bShift);
}