Integrated control+mouse quick camera shortcuts.

This commit is contained in:
nobody 2012-01-28 02:10:19 +00:00
parent de0d305b3d
commit 8a5cab7acc
7 changed files with 123 additions and 20 deletions

View file

@ -16,6 +16,7 @@
#define LC_MAXPATH 260 //_MAX_PATH
#define KEY_SHIFT VK_SHIFT
#define KEY_CONTROL VK_CONTROL
#define KEY_ALT VK_MENU
#define KEY_ESCAPE VK_ESCAPE
#define KEY_TAB VK_TAB
#define KEY_INSERT VK_INSERT
@ -34,16 +35,17 @@
#define LC_MAXPATH 1024 //FILENAME_MAX
#define KEY_SHIFT 0x01
#define KEY_CONTROL 0x02
#define KEY_ESCAPE 0x03
#define KEY_TAB 0x04
#define KEY_INSERT 0x05
#define KEY_DELETE 0x06
#define KEY_UP 0x07
#define KEY_DOWN 0x08
#define KEY_LEFT 0x09
#define KEY_RIGHT 0x0A
#define KEY_PRIOR 0x0B
#define KEY_NEXT 0x0C
#define KEY_ALT 0x03
#define KEY_ESCAPE 0x04
#define KEY_TAB 0x05
#define KEY_INSERT 0x06
#define KEY_DELETE 0x07
#define KEY_UP 0x08
#define KEY_DOWN 0x09
#define KEY_LEFT 0x0A
#define KEY_RIGHT 0x0B
#define KEY_PRIOR 0x0C
#define KEY_NEXT 0x0D
#define KEY_PLUS '+'
#define KEY_MINUS '-'

View file

@ -31,6 +31,8 @@ public:
virtual void OnLeftButtonDown(int x, int y, bool bControl, bool bShift) { };
virtual void OnLeftButtonUp(int x, int y, bool bControl, bool bShift) { };
virtual void OnLeftButtonDoubleClick(int x, int y, bool bControl, bool bShift) { };
virtual void OnMiddleButtonDown(int x, int y, bool bControl, bool bShift) { };
virtual void OnMiddleButtonUp(int x, int y, bool bControl, bool bShift) { };
virtual void OnRightButtonDown(int x, int y, bool bControl, bool bShift) { };
virtual void OnRightButtonUp(int x, int y, bool bControl, bool bShift) { };
virtual void OnMouseMove(int x, int y, bool bControl, bool bShift) { };

View file

@ -6127,8 +6127,9 @@ void Project::SetAction(int nAction)
if (m_nCurAction == LC_ACTION_INSERT)
Redraw = true;
SystemUpdateAction(nAction, m_nCurAction);
m_PreviousAction = m_nCurAction;
m_nCurAction = nAction;
SystemUpdateAction(m_nCurAction, m_PreviousAction);
if ((m_nCurAction == LC_ACTION_MOVE) || (m_nCurAction == LC_ACTION_ROTATE) ||
(m_nCurAction == LC_ACTION_ROTATE_VIEW))
@ -6782,6 +6783,12 @@ bool Project::StopTracking(bool bAccept)
case LC_ACTION_PAINT:
break;
}
if (m_RestoreAction)
{
SetAction(m_PreviousAction);
m_RestoreAction = false;
}
}
else if (m_pTrackFile != NULL)
{
@ -7552,13 +7559,20 @@ bool Project::OnKeyDown(char nKey, bool bControl, bool bShift)
void Project::BeginPieceDrop(PieceInfo* Info)
{
StartTracking(LC_TRACK_LEFT);
SetAction(LC_ACTION_INSERT);
m_RestoreAction = true;
m_PreviousAction = m_nCurAction;
m_PreviousPiece = m_pCurPiece;
m_pCurPiece = Info;
m_pCurPiece->AddRef();
SetAction(LC_ACTION_INSERT);
}
void Project::BeginColorDrop()
{
StartTracking(LC_TRACK_LEFT);
SetAction(LC_ACTION_PAINT);
m_RestoreAction = true;
}
void Project::OnLeftButtonDown(View* view, int x, int y, bool bControl, bool bShift)
@ -7587,6 +7601,12 @@ void Project::OnLeftButtonDown(View* view, int x, int y, bool bControl, bool bSh
gluUnProject(x, y, 0.9, modelMatrix, projMatrix, viewport, &point[0], &point[1], &point[2]);
m_fTrack[0] = (float)point[0]; m_fTrack[1] = (float)point[1]; m_fTrack[2] = (float)point[2];
if (Sys_KeyDown(KEY_ALT))
{
SetAction(LC_ACTION_ROTATE_VIEW);
m_RestoreAction = true;
}
switch (m_nCurAction)
{
case LC_ACTION_SELECT:
@ -7980,12 +8000,11 @@ void Project::OnLeftButtonUp(View* view, int x, int y, bool bControl, bool bShif
SystemUpdateFocus(pPiece);
if (m_nSnap & LC_DRAW_MOVE)
{
SetAction(LC_ACTION_MOVE);
else
SetAction(m_PreviousAction);
m_RestoreAction = false;
}
}
else
SetAction(m_PreviousAction);
m_pCurPiece->DeRef();
m_pCurPiece = m_PreviousPiece;
@ -7996,6 +8015,49 @@ void Project::OnLeftButtonUp(View* view, int x, int y, bool bControl, bool bShif
StopTracking(true);
}
void Project::OnMiddleButtonDown(View* view, int x, int y, bool bControl, bool bShift)
{
GLdouble modelMatrix[16], projMatrix[16], point[3];
GLint viewport[4];
if (StopTracking(false))
return;
if (SetActiveView(view))
return;
m_nDownX = x;
m_nDownY = y;
m_bTrackCancel = false;
LoadViewportProjection(m_nActiveViewport);
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
glGetIntegerv(GL_VIEWPORT, viewport);
gluUnProject(x, y, 0.9, modelMatrix, projMatrix, viewport, &point[0], &point[1], &point[2]);
m_fTrack[0] = (float)point[0]; m_fTrack[1] = (float)point[1]; m_fTrack[2] = (float)point[2];
if (Sys_KeyDown(KEY_ALT))
{
SetAction(LC_ACTION_PAN);
m_RestoreAction = true;
}
switch (m_nCurAction)
{
case LC_ACTION_PAN:
{
StartTracking(LC_TRACK_START_RIGHT);
} break;
}
}
void Project::OnMiddleButtonUp(View* view, int x, int y, bool bControl, bool bShift)
{
StopTracking(true);
}
void Project::OnRightButtonDown(View* view, int x, int y, bool bControl, bool bShift)
{
GLdouble modelMatrix[16], projMatrix[16], point[3];
@ -8019,6 +8081,12 @@ void Project::OnRightButtonDown(View* view, int x, int y, bool bControl, bool bS
gluUnProject(x, y, 0.9, modelMatrix, projMatrix, viewport, &point[0], &point[1], &point[2]);
m_fTrack[0] = (float)point[0]; m_fTrack[1] = (float)point[1]; m_fTrack[2] = (float)point[2];
if (Sys_KeyDown(KEY_ALT))
{
SetAction(LC_ACTION_ZOOM);
m_RestoreAction = true;
}
switch (m_nCurAction)
{
case LC_ACTION_MOVE:
@ -8067,6 +8135,11 @@ void Project::OnRightButtonDown(View* view, int x, int y, bool bControl, bool bS
break;
}
} break;
case LC_ACTION_ZOOM:
{
StartTracking(LC_TRACK_START_RIGHT);
} break;
}
}

View file

@ -118,6 +118,7 @@ public:
void DeleteContents(bool bUndo); // delete doc items etc
void LoadDefaults(bool cameras);
void BeginPieceDrop(PieceInfo* Info);
void BeginColorDrop();
void CreateImages(Image* images, int width, int height, unsigned short from, unsigned short to, bool hilite);
void Render(View* view, bool bToMemory);
@ -233,6 +234,8 @@ public:
void OnLeftButtonDown(View* view, int x, int y, bool bControl, bool bShift);
void OnLeftButtonUp(View* view, int x, int y, bool bControl, bool bShift);
void OnLeftButtonDoubleClick(View* view, int x, int y, bool bControl, bool bShift);
void OnMiddleButtonDown(View* view, int x, int y, bool bControl, bool bShift);
void OnMiddleButtonUp(View* view, int x, int y, bool bControl, bool bShift);
void OnRightButtonDown(View* view, int x, int y, bool bControl, bool bShift);
void OnRightButtonUp(View* view, int x, int y, bool bControl, bool bShift);
void OnMouseMove(View* view, int x, int y, bool bControl, bool bShift);
@ -245,6 +248,9 @@ public:
protected:
// State variables
int m_nCurAction;
int m_PreviousAction;
bool m_RestoreAction;
unsigned char m_nViewportMode;
unsigned char m_nActiveViewport;
int m_nViewX;
@ -252,8 +258,6 @@ protected:
PieceInfo* m_pCurPiece;
PieceInfo* m_PreviousPiece;
unsigned char m_nCurColor;
unsigned char m_nCurAction;
unsigned char m_PreviousAction;
bool m_bAnimation;
bool m_bAddKeys;
unsigned char m_nFPS;
@ -286,7 +290,7 @@ protected:
protected:
// File load/save implementation.
bool DoSave(char* lpszPathName, bool bReplace);
bool DoSave(char* PathName, bool bReplace);
bool DoFileSave();
bool FileLoad(File* file, bool bUndo, bool bMerge);
void FileSave(File* file, bool bUndo);

View file

@ -120,6 +120,18 @@ void View::OnLeftButtonDoubleClick(int x, int y, bool bControl, bool bShift)
m_Project->OnLeftButtonDoubleClick(this, x, y, bControl, bShift);
}
void View::OnMiddleButtonDown(int x, int y, bool bControl, bool bShift)
{
m_Project->SetViewSize(m_nWidth, m_nHeight);
m_Project->OnMiddleButtonDown(this, x, y, bControl, bShift);
}
void View::OnMiddleButtonUp(int x, int y, bool bControl, bool bShift)
{
m_Project->SetViewSize(m_nWidth, m_nHeight);
m_Project->OnMiddleButtonUp(this, x, y, bControl, bShift);
}
void View::OnRightButtonDown(int x, int y, bool bControl, bool bShift)
{
m_Project->SetViewSize(m_nWidth, m_nHeight);

View file

@ -16,6 +16,8 @@ public:
void OnLeftButtonDown (int x, int y, bool bControl, bool bShift);
void OnLeftButtonUp (int x, int y, bool bControl, bool bShift);
void OnLeftButtonDoubleClick (int x, int y, bool bControl, bool bShift);
void OnMiddleButtonDown(int x, int y, bool bControl, bool bShift);
void OnMiddleButtonUp(int x, int y, bool bControl, bool bShift);
void OnRightButtonDown (int x, int y, bool bControl, bool bShift);
void OnRightButtonUp (int x, int y, bool bControl, bool bShift);
void OnMouseMove (int x, int y, bool bControl, bool bShift);

View file

@ -43,6 +43,14 @@ BOOL GLWindowPreTranslateMessage (GLWindow *wnd, MSG *pMsg)
wnd->OnLeftButtonDoubleClick((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_MBUTTONDOWN:
wnd->OnMiddleButtonDown((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_MBUTTONUP:
wnd->OnMiddleButtonUp((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);
break;
case WM_RBUTTONDOWN:
wnd->OnRightButtonDown((SHORT)LOWORD(pMsg->lParam), wnd->GetHeight() - (SHORT)HIWORD(pMsg->lParam) - 1,
(pMsg->wParam & MK_CONTROL) != 0, (pMsg->wParam & MK_SHIFT) != 0);