ui_basic_view *view = dynamic_cast<ui_basic_view *>(this->get_view());
+ //Check the current rotation for set portrait or landscape content if any.
+ LOGE("view 1 load rotation = %d\n", view->get_degree());
+
//Create a main content.
Evas_Object *content = create_content(view->get_base(), "ViewMgr Demo<br>Page 1",
//Prev Button Callback
return true;
}
+
+ void rotate(int degree)
+ {
+ LOGE("Current view's degree is %d\n", degree);
+ }
+
+ void portrait()
+ {
+ LOGE("View is on portrait mode\n");
+ }
+
+ void landscape()
+ {
+ LOGE("View is on landscape mode\n");
+ }
};
void create_page1(appdata_s *ad)
*/
virtual void destroy() {}
+ /** @brief Back key callback.
+ *
+ * @note In default. current view will be popped by viewmgr in those scenarios
+ * that viewmgr is requested to poo the current view.
+ * If you return false in the overriding, then popping will be stopped.
+ */
virtual bool back() { return true; }
+
+ /** @brief View rotate callback.
+ *
+ * @param degree Current rotation degree.
+ *
+ * @note This method will be called when view rotation occurred.
+ */
+ virtual void rotate(int degree) {}
+
+ /** @brief Portrait callback.
+ *
+ * @note When current view is on portrait mode.
+ */
+ virtual void portrait() {}
+
+ /** @brief Landscape callback.
+ *
+ * @note When current view is on landscape mode.
+ */
+ virtual void landscape() {}
};
}
{
friend class ui_viewmgr;
+protected:
+ /** @brief Unload current view's content
+ *
+ * @note Make this view's content as NULL, then destroy content.
+ */
+ virtual void unload_content();
+
+ /** @brief Get a parent object of view.
+ *
+ * @note This is calling viewmgr get_base() method internally.
+ *
+ * @return base layout of viewmgr.
+ */
+ Evas_Object *get_parent();
+
+ /** @brief toggle event block.
+ *
+ * @note It makes internal conformant event freeze during effect showing.
+ *
+ * @param block @c true, when blocking is enabled, otherwise @c false.
+ */
+ virtual void set_event_block(bool block);
+
public:
///Constructor.
ui_view(ui_controller *controller, const char *name = NULL);
*/
virtual Evas_Object *get_base();
+ /** @brief This is for calling controller's back method.
+ */
virtual void back();
- /** @brief Set the indicator mode.
- *
- * @param indicator The mode to set, one of #ui_view_indicator.
+ /** @brief This is for calling controller's rotate method.
*/
- void set_indicator(ui_view_indicator indicator);
+ virtual void rotate(int degree);
-protected:
- /** @brief Unload current view's content
- *
- * @note Make this view's content as NULL, then destroy content.
+ /** @brief This is for calling controller's portrait method.
*/
- virtual void unload_content();
+ virtual void portrait();
- /** @brief Get a parent object of view.
- *
- * @note This is calling viewmgr get_base() method internally.
+ /** @brief This is for calling controller's landscape method.
+ */
+ virtual void landscape();
+ /** @brief Set the indicator mode.
*
- * @return base layout of viewmgr.
+ * @param indicator The mode to set, one of #ui_view_indicator.
*/
- Evas_Object *get_parent();
+ void set_indicator(ui_view_indicator indicator);
- /** @brief toggle event block.
- *
- * @note It makes internal conformant event freeze during effect showing.
+ /** @brief Get current view's degree.
*
- * @param block @c true, when blocking is enabled, otherwise @c false.
+ * @return Current rotation degree, -1 if failed to get viewmgr degree.
*/
- virtual void set_event_block(bool block);
+ int get_degree();
};
}
* @note When this view is on destroying by popping or deleting.
*/
virtual void destroy() = 0;
+
+ /** @brief Back key callback.
+ *
+ * @note In default. current view will be popped by viewmgr in those scenarios
+ * that viewmgr is requested to poo the current view.
+ * If you return false in the overriding, then popping will be stopped.
+ */
+ virtual bool back() = 0;
+
+ /** @brief View rotate callback.
+ *
+ * @param degree Current rotation degree.
+ *
+ * @note This method will be called when view rotation occurred.
+ */
+ virtual void rotate(int degree) = 0;
+
+ /** @brief Portrait callback.
+ *
+ * @note When current view is on portrait mode.
+ */
+ virtual void portrait() = 0;
+
+ /** @brief Landscape callback.
+ *
+ * @note When current view is on landscape mode.
+ */
+ virtual void landscape() = 0;
};
}
dynamic_cast<ui_viewmgr *>(this->get_viewmgr())->pop_view();
}
+void ui_view::rotate(int degree)
+{
+ if (this->get_controller())
+ {
+ dynamic_cast<ui_controller *>(this->get_controller())->rotate(degree);
+ }
+}
+
+void ui_view::portrait()
+{
+ if (this->get_controller())
+ {
+ dynamic_cast<ui_controller *>(this->get_controller())->portrait();
+ }
+}
+
+void ui_view::landscape()
+{
+ if (this->get_controller())
+ {
+ dynamic_cast<ui_controller *>(this->get_controller())->landscape();
+ }
+}
void ui_view::set_event_block(bool block)
{
ui_iface_view::set_event_block(block);
evas_object_freeze_events_set(CONVERT_TO_EO(this->get_content()), block);
}
+
+int ui_view::get_degree()
+{
+ ui_viewmgr *viewmgr = dynamic_cast<ui_viewmgr *>(ui_iface_view::get_viewmgr());
+ if (!viewmgr)
+ {
+ LOGE("Failed to get a viewmgr");
+ return -1;
+ }
+ return elm_win_rotation_get(viewmgr->get_window());
+}
return;
}
+ //FIXME: Make a method? to set available rotation degree.
//Set window rotation
if (elm_win_wm_rotation_supported_get(this->win))
{
{ 0, 90, 180, 270 };
elm_win_wm_rotation_available_rotations_set(this->win, (const int *) (&rots), 4);
}
+ evas_object_smart_callback_add(this->win, "wm,rotation,changed",
+ [](void *data, Evas_Object *obj, void *event_info) -> void
+ {
+ int rot = elm_win_rotation_get(obj);
+
+ ui_viewmgr *viewmgr = static_cast<ui_viewmgr *>(data);
+ ui_view *view = viewmgr->get_last_view();
+ view->rotate(rot);
+
+ //FIXME: Change this configurable?
+ if (rot == 0 || rot == 180) view->portrait();
+ else view->landscape();
+ }
+ , this);
//Window is requested to delete.
evas_object_smart_callback_add(this->win, "delete,request",