forked from organicmaps/organicmaps
[drape][android][ios][desktop] fix: Decoupled saving and setting 3D mode.
This commit is contained in:
parent
6c75501fec
commit
aa7f70075d
6 changed files with 45 additions and 7 deletions
|
@ -188,11 +188,21 @@ MapStyle Framework::GetMapStyle() const
|
|||
return m_work.GetMapStyle();
|
||||
}
|
||||
|
||||
void Framework::Allow3dMode(bool allow3d, bool allow3dBuildings)
|
||||
void Framework::Save3dMode(bool allow3d, bool allow3dBuildings)
|
||||
{
|
||||
m_work.Save3dMode(allow3d, allow3dBuildings);
|
||||
}
|
||||
|
||||
void Framework::Set3dMode(bool allow3d, bool allow3dBuildings)
|
||||
{
|
||||
m_work.Allow3dMode(allow3d, allow3dBuildings);
|
||||
}
|
||||
|
||||
void Framework::Get3dMode(bool & allow3d, bool & allow3dBuildings)
|
||||
{
|
||||
m_work.Load3dMode(allow3d, allow3dBuildings);
|
||||
}
|
||||
|
||||
Storage & Framework::Storage()
|
||||
{
|
||||
return m_work.Storage();
|
||||
|
@ -1319,14 +1329,31 @@ extern "C"
|
|||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeAllow3dMode(JNIEnv * env, jclass thiz, jboolean allow, jboolean allowBuildings)
|
||||
Java_com_mapswithme_maps_Framework_nativeSet3dMode(JNIEnv * env, jclass thiz, jboolean allow, jboolean allowBuildings)
|
||||
{
|
||||
bool const allow3d = static_cast<bool>(allow);
|
||||
bool const allow3dBuildings = static_cast<bool>(allowBuildings);
|
||||
|
||||
g_framework->Save3dMode(allow3d, allow3dBuildings);
|
||||
g_framework->PostDrapeTask([allow3d, allow3dBuildings]()
|
||||
{
|
||||
g_framework->Allow3dMode(allow3d, allow3dBuildings);
|
||||
g_framework->Set3dMode(allow3d, allow3dBuildings);
|
||||
});
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeGet3dMode(JNIEnv * env, jclass thiz, jobject result)
|
||||
{
|
||||
bool enabled;
|
||||
bool buildings;
|
||||
g_framework->Get3dMode(enabled, buildings);
|
||||
|
||||
jclass const resultClass = env->GetObjectClass(result);
|
||||
|
||||
static jfieldID const enabledField = env->GetFieldID(resultClass, "enabled", "Z");
|
||||
env->SetBooleanField(result, enabledField, enabled);
|
||||
|
||||
static jfieldID const buildingsField = env->GetFieldID(resultClass, "buildings", "Z");
|
||||
env->SetBooleanField(result, buildingsField, buildings);
|
||||
}
|
||||
} // extern "C"
|
||||
|
|
|
@ -156,7 +156,9 @@ namespace android
|
|||
location::EMyPositionMode GetMyPositionMode() const;
|
||||
void SetMyPositionMode(location::EMyPositionMode mode);
|
||||
|
||||
void Allow3dMode(bool allow3d, bool allow3dBuildings);
|
||||
void Save3dMode(bool allow3d, bool allow3dBuildings);
|
||||
void Set3dMode(bool allow3d, bool allow3dBuildings);
|
||||
void Get3dMode(bool & allow3d, bool & allow3dBuildings);
|
||||
|
||||
void SetupWidget(gui::EWidget widget, float x, float y, dp::Anchor anchor);
|
||||
void ApplyWidgets();
|
||||
|
|
|
@ -48,6 +48,12 @@ public class Framework
|
|||
void onRouteBuildingProgress(float progress);
|
||||
}
|
||||
|
||||
public static class _3dModeParams
|
||||
{
|
||||
public boolean enabled;
|
||||
public boolean buildings;
|
||||
}
|
||||
|
||||
// this class is just bridge between Java and C++ worlds, we must not create it
|
||||
private Framework() {}
|
||||
|
||||
|
@ -178,5 +184,7 @@ public class Framework
|
|||
|
||||
public native static void nativeDeregisterMaps();
|
||||
|
||||
public native static void nativeAllow3dMode(boolean allow3d, boolean allow3dBuildings);
|
||||
public native static void nativeGet3dMode(_3dModeParams result);
|
||||
|
||||
public native static void nativeSet3dMode(boolean allow3d, boolean allow3dBuildings);
|
||||
}
|
||||
|
|
|
@ -43,8 +43,9 @@
|
|||
return NO;
|
||||
|
||||
Framework & frm = GetFramework();
|
||||
frm.Save3dMode(is3d || is3dBuildings, is3dBuildings);
|
||||
frm.Allow3dMode(is3d || is3dBuildings, is3dBuildings);
|
||||
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
|
|
@ -2078,7 +2078,6 @@ void Framework::SetRouteFinishPoint(m2::PointD const & pt, bool isValid)
|
|||
|
||||
void Framework::Allow3dMode(bool allow3d, bool allow3dBuildings)
|
||||
{
|
||||
Save3dMode(allow3d, allow3dBuildings);
|
||||
CallDrapeFunction(bind(&df::DrapeEngine::Allow3dMode, _1, allow3d, allow3dBuildings));
|
||||
}
|
||||
|
||||
|
|
|
@ -201,6 +201,7 @@ bool SearchPanel::Try3dModeCmd(QString const & str)
|
|||
if (!is3dModeOn && !is3dBuildingsOn && !is3dModeOff)
|
||||
return false;
|
||||
|
||||
m_pDrawWidget->GetFramework().Save3dMode(is3dModeOn || is3dBuildingsOn, is3dBuildingsOn);
|
||||
m_pDrawWidget->GetFramework().Allow3dMode(is3dModeOn || is3dBuildingsOn, is3dBuildingsOn);
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue