TizenRefApp-8606 [Gallery] Implement ImageGrid autoscrolling in ScreenReader mode 24/132224/1
authorIgor Nazarov <i.nazarov@samsung.com>
Thu, 1 Jun 2017 15:07:34 +0000 (18:07 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Thu, 1 Jun 2017 15:07:34 +0000 (18:07 +0300)
Change-Id: I0cbad3fe97ed0bbdc76753f2c1aaaf0d8342a73f

inc/view/ImageGrid.h
src/view/ImageGrid.cpp

index af1a65bebf3a3c1df1381e3a061a816ab23bdc44..399201b15e0ae7304e994c8e87978e2dd7a3a087 100644 (file)
@@ -135,6 +135,7 @@ namespace gallery {
                void removeUnrealizeLock();
 
                void handleItemEvent(int itemIndex, int event, int x, int y) const;
+               Elm_Interface_Atspi_Accessible *requestAtspi(int itemIndex);
                Elm_Interface_Atspi_Accessible *getItemAtspi(int itemIndex);
 
                // Selection mode hanling
index 29cabf96492d4be501933d9bf8e7cfd16bf838e6..6c8e14cf2ba7def927660f3e48971c577c77d307 100644 (file)
@@ -140,8 +140,7 @@ namespace gallery {
 
                virtual int calcMaxSlotCount(const int itemCount) const = 0;
 
-               virtual int calcExtraPaddingSize(const int slotSize,
-                               const int itemCount) const
+               virtual int calcExtraPaddingSize(const int slotSize) const
                {
                        return 0;
                }
@@ -187,8 +186,8 @@ namespace gallery {
                        return ((itemCount + (totalLength - 1)) / totalLength * 2);
                }
 
-               virtual int calcExtraPaddingSize(const int slotSize,
-                               const int itemCount) const final override
+               virtual int calcExtraPaddingSize(
+                               const int slotSize) const final override
                {
                        return slotSize;
                }
@@ -538,7 +537,7 @@ namespace gallery {
                                                        (m_realizeIndex + 1) :
                                                        (m_realizeIndex - 1));
 
-                               auto relationObject = m_imageGrid.getItemAtspi(relationIndex);
+                               auto relationObject = m_imageGrid.requestAtspi(relationIndex);
                                if (!relationObject) {
                                        relationObject = m_btn.getEo();
                                }
@@ -1054,9 +1053,7 @@ namespace gallery {
        Elm_Interface_Atspi_Accessible *ImageGrid::getAccessObject(
                        const bool isFlowsTo)
        {
-               const int itemIndex = (isFlowsTo ? 0 : (m_itemCount - 1));
-               scrollToItem(itemIndex);
-               return getItemAtspi(itemIndex);
+               return getItemAtspi(isFlowsTo ? 0 : (m_itemCount - 1));
        }
 
        template <class FUNC>
@@ -1120,12 +1117,25 @@ namespace gallery {
                return doWithCell(itemIndex,
                        [this, &showFunc](const int slotIndex, const int itemOffset)
                        {
-                               const int scrollOffset = ((slotIndex / 2) * m_slotSize);
+                               const int extraPadding = ((slotIndex & 1) ?
+                                               m_info.calcExtraPaddingSize(m_slotSize) : 0);
+
+                               const int maxOffest = ((slotIndex / 2) * m_slotSize);
+                               const int minOffset = (maxOffest + extraPadding -
+                                               ((m_scrollerSize / m_slotSize) - 1) * m_slotSize);
+                               if ((m_scrollOffset >= minOffset) &&
+                                               (m_scrollOffset <= maxOffest)) {
+                                       return RES_OK;
+                               }
+
+                               const int scrollOffset = ((m_scrollOffset > maxOffest) ?
+                                               maxOffest : minOffset);
                                if (m_info.isHorizontal) {
                                        showFunc(*m_scroller, scrollOffset, 0, m_scrollerSize, 1);
                                } else {
                                        showFunc(*m_scroller, 0, scrollOffset, 1, m_scrollerSize);
                                }
+
                                return RES_OK;
                        });
        }
@@ -1186,7 +1196,7 @@ namespace gallery {
                }
        }
 
-       Elm_Interface_Atspi_Accessible *ImageGrid::getItemAtspi(const int itemIndex)
+       Elm_Interface_Atspi_Accessible *ImageGrid::requestAtspi(const int itemIndex)
        {
                if ((itemIndex < 0) || (itemIndex >= m_itemCount)) {
                        if (m_listener) {
@@ -1195,6 +1205,14 @@ namespace gallery {
                        }
                        return nullptr;
                }
+               return getItemAtspi(itemIndex);
+       }
+
+       Elm_Interface_Atspi_Accessible *ImageGrid::getItemAtspi(
+                       const int itemIndex)
+       {
+               FAIL_RETURN_VALUE(scrollToItem(itemIndex), nullptr,
+                               "scrollToItem() failed!");
 
                Elm_Interface_Atspi_Accessible *result = nullptr;
 
@@ -1391,7 +1409,7 @@ namespace gallery {
 
                m_padSize1 = std::lround(spaceSize / 2.0);
                m_padSize2 = (spaceSize - m_padSize1 +
-                               m_info.calcExtraPaddingSize(m_slotSize, m_itemCount));
+                               m_info.calcExtraPaddingSize(m_slotSize));
        }
 
        void ImageGrid::updateScrollBias()