timer: Reset button fix. 03/90603/5
authorKamil Lipiszko <k.lipiszko@samsung.com>
Sat, 1 Oct 2016 11:48:17 +0000 (13:48 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Mon, 10 Oct 2016 08:24:34 +0000 (01:24 -0700)
Hide Reset button on 00:00:00 value set.

Change-Id: I20221160c9f51cfc20c25db42589674f66336460

clock/inc/View/TimerView.h
clock/src/Presenter/TimerPresenter.cpp
clock/src/View/TimerView.cpp

index b087874..1291652 100644 (file)
@@ -71,6 +71,9 @@ namespace view {
                void ShowPausedMenu(void);
                void ShowEditingMenu(void);
 
+               void ShowSelector();
+               void ShowCounter();
+
        private:
                Evas_Object *layout_ = NULL;
                Evas_Object *selector_ = NULL;
index 89bd5ae..24fa5f4 100644 (file)
@@ -114,7 +114,7 @@ void TimerPresenter::TimeIsUp()
        model_->Stop();
        model_->Reset();
        animator_.Stop();
-       view_->ShowStartupMenu();
+       view_->ShowEditingMenu();
 }
 
 } //namespace presenter
index ca295db..650f3bd 100644 (file)
@@ -58,6 +58,11 @@ TimerView::TimerView() : set_time_()
 
 TimerView::~TimerView()
 {
+       if (selector_)
+               evas_object_del(selector_);
+       if (layout_)
+               evas_object_del(layout_);
+
        delete counter_;
 }
 
@@ -232,8 +237,6 @@ void TimerView::EntryFocusedCb(void *data, Evas_Object *obj, void *event_info)
        TimerView *object = static_cast<TimerView *>(data);
 
        elm_entry_select_all(obj);
-
-       elm_object_signal_emit(object->layout_, "menu.editing.show", "timer");
 }
 
 void TimerView::EntryUnfocusedCb(void *data, Evas_Object *obj, void *event_info)
@@ -257,10 +260,13 @@ void TimerView::EntryChangedCb(void *data, Evas_Object *obj, void *event_info)
 
        object->UpdateTime();
 
-       if (object->set_time_.Hour || object->set_time_.Min || object->set_time_.Sec)
+       if (object->set_time_.Hour || object->set_time_.Min || object->set_time_.Sec) {
                object->SetEnabledStartButton(true);
-       else
+               object->ShowEditingMenu();
+       } else {
                object->SetEnabledStartButton(false);
+               object->ShowStartupMenu();
+       }
 
        object->counter_->DisplayTime(
                        object->set_time_.Hour,
@@ -318,17 +324,42 @@ void TimerView::UnfocusEntries()
        elm_object_focus_set(entry, EINA_FALSE);
 }
 
+void TimerView::ShowSelector()
+{
+       Evas_Object *content = elm_object_part_content_get(layout_, "sw.content");
+       if (selector_ && content != selector_) {
+               elm_object_part_content_unset(layout_, "sw.content");
+               evas_object_hide(content);
+
+               elm_object_part_content_set(layout_, "sw.content", selector_);
+               evas_object_show(selector_);
+       }
+}
+
+void TimerView::ShowCounter()
+{
+       Evas_Object *content = elm_object_part_content_unset(layout_, "sw.content");
+       if (counter_->GetEvasObject() && content != counter_->GetEvasObject()) {
+               elm_object_part_content_unset(layout_, "sw.content");
+               evas_object_hide(content);
+
+               elm_object_part_content_set(layout_, "sw.content", counter_->GetEvasObject());
+               evas_object_show(counter_->GetEvasObject());
+       }
+}
+
 void TimerView::ShowStartupMenu(void)
 {
        if (!layout_)
                return;
 
-       Evas_Object *content = elm_object_part_content_unset(layout_, "sw.content");
-       if (content)
-               evas_object_hide(content);
+       if (set_time_.Hour || set_time_.Min || set_time_.Sec) {
+               ShowEditingMenu();
+               return;
+       }
+
+       ShowSelector();
 
-       if (selector_)
-               elm_object_part_content_set(layout_, "sw.content", selector_);
        elm_object_signal_emit(layout_, "menu.startup.show", "timer");
        elm_object_signal_emit(layout_, "arrow.btn.show", "timer");
 }
@@ -338,31 +369,29 @@ void TimerView::ShowRunningMenu(void)
        if (!layout_)
                return;
 
-       Evas_Object *content = elm_object_part_content_unset(layout_, "sw.content");
-       if (content)
-               evas_object_hide(content);
-
-       if (counter_->GetEvasObject())
-               elm_object_part_content_set(layout_, "sw.content", counter_->GetEvasObject());
+       ShowCounter();
 
        elm_object_signal_emit(layout_, "arrow.btn.hide", "timer");
        elm_object_signal_emit(layout_, "menu.running.show", "timer");
 }
 
-void TimerView::ShowPausedMenu(void)
+void TimerView::ShowEditingMenu(void)
 {
        if (!layout_)
                return;
 
-       elm_object_signal_emit(layout_, "menu.paused.show", "timer");
+       ShowSelector();
+
+       elm_object_signal_emit(layout_, "arrow.btn.show", "timer");
+       elm_object_signal_emit(layout_, "menu.editing.show", "timer");
 }
 
-void TimerView::ShowEditingMenu(void)
+void TimerView::ShowPausedMenu(void)
 {
        if (!layout_)
                return;
 
-       elm_object_signal_emit(layout_, "menu.editing.show", "timer");
+       elm_object_signal_emit(layout_, "menu.paused.show", "timer");
 }
 
 void TimerView::CreateMenuButtons()