TizenRefApp-8278 [Gallery] Implement End effect 73/122473/2
authorIgor Nazarov <i.nazarov@samsung.com>
Fri, 31 Mar 2017 12:42:16 +0000 (15:42 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Fri, 31 Mar 2017 12:49:23 +0000 (15:49 +0300)
- Enabled bounce effect fro scroller;
- Changed scroller page scroll limit and page size.

Change-Id: Iaebbe07e102fa30f7eebe2b1f5130931eea38582

src/presentation/ImageGrid.cpp

index 09b4cf7d625e150e096c0258336aae16e50ffaee..5ce3ab65ef5fd30c9bba20e48c6c1ef8ec808806 100644 (file)
@@ -32,10 +32,16 @@ namespace gallery { namespace { namespace impl {
        // Related to ImageGrid //
        const TString SLOT_PART_FMT {"swallow.cell_%d"};
 
+       // Related to Scroller //
+       constexpr ElmStyle SCROLLER_STYLE {"effect"};
+
        // Related to Button //
        constexpr ElmStyle ITEM_BTN_STYLE {"gallery_image"};
        constexpr EdjePart PART_BTN_BG {"swallow.bg"};
        constexpr SmartEvent BTN_CLICKED {"clicked"};
+
+       // Other //
+       constexpr auto HCOMB_SCROLL_LIMIT = 1000;
 }}}
 
 namespace gallery {
@@ -85,6 +91,7 @@ namespace gallery {
                const std::array<LayoutTheme, 2> slotThemes;
                const std::array<int, 2> slotLens;
                const int scrollLimit;
+               const int slotsPerPage;
                const bool isHorizontal;
 
                virtual int calcItemIndexFromCell(
@@ -102,10 +109,12 @@ namespace gallery {
 
                Info(const std::array<LayoutTheme, 2> &slotThemes,
                                const std::array<int, 2> &slotLens,
-                               const int scrollLimit, const bool isHorizontal) :
+                               const int scrollLimit, const int slotsPerPage,
+                               const bool isHorizontal) :
                        slotThemes(slotThemes),
                        slotLens(slotLens),
                        scrollLimit(scrollLimit),
+                       slotsPerPage(slotsPerPage),
                        isHorizontal(isHorizontal)
                {
                }
@@ -146,7 +155,7 @@ namespace gallery {
                HcombInfo(const int totalLength,
                                const std::array<LayoutTheme, 2> &slotThemes) :
                        Info(slotThemes, {{(totalLength / 2), ceilDiv<2>(totalLength)}},
-                               (totalLength - 1), true),
+                               impl::HCOMB_SCROLL_LIMIT, (totalLength - 1), true),
                        totalLength(totalLength)
                {
                }
@@ -174,7 +183,7 @@ namespace gallery {
                }
 
                LinearInfo(const LayoutTheme &slotTheme, const bool isHorizontal) :
-                       Info({{slotTheme}}, {{1, 0}}, 1, isHorizontal)
+                       Info({{slotTheme}}, {{1, 0}}, 1, 1, isHorizontal)
                {
                }
        };
@@ -522,13 +531,16 @@ namespace gallery {
                elm_box_horizontal_set(m_box, toEina(m_info.isHorizontal));
                show(m_box);
 
+               m_scroller->setStyle(impl::SCROLLER_STYLE);
                expandAndFill(*m_scroller);
                if (m_info.isHorizontal) {
                        elm_scroller_page_scroll_limit_set(
                                        *m_scroller, m_info.scrollLimit, 0);
+                       elm_scroller_bounce_set(*m_scroller, EINA_TRUE, EINA_FALSE);
                } else {
                        elm_scroller_page_scroll_limit_set(
                                        *m_scroller, 0, m_info.scrollLimit);
+                       elm_scroller_bounce_set(*m_scroller, EINA_FALSE, EINA_TRUE);
                }
                show(*m_scroller);
 
@@ -732,10 +744,11 @@ namespace gallery {
                        if (m_slotSize == 0) {
                                UCL_ASSERT(!isOdd, "Must be even!");
                                m_slotSize = std::max(slot->calcSize(), 1);
+                               const int pageSize = (m_slotSize * m_info.slotsPerPage);
                                if (m_info.isHorizontal) {
-                                       elm_scroller_page_size_set(*m_scroller, m_slotSize, 0);
+                                       elm_scroller_page_size_set(*m_scroller, pageSize, 0);
                                } else {
-                                       elm_scroller_page_size_set(*m_scroller, 0, m_slotSize);
+                                       elm_scroller_page_size_set(*m_scroller, 0, pageSize);
                                }
                        }