diff options
Diffstat (limited to 'ucl')
25 files changed, 415 insertions, 251 deletions
diff --git a/ucl/include/ucl/gui/Atspi.h b/ucl/include/ucl/gui/Atspi.h index 2657806..dcea2b1 100644 --- a/ucl/include/ucl/gui/Atspi.h +++ b/ucl/include/ucl/gui/Atspi.h @@ -31,41 +31,31 @@ namespace ucl { class Atspi final : private NonCopyable { public: /** - * @brief Constructor - * @param[in] eo Underlying Access object of the Atspi - */ - explicit Atspi(Elm_Interface_Atspi_Accessible *ao); - - /** - * @brief Destructor - * @details Unregisters all Access object callbacks - */ - ~Atspi(); - - /** - * @brief Gets Access object pointer - * @return Pointer to the Access object + * @brief Gets the underlying Access object + * @param[in] atspi Reference to target atspi + * @return Pointer to the underlying Access object */ - Elm_Interface_Atspi_Accessible *getAo(); + friend Elm_Interface_Atspi_Accessible *as_ao(Atspi &atspi); /** - * @brief Gets pointer to constant Access object - * @return Pointer to the constant Access object + * @brief Gets the underlying constant Access object + * @param[in] atspi Constant reference to target atspi + * @return Pointer to the underlying constant Access object */ - const Elm_Interface_Atspi_Accessible *getAo() const; + friend const Elm_Interface_Atspi_Accessible *as_ao(const Atspi &atspi); + public: /** - * @brief Implicitly casts to the underlying Access object - * @return Pointer to the underlying Access object + * @brief Constructor + * @param[in] eo Underlying Access object of the Atspi */ - operator Elm_Interface_Atspi_Accessible *(); + explicit Atspi(Elm_Interface_Atspi_Accessible *ao); /** - * @brief Implicitly casts to the underlying - * Access object (constant version) - * @return Pointer to the constant underlying Access object + * @brief Destructor + * @details Unregisters all Access object callbacks */ - operator const Elm_Interface_Atspi_Accessible *() const; + ~Atspi(); /** * @brief Sets name @@ -167,16 +157,16 @@ namespace ucl { * @param[in] relation Pointer to relation Access object */ void addRelationship(Elm_Atspi_Relation_Type type, - Elm_Interface_Atspi_Accessible *relation); + const Elm_Interface_Atspi_Accessible *relation); /** * @brief Deletes exiting relationship * @param[in] type Type of the exiting relationship * @param[in] relation Pointer to relation Access object, - * or NULL for all relations of the type + * or NULL for all relations of the type (optional) */ void delRelationship(Elm_Atspi_Relation_Type type, - Elm_Interface_Atspi_Accessible *relation); + const Elm_Interface_Atspi_Accessible *relation = nullptr); /** * @brief Deletes all exiting relationships @@ -196,6 +186,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 +218,43 @@ 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 + * @brief Gets Access object from pointed object + * @param[in] ptr Target object pointer + * @return Pointer to Access object or NULL + */ + template <class T> + inline auto as_ao(const T &ptr) -> typename std::enable_if< + std::is_convertible<T, bool>::value, decltype(as_ao(*ptr))>::type + { + return (ptr ? as_ao(*ptr) : nullptr); + } + + /** + * @brief Gets Access object from iterator + * @param[in] ptr Target object iterator + * @return Pointer to Access object or NULL + */ + template <class T> + inline auto as_ao(const T &iter) -> typename std::enable_if< + !std::is_convertible<T, bool>::value, decltype(as_ao(*iter))>::type + { + return as_ao(*iter); + } + + /** + * @brief Passes through original Access object pointer + * @param[in] ao Access object pointer + * @return Access object pointer */ - bool operator==(const Atspi &lhs, const Atspi &rhs); + Elm_Interface_Atspi_Accessible *as_ao(Elm_Interface_Atspi_Accessible *ao); /** - * @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 Passes through original constant Access object pointer + * @param[in] ao Constant Access object pointer + * @return Constant Access object pointer */ - bool operator!=(const Atspi &lhs, const Atspi &rhs); + const Elm_Interface_Atspi_Accessible *as_ao( + const Elm_Interface_Atspi_Accessible *ao); } #include "Atspi.hpp" diff --git a/ucl/include/ucl/gui/Atspi.hpp b/ucl/include/ucl/gui/Atspi.hpp index fcf1004..e1c53f6 100644 --- a/ucl/include/ucl/gui/Atspi.hpp +++ b/ucl/include/ucl/gui/Atspi.hpp @@ -1,3 +1,19 @@ +/* + * Copyright 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "ucl/util/helpers.h" #include "ucl/util/logging.h" @@ -27,16 +43,6 @@ namespace ucl { return m_ao; } - inline Atspi::operator Elm_Interface_Atspi_Accessible *() - { - return m_ao; - } - - inline Atspi::operator const Elm_Interface_Atspi_Accessible *() const - { - return m_ao; - } - inline void Atspi::setName(const std::string &name) { elm_atspi_accessible_name_set(getAo(), name.c_str()); @@ -125,13 +131,13 @@ namespace ucl { } inline void Atspi::addRelationship(const Elm_Atspi_Relation_Type type, - Elm_Interface_Atspi_Accessible *const relation) + const Elm_Interface_Atspi_Accessible *const relation) { elm_atspi_accessible_relationship_append(getAo(), type, relation); } inline void Atspi::delRelationship(const Elm_Atspi_Relation_Type type, - Elm_Interface_Atspi_Accessible *const relation) + const Elm_Interface_Atspi_Accessible *const relation) { elm_atspi_accessible_relationship_remove(getAo(), type, relation); } @@ -159,7 +165,7 @@ namespace ucl { if (!m_isGestureCbRegistered) { m_isGestureCbRegistered = true; elm_atspi_accessible_gesture_cb_set(m_ao, - CALLBACK_A(Atspi::onAtspiGesture), this); + UCL_CALLBACK_A(Atspi::onAtspiGesture), this); } } @@ -168,7 +174,7 @@ namespace ucl { if (!m_isNameCbRegistered) { m_isNameCbRegistered = true; elm_atspi_accessible_name_cb_set(m_ao, - CALLBACK_A(Atspi::onAtspiNameCb), this); + UCL_CALLBACK_A(Atspi::onAtspiNameCb), this); } } @@ -177,7 +183,7 @@ namespace ucl { if (!m_isDescriptionCbRegistered) { m_isDescriptionCbRegistered = true; elm_atspi_accessible_description_cb_set(m_ao, - CALLBACK_A(Atspi::onAtspiDescriptionCb), this); + UCL_CALLBACK_A(Atspi::onAtspiDescriptionCb), this); } } @@ -240,13 +246,25 @@ namespace ucl { // Non-member functions // - inline bool operator==(const Atspi &lhs, const Atspi &rhs) + inline Elm_Interface_Atspi_Accessible *as_ao(Atspi &atspi) + { + return atspi.m_ao; + } + + inline const Elm_Interface_Atspi_Accessible *as_ao(const Atspi &atspi) + { + return atspi.m_ao; + } + + inline Elm_Interface_Atspi_Accessible *as_ao( + Elm_Interface_Atspi_Accessible *const ao) { - return (lhs.getAo() == rhs.getAo()); + return ao; } - inline bool operator!=(const Atspi &lhs, const Atspi &rhs) + inline const Elm_Interface_Atspi_Accessible *as_ao( + const Elm_Interface_Atspi_Accessible *const ao) { - return (lhs.getAo() != rhs.getAo()); + return ao; } } diff --git a/ucl/include/ucl/gui/EdjeWidget.h b/ucl/include/ucl/gui/EdjeWidget.h index d195a07..da32501 100644 --- a/ucl/include/ucl/gui/EdjeWidget.h +++ b/ucl/include/ucl/gui/EdjeWidget.h @@ -56,16 +56,16 @@ namespace ucl { /** * @brief Sets content to default part - * @param[in] content Content Evas object + * @param[in] content Content widget */ - void setContent(Evas_Object *content); + void setContent(Widget &content); /** * @brief Sets content to specific part - * @param[in] content Content Evas object + * @param[in] content Content widget * @param[in] part Destination Edje part */ - void setContent(Evas_Object *content, EdjePart part); + void setContent(Widget &content, EdjePart part); /** * @brief Unsets content from default part diff --git a/ucl/include/ucl/gui/EdjeWidget.hpp b/ucl/include/ucl/gui/EdjeWidget.hpp index e08841f..763808e 100644 --- a/ucl/include/ucl/gui/EdjeWidget.hpp +++ b/ucl/include/ucl/gui/EdjeWidget.hpp @@ -32,15 +32,15 @@ namespace ucl { return elm_object_part_text_get(getEo(), part.name); } - inline void EdjeWidget::setContent(Evas_Object *const content) + inline void EdjeWidget::setContent(Widget &content) { - elm_object_content_set(getEo(), content); + elm_object_content_set(getEo(), as_eo(content)); } - inline void EdjeWidget::setContent(Evas_Object *const content, + inline void EdjeWidget::setContent(Widget &content, const EdjePart part) { - elm_object_part_content_set(getEo(), part.name, content); + elm_object_part_content_set(getEo(), part.name, as_eo(content)); } inline Evas_Object *EdjeWidget::unsetContent() 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/NaviItem.h b/ucl/include/ucl/gui/NaviItem.h index 62a5e71..495d3d8 100644 --- a/ucl/include/ucl/gui/NaviItem.h +++ b/ucl/include/ucl/gui/NaviItem.h @@ -45,17 +45,17 @@ namespace ucl { void setPopHandler(PopHandler handler) const; /** - * Pops all items of the naviframe state to this item + * @brief Pops all items of the naviframe state to this item */ void popTo() const; /** - * Moves this naviframe item to the top of the naviframe stack + * @brief Moves this naviframe item to the top of the naviframe stack */ void promote() const; /** - * Sets naviframe item tile visibility state + * @brief Sets naviframe item tile visibility state * @param[in] value Visibility state. true - visible, false - invisible * @param[in] useTransition Title show/hide transition animation flag. * true - use transition animation, false - no transition. @@ -63,13 +63,13 @@ namespace ucl { void setTitleEnabled(bool value, bool useTransition = false) const; /** - * Gets naviframe item tile visibility state + * @brief Gets naviframe item tile visibility state * @retrun Visibility state. true - visible, false - invisible */ bool isTitleEnabled() const; /** - * Sets naviframe item tile text + * @brief Sets naviframe item tile text * @param[in] title Translatable text to use as a title */ void setTitle(const TString &title) const; diff --git a/ucl/include/ucl/gui/NaviItem.hpp b/ucl/include/ucl/gui/NaviItem.hpp index b4cba2b..8b4730d 100644 --- a/ucl/include/ucl/gui/NaviItem.hpp +++ b/ucl/include/ucl/gui/NaviItem.hpp @@ -36,11 +36,6 @@ namespace ucl { inline void NaviItem::setTitle(const TString &title) const { - if (isEmpty(title)) { - setTitleEnabled(false); - } else { - setText(title); - setTitleEnabled(true); - } + setText(title); } } diff --git a/ucl/include/ucl/gui/Naviframe.h b/ucl/include/ucl/gui/Naviframe.h index 4699474..cc7a94f 100644 --- a/ucl/include/ucl/gui/Naviframe.h +++ b/ucl/include/ucl/gui/Naviframe.h @@ -136,103 +136,126 @@ namespace ucl { /** * @brief Pushes new item to the naviframe stack * @param[in] title Translatable item title (may be empty) - * @param[in] backBtn Back button Evas object (may be NULL) - * @param[in] moreBtn More button Evas object (may be NULL) - * @param[in] content Content of the item (may be NULL) + * @param[in] content Content of the item + * @param[in] backBtn Back button widget pointer (may be NULL) + * @param[in] moreBtn More button widget pointer (may be NULL) * @param[in] style Elm style of the item (optional) * @return New item */ - NaviItem push(const TString &title, - Evas_Object *backBtn, Evas_Object *moreBtn, - Evas_Object *content, ElmStyle style = nullptr); + NaviItem push(const TString &title, Widget &content, + Widget *backBtn, Widget *moreBtn, + ElmStyle style = nullptr); /** * @brief Pushes new item to the naviframe stack * @param[in] title Translatable item title (may be empty) - * @param[in] content Content of the item (may be NULL) + * @param[in] content Content of the item * @param[in] style Elm style of the item (optional) * @return New item */ - NaviItem push(const TString &title, - Evas_Object *content, ElmStyle style = nullptr); + NaviItem push(const TString &title, Widget &content, + ElmStyle style = nullptr); + + /** + * @brief Pushes new item to the naviframe stack + * @param[in] content Content of the item + * @param[in] style Elm style of the item (optional) + * @return New item + */ + NaviItem push(Widget &content, ElmStyle style = nullptr); /** * @brief Pushes new item to the naviframe stack - * @param[in] content Content of the item (may be NULL) * @param[in] style Elm style of the item (optional) * @return New item */ - NaviItem push(Evas_Object *content, ElmStyle style = nullptr); + NaviItem push(ElmStyle style = nullptr); /** * @brief Inserts new item to the naviframe stack after specific item * @param[in] after Item after which future item will be inserted * @param[in] title Translatable item title (may be empty) - * @param[in] backBtn Back button Evas object (may be NULL) - * @param[in] moreBtn More button Evas object (may be NULL) - * @param[in] content Content of the item (may be NULL) + * @param[in] content Content of the item + * @param[in] backBtn Back button widget pointer (may be NULL) + * @param[in] moreBtn More button widget pointer (may be NULL) * @param[in] style Elm style of the item (optional) * @return New item */ NaviItem insertAfter(NaviItem after, const TString &title, - Evas_Object *backBtn, Evas_Object *moreBtn, - Evas_Object *content, ElmStyle style = nullptr); + Widget &content, Widget *backBtn, Widget *moreBtn, + ElmStyle style = nullptr); /** * @brief Inserts new item to the naviframe stack after specific item * @param[in] after Item after which future item will be inserted * @param[in] title Translatable item title (may be empty) - * @param[in] content Content of the item (may be NULL) + * @param[in] content Content of the item * @param[in] style Elm style of the item (optional) * @return New item */ NaviItem insertAfter(NaviItem after, const TString &title, - Evas_Object *content, ElmStyle style = nullptr); + Widget &content, ElmStyle style = nullptr); /** * @brief Inserts new item to the naviframe stack after specific item * @param[in] after Item after which future item will be inserted - * @param[in] content Content of the item (may be NULL) + * @param[in] content Content of the item * @param[in] style Elm style of the item (optional) * @return New item */ NaviItem insertAfter(NaviItem after, - Evas_Object *content, ElmStyle style = nullptr); + Widget &content, ElmStyle style = nullptr); + + /** + * @brief Inserts new item to the naviframe stack after specific item + * @param[in] after Item after which future item will be inserted + * @param[in] style Elm style of the item (optional) + * @return New item + */ + NaviItem insertAfter(NaviItem after, ElmStyle style = nullptr); /** * @brief Inserts new item to the naviframe stack before specific item * @param[in] before Item before which future item will be inserted * @param[in] title Translatable item title (may be empty) - * @param[in] backBtn Back button Evas object (may be NULL) - * @param[in] moreBtn More button Evas object (may be NULL) - * @param[in] content Content of the item (may be NULL) + * @param[in] content Content of the item + * @param[in] backBtn Back button widget pointer (may be NULL) + * @param[in] moreBtn More button widget pointer (may be NULL) * @param[in] style Elm style of the item (optional) * @return New item */ NaviItem insertBefore(NaviItem before, const TString &title, - Evas_Object *backBtn, Evas_Object *moreBtn, - Evas_Object *content, ElmStyle style = nullptr); + Widget &content, Widget *backBtn, Widget *moreBtn, + ElmStyle style = nullptr); /** * @brief Inserts new item to the naviframe stack before specific item * @param[in] before Item before which future item will be inserted * @param[in] title Translatable item title (may be empty) - * @param[in] content Content of the item (may be NULL) + * @param[in] content Content of the item * @param[in] style Elm style of the item (optional) * @return New item */ NaviItem insertBefore(NaviItem before, const TString &title, - Evas_Object *content, ElmStyle style = nullptr); + Widget &content, ElmStyle style = nullptr); /** * @brief Inserts new item to the naviframe stack before specific item * @param[in] before Item before which future item will be inserted - * @param[in] content Content of the item (may be NULL) + * @param[in] content Content of the item * @param[in] style Elm style of the item (optional) * @return New item */ NaviItem insertBefore(NaviItem before, - Evas_Object *content, ElmStyle style = nullptr); + Widget &content, ElmStyle style = nullptr); + + /** + * @brief Inserts new item to the naviframe stack before specific item + * @param[in] before Item before which future item will be inserted + * @param[in] style Elm style of the item (optional) + * @return New item + */ + NaviItem insertBefore(NaviItem before, ElmStyle style = nullptr); /** * @brief Gets top item of the naviframe stack @@ -255,6 +278,18 @@ namespace ucl { private: Naviframe(IRefCountObj &rc, Evas_Object *eo, Private); + NaviItem push(const TString &title, + Widget *content, Widget *backBtn, Widget *moreBtn, + ElmStyle style); + + NaviItem insertAfter(NaviItem after, const TString &title, + Widget *content, Widget *backBtn, Widget *moreBtn, + ElmStyle style); + + NaviItem insertBefore(NaviItem before, const TString &title, + Widget *content, Widget *backBtn, Widget *moreBtn, + ElmStyle style); + void onTransitionFinished(Widget &widget, void *eventInfo); private: diff --git a/ucl/include/ucl/gui/Naviframe.hpp b/ucl/include/ucl/gui/Naviframe.hpp index e8fdc19..c5dc4bf 100644 --- a/ucl/include/ucl/gui/Naviframe.hpp +++ b/ucl/include/ucl/gui/Naviframe.hpp @@ -14,6 +14,19 @@ * limitations under the License. */ +namespace ucl { namespace himpl { + + inline void initItemTitle(const NaviItem item, const TString &title) + { + if (isEmpty(title)) { + item.setTitleEnabled(false); + } else { + item.setTitle(title); + item.setTitleEnabled(true); + } + } +}} + namespace ucl { // Naviframe::Builder // @@ -83,77 +96,119 @@ namespace ucl { return result; } - inline NaviItem Naviframe::push(const TString &title, - Evas_Object *const backBtn, Evas_Object *const moreBtn, - Evas_Object *const content, const ElmStyle style) + inline NaviItem Naviframe::push(const TString &title, Widget *const content, + Widget *const backBtn, Widget *const moreBtn, + const ElmStyle style) { auto result = NaviItem(elm_naviframe_item_push(getEo(), - nullptr, backBtn, moreBtn, content, style.name)); - result.setTitle(title); + nullptr, as_eo(backBtn), as_eo(moreBtn), + as_eo(content), style.name)); + himpl::initItemTitle(result, title); if (result != getBottomItem()) { setInTransition(true); } return result; } - inline NaviItem Naviframe::push(const TString &title, - Evas_Object *const content, const ElmStyle style) + inline NaviItem Naviframe::push(const TString &title, Widget &content, + Widget *const backBtn, Widget *const moreBtn, + const ElmStyle style) + { + return push(title, &content, backBtn, moreBtn, style); + } + + inline NaviItem Naviframe::push(const TString &title, Widget &content, + const ElmStyle style) + { + return push(title, &content, nullptr, nullptr, style); + } + + inline NaviItem Naviframe::push(Widget &content, const ElmStyle style) { - return push(title, nullptr, nullptr, content, style); + return push(nullptr, &content, nullptr, nullptr, style); } - inline NaviItem Naviframe::push( - Evas_Object *const content, const ElmStyle style) + inline NaviItem Naviframe::push(const ElmStyle style) { - return push(nullptr, nullptr, nullptr, content, style); + return push(nullptr, nullptr, nullptr, nullptr, style); } - inline NaviItem Naviframe::insertAfter(NaviItem after, - const TString &title, - Evas_Object *const backBtn, Evas_Object *const moreBtn, - Evas_Object *const content, const ElmStyle style) + inline NaviItem Naviframe::insertAfter(const NaviItem after, + const TString &title, Widget *const content, + Widget *const backBtn, Widget *const moreBtn, + const ElmStyle style) { auto result = NaviItem(elm_naviframe_item_insert_after(getEo(), - after, nullptr, backBtn, moreBtn, content, style.name)); - result.setTitle(title); + after, nullptr, as_eo(backBtn), as_eo(moreBtn), + as_eo(content), style.name)); + himpl::initItemTitle(result, title); return result; } - inline NaviItem Naviframe::insertAfter(NaviItem after, - const TString &title, - Evas_Object *const content, const ElmStyle style) + inline NaviItem Naviframe::insertAfter(const NaviItem after, + const TString &title, Widget &content, + Widget *const backBtn, Widget *const moreBtn, + const ElmStyle style) { - return insertAfter(after, title, nullptr, nullptr, content, style); + return insertAfter(after, title, &content, backBtn, moreBtn, style); } - inline NaviItem Naviframe::insertAfter(NaviItem after, - Evas_Object *const content, const ElmStyle style) + inline NaviItem Naviframe::insertAfter(const NaviItem after, + const TString &title, Widget &content, + const ElmStyle style) { - return insertAfter(after, nullptr, nullptr, nullptr, content, style); + return insertAfter(after, title, &content, nullptr, nullptr, style); } - inline NaviItem Naviframe::insertBefore(NaviItem before, - const TString &title, - Evas_Object *const backBtn, Evas_Object *const moreBtn, - Evas_Object *const content, const ElmStyle style) + inline NaviItem Naviframe::insertAfter(const NaviItem after, + Widget &content, const ElmStyle style) + { + return insertAfter(after, nullptr, &content, nullptr, nullptr, style); + } + + inline NaviItem Naviframe::insertAfter(const NaviItem after, + const ElmStyle style) + { + return insertAfter(after, nullptr, nullptr, nullptr, nullptr, style); + } + + inline NaviItem Naviframe::insertBefore(const NaviItem before, + const TString &title, Widget *const content, + Widget *const backBtn, Widget *const moreBtn, + const ElmStyle style) { auto result = NaviItem(elm_naviframe_item_insert_before(getEo(), - before, nullptr, backBtn, moreBtn, content, style.name)); - result.setTitle(title); + before, nullptr, as_eo(backBtn), as_eo(moreBtn), + as_eo(content), style.name)); + himpl::initItemTitle(result, title); return result; } - inline NaviItem Naviframe::insertBefore(NaviItem before, - const TString &title, - Evas_Object *const content, const ElmStyle style) + inline NaviItem Naviframe::insertBefore(const NaviItem before, + const TString &title, Widget &content, + Widget *const backBtn, Widget *const moreBtn, + const ElmStyle style) + { + return insertAfter(before, title, &content, backBtn, moreBtn, style); + } + + inline NaviItem Naviframe::insertBefore(const NaviItem before, + const TString &title, Widget &content, + const ElmStyle style) + { + return insertAfter(before, title, &content, nullptr, nullptr, style); + } + + inline NaviItem Naviframe::insertBefore(const NaviItem before, + Widget &content, const ElmStyle style) { - return insertAfter(before, title, nullptr, nullptr, content, style); + return insertAfter(before, nullptr, &content, nullptr, nullptr, style); } - inline NaviItem Naviframe::insertBefore(NaviItem before, - Evas_Object *const content, const ElmStyle style) + inline NaviItem Naviframe::insertBefore(const NaviItem before, + const ElmStyle style) { - return insertAfter(before, nullptr, nullptr, nullptr, content, style); + return insertAfter(before, nullptr, nullptr, nullptr, nullptr, style); } inline NaviItem Naviframe::getTopItem()const diff --git a/ucl/include/ucl/gui/RadioBox.h b/ucl/include/ucl/gui/RadioBox.h index a0e4b83..715b0bd 100644 --- a/ucl/include/ucl/gui/RadioBox.h +++ b/ucl/include/ucl/gui/RadioBox.h @@ -92,7 +92,7 @@ namespace ucl { * @param[in] group Radio box to which group this radio box * should be added */ - void addToGroup(Elm_Radio *group); + void addToGroup(RadioBox &group); /** * @brief Sets a value of the group in which this radio box is member diff --git a/ucl/include/ucl/gui/RadioBox.hpp b/ucl/include/ucl/gui/RadioBox.hpp index 8943278..3efe0e0 100644 --- a/ucl/include/ucl/gui/RadioBox.hpp +++ b/ucl/include/ucl/gui/RadioBox.hpp @@ -55,9 +55,9 @@ namespace ucl { return elm_radio_state_value_get(getEo()); } - inline void RadioBox::addToGroup(Elm_Radio *const group) + inline void RadioBox::addToGroup(RadioBox &group) { - elm_radio_group_add(getEo(), group); + elm_radio_group_add(getEo(), as_eo(group)); } inline void RadioBox::setGroupValue(const int value) diff --git a/ucl/include/ucl/gui/Widget.h b/ucl/include/ucl/gui/Widget.h index 0232e36..e6506ab 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,31 +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 - */ - operator Evas_Object *(); - - /** - * @brief Implicitly casts to the underlying - * Evas object (constant version) - * @return Pointer to the constant underlying Evas object - */ - operator const Evas_Object *() const; - - /** * @brief Gets Evas canvas on which underlying Evas object resides * @return Pointer to the Evas canvas */ @@ -368,6 +358,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 +435,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 +525,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..9e98bfd 100644 --- a/ucl/include/ucl/gui/Widget.hpp +++ b/ucl/include/ucl/gui/Widget.hpp @@ -44,16 +44,6 @@ namespace ucl { return m_eo; } - inline Widget::operator Evas_Object *() - { - return getEo(); - } - - inline Widget::operator const Evas_Object *() const - { - return getEo(); - } - inline Evas *Widget::getEvas() const { return evas_object_evas_get(getEo()); @@ -206,6 +196,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 +261,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/include/ucl/gui/WidgetItem.h b/ucl/include/ucl/gui/WidgetItem.h index c272bc8..3ef57d4 100644 --- a/ucl/include/ucl/gui/WidgetItem.h +++ b/ucl/include/ucl/gui/WidgetItem.h @@ -145,16 +145,16 @@ namespace ucl { /** * @brief Sets content to default part of the widget item - * @param[in] content Content Evas object + * @param[in] content Content widget */ - void setContent(Evas_Object *content) const; + void setContent(Widget &content) const; /** * @brief Sets content to specific part of the widget item - * @param[in] content Content Evas object + * @param[in] content Content widget * @param[in] part Destination Edje part */ - void setContent(Evas_Object *content, EdjePart part) const; + void setContent(Widget &content, EdjePart part) const; /** * @brief Unsets content from default part of the widget item diff --git a/ucl/include/ucl/gui/WidgetItem.hpp b/ucl/include/ucl/gui/WidgetItem.hpp index 2d53577..b36cfa4 100644 --- a/ucl/include/ucl/gui/WidgetItem.hpp +++ b/ucl/include/ucl/gui/WidgetItem.hpp @@ -97,15 +97,15 @@ namespace ucl { return elm_object_item_part_text_get(getIt(), part.name); } - inline void WidgetItem::setContent(Evas_Object *const content) const + inline void WidgetItem::setContent(Widget &content) const { - elm_object_item_content_set(getIt(), content); + elm_object_item_content_set(getIt(), as_eo(content)); } - inline void WidgetItem::setContent(Evas_Object *const content, + inline void WidgetItem::setContent(Widget &content, const EdjePart part) const { - elm_object_item_part_content_set(getIt(), part.name, content); + elm_object_item_part_content_set(getIt(), part.name, as_eo(content)); } inline Evas_Object *WidgetItem::unsetContent() const diff --git a/ucl/include/ucl/mvp/ListItemPresenter.h b/ucl/include/ucl/mvp/ListItemPresenter.h index 37175bd..690623e 100644 --- a/ucl/include/ucl/mvp/ListItemPresenter.h +++ b/ucl/include/ucl/mvp/ListItemPresenter.h @@ -36,6 +36,15 @@ namespace ucl { protected IPicker { public: /** + * @brief Gets GUI item Access object of the item presenter + * @param[in] item List item presenter + * @return Pointer to Access object or NULL + */ + friend const Elm_Interface_Atspi_Accessible *as_ao( + const ListItemPresenter &item); + + public: + /** * @brief Updates GUI item of this item */ Result updateItem(); @@ -62,12 +71,6 @@ namespace ucl { */ void setItemAtspiGestureHandler(AtspiGestureHandler handler); - /** - * @brief Gets GUI item Access object of this item - * @return Pointer to Access object or NULL - */ - Elm_Interface_Atspi_Accessible *getItemAo(); - // IDisposable // virtual void dispose() final override; @@ -128,6 +131,22 @@ namespace ucl { ElmStyle checkStyle; /** + * @brief Enable/disable Atspi support state + */ + bool enableAtspi; + + /** + * @brief Constructor + * @param[in] checkPart Part in GUI item for check widget + * @param[in] checkStyle Style of the check widget + * @param[in] enableAtspi Enable/disable Atspi support state + */ + ItemPickModeParams(EdjePart checkPart, ElmStyle checkStyle, + bool enableAtspi = false) : + checkPart(checkPart), checkStyle(checkStyle), + enableAtspi(enableAtspi) {} + + /** * @brief Checks validity of data in this structure * @return true - if valid, false - if not valid */ @@ -268,7 +287,7 @@ namespace ucl { const ItemPickModeParams ¶ms); /** - * @brief Return GUI item insertion parameters + * @brief Gets GUI item insertion parameters * @details Called just before item is added to list * @return Item insertion params structure */ diff --git a/ucl/source/gui/Genlist.cpp b/ucl/source/gui/Genlist.cpp index 6195bde..2b20d48 100644 --- a/ucl/source/gui/Genlist.cpp +++ b/ucl/source/gui/Genlist.cpp @@ -24,7 +24,7 @@ namespace ucl { GenlistSRef Genlist::Builder::build(ElmWidget &parent) const { - Evas_Object *const eo = elm_genlist_add(parent); + Evas_Object *const eo = elm_genlist_add(as_eo(parent)); if (!eo) { LOG_RETURN_VALUE(RES_FAIL, {}, "elm_genlist_add() failed!"); } diff --git a/ucl/source/gui/Layout.cpp b/ucl/source/gui/Layout.cpp index 1509fc5..f5fb2fd 100644 --- a/ucl/source/gui/Layout.cpp +++ b/ucl/source/gui/Layout.cpp @@ -26,7 +26,7 @@ namespace ucl { LayoutSRef Layout::Builder::build(ElmWidget &parent) const { - Evas_Object *const eo = elm_layout_add(parent); + Evas_Object *const eo = elm_layout_add(as_eo(parent)); if (!eo) { LOG_RETURN_VALUE(RES_FAIL, {}, "elm_layout_add() failed!"); } diff --git a/ucl/source/gui/Naviframe.cpp b/ucl/source/gui/Naviframe.cpp index 4cee1f8..7943607 100644 --- a/ucl/source/gui/Naviframe.cpp +++ b/ucl/source/gui/Naviframe.cpp @@ -24,7 +24,7 @@ namespace ucl { NaviframeSRef Naviframe::Builder::build(ElmWidget &parent) const { - Evas_Object *const eo = elm_naviframe_add(parent); + Evas_Object *const eo = elm_naviframe_add(as_eo(parent)); if (!eo) { ELOG("elm_naviframe_add() failed!"); return {}; diff --git a/ucl/source/gui/RadioBox.cpp b/ucl/source/gui/RadioBox.cpp index 3065e0a..ce8ecc7 100644 --- a/ucl/source/gui/RadioBox.cpp +++ b/ucl/source/gui/RadioBox.cpp @@ -24,7 +24,7 @@ namespace ucl { RadioBoxSRef RadioBox::Builder::build(ElmWidget &parent) const { - Evas_Object *const eo = elm_radio_add(parent); + Evas_Object *const eo = elm_radio_add(as_eo(parent)); if (!eo) { LOG_RETURN_VALUE(RES_FAIL, {}, "elm_genlist_add() failed!"); } 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/gui/Window.cpp b/ucl/source/gui/Window.cpp index 9235513..78addf3 100644 --- a/ucl/source/gui/Window.cpp +++ b/ucl/source/gui/Window.cpp @@ -45,21 +45,22 @@ namespace ucl { } } - StyledWidget bg(elm_bg_add(winEo)); + StyledWidget bg(elm_bg_add(winEo), false); expand(bg); show(bg); - StyledWidget conform(elm_conformant_add(winEo)); + StyledWidget conform(elm_conformant_add(winEo), false); expand(conform); show(conform); - elm_win_resize_object_add(winEo, bg); - elm_win_resize_object_add(winEo, conform); + elm_win_resize_object_add(winEo, as_eo(bg)); + elm_win_resize_object_add(winEo, as_eo(conform)); elm_win_indicator_opacity_set(winEo, ELM_WIN_INDICATOR_OPAQUE); elm_win_conformant_set(winEo, EINA_TRUE); - auto result = makeShared<Window>(winEo, isOwner, conform, PRIVATE); + auto result = makeShared<Window>(winEo, isOwner, + as_eo(conform), PRIVATE); if (m_needBindToEo) { result->bindToEo(); diff --git a/ucl/source/mvp/ListItemPresenter.cpp b/ucl/source/mvp/ListItemPresenter.cpp index a2087d7..bb8d719 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; }; @@ -314,27 +314,41 @@ namespace ucl { return nullptr; } - auto check = makeShared<StyledWidget>(elm_check_add(parent)); + auto check = makeShared<StyledWidget>(elm_check_add(as_eo(parent))); check->setStyle(params.checkStyle); - elm_check_state_set(*check, toEina(m_isItemPicked)); - evas_object_repeat_events_set(*check, EINA_FALSE); - evas_object_propagate_events_set(*check, EINA_FALSE); + elm_check_state_set(as_eo(*check), toEina(m_isItemPicked)); + evas_object_repeat_events_set(as_eo(*check), EINA_FALSE); + evas_object_propagate_events_set(as_eo(*check), EINA_FALSE); check->addEventHandler( impl::CHECK_CHANGED, WEAK_DELEGATE_THIS(onPickCheckChanged)); + if (params.enableAtspi) { + auto itemAtspi = getItemAtspi(); + if (itemAtspi) { + auto &checkAtspi = check->getAtspi(); + + checkAtspi.addRelationship(ELM_ATSPI_RELATION_CONTROLLED_BY, + as_ao(*itemAtspi)); + itemAtspi->addRelationship(ELM_ATSPI_RELATION_CONTROLLER_FOR, + as_ao(checkAtspi)); + itemAtspi->addRelationship(ELM_ATSPI_RELATION_DESCRIBED_BY, + as_ao(checkAtspi)); + } + } + return check; } void ListItemPresenter::onPickCheckChanged(Widget &widget, void *eventInfo) { if (!isActive()) { - elm_check_state_set(widget, toEina(m_isItemPicked)); + elm_check_state_set(as_eo(widget), toEina(m_isItemPicked)); return; } - handleItemPick(elm_check_state_get(widget)); + handleItemPick(elm_check_state_get(as_eo(widget))); if (m_item) { elm_genlist_item_bring_in(m_item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); @@ -408,14 +422,6 @@ namespace ucl { m_itemAtspiGestureHandler = std::move(handler); } - Elm_Interface_Atspi_Accessible *ListItemPresenter::getItemAo() - { - if (const auto atspi = getItemAtspi()) { - return atspi->getAo(); - } - return nullptr; - } - Result ListItemPresenter::updateItemStyle(const ElmStyle newItemStyle) { if (!m_item) { @@ -503,4 +509,12 @@ namespace ucl { void ListItemPresenter::onItemLongpressed() { } + + // Non-member functions // + + const Elm_Interface_Atspi_Accessible *as_ao( + const ListItemPresenter &item) + { + return as_ao(item.getItemAtspi()); + } } diff --git a/ucl/source/mvp/ListPresenter.cpp b/ucl/source/mvp/ListPresenter.cpp index 407cb5c..242928e 100644 --- a/ucl/source/mvp/ListPresenter.cpp +++ b/ucl/source/mvp/ListPresenter.cpp @@ -123,7 +123,7 @@ namespace ucl { expandAndFill(*m_genlist); // TODO Add Scroller widget. - elm_scroller_content_min_limit(*m_genlist, + elm_scroller_content_min_limit(as_eo(*m_genlist), toEina((flags & FLAG_CALC_X_MIN) != 0), toEina((flags & FLAG_CALC_Y_MIN) != 0)); @@ -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, |