}
//Check orientation manually to create a content.
-
- if (degree == 0 || degree == 180)
+ if (ui_view_get_orientation_mode(view) == UI_VIEW_ORIENTATION_MODE_PORTRAIT)
{
//Portrait
content = create_content(base, "ViewMgr Demo<br>Rotation", prev_btn_clicked_cb, next_btn_clicked_cb);
static bool
view9_load_cb(ui_standard_view *view, void *data)
{
- //FIXME: Change below code to more convenient and clear way.
- if (ui_view_get_degree(view) == 90 || ui_view_get_degree(view) == 270)
+ if (ui_view_get_orientation_mode(view) == UI_VIEW_ORIENTATION_MODE_PORTRAIT)
{
- return view9_landscape_cb(view, data);
- } else {
return view9_portrait_cb(view, data);
+ } else {
+ return view9_landscape_cb(view, data);
}
}
{
UiStandardView::onRotate(degree);
- if (this->getDegree() == 0 || this->getDegree() == 180)
+ if (this->getOrientationMode() == UI_VIEW_ORIENTATION_MODE_PORTRAIT)
{
//Portrait
Evas_Object *content = createContent(this->getBase(), "ViewMgr++ Demo<br>Rotation",
{
UiStandardView::onLoad();
- //FIXME: Change below code to more convenient and clear way.
- if (this->getDegree() == 90 || this->getDegree() == 270)
- this->onLandscape();
- else
+ if (this->getOrientationMode() == UI_VIEW_ORIENTATION_MODE_PORTRAIT)
this->onPortrait();
+ else
+ this->onLandscape();
}
void onPortrait()
*/
const UiMenu *getMenu();
+ /**
+ * @brief Get current view's orientation mode.
+ *
+ * @return Current orientation mode, one of #UiViewOrientationMode.
+ */
+ virtual UiViewOrientationMode getOrientationMode() override;
+
protected:
/**
* @brief This is making UiMenu instance.
*/
EAPI int ui_view_get_degree(ui_view *view);
+/**
+ * @brief Get current view's orientation mode.
+ *
+ * @param view An ui_view instance
+ *
+ * @return Current orientation mode, one of #ui_view_orientation_mode.
+ */
+EAPI ui_view_orientation_mode ui_view_get_orientation_mode(ui_view *view);
+
/**
* @brief Set transition style of a view.
*
*/
virtual int getDegree() { return 0; }
+ /**
+ * @brief Get current view's orientation mode.
+ *
+ * @return Current orientation mode, one of #UiViewOrientationMode.
+ */
+ virtual UiViewOrientationMode getOrientationMode() { return UI_VIEW_ORIENTATION_MODE_UNKOWN; }
+
protected:
/**
* @brief View portrait state.
};
typedef enum UiViewState ui_view_state;
+/**
+ * Possible values for view orientation mode.
+ */
+enum UiViewOrientationMode
+{
+ UI_VIEW_ORIENTATION_MODE_UNKOWN = 0, ///< Unknown state (Exceptional case)
+ UI_VIEW_ORIENTATION_MODE_PORTRAIT, ///< Portrait state
+ UI_VIEW_ORIENTATION_MODE_LANDSCAPE, ///< Landscape state
+ UI_VIEW_ORIENTATION_MODE_LAST,
+};
+typedef enum UiViewOrientationMode ui_view_orientation_mode;
+
#endif /* _UI_IFACE_TYPES_H_ */
{
return this->_menu;
}
+
+ UiViewOrientationMode getOrientationMode();
};
}
this->_menu->onLandscape();
}
+UiViewOrientationMode UiViewImpl::getOrientationMode()
+{
+ switch (this->_view->getDegree()) {
+ case 0:
+ case 180:
+ return UI_VIEW_ORIENTATION_MODE_PORTRAIT;
+ break;
+ case 90:
+ case 270:
+ return UI_VIEW_ORIENTATION_MODE_LANDSCAPE;
+ break;
+ }
+
+ return UI_VIEW_ORIENTATION_MODE_UNKOWN;
+}
+
+
/***********************************************************************************************/
/* External class Implementation */
/***********************************************************************************************/
this->_impl->onLandscape();
}
+UiViewOrientationMode UiView::getOrientationMode()
+{
+ return this->_impl->getOrientationMode();
+}
+
const UiMenu *UiView::getMenu()
{
return this->_impl->getMenu();
return view->getDegree();
}
+EAPI ui_view_orientation_mode ui_view_get_orientation_mode(ui_view *view)
+{
+ if (!validate_view(view)) return UI_VIEW_ORIENTATION_MODE_UNKOWN;
+ return view->getOrientationMode();
+}
+
EAPI bool ui_view_set_transition_style(ui_view *view, const char *style)
{
if (!validate_view(view)) return false;