TizenRefApp-8153 [Gallery] Implement ImageGrid with 3x3 style 43/119143/3
authorIgor Nazarov <i.nazarov@samsung.com>
Wed, 15 Mar 2017 20:12:50 +0000 (22:12 +0200)
committerIgor Nazarov <i.nazarov@samsung.com>
Thu, 16 Mar 2017 12:27:26 +0000 (14:27 +0200)
- Added ImageGrid class implementation with HCOMB_3X3 type;
- Enabled hardware acceleration;
- UCL updated.

Change-Id: Ifc4670ee233e2037d15db6ab46d316ac614d7541

21 files changed:
.cproject
edc/image-grid.edc [new file with mode: 0644]
edc/images/gallery_thumbnail_circle_04.png [new file with mode: 0644]
inc/view/ImageGrid.h [new file with mode: 0644]
res/edje/theme.edc [new file with mode: 0644]
src/view/ImageGrid.cpp [new file with mode: 0644]
tizen-manifest.xml
ucl/inc/ucl/gui/EdjeWidget.h
ucl/inc/ucl/gui/EdjeWidget.hpp
ucl/inc/ucl/gui/Layout.h
ucl/inc/ucl/gui/Layout.hpp
ucl/inc/ucl/gui/Widget.h
ucl/inc/ucl/gui/Widget.hpp
ucl/inc/ucl/gui/WidgetItem.h
ucl/inc/ucl/gui/WidgetItem.hpp
ucl/inc/ucl/gui/types.h
ucl/inc/ucl/misc/SharedObject.h
ucl/inc/ucl/misc/SharedObject.hpp
ucl/src/gui/EdjeWidget.cpp
ucl/src/gui/Widget.cpp
ucl/src/gui/WidgetItem.cpp

index ebee3a1c7a58740c97f354980e8130cea022c55e..ab8f8d1b9035842c543d21893342a0c0d7380016 100644 (file)
--- a/.cproject
+++ b/.cproject
                                                        <tool id="org.tizen.nativecore.tool.ast.cpp.1628035309" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib.1095043535" name="Archive Generator" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.po.compiler.430660379" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
-                                                       <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.635130541" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
+                                                       <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.635130541" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler">
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.id.1943645302" superClass="sbi.gnu.edc.compiler.option.misc.id" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/images&quot;"/>
+                                                               </option>
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.sd.577011069" superClass="sbi.gnu.edc.compiler.option.misc.sd" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/sounds&quot;"/>
+                                                               </option>
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.fd.977212597" superClass="sbi.gnu.edc.compiler.option.misc.fd" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/fonts&quot;"/>
+                                                               </option>
+                                                       </tool>
                                                </toolChain>
                                        </folderInfo>
                                        <sourceEntries>
                                                        <tool id="org.tizen.nativecore.tool.ast.cpp.1219639105" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib.2124683293" name="Archive Generator" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.po.compiler.2050571850" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
-                                                       <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.941988681" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
+                                                       <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.941988681" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler">
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.id.1573672197" superClass="sbi.gnu.edc.compiler.option.misc.id" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/images&quot;"/>
+                                                               </option>
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.sd.1909604650" superClass="sbi.gnu.edc.compiler.option.misc.sd" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/sounds&quot;"/>
+                                                               </option>
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.fd.2078769259" superClass="sbi.gnu.edc.compiler.option.misc.fd" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/fonts&quot;"/>
+                                                               </option>
+                                                       </tool>
                                                </toolChain>
                                        </folderInfo>
                                        <sourceEntries>
diff --git a/edc/image-grid.edc b/edc/image-grid.edc
new file mode 100644 (file)
index 0000000..a15e3b2
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2017 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.
+ */
+
+images {
+   image: "gallery_thumbnail_circle_04.png" COMP;
+}
+group { "elm/layout/gallery_image_grid/hcomb_3x3_even";
+   parts {
+      spacer { "spacer_t";
+         scale: 1;
+         desc { "default";
+            align: 0.5 0.0;
+            fixed: 0 1;
+            min: 0 124;
+            rel1.relative: 0.00 0.00;
+            rel2.relative: 1.00 0.00;
+         }
+      }
+      spacer { "spacer_b";
+         scale: 1;
+         desc { "default";
+            align: 0.5 1.0;
+            fixed: 0 1;
+            min: 0 120;
+            rel1.relative: 0.00 1.00;
+            rel2.relative: 1.00 1.00;
+         }
+      }
+      image { "image_mask_0";
+         scale: 1;
+         desc { "default";
+            image.normal: "gallery_thumbnail_circle_04.png";
+            align: 0.5 0.5;
+            fixed: 0 1;
+            min: 114 116;
+            max: 114 116;
+            rel1.to_y: "spacer_t";
+            rel2.to_y: "spacer_b";
+            rel1.relative: 0.00 1.00;
+            rel2.relative: 1.00 0.00;
+         }
+      }
+      swallow { "swallow.cell_0";
+         desc { "default";
+            fixed: 1 1;
+            clip_to: "image_mask_0";
+            rel1.to: "image_mask_0";
+            rel2.to: "image_mask_0";
+            rel1.relative: 0.00 0.00;
+            rel2.relative: 1.00 1.00;
+         }
+      }
+   }
+}
+group { "elm/layout/gallery_image_grid/hcomb_3x3_odd";
+   parts {
+      spacer { "spacer_t";
+         scale: 1;
+         desc { "default";
+            align: 0.5 0.0;
+            fixed: 0 1;
+            min: 0 23;
+            rel1.relative: 0.00 0.00;
+            rel2.relative: 1.00 0.00;
+         }
+      }
+      spacer { "spacer_b";
+         scale: 1;
+         desc { "default";
+            align: 0.5 1.0;
+            fixed: 0 1;
+            min: 0 19;
+            rel1.relative: 0.00 1.00;
+            rel2.relative: 1.00 1.00;
+         }
+      }
+      spacer { "spacer_m";
+         scale: 1;
+         desc { "default";
+            fixed: 0 1;
+            min: 0 86;
+            max: -1 86;
+            rel1.to_y: "spacer_t";
+            rel2.to_y: "spacer_b";
+            rel1.relative: 0.00 1.00;
+            rel2.relative: 1.00 0.00;
+         }
+      }
+      image { "image_mask_0";
+         scale: 1;
+         desc { "default";
+            image.normal: "gallery_thumbnail_circle_04.png";
+            align: 0.5 1.0;
+            fixed: 1 1;
+            min: 114 116;
+            max: 114 116;
+            rel1.to_y: "spacer_m";
+            rel2.to_y: "spacer_m";
+            rel1.relative: 0.50 0.00;
+            rel2.relative: 0.50 0.00;
+         }
+      }
+      image { "image_mask_1";
+         scale: 1;
+         desc { "default";
+            image.normal: "gallery_thumbnail_circle_04.png";
+            align: 0.5 0.0;
+            fixed: 1 1;
+            min: 114 116;
+            max: 114 116;
+            rel1.to_y: "spacer_m";
+            rel2.to_y: "spacer_m";
+            rel1.relative: 0.50 1.00;
+            rel2.relative: 0.50 1.00;
+         }
+      }
+      swallow { "swallow.cell_0";
+         desc { "default";
+            fixed: 1 1;
+            clip_to: "image_mask_0";
+            rel1.to: "image_mask_0";
+            rel2.to: "image_mask_0";
+            rel1.relative: 0.00 0.00;
+            rel2.relative: 1.00 1.00;
+         }
+      }
+      swallow { "swallow.cell_1";
+         desc { "default";
+            fixed: 1 1;
+            clip_to: "image_mask_1";
+            rel1.to: "image_mask_1";
+            rel2.to: "image_mask_1";
+            rel1.relative: 0.00 0.00;
+            rel2.relative: 1.00 1.00;
+         }
+      }
+   }
+}
diff --git a/edc/images/gallery_thumbnail_circle_04.png b/edc/images/gallery_thumbnail_circle_04.png
new file mode 100644 (file)
index 0000000..b2debe7
Binary files /dev/null and b/edc/images/gallery_thumbnail_circle_04.png differ
diff --git a/inc/view/ImageGrid.h b/inc/view/ImageGrid.h
new file mode 100644 (file)
index 0000000..083a920
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2017 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 __GALLERY_VIEW_IMAGE_GRID_H__
+#define __GALLERY_VIEW_IMAGE_GRID_H__
+
+#include <deque>
+
+#include "ucl/gui/StyledWidget.h"
+
+namespace gallery {
+
+       UCL_DECLARE_REF_ALIASES(ImageGrid);
+
+       class ImageGrid : public ucl::Widget {
+       public:
+               enum class Type {
+                       HCOMB_3X3
+               };
+
+               class IListener : public ucl::Polymorphic {
+               public:
+                       virtual void onItemRealized(int itemIndex) = 0;
+                       virtual void onItemUnrealized(int itemIndex) = 0;
+               };
+
+               class Builder {
+               public:
+                       Builder();
+                       Builder &setType(Type value);
+                       Builder &setListener(IListener *value);
+                       ImageGridSRef build(Widget &parent) const;
+               private:
+                       Type m_type;
+                       IListener *m_listener;
+               };
+
+               struct ItemParams {
+                       std::string imagePath;
+               };
+
+       public:
+               void setListener(IListener *listener);
+
+               void setItemCount(int count);
+
+               void update();
+
+               ucl::Result updateItem(int itemIndex, const ItemParams &params);
+
+               ucl::Result isItemRealized(int itemIndex);
+
+       private:
+               class Slot;
+               using SlotUPtr = std::unique_ptr<Slot>;
+
+               struct Info;
+               struct HcombInfo;
+
+       private:
+               friend class ucl::RefCountObj<ImageGrid>;
+               ImageGrid(ucl::RefCountObjBase *rc, Type type, Evas_Object *scroller);
+
+               static const Info &getInfo(Type type);
+
+               template <class FUNC>
+               ucl::Result doWithItem(int itemIndex, FUNC &&func);
+
+               // Initialization
+               void prepare();
+
+               // Actual slots count
+               bool updateSlotCount();
+               int calcSlotCount();
+               void setSlotCount(int newSlotCount);
+
+               // Optimal slots count
+               bool updateOptimalSlotCount();
+               int calcOptimalSlotCount();
+
+               // Maximum slots count
+               bool updateMaxSlotCount();
+               int calcMaxSlotCount();
+
+               // Actual begin slot index
+               bool updateBeginSlotIndex();
+               int calcBeginSlotIndex();
+               void setBeginSlotIndex(int newBeginSlotIndex);
+
+               // Maximum begin slot index
+               bool updateMaxBeginSlotIndex();
+               int calcMaxBeginSlotIndex();
+
+               // Misc
+               void updatePadSizes();
+               void updateScrollBias();
+               void updateRectMins();
+
+               // Scroller size
+               bool updateScrollerSize();
+               int calcScrollerSize();
+
+               // Scroller scroll offset
+               bool updateScrollOffset();
+               int calcScrollOffset();
+
+               // Slots rotations
+               void rotateSlotsRight(int count);
+               void rotateSlotsLeft(int count);
+
+               // Slots realization/unrealization
+               void realizeSlots();
+               void unrealizeSlots(int beginSlotOffset, int endSlotOffset);
+
+               // Event handling
+               void handleScrolling();
+               void handleResize();
+
+               // Events
+               void onScrollerResize(Widget &sender, void *eventInfo);
+               void onScrollerMove(Widget &sender, void *eventInfo);
+               void onBoxMove(Widget &sender, void *eventInfo);
+
+       private:
+               const Info &m_info;
+
+               ucl::StyledWidget m_scroller;
+               ucl::ElmWidget m_box;
+               ucl::Widget m_rect1;
+               ucl::Widget m_rect2;
+
+               IListener *m_listener;
+               int m_itemCount;
+
+               std::deque<SlotUPtr> m_slots;
+
+               int m_slotCount;
+               int m_optimalSlotCount;
+               int m_maxSlotCount;
+
+               int m_beginSlotIndex;
+               int m_maxBeginSlotIndex;
+
+               int m_scrollBias;
+               int m_padSize1;
+               int m_padSize2;
+
+               int m_slotSize;
+               int m_scrollerSize;
+               int m_scrollOffset;
+       };
+}
+
+#endif // __GALLERY_VIEW_IMAGE_GRID_H__
diff --git a/res/edje/theme.edc b/res/edje/theme.edc
new file mode 100644 (file)
index 0000000..b31271b
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2017 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.
+ */
+
+collections {
+   base_scale: 1.3;
+
+   #include "../../edc/image-grid.edc"
+}
diff --git a/src/view/ImageGrid.cpp b/src/view/ImageGrid.cpp
new file mode 100644 (file)
index 0000000..5ed2def
--- /dev/null
@@ -0,0 +1,835 @@
+/*
+ * Copyright 2017 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 "view/ImageGrid.h"
+
+#include <array>
+#include <vector>
+
+#include "ucl/gui/Layout.h"
+
+#include "../common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       using namespace ucl;
+
+       const TString SLOT_PART_FMT = {"swallow.cell_%d"};
+}}}
+
+namespace gallery {
+
+       using namespace ucl;
+
+       // ImageGrid::Builder //
+
+       ImageGrid::Builder::Builder() :
+               m_type(Type::HCOMB_3X3),
+               m_listener(nullptr)
+       {
+       }
+
+       ImageGrid::Builder &ImageGrid::Builder::setType(const Type value)
+       {
+               m_type = value;
+               return *this;
+       }
+
+       ImageGrid::Builder &ImageGrid::Builder::setListener(IListener *const value)
+       {
+               m_listener = value;
+               return *this;
+       }
+
+       ImageGridSRef ImageGrid::Builder::build(Widget &parent) const
+       {
+               Evas_Object *const scrollerEo = elm_scroller_add(parent);
+               if (!scrollerEo) {
+                       ELOG("elm_scroller_add() failed!");
+                       return {};
+               }
+
+               auto result = makeShared<ImageGrid>(m_type, scrollerEo);
+
+               result->bindToEo();
+               result->setListener(m_listener);
+
+               return result;
+       }
+
+       // ImageGrid::Info //
+
+       struct ImageGrid::Info {
+               const std::array<LayoutTheme, 2> slotThemes;
+               const std::array<int, 2> slotLens;
+               const int scrollLimit;
+               const bool isHorizontal;
+
+               virtual int calcItemIndexFromCell(
+                               const int slotIndex, const int itemOffset) const = 0;
+               virtual void calcCellFromItemIndex(const int itemIndex,
+                               int &slotIndex, int &itemOffset) const = 0;
+               virtual int calcMaxSlotCount(const int itemCount) const = 0;
+
+               Info(const std::array<LayoutTheme, 2> &slotThemes,
+                               const std::array<int, 2> &slotLens,
+                               const int scrollLimit, const bool isHorizontal) :
+                       slotThemes(slotThemes),
+                       slotLens(slotLens),
+                       scrollLimit(scrollLimit),
+                       isHorizontal(isHorizontal)
+               {
+               }
+       };
+
+       // ImageGrid::HcombInfo //
+
+       struct ImageGrid::HcombInfo : Info {
+               const int totalLength;
+
+               virtual int calcItemIndexFromCell(
+                               const int slotIndex, const int itemOffset) const final override
+               {
+                       return ((slotIndex / 2 * totalLength) +
+                                       (itemOffset * 2) + ((slotIndex ^ 1) & 1));
+               }
+
+               virtual void calcCellFromItemIndex(const int itemIndex,
+                               int &slotIndex, int &itemOffset) const final override
+               {
+                       slotIndex = (itemIndex / totalLength);
+                       itemOffset = (itemIndex % totalLength);
+                       slotIndex += (slotIndex + ((itemOffset ^ 1) & 1));
+                       itemOffset /= 2;
+               }
+
+               virtual int calcMaxSlotCount(const int itemCount) const final override
+               {
+                       return ((itemCount + (totalLength - 1)) / totalLength * 2);
+               }
+
+               HcombInfo(const int totalLength,
+                               const std::array<LayoutTheme, 2> &slotThemes) :
+                       Info(slotThemes, {(totalLength / 2), ceilDiv<2>(totalLength)},
+                               (totalLength - 1), true),
+                       totalLength(totalLength)
+               {
+               }
+       };
+
+       // ImageGrid::Slot //
+
+       class ImageGrid::Slot {
+       private:
+               class Item {
+               public:
+                       Item(const ImageGrid &imageGrid, Widget &parent) :
+                               m_imageGrid(imageGrid),
+                               m_image(evas_object_image_filled_add(parent.getEvas())),
+                               m_realizeIndex(-1),
+                               m_wasUpdated(false)
+                       {
+                               show(m_image);
+                       }
+
+                       Widget &getWidget()
+                       {
+                               return m_image;
+                       }
+
+                       void setImageLoadSize(const int value)
+                       {
+                               evas_object_image_load_size_set(m_image, value, value);
+                       }
+
+                       bool isRealized() const
+                       {
+                               return (m_realizeIndex >= 0);
+                       }
+
+                       void realize(const int itemIndex)
+                       {
+                               if (isRealized()) {
+                                       return;
+                               }
+
+                               m_wasUpdated = false;
+
+                               if (itemIndex < m_imageGrid.m_itemCount) {
+                                       m_realizeIndex = itemIndex;
+
+                                       if (m_imageGrid.m_listener) {
+                                               m_imageGrid.m_listener->onItemRealized(itemIndex);
+                                       }
+                               }
+
+                               if (!m_wasUpdated) {
+                                       makeTransparent(m_image);
+                               }
+                       }
+
+                       void unrealize()
+                       {
+                               if (!isRealized()) {
+                                       return;
+                               }
+
+                               const int itemIndex = m_realizeIndex;
+                               m_realizeIndex = -1;
+
+                               if (m_imageGrid.m_listener) {
+                                       m_imageGrid.m_listener->onItemUnrealized(itemIndex);
+                               }
+                       }
+
+                       bool update(const ItemParams &params)
+                       {
+                               if (!isRealized()) {
+                                       return false;
+                               }
+
+                               m_wasUpdated = true;
+
+                               if (isEmpty(params.imagePath)) {
+                                       makeTransparent(m_image);
+                                       return true;
+                               }
+
+                               evas_object_image_file_set(m_image,
+                                               params.imagePath.c_str(), NULL);
+
+                               int w, h;
+                               getSize(m_image, &w, &h);
+                               m_image.setARHint(WidgetARHint::NEITHER, w, h);
+
+                               makeWhite(m_image);
+
+                               return true;
+                       }
+
+               private:
+                       const ImageGrid &m_imageGrid;
+                       Widget m_image;
+                       int m_realizeIndex;
+                       bool m_wasUpdated;
+               };
+
+       public:
+               Slot(ImageGrid &imageGrid, const bool isOdd) :
+                       m_info(imageGrid.m_info),
+                       m_layout(elm_layout_add(imageGrid.m_box), true),
+                       m_isRealized(false)
+               {
+                       if (!m_layout.setTheme(m_info.slotThemes[isOdd])) {
+                               ELOG("setTheme() failed!");
+                       }
+                       fill(m_layout);
+                       show(m_layout);
+
+                       const int length = m_info.slotLens[isOdd];
+                       for (int i = 0; i < length; ++i) {
+                               m_items.emplace_back(new Item(imageGrid, m_layout));
+
+                               m_layout.setContent(
+                                               EdjePart(impl::SLOT_PART_FMT.format(i)),
+                                               m_items.back()->getWidget());
+                       }
+               }
+
+               Widget &getWidget()
+               {
+                       return m_layout;
+               }
+
+               int calcSize()
+               {
+                       int w = 0;
+                       int h = 0;
+                       m_layout.calculate();
+                       m_layout.getMin(&w, &h);
+                       return (m_info.isHorizontal ? w : h);
+               }
+
+               void setImageLoadSize(const int value)
+               {
+                       for (auto &item: m_items) {
+                               item->setImageLoadSize(value);
+                       }
+               }
+
+               void unrealize()
+               {
+                       if (!m_isRealized) {
+                               return;
+                       }
+                       m_isRealized = false;
+
+                       for (auto &item: m_items) {
+                               item->unrealize();
+                       }
+               }
+
+               void realize(const int slotIndex)
+               {
+                       if (m_isRealized) {
+                               return;
+                       }
+                       m_isRealized = true;
+
+                       for (UInt i = 0; i < m_items.size(); ++i) {
+                               m_items[i]->realize(
+                                               m_info.calcItemIndexFromCell(slotIndex, i));
+                       }
+               }
+
+               bool updateItem(const int itemOffset, const ItemParams &params)
+               {
+                       return m_items[itemOffset]->update(params);
+               }
+
+               bool isItemRealized(const int itemOffset) const
+               {
+                       return m_items[itemOffset]->isRealized();
+               }
+
+       private:
+               const Info &m_info;
+               std::vector<std::unique_ptr<Item>> m_items;
+               Layout m_layout;
+               bool m_isRealized;
+       };
+
+       // ImageGrid //
+
+       ImageGrid::ImageGrid(RefCountObjBase *const rc, const Type type,
+                       Evas_Object *const scroller) :
+               Widget(rc, scroller, true),
+               m_info(getInfo(type)),
+
+               m_scroller(scroller),
+               m_box(elm_box_add(m_scroller)),
+               m_rect1(evas_object_rectangle_add(m_box.getEvas())),
+               m_rect2(evas_object_rectangle_add(m_box.getEvas())),
+
+               m_listener(nullptr),
+               m_itemCount(0),
+
+               m_slotCount(0), // Must be even >= 2
+               m_optimalSlotCount(2), // Must be even >= 2
+               m_maxSlotCount(2), // Must be even >= 2
+
+               m_beginSlotIndex(0),
+               m_maxBeginSlotIndex(0),
+
+               m_scrollBias(0),
+               m_padSize1(0),
+               m_padSize2(0),
+
+               m_slotSize(0), // Must not be 0
+               m_scrollerSize(1), // Must not be 0
+               m_scrollOffset(0)
+       {
+               prepare();
+
+               updateSlotCount();
+
+               updatePadSizes();
+               updateScrollBias();
+               updateRectMins();
+       }
+
+       const ImageGrid::Info &ImageGrid::getInfo(const Type type)
+       {
+               switch (type) {
+               case Type::HCOMB_3X3:
+               default: {
+                               static HcombInfo info{3, {
+                                       LayoutTheme(
+                                               "layout", "gallery_image_grid", "hcomb_3x3_even"),
+                                       LayoutTheme(
+                                               "layout", "gallery_image_grid", "hcomb_3x3_odd")}};
+                               return info;
+                       }
+               }
+       }
+
+       void ImageGrid::prepare()
+       {
+               fill(m_rect1);
+               elm_box_pack_end(m_box, m_rect1);
+               makeTransparent(m_rect1);
+               show(m_rect1);
+
+               expandAndFill(m_rect2);
+               elm_box_pack_end(m_box, m_rect2);
+               makeTransparent(m_rect2);
+               show(m_rect2);
+
+               expandAndFill(m_box);
+               m_scroller.setContent(m_box);
+               elm_box_horizontal_set(m_box, toEina(m_info.isHorizontal));
+               show(m_box);
+
+               expandAndFill(m_scroller);
+               if (m_info.isHorizontal) {
+                       elm_scroller_page_scroll_limit_set(
+                                       m_scroller, m_info.scrollLimit, 0);
+               } else {
+                       elm_scroller_page_scroll_limit_set(
+                                       m_scroller, 0, m_info.scrollLimit);
+               }
+               show(m_scroller);
+
+               m_scroller.addEventHandler(WidgetEvent::RESIZE,
+                               WEAK_DELEGATE(ImageGrid::onScrollerResize, asWeak(this)));
+
+               m_scroller.addEventHandler(WidgetEvent::MOVE,
+                               WEAK_DELEGATE(ImageGrid::onScrollerMove, asWeak(this)));
+
+               m_box.addEventHandler(WidgetEvent::MOVE,
+                               WEAK_DELEGATE(ImageGrid::onBoxMove, asWeak(this)));
+       }
+
+       void ImageGrid::setListener(IListener *const listener)
+       {
+               m_listener = listener;
+       }
+
+       void ImageGrid::setItemCount(const int count)
+       {
+               if (m_itemCount == count) {
+                       return;
+               }
+
+               unrealizeSlots(0, m_slotCount);
+
+               m_itemCount = count;
+
+               if (updateMaxSlotCount()) {
+                       updateSlotCount();
+                       if (updateMaxBeginSlotIndex()) {
+                               updateBeginSlotIndex();
+                       }
+               }
+
+               realizeSlots();
+               updateRectMins();
+       }
+
+       void ImageGrid::update()
+       {
+               unrealizeSlots(0, m_slotCount);
+               realizeSlots();
+       }
+
+       Result ImageGrid::updateItem(const int itemIndex, const ItemParams &params)
+       {
+               return doWithItem(itemIndex,
+                       [&params](Slot &slot, const int itemOffset)
+                       {
+                               return (slot.updateItem(itemOffset, params) ?
+                                               RES_OK : RES_FALSE);
+                       });
+       }
+
+       Result ImageGrid::isItemRealized(const int itemIndex)
+       {
+               return doWithItem(itemIndex,
+                       [](Slot &slot, const int itemOffset)
+                       {
+                               return (slot.isItemRealized(itemOffset) ? RES_OK : RES_FALSE);
+                       });
+       }
+
+       template <class FUNC>
+       Result ImageGrid::doWithItem(const int itemIndex, FUNC &&func)
+       {
+               if ((itemIndex < 0) || (itemIndex >= m_itemCount)) {
+                       LOG_RETURN(RES_INVALID_ARGUMENTS,
+                                       "Item index out of range: %d", itemIndex);
+               }
+
+               int slotIndex = 0;
+               int itemOffset = 0;
+               m_info.calcCellFromItemIndex(itemIndex, slotIndex, itemOffset);
+
+               const int slotOffset = (slotIndex - m_beginSlotIndex);
+               if ((slotOffset < 0) || (slotOffset >= m_slotCount)) {
+                       return RES_FALSE;
+               }
+
+               return func(*m_slots[slotOffset], itemOffset);
+       }
+
+       bool ImageGrid::updateSlotCount()
+       {
+               const int newSlotCount = calcSlotCount();
+
+               if (newSlotCount != m_slotCount) {
+                       DLOG("newSlotCount: %d; m_slotCount: %d;",
+                                       newSlotCount, m_slotCount);
+                       setSlotCount(newSlotCount);
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcSlotCount()
+       {
+               return std::min(m_optimalSlotCount, m_maxSlotCount);
+       }
+
+       void ImageGrid::setSlotCount(const int newSlotCount)
+       {
+               for (int i = m_slotCount; i < newSlotCount; ++i) {
+                       const bool isOdd = ((m_beginSlotIndex + i) & 1);
+
+                       auto slot = util::makeUnique(new Slot(*this, isOdd));
+
+                       if (m_slotSize == 0) {
+                               UCL_ASSERT(!isOdd, "Must be even!");
+                               m_slotSize = std::max(slot->calcSize(), 1);
+                               if (m_info.isHorizontal) {
+                                       elm_scroller_page_size_set(m_scroller, m_slotSize, 0);
+                               } else {
+                                       elm_scroller_page_size_set(m_scroller, 0, m_slotSize);
+                               }
+                       }
+
+                       slot->setImageLoadSize(m_slotSize);
+
+                       elm_box_pack_before(m_box, slot->getWidget(), m_rect2);
+
+                       m_slots.emplace_back(std::move(slot));
+               }
+
+               unrealizeSlots(newSlotCount, m_slotCount);
+
+               m_slots.resize(newSlotCount);
+               m_slotCount = newSlotCount;
+       }
+
+       bool ImageGrid::updateOptimalSlotCount()
+       {
+               const int newOptimalSlotCount = calcOptimalSlotCount();
+
+               if (newOptimalSlotCount != m_optimalSlotCount) {
+                       DLOG("newOptimalSlotCount: %d; m_optimalSlotCount: %d;",
+                                       newOptimalSlotCount, m_optimalSlotCount);
+                       m_optimalSlotCount = newOptimalSlotCount;
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcOptimalSlotCount()
+       {
+               return ((((m_scrollerSize - 1) + (m_slotSize - 1)) /
+                               m_slotSize + 1) * 2);
+       }
+
+       bool ImageGrid::updateMaxSlotCount()
+       {
+               const int newMaxSlotCount = calcMaxSlotCount();
+
+               if (newMaxSlotCount != m_maxSlotCount) {
+                       DLOG("newMaxSlotCount: %d; m_maxSlotCount: %d;",
+                                       newMaxSlotCount, m_maxSlotCount);
+                       m_maxSlotCount = newMaxSlotCount;
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcMaxSlotCount()
+       {
+               return std::max(m_info.calcMaxSlotCount(m_itemCount), 2);
+       }
+
+       bool ImageGrid::updateBeginSlotIndex()
+       {
+               const int newBeginSlotIndex = calcBeginSlotIndex();
+
+               if (newBeginSlotIndex != m_beginSlotIndex) {
+                       DLOG("newBeginSlotIndex: %d; m_beginSlotIndex: %d;",
+                                       newBeginSlotIndex, m_beginSlotIndex);
+                       setBeginSlotIndex(newBeginSlotIndex);
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcBeginSlotIndex()
+       {
+               const int evenScrolledSize = (m_scrollOffset - m_scrollBias);
+               const int oddScrolledSize = (evenScrolledSize - m_slotSize / 2);
+
+               const int beginEvenSlotIndex = (evenScrolledSize / m_slotSize);
+               const int beginOddSlotIndex = (oddScrolledSize / m_slotSize);
+
+               int beginSlotIndex = ((beginEvenSlotIndex <= beginOddSlotIndex) ?
+                               (beginEvenSlotIndex * 2) : (beginOddSlotIndex * 2 + 1));
+
+               if (beginSlotIndex < 0) {
+                       beginSlotIndex = 0;
+               } else if (beginSlotIndex > m_maxBeginSlotIndex) {
+                       beginSlotIndex = m_maxBeginSlotIndex;
+               }
+
+               return beginSlotIndex;
+       }
+
+       void ImageGrid::setBeginSlotIndex(const int newBeginSlotIndex)
+       {
+               const int beginSlotIndex = m_beginSlotIndex;
+               const int endSlotIndex = (beginSlotIndex + m_slotCount);
+               const int newEndSlotIndex = (newBeginSlotIndex + m_slotCount);
+
+               if ((newEndSlotIndex <= beginSlotIndex) ||
+                               (endSlotIndex <= newBeginSlotIndex)) {
+
+                       unrealizeSlots(0, m_slotCount);
+
+                       if ((beginSlotIndex ^ newBeginSlotIndex) & 1) {
+                               rotateSlotsRight(1);
+                       }
+
+               } else if (newBeginSlotIndex < beginSlotIndex) {
+                       const int goodSlots = (newEndSlotIndex - beginSlotIndex);
+                       const int badSlots = (m_slotCount - goodSlots);
+
+                       unrealizeSlots(goodSlots, m_slotCount);
+
+                       if (goodSlots > badSlots) {
+                               rotateSlotsRight(badSlots);
+                       } else {
+                               rotateSlotsLeft(goodSlots);
+                       }
+               } else {
+                       const int goodSlots = (endSlotIndex - newBeginSlotIndex);
+                       const int badSlots = (m_slotCount - goodSlots);
+
+                       unrealizeSlots(0, badSlots);
+
+                       if (goodSlots > badSlots) {
+                               rotateSlotsLeft(badSlots);
+                       } else {
+                               rotateSlotsRight(goodSlots);
+                       }
+               }
+
+               m_beginSlotIndex = newBeginSlotIndex;
+       }
+
+       bool ImageGrid::updateMaxBeginSlotIndex()
+       {
+               const int newMaxBeginSlotIndex = calcMaxBeginSlotIndex();
+
+               if (newMaxBeginSlotIndex != m_maxBeginSlotIndex) {
+                       DLOG("newMaxBeginSlotIndex: %d; m_maxBeginSlotIndex: %d;",
+                                       newMaxBeginSlotIndex, m_maxBeginSlotIndex);
+                       m_maxBeginSlotIndex = newMaxBeginSlotIndex;
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcMaxBeginSlotIndex()
+       {
+               return (m_maxSlotCount - m_slotCount);
+       }
+
+       void ImageGrid::updatePadSizes()
+       {
+               const int spaceSize = (m_scrollerSize -
+                               ((m_scrollerSize / m_slotSize) * m_slotSize));
+
+               m_padSize1 = (spaceSize / 2);
+               m_padSize2 = (spaceSize - m_padSize1 + m_slotSize);
+       }
+
+       void ImageGrid::updateScrollBias()
+       {
+               m_scrollBias = (((m_optimalSlotCount / 2 - 1) * m_slotSize -
+                               m_scrollerSize) / 2 + m_padSize1);
+       }
+
+       void ImageGrid::updateRectMins()
+       {
+               const int beginEvenCols = ((m_beginSlotIndex + 1) / 2);
+               const int sideEvenCols = ((m_maxSlotCount - m_slotCount) / 2);
+               const int endEvenCols = (sideEvenCols - beginEvenCols);
+
+               const int rectMin1 = (m_padSize1 + (beginEvenCols * m_slotSize));
+               const int rectMin2 = (m_padSize2 + (endEvenCols * m_slotSize));
+
+               if (m_info.isHorizontal) {
+                       m_rect1.setMin(rectMin1, 0);
+                       m_rect2.setMin(rectMin2, 0);
+               } else {
+                       m_rect1.setMin(0, rectMin1);
+                       m_rect2.setMin(0, rectMin2);
+               }
+       }
+
+       int ImageGrid::calcScrollerSize()
+       {
+               int scrollerW = 0;
+               int scrollerH = 0;
+               getSize(m_scroller, &scrollerW, &scrollerH);
+
+               return std::max((m_info.isHorizontal ? scrollerW : scrollerH), 1);
+       }
+
+       bool ImageGrid::updateScrollerSize()
+       {
+               const int newScrollerSize = calcScrollerSize();
+
+               if (newScrollerSize != m_scrollerSize) {
+                       DLOG("newScrollerSize: %d; m_scrollerSize: %d;",
+                                       newScrollerSize, m_scrollerSize);
+                       m_scrollerSize = newScrollerSize;
+                       return true;
+               }
+
+               return false;
+       }
+
+       int ImageGrid::calcScrollOffset()
+       {
+               int scrollerX = 0;
+               int scrollerY = 0;
+               getPosition(m_scroller, &scrollerX, &scrollerY);
+
+               int boxX = 0;
+               int boxY = 0;
+               getPosition(m_box, &boxX, &boxY);
+
+               int scrollOffset = (m_info.isHorizontal ?
+                               (scrollerX - boxX) : (scrollerY - boxY));
+               if (scrollOffset < 0) {
+                       scrollOffset = 0;
+               }
+
+               return scrollOffset;
+       }
+
+       bool ImageGrid::updateScrollOffset()
+       {
+               const int newScrollOffset = calcScrollOffset();
+
+               if (newScrollOffset != m_scrollOffset) {
+                       DLOG("newScrollOffset: %d; m_scrollOffset: %d;",
+                                       newScrollOffset, m_scrollOffset);
+                       m_scrollOffset= newScrollOffset;
+                       return true;
+               }
+
+               return false;
+       }
+
+       void ImageGrid::rotateSlotsRight(const int count)
+       {
+               DLOG("count: %d", count);
+               for (int i = 0; i < count; ++i) {
+                       SlotUPtr slot = std::move(m_slots.back());
+                       m_slots.pop_back();
+                       elm_box_unpack(m_box, slot->getWidget());
+                       elm_box_pack_after(m_box, slot->getWidget(), m_rect1);
+                       m_slots.emplace_front(std::move(slot));
+               }
+       }
+
+       void ImageGrid::rotateSlotsLeft(const int count)
+       {
+               DLOG("count: %d", count);
+               for (int i = 0; i < count; ++i) {
+                       SlotUPtr slot = std::move(m_slots.front());
+                       m_slots.pop_front();
+                       elm_box_unpack(m_box, slot->getWidget());
+                       elm_box_pack_before(m_box, slot->getWidget(), m_rect2);
+                       m_slots.emplace_back(std::move(slot));
+               }
+       }
+
+       void ImageGrid::realizeSlots()
+       {
+               for (int i = 0; i < m_slotCount; ++i) {
+                       m_slots[i]->realize(m_beginSlotIndex + i);
+               }
+       }
+
+       void ImageGrid::unrealizeSlots(
+                       const int beginSlotOffset, const int endSlotOffset)
+       {
+               for (int i = beginSlotOffset; i < endSlotOffset; ++i) {
+                       m_slots[i]->unrealize();
+               }
+       }
+
+       void ImageGrid::handleScrolling()
+       {
+               if (updateScrollOffset() && updateBeginSlotIndex()) {
+                       realizeSlots();
+                       updateRectMins();
+               }
+       }
+
+       void ImageGrid::handleResize()
+       {
+               if (updateScrollerSize()) {
+                       bool needRealize = false;
+
+                       updatePadSizes();
+
+                       if (updateOptimalSlotCount() && updateSlotCount()) {
+                               updateMaxBeginSlotIndex();
+                               needRealize = true;
+                       }
+
+                       updateScrollBias();
+
+                       if (updateBeginSlotIndex()) {
+                               needRealize = true;
+                       }
+
+                       if (needRealize) {
+                               realizeSlots();
+                       }
+                       updateRectMins();
+               }
+       }
+
+       void ImageGrid::onScrollerResize(Widget &sender, void *eventInfo)
+       {
+               handleResize();
+       }
+
+       void ImageGrid::onScrollerMove(Widget &sender, void *eventInfo)
+       {
+               handleScrolling();
+       }
+
+       void ImageGrid::onBoxMove(Widget &sender, void *eventInfo)
+       {
+               handleScrolling();
+       }
+}
index aa3cf0350e76d4daa71d08f0e44a7fde3b281c29..22bd3cb5e5946ee949c3e074e4731ad6cdb18dd9 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.gallery" version="1.0.0">
        <profile name="wearable"/>
-       <ui-application appid="org.tizen.gallery" exec="gallery" multiple="false" nodisplay="false" taskmanage="true" type="capp">
+       <ui-application appid="org.tizen.gallery" exec="gallery" hw-acceleration="on" multiple="false" nodisplay="false" splash-screen-display="false" taskmanage="true" type="capp">
                <label>gallery</label>
                <icon>org.tizen.gallery.png</icon>
        </ui-application>
index b494b7433153a5c58d25370c8a47dedcb1595314..5700187f231b637b3c137517873803db717fe0da 100644 (file)
@@ -26,18 +26,18 @@ namespace ucl {
        class EdjeWidget : public ElmWidget {
        public:
                void setText(const TString &value);
-               void setPartText(EdjePart part, const TString &value);
+               void setText(EdjePart part, const TString &value);
 
                TString getText() const;
-               TString getPartText(EdjePart part) const;
+               TString getText(EdjePart part) const;
 
                void setContent(Evas_Object *content);
-               void setPartContent(EdjePart part, Evas_Object *content);
+               void setContent(EdjePart part, Evas_Object *content);
                Evas_Object *unsetContent();
-               Evas_Object *unsetPartContent(EdjePart part);
+               Evas_Object *unsetContent(EdjePart part);
 
                Evas_Object *getContent() const;
-               Evas_Object *getPartContent(EdjePart part) const;
+               Evas_Object *getContent(EdjePart part) const;
 
                void emitSignal(EdjeSignal signal, EdjeSignalSrc source);
 
index dbb06707fdafbe745dd94ce38c9888d86fbee775..bb539619b8fd0be3f7fc7b9faeefff39f664e9aa 100644 (file)
@@ -27,7 +27,7 @@ namespace ucl {
                return elm_object_text_get(getEo());
        }
 
-       inline TString EdjeWidget::getPartText(const EdjePart part) const
+       inline TString EdjeWidget::getText(const EdjePart part) const
        {
                return elm_object_part_text_get(getEo(), part.name);
        }
@@ -37,7 +37,7 @@ namespace ucl {
                elm_object_content_set(getEo(), content);
        }
 
-       inline void EdjeWidget::setPartContent(const EdjePart part,
+       inline void EdjeWidget::setContent(const EdjePart part,
                        Evas_Object *const content)
        {
                elm_object_part_content_set(getEo(), part.name, content);
@@ -48,7 +48,7 @@ namespace ucl {
                return elm_object_content_unset(getEo());
        }
 
-       inline Evas_Object *EdjeWidget::unsetPartContent(const EdjePart part)
+       inline Evas_Object *EdjeWidget::unsetContent(const EdjePart part)
        {
                return elm_object_part_content_unset(getEo(), part.name);
        }
@@ -58,7 +58,7 @@ namespace ucl {
                return elm_object_content_get(getEo());
        }
 
-       inline Evas_Object *EdjeWidget::getPartContent(const EdjePart part) const
+       inline Evas_Object *EdjeWidget::getContent(const EdjePart part) const
        {
                return elm_object_part_content_get(getEo(), part.name);
        }
index 1a2dd98626b8a3d2f4a96f8c0adb3a671923f2bb..dfe8aad08be5cfa0739d5adbecf0bf58ee3b14f9 100644 (file)
@@ -46,8 +46,10 @@ namespace ucl {
                using EdjeWidget::EdjeWidget;
                explicit Layout(Evas_Object *eo, bool isOwner = false);
 
-               void setTheme(const LayoutTheme &theme);
-               void setEdjeFile(const std::string &filePath, EdjeGroup group);
+               bool setTheme(const LayoutTheme &theme);
+               bool setEdjeFile(const std::string &filePath, EdjeGroup group);
+
+               Variant getEdjeData(EdjeDataKey key);
        };
 }
 
index 31f1d793691bf88cefde376abd0642b6a7433ec8..b4bc8a8d57fdd391294596022fff2c768b32c842 100644 (file)
@@ -57,14 +57,20 @@ namespace ucl {
        {
        }
 
-       inline void Layout::setTheme(const LayoutTheme &theme)
+       inline bool Layout::setTheme(const LayoutTheme &theme)
        {
-               elm_layout_theme_set(getEo(), theme.klass, theme.group, theme.style);
+               return elm_layout_theme_set(getEo(),
+                               theme.klass, theme.group, theme.style);
        }
 
-       inline void Layout::setEdjeFile(const std::string &filePath,
+       inline bool Layout::setEdjeFile(const std::string &filePath,
                        const EdjeGroup group)
        {
-               elm_layout_file_set(getEo(), filePath.c_str(), group.name);
+               return elm_layout_file_set(getEo(), filePath.c_str(), group.name);
+       }
+
+       inline Variant Layout::getEdjeData(EdjeDataKey key)
+       {
+               return elm_layout_data_get(getEo(), key);
        }
 }
index 655df0f9d2d06c7d678cfa5634d01f1879c0b3f4..1dd2a38ecd3ff6d0edec50af2f0cdd296db27595 100644 (file)
@@ -60,6 +60,12 @@ namespace ucl {
                void setVisible(bool value);
                bool isVisible() const;
 
+               void setColor(int r, int g, int b, int a = 255);
+               void setColor(int l, int a = 255);
+               void getColor(int &r, int &g, int &b, int &a) const;
+
+               void calculate();
+
                void setGeometry(int x, int y, int w, int h);
                void move(int x, int y);
                void resize(int w, int h);
@@ -76,6 +82,9 @@ namespace ucl {
                void getMin(int *w, int *h) const;
                void getMax(int *w, int *h) const;
 
+               void setARHint(WidgetARHint arControl, int w, int h);
+               void getARHint(WidgetARHint &arControl, int &w, int &h);
+
                void setFocused(bool value);
                bool isFocused() const;
 
@@ -101,7 +110,7 @@ namespace ucl {
 
                void setSelfRefUnique(const bool value);
 
-               void onEoFree(Evas *e, Evas_Object *obj, void *event_info);
+               void onEoDel(Evas *e, Evas_Object *obj, void *event_info);
 
                void delEventProxy(const EventProxiesIt it);
 
@@ -123,12 +132,15 @@ namespace ucl {
 
        // Non-member functions //
 
-       void getPosition(const Widget &widget, int &x, int &y);
-       void getSize(const Widget &widget, int &w, int &h);
+       void getPosition(const Widget &widget, int *x, int *y);
+       void getSize(const Widget &widget, int *w, int *h);
 
        void show(Widget &widget);
        void hide(Widget &widget);
 
+       void makeTransparent(Widget &widget);
+       void makeWhite(Widget &widget);
+
        void focus(Widget &widget);
        void unfocus(Widget &widget);
 
index 3584590ed327a853640d961878163ec35e2e507d..3bd2f4f80b5517cb3ff8dedb6e9a2b8f8caacaf5 100644 (file)
@@ -78,6 +78,27 @@ namespace ucl {
                return evas_object_visible_get(getEo());
        }
 
+       inline void Widget::setColor(const int r, const int g,
+                       const int b, const int a)
+       {
+               evas_object_color_set(getEo(), r, g, b, a);
+       }
+
+       inline void Widget::setColor(const int l, const int a)
+       {
+               evas_object_color_set(getEo(), l, l, l, a);
+       }
+
+       inline void Widget::getColor(int &r, int &g, int &b, int &a) const
+       {
+               evas_object_color_get(getEo(), &r, &g, &b, &a);
+       }
+
+       inline void Widget::calculate()
+       {
+               evas_object_smart_calculate(getEo());
+       }
+
        inline void Widget::setGeometry(const int x, const int y,
                        const int w, const int h)
        {
@@ -140,6 +161,19 @@ namespace ucl {
                evas_object_size_hint_max_get(getEo(), w, h);
        }
 
+       inline void Widget::setARHint(WidgetARHint arControl, int w, int h)
+       {
+               evas_object_size_hint_aspect_set(getEo(),
+                               static_cast<Evas_Aspect_Control>(arControl), w, h);
+       }
+
+       inline void Widget::getARHint(WidgetARHint &arControl, int &w, int &h)
+       {
+               Evas_Aspect_Control tmp = EVAS_ASPECT_CONTROL_NEITHER;
+               evas_object_size_hint_aspect_get(getEo(), &tmp, &w, &h);
+               arControl = static_cast<WidgetARHint>(tmp);
+       }
+
        inline void Widget::setFocused(const bool value)
        {
                setFocusedImpl(value);
@@ -152,14 +186,14 @@ namespace ucl {
 
        // Non-member functions //
 
-       inline void getPosition(const Widget &widget, int &x, int &y)
+       inline void getPosition(const Widget &widget, int *x, int *y)
        {
-               widget.getGeometry(&x, &y, nullptr, nullptr);
+               widget.getGeometry(x, y, nullptr, nullptr);
        }
 
-       inline void getSize(const Widget &widget, int &w, int &h)
+       inline void getSize(const Widget &widget, int *w, int *h)
        {
-               widget.getGeometry(nullptr, nullptr, &w, &h);
+               widget.getGeometry(nullptr, nullptr, w, h);
        }
 
        inline void show(Widget &widget)
@@ -172,6 +206,16 @@ namespace ucl {
                widget.setVisible(false);
        }
 
+       inline void makeTransparent(Widget &widget)
+       {
+               widget.setColor(0, 0);
+       }
+
+       inline void makeWhite(Widget &widget)
+       {
+               widget.setColor(255);
+       }
+
        inline void focus(Widget &widget)
        {
                widget.setFocused(true);
index b4e8ace9dba09f89a7a19e8c48f472673511d5a1..914ce4c5a391bbd846144e8e66036d576b97b34f 100644 (file)
@@ -42,18 +42,18 @@ namespace ucl {
                bool isEnabled() const;
 
                void setText(const TString &value) const;
-               void setPartText(EdjePart part, const TString &value) const;
+               void setText(EdjePart part, const TString &value) const;
 
                TString getText() const;
-               TString getPartText(EdjePart part) const;
+               TString getText(EdjePart part) const;
 
                void setContent(Evas_Object *content) const;
-               void setPartContent(EdjePart part, Evas_Object *content) const;
+               void setContent(EdjePart part, Evas_Object *content) const;
                Evas_Object *unsetContent() const;
-               Evas_Object *unsetPartContent(EdjePart part) const;
+               Evas_Object *unsetContent(EdjePart part) const;
 
                Evas_Object *getContent() const;
-               Evas_Object *getPartContent(EdjePart part) const;
+               Evas_Object *getContent(EdjePart part) const;
 
                void emitSignal(EdjeSignal signal, EdjeSignalSrc source) const;
 
index 48cafcbbb7aff20c50f34201a8bfe74b0d335b8b..577a02f6bbcbdb4f8a90381fded86f47fc6eb52d 100644 (file)
@@ -77,7 +77,7 @@ namespace ucl {
                return elm_object_item_text_get(getIt());
        }
 
-       inline TString WidgetItem::getPartText(const EdjePart part) const
+       inline TString WidgetItem::getText(const EdjePart part) const
        {
                return elm_object_item_part_text_get(getIt(), part.name);
        }
@@ -87,7 +87,7 @@ namespace ucl {
                elm_object_item_content_set(getIt(), content);
        }
 
-       inline void WidgetItem::setPartContent(const EdjePart part,
+       inline void WidgetItem::setContent(const EdjePart part,
                        Evas_Object *const content) const
        {
                elm_object_item_part_content_set(getIt(), part.name, content);
@@ -98,7 +98,7 @@ namespace ucl {
                return elm_object_item_content_unset(getIt());
        }
 
-       inline Evas_Object *WidgetItem::unsetPartContent(const EdjePart part) const
+       inline Evas_Object *WidgetItem::unsetContent(const EdjePart part) const
        {
                return elm_object_item_part_content_unset(getIt(), part.name);
        }
@@ -108,7 +108,7 @@ namespace ucl {
                return elm_object_item_content_get(getIt());
        }
 
-       inline Evas_Object *WidgetItem::getPartContent(const EdjePart part) const
+       inline Evas_Object *WidgetItem::getContent(const EdjePart part) const
        {
                return elm_object_item_part_content_get(getIt(), part.name);
        }
index 6ba7020ff7e2187545deea40fc2fa8960c584b92..bb6badba16904a00896e6989aff02827d3e53079 100644 (file)
@@ -26,6 +26,7 @@
 #include "ucl/misc/smartDelegation.h"
 #include "ucl/misc/Aspect.h"
 #include "ucl/misc/TString.h"
+#include "ucl/misc/Variant.h"
 
 namespace ucl {
 
@@ -33,6 +34,7 @@ namespace ucl {
 
        struct EdjePart : Aspect<EdjePart> { using Aspect::Aspect; };
        struct EdjeGroup : Aspect<EdjeGroup> { using Aspect::Aspect; };
+       struct EdjeDataKey : Aspect<EdjeDataKey> { using Aspect::Aspect; };
 
        struct EdjeSignal : Aspect<EdjeSignal> { using Aspect::Aspect; };
        struct EdjeSignalSrc : Aspect<EdjeSignalSrc> { using Aspect::Aspect; };
@@ -52,7 +54,6 @@ namespace ucl {
 
        enum class WidgetEvent {
                DEL  = EVAS_CALLBACK_DEL,
-               FREE = EVAS_CALLBACK_FREE,
 
                MOUSE_IN    = EVAS_CALLBACK_MOUSE_IN,
                MOUSE_OUT   = EVAS_CALLBACK_MOUSE_OUT,
@@ -84,6 +85,16 @@ namespace ucl {
                IMAGE_PRELOADED = EVAS_CALLBACK_IMAGE_PRELOADED
        };
 
+       // WidgetARHint //
+
+       enum class WidgetARHint
+       {
+               NEITHER = EVAS_ASPECT_CONTROL_NEITHER,
+               HORIZONTAL = EVAS_ASPECT_CONTROL_HORIZONTAL,
+               VERTICAL = EVAS_ASPECT_CONTROL_VERTICAL,
+               BOTH = EVAS_ASPECT_CONTROL_BOTH
+       };
+
        // LayoutTheme //
 
        struct LayoutTheme {
index 37d726c6de1e300286e30611c695fd70f61935cb..80654e476cc7af163eec8b9499b242f380debf27 100644 (file)
@@ -26,6 +26,16 @@ namespace ucl {
 
        class SharedObject : public NonCopyable {
        public:
+               template <class T>
+               static SharedRef<T> asShared(T *obj);
+               template <class T>
+               static WeakRef<T> asWeak(T *obj);
+
+               template <class T>
+               static SharedRef<T> asShared(T &obj);
+               template <class T>
+               static WeakRef<T> asWeak(T &obj);
+
                template <class T>
                SharedRef<T> asShared();
                template <class T>
@@ -56,6 +66,11 @@ namespace ucl {
        SharedRef<T> asShared(T *obj);
        template <class T>
        WeakRef<T> asWeak(T *obj);
+
+       template <class T>
+       SharedRef<T> asShared(T &obj);
+       template <class T>
+       WeakRef<T> asWeak(T &obj);
 }
 
 #include "SharedObject.hpp"
index 1c9bf8e2aab2c33ccd7a49cc3898759d9893d205..f1fbaed3f1257b8a1f98410462f1b64a39672dbc 100644 (file)
@@ -21,6 +21,30 @@ namespace ucl {
        {
        }
 
+       template <class T>
+       inline SharedRef<T> SharedObject::asShared(T *obj)
+       {
+               return (obj ? asShared(*obj) : SharedRef<T>());
+       }
+
+       template <class T>
+       inline WeakRef<T> SharedObject::asWeak(T *obj)
+       {
+               return (obj ? asWeak(*obj) : WeakRef<T>());
+       }
+
+       template <class T>
+       inline SharedRef<T> SharedObject::asShared(T &obj)
+       {
+               return obj.asShared<typename std::remove_cv<T>::type>();
+       }
+
+       template <class T>
+       inline WeakRef<T> SharedObject::asWeak(T &obj)
+       {
+               return obj.asWeak<typename std::remove_cv<T>::type>();
+       }
+
        template <class T>
        inline SharedRef<T> SharedObject::asShared()
        {
@@ -82,16 +106,24 @@ namespace ucl {
        template <class T>
        inline SharedRef<T> asShared(T *obj)
        {
-               return (obj ?
-                               obj->asShared<typename std::remove_cv<T>::type>() :
-                               SharedRef<T>());
+               return SharedObject::asShared(obj);
        }
 
        template <class T>
        inline WeakRef<T> asWeak(T *obj)
        {
-               return (obj ?
-                               obj->asWeak<typename std::remove_cv<T>::type>() :
-                               WeakRef<T>());
+               return SharedObject::asWeak(obj);
+       }
+
+       template <class T>
+       inline SharedRef<T> asShared(T &obj)
+       {
+               return SharedObject::asShared(obj);
+       }
+
+       template <class T>
+       inline WeakRef<T> asWeak(T &obj)
+       {
+               return SharedObject::asWeak(obj);
        }
 }
index b91c1d205d466763ff2f527f5028dec7dcd529f8..f9f4210a601b14f99968d285eb8eea9a246cc222 100644 (file)
@@ -34,7 +34,7 @@ namespace ucl {
                }
        }
 
-       void EdjeWidget::setPartText(const EdjePart part, const TString &value)
+       void EdjeWidget::setText(const EdjePart part, const TString &value)
        {
                if (value.isTranslatable()) {
                        if (value.hasDomain()) {
index 895816fc394ad3d83c02416fa21abff45c9b42f4..472b1ebe1e934d7848dc4234fb466596e641451c 100644 (file)
@@ -123,9 +123,9 @@ namespace ucl {
                UCL_ASSERT(m_eo, "m_eo is NULL!");
 
                if (m_rc) {
-                       evas_object_event_callback_priority_add(m_eo, EVAS_CALLBACK_FREE,
+                       evas_object_event_callback_priority_add(m_eo, EVAS_CALLBACK_DEL,
                                        EO_CALLBACK_PRIORITY_AFTER,
-                                       CALLBACK_A(Widget::onEoFree), this);
+                                       CALLBACK_A(Widget::onEoDel), this);
                }
 
                updateRefs();
@@ -140,8 +140,8 @@ namespace ucl {
                }
 
                if (m_rc) {
-                       evas_object_event_callback_del_full(m_eo, EVAS_CALLBACK_FREE,
-                                       CALLBACK_A(Widget::onEoFree), this);
+                       evas_object_event_callback_del_full(m_eo, EVAS_CALLBACK_DEL,
+                                       CALLBACK_A(Widget::onEoDel), this);
                }
 
                if (m_isOwner) {
@@ -228,7 +228,7 @@ namespace ucl {
                }
        }
 
-       void Widget::onEoFree(Evas *e, Evas_Object *obj, void *event_info)
+       void Widget::onEoDel(Evas *e, Evas_Object *obj, void *event_info)
        {
                if (!m_isSelfRefKept) {
                        FLOG("UNEXPECTED! m_isSelfRefKept: %d;", m_isSelfRefKept);
index aaf9992a84a3f624754ff9d4fdd0ea87e73f0426..8cf5bc1979930fd3e4483035c430b4c00882cda4 100644 (file)
@@ -33,7 +33,7 @@ namespace ucl {
                }
        }
 
-       void WidgetItem::setPartText(
+       void WidgetItem::setText(
                        const EdjePart part, const TString &value) const
        {
                if (value.isTranslatable()) {