-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_time_controller.cpp
More file actions
53 lines (43 loc) · 1.4 KB
/
set_time_controller.cpp
File metadata and controls
53 lines (43 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "set_time_controller.h"
#include <icons/clock-24.h>
using namespace mono;
using mono::geo::Rect;
using mono::geo::Point;
SetTimeController::SetTimeController(const Rect &rct) : SceneController(rct),
hourSelect(Rect(25, 30, 50, 70), 0, 23),
minSelect(Rect(100, 30, 50, 70), 0, 59),
clockBtn(Rect(25,220-65,125,35), "Set time"),
clockView(Point(176/2-24/2, 20), clock24)
{
addView(hourSelect);
addView(minSelect);
addView(clockBtn);
addView(clockView);
setShowCallback<SetTimeController>(this, &SetTimeController::didShow);
setHideCallback<SetTimeController>(this, &SetTimeController::didHide);
minSelect.setTouchIncrementThreshold(6);
clockBtn.setClickCallback<SetTimeController>(this, &SetTimeController::requestDismiss);
clockIsSet = false;
}
void SetTimeController::requestDismiss()
{
dismissHandler.call();
}
bool SetTimeController::IsClockSet() const
{
return clockIsSet;
}
void SetTimeController::didShow(const SceneController &)
{
DateTime now = DateTime::now();
hourSelect.setValue(now.Hours());
minSelect.setValue(now.Minutes());
}
void SetTimeController::didHide(const mono::ui::SceneController &)
{
DateTime now = DateTime::now();
DateTime newTime(now.Year(), now.Month(), now.Days(),
hourSelect.Value(), minSelect.Value(), 0);
DateTime::setSystemDateTime(newTime);
clockIsSet = true;
}