diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-02-05 14:58:20 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-03-06 13:52:25 +0100 |
commit | fb44fc81bdab09d079ed27e22b86718627ded48b (patch) | |
tree | 2a4e7c80eb49624c0b548d7bd33401792da1faa4 /platform | |
parent | 0151fe6c01367ef03a2ff282b90e32dd3785a7c2 (diff) | |
download | qtlocation-mapboxgl-fb44fc81bdab09d079ed27e22b86718627ded48b.tar.gz |
make Map::resize() private
they can only be called by View::resize
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/glfw_view.cpp | 26 | ||||
-rw-r--r-- | platform/default/headless_view.cpp | 4 | ||||
-rw-r--r-- | platform/ios/MGLMapView.mm | 8 |
3 files changed, 22 insertions, 16 deletions
diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index 8306229d4a..865636aebf 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -62,14 +62,14 @@ void GLFWView::initialize(mbgl::Map *map_) { int width, height; glfwGetWindowSize(window, &width, &height); - resize(window, width, height); + onResize(window, width, height); - glfwSetCursorPosCallback(window, mouseMove); - glfwSetMouseButtonCallback(window, mouseClick); - glfwSetWindowSizeCallback(window, resize); - glfwSetFramebufferSizeCallback(window, resize); - glfwSetScrollCallback(window, scroll); - glfwSetKeyCallback(window, key); + glfwSetCursorPosCallback(window, onMouseMove); + glfwSetMouseButtonCallback(window, onMouseClick); + glfwSetWindowSizeCallback(window, onResize); + glfwSetFramebufferSizeCallback(window, onResize); + glfwSetScrollCallback(window, onScroll); + glfwSetKeyCallback(window, onKey); const std::string extensions = reinterpret_cast<const char *>(MBGL_CHECK_ERROR(glGetString(GL_EXTENSIONS))); { @@ -157,7 +157,7 @@ void GLFWView::initialize(mbgl::Map *map_) { glfwMakeContextCurrent(nullptr); } -void GLFWView::key(GLFWwindow *window, int key, int /*scancode*/, int action, int mods) { +void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, int mods) { GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window)); if (action == GLFW_RELEASE) { @@ -190,7 +190,7 @@ void GLFWView::key(GLFWwindow *window, int key, int /*scancode*/, int action, in } } -void GLFWView::scroll(GLFWwindow *window, double /*xOffset*/, double yOffset) { +void GLFWView::onScroll(GLFWwindow *window, double /*xOffset*/, double yOffset) { GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window)); double delta = yOffset * 40; @@ -213,16 +213,16 @@ void GLFWView::scroll(GLFWwindow *window, double /*xOffset*/, double yOffset) { view->map->scaleBy(scale, view->lastX, view->lastY); } -void GLFWView::resize(GLFWwindow *window, int width, int height ) { +void GLFWView::onResize(GLFWwindow *window, int width, int height ) { GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window)); int fbWidth, fbHeight; glfwGetFramebufferSize(window, &fbWidth, &fbHeight); - view->map->resize(width, height, static_cast<float>(fbWidth) / static_cast<float>(width), fbWidth, fbHeight); + view->resize(width, height, static_cast<float>(fbWidth) / static_cast<float>(width), fbWidth, fbHeight); } -void GLFWView::mouseClick(GLFWwindow *window, int button, int action, int modifiers) { +void GLFWView::onMouseClick(GLFWwindow *window, int button, int action, int modifiers) { GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window)); if (button == GLFW_MOUSE_BUTTON_RIGHT || @@ -249,7 +249,7 @@ void GLFWView::mouseClick(GLFWwindow *window, int button, int action, int modifi } } -void GLFWView::mouseMove(GLFWwindow *window, double x, double y) { +void GLFWView::onMouseMove(GLFWwindow *window, double x, double y) { GLFWView *view = reinterpret_cast<GLFWView *>(glfwGetWindowUserPointer(window)); if (view->tracking) { double dx = x - view->lastX; diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index 656a774390..a3128234ea 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -131,7 +131,7 @@ void HeadlessView::createContext() { #endif } -void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { +void HeadlessView::resize(const uint16_t width, const uint16_t height, const float pixelRatio) { clearBuffers(); width_ = width; @@ -177,6 +177,8 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { throw std::runtime_error(error.str()); } + View::resize(width, height, pixelRatio, w, h); + deactivate(); } diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index e68ba6c93f..b1932737b7 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -239,7 +239,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; mbglFileCache = new mbgl::SQLiteCache(defaultCacheDatabase()); mbglFileSource = new mbgl::DefaultFileSource(mbglFileCache); mbglMap = new mbgl::Map(*mbglView, *mbglFileSource); - mbglMap->resize(self.bounds.size.width, self.bounds.size.height, _glView.contentScaleFactor, _glView.drawableWidth, _glView.drawableHeight); + mbglView->resize(self.bounds.size.width, self.bounds.size.height, _glView.contentScaleFactor, _glView.drawableWidth, _glView.drawableHeight); // Notify map object when network reachability status changes. [[NSNotificationCenter defaultCenter] addObserver:self @@ -489,7 +489,7 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect { - mbglMap->resize(rect.size.width, rect.size.height, view.contentScaleFactor, view.drawableWidth, view.drawableHeight); + mbglView->resize(rect.size.width, rect.size.height, view.contentScaleFactor, view.drawableWidth, view.drawableHeight); } - (void)layoutSubviews @@ -1631,6 +1631,10 @@ class MBGLView : public mbgl::View [EAGLContext setCurrentContext:nil]; } + void resize(uint16_t width, uint16_t height, float ratio, uint16_t fbWidth, uint16_t fbHeight) { + View::resize(width, height, ratio, fbWidth, fbHeight); + } + void swap() { [nativeView performSelectorOnMainThread:@selector(swap) |