void WebApplication::OnRendered(WebView* view) {
}
+
void WebApplication::OnReceivedWrtMessage(
WebView* view,
const Ewk_IPC_Wrt_Message_Data& message) {
// TODO(wy80.choi): To be implemented
}
+void WebApplication::OnOrientationLock(WebView* view,
+ bool lock,
+ int preferred_rotation) {
+ if (view_stack_.size() == 0)
+ return;
+
+ // Only top-most view can set the orientation relate operation
+ if (view_stack_.front() != view)
+ return;
+
+ // TODO(sngn.lee): check the orientaion setting
+ // if allow the auto orientation
+ // if (is not allow orientation) {
+ // return;
+ // }
+ if ( lock ) {
+ window_->SetRotationLock(preferred_rotation);
+ } else {
+ window_->SetAutoRotation();
+ }
+}
+
} // namespace wrt
virtual void OnRendered(WebView* view);
virtual void OnReceivedWrtMessage(WebView* view,
const Ewk_IPC_Wrt_Message_Data& message);
+ virtual void OnOrientationLock(WebView* view,
+ bool lock,
+ int preferred_rotation);
private:
void ClearViewStack();
static int ToWebRotation(int r) {
switch (r) {
- case 0:
- case 180:
- return r;
case 90:
return -90;
case 270:
return r;
}
+static int ToNativeRotation(int r) {
+ switch (r) {
+ case -90:
+ return 90;
+ case 90:
+ return 270;
+ }
+ return r;
+}
+
} // namespace
wrt_message_callback,
this);
+ // Orientation lock callback
+ auto orientation_lock_callback = [](Evas_Object* o,
+ Eina_Bool need_lock,
+ int orientation,
+ void* user_data) -> Eina_Bool {
+ WebView* self = static_cast<WebView*>(user_data);
+ if (self->listener_) {
+ self->listener_->OnOrientationLock(self,
+ need_lock,
+ ToNativeRotation(orientation));
+ }
+ return EINA_TRUE;
+ };
+ ewk_view_orientation_lock_callback_set(ewk_view_,
+ orientation_lock_callback,
+ this);
+
// rotation support
ewk_view_orientation_send(ewk_view_, ToWebRotation(window_->rotation()));
rotation_handler_id_ = window_->AddRotationHandler(
WebView* /*view*/, const std::string& /*keyname*/) {}
virtual void OnReceivedWrtMessage(
WebView* /*view*/, const Ewk_IPC_Wrt_Message_Data& /*msg*/) {}
+ virtual void OnOrientationLock(
+ WebView* /*view*/,
+ bool /*lock*/,
+ int /*preferred_rotation*/) {}
};
WebView(wrt::NativeWindow* window, Ewk_Context* context);