TizenRefApp-8639 [Gallery] Extend Widget functionality with gesture events 94/132794/1
authorIgor Nazarov <i.nazarov@samsung.com>
Wed, 7 Jun 2017 13:40:20 +0000 (16:40 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Wed, 7 Jun 2017 13:40:46 +0000 (16:40 +0300)
Change-Id: I28ce179a91dad4a1dcbd037c550d249c554bd32e

ucl/inc/ucl/gui/ElmWidget.h
ucl/inc/ucl/gui/ElmWidget.hpp
ucl/inc/ucl/gui/Widget.h
ucl/inc/ucl/gui/types.h
ucl/src/gui/ElmWidget.cpp
ucl/src/gui/Widget.cpp

index 9c03011a06bfa723b8b636d240000bbdfff07115..96d5cf26d750b50ef51ad6d93771d354b29a3cff 100644 (file)
 
 #include "Widget.h"
 
+#define UCL_SMART_FWD_ATSPI UCL_SMART_FWD "atspi,"
+
 namespace ucl {
 
+       constexpr SmartEvent ATSPI_ON_GESTURE {UCL_SMART_FWD_ATSPI "gesture"};
+
        class Window;
 
        UCL_DECLARE_REF_ALIASES(ElmWidget);
 
        class ElmWidget : public Widget {
        public:
-               friend class RefCountObj<ElmWidget>;
-               using Widget::Widget;
+               explicit ElmWidget(Evas_Object *eo, bool isOwner = false);
+               virtual ~ElmWidget();
 
                void setEnabled(bool value);
                bool isEnabled() const;
@@ -43,8 +47,19 @@ namespace ucl {
                Window *getWindow() const;
 
        protected:
+               friend class RefCountObj<ElmWidget>;
+               ElmWidget(RefCountObjBase *rc, Evas_Object *eo, bool isOwner = false);
+
                virtual void setFocusedImpl(bool value) final override;
                virtual bool isFocusedImpl() const final override;
+               virtual bool ensureFwdEvent(SmartEvent fwdEvent) override;
+
+       private:
+               Eina_Bool onAtspiGesture(Elm_Atspi_Gesture_Info gestureInfo,
+                                       Evas_Object *obj);
+
+       private:
+               bool m_isAtspiGestureCbSet;
        };
 
        // Non-member functions //
index 8d0e1abb4161d06f554926dcaa762e937045a4b1..0673a57276897104ddba6f84d4efda17f0bfa18d 100644 (file)
 
 namespace ucl {
 
+       inline ElmWidget::ElmWidget(Evas_Object *const eo, const bool isOwner) :
+               ElmWidget(nullptr, eo, isOwner)
+       {
+       }
+
        inline void ElmWidget::setEnabled(const bool value)
        {
                elm_object_disabled_set(getEo(), toEina(!value));
index 9f74259e2820fdddc7800dc5236d68b20da1cd04..8dfcd26fef9ee4b62c1173ec8c671033aa4331e9 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "ucl/misc/RefCountAware.h"
 
+#define UCL_SMART_FWD "ucl,fwd,"
+
 namespace ucl {
 
        UCL_DECLARE_REF_ALIASES(Widget);
@@ -100,6 +102,7 @@ namespace ucl {
 
                virtual void setFocusedImpl(bool value);
                virtual bool isFocusedImpl() const;
+               virtual bool ensureFwdEvent(SmartEvent fwdEvent);
 
        private:
                class EventProxy;
@@ -129,11 +132,11 @@ namespace ucl {
        private:
                Evas_Object *m_eo;
                EventProxies m_eventProxies;
-               bool m_isOwner;
-               bool m_isBoundToEo;
-               bool m_isEoRefKept;
-               bool m_isSelfRefKept;
-               bool m_isSelfRefUnique;
+               bool m_isOwner: 1;
+               bool m_isBoundToEo: 1;
+               bool m_isEoRefKept: 1;
+               bool m_isSelfRefKept: 1;
+               bool m_isSelfRefUnique: 1;
        };
 
        // Non-member functions //
index 3ed1afa2c38386efb14d91cb8946c94905cc066d..2a8dac56fafb785b551ffd1389a80ec3fb8b8c17 100644 (file)
@@ -87,6 +87,13 @@ namespace ucl {
                IMAGE_PRELOADED = EVAS_CALLBACK_IMAGE_PRELOADED
        };
 
+       // AtspiGestureEventInfo //
+
+       struct AtspiGestureEventInfo {
+               Elm_Atspi_Gesture_Info gestureInfo;
+               bool preventDefault;
+       };
+
        // WidgetARHint //
 
        enum class WidgetARHint
index cf99eb7c7f835b5ac30d248668ca62b856134ce5..ef8259321277d82a555b1585fb999ce5679f12ad 100644 (file)
 
 namespace ucl {
 
+       ElmWidget::ElmWidget(RefCountObjBase *rc, Evas_Object *eo, bool isOwner) :
+               Widget(rc, eo, isOwner),
+               m_isAtspiGestureCbSet(false)
+       {
+       }
+
+       ElmWidget::~ElmWidget()
+       {
+               if (m_isAtspiGestureCbSet) {
+                       elm_atspi_accessible_gesture_cb_set(getEo(), nullptr, nullptr);
+               }
+       }
+
        void ElmWidget::setFocusedImpl(const bool value)
        {
                elm_object_focus_set(getEo(), toEina(value));
@@ -31,6 +44,30 @@ namespace ucl {
                return elm_object_focus_get(getEo());
        }
 
+       bool ElmWidget::ensureFwdEvent(const SmartEvent fwdEvent)
+       {
+               if (Widget::ensureFwdEvent(fwdEvent)) {
+                       return true;
+               }
+               if (fwdEvent == ATSPI_ON_GESTURE) {
+                       if (!m_isAtspiGestureCbSet) {
+                               m_isAtspiGestureCbSet = true;
+                               elm_atspi_accessible_gesture_cb_set(getEo(),
+                                               CALLBACK_A(ElmWidget::onAtspiGesture), this);
+                       }
+                       return true;
+               }
+               return false;
+       }
+
+       Eina_Bool ElmWidget::onAtspiGesture(Elm_Atspi_Gesture_Info gestureInfo,
+                                       Evas_Object *obj)
+       {
+               AtspiGestureEventInfo eventInfo{gestureInfo, false};
+               callEvent(ATSPI_ON_GESTURE, &eventInfo);
+               return toEina(eventInfo.preventDefault);
+       }
+
        Window *ElmWidget::getWindow() const
        {
                return dynamicCast<Window>(getTopWidget());
index 5129f18be13d71212d6a650504103512f7406c4e..0d546f4d6f05360fa21bf30bf77b546e6e72ed00 100644 (file)
@@ -267,6 +267,12 @@ namespace ucl {
        void Widget::addEventHandler(const SmartEvent event,
                        const WidgetEventHandler handler)
        {
+               if (strncmp(event.name, UCL_SMART_FWD, strlen(UCL_SMART_FWD)) == 0) {
+                       if (!ensureFwdEvent(event)) {
+                               LOG_RETURN_VOID(RES_NOT_SUPPORTED,
+                                               "Event is not supported: %s;", event.name);
+                       }
+               }
                m_eventProxies.emplace_front(*this, event, handler);
                m_eventProxies.front().setSelfIt(m_eventProxies.begin());
        }
@@ -294,4 +300,9 @@ namespace ucl {
        {
                return evas_object_focus_get(getEo());
        }
+
+       bool Widget::ensureFwdEvent(const SmartEvent fwdEvent)
+       {
+               return false;
+       }
 }