diff options
author | Igor Nazarov <i.nazarov@samsung.com> | 2017-10-23 14:06:24 +0300 |
---|---|---|
committer | Igor Nazarov <i.nazarov@samsung.com> | 2017-10-23 14:10:16 +0300 |
commit | b5cd516dea99f322542ff3c49c4ebb25aa0358e9 (patch) | |
tree | 7a94f38d023b6e7db3509d1ffe708d21e4001014 | |
parent | 1ee0b6d64e08d9ae28c9ea3cefc956f01d49f389 (diff) | |
download | call-setting-b5cd516dea99f322542ff3c49c4ebb25aa0358e9.tar.gz call-setting-b5cd516dea99f322542ff3c49c4ebb25aa0358e9.tar.bz2 call-setting-b5cd516dea99f322542ff3c49c4ebb25aa0358e9.zip |
TizenRefApp-9663 [Call Setting] Implement as_eo() and as_ao() functions
in ucl
Change-Id: Ib29aab2b8567ebb84b355bdc40e588677d77f423
-rw-r--r-- | call-setting/presenters/misc/SelectModePresenter.cpp | 4 | ||||
-rw-r--r-- | ucl/include/ucl/gui/Atspi.h | 51 | ||||
-rw-r--r-- | ucl/include/ucl/gui/Atspi.hpp | 8 | ||||
-rw-r--r-- | ucl/include/ucl/gui/ElmWidget.h | 14 | ||||
-rw-r--r-- | ucl/include/ucl/gui/ElmWidget.hpp | 10 | ||||
-rw-r--r-- | ucl/include/ucl/gui/Widget.h | 66 | ||||
-rw-r--r-- | ucl/include/ucl/gui/Widget.hpp | 20 | ||||
-rw-r--r-- | ucl/source/gui/Widget.cpp | 8 | ||||
-rw-r--r-- | ucl/source/mvp/ListItemPresenter.cpp | 7 | ||||
-rw-r--r-- | ucl/source/mvp/ListPresenter.cpp | 2 |
10 files changed, 111 insertions, 79 deletions
diff --git a/call-setting/presenters/misc/SelectModePresenter.cpp b/call-setting/presenters/misc/SelectModePresenter.cpp index 00320a1..10d0835 100644 --- a/call-setting/presenters/misc/SelectModePresenter.cpp +++ b/call-setting/presenters/misc/SelectModePresenter.cpp @@ -349,7 +349,7 @@ namespace call_setting { void SelectModePresenter::onSelectAll( Evas_Object *obj, void *eventInfo) { - if (m_popup && (m_popup->getEo() == obj)) { + if (as_eo(m_popup) == obj) { dismissPopup(); dispatchEvent(Event::SELECT_ALL); } @@ -358,7 +358,7 @@ namespace call_setting { void SelectModePresenter::onDeselectAll( Evas_Object *obj, void *eventInfo) { - if (m_popup && (m_popup->getEo() == obj)) { + if (as_eo(m_popup) == obj) { dismissPopup(); dispatchEvent(Event::DESELECT_ALL); } diff --git a/ucl/include/ucl/gui/Atspi.h b/ucl/include/ucl/gui/Atspi.h index 2657806..252a990 100644 --- a/ucl/include/ucl/gui/Atspi.h +++ b/ucl/include/ucl/gui/Atspi.h @@ -31,28 +31,31 @@ namespace ucl { class Atspi final : private NonCopyable { public: /** - * @brief Constructor - * @param[in] eo Underlying Access object of the Atspi + * @brief Gets the underlying Access object + * @param[in] atspi Reference to target atspi + * @return Pointer to the underlying Access object */ - explicit Atspi(Elm_Interface_Atspi_Accessible *ao); + friend Elm_Interface_Atspi_Accessible *as_ao(Atspi &atspi); /** - * @brief Destructor - * @details Unregisters all Access object callbacks + * @brief Gets the underlying constant Access object + * @param[in] atspi Constant reference to target atspi + * @return Pointer to the underlying constant Access object */ - ~Atspi(); + friend const Elm_Interface_Atspi_Accessible *as_ao(const Atspi &atspi); + public: /** - * @brief Gets Access object pointer - * @return Pointer to the Access object + * @brief Constructor + * @param[in] eo Underlying Access object of the Atspi */ - Elm_Interface_Atspi_Accessible *getAo(); + explicit Atspi(Elm_Interface_Atspi_Accessible *ao); /** - * @brief Gets pointer to constant Access object - * @return Pointer to the constant Access object + * @brief Destructor + * @details Unregisters all Access object callbacks */ - const Elm_Interface_Atspi_Accessible *getAo() const; + ~Atspi(); /** * @brief Implicitly casts to the underlying Access object @@ -196,6 +199,9 @@ namespace ucl { void delGestureHandler(const AtspiGestureHandler &handler); private: + Elm_Interface_Atspi_Accessible *getAo(); + const Elm_Interface_Atspi_Accessible *getAo() const; + void registerGestureCb(); void registerNameCb(); void registerDescriptionCb(); @@ -225,20 +231,15 @@ namespace ucl { // Non-member functions // /** - * @brief Compares equals underlying Access objects of target objects - * @param[in] lhs Left hand side operand - * @param[in] rhs Right hand side operand - * @return true - if equal, false - not equal - */ - bool operator==(const Atspi &lhs, const Atspi &rhs); - - /** - * @brief Compares unequals underlying Access objects of target objects - * @param[in] lhs Left hand side operand - * @param[in] rhs Right hand side operand - * @return true - if not equal, false - equal + * @brief Gets Access object from pointed object + * @param[in] ptr Target object pointer + * @return Pointer to Access object or NULL */ - bool operator!=(const Atspi &lhs, const Atspi &rhs); + template <class T> + inline auto as_ao(const T &ptr) -> decltype(as_ao(*ptr)) + { + return (ptr ? as_ao(*ptr) : nullptr); + } } #include "Atspi.hpp" diff --git a/ucl/include/ucl/gui/Atspi.hpp b/ucl/include/ucl/gui/Atspi.hpp index fcf1004..3d535fa 100644 --- a/ucl/include/ucl/gui/Atspi.hpp +++ b/ucl/include/ucl/gui/Atspi.hpp @@ -240,13 +240,13 @@ namespace ucl { // Non-member functions // - inline bool operator==(const Atspi &lhs, const Atspi &rhs) + inline Elm_Interface_Atspi_Accessible *as_ao(Atspi &atspi) { - return (lhs.getAo() == rhs.getAo()); + return atspi.m_ao; } - inline bool operator!=(const Atspi &lhs, const Atspi &rhs) + inline const Elm_Interface_Atspi_Accessible *as_ao(const Atspi &atspi) { - return (lhs.getAo() != rhs.getAo()); + return atspi.m_ao; } } diff --git a/ucl/include/ucl/gui/ElmWidget.h b/ucl/include/ucl/gui/ElmWidget.h index 4c4b547..a0e2d60 100644 --- a/ucl/include/ucl/gui/ElmWidget.h +++ b/ucl/include/ucl/gui/ElmWidget.h @@ -115,6 +115,20 @@ namespace ucl { // Non-member functions // /** + * @brief Gets corresponding Access object + * @param[in] widget Reference to target widget + * @return Pointer to the corresponding Access object + */ + Elm_Interface_Atspi_Accessible *as_ao(ElmWidget &widget); + + /** + * @brief Gets corresponding constant Access object + * @param[in] widget Constant reference to target widget + * @return Pointer to the corresponding constant Access object + */ + const Elm_Interface_Atspi_Accessible *as_ao(const ElmWidget &widget); + + /** * @brief Sets widget to enabled state * @details This is equivalent to: widget.setEnabled(true); * @param[in] widget Reference to target widget diff --git a/ucl/include/ucl/gui/ElmWidget.hpp b/ucl/include/ucl/gui/ElmWidget.hpp index 2151cfd..6fe586d 100644 --- a/ucl/include/ucl/gui/ElmWidget.hpp +++ b/ucl/include/ucl/gui/ElmWidget.hpp @@ -73,6 +73,16 @@ namespace ucl { // Non-member functions // + inline Elm_Interface_Atspi_Accessible *as_ao(ElmWidget &widget) + { + return as_ao(widget.getAtspi()); + } + + inline const Elm_Interface_Atspi_Accessible *as_ao(const ElmWidget &widget) + { + return as_ao(widget.getAtspi()); + } + inline void enable(ElmWidget &widget) { widget.setEnabled(true); diff --git a/ucl/include/ucl/gui/Widget.h b/ucl/include/ucl/gui/Widget.h index 0232e36..f2f9620 100644 --- a/ucl/include/ucl/gui/Widget.h +++ b/ucl/include/ucl/gui/Widget.h @@ -47,6 +47,21 @@ namespace ucl { public: /** + * @brief Gets the underlying Evas object + * @param[in] widget Reference to target widget + * @return Pointer to the underlying Evas object + */ + friend Evas_Object *as_eo(Widget &widget); + + /** + * @brief Gets the underlying constant Evas object + * @param[in] widget Constant reference to target widget + * @return Pointer to the underlying constant Evas object + */ + friend const Evas_Object *as_eo(const Widget &widget); + + public: + /** * @brief Constructor * @param[in] eo Underlying Evas object of the widget * @param[in] isOwner Evas object ownership flag (optional: true) @@ -107,18 +122,6 @@ namespace ucl { void setIsOwner(bool value); /** - * @brief Gets the underlying Evas object - * @return Pointer to the underlying Evas object - */ - Evas_Object *getEo(); - - /** - * @brief Gets the underlying Evas object (constant version) - * @return Pointer to the constant underlying Evas object - */ - const Evas_Object *getEo() const; - - /** * @brief Implicitly casts to the underlying Evas object * @return Pointer to the underlying Evas object */ @@ -368,6 +371,18 @@ namespace ucl { protected: /** + * @brief Gets the underlying Evas object + * @return Pointer to the underlying Evas object + */ + Evas_Object *getEo(); + + /** + * @brief Gets the underlying Evas object (constant version) + * @return Pointer to the constant underlying Evas object + */ + const Evas_Object *getEo() const; + + /** * @brief Actually sets key-input focus state to the widget * @details May be overriden in subclasses to change behaviour * @param[in] value New state. true - to set focus, false - to unset @@ -433,6 +448,17 @@ namespace ucl { // Non-member functions // /** + * @brief Gets Evas object from pointed object + * @param[in] ptr Target object pointer + * @return Pointer to Evas object or NULL + */ + template <class T> + inline auto as_eo(const T &ptr) -> decltype(as_eo(*ptr)) + { + return (ptr ? as_eo(*ptr) : nullptr); + } + + /** * @brief Gets position of the widget * @param[in] widget Reference to target widget * @param[out] x Top-left X coordinate of the widget (may be NULL) @@ -512,22 +538,6 @@ namespace ucl { * @param[in] widget Reference to target widget */ void expandAndFill(Widget &widget); - - /** - * @brief Compares equals underlying Evas objects of target widgets - * @param[in] lhs Left hand side operand - * @param[in] rhs Right hand side operand - * @return true - if equal, false - not equal - */ - bool operator==(const Widget &lhs, const Widget &rhs); - - /** - * @brief Compares unequals underlying Evas objects of target widgets - * @param[in] lhs Left hand side operand - * @param[in] rhs Right hand side operand - * @return true - if not equal, false - equal - */ - bool operator!=(const Widget &lhs, const Widget &rhs); } #include "Widget.hpp" diff --git a/ucl/include/ucl/gui/Widget.hpp b/ucl/include/ucl/gui/Widget.hpp index d8c35c5..9ff8cd6 100644 --- a/ucl/include/ucl/gui/Widget.hpp +++ b/ucl/include/ucl/gui/Widget.hpp @@ -206,6 +206,16 @@ namespace ucl { // Non-member functions // + inline Evas_Object *as_eo(Widget &widget) + { + return widget.m_eo; + } + + inline const Evas_Object *as_eo(const Widget &widget) + { + return widget.m_eo; + } + inline void getPosition(const Widget &widget, int *x, int *y) { widget.getGeometry(x, y, nullptr, nullptr); @@ -261,14 +271,4 @@ namespace ucl { expand(widget); fill(widget); } - - inline bool operator==(const Widget &lhs, const Widget &rhs) - { - return (lhs.getEo() == rhs.getEo()); - } - - inline bool operator!=(const Widget &lhs, const Widget &rhs) - { - return (lhs.getEo() != rhs.getEo()); - } } diff --git a/ucl/source/gui/Widget.cpp b/ucl/source/gui/Widget.cpp index bc7d6e8..7da5d29 100644 --- a/ucl/source/gui/Widget.cpp +++ b/ucl/source/gui/Widget.cpp @@ -35,7 +35,7 @@ namespace ucl { m_handler(std::move(handler)), m_type(static_cast<Evas_Callback_Type>(event)) { - evas_object_event_callback_add(m_widget.getEo(), + evas_object_event_callback_add(as_eo(m_widget), m_type, event_cb, this); } @@ -46,17 +46,17 @@ namespace ucl { m_handler(std::move(handler)), m_type(impl::WIDGET_EVENT_SMART) { - evas_object_smart_callback_add(m_widget.getEo(), + evas_object_smart_callback_add(as_eo(m_widget), m_smartEvent.c_str(), smart_cb, this); } ~EventProxy() { if (m_type == impl::WIDGET_EVENT_SMART) { - evas_object_smart_callback_del_full(m_widget.getEo(), + evas_object_smart_callback_del_full(as_eo(m_widget), m_smartEvent.c_str(), smart_cb, this); } else { - evas_object_event_callback_del_full(m_widget.getEo(), + evas_object_event_callback_del_full(as_eo(m_widget), m_type, event_cb, this); } } diff --git a/ucl/source/mvp/ListItemPresenter.cpp b/ucl/source/mvp/ListItemPresenter.cpp index a2087d7..42ded4f 100644 --- a/ucl/source/mvp/ListItemPresenter.cpp +++ b/ucl/source/mvp/ListItemPresenter.cpp @@ -69,7 +69,7 @@ namespace ucl { if (const auto widget = item.getItemPartContent( EdjePart(part), *item.m_parent)) { widget->setIsOwner(false); - return widget->getEo(); + return as_eo(*widget); } return nullptr; }; @@ -410,10 +410,7 @@ namespace ucl { Elm_Interface_Atspi_Accessible *ListItemPresenter::getItemAo() { - if (const auto atspi = getItemAtspi()) { - return atspi->getAo(); - } - return nullptr; + return as_ao(getItemAtspi()); } Result ListItemPresenter::updateItemStyle(const ElmStyle newItemStyle) diff --git a/ucl/source/mvp/ListPresenter.cpp b/ucl/source/mvp/ListPresenter.cpp index 407cb5c..0f41987 100644 --- a/ucl/source/mvp/ListPresenter.cpp +++ b/ucl/source/mvp/ListPresenter.cpp @@ -262,7 +262,7 @@ namespace ucl { if (!relItem) { LOG_RETURN(RES_FAIL, "relItem is NULL!"); } - if (relItem.getWidget() != m_genlist->getEo()) { + if (relItem.getWidget() != as_eo(*m_genlist)) { LOG_RETURN(RES_FAIL, "relItem has wrong genlist!"); } return insert(itemPresenter, parent, |