#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;
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 //
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));
#include "ucl/misc/RefCountAware.h"
+#define UCL_SMART_FWD "ucl,fwd,"
+
namespace ucl {
UCL_DECLARE_REF_ALIASES(Widget);
virtual void setFocusedImpl(bool value);
virtual bool isFocusedImpl() const;
+ virtual bool ensureFwdEvent(SmartEvent fwdEvent);
private:
class EventProxy;
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 //
IMAGE_PRELOADED = EVAS_CALLBACK_IMAGE_PRELOADED
};
+ // AtspiGestureEventInfo //
+
+ struct AtspiGestureEventInfo {
+ Elm_Atspi_Gesture_Info gestureInfo;
+ bool preventDefault;
+ };
+
// WidgetARHint //
enum class WidgetARHint
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));
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());
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());
}
{
return evas_object_focus_get(getEo());
}
+
+ bool Widget::ensureFwdEvent(const SmartEvent fwdEvent)
+ {
+ return false;
+ }
}