TizenRefApp-8207 Implement container(box) for bubble items 28/120128/2
authorOleksander Kostenko <o.kostenko@samsung.com>
Tue, 21 Mar 2017 08:59:13 +0000 (10:59 +0200)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 22 Mar 2017 13:28:55 +0000 (06:28 -0700)
Change-Id: I40ac132d6244d512527bac0b5a7dde59eef1c184
Signed-off-by: Oleksander Kostenko <o.kostenko@samsung.com>
.cproject
src/Conversation/ConvList/Controller/inc/BubbleEntity.h [new file with mode: 0644]
src/Conversation/ConvList/View/inc/BubbleItemContainer.h [new file with mode: 0644]
src/Conversation/ConvList/View/inc/BubbleViewItem.h [new file with mode: 0644]
src/Conversation/ConvList/View/src/BubbleItemContainer.cpp [new file with mode: 0644]
src/Conversation/ConvList/View/src/BubbleViewItem.cpp [new file with mode: 0644]

index 53979137b5eb25d193c7bdea6e4fd323dedf4c9a..24dae47d4916a3757cdd6a712ad01df16d5caee3 100644 (file)
--- a/.cproject
+++ b/.cproject
                                                                <option id="gnu.cpp.compiler.option.include.paths.2037910591" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Conversation/Main/Controller/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Composer/View/inc}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Conversation/ConvList/Controller/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Composer/Controller/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/MsgThread/View/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Settings/Controller/inc}&quot;"/>
diff --git a/src/Conversation/ConvList/Controller/inc/BubbleEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleEntity.h
new file mode 100644 (file)
index 0000000..f18882b
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * 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 BubbleEntity_h_
+#define BubbleEntity_h_
+
+#include "View.h"
+#include "BubbleViewItem.h"
+#include "MsgConvMedia.h"
+#include "FileUtils.h"
+#include "Message.h"
+
+#include <string>
+
+namespace Msg {
+    class BubbleEntity {
+        public:
+            enum Type {
+                TextItem,
+                ImageItem,
+                AudioItem,
+                VideoItem,
+                ContactItem,
+                CalendarEventItem,
+                UnknownFileItem,
+                DownloadButtonItem
+            };
+
+        public:
+            BubbleEntity(Type type, Message::Direction direction, const std::string &filePath = "");
+            virtual ~BubbleEntity();
+
+            Type getType() const;
+            Message::Direction getDirection() const;
+            const std::string &getFilePath() const;
+            void setFilePath(std::string file);
+            long long getFileSize() const;
+            virtual BubbleViewItem *createView(Evas_Object *parent) = 0;
+
+        private:
+            Type m_Type;
+            Message::Direction m_Direction;
+            std::string m_FilePath;
+            long long m_FileSize;
+    };
+
+    inline BubbleEntity::BubbleEntity(Type type, Message::Direction direction, const std::string &filePath)
+        : m_Type(type)
+        , m_Direction(direction)
+        , m_FilePath(filePath)
+        , m_FileSize(!filePath.empty() ? FileUtils::getFileSize(filePath) : 0)
+    {
+    }
+
+    inline BubbleEntity::~BubbleEntity()
+    {
+    }
+
+    inline BubbleEntity::Type BubbleEntity::getType() const
+    {
+        return m_Type;
+    }
+
+    inline Message::Direction BubbleEntity::getDirection() const
+    {
+        return m_Direction;
+    }
+
+    inline const std::string &BubbleEntity::getFilePath() const
+    {
+        return m_FilePath;
+    }
+
+    inline void BubbleEntity::setFilePath(std::string file)
+    {
+        m_FilePath = std::move(file);
+    }
+
+    inline long long BubbleEntity::getFileSize() const
+    {
+        return m_FileSize;
+    }
+
+}
+
+#endif /* BubbleEntity_h_ */
diff --git a/src/Conversation/ConvList/View/inc/BubbleItemContainer.h b/src/Conversation/ConvList/View/inc/BubbleItemContainer.h
new file mode 100644 (file)
index 0000000..163b338
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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 BubbleItemContainer_h_
+#define BubbleItemContainer_h_
+
+#include "Message.h"
+#include "BubbleViewItem.h"
+
+namespace Msg {
+    class BubbleItemContainer
+        : public View {
+        public:
+            BubbleItemContainer(Evas_Object *parent);
+            virtual ~BubbleItemContainer();
+
+            void append(BubbleViewItem &item, Message::Direction direction);
+            void go();
+    };
+}
+
+#endif /* BubbleItemContainer_h_ */
diff --git a/src/Conversation/ConvList/View/inc/BubbleViewItem.h b/src/Conversation/ConvList/View/inc/BubbleViewItem.h
new file mode 100644 (file)
index 0000000..9516dab
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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 BubbleViewItem_h_
+#define BubbleViewItem_h_
+
+#include "View.h"
+#include <string>
+
+namespace Msg {
+    class IBubbleViewItemListener;
+    class BubbleEntity;
+
+    class BubbleViewItem
+        : public View {
+        public:
+            static const int maxWidth = 240;
+
+            BubbleViewItem(BubbleEntity &entity);
+            virtual ~BubbleViewItem();
+
+            virtual void calculate();
+            void setListener(IBubbleViewItemListener *l);
+            BubbleEntity &getEntity();
+
+        protected:
+            void emitActionEvent();
+            void attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj);
+
+        private:
+            BubbleEntity &m_Entity;
+            IBubbleViewItemListener *m_pListener;
+    };
+
+    class IBubbleViewItemListener {
+        public:
+            virtual ~IBubbleViewItemListener() {};
+            virtual void onAction(BubbleViewItem &item) {}; // Tap or Click
+    };
+}
+
+#endif /* BubbleViewItem_h_ */
diff --git a/src/Conversation/ConvList/View/src/BubbleItemContainer.cpp b/src/Conversation/ConvList/View/src/BubbleItemContainer.cpp
new file mode 100644 (file)
index 0000000..fc5d345
--- /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 "BubbleItemContainer.h"
+#include "Logger.h"
+
+#include <string.h>
+
+using namespace Msg;
+
+namespace {
+    const int verticalBoxPads = 12;
+    const int horizontalBoxPads = 0;
+}
+
+BubbleItemContainer::BubbleItemContainer(Evas_Object *parent)
+{
+    Evas_Object *box = elm_box_add(parent);
+    elm_box_homogeneous_set(box, false);
+    elm_box_padding_set(box, ELM_SCALE_SIZE(horizontalBoxPads), ELM_SCALE_SIZE(verticalBoxPads));
+    setEo(box);
+    expand();
+    show();
+}
+
+BubbleItemContainer::~BubbleItemContainer()
+{
+}
+
+void BubbleItemContainer::append(BubbleViewItem &item, Message::Direction direction)
+{
+    const char *itemType = evas_object_type_get(item);
+    if (strcmp(itemType, "elm_button") == 0)
+        expand(item);
+    else
+        evas_object_size_hint_align_set(item, 0.0, EVAS_HINT_FILL);
+
+    item.calculate();
+    item.show();
+    elm_box_pack_end(getEo(), item);
+}
+
+void BubbleItemContainer::go()
+{
+    elm_box_recalculate(getEo());
+}
diff --git a/src/Conversation/ConvList/View/src/BubbleViewItem.cpp b/src/Conversation/ConvList/View/src/BubbleViewItem.cpp
new file mode 100644 (file)
index 0000000..3b7f1bd
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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 "BubbleViewItem.h"
+#include "Resource.h"
+#include "Logger.h"
+
+using namespace Msg;
+
+BubbleViewItem::BubbleViewItem(BubbleEntity &entity)
+    : m_Entity(entity)
+    , m_pListener(nullptr)
+{
+}
+
+BubbleViewItem::~BubbleViewItem()
+{
+}
+
+void BubbleViewItem::setListener(IBubbleViewItemListener *l)
+{
+    m_pListener = l;
+}
+
+BubbleEntity &BubbleViewItem::getEntity()
+{
+    return m_Entity;
+}
+
+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);
+    elm_gesture_layer_tap_finger_size_set(layer, ELM_SCALE_SIZE(tapFingerSize));
+
+    elm_gesture_layer_cb_add(
+        layer,
+        ELM_GESTURE_N_TAPS,
+        ELM_GESTURE_STATE_END,
+        [](void *data, void *event_info)->Evas_Event_Flags
+        {
+            auto *self = static_cast<BubbleViewItem*>(data);
+            if (self)
+                self->emitActionEvent();
+            return EVAS_EVENT_FLAG_NONE;
+        },
+        this);
+}
+
+void BubbleViewItem::calculate()
+{
+    evas_object_smart_calculate(getEo());
+}
+
+void BubbleViewItem::emitActionEvent()
+{
+    if (m_pListener)
+        m_pListener->onAction(*this);
+}
+