*/
void NaviframeAdd();
- /**
- * @brief Creates content for Alarm, World Clock, Stopwatch and Timer pages
- */
- void CreatePages();
-
/**
* @brief Creates toolbar buttons.
*/
* @param[in] icon_path absolute icon path
* @param[in] translation msgid
*/
- void CreateToolbarItem(const char *icon_path, const char *msgid, IView *content);
+ void CreateToolbarItem(const char *icon_path, const char *msgid, IView **content);
Evas_Object *window_;
Evas_Object *conformant_;
/* Content */
Evas_Object *toolbar_;
- IView *alarm_;
- IView *world_clock_;
- IView *stop_watch_;
- IView *timer_;
+ IView *alarm_ = nullptr;
+ IView *world_clock_ = nullptr;
+ IView *stop_watch_ = nullptr;
+ IView *timer_ = nullptr;
+
+ static void ToolbarItemCb(void *data, Evas_Object *obj, void *event_info);
};
}
}
+Eina_Bool MainController::IdlerCb(void *data)
+{
+ MainController *controller = static_cast<MainController *>(data);
+ MainView *mainView = &(controller->main_view_);
+
+ controller->world_clock_model_ = new model::WorldClock();
+ controller->world_clock_presenter_ = new WorldClockPresenter(
+ (WorldClockView *)mainView->GetView(WORLD_CLOCK),
+ controller->world_clock_model_);
+
+ controller->stop_watch_model_ = new model::StopWatch();
+ controller->stop_watch_presenter_ = new StopWatchPresenter(
+ (StopWatchView *)mainView->GetView(STOP_WATCH),
+ controller->stop_watch_model_);
+
+ controller->timer_model_ = new model::Timer();
+ controller->timer_presenter_ = new TimerPresenter(
+ (TimerView *)mainView->GetView(TIMER),
+ controller->timer_model_);
+
+ controller->idler_ = nullptr;
+ return ECORE_CALLBACK_CANCEL;
+}
+
int MainController::Init()
{
if (initialized_) return 0;
- world_clock_model_ = new model::WorldClock();
- stop_watch_model_ = new model::StopWatch();
- timer_model_ = new model::Timer();
-
alarm_presenter_ = new AlarmPresenter((AlarmView *)main_view_.GetView(ALARM), provider_->GetAlarms());
- world_clock_presenter_ = new WorldClockPresenter((WorldClockView *)main_view_.GetView(WORLD_CLOCK), world_clock_model_);
- stop_watch_presenter_ = new StopWatchPresenter((StopWatchView *)main_view_.GetView(STOP_WATCH), stop_watch_model_);
- timer_presenter_ = new TimerPresenter((TimerView *)main_view_.GetView(TIMER), timer_model_);
+
+ idler_ = ecore_idler_add(IdlerCb, this);
connections_.push_back(utils::EventBus::AddListener<AlarmCreateRequestEvent>(
std::bind(&MainController::CreateNewAlarmPage, this, _1)));
{
if (!initialized_) return;
+ if (idler_) {
+ ecore_idler_del(idler_);
+ idler_ = nullptr;
+ }
+
delete alarm_presenter_;
delete world_clock_presenter_;
return EINA_FALSE;
}
-void toolbar_it_cb (void *data, Evas_Object *obj, void *event_info)
+void MainView::ToolbarItemCb(void *data, Evas_Object *obj, void *event_info)
{
- ui::IView *page = static_cast<ui::IView*>(data);
+ ui::IView **page = static_cast<ui::IView **>(data);
+ MainView *mainView = static_cast<MainView *>(evas_object_data_get(obj, "parent"));
+ if (!*page) {
+ ViewType type;
+ if (page == &(mainView->alarm_))
+ type = ViewType::ALARM;
+ else if (page == &(mainView->world_clock_))
+ type = ViewType::WORLD_CLOCK;
+ else if (page == &(mainView->stop_watch_))
+ type = ViewType::STOP_WATCH;
+ else if (page == &(mainView->timer_))
+ type = ViewType::TIMER;
+ else
+ return;
+
+ mainView->GetView(type);
+ }
Evas_Object *layout = elm_object_parent_widget_get(obj);
Evas_Object *navi = elm_object_parent_widget_get(layout);
Evas_Object *prev = elm_object_item_content_unset(top);
evas_object_hide(prev);
- evas_object_show(page->GetEvasObject());
- elm_object_item_content_set(top, page->GetEvasObject());
+ evas_object_show((*page)->GetEvasObject());
+ elm_object_item_content_set(top, (*page)->GetEvasObject());
}
MainView::MainView()
elm_object_content_set(conformant_, naviframe_);
}
-void MainView::CreatePages()
-{
- alarm_ = new AlarmView(*this);
- world_clock_ = new WorldClockView(*this);
- stop_watch_ = new StopWatchView(*this);
- timer_ = new TimerView(*this);
-}
-
-void MainView::CreateToolbarItem(const char *icon_path, const char *msgid, IView *content)
+void MainView::CreateToolbarItem(const char *icon_path, const char *msgid, IView **content)
{
Elm_Object_Item *it = elm_toolbar_item_append(toolbar_, icon_path,
- Translate::Sprintf(msgid).c_str(), toolbar_it_cb, content);
+ Translate::Sprintf(msgid).c_str(), ToolbarItemCb, content);
elm_object_item_translatable_text_set(it, msgid);
+
+ evas_object_data_set(toolbar_, "parent", this);
}
void MainView::CreateToolbarButtons()
{
CreateToolbarItem(TizenAppUtils::GetResourcePath(TizenAppUtils::APP_DIR_RESOURCE,
- "images/tabs/clock_tabs_ic_alarm.png"), "IDS_CLOCK_BODY_ALARM", alarm_);
+ "images/tabs/clock_tabs_ic_alarm.png"), "IDS_CLOCK_BODY_ALARM", &alarm_);
CreateToolbarItem(TizenAppUtils::GetResourcePath(TizenAppUtils::APP_DIR_RESOURCE,
- "images/tabs/clock_tabs_ic_worldclock.png"), "IDS_CLOCK_BODY_WORLD_CLOCK", world_clock_);
+ "images/tabs/clock_tabs_ic_worldclock.png"), "IDS_CLOCK_BODY_WORLD_CLOCK", &world_clock_);
CreateToolbarItem(TizenAppUtils::GetResourcePath(TizenAppUtils::APP_DIR_RESOURCE,
- "images/tabs/clock_tabs_ic_stopwatch.png"), "IDS_CLOCK_BODY_STOPWATCH", stop_watch_);
+ "images/tabs/clock_tabs_ic_stopwatch.png"), "IDS_CLOCK_BODY_STOPWATCH", &stop_watch_);
CreateToolbarItem(TizenAppUtils::GetResourcePath(TizenAppUtils::APP_DIR_RESOURCE,
- "images/tabs/clock_tabs_ic_timer.png"), "IDS_CLOCK_BODY_TIMER", timer_);
+ "images/tabs/clock_tabs_ic_timer.png"), "IDS_CLOCK_BODY_TIMER", &timer_);
}
void MainView::CreateToolbar()
void MainView::CreateContent()
{
- CreatePages();
CreateToolbar();
Elm_Object_Item *item = elm_naviframe_item_push(naviframe_, NULL, NULL, NULL, NULL,
"tabbar/icon/notitle");
+ alarm_ = new AlarmView(*this);
elm_naviframe_item_pop_cb_set(item, naviframe_pop_cb, window_);
elm_object_item_part_content_set(item, "tabbar", toolbar_);
{
switch (type){
case ALARM:
+ if (!alarm_)
+ alarm_ = new AlarmView(*this);
return alarm_;
case WORLD_CLOCK:
+ if (!world_clock_)
+ world_clock_ = new WorldClockView(*this);
return world_clock_;
case STOP_WATCH:
+ if (!stop_watch_)
+ stop_watch_ = new StopWatchView(*this);
return stop_watch_;
case TIMER:
+ if (!timer_)
+ timer_ = new TimerView(*this);
return timer_;
default:
ERR("Wrong view type!");