this ui_iface_overlay is designed for overlaied object such as popup and menu...
Change-Id: I4aec2a3131cb208530677749bf2fed7716ce8c3c
{
class ui_view;
-class ui_menu: public viewmgr::ui_iface_rotatable
+class ui_menu: public viewmgr::ui_iface_overlay<Elm_Ctxpopup *>
{
friend class ui_view;
private:
- ui_view *view;
- Elm_Ctxpopup *ctxpopup;
-
ui_menu(ui_view *view);
virtual ~ui_menu();
virtual bool deactivate();
virtual bool set_content(Elm_Ctxpopup* ctxpopup);
virtual Elm_Ctxpopup *unset_content();
- virtual void on_back();
virtual bool is_activated();
virtual Evas_Object *get_base();
virtual int get_degree();
- virtual Elm_Ctxpopup *get_content()
- {
- return this->ctxpopup;
- }
};
}
namespace efl_viewmgr
{
-class ui_base_view;
-
-class ui_base_popup : public viewmgr::ui_iface_rotatable
+class ui_base_popup : public viewmgr::ui_iface_overlay<Elm_Popup *>
{
- friend class ui_base_view;
private:
- ui_base_view *view;
- Elm_Popup *popup;
-
Elm_Win *get_window();
public:
virtual bool activate();
virtual bool deactivate();
- virtual bool set_content(Elm_Ctxpopup* ctxpopup);
+ virtual bool set_content(Elm_Popup* ctxpopup);
virtual Elm_Popup *unset_content();
- virtual void on_back();
virtual bool is_activated();
virtual Evas_Object *get_base();
virtual int get_degree();
- virtual Elm_Popup *get_content()
- {
- return this->popup;
- }
};
}
#include <Elementary.h>
#include "../interface/ui_iface_viewmanager.h"
-#define CONVERT_TO_EO(T) static_cast<Evas_Object *>((T))
-#define CONVERT_TO_T(EO) static_cast<T>((EO))
-
namespace efl_viewmgr
{
class ui_base_popup;
#endif
#define LOG_TAG "UI_VIEWMGR"
+#define CONVERT_TO_EO(T) static_cast<Evas_Object *>((T))
+#define CONVERT_TO_T(EO) static_cast<T>((EO))
+#define UI_BASE_VIEWMGR efl_viewmgr::ui_base_viewmgr::get_instance()
+
#include "ui_base_singleton.h"
#include "ui_base_viewmgr.h"
#include "ui_base_view.h"
#include "ui_base_key_listener.h"
#include "ui_base_popup.h"
-
-
-#define UI_BASE_VIEWMGR efl_viewmgr::ui_base_viewmgr::get_instance()
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#ifndef UI_IFACE_OVERLAY_H
+#define UI_IFACE_OVERLAY_H
+
+namespace viewmgr
+{
+
+class ui_iface_view;
+
+template<typename T>
+class ui_iface_overlay: public ui_iface_rotatable
+{
+private:
+ ui_iface_view *view;
+ T content;
+
+protected:
+ ui_iface_overlay(ui_iface_view *view);
+ virtual ~ui_iface_overlay();
+ virtual bool set_content(T content);
+ virtual T unset_content();
+
+public:
+ ui_iface_view *get_view();
+ virtual T get_content();
+ virtual void on_back();
+ virtual bool activate() = 0;
+ virtual bool deactivate() = 0;
+ virtual bool is_activated() = 0;
+};
+
+
+template<typename T>
+ui_iface_overlay<T>::ui_iface_overlay(ui_iface_view *view)
+ : view(view), content(NULL)
+{
+}
+
+template<typename T>
+ui_iface_overlay<T>::~ui_iface_overlay()
+{
+}
+
+template<typename T>
+bool ui_iface_overlay<T>::set_content(T content)
+{
+ T prev = this->content;
+ this->content = content;
+ return true;
+}
+
+template<typename T>
+T ui_iface_overlay<T>::unset_content()
+{
+ T prev = this->content;
+ this->content = NULL;
+ return prev;
+}
+
+template<typename T>
+T ui_iface_overlay<T>::get_content()
+{
+ return this->content;
+}
+
+template<typename T>
+ui_iface_view *ui_iface_overlay<T>::get_view()
+{
+ return this->view;
+}
+
+template<typename T>
+void ui_iface_overlay<T>::on_back()
+{
+ this->deactivate();
+}
+
+}
+
+#endif /* UI_IFACE_OVERLAY_H */
* limitations under the License.
*
*/
-#ifndef UI_ROTATABLE_INTERFACE_H_
-#define UI_ROTATABLE_INTERFACE_H_
+#ifndef UI_IFACE_ROTATABLE_H_
+#define UI_IFACE_ROTATABLE_H_
namespace viewmgr
{
}
-#endif /* UI_ROTATABLE_INTERFACE_H_ */
+#endif /* UI_IFACE_ROTATABLE_H_ */
* limitations under the License.
*
*/
-#ifndef UI_VIEW_INTERFACE_H_
-#define UI_VIEW_INTERFACE_H_
+#ifndef UI_IFACE_VIEW_H_
+#define UI_IFACE_VIEW_H_
#include <string>
using namespace std;
-typedef void* T;
-
namespace viewmgr {
class ui_iface_viewmgr;
{
return this->indicator;
}
+
+ virtual int get_degree()
+ {
+ return 0;
+ }
};
}
-#endif /* UI_VIEW_INTERFACE_H_ */
+#endif /* UI_IFACE_VIEW_H_ */
* limitations under the License.
*
*/
-#ifndef UI_VIEWMANAGER_INTERFACE_H_
-#define UI_VIEWMANAGER_INTERFACE_H_
+#ifndef UI_IFACE_VIEWMANAGER_H_
+#define UI_IFACE_VIEWMANAGER_H_
#include <app.h>
#include <dlog.h>
UI_VIEW_INDICATOR_LAST
};
+typedef void* T;
+
#include "ui_iface_rotatable.h"
+#include "ui_iface_overlay.h"
#include "ui_iface_viewmgr.h"
#include "ui_iface_view.h"
-#endif /* UI_VIEWMANAGER_INTERFACE_H */
+#endif /* UI_IFACE_VIEWMANAGER_H */
* limitations under the License.
*
*/
-#ifndef UI_VIEWMGR_INTERFACE_H_
-#define UI_VIEWMGR_INTERFACE_H_
+#ifndef UI_IFACE_VIEWMGR_H_
+#define UI_IFACE_VIEWMGR_H_
#include <list>
}
-#endif /* UI_VIEWMGR_INTERFACE_H_ */
+#endif /* UI_IFACE_VIEWMGR_H_ */
static void win_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
ui_menu *menu = static_cast<ui_menu *>(data);
- Elm_Ctxpopup *ctxpopup = menu->get_content();
- if (!ctxpopup) return;
- if (!evas_object_visible_get(ctxpopup)) return;
+ if (!menu->is_activated()) return;
update_menu(menu);
}
ui_menu::ui_menu(ui_view *view)
- : view(view), ctxpopup(NULL)
+ : ui_iface_overlay(view)
{
Elm_Win *win = this->get_window();
evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, win_resize_cb, this);
{
Elm_Win *win = this->get_window();
if (win) evas_object_event_callback_del(win, EVAS_CALLBACK_RESIZE, win_resize_cb);
- evas_object_del(this->ctxpopup);
+ Elm_Ctxpopup *ctxpopup = this->unset_content();
+ evas_object_del(ctxpopup);
}
Elm_Win *ui_menu::get_window()
bool ui_menu::deactivate()
{
- if (this->ctxpopup)
- {
- elm_ctxpopup_dismiss(this->ctxpopup);
- }
- else
+ Elm_Ctxpopup *ctxpopup = this->get_content();
+ if (!ctxpopup)
{
LOGE("Content is not set! = ui_menu(%p)", this);
return false;
}
- this->view->on_resume();
+ elm_ctxpopup_dismiss(ctxpopup);
+ dynamic_cast<ui_view *>(this->get_view())->on_resume();
return true;
}
bool ui_menu::activate()
{
bool ret = update_menu(this);
- if (ret) this->view->on_pause();
+ if (ret) dynamic_cast<ui_view *>(this->get_view())->on_pause();
return ret;
}
bool ui_menu::set_content(Elm_Ctxpopup *ctxpopup)
{
- evas_object_del(this->ctxpopup);
+ Elm_Ctxpopup *prev = this->unset_content();
+ evas_object_del(prev);
+
+ if (!ctxpopup) return true;
//validation!
//FIXME: isa ?
evas_object_smart_callback_add(ctxpopup, "dismissed", ctxpopup_dismissed_cb, NULL);
evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL, ctxpopup_del_cb, this);
- this->ctxpopup = ctxpopup;
+ ui_iface_overlay::set_content(ctxpopup);
return true;
}
bool ui_menu::is_activated()
{
- if (!this->ctxpopup) return false;
- return evas_object_visible_get(this->ctxpopup);
+ Elm_Ctxpopup *ctxpopup = this->get_content();
+ if (!ctxpopup) return false;
+ return evas_object_visible_get(ctxpopup);
}
Elm_Ctxpopup *ui_menu::unset_content()
{
- if (!this->ctxpopup) return NULL;
+ Elm_Ctxpopup *ctxpopup = ui_iface_overlay::unset_content();
+ if (!ctxpopup) return NULL;
+
+ evas_object_smart_callback_del(ctxpopup, "dismissed", ctxpopup_dismissed_cb);
+ evas_object_event_callback_del(ctxpopup, EVAS_CALLBACK_DEL, ctxpopup_del_cb);
- Elm_Ctxpopup *prev = this->ctxpopup;
- this->ctxpopup = NULL;
- evas_object_smart_callback_del(prev, "dismissed", ctxpopup_dismissed_cb);
- evas_object_event_callback_del(prev, EVAS_CALLBACK_DEL, ctxpopup_del_cb);
- return prev;
+ return ctxpopup;
}
Evas_Object *ui_menu::get_base()
{
- if (!this->view)
- {
- LOGE("View is null?? menu(%p)", this);
- return NULL;
- }
-
return this->get_window();
}
-void ui_menu::on_back()
-{
- this->deactivate();
-}
-
int ui_menu::get_degree()
{
- return this->view->get_degree();
+ return this->get_view()->get_degree();
}
}
ui_base_popup::ui_base_popup(ui_base_view *view)
- : view(view), popup(NULL)
+ : ui_iface_overlay(view)
{
view->connect_popup(this);
}
ui_base_popup::~ui_base_popup()
{
- this->view->disconnect_popup(this);
- this->unset_content();
- evas_object_del(this->popup);
+ dynamic_cast<ui_base_view *>(this->get_view())->disconnect_popup(this);
+ Elm_Popup *popup = this->unset_content();
+ evas_object_del(popup);
}
Elm_Win *ui_base_popup::get_window()
bool ui_base_popup::deactivate()
{
- if (!this->popup)
+ Elm_Popup *popup = this->get_content();
+ if (!popup)
{
LOGE("Content is not set! = ui_base_popup(%p)", this);
return false;
}
- elm_popup_dismiss(this->popup);
- this->view->on_resume();
+ elm_popup_dismiss(popup);
+ dynamic_cast<ui_base_view*>(this->get_view())->on_resume();
return true;
}
bool ui_base_popup::activate()
{
bool ret = update_popup(this);
- if (ret) this->view->on_pause();
+ if (ret) dynamic_cast<ui_base_view*>(this->get_view())->on_pause();
return ret;
}
bool ui_base_popup::set_content(Elm_Popup *popup)
{
- evas_object_del(this->popup);
+ Elm_Popup *prev = this->unset_content();
+ evas_object_del(prev);
+
+ if (!popup) return true;
//validation!
//FIXME: isa ?
evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_del_cb, this);
evas_object_smart_callback_add(popup, "dismissed", popup_dismissed_cb, this);
- this->popup = popup;
+ ui_iface_overlay::set_content(popup);
return true;
}
bool ui_base_popup::is_activated()
{
- if (!this->popup) return false;
- return evas_object_visible_get(this->popup);
+ Elm_Popup *popup = this->get_content();
+ if (!popup) return false;
+ return evas_object_visible_get(popup);
}
Elm_Popup *ui_base_popup::unset_content()
{
- if (!this->popup) return NULL;
+ Elm_Popup *popup = ui_iface_overlay::unset_content();
+ if (!popup) return NULL;
+
+ evas_object_event_callback_del(popup, EVAS_CALLBACK_DEL, popup_del_cb);
+ evas_object_smart_callback_del(popup, "dismissed", popup_dismissed_cb);
- Elm_Popup *prev = this->popup;
- this->popup = NULL;
- evas_object_event_callback_del(prev, EVAS_CALLBACK_DEL, popup_del_cb);
- evas_object_smart_callback_del(prev, "dismissed", popup_dismissed_cb);
- return prev;
+ return popup;
}
Evas_Object *ui_base_popup::get_base()
{
- if (!this->view)
- {
- LOGE("View is null?? menu(%p)", this);
- return NULL;
- }
-
return this->get_window();
}
-void ui_base_popup::on_back()
-{
- this->deactivate();
-}
-
int ui_base_popup::get_degree()
{
- return this->view->get_degree();
+ return this->get_view()->get_degree();
}