base_scale: 2.6;
- group { "Digit";
- parts {
- textblock { "digit"; scale;
- desc { "default";
- text.style: "ATO011";
- }
- desc { "default.expanded";
- text.style: "ATO011L";
- }
- desc { "simple";
- text.style: "ATO012L";
- }
- desc { "timer";
- text.style: "ATO010";
- }
- desc { "ring";
- text.style: "ATO021L";
- }
- }
- program {
- signal: "digits,set,stopwatch,expand";
- source: "counter";
- action: STATE_SET "default.expanded";
- target: "digit";
- }
- program {
- signal: "digits,set,stopwatch,contract";
- source: "counter";
- action: STATE_SET "default";
- target: "digit";
- }
- program {
- signal: "digits,set,simple";
- source: "counter";
- action: STATE_SET "simple";
- target: "digit";
- }
- program {
- signal: "digits,set,timer";
- source: "counter";
- action: STATE_SET "timer";
- target: "digit";
- }
- program {
- signal: "digits,set,ring";
- source: "counter";
- action: STATE_SET "ring";
- target: "digit";
- }
- }
- }
-
- group { "ExtraDigit";
+ group { "Counter";
parts {
- textblock { "digit"; scale;
+ spacer { "base"; scale;
desc { "default";
- max: -1 145;
- align: 0.5 0.0;
- text.style: "ATO012";
- rel1 { relative: 0.0 1.0; to_y: "pd.top"; }
- rel2 { relative: 1.0 0.0; to_y: "pd.bottom"; }
+ max: 500 230;
}
- desc { "default.expanded";
- inherit: "default";
- max: -1 117;
- text.style: "ATO012L";
+ desc { "stopwatch.default";
+ min: 538 227;
+ max: 538 227;
}
- desc { "simple";
- text.style: "ATO012L";
+ desc { "stopwatch.expanded";
+ min: 648 200;
+ max: 648 200;
}
- }
- spacer { "pd.top"; scale;
- desc { "default";
- align: 0.5 0.0;
- min: 0 65;
- max: -1 65;
+ desc { "timer.default";
+ min: 558 200;
+ max: 558 200;
}
}
- spacer { "pd.bottom"; scale;
- desc { "default";
- align: 0.5 1.0;
- min: 0 17;
- max: -1 17;
- }
- }
- program {
- signal: "digits,set,stopwatch,expand";
- source: "counter";
- action: STATE_SET "default.expanded";
- target: "digit";
- }
- program {
- signal: "digits,set,stopwatch,contract";
- source: "counter";
- action: STATE_SET "default";
- target: "digit";
- }
- program {
- signal: "digits,set,simple";
- source: "counter";
- action: STATE_SET "simple";
- target: "digit";
- }
- }
- }
-
- group { "Colon";
- parts {
- textblock { "colon"; scale;
+ textblock { "txt.main"; scale;
desc { "default";
+ align: 0.0 0.5;
+ min: 392 0;
+ max: 392 -1;
+ fixed: 1 0;
+ rel1.to: "base";
+ rel2.to: "base";
text {
style: "ATO011";
- text: ":";
+ text: "00:00";
+ max: 1 1;
}
+ hid;
}
- desc { "default.expanded";
- inherit: "default";
- text.style: "ATO011L";
- }
- desc { "simple";
- inherit: "default";
- text.style: "ATO012L";
- }
- desc { "timer";
+ desc { "stopwatch.default";
inherit: "default";
- text.style: "ATO010";
+ vis;
}
- desc { "ring";
+ desc { "stopwatch.expanded";
inherit: "default";
- text.style: "ATO021L";
+ min: 532 0;
+ max: 532 -1;
+ text {
+ style: "ATO011L";
+ text: "00:00:00";
+ max: 1 1;
+ }
+ vis;
}
- }
- program {
- signal: "digits,set,stopwatch,expand";
- source: "counter";
- action: STATE_SET "default.expanded";
- target: "colon";
- }
- program {
- signal: "digits,set,stopwatch,contract";
- source: "counter";
- action: STATE_SET "default";
- target: "colon";
- }
- program {
- signal: "digits,set,simple";
- source: "counter";
- action: STATE_SET "simple";
- target: "colon";
- }
- program {
- signal: "digits,set,timer";
- source: "counter";
- action: STATE_SET "timer";
- target: "colon";
- }
- program {
- signal: "digits,set,ring";
- source: "counter";
- action: STATE_SET "ring";
- target: "colon";
- }
- }
- }
-
- group { "Dot";
- parts {
- textblock { "dot"; scale;
- desc { "default";
+ desc { "lap.default";
+ align: 0.5 1.0;
text {
style: "ATO012";
- text: ".";
+ text: "00:00:00";
+ align: 0.5 1.0;
}
- rel1 { relative: 0.0 1.0; to_y: "pd.top"; }
- rel2 { relative: 1.0 0.0; to_y: "pd.bottom"; }
- }
- desc { "default.expanded";
- inherit: "default";
- text.style: "ATO012L";
- }
- desc { "simple";
- text.style: "ATO012L";
- text.text: ".";
}
- }
- spacer { "pd.top"; scale;
- desc { "default";
- align: 0.5 0.0;
- min: 0 65;
- max: -1 65;
+ desc { "timer.default";
+ rel1.to: "base";
+ rel2.to: "base";
+ align: 0.5 0.5;
+ text {
+ style: "ATO021L";
+ text: "00:00:00";
+ max: 1 0;
+ }
}
}
- spacer { "pd.bottom"; scale;
+ spacer { "pd.bottom.ms"; scale;
desc { "default";
- align: 0.5 1.0;
min: 0 17;
max: -1 17;
+ align: 0.5 1.0;
+ rel1.to: "base";
+ rel2.to: "base";
}
- }
- program {
- signal: "digits,set,stopwatch,expand";
- source: "counter";
- action: STATE_SET "default.expanded";
- target: "dot";
- }
- program {
- signal: "digits,set,stopwatch,contract";
- source: "counter";
- action: STATE_SET "default";
- target: "dot";
- }
- program {
- signal: "digits,set,simple";
- source: "counter";
- action: STATE_SET "simple";
- target: "dot";
- }
- }
- }
-
- group { "Counter";
- parts {
- table { "digits"; scale;
- desc { "default";
- max: 528 -1;
- }
- desc { "hidden";
+ desc { "stopwatch.default";
inherit: "default";
- hid;
- }
- table {
- items {
- #define ITEM(part_name, source_name, pos, wg) \
- item { \
- source: source_name; \
- name: part_name; \
- position: pos 0; \
- weight: wg 1.0; \
- span: 1 1; \
- align: -1.0 -1.0; \
- }
- ITEM("m.digit.1", "Digit", 3, 1.0);
- ITEM("m.digit.2", "Digit", 4, 1.0);
- ITEM("s.colon", "Colon", 5, 0.15);
- ITEM("s.digit.1", "Digit", 6, 1.0);
- ITEM("s.digit.2", "Digit", 7, 1.0);
- ITEM("ms.dot", "Dot", 8, 0.15);
- ITEM("ms.digit.1", "ExtraDigit", 9, 0.7);
- ITEM("ms.digit.2", "ExtraDigit", 10, 0.7);
- }
- }
- }
- program {
- signal: "counter,set,hidden";
- source: "counter";
- action: STATE_SET "hidden";
- target: "digits";
- }
- program {
- signal: "counter,set,visible";
- source: "counter";
- action: STATE_SET "default";
- target: "digits";
- }
- }
- }
-
- group { "Counter.expanded";
- parts {
- table { "digits"; scale;
- desc { "default";
- max: 648 -1;
}
- desc { "hidden";
+ desc { "stopwatch.expanded";
inherit: "default";
- hid;
- }
- table {
- items {
- #define ITEM(part_name, source_name, pos, wg) \
- item { \
- source: source_name; \
- name: part_name; \
- position: pos 0; \
- weight: wg 1.0; \
- span: 1 1; \
- align: -1.0 -1.0; \
- }
- ITEM("h.digit.1", "Digit", 0, 1.0);
- ITEM("h.digit.2", "Digit", 1, 1.0);
- ITEM("m.colon", "Colon", 2, 0.15);
- ITEM("m.digit.1", "Digit", 3, 1.0);
- ITEM("m.digit.2", "Digit", 4, 1.0);
- ITEM("s.colon", "Colon", 5, 0.15);
- ITEM("s.digit.1", "Digit", 6, 1.0);
- ITEM("s.digit.2", "Digit", 7, 1.0);
- ITEM("ms.dot", "Dot", 8, 0.15);
- ITEM("ms.digit.1", "ExtraDigit", 9, 0.7);
- ITEM("ms.digit.2", "ExtraDigit", 10, 0.7);
- }
+ min: 0 20;
+ max: -1 20;
}
}
- program {
- signal: "counter,set,hidden";
- source: "counter";
- action: STATE_SET "hidden";
- target: "digits";
- }
- program {
- signal: "counter,set,visible";
- source: "counter";
- action: STATE_SET "default";
- target: "digits";
- }
- }
- }
-
- group { "Counter.simple";
- parts {
- table { "digits"; scale;
+ textblock { "txt.ms"; scale;
desc { "default";
- max: 350 -1;
+ rel1.to: "";
+ rel2 {
+ relative: 1.0 0.0;
+ to_x: "base";
+ to_y: "pd.bottom.ms";
+ };
+ min: 130 145;
+ max: 130 145;
+ fixed: 1 1;
+ align: 1.0 1.0;
+ text {
+ style: "ATO012";
+ text: ".00";
+ max: 1 0;
+ }
+ hid;
}
- desc { "hidden";
+ desc { "stopwatch.default";
inherit: "default";
- hid;
+ vis;
}
- table {
- items {
- #define ITEM(part_name, source_name, pos, wg) \
- item { \
- source: source_name; \
- name: part_name; \
- position: pos 0; \
- weight: wg 1.0; \
- span: 1 1; \
- align: -1.0 -1.0; \
- }
- ITEM("m.digit.1", "Digit", 3, 1.0);
- ITEM("m.digit.2", "Digit", 4, 1.0);
- ITEM("s.colon", "Colon", 5, 0.15);
- ITEM("s.digit.1", "Digit", 6, 1.0);
- ITEM("s.digit.2", "Digit", 7, 1.0);
- ITEM("ms.dot", "Dot", 8, 0.15);
- ITEM("ms.digit.1", "ExtraDigit", 9, 1.0);
- ITEM("ms.digit.2", "ExtraDigit", 10, 1.0);
+ desc { "stopwatch.expanded";
+ inherit: "default";
+ min: 110 117;
+ max: 110 117;
+ text {
+ style: "ATO012L";
+ text: ".00";
}
+ vis;
}
}
program {
- signal: "counter,set,hidden";
+ signal: "counter,stopwatch,set";
source: "counter";
- action: STATE_SET "hidden";
- target: "digits";
- }
- program {
- signal: "counter,set,visible";
- source: "counter";
- action: STATE_SET "default";
- target: "digits";
- }
- }
- }
-
- group { "Counter.simple.expanded";
- parts {
- table { "digits"; scale;
- desc { "default";
- max: 469 -1;
- }
- desc { "hidden";
- inherit: "default";
- hid;
- }
- table {
- items {
- #define ITEM(part_name, source_name, pos, wg) \
- item { \
- source: source_name; \
- name: part_name; \
- position: pos 0; \
- weight: wg 1.0; \
- span: 1 1; \
- align: -1.0 -1.0; \
- }
- ITEM("h.digit.1", "Digit", 0, 1.0);
- ITEM("h.digit.2", "Digit", 1, 1.0);
- ITEM("m.colon", "Colon", 2, 0.15);
- ITEM("m.digit.1", "Digit", 3, 1.0);
- ITEM("m.digit.2", "Digit", 4, 1.0);
- ITEM("s.colon", "Colon", 5, 0.15);
- ITEM("s.digit.1", "Digit", 6, 1.0);
- ITEM("s.digit.2", "Digit", 7, 1.0);
- ITEM("ms.dot", "Dot", 8, 0.15);
- ITEM("ms.digit.1", "ExtraDigit", 9, 1.0);
- ITEM("ms.digit.2", "ExtraDigit", 10, 1.0);
- }
- }
+ action: STATE_SET "stopwatch.default";
+ target: "base";
+ target: "pd.bottom.ms";
+ target: "txt.main";
+ target: "txt.ms";
}
program {
- signal: "counter,set,hidden";
+ signal: "counter,stopwatch,set,expanded";
source: "counter";
- action: STATE_SET "hidden";
- target: "digits";
+ action: STATE_SET "stopwatch.expanded";
+ target: "base";
+ target: "pd.bottom.ms";
+ target: "txt.main";
+ target: "txt.ms";
}
program {
- signal: "counter,set,visible";
+ signal: "counter,lap,set";
source: "counter";
- action: STATE_SET "default";
- target: "digits";
- }
- }
- }
-
-
- group { "Counter.timer";
- parts {
- table { "digits"; scale;
- desc { "default";
- max: 620 -1;
- }
- desc { "hidden";
- inherit: "default";
- hid;
- }
- desc { "visible";
- inherit: "default";
- vis;
- }
- table {
- items {
- #define ITEM(part_name, source_name, pos, wg) \
- item { \
- source: source_name; \
- name: part_name; \
- position: pos 0; \
- weight: wg 1.0; \
- span: 1 1; \
- align: -1.0 -1.0; \
- }
- ITEM("h.digit.1", "Digit", 0, 1.0);
- ITEM("h.digit.2", "Digit", 1, 1.0);
- ITEM("m.colon", "Colon", 2, 0.15);
- ITEM("m.digit.1", "Digit", 3, 1.0);
- ITEM("m.digit.2", "Digit", 4, 1.0);
- ITEM("s.colon", "Colon", 5, 0.15);
- ITEM("s.digit.1", "Digit", 6, 1.0);
- ITEM("s.digit.2", "Digit", 7, 1.0);
- }
- }
+ action: STATE_SET "lap.default";
+ target: "txt.main";
+ target: "txt.ms";
}
program {
- signal: "counter,set,hidden";
+ signal: "counter,timer,set";
source: "counter";
- action: STATE_SET "hidden";
- target: "digits";
+ action: STATE_SET "timer.default";
+ target: "base";
+ target: "txt.main";
}
program {
- signal: "counter,set,visible";
+ signal: "counter,hidden,set";
source: "counter";
- action: STATE_SET "visible";
- target: "digits";
+ action: STATE_SET "default";
+ target: "txt.main";
+ target: "txt.ms";
}
}
}
#include <ctime>
#include <string>
+#include <sstream>
#include "View/CounterView.h"
#include "Utils/Utils.h"
#include "Utils/Log.h"
-#define SIGNAL_SET_COUNTER_SIMPLE "digits,set,simple"
-#define SIGNAL_SET_COUNTER_TIMER "digits,set,timer"
-#define SIGNAL_SET_COUNTER_CONTRACT "digits,set,stopwatch,contract"
-#define SIGNAL_SET_COUNTER_EXPAND "digits,set,stopwatch,expand"
+#define SIGNAL_SET_COUNTER_STOPWATCH "counter,stopwatch,set"
+#define SIGNAL_SET_COUNTER_STOPWATCH_EXPAND "counter,stopwatch,set,expanded"
+#define SIGNAL_SET_COUNTER_TIMER "counter,timer,set"
+#define SIGNAL_SET_COUNTER_LAP "counter,lap,set"
+#define SIGNAL_SET_COUNTER_HIDDEN "counter,hidden,set"
namespace view {
const char *CounterView::EDJE_FILE = "edje/Counter.edj";
const char *CounterView::GROUP = "Counter";
-const char *CounterView::GROUP_EXPANDED = "Counter.expanded";
-const char *CounterView::GROUP_SIMPLE = "Counter.simple";
-const char *CounterView::GROUP_SIMPLE_EXPANDED = "Counter.simple.expanded";
-const char *CounterView::GROUP_TIMER = "Counter.timer";
CounterView::CounterView(ui::IView &parent, CounterType type) : layout_(NULL)
{
Evas_Object *parentEo = parent.GetEvasObject();
-
layout_ = elm_layout_add(parentEo);
- if (SetTheme(type)) {
+ if (!elm_layout_file_set(layout_, GetEdjeFilePath(), GROUP)) {
+ ERR("elm_layout_file_set");
+ evas_object_del(layout_);
+ return;
+ }
+
+ if (!SetTheme(type)) {
ERR("Could not set layout");
evas_object_del(layout_);
return;
evas_object_del(layout_);
}
-bool CounterView::SetTheme(CounterType type, bool expand)
+bool CounterView::SetTheme(CounterType type)
{
- const char *group = NULL;
const char *signal = NULL;
switch (type) {
+ case CounterType::COUNTER_TYPE_STOPWATCH:
+ signal = SIGNAL_SET_COUNTER_STOPWATCH;
+ break;
+ case CounterType::COUNTER_TYPE_STOPWATCH_EXPANDED:
+ signal = SIGNAL_SET_COUNTER_STOPWATCH_EXPAND;
+ break;
+ case CounterType::COUNTER_TYPE_LAP:
+ signal = SIGNAL_SET_COUNTER_LAP;
+ break;
case CounterType::COUNTER_TYPE_TIMER:
- group = GROUP_TIMER;
signal = SIGNAL_SET_COUNTER_TIMER;
break;
- case CounterType::COUNTER_TYPE_SIMPLE:
- group = expand ? GROUP_SIMPLE_EXPANDED : GROUP_SIMPLE;
- signal = SIGNAL_SET_COUNTER_SIMPLE;
- break;
- case CounterType::COUNTER_TYPE_STOPWATCH:
- group = expand ? GROUP_EXPANDED : GROUP;
- signal = expand ? SIGNAL_SET_COUNTER_EXPAND : SIGNAL_SET_COUNTER_CONTRACT;
+ case CounterType::COUNTER_TYPE_HIDDEN:
+ signal = SIGNAL_SET_COUNTER_HIDDEN;
break;
default:
ERR("Unhandled counter theme type");
- return true;
+ return false;
}
this->type_ = type;
- if (!elm_layout_file_set(layout_, GetEdjeFilePath(), group)) {
- DBG("elm_layout_file_set failed");
- return true;
- }
-
- Evas_Object *ly = elm_layout_edje_get(layout_);
- Evas_Object *digit = NULL;
-
- for (unsigned i = 0; i < 11; ++i) {
- digit = edje_object_part_table_child_get(ly, "digits", i, 0);
- if (digit && signal)
- edje_object_signal_emit(digit, signal, "counter");
- }
+ elm_object_signal_emit(layout_, signal, "counter");
- return false;
+ return true;
}
Evas_Object *CounterView::GetEvasObject()
{
msec /= 10;
- SetDigitText(std::to_string((unsigned)(hour/10)).c_str(), 0);
- SetDigitText(std::to_string((unsigned)(hour%10)).c_str(), 1);
+ std::stringstream text;
+ std::stringstream subtext;
- if (hour > 0) {
+ if (type_ == CounterType::COUNTER_TYPE_TIMER && hour <= 0)
+ text << "00:";
+ else if (hour > 0) {
+ text << (hour < 10 ? "0" : "") << hour << ":";
Expand();
- } else
- Contract();
-
- SetDigitText(std::to_string((unsigned)(min/10)).c_str(), 3);
- SetDigitText(std::to_string((unsigned)(min%10)).c_str(), 4);
- SetDigitText(std::to_string((unsigned)(sec/10)).c_str(), 6);
- SetDigitText(std::to_string((unsigned)(sec%10)).c_str(), 7);
- SetDigitText(std::to_string((unsigned)(msec/10)).c_str(), 9);
- SetDigitText(std::to_string((unsigned)(msec%10)).c_str(), 10);
+ }
+
+ text << (min < 10 ? "0" : "") << min << ":";
+ text << (sec < 10 ? "0" : "") << sec;
+
+ if (type_ == CounterType::COUNTER_TYPE_STOPWATCH ||
+ type_ == CounterType::COUNTER_TYPE_STOPWATCH_EXPANDED) {
+ subtext << "." << (msec < 10 ? "0" : "") << msec;
+ elm_object_part_text_set(layout_, "txt.ms", subtext.str().c_str());
+ } else if (type_ == CounterType::COUNTER_TYPE_LAP) {
+ text << ":" << (msec < 10 ? "0" : "") << msec;
+ }
+
+ elm_object_part_text_set(layout_, "txt.main", text.str().c_str());
}
bool CounterView::SetDigitText(const char *text, unsigned col)
void CounterView::Reset()
{
- for (int i = 0; i < 11; ++i)
- SetDigitText("0", i);
+ switch (type_) {
+ case CounterType::COUNTER_TYPE_STOPWATCH:
+ elm_object_part_text_set(layout_, "txt.main", "00:00");
+ elm_object_part_text_set(layout_, "txt.ms", ".00");
+ break;
+ case CounterType::COUNTER_TYPE_STOPWATCH_EXPANDED:
+ case CounterType::COUNTER_TYPE_LAP:
+ case CounterType::COUNTER_TYPE_TIMER:
+ elm_object_part_text_set(layout_, "txt.main", "00:00:00");
+ break;
+ default:
+ ERR("Could not reset counter");
+ }
}
void CounterView::Expand()
{
- SetTheme(this->type_, true);
+ if (type_ == CounterType::COUNTER_TYPE_STOPWATCH)
+ SetTheme(CounterType::COUNTER_TYPE_STOPWATCH_EXPANDED);
}
void CounterView::Contract()
{
- SetTheme(this->type_, false);
+ if (type_ == CounterType::COUNTER_TYPE_STOPWATCH_EXPANDED)
+ SetTheme(CounterType::COUNTER_TYPE_STOPWATCH);
}
void CounterView::Show()
{
- elm_object_signal_emit(layout_, "counter,set,visible", "counter");
+ SetTheme(type_);
}
void CounterView::Hide()
{
- elm_object_signal_emit(layout_, "counter,set,hidden", "counter");
+ elm_object_signal_emit(layout_, SIGNAL_SET_COUNTER_HIDDEN, "counter");
}