From 9b3f1ce8264cc802973d5f493eb28d0faeb5845a Mon Sep 17 00:00:00 2001 From: Syed Khaja Moinuddin Date: Fri, 5 Apr 2013 20:38:40 +0900 Subject: [PATCH] Fixed some new issues in EditDate / Time w.r.t Element Width. Signed-off-by: Syed Khaja Moinuddin Change-Id: Id3d688288ff3833c3d7d3a750e93825c9eb231c5 Signed-off-by: Syed Khaja Moinuddin --- src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp | 1 + src/ui/controls/FUiCtrl_EditDate.cpp | 3 +- src/ui/controls/FUiCtrl_EditDatePresenter.cpp | 73 ++++++++++++++++-------- src/ui/controls/FUiCtrl_EditTime.cpp | 3 +- src/ui/controls/FUiCtrl_EditTimePresenter.cpp | 58 ++++++++++--------- src/ui/inc/FUiCtrl_EditDatePresenter.h | 9 ++- src/ui/inc/FUiCtrl_EditTimePresenter.h | 7 ++- 7 files changed, 95 insertions(+), 59 deletions(-) diff --git a/src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp b/src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp index 7db1288..177768e 100755 --- a/src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp +++ b/src/ui/controls/FUiCtrl_DateTimeBarPresenter.cpp @@ -975,6 +975,7 @@ _DateTimeBarPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& __pDateTimeBar->SetVisibleState(false); __pDateTimeBar->Close(); ResetFlickAnimationTimer(); + __pDateTimeBar->FireDateTimeChangeEvent(DATE_INTERNAL_CHANGE_CANCELED); return true; } diff --git a/src/ui/controls/FUiCtrl_EditDate.cpp b/src/ui/controls/FUiCtrl_EditDate.cpp index 50e80a4..b002f00 100644 --- a/src/ui/controls/FUiCtrl_EditDate.cpp +++ b/src/ui/controls/FUiCtrl_EditDate.cpp @@ -840,6 +840,7 @@ void _EditDate::OnDateTimeChanged(const _Control& source, int year, int month, int day, int hour, int minute) { __pEditDatePresenter->Animate(); + __pEditDatePresenter->SetLastSelectedId(DATETIME_ID_NONE); Invalidate(); FireDateChangeEvent(DATE_INTERNAL_CHANGE_SAVED); return; @@ -848,8 +849,8 @@ _EditDate::OnDateTimeChanged(const _Control& source, int year, int month, int da void _EditDate::OnDateTimeChangeCanceled(const _Control& source) { + __pEditDatePresenter->SetLastSelectedId(DATETIME_ID_NONE); Invalidate(); - FireDateChangeEvent(DATE_INTERNAL_CHANGE_CANCELED); return; } diff --git a/src/ui/controls/FUiCtrl_EditDatePresenter.cpp b/src/ui/controls/FUiCtrl_EditDatePresenter.cpp index 5b534d2..75ee4e9 100644 --- a/src/ui/controls/FUiCtrl_EditDatePresenter.cpp +++ b/src/ui/controls/FUiCtrl_EditDatePresenter.cpp @@ -50,6 +50,9 @@ _EditDatePresenter::_EditDatePresenter(void) , __dayBounds(FloatRectangle()) , __monthBounds(FloatRectangle()) , __yearBounds(FloatRectangle()) + , __dayTouchBounds(FloatRectangle()) + , __monthTouchBounds(FloatRectangle()) + , __yearTouchBounds(FloatRectangle()) , __titleBounds(FloatRectangle()) , __datePickerEnabled(true) , __selectedId(DATETIME_ID_NONE) @@ -162,13 +165,13 @@ _EditDatePresenter::Initialize(void) __yearBounds.height = editDateHeight; } - __dayBounds.width = GetTextWidth(DATETIME_ID_DAY); - __monthBounds.width = GetTextWidth(DATETIME_ID_MONTH); - __yearBounds.width = GetTextWidth(DATETIME_ID_YEAR); + __dayBounds.width = __elementWidth; + __monthBounds.width = __elementWidth; + __yearBounds.width = __elementWidth; - __dayBounds.x = (__elementWidth - __dayBounds.width) / 2.0f; - __monthBounds.x = (__elementWidth - __monthBounds.width) / 2.0f; - __yearBounds.x = (__elementWidth - __yearBounds.width) / 2.0f; + __dayBounds.x = 0.0f; + __monthBounds.x = 0.0f; + __yearBounds.x = 0.0f; __dayBounds.y = bounds.y; __monthBounds.y = bounds.y; @@ -452,16 +455,18 @@ _EditDatePresenter::Draw(void) CalculateAreaBounds(); - r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_DAY), dayString); + r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_DAY), dayString, DATETIME_ID_DAY); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_MONTH), monthString); + r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_MONTH), monthString, DATETIME_ID_MONTH); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_YEAR), yearString); + r = DrawText(*pCanvas, GetDateAreaBounds(DATETIME_ID_YEAR), yearString, DATETIME_ID_YEAR); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); r = DrawDividers(*pCanvas); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + CalculateTouchAreaBounds(); + delete pCanvas; return r; @@ -478,28 +483,49 @@ _EditDatePresenter::CalculateAreaBounds(void) if (GetLocaleDateFormat() == DATE_FORMAT_DDMMYYYY) { - __monthBounds.x = __elementWidth + __dividerLineWidth + (__elementWidth - __monthBounds.width) / 2.0f; - __yearBounds.x = (2.0f * __elementWidth) + (2.0f * __dividerLineWidth) + (__elementWidth - __yearBounds.width) / 2.0f; + __monthBounds.x = __dayBounds.x + __dayBounds.width + __dividerLineWidth; + __yearBounds.x = __monthBounds.x + __monthBounds.width + __dividerLineWidth; } else if (GetLocaleDateFormat() == DATE_FORMAT_MMDDYYYY) { - __dayBounds.x = __elementWidth + __dividerLineWidth + (__elementWidth - __dayBounds.width) / 2.0f; - __yearBounds.x = (2.0f * __elementWidth) + (2.0f * __dividerLineWidth) + (__elementWidth - __yearBounds.width) / 2.0f; + __dayBounds.x = __monthBounds.x + __monthBounds.width + __dividerLineWidth; + __yearBounds.x = __dayBounds.x + __dayBounds.width + __dividerLineWidth; } else if (GetLocaleDateFormat() == DATE_FORMAT_YYYYMMDD) { - __monthBounds.x = __elementWidth + __dividerLineWidth + (__elementWidth - __monthBounds.width) / 2.0f; - __dayBounds.x = (2.0f * __elementWidth) + (2.0f * __dividerLineWidth) + (__elementWidth - __dayBounds.width) / 2.0f; + __monthBounds.x = __yearBounds.x + __yearBounds.width + __dividerLineWidth; + __dayBounds.x = __monthBounds.x + __monthBounds.width + __dividerLineWidth; } else if (GetLocaleDateFormat() == DATE_FORMAT_YYYYDDMM) { - __dayBounds.x = __elementWidth + __dividerLineWidth + (__elementWidth - __dayBounds.width) / 2.0f; - __monthBounds.x = (2.0f * __elementWidth) + (2.0f * __dividerLineWidth) + (__elementWidth - __monthBounds.width) / 2.0f; + __dayBounds.x = __yearBounds.x + __yearBounds.width + __dividerLineWidth; + __monthBounds.x = __dayBounds.x + __dayBounds.width + __dividerLineWidth; } return r; } +void +_EditDatePresenter::CalculateTouchAreaBounds(void) +{ + __dayTouchBounds.width = GetTextWidth(DATETIME_ID_DAY); + __dayTouchBounds.x = __dayBounds.x + (__elementWidth - __dayTouchBounds.width) / 2.0f; + __dayTouchBounds.y = __dayBounds.y; + __dayTouchBounds.height = __dayBounds.height; + + __monthTouchBounds.width = GetTextWidth(DATETIME_ID_MONTH); + __monthTouchBounds.x = __monthBounds.x + (__elementWidth - __monthTouchBounds.width) / 2.0f; + __monthTouchBounds.y = __monthBounds.y; + __monthTouchBounds.height = __monthBounds.height; + + __yearTouchBounds.width = GetTextWidth(DATETIME_ID_YEAR); + __yearTouchBounds.x = __yearBounds.x + (__elementWidth - __yearTouchBounds.width) / 2.0f; + __yearTouchBounds.y = __yearBounds.y; + __yearTouchBounds.height = __yearBounds.height; + + return; +} + result _EditDatePresenter::DrawTitle(Canvas& canvas) { @@ -518,7 +544,7 @@ _EditDatePresenter::DrawTitle(Canvas& canvas) } result -_EditDatePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text) +_EditDatePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text, _DateTimeId boxId) { Color textColor; @@ -531,9 +557,6 @@ _EditDatePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const GET_COLOR_CONFIG(EDITDATE::TEXT_NORMAL, textColor); } - _DateTimeId boxId = DATETIME_ID_NONE; - boxId = GetBoxIdFromPosition(FloatPoint(bounds.x, bounds.y)); - if (boxId == __selectedId && boxId != DATETIME_ID_NONE) { GET_COLOR_CONFIG(EDITDATE::TEXT_PRESSED, textColor); @@ -621,20 +644,20 @@ _EditDatePresenter::GetBoxIdFromPosition(const FloatPoint& point) const { _DateTimeId displayBoxId = DATETIME_ID_NONE; - if (point.y < __dayBounds.y || point.y > __dayBounds.y + __dayBounds.height) + if (point.y < __dayTouchBounds.y || point.y > __dayTouchBounds.y + __dayTouchBounds.height) { return displayBoxId; } - if (__dayBounds.Contains(point) == true) + if (__dayTouchBounds.Contains(point) == true) { displayBoxId = DATETIME_ID_DAY; } - else if (__monthBounds.Contains(point) == true) + else if (__monthTouchBounds.Contains(point) == true) { displayBoxId = DATETIME_ID_MONTH; } - else if (__yearBounds.Contains(point) == true) + else if (__yearTouchBounds.Contains(point) == true) { displayBoxId = DATETIME_ID_YEAR; } diff --git a/src/ui/controls/FUiCtrl_EditTime.cpp b/src/ui/controls/FUiCtrl_EditTime.cpp index a6ecad8..7a9723d 100644 --- a/src/ui/controls/FUiCtrl_EditTime.cpp +++ b/src/ui/controls/FUiCtrl_EditTime.cpp @@ -634,6 +634,7 @@ void _EditTime::OnDateTimeChanged(const _Control& source, int year, int month, int day, int hour, int minute) { __pEditTimePresenter->Animate(); + __pEditTimePresenter->SetLastSelectedId(DATETIME_ID_NONE); Invalidate(); FireTimeChangeEvent(TIME_INTERNAL_CHANGE_SAVED); return; @@ -642,8 +643,8 @@ _EditTime::OnDateTimeChanged(const _Control& source, int year, int month, int da void _EditTime::OnDateTimeChangeCanceled(const _Control& source) { + __pEditTimePresenter->SetLastSelectedId(DATETIME_ID_NONE); Invalidate(); - FireTimeChangeEvent(TIME_INTERNAL_CHANGE_CANCELED); return; } diff --git a/src/ui/controls/FUiCtrl_EditTimePresenter.cpp b/src/ui/controls/FUiCtrl_EditTimePresenter.cpp index d4e6689..f91244d 100755 --- a/src/ui/controls/FUiCtrl_EditTimePresenter.cpp +++ b/src/ui/controls/FUiCtrl_EditTimePresenter.cpp @@ -48,6 +48,8 @@ _EditTimePresenter::_EditTimePresenter(const String& title) , __pEditTime(null) , __bounds(FloatRectangle()) , __titleBounds(FloatRectangle()) + , __hourTouchBounds(FloatRectangle()) + , __minuteTouchBounds(FloatRectangle()) , __ampmString(String()) , __hourString(String()) , __minuteString(String()) @@ -333,13 +335,12 @@ _EditTimePresenter::GetDisplayAreaBoundsFromHoursStyle(_DateTimeId displayBoxId) if (displayBoxId == DATETIME_ID_HOUR) { - bounds.width = GetTextWidth(displayBoxId); + bounds.width = timeElementWidth; } else if (displayBoxId == DATETIME_ID_MINUTE) { - bounds.width = GetTextWidth(displayBoxId); - bounds.x = bounds.x + timeElementWidth + colonWidth + 2.0f * colonMargin + (timeElementWidth - bounds.width) / 2.0f; - + bounds.x = bounds.x + timeElementWidth + colonWidth + 2.0f * colonMargin; + bounds.width = timeElementWidth; } else if (displayBoxId == DATETIME_ID_AMPM) { @@ -535,6 +536,22 @@ _EditTimePresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bou return r; } +void +_EditTimePresenter::CalculateTouchAreaBounds(const FloatRectangle hourBounds, const FloatRectangle minuteBounds) +{ + __hourTouchBounds.width = GetTextWidth(DATETIME_ID_HOUR); + __hourTouchBounds.x = hourBounds.x + (hourBounds.width - __hourTouchBounds.width) / 2.0f; + __hourTouchBounds.y = hourBounds.y; + __hourTouchBounds.height = hourBounds.height; + + __minuteTouchBounds.width = GetTextWidth(DATETIME_ID_MINUTE); + __minuteTouchBounds.x = minuteBounds.x + (minuteBounds.width - __minuteTouchBounds.width) / 2.0f; + __minuteTouchBounds.y = minuteBounds.y; + __minuteTouchBounds.height = minuteBounds.height; + + return; +} + result _EditTimePresenter::InitializeTitleObject(void) { @@ -601,7 +618,6 @@ _EditTimePresenter::Draw(void) FloatRectangle colonBounds(0.0f, 0.0f, 0.0f, 0.0f); float colonMargin = 0.0f; - float hourMinuteWidth = 0.0f; Dimension textArea; @@ -665,9 +681,8 @@ _EditTimePresenter::Draw(void) GET_SHAPE_CONFIG(EDITTIME::COLON_WIDTH, __pEditTime->GetOrientation(), colonBounds.width); GET_SHAPE_CONFIG(EDITTIME::COLON_MARGIN, __pEditTime->GetOrientation(), colonMargin); GET_SHAPE_CONFIG(EDITTIME::AMPM_HEIGHT, __pEditTime->GetOrientation(), colonBounds.height); - GET_SHAPE_CONFIG(EDITTIME::HOUR_MINUTE_WIDTH, __pEditTime->GetOrientation(), hourMinuteWidth); - colonBounds.x = hourBounds.x + hourMinuteWidth + colonMargin; + colonBounds.x = hourBounds.x + hourBounds.width + colonMargin; colonBounds.y = hourBounds.y + (hourBounds.height - colonBounds.height) / 2.0f; if (__title.IsEmpty() == false) @@ -676,21 +691,22 @@ _EditTimePresenter::Draw(void) SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); } - r = DrawText(*pCanvas, hourBounds, __hourString); + r = DrawText(*pCanvas, hourBounds, __hourString, DATETIME_ID_HOUR); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); - r = DrawText(*pCanvas, minuteBounds, __minuteString); + r = DrawText(*pCanvas, minuteBounds, __minuteString, DATETIME_ID_MINUTE); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); if (__24hours == false) { - r = DrawText(*pCanvas, ampmBounds, __ampmString, __amPmTextSize); + r = DrawText(*pCanvas, ampmBounds, __ampmString, DATETIME_ID_AMPM, __amPmTextSize); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); } r = DrawColon(*pCanvas, colonBounds); SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + CalculateTouchAreaBounds(hourBounds, minuteBounds); CATCH: delete pCanvas; @@ -711,12 +727,6 @@ _EditTimePresenter::DrawColon(Canvas& canvas, const FloatRectangle& bounds) r = DrawResourceBitmap(canvas, bounds, __pColonColorReplacementBitmap); } - if ( r != E_SUCCESS) - { - r = DrawText(canvas, bounds, L":"); - SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); - } - return r; } @@ -739,15 +749,12 @@ _EditTimePresenter::DrawTitle(Canvas& canvas) } result -_EditTimePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text, float textSize) +_EditTimePresenter::DrawText(Canvas& canvas, const FloatRectangle& bounds, const String& text, _DateTimeId boxId, float textSize) { result r = E_SUCCESS; Color textColor; - _DateTimeId boxId = DATETIME_ID_NONE; - boxId = GetBoxIdFromPosition(FloatPoint(bounds.x + 1.0f, bounds.y)); - if (!__pEditTime->IsEnabled()) { if (boxId == DATETIME_ID_AMPM) @@ -822,28 +829,23 @@ _EditTimePresenter::GetBoxIdFromPosition(const FloatPoint& point) const { _DateTimeId displayBoxId = DATETIME_ID_NONE; - FloatRectangle hourBounds(0.0f, 0.0f, 0.0f, 0.0f); - FloatRectangle minuteBounds(0.0f, 0.0f, 0.0f, 0.0f); FloatRectangle ampmBounds(0.0f, 0.0f, 0.0f, 0.0f); - hourBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_HOUR); - minuteBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_MINUTE); - if (__24hours == false) { ampmBounds = GetDisplayAreaBoundsFromHoursStyle(DATETIME_ID_AMPM); } - if (point.y < hourBounds.y || point.y > hourBounds.y + hourBounds.height) + if (point.y < __hourTouchBounds.y || point.y > __hourTouchBounds.y + __hourTouchBounds.height) { return displayBoxId; } - if (hourBounds.Contains(point) == true) + if (__hourTouchBounds.Contains(point) == true) { displayBoxId = DATETIME_ID_HOUR; } - else if (minuteBounds.Contains(point) == true) + else if (__minuteTouchBounds.Contains(point) == true) { displayBoxId = DATETIME_ID_MINUTE; } diff --git a/src/ui/inc/FUiCtrl_EditDatePresenter.h b/src/ui/inc/FUiCtrl_EditDatePresenter.h index 35fdcf1..45f4beb 100644 --- a/src/ui/inc/FUiCtrl_EditDatePresenter.h +++ b/src/ui/inc/FUiCtrl_EditDatePresenter.h @@ -66,6 +66,7 @@ public: result Draw(void); _DateTimeId GetLastSelectedId(void) const; + void SetLastSelectedId(_DateTimeId boxId); Tizen::Graphics::FloatRectangle GetDateAreaBounds(_DateTimeId id) const; Tizen::Graphics::FloatRectangle GetTitleBounds(void) const; int GetLocaleDateFormat(void) const; @@ -93,10 +94,11 @@ private: float GetTextWidth(_DateTimeId boxId) const; result CalculateAreaBounds(void); result DrawTitle(Tizen::Graphics::Canvas& canvas); - result DrawText(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, const Tizen::Base::String& text); + result DrawText(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, const Tizen::Base::String& text, _DateTimeId boxId = DATETIME_ID_NONE); result DrawDividers(Tizen::Graphics::Canvas& canvas); _DateTimeId GetBoxIdFromPosition(const Tizen::Graphics::FloatPoint& point) const; - void SetLastSelectedId(_DateTimeId boxId); + + void CalculateTouchAreaBounds(void); private: _DateTimeModel* __pEditDateTimeModel; @@ -105,6 +107,9 @@ private: Tizen::Graphics::FloatRectangle __dayBounds; Tizen::Graphics::FloatRectangle __monthBounds; Tizen::Graphics::FloatRectangle __yearBounds; + Tizen::Graphics::FloatRectangle __dayTouchBounds; + Tizen::Graphics::FloatRectangle __monthTouchBounds; + Tizen::Graphics::FloatRectangle __yearTouchBounds; Tizen::Graphics::FloatRectangle __titleBounds; Tizen::Base::String __title; Tizen::Base::String __lastSelectedValue; diff --git a/src/ui/inc/FUiCtrl_EditTimePresenter.h b/src/ui/inc/FUiCtrl_EditTimePresenter.h index 7d9e462..ae204d7 100644 --- a/src/ui/inc/FUiCtrl_EditTimePresenter.h +++ b/src/ui/inc/FUiCtrl_EditTimePresenter.h @@ -59,6 +59,7 @@ public: bool Is24HourNotationEnabled(void) const; _DateTimeId GetLastSelectedId(void) const; + void SetLastSelectedId(_DateTimeId boxId); Tizen::Graphics::FloatRectangle GetDisplayAreaBoundsFromHoursStyle(_DateTimeId displayBoxId) const; float GetTextWidth(_DateTimeId boxId) const; void SetTitleBounds(void); @@ -93,12 +94,12 @@ private: void SetTimeConversion(void); result DrawTitle(Tizen::Graphics::Canvas& canvas); - result DrawText(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, const Tizen::Base::String& text, float textSize = 0.0f); + result DrawText(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, const Tizen::Base::String& text, _DateTimeId displayBoxId, float textSize = 0.0f); result DrawColon(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds); _DateTimeId GetBoxIdFromPosition(const Tizen::Graphics::FloatPoint& point) const; - void SetLastSelectedId(_DateTimeId boxId); result LoadResource(void); result DrawResourceBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, Tizen::Graphics::Bitmap* pBitmap); + void CalculateTouchAreaBounds(const Tizen::Graphics::FloatRectangle hourBounds, const Tizen::Graphics::FloatRectangle minuteBounds); private: _DateTimeModel* __pEditDateTimeModel; @@ -106,6 +107,8 @@ private: Tizen::Graphics::FloatRectangle __bounds; Tizen::Graphics::FloatRectangle __titleBounds; + Tizen::Graphics::FloatRectangle __hourTouchBounds; + Tizen::Graphics::FloatRectangle __minuteTouchBounds; Tizen::Base::String __ampmString; Tizen::Base::String __hourString; -- 2.7.4