[Ring] Fix ring's swipe button issue. 88/110688/4
authorKamil Lipiszko <k.lipiszko@samsung.com>
Tue, 17 Jan 2017 11:40:26 +0000 (12:40 +0100)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Tue, 17 Jan 2017 13:37:54 +0000 (05:37 -0800)
This patch fixes all issues related with swipe buttons and undefined
behaviour during swipe area mouse down and drag.

Change-Id: Icb789c0d83aa7e3a8c5bff4be44fc7a9ab258f3a

clock/inc/View/RingView.h
clock/res/edje/ring.edc
clock/src/View/RingView.cpp
clock/tizen-manifest.xml

index 4e1b249..ed0e652 100644 (file)
@@ -161,9 +161,14 @@ namespace view {
                Evas_Object *GetEvasObject();
 
        private:
-               Evas_Object *win_;
-               Evas_Object *layout_;
-               view::CounterView *counter_;
+               Evas_Object *win_ = NULL;
+               Evas_Object *layout_ = NULL;
+               Evas_Object *conformant_ = NULL;
+
+               Evas_Object *dismissButton_ = NULL;
+               Evas_Object *snoozeButton_ = NULL;
+
+               view::CounterView *counter_ = NULL;
 
                std::vector<std::function<void(void)>> signals_
                        = std::vector<std::function<void(void)>>((int)RingSignal::MAX, nullptr);
@@ -189,6 +194,30 @@ namespace view {
                 * @param[in] ly The layout of the ring view where content must be placed.
                 */
                void SetMainContent(Evas_Object *ly);
+
+               /**
+                * @brief Creates dismiss swipe button
+                *
+                * @return Evas_Object of the button
+                */
+               Evas_Object *CreateDismissButton();
+
+               /**
+                * @brief Creates snooze swipe button
+                *
+                * @return Evas_Object of the button
+                */
+               Evas_Object *CreateSnoozeButton();
+
+               /**
+                * @brief Creates swipe button
+                *
+                * @param[in] group The button's layout group
+                *
+                * @return Evas_Object of the button
+                */
+               Evas_Object *CreateSwipeButton(const char *group);
+
        };
 
 } //namespace view
index f607c33..fa3634d 100644 (file)
@@ -310,8 +310,7 @@ collections {
                                        align: 1.0 0.5;
                                }
                        }
-                       group { "sw.btn.dismiss"; scale;
-                               source: "button_dismiss";
+                       swallow { "sw.btn.dismiss"; scale;
                                desc { "default";
                                        fixed: 1 1;
                                        min: 180 180;
@@ -325,8 +324,7 @@ collections {
                                        align: 0.5 0.5;
                                }
                        }
-                       group { "sw.btn.snooze"; scale;
-                               source: "button_snooze";
+                       swallow { "sw.btn.snooze"; scale;
                                desc { "default";
                                        fixed: 1 1;
                                        min: 180 180;
@@ -335,10 +333,6 @@ collections {
                                        rel1 { relative: 0.0 0.0; }
                                        rel2 { relative: 0.0 1.0; to_x: "pd.right"; }
                                }
-                               desc { "contracted";
-                                       inherit: "default";
-                                       hid;
-                               }
                        }
                        program {
                                name: "buttons,expand";
@@ -346,7 +340,6 @@ collections {
                                signal: "buttons,expand";
                                action: STATE_SET "default";
                                target: "sw.btn.dismiss";
-                               target: "sw.btn.snooze";
                        }
                        program {
                                name: "buttons,contract";
@@ -354,7 +347,6 @@ collections {
                                signal: "buttons,contract";
                                action: STATE_SET "contracted";
                                target: "sw.btn.dismiss";
-                               target: "sw.btn.snooze";
                        }
                }
        }
index 5f139dc..ac6491a 100644 (file)
@@ -54,14 +54,14 @@ RingView::RingView()
        elm_win_indicator_mode_set(win_, ELM_WIN_INDICATOR_SHOW);
        elm_win_indicator_opacity_set(win_, ELM_WIN_INDICATOR_OPAQUE);
 
-       Evas_Object *conformant = elm_conformant_add(win_);
+       conformant_ = elm_conformant_add(win_);
 
-       evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
-       evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(conformant_, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_size_hint_weight_set(conformant_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
-       elm_win_resize_object_add(win_, conformant);
+       elm_win_resize_object_add(win_, conformant_);
 
-       layout_ = elm_layout_add(conformant);
+       layout_ = elm_layout_add(conformant_);
        if (!layout_) {
                ERR("elm_layout_add failed");
                evas_object_del(win_);
@@ -71,12 +71,11 @@ RingView::RingView()
        if (!elm_layout_file_set(layout_, utils::TizenAppUtils::GetResourcePath(
                                        utils::TizenAppUtils::APP_DIR_RESOURCE, EDJE_FILE), GROUP)) {
                ERR("elm_layout_file_set failed");
-               evas_object_del(layout_);
                evas_object_del(win_);
                return;
        }
 
-       elm_object_content_set(conformant, layout_);
+       elm_object_content_set(conformant_, layout_);
 
        elm_object_translatable_part_text_set(layout_, "txt.hours", "IDS_COM_BODY_HOURS");
        elm_object_translatable_part_text_set(layout_, "txt.minutes", "IDS_COM_BODY_MINUTES");
@@ -86,11 +85,11 @@ RingView::RingView()
        evas_object_size_hint_weight_set(layout_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 
        evas_object_show(layout_);
-       evas_object_show(conformant);
+       evas_object_show(conformant_);
        evas_object_show(win_);
 
-       elm_object_signal_callback_add(layout_, "button,swipe,accept", "sw.swipe.area:sw.btn.dismiss:button", DismissCb, this);
-       elm_object_signal_callback_add(layout_, "button,swipe,accept", "sw.swipe.area:sw.btn.snooze:button", SnoozeCb, this);
+       dismissButton_ = CreateDismissButton();
+       elm_object_part_content_set(layout_, "sw.swipe.area:sw.btn.dismiss", dismissButton_);
 }
 
 RingView::~RingView()
@@ -102,6 +101,7 @@ RingView::~RingView()
                counter_ = nullptr;
        }
 }
+
 Evas_Object *RingView::GetEvasObject()
 {
        return layout_;
@@ -132,7 +132,6 @@ void RingView::DisplayTime(int hour, int min, int sec)
 
 void RingView::SetTimeLabel(const char *ampm, const char *hour, const char *date)
 {
-       DBG("%s %s %s", ampm, hour, date);
        Evas_Object *content = elm_layout_add(layout_);
        if (!content)
                return;
@@ -157,13 +156,58 @@ void RingView::SetTimeLabel(const char *ampm, const char *hour, const char *date
        elm_object_signal_emit(layout_, "set,ring,alarm,view", "ring");
 }
 
+Evas_Object *RingView::CreateDismissButton()
+{
+       Evas_Object *button = CreateSwipeButton("button_dismiss");
+
+       elm_object_signal_callback_add(button, "button,swipe,accept", "button", DismissCb, this);
+
+       return button;
+}
+
+Evas_Object *RingView::CreateSnoozeButton()
+{
+       Evas_Object *button = CreateSwipeButton("button_snooze");
+
+       elm_object_signal_callback_add(button, "button,swipe,accept", "button", SnoozeCb, this);
+
+       return button;
+}
+
+Evas_Object *RingView::CreateSwipeButton(const char *group)
+{
+       Evas_Object *layout = elm_layout_add(layout_);
+
+       if (!elm_layout_file_set(layout, utils::TizenAppUtils::GetResourcePath(
+                                       utils::TizenAppUtils::APP_DIR_RESOURCE, EDJE_FILE), group)) {
+               ERR("elm_layout_file_set failed");
+               evas_object_del(layout);
+               return NULL;
+       }
+
+       evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       evas_object_show(layout);
+
+       return layout;
+}
+
 void RingView::EnableSnooze(bool enabled)
 {
-       DBG("Enable snooze: %d", enabled);
-       if (enabled)
+       if (enabled) {
                elm_object_signal_emit(layout_, "sw.swipe.area:buttons,expand", "ring");
-       else
+                       if (!snoozeButton_) {
+                               snoozeButton_ = CreateSnoozeButton();
+                               elm_object_part_content_set(layout_, "sw.swipe.area:sw.btn.snooze", snoozeButton_);
+                       }
+       } else {
                elm_object_signal_emit(layout_, "sw.swipe.area:buttons,contract", "ring");
+
+               snoozeButton_ = elm_object_part_content_unset(layout_, "sw.swipe.area:sw.btn.snooze");
+               if (snoozeButton_)
+                       evas_object_del(snoozeButton_);
+       }
 }
 
 void RingView::SetMainContent(Evas_Object *ly)
index b1284da..aa9531e 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <manifest xmlns="http://tizen.org/ns/packages" api-version="3.0" package="org.tizen.clock" version="1.0.0">
     <profile name="mobile"/>
-    <ui-application appid="org.tizen.clock" exec="clock" launch_mode="single" multiple="false" nodisplay="false" taskmanage="true" type="capp">
+    <ui-application appid="org.tizen.clock" exec="clock" launch_mode="single" multiple="false" nodisplay="false" taskmanage="true" type="capp" hw-acceleration="on">
         <label>Clock</label>
         <icon>clock.png</icon>
     </ui-application>