Skip to content
Snippets Groups Projects
Commit 26922a95 authored by Pascal Engeler's avatar Pascal Engeler
Browse files

Added zoom shortcuts f1 f2 f3

parent d06e9f11
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,9 @@ public:
static bool b_click;
static bool s_click;
static bool g_click;
static bool f1_click;
static bool f2_click;
static bool f3_click;
//mouse position
static float mpos_x;
......
......@@ -19,6 +19,9 @@ bool InputState::should_quit = false;
bool InputState::b_click = false;
bool InputState::s_click = false;
bool InputState::g_click = false;
bool InputState::f1_click = false;
bool InputState::f2_click = false;
bool InputState::f3_click = false;
void InputState::update(const unsigned width, const unsigned height) {
//reset relative data
......@@ -30,6 +33,9 @@ void InputState::update(const unsigned width, const unsigned height) {
b_click = false;
s_click = false;
g_click = false;
f1_click = false;
f2_click = false;
f3_click = false;
SDL_Event event;
while (SDL_PollEvent(&event)) {
......@@ -144,6 +150,15 @@ void InputState::update(const unsigned width, const unsigned height) {
if (event.key.keysym.sym == SDLK_s) {
s_click = true;
}
if (event.key.keysym.sym == SDLK_F1) {
f1_click = true;
}
if (event.key.keysym.sym == SDLK_F2) {
f2_click = true;
}
if (event.key.keysym.sym == SDLK_F3) {
f3_click = true;
}
break;
case SDL_KEYUP:
if (event.key.keysym.sym == SDLK_SPACE) {
......
......@@ -139,6 +139,7 @@ int main(int argc, char** argv) {
#ifndef NDEBUG
std::cout << "Zooming" << std::endl;
#endif
std::cout << "Zooming " << InputState::mwheelmot_y << std::endl;
//calculate position of mouse cursor in real world
glm::vec2 m_real_world = camera.GetWorldXyFromMouse(InputState::mpos_x, InputState::mpos_y);
//move camera to position pointed to by cursor
......@@ -148,6 +149,51 @@ int main(int argc, char** argv) {
//process zoom (keep only this for central zoom)
camera.ProcessMouseZoom(InputState::mwheelmot_y);
}
else if (InputState::f1_click) {
//zoom 25
//calculate position of mouse cursor in real world
glm::vec2 m_real_world = camera.GetWorldXyFromMouse(InputState::mpos_x, InputState::mpos_y);
//reset view and selection
camera.SetCameraView(eye, lookAt, upVector);
//move camera to position pointed to by cursor
camera.MoveTo(m_real_world);
//move mouse to screen center (doesn't visually work in remote desktop)
SDL_WarpMouseInWindow(infra.window(), WIDTH / 2, HEIGHT / 2);
//zoom to desired level
for (int i = 0; i < 25; ++i) {
camera.ProcessMouseZoom(1);
}
}
else if (InputState::f2_click) {
//zoom 40
//calculate position of mouse cursor in real world
glm::vec2 m_real_world = camera.GetWorldXyFromMouse(InputState::mpos_x, InputState::mpos_y);
//reset view and selection
camera.SetCameraView(eye, lookAt, upVector);
//move camera to position pointed to by cursor
camera.MoveTo(m_real_world);
//move mouse to screen center (doesn't visually work in remote desktop)
SDL_WarpMouseInWindow(infra.window(), WIDTH / 2, HEIGHT / 2);
//zoom to desired level
for (int i = 0; i < 40; ++i) {
camera.ProcessMouseZoom(1);
}
}
else if (InputState::f3_click) {
//zoom 50
//calculate position of mouse cursor in real world
glm::vec2 m_real_world = camera.GetWorldXyFromMouse(InputState::mpos_x, InputState::mpos_y);
//reset view and selection
camera.SetCameraView(eye, lookAt, upVector);
//move camera to position pointed to by cursor
camera.MoveTo(m_real_world);
//move mouse to screen center (doesn't visually work in remote desktop)
SDL_WarpMouseInWindow(infra.window(), WIDTH / 2, HEIGHT / 2);
//zoom to desired level
for (int i = 0; i < 50; ++i) {
camera.ProcessMouseZoom(1);
}
}
SelectionManager::hoveredIndex = bottom_metal.selectObject(InputState::umpos_x, HEIGHT - InputState::umpos_y, projection, view, model);
if (SelectionManager::hoveredIndex != -1) {
SelectionManager::hoveredLayerName = bottom_metal.name();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment