diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-04-30 13:47:03 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-04-30 13:47:03 +0200 |
commit | 9bbdba9eab28c2ba44002bada4b3bb1c0962bd90 (patch) | |
tree | 4a56a077b8597395dd0f38c5ab9cb0c87862afa1 | |
parent | e95ece83335b85ed063f8ea903acc71d5a2fb995 (diff) | |
download | qtlocation-mapboxgl-9bbdba9eab28c2ba44002bada4b3bb1c0962bd90.tar.gz |
remove concept of settings object from library
-rw-r--r-- | common/glfw_view.cpp | 97 | ||||
-rw-r--r-- | common/glfw_view.hpp | 11 | ||||
-rw-r--r-- | common/settings_json.cpp (renamed from linux/settings.cpp) | 31 | ||||
-rw-r--r-- | common/settings_json.hpp | 24 | ||||
-rw-r--r-- | common/settings_nsuserdefaults.hpp | 24 | ||||
-rw-r--r-- | common/settings_nsuserdefaults.mm (renamed from macosx/settings.mm) | 21 | ||||
-rw-r--r-- | include/llmr/llmr.hpp | 1 | ||||
-rw-r--r-- | include/llmr/map/settings.hpp | 27 | ||||
-rw-r--r-- | include/llmr/map/view.hpp | 9 | ||||
-rw-r--r-- | ios/MBXSettings.h | 22 | ||||
-rw-r--r-- | ios/MBXSettings.mm | 52 | ||||
-rw-r--r-- | ios/MBXViewController.mm | 36 | ||||
-rw-r--r-- | ios/llmr-app.gyp | 4 | ||||
-rw-r--r-- | linux/llmr-app.gyp | 4 | ||||
-rw-r--r-- | linux/main.cpp | 29 | ||||
-rw-r--r-- | linux/settings.hpp | 19 | ||||
-rw-r--r-- | macosx/llmr-app.gyp | 4 | ||||
-rw-r--r-- | macosx/main.mm | 27 | ||||
-rw-r--r-- | macosx/settings.hpp | 19 | ||||
-rw-r--r-- | src/map/map.cpp | 2 |
20 files changed, 198 insertions, 265 deletions
diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp index 321670b664..4bdac5f6b0 100644 --- a/common/glfw_view.cpp +++ b/common/glfw_view.cpp @@ -1,11 +1,12 @@ #include "glfw_view.hpp" -MapView::MapView(llmr::Settings &settings, bool fullscreen) - : fullscreen(fullscreen), settings(settings), map(*this) {} +GLFWView::GLFWView(bool fullscreen) : fullscreen(fullscreen) {} -MapView::~MapView() { glfwTerminate(); } +GLFWView::~GLFWView() { glfwTerminate(); } + +void GLFWView::initialize(llmr::Map *map) { + View::initialize(map); -void MapView::init() { if (!glfwInit()) { fprintf(stderr, "Failed to initialize glfw\n"); exit(1); @@ -44,8 +45,6 @@ void MapView::init() { int fb_width, fb_height; glfwGetFramebufferSize(window, &fb_width, &fb_height); - settings.load(); - resize(window, 0, 0); glfwSetCursorPosCallback(window, mousemove); @@ -58,8 +57,8 @@ void MapView::init() { glfwMakeContextCurrent(nullptr); } -void MapView::key(GLFWwindow *window, int key, int /*scancode*/, int action, int mods) { - MapView *mapView = (MapView *)glfwGetWindowUserPointer(window); +void GLFWView::key(GLFWwindow *window, int key, int /*scancode*/, int action, int mods) { + GLFWView *view = (GLFWView *)glfwGetWindowUserPointer(window); if (action == GLFW_RELEASE) { switch (key) { @@ -67,26 +66,26 @@ void MapView::key(GLFWwindow *window, int key, int /*scancode*/, int action, int glfwSetWindowShouldClose(window, true); break; case GLFW_KEY_TAB: - mapView->map.toggleDebug(); + view->map->toggleDebug(); break; case GLFW_KEY_X: if (!mods) - mapView->map.resetPosition(); + view->map->resetPosition(); break; case GLFW_KEY_R: if (!mods) - mapView->map.toggleRaster(); + view->map->toggleRaster(); break; case GLFW_KEY_N: if (!mods) - mapView->map.resetNorth(); + view->map->resetNorth(); break; } } } -void MapView::scroll(GLFWwindow *window, double /*xoffset*/, double yoffset) { - MapView *mapView = (MapView *)glfwGetWindowUserPointer(window); +void GLFWView::scroll(GLFWwindow *window, double /*xoffset*/, double yoffset) { + GLFWView *view = (GLFWView *)glfwGetWindowUserPointer(window); double delta = yoffset * 40; bool is_wheel = delta != 0 && fmod(delta, 4.000244140625) == 0; @@ -104,88 +103,88 @@ void MapView::scroll(GLFWwindow *window, double /*xoffset*/, double yoffset) { scale = 1.0 / scale; } - mapView->map.startScaling(); - mapView->map.scaleBy(scale, mapView->last_x, mapView->last_y); + view->map->startScaling(); + view->map->scaleBy(scale, view->last_x, view->last_y); } -void MapView::resize(GLFWwindow *window, int, int) { - MapView *mapView = (MapView *)glfwGetWindowUserPointer(window); +void GLFWView::resize(GLFWwindow *window, int, int) { + GLFWView *view = (GLFWView *)glfwGetWindowUserPointer(window); int width, height; glfwGetWindowSize(window, &width, &height); int fb_width, fb_height; glfwGetFramebufferSize(window, &fb_width, &fb_height); - mapView->map.resize(width, height, (float)fb_width / (float)width, fb_width, fb_height); + view->map->resize(width, height, (float)fb_width / (float)width, fb_width, fb_height); } -void MapView::mouseclick(GLFWwindow *window, int button, int action, int modifiers) { - MapView *mapView = (MapView *)glfwGetWindowUserPointer(window); +void GLFWView::mouseclick(GLFWwindow *window, int button, int action, int modifiers) { + GLFWView *view = (GLFWView *)glfwGetWindowUserPointer(window); if (button == GLFW_MOUSE_BUTTON_RIGHT || (button == GLFW_MOUSE_BUTTON_LEFT && modifiers & GLFW_MOD_CONTROL)) { - mapView->rotating = action == GLFW_PRESS; - if (!mapView->rotating) { - mapView->map.stopRotating(); + view->rotating = action == GLFW_PRESS; + if (!view->rotating) { + view->map->stopRotating(); } } else if (button == GLFW_MOUSE_BUTTON_LEFT) { - mapView->tracking = action == GLFW_PRESS; + view->tracking = action == GLFW_PRESS; if (action == GLFW_RELEASE) { - mapView->map.stopPanning(); + view->map->stopPanning(); double now = glfwGetTime(); - if (now - mapView->last_click < 0.4 /* ms */) { - mapView->map.scaleBy(2.0, mapView->last_x, mapView->last_y, 0.5); + if (now - view->last_click < 0.4 /* ms */) { + view->map->scaleBy(2.0, view->last_x, view->last_y, 0.5); } - mapView->last_click = now; + view->last_click = now; } } } -void MapView::mousemove(GLFWwindow *window, double x, double y) { - MapView *mapView = (MapView *)glfwGetWindowUserPointer(window); - if (mapView->tracking) { - double dx = x - mapView->last_x; - double dy = y - mapView->last_y; +void GLFWView::mousemove(GLFWwindow *window, double x, double y) { + GLFWView *view = (GLFWView *)glfwGetWindowUserPointer(window); + if (view->tracking) { + double dx = x - view->last_x; + double dy = y - view->last_y; if (dx || dy) { - mapView->map.startPanning(); - mapView->map.moveBy(dx, dy); + view->map->startPanning(); + view->map->moveBy(dx, dy); } - } else if (mapView->rotating) { - mapView->map.startRotating(); - mapView->map.rotateBy(mapView->last_x, mapView->last_y, x, y); + } else if (view->rotating) { + view->map->startRotating(); + view->map->rotateBy(view->last_x, view->last_y, x, y); } - mapView->last_x = x; - mapView->last_y = y; + view->last_x = x; + view->last_y = y; } -int MapView::run() { - map.start(); +int GLFWView::run() { + map->start(); while (!glfwWindowShouldClose(window)) { - if (map.needsSwap()) { + if (map->needsSwap()) { glfwSwapBuffers(window); - map.swapped(); + map->swapped(); fps(); } glfwWaitEvents(); } - map.stop(); + map->stop(); return 0; } -void MapView::make_active() { +void GLFWView::make_active() { glfwMakeContextCurrent(window); } -void MapView::swap() { +void GLFWView::swap() { glfwPostEmptyEvent(); } -void MapView::fps() { +void GLFWView::fps() { static int frames = 0; static double time_elapsed = 0; diff --git a/common/glfw_view.hpp b/common/glfw_view.hpp index 7c9f41811c..d8ea7a90ae 100644 --- a/common/glfw_view.hpp +++ b/common/glfw_view.hpp @@ -5,13 +5,12 @@ #include <GLFW/glfw3.h> #include <uv.h> -class MapView : public llmr::View { +class GLFWView : public llmr::View { public: - MapView(llmr::Settings &settings, bool fullscreen = false); - ~MapView(); - - void init(); + GLFWView(bool fullscreen = false); + ~GLFWView(); + void initialize(llmr::Map *map); void swap(); void make_active(); @@ -37,8 +36,6 @@ public: double last_click = -1; GLFWwindow *window = nullptr; - llmr::Settings &settings; - llmr::Map map; uv_loop_t *loop = nullptr; }; diff --git a/linux/settings.cpp b/common/settings_json.cpp index 73df446f6a..771d89e1a2 100644 --- a/linux/settings.cpp +++ b/common/settings_json.cpp @@ -1,17 +1,14 @@ -#include "settings.hpp" -#include "rapidjson/prettywriter.h" -#include "rapidjson/filestream.h" -#include "rapidjson/document.h" +#include "settings_json.hpp" +#include <rapidjson/prettywriter.h> +#include <rapidjson/filestream.h> +#include <rapidjson/document.h> #include <stdio.h> using namespace llmr; -Settings_JSON::Settings_JSON() -{ -} +Settings_JSON::Settings_JSON() { load(); } -void Settings_JSON::load() -{ +void Settings_JSON::load() { FILE *settingsFile = fopen("/tmp/llmr-native.json", "r"); if (settingsFile != NULL) { rapidjson::FileStream is(settingsFile); @@ -20,36 +17,30 @@ void Settings_JSON::load() if (document.IsArray()) { longitude = document[rapidjson::SizeType(0)].GetDouble(); latitude = document[1].GetDouble(); - scale = document[2].GetDouble(); + zoom = document[2].GetDouble(); angle = document[3].GetDouble(); debug = document[4].GetBool(); } } } -void Settings_JSON::persist() -{ -} - -void Settings_JSON::sync() -{ +void Settings_JSON::save() { rapidjson::FileStream s(fopen("/tmp/llmr-native.json", "w")); rapidjson::PrettyWriter<rapidjson::FileStream> writer(s); writer.StartArray(); writer.Double(longitude); writer.Double(latitude); - writer.Double(scale); + writer.Double(zoom); writer.Double(angle); writer.Bool(debug); writer.EndArray(); } -void Settings_JSON::clear() -{ +void Settings_JSON::clear() { longitude = 0; latitude = 0; - scale = 0; + zoom = 0; angle = 0; debug = false; } diff --git a/common/settings_json.hpp b/common/settings_json.hpp new file mode 100644 index 0000000000..fa95254656 --- /dev/null +++ b/common/settings_json.hpp @@ -0,0 +1,24 @@ +#ifndef LLMR_JSON_SETTINGS +#define LLMR_JSON_SETTINGS + +namespace llmr { + +class Settings_JSON { +public: + Settings_JSON(); + void load(); + void save(); + void clear(); + +public: + double longitude = 0; + double latitude = 0; + double zoom = 0; + double angle = 0; + + bool debug = false; +}; + +} + +#endif diff --git a/common/settings_nsuserdefaults.hpp b/common/settings_nsuserdefaults.hpp new file mode 100644 index 0000000000..575cc4a75f --- /dev/null +++ b/common/settings_nsuserdefaults.hpp @@ -0,0 +1,24 @@ +#ifndef LLMR_COMMON_SETTINGS_NSUSERDEFAULTS +#define LLMR_COMMON_SETTINGS_NSUSERDEFAULTS + +namespace llmr { + +class Settings_NSUserDefaults { +public: + Settings_NSUserDefaults(); + void load(); + void save(); + void clear(); + +public: + double longitude = 0; + double latitude = 0; + double zoom = 0; + double angle = 0; + + bool debug = false; +}; + +} + +#endif diff --git a/macosx/settings.mm b/common/settings_nsuserdefaults.mm index 59091241e2..783aa500d0 100644 --- a/macosx/settings.mm +++ b/common/settings_nsuserdefaults.mm @@ -1,44 +1,41 @@ #import <Foundation/Foundation.h> -#include "settings.hpp" +#include "settings_nsuserdefaults.hpp" using namespace llmr; -Settings_MacOSX::Settings_MacOSX() +Settings_NSUserDefaults::Settings_NSUserDefaults() { [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"longitude" : @(longitude), @"latitude" : @(latitude), - @"scale" : @(scale), + @"zoom" : @(zoom), @"angle" : @(angle), @"debug" : @(debug) }]; + load(); } -void Settings_MacOSX::load() +void Settings_NSUserDefaults::load() { NSDictionary *settings = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]; longitude = [settings[@"longitude"] doubleValue]; latitude = [settings[@"latitude"] doubleValue]; - scale = [settings[@"scale"] doubleValue]; + zoom = [settings[@"zoom"] doubleValue]; angle = [settings[@"angle"] doubleValue]; debug = [settings[@"debug"] boolValue]; } -void Settings_MacOSX::persist() +void Settings_NSUserDefaults::save() { [[NSUserDefaults standardUserDefaults] setValuesForKeysWithDictionary:@{ @"longitude" : @(longitude), @"latitude" : @(latitude), - @"scale" : @(scale), + @"zoom" : @(zoom), @"angle" : @(angle), @"debug" : @(debug) }]; -} - -void Settings_MacOSX::sync() -{ [[NSUserDefaults standardUserDefaults] synchronize]; } -void Settings_MacOSX::clear() +void Settings_NSUserDefaults::clear() { [NSUserDefaults resetStandardUserDefaults]; }
\ No newline at end of file diff --git a/include/llmr/llmr.hpp b/include/llmr/llmr.hpp index 1bf737483c..349b15d8c9 100644 --- a/include/llmr/llmr.hpp +++ b/include/llmr/llmr.hpp @@ -3,6 +3,5 @@ #include "map/map.hpp" #include "map/view.hpp" -#include "map/settings.hpp" #endif diff --git a/include/llmr/map/settings.hpp b/include/llmr/map/settings.hpp deleted file mode 100644 index 01b0e7a020..0000000000 --- a/include/llmr/map/settings.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef LLMR_MAP_SETTINGS -#define LLMR_MAP_SETTINGS - -#include <llmr/util/noncopyable.hpp> - -namespace llmr { - -class Settings : private util::noncopyable { -public: - virtual void load() {}; // load into memory - virtual void persist() {}; // persist in memory (then call sync() if platform-appropriate) - virtual void sync() {}; // save to disk - virtual void clear() {}; // clear from memory and disk - virtual ~Settings() {} - -public: - double longitude = 0; - double latitude = 0; - double scale = 0; - double angle = 0; - - bool debug = false; -}; - -} - -#endif diff --git a/include/llmr/map/view.hpp b/include/llmr/map/view.hpp index 8f198e3c46..47ea244598 100644 --- a/include/llmr/map/view.hpp +++ b/include/llmr/map/view.hpp @@ -3,8 +3,14 @@ namespace llmr { +class Map; + class View { public: + virtual void initialize(Map *map) { + this->map = map; + } + // Called from the render (=GL) thread. Signals that the context should // swap the front and the back buffer. virtual void swap() = 0; @@ -13,6 +19,9 @@ public: // thread. This is typically just called once at the beginning of the // renderer setup since the render thread doesn't switch the contexts. virtual void make_active() = 0; + +protected: + llmr::Map *map = nullptr; }; } diff --git a/ios/MBXSettings.h b/ios/MBXSettings.h deleted file mode 100644 index a0b928ac7a..0000000000 --- a/ios/MBXSettings.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// MBXSettings.hpp -// llmr -// -// Created by Justin R. Miller on 1/27/14. -// -// - -#import <llmr/map/settings.hpp> - -namespace llmr -{ - class Settings_iOS : public Settings - { - public: - Settings_iOS(); - virtual void load(); - virtual void persist(); - virtual void sync(); - virtual void clear(); - }; -}
\ No newline at end of file diff --git a/ios/MBXSettings.mm b/ios/MBXSettings.mm deleted file mode 100644 index 57f1d0ac1e..0000000000 --- a/ios/MBXSettings.mm +++ /dev/null @@ -1,52 +0,0 @@ -// -// MBXSettings.cpp -// llmr -// -// Created by Justin R. Miller on 1/27/14. -// -// - -#import "MBXSettings.h" - -#import <Foundation/Foundation.h> - -using namespace llmr; - -Settings_iOS::Settings_iOS() -{ - [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"longitude" : @(longitude), - @"latitude" : @(latitude), - @"scale" : @(scale), - @"angle" : @(angle), - @"debug" : @(debug) }]; -} - -void Settings_iOS::load() -{ - NSDictionary *settings = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]; - - longitude = [settings[@"longitude"] doubleValue]; - latitude = [settings[@"latitude"] doubleValue]; - scale = [settings[@"scale"] doubleValue]; - angle = [settings[@"angle"] doubleValue]; - debug = [settings[@"debug"] boolValue]; -} - -void Settings_iOS::persist() -{ - [[NSUserDefaults standardUserDefaults] setValuesForKeysWithDictionary:@{ @"longitude" : @(longitude), - @"latitude" : @(latitude), - @"scale" : @(scale), - @"angle" : @(angle), - @"debug" : @(debug) }]; -} - -void Settings_iOS::sync() -{ - [[NSUserDefaults standardUserDefaults] synchronize]; -} - -void Settings_iOS::clear() -{ - [NSUserDefaults resetStandardUserDefaults]; -}
\ No newline at end of file diff --git a/ios/MBXViewController.mm b/ios/MBXViewController.mm index ca3b65621a..375c546c15 100644 --- a/ios/MBXViewController.mm +++ b/ios/MBXViewController.mm @@ -1,7 +1,6 @@ #import "MBXViewController.h" -#import "MBXSettings.h" - +#import "../common/settings_nsuserdefaults.hpp" #import "../common/foundation_request.h" #import <OpenGLES/EAGL.h> @@ -30,7 +29,7 @@ class View; llmr::Map *map = nullptr; View *viewObj = nullptr; -llmr::Settings_iOS *settings = nullptr; +llmr::Settings_NSUserDefaults *settings = nullptr; MBXViewController *viewController = nullptr; #pragma mark - Setup @@ -68,12 +67,14 @@ MBXViewController *viewController = nullptr; - (void)setupMap { - settings = new llmr::Settings_iOS(); - settings->load(); - viewObj = new View(self); - map = new llmr::Map(*viewObj); + + // Load settings + settings = new llmr::Settings_NSUserDefaults(); + map->setLonLatZoom(settings->longitude, settings->latitude, settings->zoom); + map->setAngle(settings->angle); + map->setDebug(settings->debug); } @@ -219,6 +220,20 @@ MBXViewController *viewController = nullptr; - (void)dealloc { + if (settings) + { + // Save settings + if (map) + { + map->getLonLatZoom(settings->longitude, settings->latitude, settings->zoom); + settings->angle = map->getAngle(); + settings->debug = map->getDebug(); + settings->save(); + } + delete settings; + settings = nullptr; + } + if (map) { delete map; @@ -231,13 +246,6 @@ MBXViewController *viewController = nullptr; viewObj = nullptr; } - if (settings) - { - settings->sync(); - delete settings; - settings = nullptr; - } - if ([[EAGLContext currentContext] isEqual:self.context]) { [EAGLContext setCurrentContext:nil]; diff --git a/ios/llmr-app.gyp b/ios/llmr-app.gyp index 288e2bcac8..6ae1240e22 100644 --- a/ios/llmr-app.gyp +++ b/ios/llmr-app.gyp @@ -11,8 +11,10 @@ "sources": [ "./main.m", "./MBXAppDelegate.m", - "./MBXSettings.mm", "./MBXViewController.mm", + "../common/settings_nsuserdefaults.hpp", + "../common/settings_nsuserdefaults.mm", + "../common/foundation_request.h", "../common/foundation_request.mm", ], 'product_extension': 'app', diff --git a/linux/llmr-app.gyp b/linux/llmr-app.gyp index 8cf352554d..d979f00b48 100644 --- a/linux/llmr-app.gyp +++ b/linux/llmr-app.gyp @@ -10,8 +10,8 @@ 'type': 'executable', 'sources': [ './main.cpp', - './settings.cpp', - './settings.hpp', + '../common/settings_json.cpp', + '../common/settings_json.hpp', '../common/glfw_view.hpp', '../common/glfw_view.cpp', '../common/curl_request.cpp', diff --git a/linux/main.cpp b/linux/main.cpp index 32ae04cca9..2c7440c876 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -4,15 +4,15 @@ #include <signal.h> #include <getopt.h> -#include "settings.hpp" +#include "../common/settings_json.hpp" #include "../common/glfw_view.hpp" -MapView *mapView = nullptr; +GLFWView *view = nullptr; void quit_handler(int) { - if (mapView) { + if (view) { fprintf(stderr, "waiting for quit...\n"); - glfwSetWindowShouldClose(mapView->window, true); + glfwSetWindowShouldClose(view->window, true); glfwPostEmptyEvent(); } else { exit(0); @@ -40,13 +40,22 @@ int main(int argc, char *argv[]) { sigIntHandler.sa_flags = 0; sigaction(SIGINT, &sigIntHandler, NULL); - // main loop + view = new GLFWView(); + llmr::Map map(*view); + + // Load settings llmr::Settings_JSON settings; - mapView = new MapView(settings, fullscreen_flag); - mapView->init(); - int ret = mapView->run(); - mapView->settings.sync(); - delete mapView; + map.setLonLatZoom(settings.longitude, settings.latitude, settings.zoom); + map.setAngle(settings.angle); + map.setDebug(settings.debug); + + int ret = view->run(); + + // Save settings + map.getLonLatZoom(settings.longitude, settings.latitude, settings.zoom); + settings.angle = map.getAngle(); + settings.debug = map.getDebug(); + settings.save(); return ret; } diff --git a/linux/settings.hpp b/linux/settings.hpp deleted file mode 100644 index a171e8ab8f..0000000000 --- a/linux/settings.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LLMR_JSON_SETTINGS -#define LLMR_JSON_SETTINGS - -#include <llmr/map/settings.hpp> - -namespace llmr { - -class Settings_JSON : public Settings { -public: - Settings_JSON(); - virtual void load(); - virtual void persist(); - virtual void sync(); - virtual void clear(); -}; - -} - -#endif diff --git a/macosx/llmr-app.gyp b/macosx/llmr-app.gyp index b6a42c91c9..560b223009 100644 --- a/macosx/llmr-app.gyp +++ b/macosx/llmr-app.gyp @@ -10,8 +10,8 @@ 'type': 'executable', 'sources': [ './main.mm', - './settings.mm', - './settings.hpp', + '../common/settings_nsuserdefaults.hpp', + '../common/settings_nsuserdefaults.mm', '../common/glfw_view.hpp', '../common/glfw_view.cpp', '../common/foundation_request.h', diff --git a/macosx/main.mm b/macosx/main.mm index 8d2b0d8ce9..4347a7ce86 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -1,14 +1,25 @@ -// #import <Foundation/Foundation.h> -// #import <AppKit/AppKit.h> - -#include "settings.hpp" +#include "../common/settings_nsuserdefaults.hpp" #include "../common/glfw_view.hpp" int main() { - llmr::Settings_MacOSX settings; - MapView view(settings); - view.init(); + GLFWView view; + llmr::Map map(view); + + // Load settings + llmr::Settings_NSUserDefaults settings; + map.setLonLatZoom(settings.longitude, settings.latitude, settings.zoom); + map.setAngle(settings.angle); + map.setDebug(settings.debug); + + // fprintf(stderr, "lon: %f, lat: %f, zoom: %f, angle: %f, debug: %d\n", settings.l) + int ret = view.run(); - settings.sync(); + + // Save settings + map.getLonLatZoom(settings.longitude, settings.latitude, settings.zoom); + settings.angle = map.getAngle(); + settings.debug = map.getDebug(); + settings.save(); + return ret; } diff --git a/macosx/settings.hpp b/macosx/settings.hpp deleted file mode 100644 index e507c6bd17..0000000000 --- a/macosx/settings.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LLMR_MACOSX_SETTINGS -#define LLMR_MACOSX_SETTINGS - -#include <llmr/map/settings.hpp> - -namespace llmr { - -class Settings_MacOSX : public Settings { -public: - Settings_MacOSX(); - virtual void load(); - virtual void persist(); - virtual void sync(); - virtual void clear(); -}; - -} - -#endif diff --git a/src/map/map.cpp b/src/map/map.cpp index 238d6b72f7..04d8118127 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -20,6 +20,8 @@ Map::Map(View& view) painter(*this), loop(uv_loop_new()) { + view.initialize(this); + // Make sure that we're doing an initial drawing in all cases. is_clean.clear(); is_rendered.clear(); |