From ac7585be1443a2c9f6c70070aff7269235b73d11 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Tue, 22 Mar 2016 22:36:45 +0900 Subject: [PATCH] use macro for readability. Change-Id: I5f002e0481654ab15ef38a4499a88462e7debe04 --- src/lib/efl/mobile/ui_basic_view.cpp | 8 +++++--- src/lib/efl/ui_view.cpp | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/lib/efl/mobile/ui_basic_view.cpp b/src/lib/efl/mobile/ui_basic_view.cpp index 4215e34..ca3fd00 100644 --- a/src/lib/efl/mobile/ui_basic_view.cpp +++ b/src/lib/efl/mobile/ui_basic_view.cpp @@ -23,6 +23,8 @@ using namespace efl_viewmgr; using namespace viewmgr; +#define MY_VIEWMGR dynamic_cast(this->get_viewmgr()) +#define MY_CONTROLLER dynamic_cast(this->get_controller())) static void update_menu(Evas_Object *win, Evas_Object *ctxpopup) { @@ -81,7 +83,7 @@ bool ui_basic_view::create_layout() } //Set software back key, if it's needed - ui_viewmgr *viewmgr = dynamic_cast(ui_iface_view::get_viewmgr()); + ui_viewmgr *viewmgr = MY_VIEWMGR; if (viewmgr->need_soft_key()) { Evas_Object *prev_btn = elm_button_add(layout); @@ -363,12 +365,12 @@ void ui_basic_view::on_menu() if (this->get_controller()) { - (dynamic_cast(this->get_controller()))->on_menu(); + (MY_CONTROLLER->on_menu(); } if (this->ctxpopup) { - update_menu(dynamic_cast(this->get_viewmgr())->get_window(), this->ctxpopup); + update_menu(MY_VIEWMGR->get_window(), this->ctxpopup); } } diff --git a/src/lib/efl/ui_view.cpp b/src/lib/efl/ui_view.cpp index 924e8dd..5cf2a09 100644 --- a/src/lib/efl/ui_view.cpp +++ b/src/lib/efl/ui_view.cpp @@ -19,6 +19,9 @@ using namespace efl_viewmgr; using namespace viewmgr; +#define MY_CONTROLLER dynamic_cast(this->get_controller()) +#define MY_VIEWMGR dynamic_cast(this->get_viewmgr()) + ui_view::ui_view(ui_controller *controller, const char *name) : ui_iface_view(controller, name) { @@ -41,7 +44,7 @@ Evas_Object *ui_view::set_content(Evas_Object *content) Evas_Object *ui_view::get_base() { - ui_viewmgr *viewmgr = dynamic_cast(ui_iface_view::get_viewmgr()); + ui_viewmgr *viewmgr = MY_VIEWMGR; if (!viewmgr) { return NULL; @@ -57,7 +60,7 @@ void ui_view::unload_content() Evas_Object *ui_view ::get_parent() { - ui_viewmgr *viewmgr = dynamic_cast(this->get_viewmgr()); + ui_viewmgr *viewmgr = MY_VIEWMGR; if (!viewmgr) { LOGE("Failed to get a viewmgr"); @@ -72,7 +75,7 @@ void ui_view::set_indicator(ui_view_indicator indicator) ui_iface_view::set_indicator(indicator); - ui_viewmgr *viewmgr = dynamic_cast(this->get_viewmgr()); + ui_viewmgr *viewmgr = MY_VIEWMGR; if (!viewmgr->is_activated()) return; @@ -85,19 +88,19 @@ void ui_view::on_back() { if (this->get_controller()) { - if (!dynamic_cast(this->get_controller())->on_back()) + if (!MY_CONTROLLER->on_back()) { return; } } - dynamic_cast(this->get_viewmgr())->pop_view(); + MY_VIEWMGR->pop_view(); } void ui_view::on_rotate(int degree) { if (this->get_controller()) { - dynamic_cast(this->get_controller())->on_rotate(degree); + MY_CONTROLLER->on_rotate(degree); } } @@ -105,7 +108,7 @@ void ui_view::on_portrait() { if (this->get_controller()) { - dynamic_cast(this->get_controller())->on_portrait(); + MY_CONTROLLER->on_portrait(); } } @@ -113,7 +116,7 @@ void ui_view::on_landscape() { if (this->get_controller()) { - dynamic_cast(this->get_controller())->on_landscape(); + MY_CONTROLLER->on_landscape(); } } void ui_view::set_event_block(bool block) @@ -124,7 +127,7 @@ void ui_view::set_event_block(bool block) int ui_view::get_degree() { - ui_viewmgr *viewmgr = dynamic_cast(ui_iface_view::get_viewmgr()); + ui_viewmgr *viewmgr = MY_VIEWMGR; if (!viewmgr) { LOGE("Failed to get a viewmgr"); -- 2.7.4