rotation_callback,
this);
+ if (w > h) {
+ natural_orientation_ = ScreenOrientation::LANDSCAPE_PRIMARY;
+ } else {
+ natural_orientation_ = ScreenOrientation::PORTRAIT_PRIMARY;
+ }
+
initialized_ = true;
}
void NativeWindow::SetRotationLock(int degree) {
rotation_ = degree%360;
elm_win_wm_rotation_preferred_rotation_set(window_, rotation_);
+ elm_win_rotation_set(window_, rotation_);
}
+void NativeWindow::SetRotationLock(ScreenOrientation orientation) {
+ int portrait_natural_angle[] = {
+ 0, // PORTRAIT_PRIMARY
+ 180, // PORTRAIT_SECONDARY
+ 270, // LANDSCAPE_PRIMARY
+ 90 // LANDSCAPE_SECONDARY
+ };
+ int landscape_natural_angle[] = {
+ 270, // PORTRAIT_PRIMARY
+ 90, // PORTRAIT_SECONDARY
+ 0, // LANDSCAPE_PRIMARY
+ 180 // LANDSCAPE_SECONDARY
+ };
+ auto& convert_table =
+ natural_orientation_ == ScreenOrientation::PORTRAIT_PRIMARY ?
+ portrait_natural_angle :
+ landscape_natural_angle;
+ SetRotationLock(convert_table[static_cast<int>(orientation)]);
+}
+
+
void NativeWindow::SetAutoRotation() {
elm_win_wm_rotation_preferred_rotation_set(window_, -1);
if (elm_win_wm_rotation_supported_get(window_)) {
class NativeWindow {
public:
+ enum class ScreenOrientation {
+ PORTRAIT_PRIMARY = 0,
+ PORTRAIT_SECONDARY = 1,
+ LANDSCAPE_PRIMARY = 2,
+ LANDSCAPE_SECONDARY = 3
+ };
typedef std::function<void(int)> RotationHandler;
NativeWindow();
virtual ~NativeWindow();
Evas_Object* evas_object() const;
void SetContent(Evas_Object* content);
void SetRotationLock(int degree);
+ void SetRotationLock(ScreenOrientation orientation);
void SetAutoRotation();
int AddRotationHandler(RotationHandler handler);
void RemoveRotationHandler(int id);
void Active();
void InActive();
void FullScreen(bool enable);
+ ScreenOrientation natural_orientation() const { return natural_orientation_;}
protected:
virtual Evas_Object* CreateWindowInternal() = 0;
Evas_Object* content_;
int rotation_;
int handler_id_;
+ ScreenOrientation natural_orientation_;
std::map<int, RotationHandler> handler_table_;
};
ewk_context_tizen_extensible_api_string_set(ewk_context_,
kRotationLockFeature,
true);
+ } else if (app_data_->setting_info() != NULL &&
+ app_data_->setting_info()->screen_orientation()
+ == wgt::parse::SettingInfo::ScreenOrientation::PORTRAIT) {
+ window_->SetRotationLock(
+ NativeWindow::ScreenOrientation::PORTRAIT_PRIMARY);
+ } else if (app_data_->setting_info() != NULL &&
+ app_data_->setting_info()->screen_orientation()
+ == wgt::parse::SettingInfo::ScreenOrientation::LANDSCAPE) {
+ window_->SetRotationLock(
+ NativeWindow::ScreenOrientation::LANDSCAPE_PRIMARY);
}
if (app_data_->setting_info() != NULL &&
eina_stringshare_del(msg_id);
}
-void WebApplication::OnOrientationLock(WebView* view,
- bool lock,
- int preferred_rotation) {
+void WebApplication::OnOrientationLock(
+ WebView* view,
+ bool lock,
+ NativeWindow::ScreenOrientation preferred_rotation) {
if (view_stack_.size() == 0)
return;
virtual void OnClosedWebView(WebView * view);
virtual void OnReceivedWrtMessage(WebView* view,
Ewk_IPC_Wrt_Message_Data* msg);
- virtual void OnOrientationLock(WebView* view,
- bool lock,
- int preferred_rotation);
+ virtual void OnOrientationLock(
+ WebView* view,
+ bool lock,
+ NativeWindow::ScreenOrientation preferred_rotation);
virtual void OnHardwareKey(WebView* view, const std::string& keyname);
virtual void OnConsoleMessage(const std::string& msg, int level);
#include <string>
#include <functional>
+#include "runtime/native_window.h"
+
+
class Ewk_Context;
namespace wrt {
-class NativeWindow;
class WebViewImpl;
class WebView {
virtual void OnOrientationLock(
WebView* /*view*/,
bool /*lock*/,
- int /*preferred_rotation*/) {}
+ NativeWindow::ScreenOrientation /*preferred_rotation*/) {}
virtual void OnConsoleMessage(const std::string& /*msg*/, int /*level*/) {}
virtual bool OnContextMenuDisabled(WebView* /*view*/) { return false; }
return r;
}
-static int ToNativeRotation(int r) {
- switch (r) {
- case -90:
- return 90;
- case 90:
- return 270;
+static NativeWindow::ScreenOrientation ToNativeRotation(int r) {
+ if (r & EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY) {
+ return NativeWindow::ScreenOrientation::PORTRAIT_PRIMARY;
+ } else if (r & EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY) {
+ return NativeWindow::ScreenOrientation::PORTRAIT_SECONDARY;
+ } else if (r & EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY) {
+ return NativeWindow::ScreenOrientation::LANDSCAPE_PRIMARY;
+ } else {
+ return NativeWindow::ScreenOrientation::LANDSCAPE_SECONDARY;
}
- return r;
}
+
} // namespace
WebViewImpl::WebViewImpl(WebView* view,