[StopWatch][Timer] Replace table with simple textblock. 75/106175/12
authorKamil Lipiszko <k.lipiszko@samsung.com>
Tue, 20 Dec 2016 16:45:28 +0000 (17:45 +0100)
committerKamil Lipiszko <k.lipiszko@samsung.com>
Wed, 4 Jan 2017 09:42:50 +0000 (10:42 +0100)
When those two modules were created, there was no monospace font
and all digits were placed in edje table to keep them properly
aligned. Now at least digits are monospaced so there is no need
to align them manually.

Change-Id: Id47df1025d7201974e8784fbc123779941cdb299

clock/inc/View/CounterView.h
clock/res/edje/Counter.edc
clock/res/edje/StopWatch.edc
clock/res/edje/Timer.edc
clock/res/edje/ring.edc
clock/src/View/CounterView.cpp
clock/src/View/StopWatchView.cpp

index 2ca5274..7311466 100644 (file)
@@ -25,8 +25,10 @@ namespace view {
 
        enum class CounterType {
                COUNTER_TYPE_STOPWATCH,
-               COUNTER_TYPE_SIMPLE,
-               COUNTER_TYPE_TIMER
+               COUNTER_TYPE_STOPWATCH_EXPANDED,
+               COUNTER_TYPE_LAP,
+               COUNTER_TYPE_TIMER,
+               COUNTER_TYPE_HIDDEN
        };
 
        class CounterView : public ui::IView {
@@ -53,15 +55,11 @@ namespace view {
 
                static const char *EDJE_FILE;
                static const char *GROUP;
-               static const char *GROUP_EXPANDED;
-               static const char *GROUP_TIMER;
-               static const char *GROUP_SIMPLE;
-               static const char *GROUP_SIMPLE_EXPANDED;
 
                const char *GetEdjeFilePath(void);
 
                bool SetDigitText(const char *text, unsigned col);
-               bool SetTheme(CounterType type, bool expand = false);
+               bool SetTheme(CounterType type);
        };
 }
 
index 28c3307..8f90c0d 100644 (file)
@@ -45,468 +45,163 @@ collections {
 
        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";
                        }
                }
        }
index 7695baa..349c8af 100644 (file)
@@ -61,33 +61,28 @@ collections {
                                        rel2 { relative: 1.0 0.0; to: "sw.list"; }
                                }
                        }
-                       swallow { "sw.content"; scale;
+                       spacer { "sp.content";
                                desc { "default";
-                                       min: 0 227;
-                                       max: -1 227;
-                                       align: 0.5 0.5;
-                                       rel2 { relative: 1.0 0.0; to: "pd.bottom"; }
-                               }
-                               desc { "expanded";
-                                       inherit: "default";
-                                       min: 0 200;
-                                       max: -1 200;
+                                       rel2 { relative: 1.0 0.0; to_y: "pd.bottom"; };
                                }
                        }
-                       swallow { "sw.lap.counter"; scale;
+                       swallow { "sw.counter"; scale;
                                desc { "default";
-                                       min: 0 100;
-                                       max: -1 100;
-                                       align: 0.5 0.0;
-                                       rel1 { relative: 0.0 1.0; to: "sw.content"; }
-                                       rel2 { relative: 1.0 1.0; to_x: "sw.content"; }
+                                       align: 0.5 0.5;
+                                       min: 0 227;
+                                       max: -1 227;
+                                       fixed: 0 1;
+                                       rel1.to: "sp.content";
+                                       rel2.to: "sp.content";
                                }
                        }
-                       swallow { "sw.subcounter"; scale;
+                       swallow { "sw.lap.counter";
                                desc { "default";
-                                       min: 0 0;
-                                       max: -1 120;
-                                       rel1 { relative: 0.0 1.0; to: "sw.content"; }
+                                       align: 0.5 1.0;
+                                       rel2 {
+                                               relative: 1.0 0.0;
+                                               to: "pd.bottom";
+                                       }
                                }
                        }
                        swallow { "sw.list"; scale;
@@ -187,7 +182,7 @@ collections {
                                signal: "counter.expand";
                                source: "stopwatch";
                                action: STATE_SET "expanded" ;
-                               target: "sw.content";
+                               target: "sp.content";
                        }
                        program {
                                signal: "menu.startup.show";
index 099afd1..3eb2336 100644 (file)
@@ -195,8 +195,8 @@ collections {
                        spacer { "pd.selector.left"; scale;
                                desc {
                                        fixed: 1 0;
-                                       min: 18 0; //TODO value from guide does not fit
-                                       max: 18 -1;
+                                       min: 46 0; //TODO value from guide does not fit
+                                       max: 46 -1;
                                        align: 0.0 0.5;
                                        rel1 { to_x: "sw.content"; }
                                }
@@ -204,8 +204,8 @@ collections {
                        spacer { "pd.selector.right"; scale;
                                desc {
                                        fixed: 1 0;
-                                       min: 18 0;
-                                       max: 18 -1;
+                                       min: 46 0;
+                                       max: 46 -1;
                                        align: 1.0 0.5;
                                        rel2 { to_x: "sw.content"; }
                                }
index 2b353f5..7fc310b 100644 (file)
@@ -96,14 +96,21 @@ collections {
                        }
                        swallow { "sw.content"; scale; nomouse;
                                desc { "default";
+                                       min: 500 230;
+                                       max: 500 230;
+                                       fixed: 1 1;
                                        rel1 { relative: 0.0 1.0; to_y: "txt.title"; }
                                        rel2 { relative: 1.0 0.0; to_y: "pd.bottom"; }
                                }
-                               desc { "contracted";
-                                       inherit: "default";
+                       }
+                       spacer { "pd.minus"; scale;
+                               desc { "default";
+                                       min: 8 0;
+                                       max: 8 -1;
                                        fixed: 1 0;
-                                       min: 620 0;
-                                       max: 620 230;
+                                       align: 1.0 0.5;
+                                       rel1.to_y: "sw.content";
+                                       rel2 { relative: 0.0 1.0; to: "sw.content"; };
                                }
                        }
                        textblock { "txt.minus"; scale;
@@ -113,7 +120,7 @@ collections {
                                        max: 36 204;
                                        align: 1.0 0.0;
                                        rel1 { relative: 0.0 0.0; to_y: "sw.content"; }
-                                       rel2 { relative: 0.0 1.0; to: "sw.content"; }
+                                       rel2 { relative: 0.0 1.0; to_x: "pd.minus"; to_y: "sw.content"; }
                                        text {
                                                style: "ATO021L";
                                                text: "-";
@@ -133,13 +140,24 @@ collections {
                                        align: 0.0 1.0;
                                }
                        }
-                       spacer { "pd.title"; scale;
+                       spacer { "pd.hours";
                                desc { "default";
-                                       fixed: 0 1;
-                                       min: 0 157;
-                                       max: -1 157;
-                                       align: 0.5 0.0;
-                                       rel1 { relative: 0.0 1.0; to_y: "txt.title"; }
+                                       align: 0.0 0.5;
+                                       min: 18 0;
+                                       max: 18 -1;
+                                       fixed: 1 0;
+                                       rel1.to: "sw.content";
+                                       rel2.to: "sw.content";
+                               }
+                       }
+                       spacer { "pd.seconds";
+                               desc { "default";
+                                       align: 1.0 0.5;
+                                       min: 18 0;
+                                       max: 18 -1;
+                                       fixed: 1 0;
+                                       rel1.to: "sw.content";
+                                       rel2.to: "sw.content";
                                }
                        }
                        textblock { "txt.hours"; scale;
@@ -148,8 +166,8 @@ collections {
                                        min: 146 42;
                                        max: 146 42;
                                        align: 0.0 0.0;
-                                       rel1 { relative: 0.0 1.0; to_x: "sw.content"; to_y: "pd.title"; offset: 18 0; }
-                                       rel2 { relative: 1.0 1.0; to: "sw.content"; }
+                                       rel1 { relative: 1.0 0.0; to: "pd.hours"; };
+                                       rel2.to: "sw.content";
                                        text.style: "ATO009";
                                        hid;
                                }
@@ -164,8 +182,8 @@ collections {
                                        min: 146 42;
                                        max: 146 42;
                                        align: 0.5 0.0;
-                                       rel1 { relative: 0.0 1.0; to_x: "sw.content"; to_y: "pd.title"; }
-                                       rel2 { relative: 1.0 1.0; to: "sw.content";}
+                                       rel1.to: "sw.content";
+                                       rel2.to: "sw.content";
                                        text.style: "ATO009";
                                        hid;
                                }
@@ -180,8 +198,8 @@ collections {
                                        min: 146 42;
                                        max: 146 42;
                                        align: 1.0 0.0;
-                                       rel1 { relative: 0.0 1.0; to_x: "sw.content"; to_y: "pd.title"; }
-                                       rel2 { relative: 1.0 1.0; to: "sw.content"; offset: -18 0; }
+                                       rel1.to: "sw.content";
+                                       rel2 { relative: 0.0 1.0; to: "pd.seconds"; };
                                        text.style: "ATO009";
                                        hid;
                                }
@@ -194,7 +212,6 @@ collections {
                                signal: "set,ring,alarm,view";
                                source: "ring";
                                script {
-                                       set_state(PART:"sw.content", "default", 0.0);
                                        set_state(PART:"txt.minus", "default", 0.0);
                                        set_state(PART:"txt.hours", "default", 0.0);
                                        set_state(PART:"txt.minutes", "default", 0.0);
@@ -205,7 +222,6 @@ collections {
                                signal: "set,ring,counter,view";
                                source: "ring";
                                script {
-                                       set_state(PART:"sw.content", "contracted", 0.0);
                                        set_state(PART:"txt.minus", "visible", 0.0);
                                        set_state(PART:"txt.hours", "visible", 0.0);
                                        set_state(PART:"txt.minutes", "visible", 0.0);
index a6e257f..8eced7c 100644 (file)
 
 #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;
@@ -58,46 +61,36 @@ CounterView::~CounterView()
        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()
@@ -114,20 +107,28 @@ void CounterView::DisplayTime(int hour, int min, int sec, int msec)
 {
        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)
@@ -150,28 +151,41 @@ 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");
 }
 
 
index c7a8349..b7a549b 100644 (file)
@@ -51,9 +51,9 @@ StopWatchView::StopWatchView(ui::IView &main)
        CreateList();
 
        main_counter_ = new CounterView(*this);
-       lap_counter_ = new CounterView(*this, CounterType::COUNTER_TYPE_SIMPLE);
+       lap_counter_ = new CounterView(*this, CounterType::COUNTER_TYPE_LAP);
 
-       elm_object_part_content_set(layout_, "sw.content", main_counter_->GetEvasObject());
+       elm_object_part_content_set(layout_, "sw.counter", main_counter_->GetEvasObject());
        elm_object_part_content_set(layout_, "sw.lap.counter", lap_counter_->GetEvasObject());
 
        ShowStartupMenu();