TizenRefApp-6899 Add "Delete" button next to attachment-bubble 88/83888/2
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Fri, 12 Aug 2016 13:36:28 +0000 (16:36 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Fri, 12 Aug 2016 13:41:19 +0000 (16:41 +0300)
Change-Id: I28ccb24fc70aef62ec5b90f63c59e3d50e5cdac4
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
edje/images/messages_btn_del.png [new file with mode: 0644]
res/edje/conv_list_bubble.edc
res/edje/icons.edc
src/Conversation/ConvList/View/inc/BubbleViewItem.h
src/Conversation/ConvList/View/src/BubbleViewItem.cpp

diff --git a/edje/images/messages_btn_del.png b/edje/images/messages_btn_del.png
new file mode 100644 (file)
index 0000000..7271b6a
Binary files /dev/null and b/edje/images/messages_btn_del.png differ
index e6260eb..e0df0f1 100644 (file)
@@ -45,7 +45,75 @@ collections {
             tag:  "match" "+ color=#FFFFFF color_class=T1067";
         }
     }
-
+    group {
+        name: "conv/list/compose_layout";
+        parts {
+            part {
+                name: "content.pad.right";
+                type: SPACER;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    min: 0 0;
+                    fixed: 1 0;
+                    rel1{relative: 1.0 0.0;}
+                    rel2{relative: 1.0 1.0;}
+                    align: 1.0 0.0;
+                }
+                description {
+                    state: "show" 0.0;
+                    inherit: "default" 0.0;
+                    min: 80 0;
+                }
+            }
+            part {
+                name: "pad.content";
+                type: SPACER;
+                scale: 1;
+                description {
+                   state: "default" 0.0;
+                   rel1 { relative: 0.0 0.0; }
+                   rel2 {to_x: "content.pad.right"; relative: 0.0 1.0; }
+                }
+            }
+            part {
+                name: "del_button";
+                type: SWALLOW;
+                scale: 1;
+                description {
+                   state: "default" 0.0;
+                   visible: 0;
+                   rel1 { relative: 0.0 0.0; }
+                   rel2 { relative: 1.0 1.0; }
+                   align: 1.0 0.0;
+                   min: 56 56;
+                   max: 56 56;
+                   fixed: 1 1;
+                }
+                description {
+                   state: "show" 0.0;
+                   inherit: "default";
+                   visible: 1;
+                }
+            }
+        }
+        programs {
+           program { name: "show_del_button";
+               signal: "show_del_button";
+               source: "*";
+               action: STATE_SET "show" 0.0;
+               target: "content.pad.right";
+               target: "del_button";
+           }
+           program { name: "hide_del_button";
+               signal: "hide_del_button";
+               source: "*";
+               action: STATE_SET "default" 0.0;
+               target: "content.pad.right";
+               target: "del_button";
+           }
+       }
+    }
     group {
         name: "conv/list/1icon_1text";
         parts {
@@ -132,6 +200,7 @@ collections {
 
     group {
         name: "conv/list/image_item";
+        inherit: "conv/list/compose_layout";
         parts {
             part {
                 name: "masking";
@@ -139,6 +208,8 @@ collections {
                 precise_is_inside: 1;
                 description {
                     state: "default" 0.0;
+                    rel1.to: "content";
+                    rel2.to: "content";
                     image.normal: "messages_attach_image_round_mask.#.png";
                 }
             }
@@ -149,13 +220,18 @@ collections {
                 clip_to: "masking";
                 description {
                     state: "default" 0.0;
+                    rel1.to: "pad.content";
+                    rel2.to: "pad.content";
                 }
             }
             part {
                 name: "press_effect";
                 type: IMAGE;
+                repeat_events: 1;
                 description {
                     state: "default" 0.0;
+                    rel1.to: "content";
+                    rel2.to: "content";
                     image.normal: "messages_attach_image_round_mask.#.png";
                     color: 0 0 0 0;
                 }
@@ -168,8 +244,11 @@ collections {
             part {
                 name: "line";
                 type: IMAGE;
+                repeat_events: 1;
                 description {
                     state: "default" 0.0;
+                    rel1.to: "content";
+                    rel2.to: "content";
                     image.normal: "messages_attach_image_round_line.#.png";
                     color: 0 0 0 51;
                 }
@@ -178,14 +257,14 @@ collections {
         programs {
            program { name: "pressed";
                signal: "mouse,down,1";
-               source: "*";
+               source: "content";
                action: STATE_SET "pressed" 0.0;
                target: "press_effect";
                transition: LINEAR  0.1;
            }
            program { name: "unpressed";
                signal: "mouse,up,1";
-               source: "*";
+               source: "content";
                action: STATE_SET "default" 0.0;
                target: "press_effect";
                transition: LINEAR  0.1;
@@ -195,6 +274,7 @@ collections {
 
     group {
       name: "conv/list/video_item";
+      inherit: "conv/list/compose_layout";
       images {
          image: "messages_play_btn.png" COMP;
       }
@@ -205,6 +285,8 @@ collections {
              precise_is_inside: 1;
              description {
                  state: "default" 0.0;
+                 rel1.to: "content";
+                 rel2.to: "content";
                  image.normal: "messages_attach_image_round_mask.#.png";
              }
          }
@@ -215,12 +297,8 @@ collections {
             clip_to: "masking";
             description {
                state: "default" 0.0;
-               rel1 {
-                  relative: 0.0 0.0;
-               }
-               rel2 {
-                  relative: 1.0 1.0;
-               }
+               rel1.to: "pad.content";
+               rel2.to: "pad.content";
             }
          }
          part {
@@ -228,6 +306,8 @@ collections {
              type: IMAGE;
              description {
                  state: "default" 0.0;
+                 rel1.to: "content";
+                 rel2.to: "content";
                  image.normal: "messages_attach_image_round_line.#.png";
                  color: 0 0 0 51;
              }
@@ -241,33 +321,27 @@ collections {
                image.normal: "messages_play_btn.png";
                max: 128 128;
                align: 0.5 0.5;
-               rel1 {
-                  to: "content";
-                  relative: 0.0 0.0;
-               }
-               rel2 {
-                  to: "content";
-                  relative: 1.0 1.0;
-               }
+               rel1.to: "content";
+               rel2.to: "content";
             }
             description {
                 state: "pressed";
                 inherit: "default";
-                color: 190 190 190 255;
+                color: 170 170 170 255;
             }
          }
       }
       programs {
            program { name: "pressed";
                signal: "mouse,down,1";
-               source: "*";
+               source: "play_button";
                action: STATE_SET "pressed" 0.0;
                transition: LINEAR  0.1;
                target: "play_button";
            }
            program { name: "unpressed";
                signal: "mouse,up,1";
-               source: "*";
+               source: "play_button";
                action: STATE_SET "default" 0.0;
                transition: LINEAR  0.1;
                target: "play_button";
@@ -277,6 +351,7 @@ collections {
 
    group {
        name: "conv/list/bubble_sent_bg";
+       inherit: "conv/list/compose_layout";
        parts {
            part {
                name: "bg";
@@ -285,8 +360,8 @@ collections {
                description {
                   state: "default";
                   image.normal: "messages_bubble_bg.#.png";
-                  rel1 { relative: 0.0 0.0; }
-                  rel2 { relative: 1.0 1.0; }
+                  rel1.to: "pad.content";
+                  rel2.to: "pad.content";
                   color: BUBBLE_BG_COLOR;
                }
                description {
@@ -306,10 +381,58 @@ collections {
                   rel2.to: "bg";
                }
            }
-           PADDING_TOP("pad.top", 10);
-           PADDING_BOTTOM("pad.bottom", 16);
-           PADDING_LEFT("pad.left", 34);
-           PADDING_RIGHT("pad.right", 34);
+           part {
+              name: "pad.left";
+              type: SPACER;
+              scale: 1;
+              description {
+                  state: "default" 0.0;
+                  min: 34 0;
+                  fixed: 1 0;
+                  rel1{to: "pad.content"; relative: 0.0 0.0;}
+                  rel2{to: "pad.content"; relative: 0.0 1.0;}
+                  align: 0.0 0.0;
+              }
+           }
+           part {
+              name: "pad.top";
+              type: SPACER;
+              scale: 1;
+              description {
+                  state: "default" 0.0;
+                  min: 0 10;
+                  fixed: 0 1;
+                  rel1{to: "pad.content"; relative: 0.0 0.0;}
+                  rel2{to: "pad.content"; relative: 1.0 0.0;}
+                  align: 0.0 0.0;
+              }
+           }
+           part{
+              name: pad.bottom;
+              type: SPACER;
+              scale: 1;
+              description {
+                  state: "default" 0.0;
+                  min: 0 16;
+                  fixed: 0 1;
+                  rel1{to: "pad.content"; relative: 0.0 1.0;}
+                  rel2{to: "pad.content"; relative: 1.0 1.0;}
+                  align: 0.0 1.0;
+              }
+           }
+           part {
+              name: "pad.right";
+              type: SPACER;
+              scale: 1;
+              description {
+                  state: "default" 0.0;
+                  min: 34 0;
+                  fixed: 1 0;
+                  rel1{to: "pad.content"; relative: 1.0 0.0;}
+                  rel2{to: "pad.content"; relative: 1.0 1.0;}
+                  align: 1.0 0.0;
+              }
+           }
            part {
                name: "content";
                type: SWALLOW;
@@ -324,14 +447,14 @@ collections {
        programs {
            program { name: "pressed";
                signal: "mouse,down,1";
-               source: "*";
+               source: "content";
                action: STATE_SET "pressed" 0.0;
                transition: LINEAR  0.1;
                target: "bg";
            }
            program { name: "unpressed";
                signal: "mouse,up,1";
-               source: "*";
+               source: "content";
                action: STATE_SET "default" 0.0;
                transition: LINEAR  0.1;
                target: "bg";
index 3239bd8..45999e8 100755 (executable)
@@ -103,4 +103,42 @@ collections {
            }
        }
     }
+    group {
+        name: "attach_del_icon";
+        images {
+            image: "messages_btn_del.png" RAW;
+        }
+        parts {
+            part {
+                name: "icon";
+                type: IMAGE;
+                scale: 1;
+                description {
+                    state: "default" 0.0;
+                    image.normal: "messages_btn_del.png";
+                }
+                description {
+                    state: "pressed" 0.0;
+                    inherit: "default";
+                    color: 160 160 160 255;
+                }
+            }
+        }
+        programs {
+           program { name: "pressed";
+               source: "*";
+               signal: "pressed";
+               action: STATE_SET "pressed" 0.0;
+               target: "icon";
+               transition: LINEAR  0.1;
+           }
+           program { name: "unpressed";
+               source: "*";
+               signal: "unpressed";
+               action: STATE_SET "default" 0.0;
+               target: "icon";
+               transition: LINEAR  0.1;
+           }
+       }
+   }
 }
index 8d55599..f8df410 100644 (file)
@@ -38,14 +38,19 @@ namespace Msg
             virtual void calculate();
             void setListener(IBubbleViewItemListener *l);
             BubbleEntity &getEntity();
+            void showDelButton(bool show);
 
         protected:
             void emitActionEvent();
             void attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj);
 
         private:
+            void onDelButtonClicked(Evas_Object *obj, void *eventInfo);
+
+        private:
             BubbleEntity &m_Entity;
             IBubbleViewItemListener *m_pListener;
+            Evas_Object *m_pDelButton;
     };
 
     class IBubbleViewItemListener
@@ -53,6 +58,7 @@ namespace Msg
         public:
             virtual ~IBubbleViewItemListener() {};
             virtual void onAction(BubbleViewItem &item) {}; // Tap or Click
+            virtual void onDelClecked(BubbleViewItem &item) {}; // Delete button clicked
     };
 }
 
index 3d17050..06a7b32 100644 (file)
  */
 
 #include "BubbleViewItem.h"
+#include "Resource.h"
 #include "Logger.h"
 
 using namespace Msg;
 
-const int tapFingerSize = 12;
-
 BubbleViewItem::BubbleViewItem(BubbleEntity &entity)
     : m_Entity(entity)
     , m_pListener(nullptr)
+    , m_pDelButton(nullptr)
 {
-
 }
 
 BubbleViewItem::~BubbleViewItem()
@@ -46,6 +45,8 @@ BubbleEntity &BubbleViewItem::getEntity()
 
 void BubbleViewItem::attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj)
 {
+    const int tapFingerSize = 12;
+
     Evas_Object *layer = elm_gesture_layer_add(parent);
     evas_object_show(layer);
     elm_gesture_layer_attach(layer, obj);
@@ -67,13 +68,67 @@ void BubbleViewItem::attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj
     );
 }
 
+void BubbleViewItem::showDelButton(bool show)
+{
+    if(!m_pDelButton)
+    {
+        m_pDelButton = elm_button_add(getEo());
+        elm_object_style_set(m_pDelButton, "transparent");
+        evas_object_smart_callback_add(m_pDelButton, "clicked", SMART_CALLBACK(BubbleViewItem, onDelButtonClicked), this);
+        evas_object_event_callback_add
+        (
+            m_pDelButton,
+            EVAS_CALLBACK_MOUSE_DOWN,
+            [](void *data, Evas *e, Evas_Object *obj, void *event_info)
+            {
+                if(!elm_object_disabled_get(obj))
+                    emitSignal(elm_object_content_get(obj), "pressed", "*");
+            },
+            this
+        );
+        evas_object_event_callback_add
+        (
+            m_pDelButton,
+            EVAS_CALLBACK_MOUSE_UP,
+            [](void *data, Evas *e, Evas_Object *obj, void *event_info)
+            {
+                if(!elm_object_disabled_get(obj))
+                    emitSignal(elm_object_content_get(obj), "unpressed", "*");
+            },
+            this
+        );
+
+        const char *delButtonPart = "del_button";
+
+        Evas_Object *icon = View::addLayout(m_pDelButton, ICONS_EDJ_PATH, "attach_del_icon");
+        elm_object_content_set(m_pDelButton, icon);
+
+        setContent(m_pDelButton, delButtonPart);
+        if(!getContent(delButtonPart))
+        {
+            MSG_LOG_ERROR("Layout has not 'del_button' part");
+            evas_object_del(m_pDelButton);
+            m_pDelButton = nullptr;
+            return;
+        }
+    }
+    const char *sig = show ? "show_del_button" : "hide_del_button";
+    emitSignal(sig, "*");
+}
+
+void BubbleViewItem::calculate()
+{
+    evas_object_smart_calculate(getEo());
+}
+
 void BubbleViewItem::emitActionEvent()
 {
     if(m_pListener)
         m_pListener->onAction(*this);
 }
 
-void BubbleViewItem::calculate()
+void BubbleViewItem::onDelButtonClicked(Evas_Object *obj, void *eventInfo)
 {
-    evas_object_smart_calculate(getEo());
+    if(m_pListener)
+        m_pListener->onDelClecked(*this);
 }