TizenRefApp-8208 Implement text bubble item for conversation 31/120131/2
authorOleksander Kostenko <o.kostenko@samsung.com>
Tue, 21 Mar 2017 16:33:26 +0000 (18:33 +0200)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 22 Mar 2017 13:29:59 +0000 (06:29 -0700)
Change-Id: Ibf54c0bf5ad4bde929992e2876ba57f03f753f76
Signed-off-by: Oleksander Kostenko <o.kostenko@samsung.com>
res/edje/conv_genlist_theme.edc
src/Conversation/ConvList/Controller/inc/BubbleTextEntity.h [new file with mode: 0644]
src/Conversation/ConvList/View/inc/BubbleTextViewItem.h [new file with mode: 0644]
src/Conversation/ConvList/View/inc/BubbleViewItem.h
src/Conversation/ConvList/View/src/BubbleTextViewItem.cpp [new file with mode: 0644]
src/Conversation/ConvList/View/src/BubbleViewItem.cpp

index 00bb0d6ee4de1e3bbfcfc21754f871f2d5a5f494..37342b76e22061cd396a23ec925f339cd8fb37aa 100644 (file)
@@ -4,6 +4,7 @@
 #define ENTRY_BUBBLE_TEXT_SIZE               20
 #define DATELINE_TEXT_SIZE                   24
 #define REPLY_TEXT_SIZE                      24
+#define MAIN_TEXT_SIZE                       28
 
 #define BUBBLE_CONTENT_WIDTH_MAX             240
 #define BUBBLE_CONTENT_WIDTH_MIN             78
@@ -71,6 +72,10 @@ collections {
          base: "font=Tizen:weight=Normal:width=Condensed font_size="REPLY_TEXT_SIZE" text_class=tizen color=#fafafa align=center";
          tag:  "match" "+ color=#006EFF";
       }
+      style { name: "textblock_style";
+         base: "font=Tizen:weight=Normal:width=Condensed font_size="MAIN_TEXT_SIZE" color=#000 wrap=mixed text_class=label align=left";
+         tag:  "match" "+ color=#006EFF";
+      }
    }
 
    group { name: "elm/genlist/item/sentbubble/default";
@@ -618,8 +623,8 @@ collections {
                max: REPLY_SWALLOW_SIZE REPLY_SWALLOW_SIZE;
                rel1.to_y: "padding.top";
                rel1.relative: 0 1;
-               rel2.to_y: "padding.top";
-               rel2.relative: 1 1;
+               rel2.to_y: "reply.padding.bottom";
+               rel2.relative: 1 0;
                align: 0.5 0;
                fixed: 1 1;
             }
@@ -645,11 +650,65 @@ collections {
                align: 0.5 0;
                min: 0 36;
                max: -1 36;
-               fixed: 0 1;
                text.style: "reply_textblock_style";
                text.max: 1 0;
             }
          }
       }
    }
+   group { name: "elm/label/base/conv_bubble";
+      parts {
+         rect { "label.text.clip"; scale;
+            desc { "default";}
+         }
+         textblock { "elm.text"; scale;
+            clip_to: "label.text.clip";
+            desc { "default";
+               text {
+                  style: "textblock_style";
+                  min: 0 1;
+                  align: 0.0 0.0;
+               }
+            }
+         }
+      }
+   }
+   group { name: "conv/list/bubble_item_bg";
+      parts {
+         spacer { "bg"; scale;
+            desc { "default";
+            }
+            desc { "pressed";
+               inherit: "default";
+            }
+         }
+         swallow { "swl.gesture"; scale;
+            repeat_events: 1;
+            desc { "default";
+               rel.to: "bg";
+            }
+         }
+         swallow { "content"; scale;
+            desc { "default";
+               rel.to "swl.gesture";
+            }
+         }
+      }
+      programs {
+         program { name: "pressed";
+            signal: "mouse,down,1";
+            source: "content";
+            action: STATE_SET "pressed" 0.0;
+            transition: LINEAR  0.1;
+            target: "bg";
+         }
+         program { name: "unpressed";
+            signal: "mouse,up,1";
+            source: "content";
+            action: STATE_SET "default" 0.0;
+            transition: LINEAR  0.1;
+            target: "bg";
+         }
+      }
+   }
 }
diff --git a/src/Conversation/ConvList/Controller/inc/BubbleTextEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleTextEntity.h
new file mode 100644 (file)
index 0000000..2cdbe93
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BubbleTextEntity_h_
+#define BubbleTextEntity_h_
+
+#include "BubbleTextViewItem.h"
+#include "BubbleEntity.h"
+
+namespace Msg {
+    class BubbleTextEntity
+        : public BubbleEntity {
+        public:
+            BubbleTextEntity(Message::Direction direction, std::string text);
+            virtual ~BubbleTextEntity();
+
+            virtual BubbleTextViewItem *createView(Evas_Object *parent);
+
+        private:
+            std::string m_Text;
+    };
+
+    inline BubbleTextEntity::BubbleTextEntity(Message::Direction direction, std::string text)
+        : BubbleEntity(TextItem, direction)
+        , m_Text(std::move(text))
+    {
+    }
+
+    inline BubbleTextEntity::~BubbleTextEntity()
+    {
+    }
+
+    inline BubbleTextViewItem *BubbleTextEntity::createView(Evas_Object *parent)
+    {
+        auto *item = new BubbleTextViewItem(*this, parent, m_Text);
+        return item;
+    }
+}
+
+#endif /* BubbleTextEntity_h_ */
diff --git a/src/Conversation/ConvList/View/inc/BubbleTextViewItem.h b/src/Conversation/ConvList/View/inc/BubbleTextViewItem.h
new file mode 100644 (file)
index 0000000..c90ddce
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BubbleTextViewItem_h_
+#define BubbleTextViewItem_h_
+
+#include "BubbleViewItem.h"
+
+namespace Msg {
+    class BubbleTextViewItem
+        : public BubbleViewItem {
+        public:
+            BubbleTextViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &text);
+            virtual ~BubbleTextViewItem();
+
+        private:
+            Evas_Object *createText(Evas_Object *parent, const std::string &text);
+    };
+}
+
+#endif /* BubbleTextViewItem_h_ */
index 9516dabe0be7c4ecaaaf444ec89c0b9b4b93af04..1910c27fffe95eadcb5bc760d7ca79ee4e9bf92d 100644 (file)
@@ -29,17 +29,23 @@ namespace Msg {
         public:
             static const int maxWidth = 240;
 
-            BubbleViewItem(BubbleEntity &entity);
+            BubbleViewItem(Evas_Object *parent, BubbleEntity &entity);
             virtual ~BubbleViewItem();
 
             virtual void calculate();
             void setListener(IBubbleViewItemListener *l);
             BubbleEntity &getEntity();
 
+            void setContent(Evas_Object *obj);
+            Evas_Object *getContent() const;
+
         protected:
             void emitActionEvent();
             void attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj);
 
+        private:
+            Evas_Object *createGestureRect(Evas_Object *parent);
+
         private:
             BubbleEntity &m_Entity;
             IBubbleViewItemListener *m_pListener;
diff --git a/src/Conversation/ConvList/View/src/BubbleTextViewItem.cpp b/src/Conversation/ConvList/View/src/BubbleTextViewItem.cpp
new file mode 100644 (file)
index 0000000..76759a4
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "BubbleTextViewItem.h"
+#include "Resource.h"
+#include "Logger.h"
+#include "TextDecorator.h"
+
+using namespace Msg;
+
+const std::string textColor = "#000";
+
+BubbleTextViewItem::BubbleTextViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &text)
+    : BubbleViewItem(parent, entity)
+{
+    setContent(createText(*this, TextDecorator::make(text, textColor)));
+}
+
+BubbleTextViewItem::~BubbleTextViewItem()
+{
+}
+
+Evas_Object *BubbleTextViewItem::createText(Evas_Object *parent, const std::string &text)
+{
+    if (text.empty())
+        return nullptr;
+
+    Evas_Object *label = elm_label_add(parent);
+    elm_object_style_set(label, "conv_bubble");
+
+    elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
+    elm_object_part_text_set(label, nullptr, text.c_str());
+    evas_object_show(label);
+
+    Evas_Object *edjeLabel = elm_layout_edje_get(label);
+    const Evas_Object *textBlock = edje_object_part_object_get(edjeLabel, "elm.text");
+
+    Evas_Coord ww = 0;
+    Evas_Coord hh = 0;
+
+    evas_object_textblock_size_native_get(textBlock, &ww, &hh);
+    int wrapWidth = ww > maxWidth ? maxWidth : ww;
+    elm_label_wrap_width_set(label, wrapWidth);
+
+    return label;
+}
index 3b7f1bde878ab9c2a57f37d23230f2c565eda549..403b578b236e5872b3b4ec3b347348258fb7f1ec 100644 (file)
 
 using namespace Msg;
 
-BubbleViewItem::BubbleViewItem(BubbleEntity &entity)
+BubbleViewItem::BubbleViewItem(Evas_Object *parent, BubbleEntity &entity)
     : m_Entity(entity)
     , m_pListener(nullptr)
 {
+    setEo(addLayout(parent, CONV_GENLIST_THEME_EDJ_PATH, "conv/list/bubble_item_bg"));
+    View::setContent(createGestureRect(getEo()), "swl.gesture");
+    evas_object_size_hint_align_set(getEo(), 1.0, EVAS_HINT_FILL);
 }
 
 BubbleViewItem::~BubbleViewItem()
@@ -40,6 +43,16 @@ BubbleEntity &BubbleViewItem::getEntity()
     return m_Entity;
 }
 
+void BubbleViewItem::setContent(Evas_Object *obj)
+{
+    View::setContent(obj, "content");
+}
+
+Evas_Object *BubbleViewItem::getContent() const
+{
+    return View::getContent("content");
+}
+
 void BubbleViewItem::attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj)
 {
     const int tapFingerSize = 12;
@@ -63,6 +76,15 @@ void BubbleViewItem::attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj
         this);
 }
 
+Evas_Object *BubbleViewItem::createGestureRect(Evas_Object *parent)
+{
+    Evas *e = evas_object_rectangle_add(evas_object_evas_get(parent));
+    Evas_Object *rect = evas_object_rectangle_add(e);
+    evas_object_color_set(rect, 0, 0, 0, 0);
+    attachGestureTapLayer(parent, rect);
+    return rect;
+}
+
 void BubbleViewItem::calculate()
 {
     evas_object_smart_calculate(getEo());