TizenRefApp-8264 [Gallery] Implement ImageGrid Type::LINEAR 32/121732/1
authorIgor Nazarov <i.nazarov@samsung.com>
Tue, 28 Mar 2017 14:22:50 +0000 (17:22 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Tue, 28 Mar 2017 14:22:50 +0000 (17:22 +0300)
- Implemented ImageGrid::Type::LINEAR type.

Change-Id: Iac06091ef90c58041c8cb3eb8cea04c82032baa6

edc/image-grid.edc
edc/images/gallery_circle_basic.png [new file with mode: 0644]
inc/presentation/ImageGrid.h
src/presentation/ImageGrid.cpp

index a15e3b29802fa6a29cf96a94781a50c9ad5432b0..d96dc2144ad90ece8454b3677e15b1422265264e 100644 (file)
@@ -16,6 +16,7 @@
 
 images {
    image: "gallery_thumbnail_circle_04.png" COMP;
+   image: "gallery_circle_basic.png" COMP;
 }
 group { "elm/layout/gallery_image_grid/hcomb_3x3_even";
    parts {
@@ -59,8 +60,6 @@ group { "elm/layout/gallery_image_grid/hcomb_3x3_even";
             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;
          }
       }
    }
@@ -133,8 +132,6 @@ group { "elm/layout/gallery_image_grid/hcomb_3x3_odd";
             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";
@@ -143,8 +140,36 @@ group { "elm/layout/gallery_image_grid/hcomb_3x3_odd";
             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;
+         }
+      }
+   }
+}
+group { "elm/layout/gallery_image_grid/linear";
+   parts {
+      image { "image_mask_0";
+         scale: 1;
+         desc { "default";
+            image.normal: "gallery_circle_basic.png";
+            fixed: 0 1;
+            min: 360 360;
+            max: 360 360;
+         }
+      }
+      swallow { "swallow.cell_0";
+         desc { "default";
+            fixed: 1 1;
+            clip_to: "image_mask_0";
+            rel1.to: "image_mask_0";
+            rel2.to: "image_mask_0";
+         }
+      }
+      rect { "blocker";
+         norepeat;
+         desc { "default";
+            fixed: 1 1;
+            color: 0 0 0 0;
+            rel1.to: "image_mask_0";
+            rel2.to: "image_mask_0";
          }
       }
    }
diff --git a/edc/images/gallery_circle_basic.png b/edc/images/gallery_circle_basic.png
new file mode 100644 (file)
index 0000000..fc3aea5
Binary files /dev/null and b/edc/images/gallery_circle_basic.png differ
index 11f84578293865e905c0c4e41e43a598ece5f6bb..1e0ebfc9268b52b7f971166083badaebe0b44673 100644 (file)
@@ -28,7 +28,8 @@ namespace gallery {
        class ImageGrid : public ucl::Widget {
        public:
                enum class Type {
-                       HCOMB_3X3
+                       HCOMB_3X3,
+                       LINEAR
                };
 
                class Builder {
@@ -74,6 +75,7 @@ namespace gallery {
 
                struct Info;
                struct HcombInfo;
+               struct LinearInfo;
 
        private:
                friend class ucl::RefCountObj<ImageGrid>;
index 18b7c0ca65f0ab5945fdc727c82fef09116a56aa..71eac40d43095bfa63c04a6ae0acd9b1026dc862 100644 (file)
@@ -89,8 +89,15 @@ namespace gallery {
                                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;
 
+               virtual int calcExtraPaddingSize(const int slotSize,
+                               const int itemCount) const
+               {
+                       return 0;
+               }
+
                Info(const std::array<LayoutTheme, 2> &slotThemes,
                                const std::array<int, 2> &slotLens,
                                const int scrollLimit, const bool isHorizontal) :
@@ -128,6 +135,12 @@ namespace gallery {
                        return ((itemCount + (totalLength - 1)) / totalLength * 2);
                }
 
+               virtual int calcExtraPaddingSize(const int slotSize,
+                               const int itemCount) const final override
+               {
+                       return slotSize;
+               }
+
                HcombInfo(const int totalLength,
                                const std::array<LayoutTheme, 2> &slotThemes) :
                        Info(slotThemes, {{(totalLength / 2), ceilDiv<2>(totalLength)}},
@@ -137,6 +150,33 @@ namespace gallery {
                }
        };
 
+       // ImageGrid::LinearInfo //
+
+       struct ImageGrid::LinearInfo : Info {
+               virtual int calcItemIndexFromCell(
+                               const int slotIndex, const int itemOffset) const final override
+               {
+                       return (slotIndex / 2);
+               }
+
+               virtual void calcCellFromItemIndex(const int itemIndex,
+                               int &slotIndex, int &itemOffset) const final override
+               {
+                       slotIndex = (itemIndex * 2);
+                       itemOffset = 0;
+               }
+
+               virtual int calcMaxSlotCount(const int itemCount) const final override
+               {
+                       return (itemCount * 2);
+               }
+
+               LinearInfo(const LayoutTheme &slotTheme, const bool isHorizontal) :
+                       Info({{slotTheme}}, {{1, 0}}, 1, isHorizontal)
+               {
+               }
+       };
+
        // ImageGrid::Slot //
 
        class ImageGrid::Slot {
@@ -260,7 +300,8 @@ namespace gallery {
                        m_layout(elm_layout_add(imageGrid.m_box), true),
                        m_isRealized(false)
                {
-                       if (!m_layout.setTheme(m_info.slotThemes[isOdd])) {
+                       if (isValid(m_info.slotThemes[isOdd]) &&
+                                       !m_layout.setTheme(m_info.slotThemes[isOdd])) {
                                ELOG("setTheme() failed!");
                        }
                        fill(m_layout);
@@ -402,13 +443,18 @@ namespace gallery {
        const ImageGrid::Info &ImageGrid::getInfo(const Type type)
        {
                switch (type) {
-               case Type::HCOMB_3X3:
-               default: {
+               case Type::HCOMB_3X3: {
                                static HcombInfo info{3, {{
                                                {"layout", "gallery_image_grid", "hcomb_3x3_even"},
                                                {"layout", "gallery_image_grid", "hcomb_3x3_odd"}}}};
                                return info;
                        }
+               case Type::LINEAR:
+               default: {
+                               static LinearInfo info{
+                                               {"layout", "gallery_image_grid", "linear"}, true};
+                               return info;
+                       }
                }
        }
 
@@ -761,10 +807,11 @@ namespace gallery {
        void ImageGrid::updatePadSizes()
        {
                const int spaceSize = (m_scrollerSize -
-                               ((m_scrollerSize / m_slotSize) * m_slotSize));
+                               (std::max((m_scrollerSize / m_slotSize), 1) * m_slotSize));
 
                m_padSize1 = (spaceSize / 2);
-               m_padSize2 = (spaceSize - m_padSize1 + m_slotSize);
+               m_padSize2 = (spaceSize - m_padSize1 +
+                               m_info.calcExtraPaddingSize(m_slotSize, m_itemCount));
        }
 
        void ImageGrid::updateScrollBias()