From 5662102135574da4320cab0d31876fd222819055 Mon Sep 17 00:00:00 2001 From: Kamil Lipiszko Date: Sat, 1 Oct 2016 13:48:17 +0200 Subject: [PATCH] timer: Reset button fix. Hide Reset button on 00:00:00 value set. Change-Id: I20221160c9f51cfc20c25db42589674f66336460 --- clock/inc/View/TimerView.h | 3 ++ clock/src/Presenter/TimerPresenter.cpp | 2 +- clock/src/View/TimerView.cpp | 67 ++++++++++++++++++++++++---------- 3 files changed, 52 insertions(+), 20 deletions(-) diff --git a/clock/inc/View/TimerView.h b/clock/inc/View/TimerView.h index b087874..1291652 100644 --- a/clock/inc/View/TimerView.h +++ b/clock/inc/View/TimerView.h @@ -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; diff --git a/clock/src/Presenter/TimerPresenter.cpp b/clock/src/Presenter/TimerPresenter.cpp index 89bd5ae..24fa5f4 100644 --- a/clock/src/Presenter/TimerPresenter.cpp +++ b/clock/src/Presenter/TimerPresenter.cpp @@ -114,7 +114,7 @@ void TimerPresenter::TimeIsUp() model_->Stop(); model_->Reset(); animator_.Stop(); - view_->ShowStartupMenu(); + view_->ShowEditingMenu(); } } //namespace presenter diff --git a/clock/src/View/TimerView.cpp b/clock/src/View/TimerView.cpp index ca295db..650f3bd 100644 --- a/clock/src/View/TimerView.cpp +++ b/clock/src/View/TimerView.cpp @@ -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(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() -- 2.7.4