From e97ede021245c11005aa77a544d4f06efe13ff59 Mon Sep 17 00:00:00 2001 From: ExMix Date: Fri, 12 Jun 2015 16:05:43 +0300 Subject: [PATCH] [drape] tempotaty code for ios part layout dynamic widgets --- iphone/Maps/Classes/EAGLView.mm | 42 ++++++++++++++++++++++-- iphone/Maps/Classes/MapViewController.h | 2 -- iphone/Maps/Classes/MapViewController.mm | 7 ---- iphone/Maps/Settings/Preferences.mm | 5 --- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index d8f154769d..c4beffa747 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -8,12 +8,19 @@ #include "indexer/classificator_loader.hpp" #import "../Platform/opengl/iosOGLContextFactory.h" +#include "drape_gui/skin.hpp" + #include "platform/platform.hpp" #include "std/bind.hpp" #include "std/limits.hpp" +#include "std/unique_ptr.hpp" + @implementation EAGLView +{ + unique_ptr m_skin; +} namespace { @@ -105,7 +112,22 @@ graphics::EDensity getDensityType(int exactDensityDPI, double scale) NSLog(@"EAGLView initRenderPolicy Started"); CGRect frameRect = [UIScreen mainScreen].applicationFrame; - GetFramework().CreateDrapeEngine(make_ref(m_factory), self.contentScaleFactor, frameRect.size.width, frameRect.size.height); + Framework::DrapeCreationParams p; + p.m_surfaceWidth = frameRect.size.width; + p.m_surfaceHeight = frameRect.size.height; + p.m_visualScale = self.contentScaleFactor; + + /// @TODO (iOS developers) remove this stuff and create real logic for init and layout core widgets + m_skin.reset(new gui::Skin(gui::ResolveGuiSkinFile("default"), p.m_visualScale)); + m_skin->Resize(p.m_surfaceWidth, p.m_surfaceHeight); + m_skin->ForEach([&p](gui::EWidget widget, gui::Position const & pos) + { + p.m_widgetsInitInfo[widget] = pos; + }); + + p.m_widgetsInitInfo[gui::WIDGET_SCALE_LABLE] = gui::Position(dp::LeftBottom); + + GetFramework().CreateDrapeEngine(make_ref(m_factory), move(p)); NSLog(@"EAGLView initRenderPolicy Ended"); } @@ -130,7 +152,23 @@ graphics::EDensity getDensityType(int exactDensityDPI, double scale) - (void)onSize:(int)width withHeight:(int)height { - GetFramework().OnSize(width * self.contentScaleFactor, height * self.contentScaleFactor); + int w = width * self.contentScaleFactor; + int h = height * self.contentScaleFactor; + GetFramework().OnSize(w, h); + + /// @TODO (iOS developers) remove this stuff and create real logic for layout core widgets + if (m_skin) + { + m_skin->Resize(w, h); + + gui::TWidgetsLayoutInfo layout; + m_skin->ForEach([&layout](gui::EWidget w, gui::Position const & pos) + { + layout[w] = pos.m_pixelPivot; + }); + + GetFramework().SetWidgetLayout(move(layout)); + } } - (double)correctContentScale diff --git a/iphone/Maps/Classes/MapViewController.h b/iphone/Maps/Classes/MapViewController.h index 65ed0cac3d..b4f1b89267 100644 --- a/iphone/Maps/Classes/MapViewController.h +++ b/iphone/Maps/Classes/MapViewController.h @@ -20,8 +20,6 @@ namespace search { struct AddressInfo; } LocationPredictor * m_predictor; } -- (void)setupMeasurementSystem; - // called when app is terminated by system - (void)onTerminate; - (void)onEnterForeground; diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index c4a89658e5..dc919f8cfa 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -813,13 +813,6 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction) [self.searchView downloadProgress:normProgress countryName:countryName]; } -#pragma mark - Public methods - -- (void)setupMeasurementSystem -{ - GetFramework().SetupMeasurementSystem(); -} - #pragma mark - Private methods NSInteger compareAddress(id l, id r, void * context) diff --git a/iphone/Maps/Settings/Preferences.mm b/iphone/Maps/Settings/Preferences.mm index d080b3402e..b26fb744b3 100644 --- a/iphone/Maps/Settings/Preferences.mm +++ b/iphone/Maps/Settings/Preferences.mm @@ -27,10 +27,7 @@ // get system locale preferences BOOL const isMetric = [[[NSLocale autoupdatingCurrentLocale] objectForKey:NSLocaleUsesMetricSystem] boolValue]; if (isMetric) - { u = Settings::Metric; - [controller setupMeasurementSystem]; - } else { u = Settings::Foot; @@ -41,8 +38,6 @@ Settings::Set("Units", u); } - else - [controller setupMeasurementSystem]; } @end