add keyboard shortcuts for resetting position
This commit is contained in:
@@ -26,6 +26,14 @@ public:
|
||||
void tileLoaded(tile::ptr tile);
|
||||
void tileFailed(tile::ptr tile);
|
||||
|
||||
/* position */
|
||||
void resetNorth();
|
||||
void resetPosition();
|
||||
// void setAngle(double angle);
|
||||
// void setLonLat(double lon, double lat);
|
||||
// void setZoom(double zoom);
|
||||
// void setLonLatZoom(double lon, double lat, double zoom);
|
||||
|
||||
private:
|
||||
bool findLoadedChildren(const tile_id& id, int32_t maxCoveringZoom, std::forward_list<tile_id>& retain);
|
||||
bool findLoadedParent(const tile_id& id, int32_t minCoveringZoom, std::forward_list<tile_id>& retain);
|
||||
|
||||
@@ -49,10 +49,40 @@ public:
|
||||
glfwSetMouseButtonCallback(window, mouseclick);
|
||||
glfwSetWindowSizeCallback(window, resize);
|
||||
glfwSetScrollCallback(window, scroll);
|
||||
glfwSetCharCallback(window, character);
|
||||
glfwSetKeyCallback(window, key);
|
||||
|
||||
glfwSetWindowUserPointer(window, this);
|
||||
}
|
||||
|
||||
static void character(GLFWwindow *window, unsigned int codepoint) {
|
||||
MapView *view = (MapView *)glfwGetWindowUserPointer(window);
|
||||
switch (codepoint) {
|
||||
case L'n':
|
||||
case L'N':
|
||||
view->map->resetNorth();
|
||||
break;
|
||||
case L'r':
|
||||
case L'R':
|
||||
view->map->resetPosition();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void key(GLFWwindow *window, int key, int scancode, int action, int mods) {
|
||||
// MapView *view = (MapView *)glfwGetWindowUserPointer(window);
|
||||
|
||||
if (action == GLFW_RELEASE) {
|
||||
switch (key) {
|
||||
case GLFW_KEY_ESCAPE:
|
||||
glfwSetWindowShouldClose(window, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void scroll(GLFWwindow *window, double xoffset, double yoffset) {
|
||||
MapView *view = (MapView *)glfwGetWindowUserPointer(window);
|
||||
double delta = yoffset * 40;
|
||||
|
||||
@@ -53,6 +53,19 @@ void map::rotateBy(double cx, double cy, double sx, double sy, double ex, double
|
||||
platform::restart(this);
|
||||
}
|
||||
|
||||
void map::resetNorth() {
|
||||
transform->setAngle(0);
|
||||
updateTiles();
|
||||
platform::restart(this);
|
||||
}
|
||||
|
||||
void map::resetPosition() {
|
||||
transform->setAngle(0);
|
||||
transform->setLonLat(0, 0);
|
||||
transform->setZoom(0);
|
||||
updateTiles();
|
||||
platform::restart(this);
|
||||
}
|
||||
|
||||
tile::ptr map::hasTile(const tile_id& id) {
|
||||
for (tile::ptr& tile : tiles) {
|
||||
|
||||
Reference in New Issue
Block a user