From: Igor Olshevskyi Date: Thu, 26 Oct 2017 12:37:07 +0000 (+0300) Subject: TizenRefApp-9690 [Call UI] Update UCL source files X-Git-Tag: submit/tizen/20180410.135041~2^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6ac5f4d0dbd1bab1ff2997a9052915a29ace5692;p=profile%2Fwearable%2Fapps%2Fnative%2Fcall-ui.git TizenRefApp-9690 [Call UI] Update UCL source files Change-Id: I175a8c227169df3f12bee6c6101d3fef5b3dd54e --- diff --git a/call-ui/model/impl/BatteryStateSource.cpp b/call-ui/model/impl/BatteryStateSource.cpp index 4fb1498..1a64825 100644 --- a/call-ui/model/impl/BatteryStateSource.cpp +++ b/call-ui/model/impl/BatteryStateSource.cpp @@ -139,25 +139,25 @@ namespace callui { int res = vconf_notify_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS, CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_STATUS_LOW, CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, CALLBACK_B(BatteryStateSource::onBatteryStateChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } return RES_OK; diff --git a/call-ui/model/impl/BluetoothManager.cpp b/call-ui/model/impl/BluetoothManager.cpp index f5f39eb..0cb78c0 100644 --- a/call-ui/model/impl/BluetoothManager.cpp +++ b/call-ui/model/impl/BluetoothManager.cpp @@ -90,10 +90,10 @@ namespace callui { "initializeBluetooth() failed!"); FAIL_RETURN(registerVolumeChangeHandling(), - "registerVolumeChangeHandling() failed"); + "registerVolumeChangeHandling() failed!"); FAIL_RETURN(registerScoStateHandling(), - "registerScoStateHandling() failed"); + "registerScoStateHandling() failed!"); FAIL_RETURN(registerHeadsetConnectionHandling(), "registerHeadsetConnectionHandling() failed!"); diff --git a/call-ui/model/impl/CallInfo.cpp b/call-ui/model/impl/CallInfo.cpp index 36eed08..d1913d3 100644 --- a/call-ui/model/impl/CallInfo.cpp +++ b/call-ui/model/impl/CallInfo.cpp @@ -196,7 +196,7 @@ namespace callui { { struct tm tmp{0}; FAIL_RETURN_VALUE(impl::getCurrTimeDiffInTm(m_startTime, tmp), - {0}, "getCurrTimeDiffInTm() failed"); + {0}, "getCurrTimeDiffInTm() failed!"); return tmp; } diff --git a/call-ui/model/impl/CallManager.cpp b/call-ui/model/impl/CallManager.cpp index 3df8dcd..c63803f 100644 --- a/call-ui/model/impl/CallManager.cpp +++ b/call-ui/model/impl/CallManager.cpp @@ -58,7 +58,7 @@ namespace callui { { m_contactInfoProvider = ContactInfoProvider::newInstance(); if (!m_contactInfoProvider) { - ELOG("ContactInfoProvider::newInstance() failed"); + ELOG("ContactInfoProvider::newInstance() failed!"); } FAIL_RETURN(initCalls(), "initCalls() failed!"); diff --git a/call-ui/model/impl/ConnectionStateSource.cpp b/call-ui/model/impl/ConnectionStateSource.cpp index e6eb768..0fbdbf1 100644 --- a/call-ui/model/impl/ConnectionStateSource.cpp +++ b/call-ui/model/impl/ConnectionStateSource.cpp @@ -70,7 +70,7 @@ namespace callui { { int state = VCONFKEY_WIFI_UNCONNECTED; if (vconf_get_int(VCONFKEY_WIFI_STATE, &state) < 0) { - ELOG("Get WiFi connection state failed"); + ELOG("Get WiFi connection state failed!"); return false; } return (state == VCONFKEY_WIFI_CONNECTED); @@ -208,7 +208,7 @@ namespace callui { return PacketDirection::NO_INPUT; } } - ELOG("Get WiFi transfer state failed"); + ELOG("Get WiFi transfer state failed!"); return PacketDirection::NONE; } @@ -223,7 +223,7 @@ namespace callui { default: return PacketDirection::NO_INPUT; } } - ELOG("Get packet state failed"); + ELOG("Get packet state failed!"); return PacketDirection::NONE; } @@ -261,7 +261,7 @@ namespace callui { CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed( @@ -269,7 +269,7 @@ namespace callui { CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed( @@ -277,7 +277,7 @@ namespace callui { CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed( @@ -285,7 +285,7 @@ namespace callui { CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed( @@ -293,7 +293,7 @@ namespace callui { CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed( @@ -301,7 +301,7 @@ namespace callui { CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed( @@ -309,7 +309,7 @@ namespace callui { CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed( @@ -317,7 +317,7 @@ namespace callui { CALLBACK_B(ConnectionStateSource::onConnTypeChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } // PACKET @@ -326,7 +326,7 @@ namespace callui { CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed( @@ -334,7 +334,7 @@ namespace callui { CALLBACK_B(ConnectionStateSource::onPacketStateChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } return RES_OK; diff --git a/call-ui/model/impl/RssiStateSource.cpp b/call-ui/model/impl/RssiStateSource.cpp index fe80040..915d715 100644 --- a/call-ui/model/impl/RssiStateSource.cpp +++ b/call-ui/model/impl/RssiStateSource.cpp @@ -158,31 +158,31 @@ namespace callui { int res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM, CALLBACK_B(RssiStateSource::onRssiChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, CALLBACK_B(RssiStateSource::onRssiChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVCTYPE, CALLBACK_B(RssiStateSource::onRssiChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_RSSI, CALLBACK_B(RssiStateSource::onRssiChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } res = vconf_notify_key_changed(VCONFKEY_TELEPHONY_ROAM_ICON_MODE, CALLBACK_B(RssiStateSource::onRssiChangedCb), this); if (res != 0) { - LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed"); + LOG_RETURN(RES_FAIL, "vconf_notify_key_changed() failed!"); } return RES_OK; diff --git a/call-ui/model/impl/SoundManager.cpp b/call-ui/model/impl/SoundManager.cpp index f243df8..563b6c2 100644 --- a/call-ui/model/impl/SoundManager.cpp +++ b/call-ui/model/impl/SoundManager.cpp @@ -95,7 +95,7 @@ namespace callui { &m_deviceVolumeCbId); if (ret != SOUND_MANAGER_ERROR_NONE) { LOG_RETURN(RES_FAIL, - "sound_manager_add_volume_changed_cb() failed"); + "sound_manager_add_volume_changed_cb() failed!"); } if (isBTSupported()) { diff --git a/call-ui/presenters/Instance.cpp b/call-ui/presenters/Instance.cpp index f976f39..4a91def 100644 --- a/call-ui/presenters/Instance.cpp +++ b/call-ui/presenters/Instance.cpp @@ -61,7 +61,7 @@ namespace callui { { m_powerKeyHoldTimout.reset(); - elm_win_keygrab_unset(*m_win, impl::STR_POWER_KEY, 0, 0); + elm_win_keygrab_unset(as_eo(*m_win), impl::STR_POWER_KEY, 0, 0); if (m_keyUpEventHandler) { ecore_event_handler_del(m_keyUpEventHandler); @@ -76,7 +76,7 @@ namespace callui { m_win = m_context->getWindow(); - elm_win_keygrab_set(*m_win, impl::STR_POWER_KEY, 0, 0, 0, + elm_win_keygrab_set(as_eo(*m_win), impl::STR_POWER_KEY, 0, 0, 0, ELM_WIN_KEYGRAB_TOPMOST); m_keyUpEventHandler = ecore_event_handler_add(ECORE_EVENT_KEY_UP, @@ -102,8 +102,10 @@ namespace callui { } m_win->getConformant().setContent(*m_navi); - elm_atspi_accessible_translation_domain_set(*m_win, TEXT_DOMAIN); - elm_atspi_accessible_name_set(*m_win, AO_STR_CALL); + + auto &atspi = m_win->getAtspi(); + atspi.setTDomain(TEXT_DOMAIN); + atspi.setName(AO_STR_CALL); FAIL_RETURN(utils::createCircleSurface(*m_navi), "createCircleSurface() failed!"); diff --git a/call-ui/presenters/dialogs/AcceptDialog.cpp b/call-ui/presenters/dialogs/AcceptDialog.cpp index 64a2373..f3d2ced 100644 --- a/call-ui/presenters/dialogs/AcceptDialog.cpp +++ b/call-ui/presenters/dialogs/AcceptDialog.cpp @@ -75,7 +75,7 @@ namespace callui { { return doPrepare(); }), - "Dialog::prepare failed"); + "Dialog::prepare() failed!"); return RES_OK; } @@ -86,7 +86,7 @@ namespace callui { FAIL_RETURN(createList(), "createList() failed!"); - FAIL_RETURN(createCircleObject(), "createCircleObject() failed"); + FAIL_RETURN(createCircleObject(), "createCircleObject() failed!"); FAIL_RETURN(createListItems(), "createListItems() failed!"); @@ -103,10 +103,10 @@ namespace callui { } m_popup->setContent(*layout, impl::PART_CIRCLE_SFC); - auto surface = eext_circle_surface_layout_add(*layout); + auto surface = eext_circle_surface_layout_add(as_eo(*layout)); m_circleObj = eext_circle_object_genlist_add( - m_listPresenter->getWidget(), surface); + as_eo(m_listPresenter->getWidget()), surface); eext_circle_object_genlist_scroller_policy_set(m_circleObj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); diff --git a/call-ui/presenters/dialogs/base/Dialog.cpp b/call-ui/presenters/dialogs/base/Dialog.cpp index 7cde517..5236a66 100644 --- a/call-ui/presenters/dialogs/base/Dialog.cpp +++ b/call-ui/presenters/dialogs/base/Dialog.cpp @@ -38,17 +38,17 @@ namespace callui { Result Dialog::createPopup(ElmWidget &parent, const PopupType popupType) { Evas_Object *const popupEo = ((popupType == PopupType::NORMAL) ? - elm_popup_add(parent) : elm_ctxpopup_add(parent)); + elm_popup_add(as_eo(parent)) : + elm_ctxpopup_add(as_eo(parent))); if (!popupEo) { LOG_RETURN(RES_FAIL, "elm_popup_add() failed!"); } m_popup = makeShared(popupEo); - m_popup->addEventHandler( POPUP_DISMISSED, WEAK_DELEGATE_THIS(onPopupDismissed)); - eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK, + eext_object_event_callback_add(popupEo, EEXT_CALLBACK_BACK, CALLBACK_A(Dialog::onPopupHWBackKey), this); getWindow().addEventHandler( @@ -73,7 +73,7 @@ namespace callui { if (m_popup && !m_isDismissed && m_popup->isVisible()) { m_isDismissed = true; deactivateSelf(); - elm_popup_dismiss(*m_popup); + elm_popup_dismiss(as_eo(*m_popup)); onDismiss(); } } @@ -81,7 +81,7 @@ namespace callui { void Dialog::dispose() { if (m_popup) { - eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK, + eext_object_event_callback_del(as_eo(*m_popup), EEXT_CALLBACK_BACK, CALLBACK_A(Dialog::onPopupHWBackKey)); deactivateSelf(); diff --git a/call-ui/presenters/items/SimpleListItem.cpp b/call-ui/presenters/items/SimpleListItem.cpp index 46b12ad..e34dc1d 100644 --- a/call-ui/presenters/items/SimpleListItem.cpp +++ b/call-ui/presenters/items/SimpleListItem.cpp @@ -20,11 +20,21 @@ namespace callui { - SimpleListItem::SimpleListItem(IRefCountObj &rc, - ElmStyle style, PartTextMap parts) : + using ucl::ListItemPresenter; + + SimpleListItem::SimpleListItem(IRefCountObj &rc, ElmStyle style, + PartTextMap parts, bool useAtspiRedundant) : ListItemPresenter::ListItemPresenter(rc), m_listItemStyle(style), - m_listItemParts(std::move(parts)) + m_listItemParts(std::move(parts)), + m_useAtspiRedundant(useAtspiRedundant) + { + } + + SimpleListItem::SimpleListItem(IRefCountObj &rc, ElmStyle style) : + ListItemPresenter::ListItemPresenter(rc), + m_listItemStyle(style), + m_useAtspiRedundant(true) { } @@ -57,4 +67,10 @@ namespace callui { } } + void SimpleListItem::onItemAttached() + { + if (m_useAtspiRedundant) { + getItemAtspi()->setRole(ELM_ATSPI_ROLE_REDUNDANT_OBJECT); + } + } } diff --git a/call-ui/presenters/items/SimpleListItem.h b/call-ui/presenters/items/SimpleListItem.h index 03f8e6f..2ec4a9a 100644 --- a/call-ui/presenters/items/SimpleListItem.h +++ b/call-ui/presenters/items/SimpleListItem.h @@ -27,20 +27,30 @@ namespace callui { class SimpleListItem final : public ucl::ListItemPresenter { public: - /** - * @brief Constructor - * @param[in] rc Pointer to IRefCountObj (passed automatically) - * @param[in] style Item style - * @param[in] parts Map of item text parts value - */ + * @brief Constructor + * @param[in] rc Pointer to IRefCountObj (passed automatically) + * @param[in] style Item style + * @param[in] parts Map of item text parts value + * @param[in] useAtspiRedundant true - if item is Atspi redundant object, + * false - otherwise + */ SimpleListItem(ucl::IRefCountObj &rc, ucl::ElmStyle style, - PartTextMap parts = {}); + PartTextMap parts, bool useAtspiRedundant = false); /** - * @brief Sets item select handler - * @param[in] handler Select handler - */ + * @brief Constructor + * @details Constructor that creates items already as Atspi redundant + * object + * @param[in] rc Pointer to IRefCountObj (passed automatically) + * @param[in] style Item style + */ + SimpleListItem(ucl::IRefCountObj &rc, ucl::ElmStyle style); + + /** + * @brief Sets item select handler + * @param[in] handler Select handler + */ void setItemSelectHandler(NotiHandler handler); protected: @@ -62,6 +72,11 @@ namespace callui { */ virtual void onItemSelected() override; + /** + * @see ucl::ListItemPresenter::onItemAttached() + */ + virtual void onItemAttached() override; + private: ~SimpleListItem() = default; @@ -70,6 +85,7 @@ namespace callui { const PartTextMap m_listItemParts; NotiHandler m_onItemSelected; + bool m_useAtspiRedundant; friend class ucl::ReffedObj; }; diff --git a/call-ui/presenters/misc/AccessoryPresenter.cpp b/call-ui/presenters/misc/AccessoryPresenter.cpp index 59045d4..dcee9e5 100644 --- a/call-ui/presenters/misc/AccessoryPresenter.cpp +++ b/call-ui/presenters/misc/AccessoryPresenter.cpp @@ -138,8 +138,8 @@ namespace callui { } auto result = makeShared(m_sm, m_exitHandler); - FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget, m_cm), - {}, "result->prepare() failed!"); + FAIL_RETURN_VALUE(result->prepare(parent, *m_parentWidget, m_cm), {}, + "result->prepare() failed!"); return result; } @@ -167,16 +167,16 @@ namespace callui { ElmWidget &parentWidget, const ICallManagerSRef &cm) { FAIL_RETURN(GuiPresenter::prepare(parent), - "Presenter::prepare() failed"); + "Presenter::prepare() failed!"); FAIL_RETURN(createWidget(parentWidget), - "createWidget() failed"); + "createWidget() failed!"); FAIL_RETURN(createSlider(), - "createSlider() failed"); + "createSlider() failed!"); FAIL_RETURN(createVolumeControl(), - "createVolumeControl() failed"); + "createVolumeControl() failed!"); updateCurrentVolume(); @@ -186,7 +186,7 @@ namespace callui { updateMode(cm); FAIL_RETURN(updateModeRelativeComponents(cm), - "updateComponents() failed"); + "updateComponents() failed!"); return RES_OK; } @@ -214,7 +214,7 @@ namespace callui { m_audioState = m_sm->getAudioState(); FAIL_RETURN(updateModeRelativeComponents(cm), - "updateModeRelativeComponents() failed"); + "updateModeRelativeComponents() failed!"); return RES_OK; } @@ -247,13 +247,13 @@ namespace callui { updateMaxVolume(); updateCurrentVolume(); - FAIL_RETURN(createVolumeBtn(), "createVolumeBtn() failed"); + FAIL_RETURN(createVolumeBtn(), "createVolumeBtn() failed!"); m_widget->setContent(*m_volumeBtn, impl::PART_SWL_SLOT1); - FAIL_RETURN(createMuteBtn(), "createMuteBtn create failed"); + FAIL_RETURN(createMuteBtn(), "createMuteBtn create failed!"); m_widget->setContent(*m_muteBtn, impl::PART_SWL_SLOT3); - FAIL_RETURN(createBluetoothBtn(), "createBluetoothBtn() failed"); + FAIL_RETURN(createBluetoothBtn(), "createBluetoothBtn() failed!"); m_widget->setContent(*m_bluetoothBtn, impl::PART_SWL_SLOT2); if (m_mode == CallMode::OUTGOING) { @@ -280,7 +280,7 @@ namespace callui { isUnknownCaller(*callInfo)) && !(callInfo->getConferenceMemberCount() > 1) && !(callInfo->getContactInfo())) { - FAIL_RETURN(createAddContactBtn(), "createAddContactBtn() failed"); + FAIL_RETURN(createAddContactBtn(), "createAddContactBtn() failed!"); m_widget->setContent(*m_addContactBtn, impl::PART_SWL_SLOT2); m_unsavedPhoneNumber = callInfo->getPhoneNumber(); } @@ -317,7 +317,7 @@ namespace callui { setMaxValue(m_sm->getMaxVolume()). build(*m_widget); if (!m_slider) { - LOG_RETURN(RES_FAIL, "Slider::build() failed"); + LOG_RETURN(RES_FAIL, "Slider::build() failed!"); } m_widget->setContent(*m_slider, impl::PART_SWL_VOLUME_SLIDER); @@ -332,7 +332,7 @@ namespace callui { setEventHandler(WEAK_DELEGATE_THIS(onVolumeControlEventCb)). build(*m_widget); if (!m_vc) { - LOG_RETURN(RES_FAIL, "VolumeControl::build() failed"); + LOG_RETURN(RES_FAIL, "VolumeControl::build() failed!"); } auto window = m_vc->getWindow(); @@ -353,69 +353,62 @@ namespace callui { Result AccessoryPresenter::createVolumeBtn() { - Evas_Object *eo = elm_button_add(*m_widget); + Evas_Object *const eo = elm_button_add(as_eo(*m_widget)); if (!eo) { - LOG_RETURN(RES_FAIL, "eo is NULL"); + LOG_RETURN(RES_FAIL, "elm_button_add() failed!"); } - m_volumeBtn = makeShared(eo); m_volumeBtn->setStyle(impl::STYLE_BTN_VOLUME); m_volumeBtn->addEventHandler(BTN_CLICKED, WEAK_DELEGATE_THIS(onVolumeBtnClicked)); show(*m_volumeBtn); - // Screen Reader - elm_atspi_accessible_translation_domain_set(*m_volumeBtn, TEXT_DOMAIN); - elm_atspi_accessible_name_set(*m_volumeBtn, STR_VOLUME); + auto &atspi = m_volumeBtn->getAtspi(); + atspi.setTDomain(TEXT_DOMAIN); + atspi.setName(STR_VOLUME); return RES_OK; } Result AccessoryPresenter::createMuteBtn() { - Evas_Object *eo = elm_button_add(*m_widget); + Evas_Object *const eo = elm_button_add(as_eo(*m_widget)); if (!eo) { - LOG_RETURN(RES_FAIL, "eo is NULL"); + LOG_RETURN(RES_FAIL, "elm_button_add() failed!"); } m_muteBtn = makeShared(eo); m_muteBtn->setStyle(impl::STYLE_BTN_MUTE); m_muteBtn->addEventHandler(BTN_CLICKED, WEAK_DELEGATE_THIS(onMuteBtnClicked)); - show(*m_muteBtn); - // Screen Reader - elm_atspi_accessible_translation_domain_set(*m_muteBtn, TEXT_DOMAIN); - elm_atspi_accessible_name_set(*m_muteBtn, AO_STR_MUTE); + auto &atspi = m_muteBtn->getAtspi(); + atspi.setTDomain(TEXT_DOMAIN); + atspi.setName(AO_STR_MUTE); return RES_OK; } Result AccessoryPresenter::createBluetoothBtn() { - Evas_Object *eo = elm_button_add(*m_widget); + Evas_Object *const eo = elm_button_add(as_eo(*m_widget)); if (!eo) { - LOG_RETURN(RES_FAIL, "eo is NULL"); + LOG_RETURN(RES_FAIL, "elm_button_add() failed!"); } m_bluetoothBtn = makeShared(eo); m_bluetoothBtn->setStyle(impl::STYLE_BTN_BT); m_bluetoothBtn->addEventHandler(BTN_CLICKED, WEAK_DELEGATE_THIS(onBluetoothBtnClicked)); - show(*m_bluetoothBtn); - // Screen Reader - elm_atspi_accessible_translation_domain_set(*m_bluetoothBtn, TEXT_DOMAIN); + auto &atspi = m_bluetoothBtn->getAtspi(); + atspi.setTDomain(TEXT_DOMAIN); if (m_audioState == AudioStateType::BT) { m_bluetoothBtn->emit(impl::SIGNAL_TURN_ON); - // Screen Reader - elm_atspi_accessible_name_set(*m_bluetoothBtn, - STR_MORE_GEAR); + atspi.setName(STR_MORE_GEAR); } else { m_bluetoothBtn->emit(impl::SIGNAL_TURN_OFF); - // Screen Reader - elm_atspi_accessible_name_set(*m_bluetoothBtn, - STR_MORE_HEADSET); + atspi.setName(STR_MORE_HEADSET); } if (!m_sm->isBTSupported()) { @@ -427,9 +420,9 @@ namespace callui { Result AccessoryPresenter::createAddContactBtn() { - Evas_Object *eo = elm_button_add(*m_widget); + Evas_Object *const eo = elm_button_add(as_eo(*m_widget)); if (!eo) { - LOG_RETURN(RES_FAIL, "eo is NULL"); + LOG_RETURN(RES_FAIL, "elm_button_add() failed!"); } m_addContactBtn = makeShared(eo); m_addContactBtn->setStyle(impl::STYLE_BTN_ADD_CONTACT); @@ -437,10 +430,9 @@ namespace callui { WEAK_DELEGATE_THIS(onAddContactBtnClicked)); show(*m_addContactBtn); - // Screen Reader - elm_atspi_accessible_translation_domain_set(*m_addContactBtn, TEXT_DOMAIN); - elm_atspi_accessible_name_set(*m_addContactBtn, - AO_STR_ADD_TO_CONTACTS); + auto &atspi = m_addContactBtn->getAtspi(); + atspi.setTDomain(TEXT_DOMAIN); + atspi.setName(AO_STR_ADD_TO_CONTACTS); return RES_OK; } @@ -454,8 +446,7 @@ namespace callui { show(*m_vc); startVCTimer(); - - elm_atspi_component_highlight_grab(*m_vc); + m_vc->getAtspi().highlight(); } void AccessoryPresenter::onMuteBtnClicked(Widget &widget, void *eventInfo) @@ -474,16 +465,16 @@ namespace callui { if (m_audioState == AudioStateType::BT) { auto res = m_sm->setBluetoothState(false); if (res != RES_OK && res != RES_NOT_CONNECTED) { - FAIL_RETURN_VOID(res, "setBluetoothState(false) failed"); + FAIL_RETURN_VOID(res, "setBluetoothState(false) failed!"); } } else { auto res = m_sm->setBluetoothState(true); if (res == RES_NOT_CONNECTED) { DLOG("Launch bluetooth settings..."); FAIL_RETURN_VOID(impl::launchBluetoothSettings(), - "launchBluetoothSettings() failed"); + "launchBluetoothSettings() failed!"); } else { - FAIL_RETURN_VOID(res, "setBluetoothState(true) failed"); + FAIL_RETURN_VOID(res, "setBluetoothState(true) failed!"); } } } @@ -492,7 +483,7 @@ namespace callui { { Result res = impl::launchAddContact(m_unsavedPhoneNumber); if (res != RES_OK) { - RESLOG(res, "launchAddContact() failed"); + RESLOG(res, "launchAddContact() failed!"); } if (const auto handler = m_exitHandler.lock()) { @@ -574,7 +565,7 @@ namespace callui { show(*m_vc); startVCTimer(); m_isVcShowOnRotaryEvent = true; - elm_atspi_component_highlight_grab(*m_vc); + m_vc->getAtspi().highlight(); } if (m_isVcShowOnRotaryEvent) { @@ -634,7 +625,7 @@ namespace callui { auto cur = m_sm->getVolume(); if (checkPossibilityToModifyVolume(cur, true)) { FAIL_RETURN_VOID(m_sm->setVolume(cur + 1), - "setVolume() failed"); + "setVolume() failed!"); } } @@ -643,7 +634,7 @@ namespace callui { auto cur = m_sm->getVolume(); if (checkPossibilityToModifyVolume(cur, false)) { FAIL_RETURN_VOID(m_sm->setVolume(cur - 1), - "setVolume() failed"); + "setVolume() failed!"); } } @@ -663,14 +654,10 @@ namespace callui { if (m_bluetoothBtn) { if (m_audioState == AudioStateType::BT) { m_bluetoothBtn->emit(impl::SIGNAL_TURN_ON); - // Screen Reader - elm_atspi_accessible_name_set(*m_bluetoothBtn, - STR_MORE_GEAR); + m_bluetoothBtn->getAtspi().setName(STR_MORE_GEAR); } else { m_bluetoothBtn->emit(impl::SIGNAL_TURN_OFF); - // Screen Reader - elm_atspi_accessible_name_set(*m_bluetoothBtn, - STR_MORE_HEADSET); + m_bluetoothBtn->getAtspi().setName(STR_MORE_HEADSET); } } } @@ -695,7 +682,6 @@ namespace callui { m_vc->setDecreaseBtnEnable(true); } - // Screen Reader if (m_vc->isVisible()) { if (!m_isVcShowOnRotaryEvent) { elm_atspi_bridge_utils_say(std::to_string(cur).c_str(), @@ -724,8 +710,9 @@ namespace callui { return; } - if (!elm_object_disabled_get(*m_muteBtn)) + if (m_muteBtn->isEnabled()) { updateMuteBtn(); + } } void AccessoryPresenter::updateMuteBtn() diff --git a/call-ui/presenters/misc/AtspiHighlightHelper.cpp b/call-ui/presenters/misc/AtspiHighlightHelper.cpp index e91f292..6dc8353 100644 --- a/call-ui/presenters/misc/AtspiHighlightHelper.cpp +++ b/call-ui/presenters/misc/AtspiHighlightHelper.cpp @@ -25,16 +25,16 @@ namespace callui { namespace { namespace impl { namespace callui { + using ucl::Atspi; using ucl::AtspiGestureEventInfo; - - using ucl::ATSPI_ON_GESTURE; + using ucl::ListItemPresenter; AtspiHighlightHelperSRef AtspiHighlightHelper::newInstance( - GuiPresenter &parent, ElmWidget &rootWidget) + GuiPresenter &parent) { auto result = makeShared(); - FAIL_RETURN_VALUE(result->prepare(parent, rootWidget), {}, + FAIL_RETURN_VALUE(result->prepare(parent), {}, "result->prepare() failed!"); return result; @@ -45,47 +45,42 @@ namespace callui { { } - Result AtspiHighlightHelper::prepare(GuiPresenter &parent, - ElmWidget &rootWidget) + Result AtspiHighlightHelper::prepare(GuiPresenter &parent) { FAIL_RETURN(GuiPresenter::prepare(parent), "GuiPresenter::prepare() failed!"); - registerWidget(rootWidget); - return RES_OK; } - void AtspiHighlightHelper::setRelationEventHandler(RelationEventHandler handler) + void AtspiHighlightHelper::setEventHandler( + EventHandler handler) { - m_relationEventHandler = handler; + m_eventHandler = handler; } - void AtspiHighlightHelper::setGestureEventHandler(GestureEventHandler handler) + void AtspiHighlightHelper::registerObject(ElmWidget &widget) { - m_gestureEventHandler = handler; + widget.getAtspi().addGestureHandler( + WEAK_DELEGATE_THIS(onAtspiGesture)); } - void AtspiHighlightHelper::registerWidget(ElmWidget &widget) + void AtspiHighlightHelper::registerObject(ListItemPresenter &listItemPrs) { - widget.addEventHandler(ATSPI_ON_GESTURE, + listItemPrs.setItemAtspiGestureHandler( WEAK_DELEGATE_THIS(onAtspiGesture)); } - void AtspiHighlightHelper::handleAtspiGesture( - Elm_Interface_Atspi_Accessible *ao, + void AtspiHighlightHelper::handleAtspiGesture(Atspi &atspi, AtspiGestureEventInfo &e) { - DLOG("Access object [%p]", ao); - - if (e.stopPropagation) { - DLOG("Ignored. Propagation was stopped."); - return; - } + Elm_Interface_Atspi_Accessible *currentAo = as_ao(atspi); + DLOG("Access object [%p]", currentAo); if (!isActive()) { DLOG("Ignored. Presenter is not active"); - if (e.gestureInfo.type != ELM_ATSPI_GESTURE_ONE_FINGER_SINGLE_TAP) { + if ((e.gestureInfo.type != ELM_ATSPI_GESTURE_ONE_FINGER_SINGLE_TAP) + && (currentAo != as_ao(getWindow()))) { DLOG("Prevent default handler"); e.preventDefault = true; } @@ -93,76 +88,61 @@ namespace callui { } e.stopPropagation = true; - - if (const auto handler = m_gestureEventHandler.lock()) { - if (handler(ao, e.gestureInfo.type)) { - DLOG("Prevent default handler"); - e.preventDefault = true; - return; - } - } - e.preventDefault = false; - if (!m_relationEventHandler) { - DLOG("Relation event handler does not set"); - return; - } - const Elm_Atspi_Relation_Type relation = getFlowRelation(e.gestureInfo); if (relation == ELM_ATSPI_RELATION_NULL) { DLOG("Not supported gesture type for processing"); return; } - Elm_Interface_Atspi_Accessible *relationObj = nullptr; - if (const auto handler = m_relationEventHandler.lock()) { - relationObj = handler(ao, relation); + const Elm_Interface_Atspi_Accessible *relationAo = nullptr; + if (const auto handler = m_eventHandler.lock()) { + relationAo = handler(currentAo, relation); } - if (!relationObj) { - DLOG("Relation object is NULL!"); + if (!relationAo) { + DLOG("Relation object is NULL"); return; } - DLOG("Relation object [%p]", relationObj); + DLOG("Relation object [%p]", relationAo); + + if (currentAo == as_ao(getWindow())) { + const auto fakeAtspi = getFakeAtspi(); + if (!fakeAtspi) { + LOG_RETURN_VOID(RES_FAIL, "fakeAtspi is NULL!"); + } + currentAo = as_ao(*fakeAtspi); + fakeAtspi->highlight(); + } + Atspi currentAtspi {currentAo}; + currentAtspi.delRelationship(relation, nullptr); + currentAtspi.addRelationship(relation, relationAo); + } + + Atspi *AtspiHighlightHelper::getFakeAtspi() + { auto &win = getWindow(); - auto atspiHelper = static_cast - (win.getData(impl::ATSPI_HELPER_DATA)); + auto widget = static_cast(win.getData( + impl::ATSPI_HELPER_DATA)); - if (!atspiHelper) { - const auto obj = utils::createFakeAccessObject(win); + if (!widget) { + const ElmWidgetSRef obj = utils::createFakeAccessObject(win); if (!obj) { - LOG_RETURN_VOID(RES_FAIL, "createFakeAccessObject() failed!"); + LOG_RETURN_VALUE(RES_FAIL, nullptr, + "createFakeAccessObject() failed!"); } obj->setIsOwner(false); - atspiHelper = obj->getEo(); - win.setData(impl::ATSPI_HELPER_DATA, atspiHelper); + widget = obj.get(); + win.setData(impl::ATSPI_HELPER_DATA, widget); } - if (ao == win) { - ao = atspiHelper; - elm_atspi_component_highlight_grab(ao); - } - - elm_atspi_accessible_relationships_clear(ao); - elm_atspi_accessible_relationship_append(ao, relation, relationObj); + return &widget->getAtspi(); } - void AtspiHighlightHelper::onAtspiGesture( - Widget &widget, void *eventInfo) + void AtspiHighlightHelper::onAtspiGesture(Atspi &atspi, + AtspiGestureEventInfo &eventInfo) { - handleAtspiGesture(widget, - *static_cast(eventInfo)); - } - - bool AtspiHighlightHelper::handleGesture(Elm_Interface_Atspi_Accessible *ao, - const Elm_Atspi_Gesture_Info &info) - { - AtspiGestureEventInfo eventInfo {}; - eventInfo.gestureInfo = info; - - handleAtspiGesture(ao, eventInfo); - - return eventInfo.preventDefault; + handleAtspiGesture(atspi, eventInfo); } } diff --git a/call-ui/presenters/misc/AtspiHighlightHelper.h b/call-ui/presenters/misc/AtspiHighlightHelper.h index e9788c0..34fd742 100644 --- a/call-ui/presenters/misc/AtspiHighlightHelper.h +++ b/call-ui/presenters/misc/AtspiHighlightHelper.h @@ -18,6 +18,7 @@ #define __CALL_UI_PRESENTERS_MISC_ATSPI_HIGHLIGHT_HELPER_H__ #include "ucl/mvp/GuiPresenter.h" +#include "ucl/mvp/ListItemPresenter.h" #include "call-ui/presenters/types.h" @@ -32,75 +33,58 @@ namespace callui { public: /** - * @brief Relation event handler definition + * @brief Event handler definition */ - using RelationEventHandler = ucl::WeakDelegate; + using EventHandler = ucl::WeakDelegate< + const Elm_Interface_Atspi_Accessible *( + const Elm_Interface_Atspi_Accessible *ao, + Elm_Atspi_Relation_Type flowRelation)>; - /** - * @brief Gesture event handler definition - */ - using GestureEventHandler = ucl::WeakDelegate; public: /** * @brief Creates new instance of AtspiHighlightHelper * @param[in] parent Parent presenter - * @param[in] rootWidget Root widget for Screen Reader * @return Shared reference to AtspiHighlightHelper instance * on success or NULL otherwise */ - static AtspiHighlightHelperSRef newInstance(GuiPresenter &parent, - ucl::ElmWidget &rootWidget); + static AtspiHighlightHelperSRef newInstance(GuiPresenter &parent); /** - * @brief Sets relation event handler - * @param[in] handler Relation event handler + * @brief Sets event handler + * @param[in] handler Event handler */ - void setRelationEventHandler(RelationEventHandler handler); + void setEventHandler(EventHandler handler); /** - * @brief Sets gesture event handler - * @param[in] handler Gesture event handler - */ - void setGestureEventHandler(GestureEventHandler handler); - - /** - * @brief Registers widget for Screen Reader events - * relation and gesture events + * @brief Registers widget for handling Atspi gesture events * @param[in] widget Widget to register */ - void registerWidget(ucl::ElmWidget &widget); + void registerObject(ucl::ElmWidget &widget); /** - * @brief Handles gesture events on Access object that - * are not register by AtspiHighlightHelper - * @param[in] widget Access object - * @param[in] info Gesture info - * @return true if no need to process gesture event by EFL, - * false otherwise + * @brief Registers List Item presenter for handling Atspi + * gesture events + * @param[in] listItemPrs List item presenter to register */ - bool handleGesture(Elm_Interface_Atspi_Accessible *widget, - const Elm_Atspi_Gesture_Info &info); + void registerObject(ucl::ListItemPresenter &listItemPrs); private: AtspiHighlightHelper(ucl::IRefCountObj &rc); ~AtspiHighlightHelper() = default; - ucl::Result prepare(GuiPresenter &parent, ucl::ElmWidget &rootWidget); + ucl::Result prepare(GuiPresenter &parent); - void handleAtspiGesture(Elm_Interface_Atspi_Accessible *widget, + void handleAtspiGesture(ucl::Atspi &atspi, ucl::AtspiGestureEventInfo &e); - private: - void onAtspiGesture(ucl::Widget &widget, void *eventInfo); + void onAtspiGesture(ucl::Atspi &atspi, + ucl::AtspiGestureEventInfo &eventInfo); + + ucl::Atspi *getFakeAtspi(); private: - RelationEventHandler m_relationEventHandler; - GestureEventHandler m_gestureEventHandler; + EventHandler m_eventHandler; friend class ucl::ReffedObj; }; diff --git a/call-ui/presenters/misc/CallInfoPresenter.cpp b/call-ui/presenters/misc/CallInfoPresenter.cpp index 45f3de2..0936bf7 100644 --- a/call-ui/presenters/misc/CallInfoPresenter.cpp +++ b/call-ui/presenters/misc/CallInfoPresenter.cpp @@ -74,7 +74,7 @@ namespace callui { namespace { namespace impl { int getTextWidth(ElmWidget &parent, const char *fontStyle, int fontSize, const std::string &text) { - auto eoText = evas_object_text_add(evas_object_evas_get(parent)); + auto eoText = evas_object_text_add(evas_object_evas_get(as_eo(parent))); evas_object_text_font_set(eoText, fontStyle, fontSize); evas_object_text_style_set(eoText, EVAS_TEXT_STYLE_PLAIN); evas_object_text_text_set(eoText, text.c_str()); @@ -342,7 +342,7 @@ namespace callui { Result CallInfoPresenter::createLabel(const std::string &text) { - auto *eo = elm_label_add(*m_widget); + Evas_Object *const eo = elm_label_add(as_eo(*m_widget)); if (!eo) { LOG_RETURN(RES_FAIL, "elm_label_add() failed!"); } @@ -358,40 +358,40 @@ namespace callui { m_label->setStyle(impl::STYLE_SLIDING_LABEL); m_label->setText(txtStyle.format(text.c_str())); - elm_label_slide_mode_set(*m_label, ELM_LABEL_SLIDE_MODE_AUTO); - elm_label_wrap_width_set(*m_label, + elm_label_slide_mode_set(eo, ELM_LABEL_SLIDE_MODE_AUTO); + elm_label_wrap_width_set(eo, ELM_SCALE_SIZE(impl::SUB_TXT_MAX_WIDTH)); double duration = (static_cast(text.size())) / impl::SLIDE_LABEL_DURATION_KOEFF; - elm_label_slide_duration_set(*m_label, duration); - elm_label_slide_go(*m_label); + elm_label_slide_duration_set(eo, duration); + elm_label_slide_go(eo); m_widget->setContent(*m_label, impl::PART_SWL_2LINE); - elm_atspi_accessible_can_highlight_set(*m_label, EINA_FALSE); + m_label->getAtspi().setHighlightable(false); return RES_OK; } Result CallInfoPresenter::createCallerIdImage(const std::string &imagePath) { - auto *eo = elm_image_add(*m_widget); + Evas_Object *const eo = elm_image_add(as_eo(*m_widget)); if (!eo) { - LOG_RETURN(RES_FAIL, "elm_image_add() failed"); + LOG_RETURN(RES_FAIL, "elm_image_add() failed!"); } - auto callerId = makeShared(eo); - elm_image_file_set(*callerId, imagePath.c_str(), NULL); - elm_image_aspect_fixed_set(*callerId, EINA_TRUE); - elm_image_fill_outside_set(*callerId, EINA_TRUE); + elm_image_file_set(eo, imagePath.c_str(), NULL); + elm_image_aspect_fixed_set(eo, EINA_TRUE); + elm_image_fill_outside_set(eo, EINA_TRUE); + const auto callerId = makeShared(eo); auto window = callerId->getWindow(); if (!window) { LOG_RETURN(RES_FAIL, "Window is NULL!"); } int w = 0, h = 0; window->getScreenSize(&w, &h); - evas_object_size_hint_min_set(*callerId, w, h); + callerId->setMin(w, h); m_widget->setContent(*callerId, impl::PART_SWL_CALLER_ID); @@ -421,7 +421,7 @@ namespace callui { } FAIL_RETURN(createCallerIdImage(callerIdPath), - "createCallerIdImage() failed"); + "createCallerIdImage() failed!"); m_widget->emit(impl::SIGN_CID_ENABLE, impl::SRC_CALLER_ID); } @@ -457,7 +457,7 @@ namespace callui { if (!subTxt.empty()) { m_isSubTxtEnable = true; - FAIL_RETURN(createLabel(subTxt), "createLabel() failed"); + FAIL_RETURN(createLabel(subTxt), "createLabel() failed!"); } if (m_mode == CallMode::INCOMING) { @@ -651,12 +651,12 @@ namespace callui { ElmWidget *CallInfoPresenter::getMainTxtAo() { - return m_mainTxtAO.get(); + return m_mainTxtAo.get(); } ElmWidget *CallInfoPresenter::getSubTxtAo() { - return m_subTxtAO.get(); + return m_subTxtAo.get(); } ElmWidget *CallInfoPresenter::getStatusTxtAo() @@ -666,18 +666,17 @@ namespace callui { Result CallInfoPresenter::setMainTxtAccessObject(const std::string &text) { - if (!m_mainTxtAO) { - m_mainTxtAO = utils::createAccessObjectFromLyPart(*m_widget, - *m_widget, - impl::PART_AO_MAIN_TXT); - if (!m_mainTxtAO) { - LOG_RETURN(RES_FAIL, "createAccessObjectFromLyPart() failed!"); + if (!m_mainTxtAo) { + m_mainTxtAo = utils::createAccessObjectFromPart(*m_widget, + *m_widget, impl::PART_AO_MAIN_TXT); + if (!m_mainTxtAo) { + LOG_RETURN(RES_FAIL, "createAccessObjectFromPart() failed!"); } } - elm_atspi_accessible_reading_info_type_set(*m_mainTxtAO, - ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - elm_atspi_accessible_name_set(*m_mainTxtAO, text.c_str()); + auto &atspi = m_mainTxtAo->getAtspi(); + atspi.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + atspi.setName(text.c_str()); return RES_OK; } @@ -685,23 +684,21 @@ namespace callui { Result CallInfoPresenter::setSubTxtAccessObject(const std::string &text) { if (!text.empty()) { - if (!m_subTxtAO) { - m_subTxtAO = utils::createAccessObjectFromLyPart(*m_widget, - *m_widget, - impl::PART_AO_SUB_TXT); - if (!m_subTxtAO) { + if (!m_subTxtAo) { + m_subTxtAo = utils::createAccessObjectFromPart(*m_widget, + *m_widget, impl::PART_AO_SUB_TXT); + if (!m_subTxtAo) { LOG_RETURN(RES_FAIL, - "createAccessObjectFromLyPart() failed!"); + "createAccessObjectFromPart() failed!"); } } - elm_atspi_accessible_reading_info_type_set(*m_subTxtAO, - ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - elm_atspi_accessible_name_set(*m_subTxtAO, text.c_str()); + auto &atspi = m_subTxtAo->getAtspi(); + atspi.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + atspi.setName(text.c_str()); - } else if (m_subTxtAO) { - utils::destroyAccessObject(*m_subTxtAO); - m_subTxtAO.reset(); + } else if (m_subTxtAo) { + m_subTxtAo.reset(); } return RES_OK; diff --git a/call-ui/presenters/misc/CallInfoPresenter.h b/call-ui/presenters/misc/CallInfoPresenter.h index 756b35a..c10cf68 100644 --- a/call-ui/presenters/misc/CallInfoPresenter.h +++ b/call-ui/presenters/misc/CallInfoPresenter.h @@ -162,9 +162,9 @@ namespace callui { bool m_isSubTxtEnable; bool m_needModifyCallStatus; - ucl::ElmWidgetSRef m_statusAO; - ucl::ElmWidgetSRef m_mainTxtAO; - ucl::ElmWidgetSRef m_subTxtAO; + ucl::ElmWidgetSRef m_statusAo; + ucl::ElmWidgetSRef m_mainTxtAo; + ucl::ElmWidgetSRef m_subTxtAo; friend class ucl::ReffedObj; }; diff --git a/call-ui/presenters/misc/CallStatusPresenter.cpp b/call-ui/presenters/misc/CallStatusPresenter.cpp index 30e9ae0..f66602d 100644 --- a/call-ui/presenters/misc/CallStatusPresenter.cpp +++ b/call-ui/presenters/misc/CallStatusPresenter.cpp @@ -281,31 +281,25 @@ namespace callui { Result CallStatusPresenter::createStatusTxtAo() { if (!m_statusTxtAo) { - m_statusTxtAo = utils::createAccessObjectFromLyPart(*m_ly, - *m_ly, + m_statusTxtAo = utils::createAccessObjectFromPart(*m_ly, *m_ly, impl::PART_AO_STATUS); if (!m_statusTxtAo) { - LOG_RETURN(RES_FAIL, "createAccessObjectFromLyPart() failed!"); + LOG_RETURN(RES_FAIL, "createAccessObjectFromPart() failed!"); } - elm_atspi_accessible_reading_info_type_set(*m_statusTxtAo, - ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - elm_atspi_accessible_name_cb_set(*m_statusTxtAo, - [](void *data, Evas_Object *obj) -> char * - { - auto self = static_cast(data); - if (!self) { - return nullptr; - } - auto txt = self->m_ly-> - getText(impl::PART_TXT_TEXT_INFO).getCStr(); - return (txt) ? strdup(txt) : nullptr; - }, - this); + auto &atspi = m_statusTxtAo->getAtspi(); + atspi.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + atspi.setNameCb(WEAK_DELEGATE_THIS(onStatusTxtAoNameCb)); } return RES_OK; } + CString CallStatusPresenter::onStatusTxtAoNameCb(Atspi &atspi) + { + const auto txt = m_ly->getText(impl::PART_TXT_TEXT_INFO); + return (!txt.empty()) ? CString::dup(txt.c_str()) : nullptr; + } + ElmWidget *CallStatusPresenter::getStatusTextAo() { return m_statusTxtAo.get(); diff --git a/call-ui/presenters/misc/CallStatusPresenter.h b/call-ui/presenters/misc/CallStatusPresenter.h index 80486c0..710d111 100644 --- a/call-ui/presenters/misc/CallStatusPresenter.h +++ b/call-ui/presenters/misc/CallStatusPresenter.h @@ -121,6 +121,7 @@ namespace callui { void onLanguageChanged(ucl::Widget &widget, void *eventInfo); ucl::Result createStatusTxtAo(); + ucl::CString onStatusTxtAoNameCb(ucl::Atspi &atspi); private: const ICallInfoWCRef m_info; diff --git a/call-ui/presenters/misc/DeviceStatePresenter.cpp b/call-ui/presenters/misc/DeviceStatePresenter.cpp index ebdd2f9..bbda1f3 100644 --- a/call-ui/presenters/misc/DeviceStatePresenter.cpp +++ b/call-ui/presenters/misc/DeviceStatePresenter.cpp @@ -85,17 +85,17 @@ namespace callui { { if (state != DisplayState::UNDEFINED) { FAIL_RETURN(setDisplayState(state, true), - "setDisplayState() failed"); + "setDisplayState() failed!"); } if (mode != DisplayMode::UNDEFINED) { FAIL_RETURN(setDisplayMode(mode), - "setDisplayMode() failed"); + "setDisplayMode() failed!"); } if (lockState) { FAIL_RETURN(setCpuLockState(lockState), - "setCpuLockState() failed"); + "setCpuLockState() failed!"); } return RES_OK; @@ -167,7 +167,8 @@ namespace callui { EFL_UTIL_SCREEN_MODE_ALWAYS_ON : EFL_UTIL_SCREEN_MODE_DEFAULT; - int res = efl_util_set_window_screen_mode(*m_window, setScreenMode); + int res = efl_util_set_window_screen_mode(as_eo(*m_window), + setScreenMode); if (res != EFL_UTIL_ERROR_NONE) { LOG_RETURN(RES_FAIL, "Set window screen mode failed." "res[%d] msg[%s]", res, get_error_message(res)); diff --git a/call-ui/presenters/misc/MoreOptionsPresenter.cpp b/call-ui/presenters/misc/MoreOptionsPresenter.cpp index 0b7753a..8ec22e9 100644 --- a/call-ui/presenters/misc/MoreOptionsPresenter.cpp +++ b/call-ui/presenters/misc/MoreOptionsPresenter.cpp @@ -56,7 +56,6 @@ namespace callui { namespace { namespace impl { constexpr EdjeSignal SIGNAL_EVEN {"even"}; constexpr EdjeSignalSrc SIGNAL_SRC_MORE_OPTION {"more_option"}; - }}} namespace callui { @@ -131,7 +130,7 @@ namespace callui { stopCallDurationTimer(); if (m_widget) { - eext_object_event_callback_del(*m_widget, EEXT_CALLBACK_BACK, + eext_object_event_callback_del(as_eo(*m_widget), EEXT_CALLBACK_BACK, CALLBACK_A(MoreOptionsPresenter::onBackKey)); sendActivate(*m_widget); @@ -192,33 +191,33 @@ namespace callui { createStatusTxtAo(); if (m_statusTxtAo) { - m_atspiHelper->registerWidget(*m_statusTxtAo); + m_atspiHelper->registerObject(*m_statusTxtAo); } } Result MoreOptionsPresenter::createPanel() { - auto *eo = elm_panel_add(*m_widget); + Evas_Object *const eo = elm_panel_add(as_eo(*m_widget)); if (!eo) { LOG_RETURN(RES_FAIL, "elm_panel_add() failed!"); } m_panel = makeShared(eo); - elm_panel_orient_set(*m_panel, ELM_PANEL_ORIENT_RIGHT); + elm_panel_orient_set(eo, ELM_PANEL_ORIENT_RIGHT); show(*m_panel); m_widget->setContent(*m_panel, impl::PART_SWL_RIGHT); - elm_panel_toggle(*m_panel); + elm_panel_toggle(eo); - elm_layout_signal_callback_add(*m_panel, "elm,state,active,finished", + elm_layout_signal_callback_add(eo, "elm,state,active,finished", "elm", CALLBACK_A(MoreOptionsPresenter::onPanelActivate), this); - elm_layout_signal_callback_add(*m_panel, "elm,state,inactive,finished", + elm_layout_signal_callback_add(eo, "elm,state,inactive,finished", "elm", CALLBACK_A(MoreOptionsPresenter::onPanelInactivate), this); setDeactivatorSink(m_panel); - elm_layout_signal_callback_add(*m_panel, "cue,clicked", + elm_layout_signal_callback_add(eo, "cue,clicked", "elm", CALLBACK_A(MoreOptionsPresenter::onCueClicked), this); return RES_OK; @@ -255,7 +254,7 @@ namespace callui { { if (const auto keypad = m_keypad.lock()) { if (keypad->isAtTop()) { - elm_panel_hidden_set(*m_panel, EINA_TRUE); + elm_panel_hidden_set(as_eo(*m_panel), EINA_TRUE); } } } @@ -269,18 +268,18 @@ namespace callui { auto held = m_cm->getHeldCall(); FAIL_RETURN_VOID(createKeypadButton(), - "createKeypadButton() failed"); + "createKeypadButton() failed!"); if (held) { m_panelLy->emit(impl::SIGNAL_EVEN, impl::SIGNAL_SRC_MORE_OPTION); if (active) { FAIL_RETURN_VOID(createSwapButton(), - "createSwapButton() failed"); + "createSwapButton() failed!"); setPanelContent(*m_btnSwap, impl::PART_SWL_SLOT1); } else { FAIL_RETURN_VOID(createUnholdButton(), - "createUnholdButton() failed"); + "createUnholdButton() failed!"); setPanelContent(*m_btnUnhold, impl::PART_SWL_SLOT1); } setPanelContent(*m_btnKeypad, impl::PART_SWL_SLOT2); @@ -330,7 +329,7 @@ namespace callui { if (!held) { LOG_RETURN_VOID(RES_FAIL, "Held call is NULL"); } - FAIL_RETURN_VOID(held->swapWithActive(), "swapWithActive() failed"); + FAIL_RETURN_VOID(held->swapWithActive(), "swapWithActive() failed!"); } void MoreOptionsPresenter::onUnholdBtnClick(Widget &sender, void *eventInfo) @@ -339,7 +338,7 @@ namespace callui { if (!held) { LOG_RETURN_VOID(RES_FAIL, "Held call is NULL"); } - FAIL_RETURN_VOID(held->unhold(), "unhold() failed"); + FAIL_RETURN_VOID(held->unhold(), "unhold() failed!"); } void MoreOptionsPresenter::onKeypadBtnClick(Widget &sender, void *eventInfo) @@ -365,11 +364,11 @@ namespace callui { const TString &txt, WidgetEventHandler handler) { - auto *eo = elm_button_add(*m_panelLy); + Evas_Object *const eo = elm_button_add(as_eo(*m_panelLy)); if (!eo) { LOG_RETURN_VALUE(RES_FAIL, {}, "elm_button_add() failed!"); } - auto btn = makeShared(eo); + const auto btn = makeShared(eo); btn->setStyle(style); btn->setText(txt); btn->addEventHandler(BTN_CLICKED, std::move(handler)); @@ -400,21 +399,21 @@ namespace callui { const char *emission, const char *source) { - eext_object_event_callback_add(*m_widget, EEXT_CALLBACK_BACK, + eext_object_event_callback_add(as_eo(*m_widget), EEXT_CALLBACK_BACK, CALLBACK_A(MoreOptionsPresenter::onBackKey), this); const auto keepAliver = asShared(*this); sendDeactivate(*m_widget); activateBy(m_widget.get()); - elm_atspi_component_highlight_grab(*m_fakeAo); + m_fakeAo->getAtspi().highlight(); } void MoreOptionsPresenter::onPanelInactivate(Evas_Object *obj, const char *emission, const char *source) { - eext_object_event_callback_del(*m_widget, EEXT_CALLBACK_BACK, + eext_object_event_callback_del(as_eo(*m_widget), EEXT_CALLBACK_BACK, CALLBACK_A(MoreOptionsPresenter::onBackKey)); const auto keepAliver = asShared(*this); @@ -425,14 +424,15 @@ namespace callui { hide(*m_panelLy); m_statusTxtAo.reset(); - elm_atspi_accessible_can_highlight_set(*m_cueAo, EINA_TRUE); + m_cueAo->getAtspi().setHighlightable(true); + hide(*m_fakeAo); } void MoreOptionsPresenter::onBackKey(Evas_Object *obj, void *eventInfo) { - if (isActive() && !elm_panel_hidden_get(*m_panel)) { - elm_panel_toggle(*m_panel); + if (isActive() && !elm_panel_hidden_get(as_eo(*m_panel))) { + elm_panel_toggle(as_eo(*m_panel)); } } @@ -523,123 +523,123 @@ namespace callui { Result MoreOptionsPresenter::createAtspiHighlightHelper() { - DLOG("ENTER"); - m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow()); + m_atspiHelper = AtspiHighlightHelper::newInstance(*this); if (!m_atspiHelper) { LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!"); } - m_atspiHelper->setRelationEventHandler( + m_atspiHelper->setEventHandler( WEAK_DELEGATE_THIS(onAtspiHighlight)); + + m_atspiHelper->registerObject(getWindow()); + if (m_fakeAo) { - m_atspiHelper->registerWidget(*m_fakeAo); + m_atspiHelper->registerObject(*m_fakeAo); } if (m_panelLy) { - m_atspiHelper->registerWidget(*m_panelLy); + m_atspiHelper->registerObject(*m_panelLy); } if (m_btnSwap) { - m_atspiHelper->registerWidget(*m_btnSwap); + m_atspiHelper->registerObject(*m_btnSwap); } if (m_btnUnhold) { - m_atspiHelper->registerWidget(*m_btnUnhold); + m_atspiHelper->registerObject(*m_btnUnhold); } if (m_btnKeypad) { - m_atspiHelper->registerWidget(*m_btnKeypad); + m_atspiHelper->registerObject(*m_btnKeypad); } if (m_statusTxtAo) { - m_atspiHelper->registerWidget(*m_statusTxtAo); + m_atspiHelper->registerObject(*m_statusTxtAo); } - DLOG("EXIT"); + return RES_OK; } - Elm_Interface_Atspi_Accessible *MoreOptionsPresenter::onAtspiHighlight( - Elm_Interface_Atspi_Accessible *ao, - Elm_Atspi_Relation_Type flowRelation) + const Elm_Interface_Atspi_Accessible * + MoreOptionsPresenter::onAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, + Elm_Atspi_Relation_Type flowRelation) { - DLOG("FlowRelation [%s]", - flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ? - "FROM" : - "TO"); + const auto swapBtnAo = utils::getAo(m_btnSwap.get()); + const auto unholdBtnAo = utils::getAo(m_btnUnhold.get()); + const auto keypadBtnAo = utils::getAo(m_btnKeypad.get()); + const auto statusTxtAo = utils::getAo(m_statusTxtAo.get()); + const auto fakeAo = utils::getAo(m_fakeAo.get()); - if (m_btnSwap && ao == *m_btnSwap) { + if (ao == swapBtnAo) { DLOG("Swap button"); if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *m_btnKeypad; + return keypadBtnAo; } - } else if (m_btnUnhold && ao == *m_btnUnhold) { + } else if (ao == unholdBtnAo) { DLOG("Unhold button"); if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *m_btnKeypad; + return keypadBtnAo; } - } else if (ao == *m_btnKeypad) { + } else if (ao == keypadBtnAo) { DLOG("Keypad button"); if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *m_statusTxtAo; + return statusTxtAo; } else { - if (m_btnSwap) { - return *m_btnSwap; - } else if (m_btnUnhold) { - return *m_btnUnhold; + if (swapBtnAo) { + return swapBtnAo; + } else if (unholdBtnAo) { + return unholdBtnAo; } } - } else if (ao == *m_statusTxtAo) { + } else if (ao == statusTxtAo) { DLOG("Status text"); if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { - return *m_btnKeypad; + return keypadBtnAo; } - } else if (ao == getWindow() || ao == *m_fakeAo) { + } else if (ao == as_ao(getWindow()) || ao == fakeAo) { DLOG("window or panelLy"); - if (m_btnSwap) { - return *m_btnSwap; - } else if (m_btnUnhold) { - return *m_btnUnhold; + if (swapBtnAo) { + return swapBtnAo; + } else if (unholdBtnAo) { + return unholdBtnAo; } else { - return *m_btnKeypad; + return keypadBtnAo; } - } else { - LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!"); } - - return ao; + LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!"); } Result MoreOptionsPresenter::createAccessObjects() { - FAIL_RETURN(createCueAo(), "createCueAo() failed"); - FAIL_RETURN(createStatusTxtAo(), "createStatusTxtAo() failed"); - FAIL_RETURN(createFakeAo(), "createFakeAo() failed"); + FAIL_RETURN(createCueAo(), "createCueAo() failed!"); + FAIL_RETURN(createStatusTxtAo(), "createStatusTxtAo() failed!"); + FAIL_RETURN(createFakeAo(), "createFakeAo() failed!"); return RES_OK; } Result MoreOptionsPresenter::createCueAo() { - m_cueAo = utils::createAccessObjectFromLyPart(*m_widget, - *m_panel, + m_cueAo = utils::createAccessObjectFromPart(*m_widget, *m_panel, impl::PART_ACCESS); if (!m_cueAo) { LOG_RETURN(RES_FAIL, - "createAccessObjectFromLyPart() failed!"); + "createAccessObjectFromPart() failed!"); } - elm_access_action_cb_set(*m_cueAo, + elm_access_action_cb_set(as_eo(*m_cueAo), ELM_ACCESS_ACTION_ACTIVATE, CALLBACK_A(MoreOptionsPresenter::onCueAoActionCb), this); - elm_atspi_accessible_translation_domain_set(*m_cueAo, TEXT_DOMAIN); - elm_atspi_accessible_reading_info_type_set(*m_cueAo, - ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | + auto &atspi = m_cueAo->getAtspi(); + atspi.setTDomain(TEXT_DOMAIN); + atspi.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_ROLE); - elm_atspi_accessible_name_set(*m_cueAo, AO_STR_MORE_OPTIONS); - elm_atspi_accessible_role_set(*m_cueAo, ELM_ATSPI_ROLE_PUSH_BUTTON); + atspi.setName(AO_STR_MORE_OPTIONS); + atspi.setRole(ELM_ATSPI_ROLE_PUSH_BUTTON); return RES_OK; } @@ -661,52 +661,50 @@ namespace callui { Result MoreOptionsPresenter::createStatusTxtAo() { - m_statusTxtAo = utils::createAccessObjectFromLyPart(*m_widget, - *m_panelLy, - impl::PART_AO_TXT_STATUS); + m_statusTxtAo = utils::createAccessObjectFromPart(*m_panelLy, + *m_panelLy, impl::PART_AO_TXT_STATUS); if (!m_statusTxtAo) { LOG_RETURN(RES_FAIL, - "createAccessObjectFromLyPart() failed!"); - } - - elm_atspi_accessible_reading_info_type_set(*m_statusTxtAo, - ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - elm_atspi_accessible_name_cb_set(*m_statusTxtAo, - [](void *data, Evas_Object *obj) -> char * - { - auto self = static_cast(data); - if (!self) { - return nullptr; - } - auto txt = self->m_panelLy-> - getText(impl::PART_TXT_STATUS).getCStr(); - return (txt) ? strdup(txt) : nullptr; - }, - this); + "createAccessObjectFromPart() failed!"); + } + + auto &atspi = m_statusTxtAo->getAtspi(); + atspi.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + atspi.setNameCb(WEAK_DELEGATE_THIS(onStatusTxtAoNameCb)); return RES_OK; } + CString MoreOptionsPresenter::onStatusTxtAoNameCb(Atspi &atspi) + { + const auto text = m_panelLy->getText(impl::PART_TXT_STATUS); + return (!text.empty()) ? CString::dup(text.c_str()) : nullptr; + } + Eina_Bool MoreOptionsPresenter::onCueAoActionCb(Evas_Object *obj, Elm_Access_Action_Info *actionInfo) { switch (actionInfo->action_type) { case ELM_ACCESS_ACTION_ACTIVATE: - + { show(*m_fakeAo); m_panel->setContent(*m_panelLy); show(*m_panelLy); createStatusTxtAo(); + if (m_statusTxtAo) { - m_atspiHelper->registerWidget(*m_statusTxtAo); + m_atspiHelper->registerObject(*m_statusTxtAo); } - elm_panel_toggle(*m_panel); - elm_atspi_component_highlight_clear(*m_cueAo); - elm_atspi_accessible_can_highlight_set(*m_cueAo, EINA_FALSE); + elm_panel_toggle(as_eo(*m_panel)); + + auto &atspi = m_cueAo->getAtspi(); + atspi.unhighlight(); + atspi.setHighlightable(false); return EINA_TRUE; break; + } default: break; } diff --git a/call-ui/presenters/misc/MoreOptionsPresenter.h b/call-ui/presenters/misc/MoreOptionsPresenter.h index 376052b..ddea718 100644 --- a/call-ui/presenters/misc/MoreOptionsPresenter.h +++ b/call-ui/presenters/misc/MoreOptionsPresenter.h @@ -173,12 +173,14 @@ namespace callui { ucl::Result createStatusTxtAo(); ucl::Result createFakeAo(); ucl::Result createAtspiHighlightHelper(); - Elm_Interface_Atspi_Accessible *onAtspiHighlight( - Elm_Interface_Atspi_Accessible *ao, + const Elm_Interface_Atspi_Accessible *onAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, Elm_Atspi_Relation_Type flowRelation); Eina_Bool onCueAoActionCb(Evas_Object *obj, Elm_Access_Action_Info *actionInfo); + ucl::CString onStatusTxtAoNameCb(ucl::Atspi &atspi); + private: const ICallManagerSRef m_cm; const ISoundManagerSRef m_sm; diff --git a/call-ui/presenters/misc/RejectMsgPresenter.cpp b/call-ui/presenters/misc/RejectMsgPresenter.cpp index 8c4dd07..1f3b62f 100644 --- a/call-ui/presenters/misc/RejectMsgPresenter.cpp +++ b/call-ui/presenters/misc/RejectMsgPresenter.cpp @@ -189,7 +189,7 @@ namespace callui { LOG_RETURN(RES_FAIL, "Layout::build() failed!"); } - eext_object_event_callback_add(m_widget->getEo(), EEXT_CALLBACK_BACK, + eext_object_event_callback_add(as_eo(*m_widget), EEXT_CALLBACK_BACK, CALLBACK_A(RejectMsgPresenter::onBackKey), this); return RES_OK; @@ -204,14 +204,15 @@ namespace callui { void RejectMsgPresenter::panelScrollCb(Widget &widget, void *eventInfo) { - Elm_Panel_Scroll_Info *ev = static_cast(eventInfo); + Elm_Panel_Scroll_Info *ev = + static_cast(eventInfo); DLOG("pos x[%f] y[%f]", ev->rel_x, ev->rel_y); auto prevState = m_state; if (ev->rel_y == 1.0) { m_state = State::SHOWN; // Prevent panel scrolling - elm_object_scroll_freeze_push(m_panel->getEo()); + elm_object_scroll_freeze_push(as_eo(*m_panel)); } else if (ev->rel_y == 0.0) { m_state = State::HIDDEN; destroyRejectMsgList(); @@ -248,14 +249,16 @@ namespace callui { Result RejectMsgPresenter::createPanel() { - m_panel = makeShared(elm_panel_add(*m_widget)); - if (!m_panel) { + Evas_Object *const eo = elm_panel_add(as_eo(*m_widget)); + if (!eo) { LOG_RETURN(RES_FAIL, "elm_panel_add() failed!"); } - elm_panel_scrollable_set(*m_panel, EINA_TRUE); - elm_panel_scrollable_content_size_set(*m_panel, 1.0); - elm_panel_hidden_set(*m_panel, EINA_TRUE); - elm_panel_orient_set(*m_panel, ELM_PANEL_ORIENT_BOTTOM); + m_panel = makeShared(eo); + + elm_panel_scrollable_set(eo, EINA_TRUE); + elm_panel_scrollable_content_size_set(eo, 1.0); + elm_panel_hidden_set(eo, EINA_TRUE); + elm_panel_orient_set(eo, ELM_PANEL_ORIENT_BOTTOM); show(*m_panel); m_panel->addEventHandler(impl::EVENT_SCROLL, @@ -270,16 +273,17 @@ namespace callui { Result RejectMsgPresenter::createPanelBg() { - m_panelBg = makeShared( - evas_object_rectangle_add(evas_object_evas_get(*m_widget)), - false); - if (!m_panelBg) { + Evas_Object *const eo = evas_object_rectangle_add( + evas_object_evas_get(as_eo(*m_widget))); + if (!eo) { LOG_RETURN(RES_FAIL, "evas_object_rectangle_add() failed!"); } + + m_panelBg = makeShared(eo); m_panelBg->setColor(0, 0); show(*m_panelBg); - m_widget->setContent(m_panelBg->getEo(), impl::PART_SWL_BG); + m_widget->setContent(*m_panelBg, impl::PART_SWL_BG); return RES_OK; } @@ -292,6 +296,7 @@ namespace callui { if (!m_panelLy) { LOG_RETURN(RES_FAIL, "Layout::build failed!"); } + m_panel->setContent(*m_panelLy); return RES_OK; @@ -299,7 +304,7 @@ namespace callui { Result RejectMsgPresenter::createCircleSurfaceLy() { - auto circleLy = Layout::Builder(). + const auto circleLy = Layout::Builder(). setIsOwner(false). build(*m_panelLy); if (!circleLy) { @@ -307,7 +312,7 @@ namespace callui { } m_panelLy->setContent(*circleLy, impl::PART_SWL_SCROLLER); - m_circleSurface = eext_circle_surface_layout_add(*circleLy); + m_circleSurface = eext_circle_surface_layout_add(as_eo(*circleLy)); if (!m_circleSurface) { LOG_RETURN(RES_FAIL, "eext_circle_surface_layout_add() failed!"); } @@ -321,7 +326,7 @@ namespace callui { FAIL_RETURN(makeListItems(), "makeListItems() failed!"); - registerGenlistAtspiGestureCallbacks(); + registerListItemsAo(); return RES_OK; } @@ -332,6 +337,9 @@ namespace callui { m_circleEo = nullptr; + m_firstItem.reset(); + m_lastItem.reset(); + m_listPresenter.reset(); } @@ -347,7 +355,7 @@ namespace callui { impl::PART_SWL_CONTENT); m_circleEo = eext_circle_object_genlist_add( - m_listPresenter->getWidget(), m_circleSurface); + as_eo(m_listPresenter->getWidget()), m_circleSurface); if (!m_circleEo) { LOG_RETURN(RES_FAIL, "elm_genlist_add() failed!"); } @@ -361,16 +369,23 @@ namespace callui { Result RejectMsgPresenter::makeListItems() { - FAIL_RETURN(m_listPresenter->append( - *makeTitleListItem(STR_DECLINE_MESSAGES)), + m_firstItem = makeTitleListItem(STR_DECLINE_MESSAGES); + FAIL_RETURN(m_listPresenter->append(*m_firstItem), "m_listPresenter->append failed!"); auto msgList = m_provider->getMsgList(); - for (auto &iter : msgList) { - FAIL_RETURN(m_listPresenter->append( - *RejectMsgListItem::newInstance(iter, - WEAK_DELEGATE_THIS(onRejectMsgListItemSelect))), + const int listSize = msgList.size(); + + for (int i = 0 ; i < listSize; i++) { + RejectMsgListItemSRef rmItem = RejectMsgListItem::newInstance( + msgList[i], + WEAK_DELEGATE_THIS(onRejectMsgListItemSelect)); + FAIL_RETURN(m_listPresenter->append(*rmItem), "m_listPresenter->append failed!"); + + if (i == listSize - 1) { + m_lastItem = rmItem; + } } FAIL_RETURN(m_listPresenter->append(*makePaddingListItem()), @@ -406,7 +421,7 @@ namespace callui { DLOG(); if (m_state != State::SHOWN) { DLOG("Panel state [NOT SHOWN]"); - elm_panel_hidden_set(m_panel->getEo(), EINA_FALSE); + elm_panel_hidden_set(as_eo(*m_panel), EINA_FALSE); } } @@ -415,8 +430,8 @@ namespace callui { DLOG(); if (m_state == State::SHOWN) { DLOG("Panel state [SHOWN]"); - elm_object_scroll_freeze_pop(m_panel->getEo()); - elm_panel_hidden_set(m_panel->getEo(), EINA_TRUE); + elm_object_scroll_freeze_pop(as_eo(*m_panel)); + elm_panel_hidden_set(as_eo(*m_panel), EINA_TRUE); } } @@ -446,76 +461,61 @@ namespace callui { } } - Elm_Interface_Atspi_Accessible *RejectMsgPresenter::getFirstAo() - { - return (m_listPresenter ? - elm_genlist_first_item_get(m_listPresenter->getWidget()) : - nullptr); - } - - Elm_Interface_Atspi_Accessible *RejectMsgPresenter::getLastAo() - { - return (m_listPresenter ? - elm_genlist_last_item_get(m_listPresenter->getWidget()) : - nullptr); - } - Result RejectMsgPresenter::createAtspiHighlightHelper() { - m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow()); + m_atspiHelper = AtspiHighlightHelper::newInstance(*this); if (!m_atspiHelper) { LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!"); } - m_atspiHelper->setRelationEventHandler( - WEAK_DELEGATE_THIS(onAtspiHighlight)); + m_atspiHelper->registerObject(getWindow()); + + m_atspiHelper->setEventHandler(WEAK_DELEGATE_THIS(onAtspiHighlight)); return RES_OK; } - void RejectMsgPresenter::registerGenlistAtspiGestureCallbacks() + void RejectMsgPresenter::registerListItemsAo() { - auto item = getFirstAo(); - elm_atspi_accessible_gesture_cb_set(item, - CALLBACK_A(RejectMsgPresenter::onAtspiGesture), this); + if (m_firstItem) { + m_atspiHelper->registerObject(*m_firstItem); + } - item = getLastAo(); - elm_atspi_accessible_gesture_cb_set(item, - CALLBACK_A(RejectMsgPresenter::onAtspiGesture), this); + if (m_lastItem) { + m_atspiHelper->registerObject(*m_lastItem); + } } - Elm_Interface_Atspi_Accessible *RejectMsgPresenter::onAtspiHighlight( - Elm_Interface_Atspi_Accessible *ao, + const Elm_Interface_Atspi_Accessible *RejectMsgPresenter::onAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, Elm_Atspi_Relation_Type flowRelation) { DLOG("ENTER"); - DLOG("FlowRelation [%s]", - flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ? - "FROM" : - "TO"); + const Elm_Interface_Atspi_Accessible * firstListAo = nullptr; + if (m_firstItem) { + firstListAo = as_ao(*m_firstItem); + } + const Elm_Interface_Atspi_Accessible * lastListAo = nullptr; + if (m_lastItem) { + lastListAo = as_ao(*m_lastItem); + } - if (ao == getFirstAo()) { + if (ao == firstListAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { return nullptr; } - } else if (ao == getLastAo()) { + } else if (ao == lastListAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { return nullptr; } - } else if (ao == getWindow()) { - return getFirstAo(); + } else if (ao == as_ao(getWindow())) { + return firstListAo; } else { LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!"); } - return ao; - } - Eina_Bool RejectMsgPresenter::onAtspiGesture( - Elm_Atspi_Gesture_Info gestureInfo, - Elm_Interface_Atspi_Accessible *ao) - { - return toEina(m_atspiHelper->handleGesture(ao, gestureInfo)); + return ao; } } diff --git a/call-ui/presenters/misc/RejectMsgPresenter.h b/call-ui/presenters/misc/RejectMsgPresenter.h index e52803d..48fccb5 100644 --- a/call-ui/presenters/misc/RejectMsgPresenter.h +++ b/call-ui/presenters/misc/RejectMsgPresenter.h @@ -172,14 +172,9 @@ namespace callui { void onBackKey(Evas_Object *obj, void *eventInfo); ucl::Result createAtspiHighlightHelper(); - void registerGenlistAtspiGestureCallbacks(); - Elm_Interface_Atspi_Accessible *getFirstAo(); - Elm_Interface_Atspi_Accessible *getLastAo(); - Eina_Bool onAtspiGesture( - Elm_Atspi_Gesture_Info gestureInfo, - Elm_Interface_Atspi_Accessible *ao); - Elm_Interface_Atspi_Accessible *onAtspiHighlight( - Elm_Interface_Atspi_Accessible *ao, + void registerListItemsAo(); + const Elm_Interface_Atspi_Accessible *onAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, Elm_Atspi_Relation_Type flowRelation); // GuiPresenter // @@ -193,6 +188,8 @@ namespace callui { const SelectHandler m_selectHandler; ucl::ListPresenterSRef m_listPresenter; + ucl::ListItemPresenterSRef m_firstItem; + ucl::ListItemPresenterSRef m_lastItem; ucl::LayoutSRef m_widget; ucl::StyledWidgetSRef m_panel; diff --git a/call-ui/presenters/pages/KeypadPage.cpp b/call-ui/presenters/pages/KeypadPage.cpp index f36d126..2911c99 100644 --- a/call-ui/presenters/pages/KeypadPage.cpp +++ b/call-ui/presenters/pages/KeypadPage.cpp @@ -230,8 +230,8 @@ namespace callui { DLOG("Button pressed [%c]", *(info->str)); if (info->type == impl::OperationType::DTMF) { - elm_entry_entry_append(*m_entry, info->str); - elm_entry_cursor_end_set(*m_entry); + elm_entry_entry_append(as_eo(*m_entry), info->str); + elm_entry_cursor_end_set(as_eo(*m_entry)); startDtmf(*(info->str)); } } @@ -254,7 +254,7 @@ namespace callui { show(*m_vc); startVCTimer(); - elm_atspi_component_highlight_grab(*m_vc); + m_vc->getAtspi().highlight(); } } @@ -263,14 +263,13 @@ namespace callui { m_widget = Layout::Builder(). setTheme(impl::LAYOUT_KEYPAD_WIDGET). build(getNaviframe()); - if (!m_widget) { LOG_RETURN(RES_FAIL, "Layout::build() failed!"); } // RTL support - elm_object_mirrored_automatic_set(*m_widget, EINA_FALSE); - elm_object_mirrored_set(*m_widget, false); + elm_object_mirrored_automatic_set(as_eo(*m_widget), EINA_FALSE); + elm_object_mirrored_set(as_eo(*m_widget), false); setDeactivatorSink(m_widget); @@ -279,7 +278,7 @@ namespace callui { ucl::Result KeypadPage::createEntry() { - Evas_Object *entry = elm_entry_add(*m_widget); + Evas_Object *const entry = elm_entry_add(as_eo(*m_widget)); if (!entry) { LOG_RETURN(RES_FAIL, "elm_entry_add() failed!"); } @@ -296,7 +295,7 @@ namespace callui { elm_entry_markup_filter_append(entry, elm_entry_filter_accept_set, &digitsFilterData); - m_widget->setContent(entry, impl::PART_SWL_ENTRY); + m_widget->setContent(*m_entry, impl::PART_SWL_ENTRY); show(*m_entry); return RES_OK; @@ -308,8 +307,7 @@ namespace callui { StyledWidgetSRef buttonSRef; for (int i = 0; i < impl::KEYPAD_BTN_MAX_COUNT; ++i) { - button = elm_button_add(*m_widget); - + button = elm_button_add(as_eo(*m_widget)); if (!button) { LOG_RETURN(RES_FAIL, "elm_button_add() failed!"); } @@ -330,27 +328,20 @@ namespace callui { WEAK_DELEGATE_THIS(onBtnClicked)); // RTL support - elm_object_mirrored_automatic_set(*buttonSRef, EINA_FALSE); - elm_object_mirrored_set(*buttonSRef, false); + elm_object_mirrored_automatic_set(button, EINA_FALSE); + elm_object_mirrored_set(button, false); } // Screen Reader - elm_atspi_accessible_name_cb_set(*buttonSRef, - [](void *data, Evas_Object *obj) -> char * - { - impl::ButtonInfo *info = - static_cast(asWidget(obj)-> - getData(impl::BTN_DATA_KEY)); - if (info->type == impl::OperationType::DTMF) { - return strdup(info->str); - } else { - return strdup(STR_VOLUME.translate()); - } - return nullptr; - }, - this); - - m_widget->setContent(button, impl::buttonsInfo[i].swlPart); + auto &atspi = buttonSRef->getAtspi(); + atspi.setTDomain(TEXT_DOMAIN); + if (impl::buttonsInfo[i].type == impl::OperationType::DTMF) { + atspi.setName(impl::buttonsInfo[i].str); + } else { + atspi.setName(STR_VOLUME); + } + + m_widget->setContent(*buttonSRef, impl::buttonsInfo[i].swlPart); show(*buttonSRef); } @@ -380,7 +371,7 @@ namespace callui { setEventHandler(WEAK_DELEGATE_THIS(onVolumeControlEventCb)). build(*m_widget); if (!m_vc) { - LOG_RETURN(RES_FAIL, "VolumeControl::build() failed"); + LOG_RETURN(RES_FAIL, "VolumeControl::build() failed!"); } auto window = m_vc->getWindow(); @@ -583,71 +574,70 @@ namespace callui { Result KeypadPage::createAtspiHighlightHelper() { - m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow()); + m_atspiHelper = AtspiHighlightHelper::newInstance(*this); if (!m_atspiHelper) { LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!"); } - m_atspiHelper->setRelationEventHandler( + m_atspiHelper->setEventHandler( WEAK_DELEGATE_THIS(onAtspiHighlight)); - m_atspiHelper->registerWidget(*getFirstButton()); - m_atspiHelper->registerWidget(*getLastButton()); - m_atspiHelper->registerWidget(*m_vc.get()); - m_atspiHelper->registerWidget(*m_vc->getDecreaseBtn()); - m_atspiHelper->registerWidget(*m_vc->getIncreaseBtn()); - m_atspiHelper->registerWidget(*m_vc->getValueTxtAo()); + m_atspiHelper->registerObject(getWindow()); + m_atspiHelper->registerObject(*getFirstButton()); + m_atspiHelper->registerObject(*getLastButton()); + m_atspiHelper->registerObject(*m_vc.get()); + m_atspiHelper->registerObject(*m_vc->getDecreaseBtn()); + m_atspiHelper->registerObject(*m_vc->getIncreaseBtn()); + m_atspiHelper->registerObject(*m_vc->getValueTxtAo()); return RES_OK; } - Elm_Interface_Atspi_Accessible *KeypadPage::onAtspiHighlight( - Elm_Interface_Atspi_Accessible *ao, + const Elm_Interface_Atspi_Accessible *KeypadPage::onAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, Elm_Atspi_Relation_Type flowRelation) { - DLOG("FlowRelation [%s]", - flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ? - "FROM" : "TO"); + DLOG(); - auto firstBtn = getFirstButton(); - auto lastBtn = getLastButton(); - auto vcLayout = m_vc.get(); - auto vcDecrVolumeBtn = m_vc->getDecreaseBtn(); - auto vcIncrVolumeBtn = m_vc->getIncreaseBtn(); - auto vcVolumeValueAo = m_vc->getValueTxtAo(); + auto firstBtnAo = utils::getAo(getFirstButton()); + auto lastBtnAo = utils::getAo(getLastButton()); + auto vcLayoutAo = utils::getAo(m_vc.get()); + auto vcDecrVolumeBtnAo = utils::getAo(m_vc->getDecreaseBtn()); + auto vcIncrVolumeBtnAo = utils::getAo(m_vc->getIncreaseBtn()); + auto vcVolumeValueAo = utils::getAo(m_vc->getValueTxtAo()); - if (firstBtn && ao == *firstBtn) { + if (firstBtnAo && ao == firstBtnAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { return nullptr; } - } else if (lastBtn && ao == *lastBtn) { + } else if (lastBtnAo && ao == lastBtnAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { return nullptr; } - } else if (ao == *vcLayout) { + } else if (ao == vcLayoutAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *vcDecrVolumeBtn; + return vcDecrVolumeBtnAo; } - } else if (ao == *vcDecrVolumeBtn) { + } else if (ao == vcDecrVolumeBtnAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *vcVolumeValueAo; + return vcVolumeValueAo; } else { - return *vcLayout; + return vcLayoutAo; } - } else if (ao == *vcVolumeValueAo) { + } else if (ao == vcVolumeValueAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *vcIncrVolumeBtn; + return vcIncrVolumeBtnAo; } else { - return *vcDecrVolumeBtn; + return vcDecrVolumeBtnAo; } - } else if (ao == *vcIncrVolumeBtn) { + } else if (ao == vcIncrVolumeBtnAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { - return *vcVolumeValueAo; + return vcVolumeValueAo; } - } else if (ao == getWindow()) { - if (firstBtn) { - return *firstBtn; + } else if (ao == as_ao(getWindow())) { + if (firstBtnAo) { + return firstBtnAo; } } else { LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!"); diff --git a/call-ui/presenters/pages/KeypadPage.h b/call-ui/presenters/pages/KeypadPage.h index f587587..5938aa8 100644 --- a/call-ui/presenters/pages/KeypadPage.h +++ b/call-ui/presenters/pages/KeypadPage.h @@ -117,8 +117,8 @@ namespace callui { void unregisterCallbacks(); ucl::Result createAtspiHighlightHelper(); - Elm_Interface_Atspi_Accessible *onAtspiHighlight( - Elm_Interface_Atspi_Accessible *ao, + const Elm_Interface_Atspi_Accessible *onAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, Elm_Atspi_Relation_Type flowRelation); ucl::ElmWidget *getFirstButton(); ucl::ElmWidget *getLastButton(); diff --git a/call-ui/presenters/pages/MainPage.cpp b/call-ui/presenters/pages/MainPage.cpp index 51dd8e4..da99bd9 100644 --- a/call-ui/presenters/pages/MainPage.cpp +++ b/call-ui/presenters/pages/MainPage.cpp @@ -45,10 +45,9 @@ namespace callui { namespace { namespace impl { constexpr EdjePart PART_SWL_BOTTOM_BTN {"swl.bottom_btn"}; constexpr EdjePart PART_SWL_OVERLAY {"swl.overlay"}; constexpr EdjePart PART_SWL_MORE_OPTION {"swl.more_option"}; - + constexpr EdjePart PART_TXT_REJECT_MSG {"reject_msg_text"}; constexpr EdjePart PART_TXT_REJECT_MSG_CUE_AO {"ao_cue"}; - constexpr EdjePart PART_TXT_REJECT_MSG {"reject_msg_text"}; constexpr ElmStyle STYLE_BB_END_CALL {"callui/end_call"}; constexpr ElmStyle STYLE_BB_RECALL {"callui/call_back"}; }}} @@ -251,7 +250,7 @@ namespace callui { Result MainPage::processEndCallMode() { FAIL_RETURN(createAccessoryPresenter(), - "createAccessoryPresenter() failed"); + "createAccessoryPresenter() failed!"); auto end = m_cm->getEndCall(); if (end) { @@ -261,7 +260,7 @@ namespace callui { !(info->getPhoneNumber().empty() && !info->isEmergency())) { FAIL_RETURN(createBottomBtn(impl::STYLE_BB_RECALL, false), - "createBottomBtn() failed"); + "createBottomBtn() failed!"); hide(*m_bottomBtn); } } else { @@ -281,11 +280,11 @@ namespace callui { m_rmCueAo.reset(); FAIL_RETURN(createAccessoryPresenter(), - "createAccessoryPresenter() failed"); + "createAccessoryPresenter() failed!"); FAIL_RETURN(createMoreOptionsPresenter(), - "createMoreOptionsPresenter() failed"); + "createMoreOptionsPresenter() failed!"); FAIL_RETURN(createBottomBtn(impl::STYLE_BB_END_CALL), - "createBottomBtn() failed"); + "createBottomBtn() failed!"); return RES_OK; } @@ -343,17 +342,21 @@ namespace callui { Result MainPage::createBottomBtn(const ElmStyle &style, bool setVisible) { - m_bottomBtn = makeShared(elm_button_add(*m_widget)); + Evas_Object *const eo = elm_button_add(as_eo(*m_widget)); + if (!eo) { + LOG_RETURN(RES_FAIL, "elm_button_add() failed!"); + } + m_bottomBtn = makeShared(eo); m_bottomBtn->setStyle(style); - m_bottomBtn->addEventHandler(BTN_CLICKED, WEAK_DELEGATE_THIS(MainPage::onBottomBtnClicked)); - elm_atspi_accessible_translation_domain_set(*m_bottomBtn, TEXT_DOMAIN); + auto &atspi = m_bottomBtn->getAtspi(); + atspi.setTDomain(TEXT_DOMAIN); if (style == impl::STYLE_BB_RECALL) { - elm_atspi_accessible_name_set(*m_bottomBtn, AO_STR_CALLBACK); + atspi.setName(AO_STR_CALLBACK); } else { - elm_atspi_accessible_name_set(*m_bottomBtn, AO_STR_END_CALL); + atspi.setName(AO_STR_END_CALL); } if (setVisible) { @@ -656,43 +659,44 @@ namespace callui { Result MainPage::createRejectMsgCueAo() { - m_rmCueAo = utils::createAccessObjectFromLyPart(*m_widget, - *m_rmLy, + m_rmCueAo = utils::createAccessObjectFromPart(*m_widget, *m_rmLy, impl::PART_TXT_REJECT_MSG_CUE_AO); if (!m_rmCueAo) { - LOG_RETURN(RES_FAIL, "createAccessObjectFromLyPart() failed!"); + LOG_RETURN(RES_FAIL, "createAccessObjectFromPart() failed!"); } - elm_atspi_accessible_translation_domain_set(*m_rmCueAo, TEXT_DOMAIN); - elm_atspi_accessible_reading_info_type_set(*m_rmCueAo, - ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | + + auto &atspi = m_rmCueAo->getAtspi(); + atspi.setTDomain(TEXT_DOMAIN); + atspi.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION); - elm_atspi_accessible_name_set(*m_rmCueAo, STR_DECLINE_MESSAGES); - elm_atspi_accessible_description_set(*m_rmCueAo, + atspi.setName(STR_DECLINE_MESSAGES); + atspi.setDescription( AO_STR_SWIPE_UP_WITH_TWO_FINGERS_TO_SEND_A_DECLINE_MESSAGE); - - elm_atspi_accessible_gesture_cb_set(*m_rmCueAo, - [](void *data, Elm_Atspi_Gesture_Info gesture, Evas_Object *obj) { - // TODO: ELM_ATSPI_GESTURE_TWO_FINGERS_HOVER must be replaced - if (gesture.type == ELM_ATSPI_GESTURE_TWO_FINGERS_HOVER) { - auto page = (MainPage *)data; - page->m_rmPrs->showPanel(); - return EINA_TRUE; - } - - return EINA_FALSE; - }, this); + atspi.addGestureHandler(WEAK_DELEGATE_THIS(onRejectMsgCueAoGestureCb)); return RES_OK; } + void MainPage::onRejectMsgCueAoGestureCb(Atspi &atspi, + AtspiGestureEventInfo &eventInfo) + { + // TODO: ELM_ATSPI_GESTURE_TWO_FINGERS_HOVER must be replaced + if (eventInfo.gestureInfo.type == ELM_ATSPI_GESTURE_TWO_FINGERS_HOVER) { + m_rmPrs->showPanel(); + eventInfo.preventDefault = true; + } + } + Result MainPage::createAtspiHighlightHelper() { - m_atspiHelper = AtspiHighlightHelper::newInstance(*this, getWindow()); + m_atspiHelper = AtspiHighlightHelper::newInstance(*this); if (!m_atspiHelper) { LOG_RETURN(RES_FAIL, "AtspiHighlightHelper::newInstance() failed!"); } + m_atspiHelper->registerObject(getWindow()); + switch (m_mode) { case CallMode::INCOMING: registerIncomingCallModeAo(); @@ -712,118 +716,99 @@ namespace callui { void MainPage::registerIncomingCallModeAo() { DLOG("ENTER"); - m_atspiHelper->setRelationEventHandler( + m_atspiHelper->setEventHandler( WEAK_DELEGATE_THIS(onIncomingCallModeAtspiHighlight)); - m_atspiHelper->setGestureEventHandler( - WEAK_DELEGATE_THIS(onIncomingModeAtspiGesture)); - - auto acceptAO = m_acceptRejectPrs->getAcceptAo(); - if (!acceptAO) { + auto acceptAo = m_acceptRejectPrs->getAcceptAo(); + if (!acceptAo) { DLOG("acceptAO is NULL"); } else { - m_atspiHelper->registerWidget(*acceptAO); + m_atspiHelper->registerObject(*acceptAo); } auto rejectAo = m_acceptRejectPrs->getRejectAo(); if (!rejectAo) { DLOG("rejectAo is NULL"); } else { - m_atspiHelper->registerWidget(*rejectAo); + m_atspiHelper->registerObject(*rejectAo); } auto statusTxtAo = m_callInfoPrs->getStatusTxtAo(); if (!statusTxtAo) { DLOG("statusTxtAo is NULL"); } else { - m_atspiHelper->registerWidget(*statusTxtAo); + m_atspiHelper->registerObject(*statusTxtAo); } auto mainTxtAo = m_callInfoPrs->getMainTxtAo(); if (!mainTxtAo) { DLOG("mainTxtAo is NULL"); } else { - m_atspiHelper->registerWidget(*mainTxtAo); + m_atspiHelper->registerObject(*mainTxtAo); } auto subTxtAo = m_callInfoPrs->getSubTxtAo(); if (!subTxtAo) { DLOG("subTxtAo is NULL"); } else { - m_atspiHelper->registerWidget(*subTxtAo); + m_atspiHelper->registerObject(*subTxtAo); } if (!m_rmCueAo) { DLOG("m_rmCueAo is NULL"); } else { - m_atspiHelper->registerWidget(*m_rmCueAo); + m_atspiHelper->registerObject(*m_rmCueAo); } DLOG("EXIT"); } - bool MainPage::onIncomingModeAtspiGesture(Elm_Interface_Atspi_Accessible *widget, - Elm_Atspi_Gesture_Type gestureType) - { - DLOG(" GESTURE TYPE [%d]", gestureType); - - if (m_rmCueAo && widget == *m_rmCueAo) { - if (gestureType == ELM_ATSPI_GESTURE_TWO_FINGERS_HOVER) { - m_rmPrs->showPanel(); - return true; - } - } - return false; - } - - Elm_Interface_Atspi_Accessible *MainPage::onIncomingCallModeAtspiHighlight( - Elm_Interface_Atspi_Accessible *ao, - Elm_Atspi_Relation_Type flowRelation) + const Elm_Interface_Atspi_Accessible * + MainPage::onIncomingCallModeAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, + Elm_Atspi_Relation_Type flowRelation) { - DLOG("FlowRelation [%s]", - flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ? - "FROM" : "TO"); - - auto acceptAo = m_acceptRejectPrs->getAcceptAo(); - auto rejectAo = m_acceptRejectPrs->getRejectAo(); - auto statusTxtAo = m_callInfoPrs->getStatusTxtAo(); - auto mainTxtAo = m_callInfoPrs->getMainTxtAo(); - auto subTxtAo = m_callInfoPrs->getSubTxtAo(); - - if (ao == *acceptAo) { + const auto acceptAo = utils::getAo(m_acceptRejectPrs->getAcceptAo()); + const auto rejectAo = utils::getAo(m_acceptRejectPrs->getRejectAo()); + const auto statusTxtAo = utils::getAo(m_callInfoPrs->getStatusTxtAo()); + const auto mainTxtAo = utils::getAo(m_callInfoPrs->getMainTxtAo()); + const auto subTxtAo = utils::getAo(m_callInfoPrs->getSubTxtAo()); + const auto rmCueAo = utils::getAo(m_rmCueAo.get()); + + if (ao == acceptAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *statusTxtAo; + return statusTxtAo; } - } else if (ao == *statusTxtAo) { + } else if (ao == statusTxtAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *mainTxtAo; + return mainTxtAo; } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { - return *acceptAo; + return acceptAo; } - } else if (ao == *mainTxtAo) { + } else if (ao == mainTxtAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return (subTxtAo) ? *subTxtAo : *rejectAo; + return (subTxtAo) ? subTxtAo : rejectAo; } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { - return *statusTxtAo; + return statusTxtAo; } - } else if (subTxtAo && ao == *subTxtAo) { + } else if (ao == subTxtAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *rejectAo; + return rejectAo; } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { - return *mainTxtAo; + return mainTxtAo; } - } else if (ao == *rejectAo) { + } else if (ao == rejectAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return m_rmCueAo ? *m_rmCueAo : ao; + return rmCueAo ? rmCueAo : ao; } else if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { - return (subTxtAo) ? *subTxtAo : *mainTxtAo; + return (subTxtAo) ? subTxtAo : mainTxtAo; } - } else if (m_rmCueAo && ao == *m_rmCueAo) { + } else if (ao == rmCueAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { - return *rejectAo; + return rmCueAo; } - } else if (ao == getWindow()) { - return *acceptAo; + } else if (ao == as_ao(getWindow())) { + return acceptAo; } else { LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!"); } @@ -834,177 +819,186 @@ namespace callui { void MainPage::registerActiveCallModeAo() { DLOG("ENTER"); - m_atspiHelper->setRelationEventHandler( + m_atspiHelper->setEventHandler( WEAK_DELEGATE_THIS(onActiveCallModeAtspiHighlight)); auto statusTxtAo = m_callInfoPrs->getStatusTxtAo(); if (!statusTxtAo) { DLOG("statusTxtAo is NULL"); } else { - m_atspiHelper->registerWidget(*statusTxtAo); + m_atspiHelper->registerObject(*statusTxtAo); } auto mainTxtAo = m_callInfoPrs->getMainTxtAo(); if (!mainTxtAo) { DLOG("mainTxtAo is NULL"); } else { - m_atspiHelper->registerWidget(*mainTxtAo); + m_atspiHelper->registerObject(*mainTxtAo); } auto subTxtAo = m_callInfoPrs->getSubTxtAo(); if (!subTxtAo) { DLOG("subTxtAo is NULL"); } else { - m_atspiHelper->registerWidget(*subTxtAo); + m_atspiHelper->registerObject(*subTxtAo); } auto volumeBtnAo = m_accessoryPrs->getVolumBtn(); if (!volumeBtnAo) { DLOG("volumeBtnAo is NULL"); } else { - m_atspiHelper->registerWidget(*volumeBtnAo); + m_atspiHelper->registerObject(*volumeBtnAo); } auto bluetoothBtnAo = m_accessoryPrs->getBluetoothBtn(); if (!bluetoothBtnAo) { DLOG("bluetoothBtnAo is NULL"); } else { - m_atspiHelper->registerWidget(*bluetoothBtnAo); + m_atspiHelper->registerObject(*bluetoothBtnAo); } auto muteBtnAo = m_accessoryPrs->getMuteBtn(); if (!muteBtnAo) { DLOG("muteBtnAo is NULL"); } else { - m_atspiHelper->registerWidget(*muteBtnAo); + m_atspiHelper->registerObject(*muteBtnAo); } auto moreOptCueAo = m_moreOptionsPrs->getCueAo(); if (!moreOptCueAo) { DLOG("moreCueAo is NULL"); } else { - m_atspiHelper->registerWidget(*moreOptCueAo); + m_atspiHelper->registerObject(*moreOptCueAo); } if (!m_bottomBtn) { DLOG("m_bottomBtn is NULL"); } else { - m_atspiHelper->registerWidget(*m_bottomBtn); + m_atspiHelper->registerObject(*m_bottomBtn); } auto vcLayout = m_accessoryPrs->getVolumeControlLy(); if (!vcLayout) { DLOG("vcLayout is NULL"); } else { - m_atspiHelper->registerWidget(*vcLayout); + m_atspiHelper->registerObject(*vcLayout); - m_atspiHelper->registerWidget(*m_accessoryPrs-> + m_atspiHelper->registerObject(*m_accessoryPrs-> getVolumeControlDecreaseBtn()); - m_atspiHelper->registerWidget(*m_accessoryPrs-> + m_atspiHelper->registerObject(*m_accessoryPrs-> getVolumeControlIncreaseBtn()); - m_atspiHelper->registerWidget(*m_accessoryPrs-> + m_atspiHelper->registerObject(*m_accessoryPrs-> getVolumeControlValueTxtAo()); } DLOG("EXIT"); } - Elm_Interface_Atspi_Accessible *MainPage::onActiveCallModeAtspiHighlight( - Elm_Interface_Atspi_Accessible *ao, - Elm_Atspi_Relation_Type flowRelation) + const Elm_Interface_Atspi_Accessible * + MainPage::onActiveCallModeAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, + Elm_Atspi_Relation_Type flowRelation) { - DLOG("FlowRelation [%s]", - flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ? - "FROM" : "TO"); - - auto statusTxtAo = m_callInfoPrs->getStatusTxtAo(); - auto mainTxtAo = m_callInfoPrs->getMainTxtAo(); - auto subTxtAo = m_callInfoPrs->getSubTxtAo(); - auto volumeBtnAo = m_accessoryPrs->getVolumBtn(); - auto bluetoothBtnAo = m_accessoryPrs->getBluetoothBtn(); - auto muteBtnAo = m_accessoryPrs->getMuteBtn(); - auto moreOptCueAo = m_moreOptionsPrs->getCueAo(); - auto vcLayout = m_accessoryPrs->getVolumeControlLy(); - auto vcDecrVolumeBtn = m_accessoryPrs->getVolumeControlDecreaseBtn(); - auto vcIncrVolumeBtn = m_accessoryPrs->getVolumeControlIncreaseBtn(); - auto vcVolumeValueAo = m_accessoryPrs->getVolumeControlValueTxtAo(); - - if (ao == *statusTxtAo) { + const auto statusTxtAo = + utils::getAo(m_callInfoPrs->getStatusTxtAo()); + const auto mainTxtAo = + utils::getAo(m_callInfoPrs->getMainTxtAo()); + const auto subTxtAo = + utils::getAo(m_callInfoPrs->getSubTxtAo()); + const auto volumeBtnAo = + utils::getAo(m_accessoryPrs->getVolumBtn()); + const auto bluetoothBtnAo = + utils::getAo(m_accessoryPrs->getBluetoothBtn()); + const auto muteBtnAo = + utils::getAo(m_accessoryPrs->getMuteBtn()); + const auto moreOptCueAo = + utils::getAo(m_moreOptionsPrs->getCueAo()); + const auto vcLayout = + utils::getAo(m_accessoryPrs->getVolumeControlLy()); + const auto vcDecrVolumeBtn = + utils::getAo(m_accessoryPrs->getVolumeControlDecreaseBtn()); + const auto vcIncrVolumeBtn = + utils::getAo(m_accessoryPrs->getVolumeControlIncreaseBtn()); + const auto vcVolumeValueAo = + utils::getAo(m_accessoryPrs->getVolumeControlValueTxtAo()); + const auto bottomBtnAo = utils::getAo(m_bottomBtn.get()); + + if (ao == statusTxtAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *mainTxtAo; + return mainTxtAo; } - } else if (ao == *mainTxtAo) { + } else if (ao == mainTxtAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { if (subTxtAo) { - return *subTxtAo; + return subTxtAo; } else { - return *volumeBtnAo; + return volumeBtnAo; } } else { - return *statusTxtAo; + return statusTxtAo; } - } else if (subTxtAo && ao == *subTxtAo) { + } else if (ao == subTxtAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *volumeBtnAo; + return volumeBtnAo; } else { - return *mainTxtAo; + return mainTxtAo; } - } else if (ao == *volumeBtnAo) { + } else if (ao == volumeBtnAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *bluetoothBtnAo; + return bluetoothBtnAo; } else { if (subTxtAo) { - return *subTxtAo; + return subTxtAo; } else { - return *mainTxtAo; + return mainTxtAo; } } - } else if (ao == *bluetoothBtnAo) { + } else if (ao == bluetoothBtnAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *muteBtnAo; + return muteBtnAo; } else { - return *volumeBtnAo; + return volumeBtnAo; } - } else if (ao == *muteBtnAo) { + } else if (ao == muteBtnAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *moreOptCueAo; + return moreOptCueAo; } else { - return *bluetoothBtnAo; + return bluetoothBtnAo; } - } else if (ao == *moreOptCueAo) { + } else if (ao == moreOptCueAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *m_bottomBtn; + return bottomBtnAo; } else { - return *muteBtnAo; + return muteBtnAo; } - } else if (ao == *m_bottomBtn) { + } else if (ao == bottomBtnAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { - return *moreOptCueAo; + return moreOptCueAo; } - } else if (ao == *vcLayout) { + } else if (ao == vcLayout) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *vcDecrVolumeBtn; + return vcDecrVolumeBtn; } - } else if (ao == *vcDecrVolumeBtn) { + } else if (ao == vcDecrVolumeBtn) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *vcVolumeValueAo; + return vcVolumeValueAo; } else { - return *vcLayout; + return vcLayout; } - } else if (ao == *vcVolumeValueAo) { + } else if (ao == vcVolumeValueAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *vcIncrVolumeBtn; + return vcIncrVolumeBtn; } else { - return *vcDecrVolumeBtn; + return vcDecrVolumeBtn; } - } else if (ao == *vcIncrVolumeBtn) { + } else if (ao == vcIncrVolumeBtn) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { - return *vcVolumeValueAo; + return vcVolumeValueAo; } - } else if (ao == getWindow()) { - return *statusTxtAo; + } else if (ao == as_ao(getWindow())) { + return statusTxtAo; } else { LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!"); } @@ -1014,81 +1008,84 @@ namespace callui { void MainPage::registerEndCallModeAo() { - m_atspiHelper->setRelationEventHandler( + m_atspiHelper->setEventHandler( WEAK_DELEGATE_THIS(onEndCallModeAtspiHighlight)); auto statusTxtAo = m_callInfoPrs->getStatusTxtAo(); if (!statusTxtAo) { DLOG("statusTxtAo is NULL"); } else { - m_atspiHelper->registerWidget(*statusTxtAo); + m_atspiHelper->registerObject(*statusTxtAo); } auto mainTxtAo = m_callInfoPrs->getMainTxtAo(); if (!mainTxtAo) { DLOG("mainTxtAo is NULL"); } else { - m_atspiHelper->registerWidget(*mainTxtAo); + m_atspiHelper->registerObject(*mainTxtAo); } auto addContactsBtnAo = m_accessoryPrs->getAddContactBtn(); if (!addContactsBtnAo) { DLOG("addContactsBtnAo is NULL"); } else { - m_atspiHelper->registerWidget(*addContactsBtnAo); + m_atspiHelper->registerObject(*addContactsBtnAo); } if (!m_bottomBtn) { DLOG("m_bottomBtn is NULL"); } else { - m_atspiHelper->registerWidget(*m_bottomBtn); + m_atspiHelper->registerObject(*m_bottomBtn); } DLOG("EXIT"); } - Elm_Interface_Atspi_Accessible *MainPage::onEndCallModeAtspiHighlight( - Elm_Interface_Atspi_Accessible *ao, - Elm_Atspi_Relation_Type flowRelation) + const Elm_Interface_Atspi_Accessible * + MainPage::onEndCallModeAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, + Elm_Atspi_Relation_Type flowRelation) { - DLOG("FlowRelation [%s]", - flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM ? - "FROM" : "TO"); + DLOG(); - auto statusTxtAo = m_callInfoPrs->getStatusTxtAo(); - auto mainTxtAo = m_callInfoPrs->getMainTxtAo(); - auto addContactsBtnAo = m_accessoryPrs->getAddContactBtn(); + const auto statusTxtAo = + utils::getAo(m_callInfoPrs->getStatusTxtAo()); + const auto mainTxtAo = + utils::getAo(m_callInfoPrs->getMainTxtAo()); + const auto addContactsBtnAo = + utils::getAo(m_accessoryPrs->getAddContactBtn()); + const auto bottomBtnAo = utils::getAo(m_bottomBtn.get()); - if (ao == *statusTxtAo) { + if (ao == statusTxtAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *mainTxtAo; + return mainTxtAo; } - } else if (ao == *mainTxtAo) { + } else if (ao == mainTxtAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { if (addContactsBtnAo) { - return *addContactsBtnAo; + return addContactsBtnAo; } else { - return *m_bottomBtn; + return bottomBtnAo; } } else { - return *statusTxtAo; + return statusTxtAo; } - } else if (addContactsBtnAo && ao == *addContactsBtnAo) { + } else if (ao == addContactsBtnAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_TO) { - return *m_bottomBtn; + return bottomBtnAo; } else { - return *mainTxtAo; + return mainTxtAo; } - } else if (ao == *m_bottomBtn) { + } else if (ao == bottomBtnAo) { if (flowRelation == ELM_ATSPI_RELATION_FLOWS_FROM) { if (addContactsBtnAo) { - return *addContactsBtnAo; + return addContactsBtnAo; } else { - return *mainTxtAo; + return mainTxtAo; } } - } else if (ao == getWindow()) { - return *statusTxtAo; + } else if (ao == as_ao(getWindow())) { + return statusTxtAo; } else { LOG_RETURN_VALUE(RES_FAIL, nullptr, "Unknown object!"); } diff --git a/call-ui/presenters/pages/MainPage.h b/call-ui/presenters/pages/MainPage.h index 3f58b82..c6654c0 100644 --- a/call-ui/presenters/pages/MainPage.h +++ b/call-ui/presenters/pages/MainPage.h @@ -130,22 +130,21 @@ namespace callui { void onExitAppRequest(); ucl::Result createRejectMsgCueAo(); + void onRejectMsgCueAoGestureCb(ucl::Atspi &atspi, + ucl::AtspiGestureEventInfo &eventInfo); ucl::Result createAtspiHighlightHelper(); void registerIncomingCallModeAo(); void registerActiveCallModeAo(); void registerEndCallModeAo(); - Elm_Interface_Atspi_Accessible *onIncomingCallModeAtspiHighlight( - Elm_Interface_Atspi_Accessible *widget, + const Elm_Interface_Atspi_Accessible *onIncomingCallModeAtspiHighlight( + const Elm_Interface_Atspi_Accessible *widget, Elm_Atspi_Relation_Type flowRelation); - Elm_Interface_Atspi_Accessible *onActiveCallModeAtspiHighlight( - Elm_Interface_Atspi_Accessible *widget, + const Elm_Interface_Atspi_Accessible *onActiveCallModeAtspiHighlight( + const Elm_Interface_Atspi_Accessible *widget, Elm_Atspi_Relation_Type flowRelation); - Elm_Interface_Atspi_Accessible *onEndCallModeAtspiHighlight( - Elm_Interface_Atspi_Accessible *ao, + const Elm_Interface_Atspi_Accessible *onEndCallModeAtspiHighlight( + const Elm_Interface_Atspi_Accessible *ao, Elm_Atspi_Relation_Type flowRelation); - bool onIncomingModeAtspiGesture( - Elm_Interface_Atspi_Accessible *widget, - Elm_Atspi_Gesture_Type gestureType); // Page // diff --git a/call-ui/view/AcceptRejectWidget.cpp b/call-ui/view/AcceptRejectWidget.cpp index 09b14db..9b1e93a 100644 --- a/call-ui/view/AcceptRejectWidget.cpp +++ b/call-ui/view/AcceptRejectWidget.cpp @@ -216,7 +216,7 @@ namespace callui { NotiHandler acceptHandler, NotiHandler rejectHandler, AcceptButtonType acceptBtnType): - ElmWidget(&rc, *layout, false), + ElmWidget(&rc, as_eo(*layout), false), m_accHandler(std::move(acceptHandler)), m_rejHandler(std::move(rejectHandler)), m_layout(layout.get()), @@ -279,7 +279,7 @@ namespace callui { DEL_TRANSIT(m_rejGuideTr); DEL_TRANSIT(m_rejIconTr); - eext_rotary_object_event_callback_del(*m_layout, CALLBACK_A( + eext_rotary_object_event_callback_del(as_eo(*m_layout), CALLBACK_A( AcceptRejectWidget::onRotaryEvent)); } @@ -294,7 +294,7 @@ namespace callui { FAIL_RETURN_VOID(createBezelCueComponents(), "createBezelCueImages() failed!"); - eext_rotary_object_event_callback_add(*m_layout, CALLBACK_A( + eext_rotary_object_event_callback_add(as_eo(*m_layout), CALLBACK_A( AcceptRejectWidget::onRotaryEvent), this); } @@ -302,7 +302,7 @@ namespace callui { { m_accTracer = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG); if (!m_accTracer) { - LOG_RETURN(RES_FAIL, "createImage() failed"); + LOG_RETURN(RES_FAIL, "createImage() failed!"); } m_accTracer->setColor(CU_COL_TRANSPARENT); m_layout->setContent(*m_accTracer, @@ -310,7 +310,7 @@ namespace callui { m_accGuide = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG); if (!m_accGuide) { - LOG_RETURN(RES_FAIL, "createImage() failed"); + LOG_RETURN(RES_FAIL, "createImage() failed!"); } m_accGuide->setColor(CU_COL_TRANSPARENT); m_layout->setContent(*m_accGuide, @@ -327,7 +327,7 @@ namespace callui { break; } if (!m_accIcon) { - LOG_RETURN(RES_FAIL, "createImage() failed"); + LOG_RETURN(RES_FAIL, "createImage() failed!"); } m_accIcon->setColor(CU_COL_AO0113); m_layout->setContent(*m_accIcon, @@ -356,7 +356,7 @@ namespace callui { { m_rejTracer = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG); if (!m_rejTracer) { - LOG_RETURN(RES_FAIL, "createImage() failed"); + LOG_RETURN(RES_FAIL, "createImage() failed!"); } m_rejTracer->setColor(CU_COL_TRANSPARENT); m_layout->setContent(*m_rejTracer, @@ -364,7 +364,7 @@ namespace callui { m_rejGuide = impl::createImage(*m_layout, impl::LAYOUT_IMG_ACTION_BG); if (!m_rejGuide) { - LOG_RETURN(RES_FAIL, "createImage() failed"); + LOG_RETURN(RES_FAIL, "createImage() failed!"); } m_rejGuide->setColor(CU_COL_TRANSPARENT); m_layout->setContent(*m_rejGuide, @@ -372,7 +372,7 @@ namespace callui { m_rejIcon = impl::createImage(*m_layout, impl::LAYOUT_IMG_REJECT); if (!m_rejIcon) { - LOG_RETURN(RES_FAIL, "createImage() failed"); + LOG_RETURN(RES_FAIL, "createImage() failed!"); } m_rejIcon->setColor(CU_COL_AO0115); m_layout->setContent(*m_rejIcon, @@ -431,13 +431,13 @@ namespace callui { needTransition = false; } - if (widget == *m_accEventLy) { + if (as_eo(widget) == as_eo(*m_accEventLy)) { DLOG("Accept button down"); m_isAccPressed = true; if (needTransition) { setAcceptPressedState(); } - } else if (widget == *m_rejEventLy) { + } else if (as_eo(widget) == as_eo(*m_rejEventLy)) { DLOG("Reject button down"); m_isRejPressed = true; if (needTransition) { @@ -470,14 +470,14 @@ namespace callui { m_lastMoveDistance = impl::INIT_MOVE_DISTANCE_VAL; - if (widget == *m_accEventLy) { + if (as_eo(widget) == as_eo(*m_accEventLy)) { if (m_isAccPressed) { DLOG("Accept button released"); setAcceptUnpressedState(); } else { LOG_RETURN_VOID(RES_FAIL, "Accept button was not pressed"); } - } else if (widget == *m_rejEventLy) { + } else if (as_eo(widget) == as_eo(*m_rejEventLy)) { if (m_isRejPressed) { DLOG("Reject button released"); setRejectUnpressedState(); @@ -518,12 +518,12 @@ namespace callui { } ElmWidgetSRef img; - if (widget == *m_accEventLy) { + if (as_eo(widget) == as_eo(*m_accEventLy)) { if (!m_isAccPressed) { LOG_RETURN_VOID(RES_FAIL, "Down callback is not come"); } img = m_accTracer; - } else if (widget == *m_rejEventLy) { + } else if (as_eo(widget) == as_eo(*m_rejEventLy)) { if (!m_isRejPressed) { LOG_RETURN_VOID(RES_FAIL, "Down callback is not come"); } @@ -578,7 +578,7 @@ namespace callui { m_accBCAnimIndex = impl::BC_ITEM_COUNT - 1; Elm_Transit *tr1 = elm_transit_add(); elm_transit_effect_color_add(tr1, CU_COL_AO0113D, CU_COL_AO0113); - elm_transit_object_add(tr1, *m_accBezelCueImg[m_accBCAnimIndex]); + elm_transit_object_add(tr1, as_eo(*m_accBezelCueImg[m_accBCAnimIndex])); elm_transit_duration_set(tr1, impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]); elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE); @@ -591,7 +591,7 @@ namespace callui { m_rejBCAnimIndex = impl::BC_ITEM_COUNT - 1; Elm_Transit *tr2 = elm_transit_add(); elm_transit_effect_color_add(tr2, CU_COL_AO0115D, CU_COL_AO0115); - elm_transit_object_add(tr2, *m_rejBezelCueImg[m_rejBCAnimIndex]); + elm_transit_object_add(tr2, as_eo(*m_rejBezelCueImg[m_rejBCAnimIndex])); elm_transit_duration_set(tr2, impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]); elm_transit_objects_final_state_keep_set(tr2, EINA_TRUE); @@ -618,7 +618,7 @@ namespace callui { m_accTracerTr = elm_transit_add(); elm_transit_effect_zoom_add(m_accTracerTr, impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MID); - elm_transit_object_add(m_accTracerTr, *m_accTracer); + elm_transit_object_add(m_accTracerTr, as_eo(*m_accTracer)); elm_transit_duration_set(m_accTracerTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_accTracerTr, EINA_FALSE); elm_transit_del_cb_set(m_accTracerTr, @@ -633,7 +633,7 @@ namespace callui { m_accGuideTr = elm_transit_add(); elm_transit_effect_zoom_add(m_accGuideTr, impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX); - elm_transit_object_add(m_accGuideTr, *m_accGuide); + elm_transit_object_add(m_accGuideTr, as_eo(*m_accGuide)); elm_transit_duration_set(m_accGuideTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_accGuideTr, EINA_FALSE); elm_transit_del_cb_set(m_accGuideTr, @@ -647,7 +647,7 @@ namespace callui { DEL_TRANSIT(m_accIconTr); m_accIconTr = elm_transit_add(); elm_transit_effect_color_add(m_accIconTr, CU_COL_AO0113, CU_COL_WHITE); - elm_transit_object_add(m_accIconTr, *m_accIcon); + elm_transit_object_add(m_accIconTr, as_eo(*m_accIcon)); elm_transit_duration_set(m_accIconTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_accIconTr, EINA_TRUE); elm_transit_del_cb_set(m_accIconTr, @@ -684,7 +684,7 @@ namespace callui { m_rejIconTr = elm_transit_add(); elm_transit_effect_translation_add(m_rejIconTr, 0, 0, animTrace, 0); - elm_transit_object_add(m_rejIconTr, *m_rejIcon); + elm_transit_object_add(m_rejIconTr, as_eo(*m_rejIcon)); elm_transit_duration_set(m_rejIconTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_rejIconTr, EINA_TRUE); elm_transit_del_cb_set(m_rejIconTr, @@ -699,7 +699,7 @@ namespace callui { m_accTracerTr = elm_transit_add(); elm_transit_effect_zoom_add(m_accTracerTr, impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX); - elm_transit_object_add(m_accTracerTr, *m_accTracer); + elm_transit_object_add(m_accTracerTr, as_eo(*m_accTracer)); elm_transit_duration_set(m_accTracerTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_accTracerTr, EINA_FALSE); elm_transit_del_cb_set(m_accTracerTr, @@ -715,7 +715,7 @@ namespace callui { m_accGuideTr = elm_transit_add(); elm_transit_effect_zoom_add(m_accGuideTr, impl::ICON_ZOOM_EFF_VAL_MAX, impl::ICON_ZOOM_EFF_VAL_MIN); - elm_transit_object_add(m_accGuideTr, *m_accGuide); + elm_transit_object_add(m_accGuideTr, as_eo(*m_accGuide)); elm_transit_duration_set(m_accGuideTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_accGuideTr, EINA_FALSE); elm_transit_del_cb_set(m_accGuideTr, @@ -750,7 +750,7 @@ namespace callui { m_rejIconTr = elm_transit_add(); elm_transit_effect_translation_add(m_rejIconTr, 0, 0, dx, 0); - elm_transit_object_add(m_rejIconTr, *m_rejIcon); + elm_transit_object_add(m_rejIconTr, as_eo(*m_rejIcon)); elm_transit_duration_set(m_rejIconTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_rejIconTr, EINA_TRUE); elm_transit_del_cb_set(m_rejIconTr, @@ -781,7 +781,7 @@ namespace callui { m_rejTracerTr = elm_transit_add(); elm_transit_effect_zoom_add(m_rejTracerTr, impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MID); - elm_transit_object_add(m_rejTracerTr, *m_rejTracer); + elm_transit_object_add(m_rejTracerTr, as_eo(*m_rejTracer)); elm_transit_duration_set(m_rejTracerTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_rejTracerTr, EINA_FALSE); elm_transit_del_cb_set(m_rejTracerTr, @@ -796,7 +796,7 @@ namespace callui { m_rejGuideTr = elm_transit_add(); elm_transit_effect_zoom_add(m_rejGuideTr, impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX); - elm_transit_object_add(m_rejGuideTr, *m_rejGuide); + elm_transit_object_add(m_rejGuideTr, as_eo(*m_rejGuide)); elm_transit_duration_set(m_rejGuideTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_rejGuideTr, EINA_FALSE); elm_transit_del_cb_set(m_rejGuideTr, @@ -810,7 +810,7 @@ namespace callui { DEL_TRANSIT(m_rejIconTr); m_rejIconTr = elm_transit_add(); elm_transit_effect_color_add(m_rejIconTr, CU_COL_AO0115, CU_COL_WHITE); - elm_transit_object_add(m_rejIconTr, *m_rejIcon); + elm_transit_object_add(m_rejIconTr, as_eo(*m_rejIcon)); elm_transit_duration_set(m_rejIconTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_rejIconTr, EINA_TRUE); elm_transit_del_cb_set(m_rejIconTr, @@ -847,7 +847,7 @@ namespace callui { m_accIconTr = elm_transit_add(); elm_transit_effect_translation_add(m_accIconTr, 0, 0, animTrace, 0); - elm_transit_object_add(m_accIconTr, *m_accIcon); + elm_transit_object_add(m_accIconTr, as_eo(*m_accIcon)); elm_transit_duration_set(m_accIconTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_accIconTr, EINA_TRUE); elm_transit_del_cb_set(m_accIconTr, @@ -881,7 +881,7 @@ namespace callui { m_accIconTr = elm_transit_add(); elm_transit_effect_translation_add(m_accIconTr, 0, 0, dx, 0); - elm_transit_object_add(m_accIconTr, *m_accIcon); + elm_transit_object_add(m_accIconTr, as_eo(*m_accIcon)); elm_transit_duration_set(m_accIconTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_accIconTr, EINA_TRUE); elm_transit_del_cb_set(m_accIconTr, @@ -896,7 +896,7 @@ namespace callui { m_rejTracerTr = elm_transit_add(); elm_transit_effect_zoom_add(m_rejTracerTr, impl::ICON_ZOOM_EFF_VAL_MIN, impl::ICON_ZOOM_EFF_VAL_MAX); - elm_transit_object_add(m_rejTracerTr, *m_rejTracer); + elm_transit_object_add(m_rejTracerTr, as_eo(*m_rejTracer)); elm_transit_duration_set(m_rejTracerTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_rejTracerTr, EINA_FALSE); elm_transit_del_cb_set(m_rejTracerTr, @@ -918,7 +918,7 @@ namespace callui { m_rejGuideTr = elm_transit_add(); elm_transit_effect_zoom_add(m_rejGuideTr, impl::ICON_ZOOM_EFF_VAL_MAX, impl::ICON_ZOOM_EFF_VAL_MIN); - elm_transit_object_add(m_rejGuideTr, *m_rejGuide); + elm_transit_object_add(m_rejGuideTr, as_eo(*m_rejGuide)); elm_transit_duration_set(m_rejGuideTr, impl::ROTARY_ACTION_ANIM_DUR); elm_transit_objects_final_state_keep_set(m_rejGuideTr, EINA_FALSE); elm_transit_del_cb_set(m_rejGuideTr, @@ -934,7 +934,7 @@ namespace callui { m_accBezelCueImg[i] = impl::createImage(*m_layout, impl::ACCEPT_BC_PARAMS[i].theme); if (!m_accBezelCueImg[i]) { - LOG_RETURN(RES_FAIL, "Create bezel cue image failed"); + LOG_RETURN(RES_FAIL, "Create bezel cue image failed!"); } m_accBezelCueImg[i]->setColor(CU_COL_AO0113T); show(*m_accBezelCueImg[i]); @@ -945,7 +945,7 @@ namespace callui { m_rejBezelCueImg[i] = impl::createImage(*m_layout, impl::REJECT_BC_PARAMS[i].theme); if (!m_rejBezelCueImg[i]) { - LOG_RETURN(RES_FAIL, "Create bezel cue image failed"); + LOG_RETURN(RES_FAIL, "Create bezel cue image failed!"); } m_rejBezelCueImg[i]->setColor(CU_COL_AO0113T); show(*m_rejBezelCueImg[i]); @@ -1069,7 +1069,8 @@ namespace callui { if (m_accBCAnimIndex == 0) { Elm_Transit *tr1 = elm_transit_add(); elm_transit_effect_color_add(tr1, CU_COL_AO0113, CU_COL_AO0113D); - elm_transit_object_add(tr1, *m_accBezelCueImg[m_accBCAnimIndex]); + elm_transit_object_add(tr1, + as_eo(*m_accBezelCueImg[m_accBCAnimIndex])); elm_transit_duration_set(tr1, impl::BC_ANIMATION_DURATION[impl::BC_ITEM_COUNT - 1]); elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE); @@ -1088,7 +1089,7 @@ namespace callui { Elm_Transit *tr1 = elm_transit_add(); elm_transit_effect_color_add(tr1, CU_COL_AO0113, CU_COL_AO0113D); - elm_transit_object_add(tr1, *m_accBezelCueImg[oldIndex]); + elm_transit_object_add(tr1, as_eo(*m_accBezelCueImg[oldIndex])); elm_transit_duration_set(tr1, impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]); elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE); @@ -1096,7 +1097,7 @@ namespace callui { Elm_Transit *tr2 = elm_transit_add(); elm_transit_effect_color_add(tr2, CU_COL_AO0113D, CU_COL_AO0113); - elm_transit_object_add(tr2, *m_accBezelCueImg[m_accBCAnimIndex]); + elm_transit_object_add(tr2, as_eo(*m_accBezelCueImg[m_accBCAnimIndex])); elm_transit_duration_set(tr2, impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]); elm_transit_objects_final_state_keep_set(tr2, EINA_TRUE); @@ -1122,7 +1123,8 @@ namespace callui { CU_COL_AO0113D, CU_COL_AO0113T); for (int i = 0; i < impl::BC_ITEM_COUNT; i++) { m_accBezelCueImg[i]->setColor(CU_COL_AO0113D); - elm_transit_object_add(hideTransit, *m_accBezelCueImg[i]); + elm_transit_object_add(hideTransit, + as_eo(*m_accBezelCueImg[i])); } elm_transit_duration_set(hideTransit, impl::BC_ANIM_DUR_HIDE); elm_transit_objects_final_state_keep_set(hideTransit, EINA_TRUE); @@ -1143,7 +1145,7 @@ namespace callui { m_accBCAnimIndex = impl::BC_ITEM_COUNT - 1; Elm_Transit *tr1 = elm_transit_add(); elm_transit_effect_color_add(tr1, CU_COL_AO0113D, CU_COL_AO0113); - elm_transit_object_add(tr1, *m_accBezelCueImg[m_accBCAnimIndex]); + elm_transit_object_add(tr1, as_eo(*m_accBezelCueImg[m_accBCAnimIndex])); elm_transit_duration_set(tr1, impl::BC_ANIMATION_DURATION[m_accBCAnimIndex]); elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE); @@ -1161,7 +1163,8 @@ namespace callui { if (m_rejBCAnimIndex == 0) { Elm_Transit *tr1 = elm_transit_add(); elm_transit_effect_color_add(tr1, CU_COL_AO0115, CU_COL_AO0115D); - elm_transit_object_add(tr1, *m_rejBezelCueImg[m_rejBCAnimIndex]); + elm_transit_object_add(tr1, + as_eo(*m_rejBezelCueImg[m_rejBCAnimIndex])); elm_transit_duration_set(tr1, impl::BC_ANIMATION_DURATION[impl::BC_ITEM_COUNT - 1]); elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE); @@ -1179,7 +1182,7 @@ namespace callui { Elm_Transit *tr1 = elm_transit_add(); elm_transit_effect_color_add(tr1, CU_COL_AO0115, CU_COL_AO0115D); - elm_transit_object_add(tr1, *m_rejBezelCueImg[oldIndex]); + elm_transit_object_add(tr1, as_eo(*m_rejBezelCueImg[oldIndex])); elm_transit_duration_set(tr1, impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]); elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE); @@ -1187,7 +1190,7 @@ namespace callui { Elm_Transit *tr2 = elm_transit_add(); elm_transit_effect_color_add(tr2, CU_COL_AO0115D, CU_COL_AO0115); - elm_transit_object_add(tr2, *m_rejBezelCueImg[m_rejBCAnimIndex]); + elm_transit_object_add(tr2, as_eo(*m_rejBezelCueImg[m_rejBCAnimIndex])); elm_transit_duration_set(tr2, impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]); elm_transit_objects_final_state_keep_set(tr2, EINA_TRUE); @@ -1213,7 +1216,8 @@ namespace callui { CU_COL_AO0115D, CU_COL_AO0115T); for (int i = 0; i < impl::BC_ITEM_COUNT; i++) { m_rejBezelCueImg[i]->setColor(CU_COL_AO0115D); - elm_transit_object_add(hideTransit, *m_rejBezelCueImg[i]); + elm_transit_object_add(hideTransit, + as_eo(*m_rejBezelCueImg[i])); } elm_transit_duration_set(hideTransit, impl::BC_ANIM_DUR_HIDE); elm_transit_objects_final_state_keep_set(hideTransit, EINA_TRUE); @@ -1234,7 +1238,7 @@ namespace callui { m_rejBCAnimIndex = impl::BC_ITEM_COUNT - 1; Elm_Transit *tr1 = elm_transit_add(); elm_transit_effect_color_add(tr1, CU_COL_AO0115D, CU_COL_AO0115); - elm_transit_object_add(tr1, *m_rejBezelCueImg[m_rejBCAnimIndex]); + elm_transit_object_add(tr1, as_eo(*m_rejBezelCueImg[m_rejBCAnimIndex])); elm_transit_duration_set(tr1, impl::BC_ANIMATION_DURATION[m_rejBCAnimIndex]); elm_transit_objects_final_state_keep_set(tr1, EINA_TRUE); @@ -1398,11 +1402,11 @@ namespace callui { void AcceptRejectWidget::activateRotary() { - eext_rotary_object_event_activated_set(*m_layout, EINA_TRUE); + eext_rotary_object_event_activated_set(as_eo(*m_layout), EINA_TRUE); } void AcceptRejectWidget::deactivateRotary() { - eext_rotary_object_event_activated_set(*m_layout, EINA_FALSE); + eext_rotary_object_event_activated_set(as_eo(*m_layout), EINA_FALSE); } void AcceptRejectWidget::setAcceptBtnType(AcceptButtonType type) @@ -1510,24 +1514,24 @@ namespace callui { if (!m_accAo) { LOG_RETURN(RES_FAIL, "createAccessObject() failed!"); } - elm_atspi_accessible_translation_domain_set(*m_accAo, TEXT_DOMAIN); - elm_atspi_accessible_reading_info_type_set(*m_accAo, - ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | + auto &acceptAtspi = m_accAo->getAtspi(); + acceptAtspi.setTDomain(TEXT_DOMAIN); + acceptAtspi.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION); - elm_atspi_accessible_name_set(*m_accAo, AO_STR_ACCEPT_CALL); - elm_atspi_accessible_description_set(*m_accAo, + acceptAtspi.setName(AO_STR_ACCEPT_CALL); + acceptAtspi.setDescription( AO_STR_SWIPE_RIGHT_WITH_TWO_FINGERS_TO_ACCEPT); m_rejAo = utils::createAccessObject(parent, *m_rejEventLy); if (!m_rejAo) { LOG_RETURN(RES_FAIL, "createAccessObject() failed!"); } - elm_atspi_accessible_translation_domain_set(*m_rejAo, TEXT_DOMAIN); - elm_atspi_accessible_reading_info_type_set(*m_rejAo, - ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | + auto &rejectAtspi = m_rejAo->getAtspi(); + rejectAtspi.setTDomain(TEXT_DOMAIN); + rejectAtspi.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION); - elm_atspi_accessible_name_set(*m_rejAo, AO_STR_REJECT_CALL); - elm_atspi_accessible_description_set(*m_rejAo, + rejectAtspi.setName(AO_STR_REJECT_CALL); + rejectAtspi.setDescription( AO_STR_SWIPE_LEFT_WITH_TWO_FINGERS_TO_REJECT); return RES_OK; diff --git a/call-ui/view/Slider.cpp b/call-ui/view/Slider.cpp index 9431a5d..2285f68 100644 --- a/call-ui/view/Slider.cpp +++ b/call-ui/view/Slider.cpp @@ -70,11 +70,12 @@ namespace callui { const LayoutSRef &layout, int maxValue, int curValue): - ElmWidget(&rc, *layout, false), + ElmWidget(&rc, as_eo(*layout), false), m_layout(layout.get()), - m_circleLy(elm_layout_add(*m_layout)), - m_circleSurf(eext_circle_surface_layout_add(m_circleLy)), - m_slider(eext_circle_object_slider_add(*m_layout, m_circleSurf)) + m_circleLy(elm_layout_add(as_eo(*m_layout))), + m_circleSurf(eext_circle_surface_layout_add(as_eo(m_circleLy))), + m_slider(eext_circle_object_slider_add(as_eo(*m_layout), + m_circleSurf)) { prepare(maxValue, curValue); } @@ -95,21 +96,19 @@ namespace callui { setValue(curValue); // Screen Reader - elm_atspi_accessible_role_set(m_slider, - ELM_ATSPI_ROLE_REDUNDANT_OBJECT); - elm_atspi_accessible_role_set(m_circleLy, - ELM_ATSPI_ROLE_REDUNDANT_OBJECT); - elm_atspi_accessible_role_set(*m_layout, - ELM_ATSPI_ROLE_REDUNDANT_OBJECT); + m_slider.getAtspi().setRole(ELM_ATSPI_ROLE_REDUNDANT_OBJECT); + m_circleLy.getAtspi().setRole(ELM_ATSPI_ROLE_REDUNDANT_OBJECT); + m_layout->getAtspi().setRole(ELM_ATSPI_ROLE_REDUNDANT_OBJECT); } void Slider::setValue(int value) { - eext_circle_object_value_set(m_slider, static_cast(value)); + eext_circle_object_value_set(as_eo(m_slider), + static_cast(value)); } void Slider::setMaxValue(int maxValue) { - eext_circle_object_value_min_max_set(m_slider, 0, maxValue); + eext_circle_object_value_min_max_set(as_eo(m_slider), 0, maxValue); } } diff --git a/call-ui/view/VolumeControl.cpp b/call-ui/view/VolumeControl.cpp index 5eeb11b..478070d 100644 --- a/call-ui/view/VolumeControl.cpp +++ b/call-ui/view/VolumeControl.cpp @@ -104,8 +104,8 @@ namespace callui { EventHandler handler): Slider(rc, layout, maxValue, curValue), m_handler(std::move(handler)), - m_decreaseBtn(elm_button_add(*m_layout)), - m_increaseBtn(elm_button_add(*m_layout)) + m_decreaseBtn(elm_button_add(as_eo(*m_layout))), + m_increaseBtn(elm_button_add(as_eo(*m_layout))) { prepare(info, curValue); } @@ -154,7 +154,8 @@ namespace callui { void VolumeControl::setValue(int value) { - eext_circle_object_value_set(m_slider, static_cast(value)); + eext_circle_object_value_set(as_eo(m_slider), + static_cast(value)); m_layout->setText(std::to_string(value), impl::PART_TXT_VALUE); } @@ -199,58 +200,48 @@ namespace callui { void VolumeControl::registerAccessObjectInformation() { - elm_atspi_accessible_translation_domain_set(m_slider, TEXT_DOMAIN); - elm_atspi_accessible_reading_info_type_set(m_slider, - ELM_ACCESSIBLE_READING_INFO_TYPE_NAME + auto &sliderAtspi = m_slider.getAtspi(); + sliderAtspi.setTDomain(TEXT_DOMAIN); + sliderAtspi.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION); - elm_atspi_accessible_name_set(m_slider, STR_VOLUME); - elm_atspi_accessible_description_set(m_slider, - AO_STR_ROTATE_BEZEL_TO_ADJUST); - - elm_atspi_accessible_description_cb_set(m_slider, - [](void *data, Evas_Object *obj) -> char * - { - char buff[impl::DESCRIPTION_BUFF_SIZE] = { 0 } ; - snprintf(buff, sizeof(buff), - AO_STR_ROTATE_BEZEL_TO_ADJUST.translate(), - STR_VOLUME.translate()); - return strdup(buff); - }, - this); - - elm_atspi_accessible_translation_domain_set(m_decreaseBtn, TEXT_DOMAIN); - elm_atspi_accessible_name_set(m_decreaseBtn, - AO_STR_DECREASE_VOLUME); - - elm_atspi_accessible_translation_domain_set(m_increaseBtn, TEXT_DOMAIN); - elm_atspi_accessible_name_set(m_increaseBtn, - AO_STR_INCREASE_VOLUME); - - m_valueTxtAo = utils::createAccessObjectFromLyPart( - *m_layout, - *m_layout, + sliderAtspi.setName(STR_VOLUME); + sliderAtspi.setDescriptionCb( + WEAK_DELEGATE_THIS(onSliderAoDescriptionCb)); + + auto &dereaseAtspi = m_decreaseBtn.getAtspi(); + dereaseAtspi.setTDomain(TEXT_DOMAIN); + dereaseAtspi.setName(AO_STR_DECREASE_VOLUME); + + auto &increaseAtspi = m_increaseBtn.getAtspi(); + increaseAtspi.setTDomain(TEXT_DOMAIN); + increaseAtspi.setName(AO_STR_INCREASE_VOLUME); + + m_valueTxtAo = utils::createAccessObjectFromPart(*m_layout, *m_layout, impl::PART_TXT_VALUE_AO); if (!m_valueTxtAo) { - ELOG("createAccessObjectFromLyPart() failed"); + ELOG("createAccessObjectFromPart() failed!"); } else { - elm_atspi_accessible_translation_domain_set(*m_valueTxtAo, - TEXT_DOMAIN); - elm_atspi_accessible_reading_info_type_set(*m_valueTxtAo, - ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); - elm_atspi_accessible_name_cb_set(*m_valueTxtAo, - [](void *data, Evas_Object *obj) -> char * - { - auto self = static_cast(data); - if (!self) { - return nullptr; - } - auto txt = self->m_layout-> - getText(impl::PART_TXT_VALUE).getCStr(); - return (txt) ? strdup(txt) : nullptr; - }, - this); + auto &valueTxtAtspi = m_valueTxtAo->getAtspi(); + valueTxtAtspi.setTDomain(TEXT_DOMAIN); + valueTxtAtspi.setReadingInfo(ELM_ACCESSIBLE_READING_INFO_TYPE_NAME); + valueTxtAtspi.setNameCb(WEAK_DELEGATE_THIS(onValueTextAoNameCb)); } - elm_atspi_accessible_role_set(*m_layout, ELM_ATSPI_ROLE_TEXT); + m_layout->getAtspi().setRole(ELM_ATSPI_ROLE_TEXT); + } + + CString VolumeControl::onSliderAoDescriptionCb(Atspi &atspi) + { + char buff[impl::DESCRIPTION_BUFF_SIZE] = { 0 }; + snprintf(buff, sizeof(buff), + AO_STR_ROTATE_BEZEL_TO_ADJUST.translate(), + STR_VOLUME.translate()); + return CString::dup(buff); + } + + CString VolumeControl::onValueTextAoNameCb(Atspi &atspi) + { + const auto txt = m_layout->getText(impl::PART_TXT_VALUE); + return (!txt.empty()) ? CString::dup(txt.c_str()) : nullptr; } } diff --git a/call-ui/view/VolumeControl.h b/call-ui/view/VolumeControl.h index 168a4ea..5b14b8d 100644 --- a/call-ui/view/VolumeControl.h +++ b/call-ui/view/VolumeControl.h @@ -173,6 +173,8 @@ namespace callui { void registerAccessObjectInformation(); + ucl::CString onSliderAoDescriptionCb(ucl::Atspi &atspi); + ucl::CString onValueTextAoNameCb(ucl::Atspi &atspi); private: const EventHandler m_handler; diff --git a/call-ui/view/helpers.cpp b/call-ui/view/helpers.cpp index 4e26d22..31e74a3 100644 --- a/call-ui/view/helpers.cpp +++ b/call-ui/view/helpers.cpp @@ -47,7 +47,8 @@ namespace callui { namespace utils { LOG_RETURN(RES_INVALID_OPERATION, "Circle Surface data already set!"); } - const auto sfc = eext_circle_surface_conformant_add(win->getConformant()); + const auto sfc = eext_circle_surface_conformant_add( + as_eo(win->getConformant())); if (!sfc) { LOG_RETURN(RES_FAIL, "eext_circle_surface_conformant_add() failed!"); @@ -89,14 +90,28 @@ namespace callui { namespace utils { result->setGeometry(0, 0, 1, 1); show(*result); - elm_atspi_accessible_reading_info_type_set(*result, 0); + struct FakeHandler { + SharedRef selfRef; - elm_atspi_accessible_gesture_cb_set(*result, - [](void *, Elm_Atspi_Gesture_Info, Evas_Object *) -> Eina_Bool + void onGestureCb(Atspi &atspi, + AtspiGestureEventInfo &eventInfo) { - return EINA_TRUE; - }, - nullptr); + eventInfo.preventDefault = true; + } + }; + + auto fh = makeShared(); + fh->selfRef = fh; + + evas_object_event_callback_add(as_eo(*result), EVAS_CALLBACK_DEL, + [](void *data, Evas *e, Evas_Object *obj, void *event_info) + { + static_cast(data)->selfRef.reset(); + }, fh.get()); + + auto &atspi = result->getAtspi(); + atspi.setReadingInfo(0); + atspi.addGestureHandler(WEAK_DELEGATE(FakeHandler::onGestureCb, fh)); return result; } @@ -120,7 +135,7 @@ namespace callui { namespace utils { ElmWidgetSRef createAccessObject(ElmWidget &parent, Widget &obj) { - auto ao = elm_access_object_register(obj, parent); + auto ao = elm_access_object_register(as_eo(obj), as_eo(parent)); if (!ao) { LOG_RETURN_VALUE(RES_FAIL, {}, "elm_access_object_register() failed!"); @@ -129,18 +144,23 @@ namespace callui { namespace utils { return makeShared(ao); } - ElmWidgetSRef createAccessObjectFromLyPart(ElmWidget &parent, - Widget &ly, - const EdjePart &lyPart) + ElmWidgetSRef createAccessObjectFromPart(ElmWidget &parent, + EdjeWidget &widget, EdjePart part) { - auto po = const_cast( - edje_object_part_object_get( - elm_layout_edje_get(ly), lyPart)); - if (!po) { - LOG_RETURN_VALUE(RES_FAIL, {}, "Part object is NULL"); + auto edjeLy = elm_layout_edje_get(as_eo(widget)); + if (!edjeLy) { + LOG_RETURN_VALUE(RES_FAIL, {}, + "elm_layout_edje_get() failed!"); + } + + auto edjeObj = const_cast( + edje_object_part_object_get(edjeLy, part.name)); + if (!edjeObj) { + LOG_RETURN_VALUE(RES_FAIL, {}, + "edje_object_part_object_get() failed!"); } - auto ao = elm_access_object_register(po, parent); + auto ao = elm_access_object_register(edjeObj, as_eo(parent)); if (!ao) { LOG_RETURN_VALUE(RES_FAIL, {}, "elm_access_object_register() failed!"); @@ -149,11 +169,6 @@ namespace callui { namespace utils { return makeShared(ao); } - void destroyAccessObject(ElmWidget &ao) - { - elm_access_object_unregister(ao); - } - void setMirroredMode(bool isMirroredMode) { elm_config_mirrored_set(isMirroredMode); @@ -164,6 +179,11 @@ namespace callui { namespace utils { return elm_config_mirrored_get(); } + const Elm_Interface_Atspi_Accessible *getAo(ElmWidget *widget) + { + return (widget) ? as_ao(*widget) : nullptr; + } + }} namespace callui { diff --git a/call-ui/view/helpers.h b/call-ui/view/helpers.h index f6449f3..c2398c1 100644 --- a/call-ui/view/helpers.h +++ b/call-ui/view/helpers.h @@ -76,21 +76,15 @@ namespace callui { namespace utils { /** * @brief Creates Access object from layout part - * @param[in] parent ElmWidget which is used for creating - * @param[in] ly Widget which part is used to register as an accessible object - * @param[in] lyPart Widget part to register as an accessible object + * @param[in] parent Parent for access object + * @param[in] widget Widget which part is used to register as an accessible object + * @param[in] part Widget part to register as an accessible object * @return Shared reference to ElmWidget instance * on success or NULL otherwise */ - ucl::ElmWidgetSRef createAccessObjectFromLyPart(ucl::ElmWidget &parent, - ucl::Widget &ly, - const ucl::EdjePart &lyPart); - - /** - * @brief Destroys Access object - * @param[in] ao Access object to destroy - */ - void destroyAccessObject(ucl::ElmWidget &ao); + ucl::ElmWidgetSRef createAccessObjectFromPart(ucl::ElmWidget &parent, + ucl::EdjeWidget &widget, + ucl::EdjePart part); /** * @brief Sets mirrored mode status @@ -104,6 +98,13 @@ namespace callui { namespace utils { */ bool getMirroredMode(); + /** + * @brief Gets Atspi object of the Widget + * @param[in] widget Pointer on widget + * @return Atspi object on success otherwise null on fail + */ + const Elm_Interface_Atspi_Accessible *getAo(ucl::ElmWidget *widget); + }} namespace callui { diff --git a/ucl/include/ucl/appfw/IInstance.h b/ucl/include/ucl/appfw/IInstance.h index fd9dfe4..bef5fc9 100644 --- a/ucl/include/ucl/appfw/IInstance.h +++ b/ucl/include/ucl/appfw/IInstance.h @@ -23,12 +23,43 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(IInstance); + /** + * @brief Abstract interface for the application instances + * @details Instance is an object inside the application executable that + * represents it. UIApp may have only 1 instance per application. + * Other types of applications (widget) may have more that one + * instance (or none) in a single executable. + */ class IInstance : protected NonCopyable { public: + /** + * @brief Called when instance is created. + * @details This function is called when instance gets created. + * Implementation must allocate all global resources in this + * function. For UIApp function called in app's "create" cb. + * @param[in] context Pointer to the context of this instance + * @return RES_OK on success, + * otherwise other result + */ virtual Result onCreate(IInstanceContext *context) = 0; + + /** + * @brief Called when instance is paused + * @details For UIApp function called in app's "pause" cb. + */ virtual void onPause() = 0; + + /** + * @brief Called when instance is resumed + * @details For UIApp function called in app's "resume" cb. + */ virtual void onResume() = 0; + protected: + /** + * @brief Destructor + * @details Deallocate all resources here + */ ~IInstance() = default; }; } diff --git a/ucl/include/ucl/appfw/IInstanceAppControlExt.h b/ucl/include/ucl/appfw/IInstanceAppControlExt.h index 9720dc7..02a211b 100644 --- a/ucl/include/ucl/appfw/IInstanceAppControlExt.h +++ b/ucl/include/ucl/appfw/IInstanceAppControlExt.h @@ -21,10 +21,23 @@ namespace ucl { + /** + * @brief Extension interface for instances that supports processing of app + * controll requests. + */ class IInstanceAppControlExt : protected NonCopyable { public: + /** + * @brief Called to process an app control request. + * @details For UIApp function called in app's "app_control" cb. + * @param[in] appControl App control request to process + */ virtual void onAppControl(app_control_h appControl) = 0; + protected: + /** + * @brief Destructor + */ ~IInstanceAppControlExt() = default; }; } diff --git a/ucl/include/ucl/appfw/IInstanceContext.h b/ucl/include/ucl/appfw/IInstanceContext.h index bab6a5b..c67d954 100644 --- a/ucl/include/ucl/appfw/IInstanceContext.h +++ b/ucl/include/ucl/appfw/IInstanceContext.h @@ -23,12 +23,34 @@ namespace ucl { + /** + * @brief Abstract interface for the instance context. + * @details Instance context allows an instance to communicate with the + * application + */ class IInstanceContext : protected NonCopyable { public: + /** + * @brief Gets type of the application + * @return The application type + */ virtual AppType getAppType() const = 0; + + /** + * @brief Gets window of the instance + * @return Window object of the instance + */ virtual WindowSRef getWindow() = 0; + + /** + * @brief Singals to the application to terminate + */ virtual void exitApp() = 0; + protected: + /** + * @brief Destructor + */ ~IInstanceContext() = default; }; } diff --git a/ucl/include/ucl/appfw/InstanceManagerBase.h b/ucl/include/ucl/appfw/InstanceManagerBase.h index 0448244..aaa894a 100644 --- a/ucl/include/ucl/appfw/InstanceManagerBase.h +++ b/ucl/include/ucl/appfw/InstanceManagerBase.h @@ -22,18 +22,49 @@ namespace ucl { + /** + * @brief Base class for implementing instance manager + * @details Instance manager is class that is used by the application + * class (UIApp) to create instances. + */ class InstanceManagerBase : protected NonCopyable { public: + /** + * @brief Gets customization parameters for the application + * @return Reference to the parameters object + */ const AppParams &getAppParams() const; + /** + * @brief Stores systems event provider in the manager + * @param[in] provider Unique pointer to system event provider object + */ void setSysEventProvider(SysEventProviderUPtr provider); + /** + * @brief Creates new application instance object + * @return Shared reference to the new instance + */ virtual IInstanceSRef newInstance() const = 0; protected: + /** + * @brief Constructor + * @param[in] appParams Customization parameters for the application + */ InstanceManagerBase(AppParams appParams); + + /** + * @brief Destructor + */ ~InstanceManagerBase(); + /** + * @brief Gets system event provider that was stored in the manager + * @details If system event provider was not stored before using this + * function runtime assert is performed + * @return Reference to the stored system event provider + */ SysEventProvider &getSysEventProvider() const; private: diff --git a/ucl/include/ucl/appfw/SysEventProvider.h b/ucl/include/ucl/appfw/SysEventProvider.h index 2d926e9..45a65b1 100644 --- a/ucl/include/ucl/appfw/SysEventProvider.h +++ b/ucl/include/ucl/appfw/SysEventProvider.h @@ -26,18 +26,44 @@ namespace ucl { class SysEventProvider; using SysEventProviderUPtr = std::unique_ptr; + /** + * @brief Provider for system events. + */ class SysEventProvider final : protected NonCopyable { public: + /** + * @brief Pointer to function that adds Tizen system event handler + */ using EventHandlerAddFunc = int (*)(app_event_handler_h *, app_event_type_e, app_event_cb, void *); + + /** + * @brief Pointer to function that deletes Tizen system event handler + */ using EventHandlerDelFunc = int (*)(app_event_handler_h); public: + /** + * @brief Constructor + * @param[in] addFunc Tizen API for adding system event handler + * @param[in] delFunc Tizen API for deleting system event handler + */ SysEventProvider(EventHandlerAddFunc addFunc, EventHandlerDelFunc delFunc); + + /** + * @brief Destructor + */ ~SysEventProvider(); + /** + * @brief Registers system event handler + */ void addEventHandler(SysEventHandler handler); + + /** + * @brief Deregisters system event handler + */ void delEventHandler(SysEventHandler::CDRef handler); private: diff --git a/ucl/include/ucl/appfw/UIApp.h b/ucl/include/ucl/appfw/UIApp.h index 2e2b435..39afee8 100644 --- a/ucl/include/ucl/appfw/UIApp.h +++ b/ucl/include/ucl/appfw/UIApp.h @@ -23,11 +23,33 @@ namespace ucl { + /** + * @brief Represent Tizen UI application. + * @details Root object of any application. + */ class UIApp final : private IInstanceContext { public: + /** + * @brief Constructor + * @param[in] instanceMgr Reference to the instance manager + */ UIApp(InstanceManagerBase &instanceMgr); + + /** + * @brief Destructor + */ ~UIApp(); + /** + * @brief Runs the application + * @details Must be run in the application "main()" function + * @param[in] argc Count of command line arguments + * (must be passed from "main()"") + * @param[in] argv Array of command line arguments + * (must be passed from "main()"") + * @return 0 on success, + * otherwise a negative error value + */ int run(int argc, char *argv[]); private: diff --git a/ucl/include/ucl/appfw/helpers.h b/ucl/include/ucl/appfw/helpers.h index fe598d9..dbb850c 100644 --- a/ucl/include/ucl/appfw/helpers.h +++ b/ucl/include/ucl/appfw/helpers.h @@ -21,6 +21,12 @@ namespace ucl { + /** + * @brief Generates full path to the resource file. + * @param[in] relativePath Relative (to the "res" folder) path of the + * resource file (without leading "/") + * @return Full path to the resource file + */ std::string getResPath(const char *relativePath); } diff --git a/ucl/include/ucl/appfw/types.h b/ucl/include/ucl/appfw/types.h index d8455eb..8268e57 100644 --- a/ucl/include/ucl/appfw/types.h +++ b/ucl/include/ucl/appfw/types.h @@ -30,21 +30,33 @@ namespace ucl { + /** + * @brief Enumeration of application types + */ enum class AppType { UI, WIDGET, WATCH }; + /** + * @brief Defines keys for the application customization parameters + */ enum class AppParam { BASE_SCALE, - ACCELERATION_PREFERENECE, + ACCELERATION_PREFERENCE, WINDOW_TYPE, - WINDOW_NAME + WINDOW_NAME, }; + /** + * @brief Application customization parameters + */ using AppParams = HashMap; + /** + * @brief Enumeration of system events + */ enum class SysEvent { LANGUAGE_CHANGED, REGION_FMT_CHANGED, @@ -55,8 +67,14 @@ namespace ucl { UPDATE_REQUESTED }; + /** + * @brief Delegate to handle system events + */ using SysEventHandler = WeakDelegate; + /** + * @brief Automatic handle to native Tizen app control + */ using AppCtrlAuto = AutoObject; } diff --git a/ucl/include/ucl/gui/Atspi.h b/ucl/include/ucl/gui/Atspi.h new file mode 100644 index 0000000..4194ddc --- /dev/null +++ b/ucl/include/ucl/gui/Atspi.h @@ -0,0 +1,262 @@ +/* + * 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. + */ + +#ifndef __UCL_GUI_ATSPI_H__ +#define __UCL_GUI_ATSPI_H__ + +#include "types.h" + +#include "ucl/misc/Event.h" + +namespace ucl { + + UCL_DECLARE_REF_ALIASES(Atspi); + + /** + * @brief Provides Accessibility interface + */ + class Atspi final : private NonCopyable { + public: + /** + * @brief Gets the underlying Access object + * @param[in] atspi Reference to target atspi + * @return Pointer to the underlying Access object + */ + friend Elm_Interface_Atspi_Accessible *as_ao(Atspi &atspi); + + /** + * @brief Gets the underlying constant Access object + * @param[in] atspi Constant reference to target atspi + * @return Pointer to the underlying constant Access object + */ + friend const Elm_Interface_Atspi_Accessible *as_ao(const Atspi &atspi); + + 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 Sets name + * @param[in] name New name + */ + void setName(const std::string &name); + + /** + * @brief Gets name + * @return Current name + */ + std::string getName() const; + + /** + * @brief Sets name callback + * @param[in] cb name callback + */ + void setNameCb(AtspiStringCb cb); + + /** + * @brief Sets description + * @param[in] description New description + */ + void setDescription(const std::string &description); + + /** + * @brief Gets description + * @return Current description + */ + std::string getDescription() const; + + /** + * @brief Sets description callback + * @param[in] cb description callback + */ + void setDescriptionCb(AtspiStringCb cb); + + /** + * @brief Sets translation domain + * @param[in] domain New translation domain + */ + void setTDomain(const std::string &domain); + + /** + * @brief Gets translation domain + * @return Current translation domain + */ + std::string getTDomain() const; + + /** + * @brief Sets reading information type mask + * @param[in] info New reading information type mask + */ + void setReadingInfo(Elm_Atspi_Reading_Info_Type_Mask info); + + /** + * @brief Gets reading information type mask + * @return Current reading information type mask + */ + Elm_Atspi_Reading_Info_Type_Mask getReadingInfo() const; + + /** + * @brief Sets role + * @param[in] role New role + */ + void setRole(Elm_Atspi_Role role); + + /** + * @brief Gets role + * @return Current role + */ + Elm_Atspi_Role getRole() const; + + /** + * @brief Sets highlight ability status + * @param[in] value New highlight ability status + */ + void setHighlightable(bool value); + + /** + * @brief Gets highlight ability status + * @return Current highlight ability status + */ + bool isHighlightable() const; + + /** + * @brief Makes this Access object highlighted + */ + void highlight(); + + /** + * @brief Makes this Access object not highlighted + */ + void unhighlight(); + + /** + * @brief Adds new relationship + * @param[in] type Type of the new relationship + * @param[in] relation Pointer to relation Access object + */ + void addRelationship(Elm_Atspi_Relation_Type type, + 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 (optional) + */ + void delRelationship(Elm_Atspi_Relation_Type type, + const Elm_Interface_Atspi_Accessible *relation = nullptr); + + /** + * @brief Deletes all exiting relationships + */ + void clearRelationships(); + + /** + * @brief Registers gesture event handler + * @param[in] handler Handler of the event + */ + void addGestureHandler(AtspiGestureHandler handler); + + /** + * @brief Deregisters gesture event handler + * @param[in] handler Handler of the event + */ + void delGestureHandler(const AtspiGestureHandler &handler); + + private: + Elm_Interface_Atspi_Accessible *getAo(); + const Elm_Interface_Atspi_Accessible *getAo() const; + + void registerGestureCb(); + void registerNameCb(); + void registerDescriptionCb(); + + void unregisterGestureCb(); + void unregisterNameCb(); + void unregisterDescriptionCb(); + void unregisterAllCallbacks(); + + Eina_Bool onAtspiGesture( + Elm_Atspi_Gesture_Info gestureInfo, Evas_Object *obj); + char *onAtspiNameCb(Evas_Object *obj); + char *onAtspiDescriptionCb(Evas_Object *obj); + + private: + Elm_Interface_Atspi_Accessible *const m_ao; + + Event m_onGesture; + AtspiStringCb m_nameCb; + AtspiStringCb m_descriptionCb; + + bool m_isGestureCbRegistered; + bool m_isNameCbRegistered; + bool m_isDescriptionCbRegistered; + }; + + // Non-member functions // + + /** + * @brief Gets Access object from pointed object + * @param[in] ptr Target object pointer + * @return Pointer to Access object or NULL + */ + template + inline auto as_ao(const T &ptr) -> typename std::enable_if< + std::is_convertible::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 + inline auto as_ao(const T &iter) -> typename std::enable_if< + !std::is_convertible::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 + */ + Elm_Interface_Atspi_Accessible *as_ao(Elm_Interface_Atspi_Accessible *ao); + + /** + * @brief Passes through original constant Access object pointer + * @param[in] ao Constant Access object pointer + * @return Constant Access object pointer + */ + const Elm_Interface_Atspi_Accessible *as_ao( + const Elm_Interface_Atspi_Accessible *ao); +} + +#include "Atspi.hpp" + +#endif // __UCL_GUI_ATSPI_H__ diff --git a/ucl/include/ucl/gui/Atspi.hpp b/ucl/include/ucl/gui/Atspi.hpp new file mode 100644 index 0000000..e1c53f6 --- /dev/null +++ b/ucl/include/ucl/gui/Atspi.hpp @@ -0,0 +1,270 @@ +/* + * 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" + +namespace ucl { + + inline Atspi::Atspi(Elm_Interface_Atspi_Accessible *const ao) : + m_ao(ao), + m_isGestureCbRegistered(false), + m_isNameCbRegistered(false), + m_isDescriptionCbRegistered(false) + { + UCL_ASSERT(ao, "ao is NULL"); + } + + inline Atspi::~Atspi() + { + unregisterAllCallbacks(); + } + + inline Elm_Interface_Atspi_Accessible *Atspi::getAo() + { + return m_ao; + } + + inline const Elm_Interface_Atspi_Accessible *Atspi::getAo() const + { + return m_ao; + } + + inline void Atspi::setName(const std::string &name) + { + elm_atspi_accessible_name_set(getAo(), name.c_str()); + } + + inline std::string Atspi::getName() const + { + return nz(elm_atspi_accessible_name_get(getAo())); + } + + inline void Atspi::setNameCb(AtspiStringCb cb) + { + if (cb) { + registerNameCb(); + } + m_nameCb = std::move(cb); + } + + inline void Atspi::setDescription(const std::string &description) + { + elm_atspi_accessible_description_set(getAo(), description.c_str()); + } + + inline std::string Atspi::getDescription() const + { + return nz(elm_atspi_accessible_description_get(getAo())); + } + + inline void Atspi::setDescriptionCb(AtspiStringCb cb) + { + if (cb) { + registerDescriptionCb(); + } + m_descriptionCb = std::move(cb); + } + + inline void Atspi::setTDomain(const std::string &domain) + { + elm_atspi_accessible_translation_domain_set(getAo(), domain.c_str()); + } + + inline std::string Atspi::getTDomain() const + { + return nz(elm_atspi_accessible_translation_domain_get(getAo())); + } + + inline void Atspi::setReadingInfo( + const Elm_Atspi_Reading_Info_Type_Mask info) + { + elm_atspi_accessible_reading_info_type_set(getAo(), info); + } + + inline Elm_Atspi_Reading_Info_Type_Mask Atspi::getReadingInfo() const + { + return elm_atspi_accessible_reading_info_type_get(getAo()); + } + + inline void Atspi::setRole(const Elm_Atspi_Role role) + { + elm_atspi_accessible_role_set(getAo(), role); + } + + inline Elm_Atspi_Role Atspi::getRole() const + { + return elm_atspi_accessible_role_get(getAo()); + } + + inline void Atspi::setHighlightable(const bool value) + { + elm_atspi_accessible_can_highlight_set(getAo(), toEina(value)); + } + + inline bool Atspi::isHighlightable() const + { + return elm_atspi_accessible_can_highlight_get(getAo()); + } + + inline void Atspi::highlight() + { + elm_atspi_component_highlight_grab(getAo()); + } + + inline void Atspi::unhighlight() + { + elm_atspi_component_highlight_clear(getAo()); + } + + inline void Atspi::addRelationship(const Elm_Atspi_Relation_Type type, + 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, + const Elm_Interface_Atspi_Accessible *const relation) + { + elm_atspi_accessible_relationship_remove(getAo(), type, relation); + } + + inline void Atspi::clearRelationships() + { + elm_atspi_accessible_relationships_clear(getAo()); + } + + inline void Atspi::addGestureHandler(AtspiGestureHandler handler) + { + if (handler) { + registerGestureCb(); + m_onGesture += std::move(handler); + } + } + + inline void Atspi::delGestureHandler(const AtspiGestureHandler &handler) + { + m_onGesture -= handler; + } + + inline void Atspi::registerGestureCb() + { + if (!m_isGestureCbRegistered) { + m_isGestureCbRegistered = true; + elm_atspi_accessible_gesture_cb_set(m_ao, + UCL_CALLBACK_A(Atspi::onAtspiGesture), this); + } + } + + inline void Atspi::registerNameCb() + { + if (!m_isNameCbRegistered) { + m_isNameCbRegistered = true; + elm_atspi_accessible_name_cb_set(m_ao, + UCL_CALLBACK_A(Atspi::onAtspiNameCb), this); + } + } + + inline void Atspi::registerDescriptionCb() + { + if (!m_isDescriptionCbRegistered) { + m_isDescriptionCbRegistered = true; + elm_atspi_accessible_description_cb_set(m_ao, + UCL_CALLBACK_A(Atspi::onAtspiDescriptionCb), this); + } + } + + inline void Atspi::unregisterGestureCb() + { + if (m_isGestureCbRegistered) { + m_isGestureCbRegistered = false; + elm_atspi_accessible_gesture_cb_set(m_ao, nullptr, nullptr); + } + } + + inline void Atspi::unregisterNameCb() + { + if (m_isNameCbRegistered) { + m_isNameCbRegistered = false; + elm_atspi_accessible_name_cb_set(m_ao, nullptr, nullptr); + } + } + + inline void Atspi::unregisterDescriptionCb() + { + if (m_isDescriptionCbRegistered) { + m_isDescriptionCbRegistered = false; + elm_atspi_accessible_description_cb_set(m_ao, nullptr, nullptr); + } + } + + inline void Atspi::unregisterAllCallbacks() + { + unregisterGestureCb(); + unregisterNameCb(); + unregisterDescriptionCb(); + } + + inline Eina_Bool Atspi::onAtspiGesture( + Elm_Atspi_Gesture_Info gestureInfo, Evas_Object *obj) + { + AtspiGestureEventInfo eventInfo{gestureInfo}; + m_onGesture.dispatchPred( + [&eventInfo]() { return !eventInfo.stopPropagation; }, + *this, eventInfo); + return toEina(eventInfo.preventDefault); + } + + inline char *Atspi::onAtspiNameCb(Evas_Object *obj) + { + if (const auto cb = m_nameCb.lock()) { + return cb(*this).release(); + } + return nullptr; + } + + inline char *Atspi::onAtspiDescriptionCb(Evas_Object *obj) + { + if (const auto cb = m_descriptionCb.lock()) { + return cb(*this).release(); + } + return nullptr; + } + + // Non-member functions // + + 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 ao; + } + + inline const Elm_Interface_Atspi_Accessible *as_ao( + const Elm_Interface_Atspi_Accessible *const ao) + { + return ao; + } +} diff --git a/ucl/include/ucl/gui/EdjeWidget.h b/ucl/include/ucl/gui/EdjeWidget.h index 8d045c4..da32501 100644 --- a/ucl/include/ucl/gui/EdjeWidget.h +++ b/ucl/include/ucl/gui/EdjeWidget.h @@ -23,26 +23,91 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(EdjeWidget); + /** + * @brief Base class for all widgets that has Edje theme + */ class EdjeWidget : public ElmWidget { public: + /** + * @brief Sets text to default part + * @param[in] value Translatable text value to set + */ void setText(const TString &value); + + /** + * @brief Sets text to specific part + * @param[in] value Translatable text value to set + * @param[in] part Destination Edje part + */ void setText(const TString &value, EdjePart part); - TString getText() const; - TString getText(EdjePart part) const; + /** + * @brief Gets text from default part + * @return Translated text from default part + */ + std::string getText() const; + + /** + * @brief Gets text from specific part + * @param[in] part Source Edje part + * @return Translated text from specific part + */ + std::string getText(EdjePart part) const; + + /** + * @brief Sets content to default part + * @param[in] content Content widget + */ + void setContent(Widget &content); - void setContent(Evas_Object *content); - void setContent(Evas_Object *content, EdjePart part); + /** + * @brief Sets content to specific part + * @param[in] content Content widget + * @param[in] part Destination Edje part + */ + void setContent(Widget &content, EdjePart part); + + /** + * @brief Unsets content from default part + * @return Content Evas object or NULL + */ Evas_Object *unsetContent(); + + /** + * @brief Unsets content from specific part + * @param[in] part Source Edje part + * @return content Evas object or NULL + */ Evas_Object *unsetContent(EdjePart part); + /** + * @brief Gets content from default part + * @return Content Evas object or NULL + */ Evas_Object *getContent() const; + + /** + * @brief Gets content from specific part + * @param[in] part Source Edje part + * @return content Evas object or NULL + */ Evas_Object *getContent(EdjePart part) const; + /** + * @brief Emits signal to the widget's Edje theme + * @param[in] signal Emitted signal + * @param[in] signal Emitted signal source (optional) + */ void emit(EdjeSignal signal, EdjeSignalSrc source = EdjeSignalSrc("")); protected: + /** + * @brief Constructor + * @param[in] rc Pointer to IRefCountObj (passed automatically) + * @param[in] eo Underlying Evas object of the widget + * @param[in] isOwner Evas object ownership flag (optional: true) + */ EdjeWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true); }; } diff --git a/ucl/include/ucl/gui/EdjeWidget.hpp b/ucl/include/ucl/gui/EdjeWidget.hpp index 3f989c7..763808e 100644 --- a/ucl/include/ucl/gui/EdjeWidget.hpp +++ b/ucl/include/ucl/gui/EdjeWidget.hpp @@ -22,25 +22,25 @@ namespace ucl { { } - inline TString EdjeWidget::getText() const + inline std::string EdjeWidget::getText() const { return elm_object_text_get(getEo()); } - inline TString EdjeWidget::getText(const EdjePart part) const + inline std::string EdjeWidget::getText(const EdjePart part) const { 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 795cf2b..a0e2d60 100644 --- a/ucl/include/ucl/gui/ElmWidget.h +++ b/ucl/include/ucl/gui/ElmWidget.h @@ -18,53 +18,128 @@ #define __UCL_GUI_ELM_WIDGET_H__ #include "Widget.h" - -#define UCL_SMART_FWD_ATSPI UCL_SMART_FWD "atspi," +#include "Atspi.h" namespace ucl { - constexpr SmartEvent ATSPI_ON_GESTURE {UCL_SMART_FWD_ATSPI "gesture"}; - class Window; UCL_DECLARE_REF_ALIASES(ElmWidget); + /** + * @brief Represents Elementary widget and serves as base class for more + * concrete widget types + */ class ElmWidget : public Widget { public: - explicit ElmWidget(Evas_Object *eo, bool isOwner = true); - ElmWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true); - virtual ~ElmWidget(); - + using Widget::Widget; + + /** + * @brief Gets Atspi of this widget + * @return Reference to the Atspi object + */ + Atspi &getAtspi(); + + /** + * @brief Gets Atspi of this widget (constant version) + * @return Reference to the constant Atspi object + */ + Atspi &getAtspi() const; + + /** + * @brief Sets enabled state of the widget + * @param[in] value New state + */ void setEnabled(bool value); - bool isEnabled() const; - void setFocusAlowed(bool value); - bool isFocusAlowed() const; + /** + * @brief Gets enabled state of the widget + * @return true if enabled, false if disabled + */ + bool isEnabled() const; + /** + * @brief Sets if key-input focus is allowed for the widget + * @param[in] value New state + */ + void setFocusAllowed(bool value); + + /** + * @brief Gets if key-input focus is allowed for the widget + * @return true if allowed, false if not allowed + */ + bool isFocusAllowed() const; + + /** + * @brief Sets theme object to the widget + * @details This function does not affect look of this widget directly, + * instead it makes all styles from Theme visible to this + * widget and all it's children. + * @param[in] th Theme object to set + */ void setTheme(Elm_Theme *th); + + /** + * @brief Gets theme object that assigned to the widget + * @return Assigned Theme object + */ Elm_Theme *getTheme(); + /** + * @brief Gets top level parent of the widget + * @return Top level Evas object + */ Evas_Object *getTopWidget() const; + + /** + * @brief Tries to get top level parent of the widget as Window widget + * @return Window widget or NULL + */ Window *getWindow() const; protected: + // Widget // + 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); + void ensureAtspi(); private: - bool m_isAtspiGestureCbSet; + AtspiSRef m_atspi; friend class ReffedObj; }; // 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 + */ void enable(ElmWidget &widget); + + /** + * @brief Sets widget to disabled state + * @details This is equivalent to: widget.setEnabled(false); + * @param[in] widget Reference to target widget + */ void disable(ElmWidget &widget); } diff --git a/ucl/include/ucl/gui/ElmWidget.hpp b/ucl/include/ucl/gui/ElmWidget.hpp index 0673a57..6fe586d 100644 --- a/ucl/include/ucl/gui/ElmWidget.hpp +++ b/ucl/include/ucl/gui/ElmWidget.hpp @@ -16,9 +16,24 @@ namespace ucl { - inline ElmWidget::ElmWidget(Evas_Object *const eo, const bool isOwner) : - ElmWidget(nullptr, eo, isOwner) + inline Atspi &ElmWidget::getAtspi() { + ensureAtspi(); + return *m_atspi; + } + + inline Atspi &ElmWidget::getAtspi() const + { + // Need cast for lazy initialization. Can't use mutable. + const_cast(this)->ensureAtspi(); + return *m_atspi; + } + + inline void ElmWidget::ensureAtspi() + { + if (!m_atspi) { + m_atspi = makeShared(getEo()); + } } inline void ElmWidget::setEnabled(const bool value) @@ -31,12 +46,12 @@ namespace ucl { return !elm_object_disabled_get(getEo()); } - inline void ElmWidget::setFocusAlowed(const bool value) + inline void ElmWidget::setFocusAllowed(const bool value) { elm_object_focus_allow_set(getEo(), toEina(value)); } - inline bool ElmWidget::isFocusAlowed() const + inline bool ElmWidget::isFocusAllowed() const { return elm_object_focus_allow_get(getEo()); } @@ -58,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/Genlist.h b/ucl/include/ucl/gui/Genlist.h index 7c80ab4..3791d8f 100644 --- a/ucl/include/ucl/gui/Genlist.h +++ b/ucl/include/ucl/gui/Genlist.h @@ -24,8 +24,14 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(Genlist); + /** + * @brief Represents Elementary Genlist widget + */ class Genlist final : public StyledWidget { public: + /** + * @brief Enumeration of Genlist modes + */ enum class Mode { COMPRESS = ELM_LIST_COMPRESS, SCROLL = ELM_LIST_SCROLL, @@ -33,15 +39,58 @@ namespace ucl { EXPAND = ELM_LIST_EXPAND }; + /** + * @brief Builder of Genlist objects + */ class Builder final { public: + /** + * @brief Constructor + */ Builder(); + + /** + * @brief Sets style of the future object + * @param[in] style Style of the future object + * @return Reference to this builder + */ Builder &setStyle(ElmStyle style); + + /** + * @brief Sets mode of the future object + * @param[in] mode Mode of the future object + * @return Reference to this builder + */ Builder &setMode(Mode mode); + + /** + * @brief Sets if future object will be homogeneous or not + * @param[in] value true if homogeneous, false - otherwise + * @return Reference to this builder + */ Builder &setHomogeneous(bool value); + + /** + * @brief Sets Evas object ownership flag of the future object + * @param[in] value true if owner, false - otherwise + * @return Reference to this builder + */ Builder &setIsOwner(bool value); + + /** + * @brief Sets if future object needs to be bind to it's Evas object + * @param[in] value true if need to bind, false - otherwise + * @return Reference to this builder + */ Builder &setNeedBindToEo(bool value); + + /** + * @brief Creates new Genlist object using current parameters + * @param[in] parent Reference to parent widget + * @return Shared reference to new Genlist object or NULL + */ GenlistSRef build(ElmWidget &parent) const; + private: ElmStyle m_style; Mode m_mode; @@ -53,31 +102,102 @@ namespace ucl { public: using StyledWidget::StyledWidget; + /** + * @brief Sets mode of the genlist + * @param[in] mode New mode of the genlist + */ void setMode(Mode mode); + + /** + * @brief Gets mode of the genlist + * @return Current mode of the genlist + */ Mode getMode() const; + /** + * @brief Sets homogeneous flag of the genlist + * @param[in] mode New flag value + */ void setHomogeneous(bool isHomogeneous); + + /** + * @brief Gets homogeneous flag of the genlist + * @return Current flag value + */ bool isHomogeneous() const; + /** + * @brief Updates all items that are realized + */ void updateRealizedItems(); + + /** + * @brief Removes all items from the genlist + */ void clear(); + /** + * @brief Appends new item to the genlist + * @param[in] itc Item class of the future item + * @param[in] data Pointer to user data of the item + * @param[in] onSelect Convenience callback when item + * is selected (optional) + * @param[in] type Type of the future item + * (optional: GenlistItem::Type::SIMPLE) + * @param[in] parent Parent item for the future item (optional) + * @return New item + */ GenlistItem append(const Elm_Genlist_Item_Class *itc, const void *data, SmartCbHandler onSelect = nullptr, GenlistItem::Type type = GenlistItem::Type::SIMPLE, GenlistItem parent = nullptr); + /** + * @brief Prepends new item to the genlist + * @param[in] itc Item class of the future item + * @param[in] data Pointer to user data of the item + * @param[in] onSelect Convenience callback when item + * is selected (optional) + * @param[in] type Type of the future item + * (optional: GenlistItem::Type::SIMPLE) + * @param[in] parent Parent item for the future item (optional) + * @return New item + */ GenlistItem prepend(const Elm_Genlist_Item_Class *itc, const void *data, SmartCbHandler onSelect = nullptr, GenlistItem::Type type = GenlistItem::Type::SIMPLE, GenlistItem parent = nullptr); + /** + * @brief Inserts new item to the genlist after specific item + * @param[in] after Item after which future item will be inserted + * @param[in] itc Item class of the future item + * @param[in] data Pointer to user data of the item + * @param[in] onSelect Convenience callback when item + * is selected (optional) + * @param[in] type Type of the future item + * (optional: GenlistItem::Type::SIMPLE) + * @param[in] parent Parent item for the future item (optional) + * @return New item + */ GenlistItem insertAfter(GenlistItem after, const Elm_Genlist_Item_Class *itc, const void *data, SmartCbHandler onSelect = nullptr, GenlistItem::Type type = GenlistItem::Type::SIMPLE, GenlistItem parent = nullptr); + /** + * @brief Inserts new item to the genlist before specific item + * @param[in] before Item before which future item will be inserted + * @param[in] itc Item class of the future item + * @param[in] data Pointer to user data of the item + * @param[in] onSelect Convenience callback when item + * is selected (optional) + * @param[in] type Type of the future item + * (optional: GenlistItem::Type::SIMPLE) + * @param[in] parent Parent item for the future item (optional) + * @return New item + */ GenlistItem insertBefore(GenlistItem before, const Elm_Genlist_Item_Class *itc, const void *data, SmartCbHandler onSelect = nullptr, diff --git a/ucl/include/ucl/gui/GenlistItem.h b/ucl/include/ucl/gui/GenlistItem.h index 2c96b9c..3de1517 100644 --- a/ucl/include/ucl/gui/GenlistItem.h +++ b/ucl/include/ucl/gui/GenlistItem.h @@ -21,14 +21,27 @@ namespace ucl { + /** + * @brief Represents Elementary Genlist widget item + * @details This class has semantic of a pointer and therefore does not + * manage lifetime of the item. Pointer is always point to the non + * constant Genlist item. Most of the methods marked as const + * because pointer is not changed in these method calls. + */ class GenlistItem final : public WidgetItem { public: + /** + * @brief Enumeration of Genlist item types + */ enum class Type { SIMPLE = ELM_GENLIST_ITEM_NONE, TREE = ELM_GENLIST_ITEM_TREE, GROUP = ELM_GENLIST_ITEM_GROUP }; + /** + * @brief Enumeration of select modes for Genlist item + */ enum class SelectMode { DEFAULT = ELM_OBJECT_SELECT_MODE_DEFAULT, ALWAYS = ELM_OBJECT_SELECT_MODE_ALWAYS, @@ -36,6 +49,9 @@ namespace ucl { DISPLAY_ONLY = ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY }; + /** + * @brief Enumeration of update field flags + */ enum { FIELD_ALL = ELM_GENLIST_ITEM_FIELD_ALL, FIELD_TEXT = ELM_GENLIST_ITEM_FIELD_TEXT, @@ -46,14 +62,48 @@ namespace ucl { public: using WidgetItem::WidgetItem; + /** + * @brief Sets select mode of the genlist item + * @param[in] mode New select mode of the genlist item + */ void setSelectMode(SelectMode mode) const; + + /** + * @brief Gets select mode of the genlist item + * @return Current mode of the genlist item + */ SelectMode getSelectMode() const; + /** + * @brief Sets selected state of the genlist item + * @param[in] isSelected New select state of the genlist item + */ void setSelected(bool isSelected) const; + + /** + * @brief Gets selected state of the genlist item + * @return Current selected state of the genlist item + */ bool isSelected() const; + /** + * @brief Performs full update of the genlist item + */ void update() const; + + /** + * @brief Changes item class of the genlist item and + * performs full update + */ void update(const Elm_Genlist_Item_Class *newItc) const; + + /** + * @brief Update only specific parts and fields of the item + * @param[in] parts Globbing expresion to match a part name. + * Can include '*', '?', and '.' + * @param[in] fields Bitwise or of FILED_* enumeration + * (optional: FIELD_ALL) + */ void update(const char *parts, int fields = FIELD_ALL) const; }; } diff --git a/ucl/include/ucl/gui/Layout.h b/ucl/include/ucl/gui/Layout.h index dbfc163..2a25de0 100644 --- a/ucl/include/ucl/gui/Layout.h +++ b/ucl/include/ucl/gui/Layout.h @@ -23,16 +23,61 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(Layout); + /** + * @brief Represents Elementary Layout widget + */ class Layout : public EdjeWidget { public: + /** + * @brief Builder of Layout objects + */ class Builder final { public: + /** + * @brief Constructor + */ Builder(); + + /** + * @brief Sets layout theme of the future object + * @details EdjeFile property takes precedence over this property + * if both are set. + * @param[in] value Layout of the future object + * @return Reference to this builder + */ Builder &setTheme(const LayoutTheme &value); + + /** + * @brief Sets edje file and group of the future object + * @details This property takes precedence over Theme property + * if both are set. + * @param[in] filePath Path to the Edje file + * @param[in] group Edje group to apply to the future object + * @return Reference to this builder + */ Builder &setEdjeFile(std::string filePath, EdjeGroup group); + + /** + * @brief Sets Evas object ownership flag of the future object + * @param[in] value true if owner, false - otherwise + * @return Reference to this builder + */ Builder &setIsOwner(bool value); + + /** + * @brief Sets if future object needs to be bind to it's Evas object + * @param[in] value true if need to bind, false - otherwise + * @return Reference to this builder + */ Builder &setNeedBindToEo(bool value); + + /** + * @brief Creates new Layout object using current parameters + * @param[in] parent Reference to parent widget + * @return Shared reference to new Layout object or NULL + */ LayoutSRef build(ElmWidget &parent) const; + private: LayoutTheme m_theme; std::string m_edjeFilePath; @@ -42,14 +87,41 @@ namespace ucl { }; public: - using EdjeWidget::EdjeWidget; + using ElmWidget::setTheme; + + /** + * @brief Constructor + * @param[in] eo Underlying Elementary Layout Evas object + * @param[in] isOwner Evas object ownership flag (optional: true) + */ explicit Layout(Evas_Object *eo, bool isOwner = true); + /** + * @brief Applies LayoutTheme to the layout + * @param[in] theme LayoutTheme to apply + * @return true on success, false on failure + */ bool setTheme(const LayoutTheme &theme); + + /** + * @brief Applies edje file and group to the layout + * @param[in] filePath Path to the Edje file + * @param[in] group Edje group to apply to the layout + * @return true on success, false on failure + */ bool setEdjeFile(const std::string &filePath, EdjeGroup group); + /** + * @brief Gets data from Edje theme applied to the layout + * @param[in] key Edje data key of the data + * @return TYPE_STRING Variant value of the Edje data, + * or TYPE_NIL if not found + */ Variant getData(EdjeDataKey key); + protected: + using EdjeWidget::EdjeWidget; + private: friend class ReffedObj; }; diff --git a/ucl/include/ucl/gui/NaviItem.h b/ucl/include/ucl/gui/NaviItem.h index a11c7ca..495d3d8 100644 --- a/ucl/include/ucl/gui/NaviItem.h +++ b/ucl/include/ucl/gui/NaviItem.h @@ -21,21 +21,57 @@ namespace ucl { + /** + * @brief Represents Elementary Naviframe widget item + * @details This class has semantic of a pointer and therefore does not + * manage lifetime of the item. Pointer is always point to the non + * constant Naviframe item. Most of the methods marked as const + * because pointer is not changed in these method calls. + */ class NaviItem final : public WidgetItem { public: + /** + * @brief Delegate for handling naviframe item pop event + */ using PopHandler = Delegate; public: using WidgetItem::WidgetItem; + /** + * @brief Registers item pop handler + * @param[in] handler Handler delegate + */ void setPopHandler(PopHandler handler) const; + /** + * @brief Pops all items of the naviframe state to this item + */ void popTo() const; + + /** + * @brief Moves this naviframe item to the top of the naviframe stack + */ void promote() const; + /** + * @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. + */ void setTitleEnabled(bool value, bool useTransition = false) const; + + /** + * @brief Gets naviframe item tile visibility state + * @retrun Visibility state. true - visible, false - invisible + */ bool isTitleEnabled() const; + /** + * @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 7333e11..cc7a94f 100644 --- a/ucl/include/ucl/gui/Naviframe.h +++ b/ucl/include/ucl/gui/Naviframe.h @@ -29,64 +29,267 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(Naviframe); + /** + * @brief Represents Elementary Naviframe widget + */ class Naviframe final : public StyledWidget { public: + /** + * @brief Builder of Naviframe objects + */ class Builder final { public: + /** + * @brief Constructor + */ Builder(); + + /** + * @brief Sets style of the future object + * @param[in] style Style of the future object + * @return Reference to this builder + */ Builder &setStyle(ElmStyle value); + + /** + * @brief Sets if future object needs to be bind to it's Evas object + * @param[in] value true if need to bind, false - otherwise + * @return Reference to this builder + */ Builder &setNeedBindToEo(bool value); + + /** + * @brief Creates new Naviframe object using current parameters + * @param[in] parent Reference to parent widget + * @return Shared reference to new Naviframe object or NULL + */ NaviframeSRef build(ElmWidget &parent) const; + private: ElmStyle m_style; bool m_needBindToEo; }; public: + /** + * @brief Sets transition state of naviframe + * @details Warning! It is workaround function for internal use only. + * TODO Need to remove when page manager will be implemented. + * @param[in] inTransition true if in transition, false - otherwise + */ void setInTransition(bool inTransition); + + /** + * @brief Gets current transition state of naviframe + * @details Warning! It is workaround function for internal use only. + * TODO Need to remove when page manager will be implemented. + * @return true if in transition, false - otherwise + */ bool isInTransition() const; + /** + * @brief Sets if back button should be automatically created in + * items on push + * @param[in] value true if need create, false - otherwise + */ void setAutoBackBtn(bool value); + + /** + * @brief Gets if back button will be automatically created in + * items on push + * @return true if will be created, false - otherwise + */ bool isAutoBackBtn() const; + /** + * @brief Sets if item content should be preserved on pop + * @param[in] value true if need preserve, false - otherwise + */ void setPreservePop(bool value); + + /** + * @brief Gets if item content will be preserved on pop + * @return true if will be preserve, false - otherwise + */ bool isPreservePop() const; + /** + * @brief Sets if events should be processed by naviframe + * on item transition + * @param[in] value true if need to process events, false - otherwise + */ void setEventsEnabledOnTransition(bool value); + + /** + * @brief Gets if events will be processed by naviframe + * on item transition + * @return true if will be process events, false - otherwise + */ bool isEventsEnabledOnTransition() const; + /** + * @brief Pops and then deletes topmost item from stack with transition + * @return Preserved content of the popped item or NULL + */ Evas_Object *pop(); - NaviItem push(const TString &title, - Evas_Object *backBtn, Evas_Object *moreBtn, - Evas_Object *content, ElmStyle style = nullptr); - NaviItem push(const TString &title, - Evas_Object *content, ElmStyle style = nullptr); - NaviItem push(Evas_Object *content, 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 + * @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, 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 + * @param[in] style Elm style of the item (optional) + * @return New item + */ + 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] style Elm style of the item (optional) + * @return New item + */ + 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] 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 + * @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 + * @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] 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 + * @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 + * @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 + * @return Top item + */ NaviItem getTopItem()const; + + /** + * @brief Gets bottom item of the naviframe stack + * @return Bottom item + */ NaviItem getBottomItem() const; + + /** + * @brief Gets all items of the naviframe stack + * @return Items vector + */ std::vector getItems() const; 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 7737852..715b0bd 100644 --- a/ucl/include/ucl/gui/RadioBox.h +++ b/ucl/include/ucl/gui/RadioBox.h @@ -23,15 +23,49 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(RadioBox); + /** + * @brief Represents Elementary Radio widget + */ class RadioBox final : public StyledWidget { public: + /** + * @brief Builder of RadioBox objects + */ class Builder final { public: + /** + * @brief Constructor + */ Builder(); + + /** + * @brief Sets style of the future object + * @param[in] style Style of the future object + * @return Reference to this builder + */ Builder &setStyle(ElmStyle style); + + /** + * @brief Sets Evas object ownership flag of the future object + * @param[in] value true if owner, false - otherwise + * @return Reference to this builder + */ Builder &setIsOwner(bool value); + + /** + * @brief Sets if future object needs to be bind to it's Evas object + * @param[in] value true if need to bind, false - otherwise + * @return Reference to this builder + */ Builder &setNeedBindToEo(bool value); + + /** + * @brief Creates new RadioBox object using current parameters + * @param[in] parent Reference to parent widget + * @return Shared reference to new RadioBox object or NULL + */ RadioBoxSRef build(ElmWidget &parent) const; + private: ElmStyle m_style; bool m_isOwner; @@ -41,16 +75,55 @@ namespace ucl { public: using StyledWidget::StyledWidget; + /** + * @brief Assigns a value that this radio box represents + * @param[in] value Integer value for this radio box + */ void setItemValue(int value); + + /** + * @brief Gets a value that this radio box represents + * @return Integer value for this radio box + */ int getItemValue() const; - void addToGroup(Elm_Radio *group); + /** + * @brief Adds this radio box to the group of other radio boxes + * @param[in] group Radio box to which group this radio box + * should be added + */ + void addToGroup(RadioBox &group); + /** + * @brief Sets a value of the group in which this radio box is member + * @details All radio boxes in the same group will be selected if + * their index matches group index. + * @param[in] value Integer value for the group of this radio box + */ void setGroupValue(int value); + + /** + * @brief Gets a value of the group in which this radio box is member + * @return Integer value for the group of this radio box + */ int getGroupValue() const; + /** + * @brief Sets pointer to track group value of this radio box + * @details If pointer is not NULL group value will be changed to the + * value pointed by this pointer. From this time value pointed + * by this pointer will automatically change each time when + * group value changes. Do not change pointed value manually. + * @param[in] valuePtr Pointer to integer for tracking the group value. + * Use NULL to remove previous pointer. + */ void setGroupValuePointer(int *valuePtr); + /** + * @brief Gets currently selected radio box Evas object + * @return Pointer to selected radio box Evas object, + * or NULL if no selection + */ Elm_Radio *getSelectedObject() const; private: 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/StyledWidget.h b/ucl/include/ucl/gui/StyledWidget.h index 5401d2a..c852c7c 100644 --- a/ucl/include/ucl/gui/StyledWidget.h +++ b/ucl/include/ucl/gui/StyledWidget.h @@ -23,11 +23,25 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(StyledWidget); + /** + * @brief Represents Elementary widget which can apply ElmStyle + * and serves as base class for more concrete widget types + */ class StyledWidget : public EdjeWidget { public: using EdjeWidget::EdjeWidget; + + /** + * @brief Constructor + * @param[in] eo Underlying Evas object of the widget + * @param[in] isOwner Evas object ownership flag (optional: true) + */ explicit StyledWidget(Evas_Object *eo, bool isOwner = true); + /** + * @brief Applies style to the widget + * @param[in] style Style to apply + */ void setStyle(ElmStyle style); private: diff --git a/ucl/include/ucl/gui/Theme.h b/ucl/include/ucl/gui/Theme.h index d8b5b31..d819186 100644 --- a/ucl/include/ucl/gui/Theme.h +++ b/ucl/include/ucl/gui/Theme.h @@ -21,27 +21,108 @@ namespace ucl { + /** + * @brief Represents Elementary theme object that can be assigned to + * any Elementary widget. + * @see ElmWidget::setTheme + */ class Theme final : NonCopyable { public: + /** + * @brief Creates new Theme object that refers default theme + * @return New Theme object (may not valid) + */ static Theme create(); + /** + * @brief Swaps Theme objects with each other + * @param[in/out] x First theme object + * @param[in/out] y Second theme object + */ friend void swap(Theme &x, Theme &y); public: + /** + * @brief Default constructor + * @details Constructs empty non valid theme + */ Theme(); + + /** + * @brief Constructor + * @details Same as default constructor + */ Theme(std::nullptr_t); + + /** + * @brief Constructor + * @details Wraps native Elementary theme object. Native Elementary + * theme objet will be deleted if Theme object is owner. + * @param[in] th Native Elementary theme object + * @param[in] isOwner Elementary theme object ownership + * flag (optional: false) + */ explicit Theme(Elm_Theme *th, bool isOwner = false); + + /** + * @brief Move constructor + * @param[in] tmp Source temporary Theme object + */ Theme(Theme &&tmp); - Theme &operator=(Theme &&tmp); + + /** + * @brief Destructor + * @details Deletes native Elementary theme object if owner. + */ ~Theme(); + /** + * @brief Assigns one Them object to another + * @details Only move assignment is possible. Original will be deleted. + * @param[in] tmp Source Theme object + * @return Reference to this Theme object + */ + Theme &operator=(Theme tmp); + + /** + * @brief Gets native Elementary theme object + * @return Pointer to native Elementary theme object + */ Elm_Theme *getTh(); + + /** + * @brief Gets native Elementary theme object (constant version) + * @return Pointer to native constant Elementary theme object + */ const Elm_Theme *getTh() const; + /** + * @brief Implicitly casts to native Elementary theme object + * @return Pointer to native Elementary theme object + */ operator Elm_Theme *(); + + /** + * @brief Implicitly casts to native Elementary + * theme object (constant version) + * @return Pointer to native constant Elementary theme object + */ operator const Elm_Theme *() const; + /** + * @brief Adds specified Edje file as extension to this Theme object + * @details All Edje groups from the extension will be examined after + * all groups currently existing in this theme. + * @param[in] edjePath File path to Edje file with extension + */ void addExtension(const std::string edjePath); + + /** + * @brief Adds specified Edje file as overlay to this Theme object + * @details All Edje groups from the overlay will be examined before + * all groups currently existing in this theme. + * @param[in] edjePath File path to Edje file with overlay + */ void addOverlay(const std::string edjePath); private: @@ -51,7 +132,13 @@ namespace ucl { // Non-member functions // - bool isValid(const Theme &item); + /** + * @brief Checks whether Theme object is valid + * @details This is equivalent to: item.getTh() != NULL; + * @param[in] theme Reference to target Theme object + * @return true if valid, false if not valid + */ + bool isValid(const Theme &theme); } #include "Theme.hpp" diff --git a/ucl/include/ucl/gui/Theme.hpp b/ucl/include/ucl/gui/Theme.hpp index 65910df..b357dd7 100644 --- a/ucl/include/ucl/gui/Theme.hpp +++ b/ucl/include/ucl/gui/Theme.hpp @@ -48,12 +48,6 @@ namespace ucl { tmp.m_th = nullptr; } - inline Theme &Theme::operator=(Theme &&tmp) - { - swap(*this, tmp); - return *this; - } - inline Theme::~Theme() { if (m_isOwner && m_th) { @@ -61,6 +55,12 @@ namespace ucl { } } + inline Theme &Theme::operator=(Theme tmp) + { + swap(*this, tmp); + return *this; + } + inline Elm_Theme *Theme::getTh() { return m_th; @@ -93,9 +93,9 @@ namespace ucl { // Non-member functions // - inline bool isValid(const Theme &item) + inline bool isValid(const Theme &theme) { - return !!item.getTh(); + return !!theme.getTh(); } inline void swap(Theme &x, Theme &y) diff --git a/ucl/include/ucl/gui/Widget.h b/ucl/include/ucl/gui/Widget.h index 9292cad..e6506ab 100644 --- a/ucl/include/ucl/gui/Widget.h +++ b/ucl/include/ucl/gui/Widget.h @@ -29,79 +29,367 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(Widget); + /** + * @brief Represents Evas widget and serves as base class for more + * concrete widget types + */ class Widget : public RefCountAware { public: + /** + * @brief Constant for setWeight() method + */ static constexpr auto EXPAND = EVAS_HINT_EXPAND; + + /** + * @brief Constant for setAllign() method + */ static constexpr auto FILL = EVAS_HINT_FILL; 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) + */ explicit Widget(Evas_Object *eo, bool isOwner = true); + + /** + * @brief Constructor + * @param[in] rc Pointer to IRefCountObj (passed automatically) + * @param[in] eo Underlying Evas object of the widget + * @param[in] isOwner Evas object ownership flag (optional: true) + */ Widget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true); + + /** + * @brief Destructor + */ virtual ~Widget(); + /** + * @brief Binds underlying Evas object to this widget + * @details When Evas object is bound it makes possible to convert + * Evas object pointer to Widget pointer. Only single + * Widget object may be bound same Evas object. + */ void bindToEo(); + + /** + * @brief Unbinds underlying Evas object from this widget + * @details Reverts the effect of bindToEo() function call. Use this + * function if you want to bind different Widget object to + * same Evas object (usefull when wrapping widgets). + */ void unbindFromEo(); + /** + * @brief Sets ownership of Evas object flag to this widget + * @details In all cases: + * Evas object can't be destroyed while Widget object is alive. + * But it can still be marked for deletion. + * + * In all cases when ownership flag is true: + * Underlying Evas object is marked for deletion in the + * destructor of this Widget object. Otherwise... + * + * In case if Widget object is shared: + * While Evas object is alive Widget object is also remains + * alive even if all visible shared references destroyed. + * It is possible to create new shared reference to Widget + * from Evas object pointer. + * + * In case if Widget object is not shared: + * Underlying Evas object is not marked for deletion in the + * destructor of this Widget object + * + * @param[in] value Ownership flag. true - owner, false - not owner. + */ void setIsOwner(bool value); - Evas_Object *getEo(); - const Evas_Object *getEo() const; - - operator Evas_Object *(); - operator const Evas_Object *() const; - + /** + * @brief Gets Evas canvas on which underlying Evas object resides + * @return Pointer to the Evas canvas + */ Evas *getEvas() const; + /** + * @brief Assigns user data to this widget + * @param[in] key Name of the data key + * @param[in] data Pointer to the user data + */ void setData(EoDataKey key, void *data); + + /** + * @brief Deletes user data from this widget + * @param[in] key Name of the data key + */ void delData(EoDataKey key); + + /** + * @brief Gets user data from this widget + * @param[in] key Name of the data key + * @return Pointer to the user data or NULL if not found + */ void *getData(EoDataKey key) const; + /** + * @brief Registers standard widget event handler + * @param[in] event Value of the standart widget event enumeration + * @param[in] handler Handler of the event + */ void addEventHandler(WidgetEvent event, WidgetEventHandler handler); + + /** + * @brief Registers smart widget event handler + * @param[in] event Name of the smart widget event + * @param[in] handler Handler of the event + */ void addEventHandler(SmartEvent event, WidgetEventHandler handler); + /** + * @brief Deregisters standard widget event handler + * @param[in] event Value of the standart widget event enumeration + * @param[in] handler Handler of the event + */ void delEventHandler(WidgetEvent event, WidgetEventHandler::CDRef handler); + + /** + * @brief Deregisters smart widget event handler + * @param[in] event Name of the smart widget event + * @param[in] handler Handler of the event + */ void delEventHandler(SmartEvent event, WidgetEventHandler::CDRef handler); + /** + * @brief Calls smart widget event on this widget + * @details All handler of this event on this widget will handle this + * event synchronously during call to this function. + * @param[in] event Name of the smart widget event + * @param[in] eventInfo Pointer to event info (optional) + */ void callEvent(SmartEvent event, void *eventInfo = nullptr); + /** + * @brief Marks underlying Evas object for deletion + * @details Evas object will be deleted when there is no Widget objects + * referencing it and no other references to it. + */ void markForDeletion(); + /** + * @brief Sets visibility state of the widget + * @param[in] value New state + */ void setVisible(bool value); + + /** + * @brief Gets visibility state of the widget + * @return true if visible, false if invisible + */ bool isVisible() const; + /** + * @brief Sets color to this widget + * @details Color component values must be premultiplied if alpha + * is not 255. + * @param[in] r Red component of the color [0-255] + * @param[in] g Green component of the color [0-255] + * @param[in] b Blue component of the color [0-255] + * @param[in] a Alpha transparency of the color [0-255] (optional: 255) + */ void setColor(int r, int g, int b, int a = 255); + + /** + * @brief Sets gray color to this widget + * @param[in] l Luminosity of the color [0-255] + * @param[in] a Alpha transparency of the color [0-255] (optional: 255) + */ void setColor(int l, int a = 255); + + /** + * @brief Gets color of this widget + * @param[out] r Reference to the red component of the color + * @param[out] g Reference to the green component of the color + * @param[out] b Reference to the blue component of the color + * @param[out] a Reference to the alpha + */ void getColor(int &r, int &g, int &b, int &a) const; + /** + * @brief Performs forced size calculations on the widget + */ void calculate(); + /** + * @brief Sets geometry of this widget + * @param[in] x Top-left X coordinate of the widget + * @param[in] y Top-left Y coordinate of the widget + * @param[in] w New width of the widget + * @param[in] h New height of the widget + */ void setGeometry(int x, int y, int w, int h); + + /** + * @brief Changes position of this widget + * @param[in] x Top-left X coordinate of the widget + * @param[in] y Top-left Y coordinate of the widget + */ void move(int x, int y); + + /** + * @brief Changes size of this widget + * @param[in] w New width of the widget + * @param[in] h New height of the widget + */ void resize(int w, int h); + /** + * @brief Gets geometry of this widget + * @param[out] x Top-left X coordinate of the widget (may be NULL) + * @param[out] y Top-left Y coordinate of the widget (may be NULL) + * @param[out] w Width of the widget (may be NULL) + * @param[out] h Height of the widget (may be NULL) + */ void getGeometry(int *x, int *y, int *w, int *h) const; - void setWeight(double w, double h); - void setAlign(double w, double h); + /** + * @brief Sets weight size hints to the widget + * @details Use EXPAND to expand container to the parent size + * @param[in] x Weight of the widget along X axis + * @param[in] y Weight of the widget along Y axis + */ + void setWeight(double x, double y); + + /** + * @brief Sets align size hints to the widget + * @details Use FILL to streth to the size of the container + * @param[in] x Align of the widget along X axis [0.0-1.0] + * @param[in] y Align of the widget along Y axis [0.0-1.0] + */ + void setAlign(double x, double y); + + /** + * @brief Sets mimimum size hints to the widget + * @param[in] w Minimul allowed with of the widget + * @param[in] h Minimul allowed height of the widget + */ void setMin(int w, int h); + + /** + * @brief Sets maximum size hints to the widget + * @details Use -1 for infinity. + * @param[in] w Maximum allowed with of the widget + * @param[in] h Maximum allowed height of the widget + */ void setMax(int w, int h); - void getWeight(double *w, double *h) const; - void getAlign(double *w, double *h) const; + /** + * @brief Gets weight size hints of the widget + * @param[out] x Weight of the widget along X axis (may be NULL) + * @param[out] y Weight of the widget along Y axis (may be NULL) + */ + void getWeight(double *x, double *y) const; + + /** + * @brief Gets align size hints of the widget + * @param[out] x Align of the widget along X axis (may be NULL) + * @param[out] y Align of the widget along Y axis (may be NULL) + */ + void getAlign(double *x, double *y) const; + + /** + * @brief Gets mimimum size hints of the widget + * @param[in] w Minimul allowed with of the widget (may be NULL) + * @param[in] h Minimul allowed height of the widget (may be NULL) + */ void getMin(int *w, int *h) const; + + /** + * @brief Gets maximum size hints of the widget + * @param[in] w Maximum allowed with of the widget (may be NULL) + * @param[in] h Maximum allowed height of the widget (may be NULL) + */ void getMax(int *w, int *h) const; + /** + * @brief Sets aspect ratio size hints to the widget + * @param[in] arControl Type of aspect ration control + * @param[in] w Width aspect ration term + * @param[in] h Height aspect ration term + */ void setARHint(WidgetARHint arControl, int w, int h); + + /** + * @brief Gets aspect ratio size hints of the widget + * @param[out] arControl Type of aspect ration control + * @param[out] w Width aspect ration term + * @param[out] h Height aspect ration term + */ void getARHint(WidgetARHint &arControl, int &w, int &h); + /** + * @brief Sets key-input focus state to the widget + * @param[in] value New state. true - to set focus, false - to unset + */ void setFocused(bool value); + + /** + * @brief Gets key-input focus state of the widget + * @return true if focused, false id not focused + */ bool isFocused() const; 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 + */ virtual void setFocusedImpl(bool value); + + /** + * @brief Actually gets key-input focus state of the widget + * @details May be overriden in subclasses to change behaviour + * @return true if focused, false id not focused + */ virtual bool isFocusedImpl() const; + + /** + * @brief Setups all necessary state to handle forwarded smart events + * @details Called when a handler for UCL_SMART_FWD is added. + * @param[in] fwdEvent Smart event that needs to be forwarded + * @return true - if forwarded event is supported and necessary state + * was succesfully prepared, false - otherwise + */ virtual bool ensureFwdEvent(SmartEvent fwdEvent); private: @@ -146,24 +434,97 @@ 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 + 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) + * @param[out] y Top-left Y coordinate of the widget (may be NULL) + */ void getPosition(const Widget &widget, int *x, int *y); + + /** + * @brief Gets size of the widget + * @param[in] widget Reference to target widget + * @param[out] w Width of the widget (may be NULL) + * @param[out] h Height of the widget (may be NULL) + */ void getSize(const Widget &widget, int *w, int *h); + /** + * @brief Makes the widget visible + * @details This is equivalent to: widget.setVisible(true); + * @param[in] widget Reference to target widget + */ void show(Widget &widget); + + /** + * @brief Makes the widget invisible + * @details This is equivalent to: widget.setVisible(false); + * @param[in] widget Reference to target widget + */ void hide(Widget &widget); + /** + * @brief Makes the widget transparent + * @details This is equivalent to: widget.setColor(0, 0); + * @param[in] widget Reference to target widget + */ void makeTransparent(Widget &widget); + + /** + * @brief Makes the widget color white + * @details This is equivalent to: widget.setColor(255); + * @param[in] widget Reference to target widget + */ void makeWhite(Widget &widget); + /** + * @brief Sets widget to focused state + * @details This is equivalent to: widget.setFocused(true); + * @param[in] widget Reference to target widget + */ void focus(Widget &widget); + + /** + * @brief Sets widget to unfocused state + * @details This is equivalent to: widget.setFocused(false); + * @param[in] widget Reference to target widget + */ void unfocus(Widget &widget); + /** + * @brief Sets EXPAND weight size hits to the widget + * @details This is equivalent to: + * widget.setWight(Widget::EXPAND, Widget::EXPAND); + * @param[in] widget Reference to target widget + */ void expand(Widget &widget); + + /** + * @brief Sets FILL align size hits to the widget + * @details This is equivalent to: + * widget.setAlign(Widget::FILL, Widget::FILL); + * @param[in] widget Reference to target widget + */ void fill(Widget &widget); - void expandAndFill(Widget &widget); - bool operator==(const Widget &lhs, const Widget &rhs); - bool operator!=(const Widget &lhs, const Widget &rhs); + /** + * @brief Sets EXPAND weight and FILL align size hits to the widget + * @details This is equivalent to: expand(widget); fill(widget); + * @param[in] widget Reference to target widget + */ + void expandAndFill(Widget &widget); } #include "Widget.hpp" diff --git a/ucl/include/ucl/gui/Widget.hpp b/ucl/include/ucl/gui/Widget.hpp index 95da66a..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()); @@ -141,14 +131,14 @@ namespace ucl { evas_object_geometry_get(getEo(), x, y, w, h); } - inline void Widget::setWeight(const double w, const double h) + inline void Widget::setWeight(const double x, const double y) { - evas_object_size_hint_weight_set(getEo(), w, h); + evas_object_size_hint_weight_set(getEo(), x, y); } - inline void Widget::setAlign(const double w, const double h) + inline void Widget::setAlign(const double x, const double y) { - evas_object_size_hint_align_set(getEo(), w, h); + evas_object_size_hint_align_set(getEo(), x, y); } inline void Widget::setMin(const int w, const int h) @@ -161,14 +151,14 @@ namespace ucl { evas_object_size_hint_max_set(getEo(), w, h); } - inline void Widget::getWeight(double *const w, double *const h) const + inline void Widget::getWeight(double *const x, double *const y) const { - evas_object_size_hint_weight_get(getEo(), w, h); + evas_object_size_hint_weight_get(getEo(), x, y); } - inline void Widget::getAlign(double *const w, double *const h) const + inline void Widget::getAlign(double *const x, double *const y) const { - evas_object_size_hint_align_get(getEo(), w, h); + evas_object_size_hint_align_get(getEo(), x, y); } inline void Widget::getMin(int *const w, int *const h) const @@ -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 646cf50..3ef57d4 100644 --- a/ucl/include/ucl/gui/WidgetItem.h +++ b/ucl/include/ucl/gui/WidgetItem.h @@ -21,45 +21,172 @@ namespace ucl { + /** + * @brief Represents generic Elementary widget item and serves as base + * class for more concrete widget item types + * @details This class has semantic of a pointer and therefore does not + * manage lifetime of the item. Pointer is always point to the non + * constant Genlist item. Most of the methods marked as const + * because pointer is not changed in these method calls. + */ class WidgetItem { public: + /** + * @brief Default constructor + * @details Constructs NULL item + */ constexpr WidgetItem(); + + /** + * @brief Constructor + * @details Same as default constructor + */ constexpr WidgetItem(std::nullptr_t); + + /** + * @brief Constructor + * @details Wraps native Elementary widget item. + * @param[in] it Native Elementary widget item + */ explicit WidgetItem(Elm_Object_Item *it); + /** + * @brief Gets native Elementary widget item + * @return Pointer to native Elementary widget item + */ Elm_Object_Item *getIt() const; + /** + * @brief Implicitly casts to native Elementary widget item + * @return Pointer to native Elementary widget item + */ operator Elm_Object_Item *() const; + + /** + * @brief Explicitly casts to boolen type + * @return true if native item is not NULL, false - if NULL + */ explicit operator bool() const; + /** + * @brief Gets owning Evas object of this widget item + * @return Pointer to the owning Evas object + */ Evas_Object *getWidget() const; + /** + * @brief Sets widget item delete callback + * @details Callback is called when item is deleted. + * Data of the callback is set by setData() method. + * @param[in] cb Pointer to callback function + */ void setDelCallback(Evas_Smart_Cb cb) const; + /** + * Deletes this widget item and NULL the pointer + */ void del(); + /** + * @brief Assigns user data to this widget item + * @param[in] data Pointer to the user data + */ void setData(void *data) const; + + /** + * @brief Gets assigned user data to this widget item + * @return Pointer to the assigned user data or NULL + */ void *getData() const; + /** + * @brief Sets enabled state of the widget item + * @param[in] value New state + */ void setEnabled(bool value) const; + + /** + * @brief Gets enabled state of the widget item + * @return true if enabled, false if disabled + */ bool isEnabled() const; + /** + * @brief Applies style to the widget item + * @param[in] style Style to apply + */ void setStyle(ElmStyle style) const; + /** + * @brief Sets text to default part of the widget item + * @param[in] value Translatable text value to set + */ void setText(const TString &value) const; - void setText(const TString &value, EdjePart part) const; - TString getText() const; - TString getText(EdjePart part) const; + /** + * @brief Sets text to specific part of the widget item + * @param[in] value Translatable text value to set + * @param[in] part Destination Edje part + */ + void setText(const TString &value, EdjePart part) const; - void setContent(Evas_Object *content) const; - void setContent(Evas_Object *content, EdjePart part) const; + /** + * @brief Gets text from default part of the widget item + * @return Translated text from default part + */ + std::string getText() const; + + /** + * @brief Gets text from specific part of the widget item + * @param[in] part Source Edje part + * @return Translated text from specific part + */ + std::string getText(EdjePart part) const; + + /** + * @brief Sets content to default part of the widget item + * @param[in] content Content widget + */ + void setContent(Widget &content) const; + + /** + * @brief Sets content to specific part of the widget item + * @param[in] content Content widget + * @param[in] part Destination Edje part + */ + void setContent(Widget &content, EdjePart part) const; + + /** + * @brief Unsets content from default part of the widget item + * @return Content Evas object or NULL + */ Evas_Object *unsetContent() const; + + /** + * @brief Unsets content from specific part of the widget item + * @param[in] part Source Edje part + * @return content Evas object or NULL + */ Evas_Object *unsetContent(EdjePart part) const; + /** + * @brief Gets content from default part of the widget item + * @return Content Evas object or NULL + */ Evas_Object *getContent() const; + + /** + * @brief Gets content from specific part of the widget item + * @param[in] part Source Edje part + * @return content Evas object or NULL + */ Evas_Object *getContent(EdjePart part) const; + /** + * @brief Emits signal to the widget item's Edje theme + * @param[in] signal Emitted signal + * @param[in] signal Emitted signal source (optional) + */ void emit(EdjeSignal signal, EdjeSignalSrc source = EdjeSignalSrc("")) const; @@ -69,10 +196,32 @@ namespace ucl { // Non-member functions // + /** + * @brief Sets widget item to enabled state + * @details This is equivalent to: item.setEnabled(true); + * @param[in] item Reference to target widget item + */ void enable(WidgetItem item); + + /** + * @brief Sets widget item to disabled state + * @details This is equivalent to: item.setEnabled(false); + * @param[in] item Reference to target widget item + */ void disable(WidgetItem item); + /** + * @brief Compares equals underlying item pointers of target widgets items + * @param[in] lhs Left hand side operand + * @param[in] rhs Right hand side operand + */ bool operator==(WidgetItem lhs, WidgetItem rhs); + + /** + * @brief Compares unequals underlying item pointers of target widget items + * @param[in] lhs Left hand side operand + * @param[in] rhs Right hand side operand + */ bool operator!=(WidgetItem lhs, WidgetItem rhs); } diff --git a/ucl/include/ucl/gui/WidgetItem.hpp b/ucl/include/ucl/gui/WidgetItem.hpp index 26b6cbd..b36cfa4 100644 --- a/ucl/include/ucl/gui/WidgetItem.hpp +++ b/ucl/include/ucl/gui/WidgetItem.hpp @@ -87,25 +87,25 @@ namespace ucl { elm_object_item_style_set(getIt(), style.name); } - inline TString WidgetItem::getText() const + inline std::string WidgetItem::getText() const { return elm_object_item_text_get(getIt()); } - inline TString WidgetItem::getText(const EdjePart part) const + inline std::string WidgetItem::getText(const EdjePart part) const { 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/gui/Window.h b/ucl/include/ucl/gui/Window.h index c21fb42..053a627 100644 --- a/ucl/include/ucl/gui/Window.h +++ b/ucl/include/ucl/gui/Window.h @@ -27,29 +27,98 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(Window); + /** + * @brief Represents Elementary Window widget with Conformant + */ class Window final : public ElmWidget { public: + /** + * @brief Enumeration of Window types + */ enum class Type { BASIC = ELM_WIN_BASIC }; + /** + * @brief Builder of Window objects + */ class Builder final { public: + /** + * @brief Constructor + */ Builder(); + /** + * @brief Sets Evas object for the future window + * @details If Evas object is set builder will create wrapper + * Window object. + * @param[in] value Pointer to window Evas object + * @return Reference to this builder + */ Builder &setWinEo(Evas_Object *value); + /** + * @brief Sets type of the future window + * @details Ignored if WinEo is set. + * @param[in] type Type of the future window + * @return Reference to this builder + */ Builder &setType(Type type); + + /** + * @brief Sets name of the future window + * @details Ignored if WinEo is set or used as title (if not set). + * @param[in] value Name of the future window + * @return Reference to this builder + */ Builder &setName(std::string value); + /** + * @brief Sets title of the future window + * @details Name is used if not set. + * @param[in] value Title of the future window + * @return Reference to this builder + */ Builder &setTitle(std::string value); + + /** + * @brief Sets indicator visibility state of the future window + * @param[in] value Indicator visibility state of the future window + * @return Reference to this builder + */ Builder &setIndicatorVisible(bool value); + + /** + * @brief Sets supported rotations by the future window + * @param[in] value Rotations supported by the future window + * @return Reference to this builder + */ Builder &setRotations(std::vector value); + /** + * @brief Sets Evas object ownership flag of the future object + * @details If not set and WinEo is also not IsOwner + * is true by default, otherwise - false. + * @param[in] value true if owner, false - otherwise + * @return Reference to this builder + */ Builder &setIsOwner(bool value); + + /** + * @brief Sets if future object needs to be bind to it's Evas object + * @param[in] value true if need to bind, false - otherwise + * @return Reference to this builder + */ Builder &setNeedBindToEo(bool value); + /** + * @brief Creates new Window object using current parameters + * @param[in] parent Reference to parent widget + * @return Shared reference to new Window object or NULL + */ WindowSRef build() const; + private: std::string m_name; std::string m_title; @@ -63,21 +132,69 @@ namespace ucl { }; public: + /** + * @brief Gets conformant of this Window + * @return Reference to Conformant widget + */ StyledWidget &getConformant(); + + /** + * @brief Gets conformant of this Window (constant version) + * @return Reference to constant Conformant widget + */ const StyledWidget &getConformant() const; + /** + * @brief Gets screen size of the window + * @param[out] w Width of the screen (may be NULL) + * @param[out] h Height of the screen (may be NULL) + */ void getScreenSize(int *w, int *h) const; + /** + * @brief Sets title of the window + * @param[in] value Title of the window + */ void setTitle(const std::string &title); + + /** + * @brief Gets title of the window + * @return Title of the window + */ std::string getTitle() const; + /** + * Sets window indicator visibility state + * @param[in] value Visibility state. true - visible, false - invisible + */ void setIndicatorVisible(bool value); + + /** + * Gets window indicator visibility state + * @retrun Visibility state. true - visible, false - invisible + */ bool isIndicatorVisible() const; + /** + * Gets window rotations support status + * @retrun true - rotation supported, false - no supported + */ bool isRotationsSupported() const; + + /** + * @brief Sets supported rotations to the window + * @param[in] value Rotations supported by the window + */ void setRotations(const std::vector &value); + /** + * @brief Resizes the window to fill whole screen + */ void resizeToScreen(); + + /** + * @brief Moves window to foreground + */ void lower(); private: @@ -94,11 +211,27 @@ namespace ucl { // Window // + /** + * @brief Makes the window indicator visible + * @details This is equivalent to: win.setIndicatorVisible(true); + * @param[in] win Reference to target window + */ void showIndicator(Window &win); + + /** + * @brief Makes the window indicator invisible + * @details This is equivalent to: win.setIndicatorVisible(false); + * @param[in] win Reference to target window + */ void hideIndicator(Window &win); // Window::Type // + /** + * @brief Checks validity of window type value + * @param[in] winType Window type value to validate + * @return true - if window type valid, false - otherwise + */ bool isValid(Window::Type winType); } diff --git a/ucl/include/ucl/gui/helpers.h b/ucl/include/ucl/gui/helpers.h index d42eccb..6e2bd22 100644 --- a/ucl/include/ucl/gui/helpers.h +++ b/ucl/include/ucl/gui/helpers.h @@ -23,11 +23,31 @@ namespace ucl { // Converts Evas_Object to Widget pointer // + /** + * @brief Converts Evas object pointer to Widget pointer + * @details Widget::bindToEo() must be called on widget object in order + * for this function to work. + * @return Pointer to the corresponding Widget object or NULL + */ Widget *asWidget(Evas_Object *eo); + + /** + * @brief Converts pointer to constant Evas object to pointer + * to constant Widget + * @details Widget::bindToEo() must be called on widget object in order + * for this function to work. + * @return Pointer to the corresponding Widget object or NULL + */ const Widget *asWidget(const Evas_Object *eo); // Widget casting functions from Evas_Object // + /** + * @brief Statically casts Evas object pointer to WIDGET_TYPE pointer + * @details This function performs static_cast on + * the result of asWidget() function call. + * @return Pointer to the corresponding WIDGET_TYPE object or NULL + */ template inline auto staticWidgetCast(Evas_Object *eo) -> decltype(static_cast(asWidget(eo))) @@ -35,13 +55,27 @@ namespace ucl { return static_cast(asWidget(eo)); } + /** + * @brief Statically casts pointer to constant Evas object to pointer + * to constant WIDGET_TYPE + * @details This function performs static_cast on + * the result of asWidget() function call. + * Do not need to add const to WIDGET_TYPE. + * @return Pointer to the corresponding WIDGET_TYPE object or NULL + */ template inline auto staticWidgetCast(const Evas_Object *eo) -> - decltype(static_cast(asWidget(eo))) + decltype(static_cast(asWidget(eo))) { - return static_cast(asWidget(eo)); + return static_cast(asWidget(eo)); } + /** + * @brief Dynamically casts Evas object pointer to WIDGET_TYPE pointer + * @details This function performs dynamic_cast on + * the result of asWidget() function call. + * @return Pointer to the corresponding WIDGET_TYPE object or NULL + */ template inline auto dynamicWidgetCast(Evas_Object *eo) -> decltype(dynamic_cast(asWidget(eo))) @@ -49,13 +83,27 @@ namespace ucl { return dynamic_cast(asWidget(eo)); } + /** + * @brief Dynamically casts pointer to constant Evas object to pointer + * to constant WIDGET_TYPE + * @details This function performs dynamic_cast + * on the result of asWidget() function call. + * Do not need to add const to WIDGET_TYPE. + * @return Pointer to the corresponding WIDGET_TYPE object or NULL + */ template inline auto dynamicWidgetCast(const Evas_Object *eo) -> - decltype(dynamic_cast(asWidget(eo))) + decltype(dynamic_cast(asWidget(eo))) { - return dynamic_cast(asWidget(eo)); + return dynamic_cast(asWidget(eo)); } + /** + * @brief Statically casts Evas object pointer to SharedRef + * @details This function calls asShared() on the result of + * staticWidgetCast() function call. + * @return Shared reference to the corresponding WIDGET_TYPE object or NULL + */ template inline auto staticWidgetRefCast(Evas_Object *eo) -> decltype(asShared(staticWidgetCast(eo))) @@ -63,6 +111,13 @@ namespace ucl { return asShared(staticWidgetCast(eo)); } + /** + * @brief Statically casts pointer to constant Evas object + * to SharedRef + * @details This function calls asShared() on the result of + * staticWidgetCast() function call. + * @return Shared reference to the corresponding WIDGET_TYPE object or NULL + */ template inline auto staticWidgetRefCast(const Evas_Object *eo) -> decltype(asShared(staticWidgetCast(eo))) @@ -70,6 +125,12 @@ namespace ucl { return asShared(staticWidgetCast(eo)); } + /** + * @brief Dynamically casts Evas object pointer to SharedRef + * @details This function calls asShared() on the result of + * dynamicWidgetCast() function call. + * @return Shared reference to the corresponding WIDGET_TYPE object or NULL + */ template inline auto dynamicWidgetRefCast(Evas_Object *eo) -> decltype(asShared(dynamicWidgetCast(eo))) @@ -77,6 +138,13 @@ namespace ucl { return asShared(dynamicWidgetCast(eo)); } + /** + * @brief Dynamically casts pointer to constant Evas object + * to SharedRef + * @details This function calls asShared() on the result of + * dynamicWidgetCast() function call. + * @return Shared reference to the corresponding WIDGET_TYPE object or NULL + */ template inline auto dynamicWidgetRefCast(const Evas_Object *eo) -> decltype(asShared(dynamicWidgetCast(eo))) diff --git a/ucl/include/ucl/gui/stdTheme/common.h b/ucl/include/ucl/gui/stdTheme/common.h index 7ec81b9..d7537c2 100644 --- a/ucl/include/ucl/gui/stdTheme/common.h +++ b/ucl/include/ucl/gui/stdTheme/common.h @@ -23,15 +23,36 @@ namespace ucl { // Styles // + /** + * @brief Style that is default for wide range of widgets + */ constexpr ElmStyle STYLE_DEFAULT {"default"}; // Parts // + /** + * @brief Default text part for wide range of widgets + */ constexpr EdjePart PART_TEXT {"elm.text"}; + + /** + * @brief Default title text part for wide range of widgets + */ constexpr EdjePart PART_TITLE {"elm.text.title"}; + /** + * @brief Default content part for wide range of widgets + */ constexpr EdjePart PART_CONTENT {"elm.swallow.content"}; + + /** + * @brief Default icon part for wide range of widgets + */ constexpr EdjePart PART_ICON {"elm.swallow.icon"}; + + /** + * @brief Default button part for wide range of widgets + */ constexpr EdjePart PART_BUTTON {"elm.swallow.button"}; } diff --git a/ucl/include/ucl/gui/stdTheme/layout.h b/ucl/include/ucl/gui/stdTheme/layout.h index 79ff426..24bc361 100644 --- a/ucl/include/ucl/gui/stdTheme/layout.h +++ b/ucl/include/ucl/gui/stdTheme/layout.h @@ -21,8 +21,14 @@ namespace ucl { + /** + * @brief Application default layout theme + */ constexpr LayoutTheme LAYOUT_DEFAULT {"layout", "application", "default"}; + /** + * @brief No contents layout theme + */ constexpr LayoutTheme LAYOUT_NO_CONTENTS {"layout", "nocontents", "default"}; } diff --git a/ucl/include/ucl/gui/stdTheme/naviframe.h b/ucl/include/ucl/gui/stdTheme/naviframe.h index fd99fdc..9c0cc49 100644 --- a/ucl/include/ucl/gui/stdTheme/naviframe.h +++ b/ucl/include/ucl/gui/stdTheme/naviframe.h @@ -21,6 +21,9 @@ namespace ucl { + /** + * @brief Empty naviframe style (only with content part) + */ constexpr ElmStyle NAVIFRAME_EMPTY {"empty"}; } diff --git a/ucl/include/ucl/gui/types.h b/ucl/include/ucl/gui/types.h index 6d43d76..03dd8aa 100644 --- a/ucl/include/ucl/gui/types.h +++ b/ucl/include/ucl/gui/types.h @@ -33,34 +33,70 @@ namespace ucl { // Aspects // + /** + * @brief Represent Edje part name + */ struct EdjePart : Aspect { using Aspect::Aspect; }; + + /** + * @brief Represent Edje group name + */ struct EdjeGroup : Aspect { using Aspect::Aspect; }; + + /** + * @brief Represent Edje data key name + */ struct EdjeDataKey : Aspect { using Aspect::Aspect; }; + /** + * @brief Represent Edje signal name + */ struct EdjeSignal : Aspect { using Aspect::Aspect; }; + + /** + * @brief Represent Edje signal source name + */ struct EdjeSignalSrc : Aspect { using Aspect::Aspect; }; + /** + * @brief Represent Elementary widget style name + */ struct ElmStyle : Aspect { using Aspect::Aspect; }; + /** + * @brief Represent Evas object smart callback name + */ struct SmartEvent : Aspect { using Aspect::Aspect; }; + /** + * @brief Represent Evas object data key name + */ struct EoDataKey : Aspect { using Aspect::Aspect; }; // Delegates // + /** + * @brief Handler for events with the Evas object smart callback signature + */ using SmartCbHandler = Delegate; // WidgetEventHandler // class Widget; + /** + * @brief Handler for Widget standard/smart events + */ using WidgetEventHandler = WeakDelegate; // WidgetEvent // + /** + * @brief Enumeration of Widget standard events + */ enum class WidgetEvent { - DEL = EVAS_CALLBACK_DEL, + DEL = EVAS_CALLBACK_DEL, MOUSE_IN = EVAS_CALLBACK_MOUSE_IN, MOUSE_OUT = EVAS_CALLBACK_MOUSE_OUT, @@ -94,16 +130,34 @@ namespace ucl { // AtspiGestureEventInfo // + class Atspi; + + /** + * @brief Event info data for ATSPI gesture smart event + */ struct AtspiGestureEventInfo final { Elm_Atspi_Gesture_Info gestureInfo; bool preventDefault; bool stopPropagation; }; + /** + * @brief Handler for Atspi gesture events + */ + using AtspiGestureHandler = WeakDelegate; + + /** + * @brief Callback for Atspi string requesting functions (name, description) + */ + using AtspiStringCb = WeakDelegate; + // WidgetARHint // - enum class WidgetARHint - { + /** + * @brief Enumeration of widget aspect ration hints + */ + enum class WidgetARHint { NEITHER = EVAS_ASPECT_CONTROL_NEITHER, HORIZONTAL = EVAS_ASPECT_CONTROL_HORIZONTAL, VERTICAL = EVAS_ASPECT_CONTROL_VERTICAL, @@ -112,19 +166,54 @@ namespace ucl { // LayoutTheme // + /** + * @brief Represents Layout theme description + */ struct LayoutTheme final { + /** + * @brief Name of the widget class + */ const char *klass; + + /** + * @brief Name of the group + */ const char *group; + + /** + * @brief Name of the style + */ const char *style; + /** + * @brief Default constructor + * @details Constructs empty non valid LayoutTheme + */ constexpr LayoutTheme(); + + /** + * @brief Constructor + * @details Same as default constructor + */ constexpr LayoutTheme(std::nullptr_t); + + /** + * @brief Constructor + * @param[in] klass Name of the widget class + * @param[in] group Name of the group + * @param[in] style Name of the style + */ constexpr LayoutTheme(const char *klass, const char *group, const char *style); }; // LayoutTheme non-member functions // + /** + * @brief Checks whether LayoutTheme object is valid + * @param[in] value Reference to target LayoutTheme object + * @return true if valid, false if not valid + */ constexpr bool isValid(const LayoutTheme &value); } diff --git a/ucl/include/ucl/misc/Aspect.h b/ucl/include/ucl/misc/Aspect.h index 0c55bf6..88c92b6 100644 --- a/ucl/include/ucl/misc/Aspect.h +++ b/ucl/include/ucl/misc/Aspect.h @@ -21,16 +21,44 @@ namespace ucl { + /** + * @brief Implementation for CHILD aspect + * @details CHILD class must inherit from this template to implement + * specific aspect + */ template struct Aspect { + /** + * @brief Name of the aspect + */ const char *name; + /** + * @brief Default constructor + * @details Initializes "name" to NULL. + */ constexpr Aspect(); + + /** + * @brief Constructor + * @details Same as default constructor + */ constexpr Aspect(std::nullptr_t); + + /** + * @brief Constructor + * @param[in] name Name for the new aspect or NULL + */ explicit constexpr Aspect(const char *name); + /** + * @brief Returns name of the aspect + */ constexpr operator const char *() const; + /** + * @brief Custom hash functor for Aspect + */ struct Hash final { size_t operator()(const Aspect &key) const; }; @@ -38,11 +66,29 @@ namespace ucl { // Non-member functions // + /** + * @brief Checks validity of the Aspect (name is not NULL) + * @param[in] aspect Target aspect + * @return Validity status. true - valid, false - not valid + */ template constexpr bool isValid(Aspect aspect); + /** + * @brief Compares equals names of target aspects + * @param[in] lhs Left hand side operand + * @param[in] rhs Right hand side operand + * @return true - if equal, false - not equal + */ template constexpr bool operator==(Aspect lhs, Aspect rhs); + + /** + * @brief Compares unequals names of target aspects + * @param[in] lhs Left hand side operand + * @param[in] rhs Right hand side operand + * @return true - if not equal, false - equal + */ template constexpr bool operator!=(Aspect lhs, Aspect rhs); } diff --git a/ucl/include/ucl/misc/AutoObject.h b/ucl/include/ucl/misc/AutoObject.h index e2d06a1..cb65f9e 100644 --- a/ucl/include/ucl/misc/AutoObject.h +++ b/ucl/include/ucl/misc/AutoObject.h @@ -21,27 +21,54 @@ namespace ucl { + /** + * @brief Resource wrapper for automatically deallocate OBJ_TYPE + * using DEL_FUNC in destructor + */ template struct AutoObject final : ucl::NonCopyable { - using Handle = OBJ_TYPE; - + /** + * @brief Type of the wrapped object + */ + using ObjType = OBJ_TYPE; + + /** + * @brief Value of the object + */ OBJ_TYPE obj; + /** + * @brief Default constructor + * @details Initializes "obj" using value initialization + */ AutoObject() : obj{} { } + /** + * @brief Constructor + * @details Same as default constructor + */ AutoObject(std::nullptr_t) : AutoObject() { } + /** + * @brief Constructor + * @param[in] obj Source object to wrap + */ AutoObject(const OBJ_TYPE &obj) : obj{obj} { } + /** + * @brief Destructor + * @details Calls DEL_FUNC on the object if it explicitly + * casts to "true" + */ ~AutoObject() { if (obj) { @@ -49,23 +76,42 @@ namespace ucl { } } + /** + * @brief Move constructor + * @details Source will be in the default constructed state + * @param[in] src Source of the move + */ AutoObject(AutoObject &&src) : obj{src.obj} { src.obj = {}; } + /** + * @brief Assigns one AutoObject to another + * @details Only move assignment is possible. Original will be deleted. + * @param[in] src Source AutoObject + * @return Reference to this AutoObject + */ AutoObject &operator=(AutoObject src) { swap(*this, src); return *this; } + /** + * @brief Returns pointer to "obj" member + * @datails This is unsafe function, avoid using it. May use in + * templates to get the underlying object type. + */ OBJ_TYPE *operator&() { return &obj; } + /** + * @brief Returns constant reference to "obj" + */ operator const OBJ_TYPE &() const { return obj; @@ -74,6 +120,11 @@ namespace ucl { // Non-member functions // + /** + * @brief Swaps AutoObject objects with each other + * @param[in/out] x First AutoObject + * @param[in/out] y Second AutoObject + */ template inline void swap(AutoObject &x, AutoObject &y) noexcept diff --git a/ucl/include/ucl/misc/CArray.h b/ucl/include/ucl/misc/CArray.h index 1318735..9e5ca11 100644 --- a/ucl/include/ucl/misc/CArray.h +++ b/ucl/include/ucl/misc/CArray.h @@ -21,31 +21,73 @@ namespace ucl { + /** + * @brief Simple wrapper for C-Style array of T + */ template struct CArray { + /** + * @brief Data of the array + */ T *data; + + /** + * @brief Length of the array + */ int length; + /** + * @brief Default constructor + * @details Creates empty array + */ CArray() noexcept; + + /** + * @brief Constructor + * @details Same as default constructor + */ CArray(std::nullptr_t) noexcept; + /** + * @brief Checks if array is no empty + * @return true - array is not empty, false - array is empty + */ explicit operator bool() const noexcept; }; // Non-member functions // + /** + * @brief Checks validity of the CArray + * @param[in] array Target array + * @return Validity status. true - valid, false - not valid + */ template bool isValid(const CArray &array); + /** + * @brief Checks emptiness of the CArray + * @param[in] array Target array + * @return Emptiness status. true - empty, false - not empty + */ template bool isEmpty(const CArray &array); + /** + * @brief Performs destruction of the array and array items + * @param[in] array Target array + * @param[in] itemDelCb Callback which is called to delete each item + */ template void performDestroy(const CArray &array, ITEM_DEL_CB &&itemDelCb); } namespace ucl { namespace aux { + /** + * @brief Performs destruction of the array and array items using free + * @param[in] array Target array + */ template void destroyUsingFree(CArray array); }} diff --git a/ucl/include/ucl/misc/CString.h b/ucl/include/ucl/misc/CString.h index 5496cda..1704f63 100644 --- a/ucl/include/ucl/misc/CString.h +++ b/ucl/include/ucl/misc/CString.h @@ -21,25 +21,85 @@ namespace ucl { + /** + * @brief Represents managed mutable C-String + */ class CString final : protected NonCopyable { public: + /** + * @brief Swaps CString objects with each other + * @param[in/out] x First theme object + * @param[in/out] y Second theme object + */ friend void swap(CString &x, CString &y) noexcept; + /** + * @brief Creates new CString object by duplicating source C-String + * @param[in] ptr Pointer to source C-String + * @details New C-String will be freed in destructor. + */ static CString dup(const char *ptr); + + /** + * @brief Creates new CString object by taking over source C-String + * @param[in] ptr Pointer to source C-String + * @details Source C-String will be freed in destructor. + */ static CString takeover(char *ptr) noexcept; + /** + * @brief Defatult constructor + * @details Creates NULL CString object + */ CString() noexcept; + + /** + * @brief Constructor + * @details Same as default constructor + */ CString(std::nullptr_t) noexcept; + + /** + * @brief Move constructor + * @details Transfers ownership from source to the new object. + * Source string pointer will become NULL. + * @param[in] s Source CString object + */ CString(CString &&s) noexcept; + + /** + * @brief Converting constructor + * @details Duplicates source std::string if it is not empty. + * If std::string is empty NULL CString object will be created. + * @param[in] s Source std::string object + */ CString(const std::string &s); + + /** + * @brief Destructor + * @details Frees C-String pointer if not NULL + */ ~CString() noexcept; + /** + * @brief Assigns one CString object to another + * @details Only move assignment is possible. Original will be deleted. + * @param[in] s Source CString object + * @return Reference to this CString object + */ CString &operator=(CString s) noexcept; - bool isEmpty() const; - + /** + * @brief Releases this CString object from C-String ownership + * @details This CString object will become NULL + * @return Pointer to underlying C-String + */ char *release() noexcept; + /** + * @brief Gets underlying C-String pointer; + * @return Pointer to underlying C-String + */ char *get() const noexcept; private: @@ -48,6 +108,14 @@ namespace ucl { private: char *m_ptr; }; + + /** + * @brief Checks whether string is empty + * @details This is equivalent to: isEmpty(s.get()); + * @param[in] s Reference to target CString object + * @return true if empty, false if not empty + */ + bool isEmpty(const CString &s); } #include "CString.hpp" diff --git a/ucl/include/ucl/misc/CString.hpp b/ucl/include/ucl/misc/CString.hpp index 086b3c2..b7456f3 100644 --- a/ucl/include/ucl/misc/CString.hpp +++ b/ucl/include/ucl/misc/CString.hpp @@ -67,11 +67,6 @@ namespace ucl { return *this; } - inline bool CString::isEmpty() const - { - return !m_ptr; - } - inline char *CString::release() noexcept { char *const result = m_ptr; @@ -90,4 +85,9 @@ namespace ucl { { std::swap(x.m_ptr, y.m_ptr); } + + inline bool isEmpty(const CString &s) + { + return isEmpty(s.get()); + } } diff --git a/ucl/include/ucl/misc/ConstCString.h b/ucl/include/ucl/misc/ConstCString.h index e319676..51bd3ca 100644 --- a/ucl/include/ucl/misc/ConstCString.h +++ b/ucl/include/ucl/misc/ConstCString.h @@ -21,22 +21,72 @@ namespace ucl { + /** + * @brief Represents managed constant C-String + */ class ConstCString final : protected NonCopyable { public: + /** + * @brief Swaps ConstCString objects with each other + * @param[in/out] x First theme object + * @param[in/out] y Second theme object + */ friend void swap(ConstCString &x, ConstCString &y) noexcept; + /** + * @brief Creates new ConstCString object by wrapping source C-String + * @param[in] ptr Pointer to source C-String + * @details Source C-String will not be freed in destructor. + * Ownership can be transferred only using move constructors. + */ static ConstCString wrap(const char *ptr) noexcept; + /** + * @brief Defatult constructor + * @details Creates NULL ConstCString object + */ ConstCString() noexcept; + + /** + * @brief Constructor + * @details Same as default constructor + */ ConstCString(std::nullptr_t) noexcept; + + /** + * @brief Move constructor + * @details Transfers ownership from source to the new object. + * Source string pointer will not change. + * @param[in] s Source ConstCString object + */ ConstCString(ConstCString &&s) noexcept; + + /** + * @brief Move constructor + * @details Transfers ownership from source to the new object. + * Source string pointer will become NULL. + * @param[in] s Source CString object + */ ConstCString(CString &&s) noexcept; + + /** + * @brief Destructor + * @details Frees C-String pointer if owner + */ ~ConstCString() noexcept; + /** + * @brief Assigns one ConstCString object to another + * @details Only move assignment is possible. Original will be deleted. + * @param[in] s Source ConstCString object + * @return Reference to this ConstCString object + */ ConstCString &operator=(ConstCString s) noexcept; - bool isEmpty() const; - + /** + * @brief Gets underlying C-String pointer; + * @return Pointer to underlying C-String + */ const char *get() const noexcept; private: @@ -46,6 +96,14 @@ namespace ucl { const char *m_ptr; bool m_isOwner; }; + + /** + * @brief Checks whether string is empty + * @details This is equivalent to: isEmpty(s.get()); + * @param[in] s Reference to target ConstCString object + * @return true if empty, false if not empty + */ + bool isEmpty(const ConstCString &s); } #include "ConstCString.hpp" diff --git a/ucl/include/ucl/misc/ConstCString.hpp b/ucl/include/ucl/misc/ConstCString.hpp index 50df605..7089b52 100644 --- a/ucl/include/ucl/misc/ConstCString.hpp +++ b/ucl/include/ucl/misc/ConstCString.hpp @@ -66,11 +66,6 @@ namespace ucl { return *this; } - inline bool ConstCString::isEmpty() const - { - return !m_ptr; - } - inline const char *ConstCString::get() const noexcept { return m_ptr; @@ -83,4 +78,9 @@ namespace ucl { std::swap(x.m_ptr, y.m_ptr); std::swap(x.m_isOwner, y.m_isOwner); } + + inline bool isEmpty(const ConstCString &s) + { + return isEmpty(s.get()); + } } diff --git a/ucl/include/ucl/misc/Event.h b/ucl/include/ucl/misc/Event.h index cd27f29..cb72292 100644 --- a/ucl/include/ucl/misc/Event.h +++ b/ucl/include/ucl/misc/Event.h @@ -23,20 +23,61 @@ namespace ucl { + /** + * @brief Implements event dispatching using specified DELEGATE class + */ template class Event final { public: + /** + * @brief Default constructor + */ Event(); + /** + * @brief Adds new delegate to the delegate list + * @param[in] delegate Delagate object to add. + * DELEGATE2 must be convertible to DELEGATE + */ template void operator+=(DELEGATE2 &&delegate); + + /** + * @brief Removes existing delegate from the delegate list + * @param[in] delegate Delagate object to add. + * DELEGATE2 must be comparable with DELEGATE + */ template void operator-=(const DELEGATE2 &delegate); + /** + * @brief Checks if the delegate list is empty + * @return true - the delegate list is empty, false - not empty + */ bool isEmpty() const; + /** + * @brief Dispatches event on delegates in list + * @details Delegates are called in order from old to new. If new + * delegates will be added in the dispatch process they will + * be ignored until next dispatch. It is possible to remove + * existing delegate from list. Removed delagate will not be + * invoked. + * @param[in] args Event dispatch arguments + */ template void dispatch(ARGS &&...args); + + /** + * @brief Dispatches event on delegates using canceling predecate + * @details Same as dispatch() but with canceling predecate. Predicate + * is called on each delegate invoke with the return result of + * this invoke as single argument or no arguments if return + * type is void. Predicate must return true if dispatch should + * continue or false if it should stop. Result type of the + * predicate may be any object convertible to bool. + * @param[in] args Event dispatch arguments + */ template void dispatchPred(PREDICATE &&pred, ARGS &&...args); diff --git a/ucl/include/ucl/misc/HashMap.h b/ucl/include/ucl/misc/HashMap.h index 8470fed..ada832e 100644 --- a/ucl/include/ucl/misc/HashMap.h +++ b/ucl/include/ucl/misc/HashMap.h @@ -31,17 +31,51 @@ namespace ucl { using VarDict = Dict; + /** + * @brief Represents simple to use HashMap collection + * @details Enumerations are supported as KEY type. Custom hashing function + * may be specified for KEY using nested KEY::Hash functor. + */ template class HashMap final { public: + /** + * @brief Sets value with specified key to the map + * @details Overrides existing values + * @param[in] key Key of the value + * @param[in] value Value + * @return Reference to this hashMap object + */ template HashMap &set(const KEY &key, VALUE2 &&value); + + /** + * @brief Unsets value with specified key from the map + * @details Removes existing value or do nothing + * @param[in] key Key of the value + * @return Reference to this hashMap object + */ HashMap &unset(const KEY &key); + /** + * @brief Gets value with specified key from the map + * @param[in] key Key of the value + * @param[out] value Existing value if exists + * @return true - if value with key exists, false - not exists + */ template bool get(const KEY &key, VALUE2 &value) const; + + /** + * @brief Gets value with specified key from the map + * @param[in] key Key of the value + * @return Existing value if exists, or {} if not exists + */ VALUE get(const KEY &key) const; + /** + * @brief Removes all values from the map + */ void clear(); private: diff --git a/ucl/include/ucl/misc/MonoObservable.h b/ucl/include/ucl/misc/MonoObservable.h index 16604b2..dd4c9bf 100644 --- a/ucl/include/ucl/misc/MonoObservable.h +++ b/ucl/include/ucl/misc/MonoObservable.h @@ -23,30 +23,87 @@ namespace ucl { + /** + * @brief Represents observable value of type T by single observer + */ template class MonoObservable final : protected NonCopyable { public: + /** + * @brief Swaps MonoObservable objects with each other + * @param[in/out] x First theme object + * @param[in/out] y Second theme object + */ template friend void swap(MonoObservable &x, MonoObservable &y) noexcept; public: + /** + * @brief Defatult constructor + * @details Value will be initialized with {} + */ MonoObservable() noexcept; + + /** + * @brief Conversion constructor + * @param[in] value Source value + */ explicit MonoObservable(T value) noexcept; + + /** + * @brief Constructor + * @param[in] value Source value + * @param[in] handler Observer of the value change + */ MonoObservable(T value, NotiHandler handler) noexcept; + + /** + * @brief Move constructor + * @param[in] rv Source MonoObservable object + */ MonoObservable(MonoObservable &&rv) noexcept; + /** + * @brief Assigns one MonoObservable object to another + * @details Only move assignment is possible. Original will be deleted. + * @param[in] s Source MonoObservable object + * @return Reference to this MonoObservable object + */ MonoObservable &operator=(MonoObservable v) noexcept; + /** + * @brief Assigns an observer to this observable + * @param[in] handler Observer delegate (may be empty to remove) + */ void setObserver(NotiHandler handler) noexcept; + /** + * @brief Gets value of this observable + * @return Constant reference to the value of this observable + */ const T &getValue() const noexcept; + /** + * @brief Casts to the value of this observable + * @return Constant reference to the value of this observable + */ operator const T &() const noexcept; + /** + * @brief Assigns new value to this observable + * @param[in] value New value + * @return Reference to this MonoObservable object + */ MonoObservable &operator=(const T &value); + + /** + * @brief Move-assigns new value to this observable + * @param[in] value New value + * @return Reference to this MonoObservable object + */ MonoObservable &operator=(T &&value); - public: + private: T m_value; NotiHandler m_onValueChanged; }; diff --git a/ucl/include/ucl/misc/Observable.h b/ucl/include/ucl/misc/Observable.h index 4e180f4..0fc7209 100644 --- a/ucl/include/ucl/misc/Observable.h +++ b/ucl/include/ucl/misc/Observable.h @@ -22,30 +22,86 @@ namespace ucl { + /** + * @brief Represents observable value of type T by multiple observers + */ template class Observable final : protected NonCopyable { public: + /** + * @brief Swaps Observable objects with each other + * @param[in/out] x First theme object + * @param[in/out] y Second theme object + */ template friend void swap(Observable &x, Observable &y) noexcept; public: + /** + * @brief Defatult constructor + * @details Value will be initialized with {} + */ Observable() noexcept; + + /** + * @brief Conversion constructor + * @param[in] value Source value + */ explicit Observable(T value) noexcept; + + /** + * @brief Move constructor + * @param[in] rv Source Observable object + */ Observable(Observable &&rv) noexcept; + /** + * @brief Assigns one Observable object to another + * @details Only move assignment is possible. Original will be deleted. + * @param[in] s Source Observable object + * @return Reference to this Observable object + */ Observable &operator=(Observable v) noexcept; + /** + * @brief Adds new observer to this observable + * @param[in] handler Observer delegate + */ void addObserver(NotiHandler handler); + + /** + * @brief Removes existing observer from this observable + * @param[in] handler Observer delegate + */ void removeObserver(NotiHandler::CDRef handler); + /** + * @brief Gets value of this observable + * @return Constant reference to the value of this observable + */ const T &getValue() const noexcept; + /** + * @brief Casts to the value of this observable + * @return Constant reference to the value of this observable + */ operator const T &() const noexcept; + /** + * @brief Assigns new value to this observable + * @param[in] value New value + * @return Reference to this Observable object + */ Observable &operator=(const T &value); + + /** + * @brief Move-assigns new value to this observable + * @param[in] value New value + * @return Reference to this Observable object + */ Observable &operator=(T &&value); - public: + private: T m_value; Event m_onValueChanged; }; diff --git a/ucl/include/ucl/misc/RefCountAware.h b/ucl/include/ucl/misc/RefCountAware.h index 2f4d4a2..7d2ff6e 100644 --- a/ucl/include/ucl/misc/RefCountAware.h +++ b/ucl/include/ucl/misc/RefCountAware.h @@ -24,20 +24,56 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(RefCountAware); + /** + * @brief Base class for objects that aware if they are shared or not + */ class RefCountAware : protected NonCopyable { public: + /** + * @brief Returns shared state of the object + * @return true - object is shared, false - no shared + */ bool isShared() const; + + /** + * @brief Returns count of shared references to this object if shared + * @return Count of shared references (0 on error) + */ UInt getUseCount() const; + + /** + * @brief Gets pointer to the allocated storage of this object + * @details Matches "this" of the instance's class. + * @return Pointer to the allocated storage of this object + */ const void *getObjPtr() const; + /** + * @brief Creates shared reference to T from "this" pointer + * @param[in] thisAlias Pointer to "this" implicitly converted to "T *" + * @return Shared reference to T + */ template SharedRef asSharedThis(T *thisAlias) const; + /** + * @brief Creates weak reference to T from "this" pointer + * @param[in] thisAlias Pointer to "this" implicitly converted to "T *" + * @return Weak reference to T + */ template WeakRef asWeakThis(T *thisAlias) const; protected: + /** + * @brief Constructor + * @param[in] rc Pointer to IRefCountObj (may be NULL) + */ RefCountAware(IRefCountObj *rc); + + /** + * @brief Destructor + */ ~RefCountAware() = default; private: @@ -54,40 +90,106 @@ namespace ucl { // Non-member functions // + /** + * @brief Creates shared reference to specified object + * @param[in] obj Reference to target object + * @return Shared reference to specified object or NULL + */ template SharedRef asShared(T &obj); + + /** + * @brief Creates shared reference to specified object + * @param[in] obj Pointer to target object + * @return Shared reference to specified object or NULL + */ template SharedRef asShared(T *obj); + /** + * @brief Creates weak reference to specified object + * @param[in] obj Reference to target object + * @return Weak reference to specified object or NULL + */ template WeakRef asWeak(T &obj); + + /** + * @brief Creates weak reference to specified object + * @param[in] obj Pointer to target object + * @return Weak reference to specified object or NULL + */ template WeakRef asWeak(T *obj); + /** + * @brief Creates shared reference to T from specified object + * @param[in] obj Reference to target object + * @return Shared reference to specified object as T + */ template ::value>::type> SharedRef asShared(U &obj); + + /** + * @brief Creates shared reference to T from specified object + * @param[in] obj Pointer to target object + * @return Shared reference to specified object as T + */ template ::value>::type> SharedRef asShared(U *obj); + /** + * @brief Creates weak reference to T from specified object + * @param[in] obj Reference to target object + * @return Weak reference to specified object as T + */ template ::value>::type> WeakRef asWeak(U &obj); + + /** + * @brief Creates weak reference to T from specified object + * @param[in] obj Pointer to target object + * @return Weak reference to specified object as T + */ template ::value>::type> WeakRef asWeak(U *obj); + /** + * @brief Creates shared reference to T from specified constant object + * @param[in] obj Reference to target constant object + * @return Shared reference to specified constant object as T + */ template ::value>::type> SharedRef asShared(const U &obj); + + /** + * @brief Creates shared reference to T from specified constant object + * @param[in] obj Pointer to target constant object + * @return Shared reference to specified constant object as T + */ template ::value>::type> SharedRef asShared(const U *obj); + /** + * @brief Creates weak reference to T from specified constant object + * @param[in] obj Reference to target constant object + * @return Weak reference to specified constant object as T + */ template ::value>::type> WeakRef asWeak(const U &obj); + + /** + * @brief Creates weak reference to T from specified constant object + * @param[in] obj Pointer to target constant object + * @return Weak reference to specified constant object as T + */ template ::value>::type> WeakRef asWeak(const U *obj); diff --git a/ucl/include/ucl/misc/TString.h b/ucl/include/ucl/misc/TString.h index 71ca2d9..7ce0e8a 100644 --- a/ucl/include/ucl/misc/TString.h +++ b/ucl/include/ucl/misc/TString.h @@ -21,40 +21,132 @@ namespace ucl { + /** + * @brief Represents translatable string + */ class TString final { public: + /** + * @brief Default constructor + * @datails Creates empty string + */ TString(); /** - * Constructs TString from std::string and domain - * - * @param str Text string or string id if translatable. - * @param domain Valid domain name or "" for default domain, - * nullptr - if string is not translatable + * @brief Constructor + * @details Constructs TString from std::string and domain + * @param[in] str Text string or string id if translatable + * @param[in] domain Valid domain name or "" for default domain, + * NULL - if string is not translatable */ TString(const std::string &str, const char *domain); + + /** + * @brief Constructor + * @details Constructs TString from std::string + * @param[in] str Text string or string id if translatable. + * @param[in] translatable true - translate using default domain, + * false - if string is not translatable + */ TString(const std::string &str, bool translatable = false); + /** + * @brief Constructor + * @details Constructs TString from temporrary std::string and domain + * @param[in] str Temporrary text string or string id if translatable + * @param[in] domain Valid domain name or "" for default domain, + * NULL - if string is not translatable + */ TString(std::string &&str, const char *domain); + + /** + * @brief Constructor + * @details Constructs TString from temporrary std::string + * @param[in] str Temporrary text string or string id if translatable. + * @param[in] translatable true - translate using default domain, + * false - if string is not translatable + */ TString(std::string &&str, bool translatable = false); + /** + * @brief Constructor + * @details Constructs TString from C-String and domain + * @param[in] str Text string or string id if translatable + * @param[in] domain Valid domain name or "" for default domain, + * NULL - if string is not translatable + */ TString(const char *str, const char *domain); + + /** + * @brief Constructor + * @details Constructs TString from C-String + * @param[in] str Text string or string id if translatable. + * @param[in] translatable true - translate using default domain, + * false - if string is not translatable + */ TString(const char *str, bool translatable = false); + /** + * @brief Checks if string is empty + * @return true - if empty, false - if not empty + */ bool isEmpty() const; + /** + * @brief Gets translatable state of the string + * @return true - if translatable, false - if not translateable + */ bool isTranslatable() const; + + /** + * @brief Checks if string has translatable domain + * @return true - if has domain, false - otherwise (domain is NULL) + */ bool hasDomain() const; + + /** + * @brief Gets translatable domain of the string + * @return Translatable domain of the string, + * "" - default, + * NULL - not translatable + */ const char *getDomain() const; + /** + * @brief Gets underlying std::string of the string + * @return Constant reference to the underlying std::string + */ const std::string &getStr() const; + + /** + * @brief Casts to underlying std::string of the string + * @return Constant reference to the underlying std::string + */ operator const std::string &() const; + /** + * @brief Gets C-String of the underlying std::string + * @return Underlying C-String of the underlying std::string + */ const char *getCStr() const; + + /** + * @brief Casts to C-String of the underlying std::string + * @return Underlying C-String of the underlying std::string + */ operator const char *() const; + /** + * @brief Translates the string if translatable + * @return Translated string or original if not translated + */ const char *translate() const; + /** + * @brief Formats translation (if translatable) of the string + * @param[in] args Format arguments + * @return Formatted translation (if translatable) of the string + */ template std::string format(ARGS ...args) const; diff --git a/ucl/include/ucl/misc/Timeout.h b/ucl/include/ucl/misc/Timeout.h index ebff032..2f572a6 100644 --- a/ucl/include/ucl/misc/Timeout.h +++ b/ucl/include/ucl/misc/Timeout.h @@ -26,13 +26,29 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(Timeout); + /** + * @brief Eecutes specific action after specified timeout + */ class Timeout final : protected NonCopyable { public: + /** + * @brief Delegate of the timeout action + */ using TimeoutHandler = WeakDelegate; public: + /** + * @brief Creates new Timeout object + * @param[in] timeoutSec Timeout value in seconds + * @param[in] handler Action of the timeout + * @return Shared reference to new Timeout object + */ static TimeoutSRef create(double timeoutSec, TimeoutHandler handler); + /** + * @brief Gets expiration status of the timeout + * @return true - timeout is already expired, false - in progress + */ bool isExpired() const; private: diff --git a/ucl/include/ucl/misc/Variant.h b/ucl/include/ucl/misc/Variant.h index a07e10b..92c4f9b 100644 --- a/ucl/include/ucl/misc/Variant.h +++ b/ucl/include/ucl/misc/Variant.h @@ -32,8 +32,14 @@ namespace ucl { template using VarArray = std::array; + /** + * @brief Represents value with dynamic type + */ class Variant final { public: + /** + * @brief Enumeration of possible value types + */ enum Type { TYPE_NIL, TYPE_BOOLEAN, @@ -45,72 +51,326 @@ namespace ucl { }; public: + /** + * @brief Swaps Variant objects with each other + * @param[in/out] x First theme object + * @param[in/out] y Second theme object + */ friend void swap(Variant &x, Variant &y) noexcept; + /** + * @brief Compares equals two Variant objects by value + * @param[in] lhs Left hand side operand + * @param[in] rhs Right hand side operand + * @return true - if equal, false - not equal + */ friend bool operator==(const Variant &lhs, const Variant &rhs) noexcept; + + /** + * @brief Compares unequals two Variant objects by value + * @param[in] lhs Left hand side operand + * @param[in] rhs Right hand side operand + * @return true - if not equal, false - equal + */ friend bool operator!=(const Variant &lhs, const Variant &rhs) noexcept; public: + /** + * @brief Default constructor + * @details Creates TYPE_NIL value + */ Variant() noexcept; + + /** + * @brief Constructor + * @details Same as deafult constructor + */ Variant(std::nullptr_t) noexcept; + /** + * @brief Constructor + * @details Creates TYPE_BOOLEAN value + * @param[in] aBool Source value + */ Variant(bool aBool) noexcept; + + /** + * @brief Constructor + * @details Creates TYPE_INTEGER value + * @param[in] anInt Source value + */ Variant(int anInt) noexcept; + + /** + * @brief Constructor + * @details Creates TYPE_FLOAT value + * @param[in] aFloat Source value + */ Variant(float aFloat) noexcept; + + /** + * @brief Constructor + * @details Creates TYPE_DOUBLE value + * @param[in] aDouble Source value + */ Variant(double aDouble) noexcept; + /** + * @brief Constructor + * @details Creates TYPE_STRING value + * @param[in] aString NULL-terminated source value + */ Variant(const char *aString); + + /** + * @brief Constructor + * @details Creates TYPE_STRING value + * @param[in] aString Source value + * @param[in] length Length of the string + */ Variant(const char *aString, int length); + + /** + * @brief Constructor + * @details Creates TYPE_STRING value + * @param[in] aString Source value + */ Variant(const std::string &aString); + /** + * @brief Constructor + * @details Creates TYPE_ARRAY value + * @param[in] nullptr for all TYPE_NIL elements + * @param[in] arrayLength Length of the array + */ Variant(std::nullptr_t, int arrayLength); + + /** + * @brief Constructor + * @details Creates TYPE_ARRAY value + * @param[in] anArray Source Variant C-Array + * @param[in] length Length of the array + */ Variant(const Variant *anArray, int length); + + /** + * @brief Constructor + * @details Creates TYPE_ARRAY value + * @param[in] anArray Source std::vector + */ Variant(const VarVector &anArray); + + /** + * @brief Constructor + * @details Creates TYPE_ARRAY value + * @param[in] anArray Source std::array + */ template Variant(const VarArray &anArray); + + /** + * @brief Constructor + * @details Creates TYPE_ARRAY value + * @param[in] anArray Source std::initializer_list + */ Variant(std::initializer_list anArray); + /** + * @brief Destructor + */ ~Variant(); + /** + * @brief Copy constructor + * @param[in] v Source value + */ Variant(const Variant &v); + + /** + * @brief Move constructor + * @param[in] v Source value + */ Variant(Variant &&v) noexcept; + /** + * @brief Assigns one Variant object to another + * @param[in] v Source value + * @return Reference to this Variant object + */ Variant &operator=(Variant v); + /** + * @brief Gets type of the variant value + * @return Type of the value + */ Type getType() const noexcept; + + /** + * @brief Gets lengths of the value + * @return Lengths of string/array, 1 for other types and 0 for TYPE_NIL + */ int getLength() const noexcept; + + /** + * @brief Checks whether variant is empty + * @details This is equivalent to: (getLength() == 0); + * @return true if empty, false if not empty + */ bool isEmpty() const noexcept; + /** + * @brief Reads current variant value as bool + * @return Value of the variant converted to bool: + * as is - for boolean; + * true - (numeric values != 0); + * true - string in case insensitive + * ("true", "yes", "ok", "on", "1"); + * true - (array length != 0); + * false - otherwise + */ bool asBool() const noexcept; + + /** + * @brief Reads current variant value as int + * @return Value of the variant converted to int: + * static_cast() - all numeric values; + * std::atoi() - for string; + * length - for array; + * 0 - otherwise + */ int asInt() const noexcept; + + /** + * @brief Reads current variant value as float + * @return Value of the variant converted to float: + * static_cast() - all numeric values; + * static_cast(std::atof()) - for string; + * static_cast(length) - for array; + * 0.0f - otherwise + */ float asFloat() const noexcept; + + /** + * @brief Reads current variant value as double + * @return Value of the variant converted to double: + * static_cast() - all numeric values; + * std::atof() - for string; + * static_cast(length) - for array; + * 0.0 - otherwise + */ double asDouble() const noexcept; + /** + * @brief Reads current variant value as string + * @return Value of the variant converted to string: + * as is - for string + * "true"|"false" - for boolean; + * printf("%d") - integer, array length; + * printf("%f") - float and double; + * "" - otherwise + */ ConstCString asString() const noexcept; + /** + * @brief Reads current variant value as Variant C-Array + * @return Value of the variant converted as Variant C-Array + * as is - for array + * this - for simple value + */ Variant *asArray() noexcept; + + /** + * @brief Reads current variant value as constant Variant C-Array + * @return Value of the variant converted as constant Variant C-Array + * as is - for array + * this - for simple value + */ const Variant *asArray() const noexcept; + /** + * @brief Gets begin iterator of this variant as an array + * @return Begin iterator + */ Variant *begin() noexcept; + + /** + * @brief Gets end iterator of this variant as an array + * @return End iterator + */ Variant *end() noexcept; + + /** + * @brief Gets begin constant iterator of this variant as an array + * @return Begin constant iterator + */ const Variant *begin() const noexcept; + + /** + * @brief Gets end constant iterator of this variant as an array + * @return End constant iterator + */ const Variant *end() const noexcept; + /** + * @brief Gets indexed element of this variant as an array + * @param[in] index Index of the element + * @return Reference to indexed element + */ Variant &operator[](int index) noexcept; + + /** + * @brief Gets indexed constant element of this variant as an array + * @param[in] index Index of the element + * @return Reference to indexed constant element + */ const Variant &operator[](int index) const noexcept; + /** + * @brief Explicitly casts to bool + * @details Same as asBool() + * @return Value of the variant converted to bool + */ explicit operator bool() const noexcept; + + /** + * @brief Explicitly casts to int + * @details Same as asInt() + * @return Value of the variant converted to int + */ explicit operator int() const noexcept; + + /** + * @brief Explicitly casts to float + * @details Same as asFloat() + * @return Value of the variant converted to float + */ explicit operator float() const noexcept; + + /** + * @brief Explicitly casts to double + * @details Same as asDouble() + * @return Value of the variant converted to double + */ explicit operator double() const noexcept; + /** + * @brief Compares equals Variant object type with other type + * @param[in] rhs Right hand side operand + * @return true - if equal, false - not equal + */ bool operator==(Variant::Type rhs) const noexcept; + + /** + * @brief Compares unequals Variant object type with other type + * @param[in] rhs Right hand side operand + * @return true - if not equal, false - equal + */ bool operator!=(Variant::Type rhs) const noexcept; private: const char *getStr() const noexcept; - public: + private: union { uint8_t m_type; struct { diff --git a/ucl/include/ucl/misc/types.h b/ucl/include/ucl/misc/types.h index c56004c..adf79dc 100644 --- a/ucl/include/ucl/misc/types.h +++ b/ucl/include/ucl/misc/types.h @@ -21,6 +21,9 @@ namespace ucl { + /** + * @brief Represents delegate to handle simple notification events + */ using NotiHandler = WeakDelegate; } diff --git a/ucl/include/ucl/mvp/GuiPresenter.h b/ucl/include/ucl/mvp/GuiPresenter.h index d56e0bd..c2942ef 100644 --- a/ucl/include/ucl/mvp/GuiPresenter.h +++ b/ucl/include/ucl/mvp/GuiPresenter.h @@ -27,59 +27,264 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(GuiPresenter); + /** + * @brief Base class for presenters with GUI + */ class GuiPresenter : public RefCountAware { public: + /** + * @brief Information about deactivator that used in events + */ struct DeactivatorInfo final { + /** + * @brief Deactivator pointer + */ const void *deactivator; + /** + * @brief true - deactivator was broadcasted, false - otherwise + */ bool isBroadcast; }; public: + /** + * @brief Gets activation status + * @return true - if presenter is active, false - if not active + */ bool isActive() const; + + /** + * @brief Checks whether this presenter is deactivated + * by specific deactivator + * @param[in] deactivator Pointer to the target deactivator + * @return true - if deactivated by the deactivator, false - otherwise + */ bool isDeactivatedBy(const void *deactivator) const; + /** + * @brief Activates the presenter by specific deactivator + * @details If this presenter was not deactivated by the deactivator + * this function has no effect, otherwise deactivation + * imposed by the deactivator is lifted. Deactivator exception + * does not affect this function. + * @param[in] deactivator Pointer to the target deactivator + */ void activateBy(const void *deactivator); + + /** + * @brief Deactivates the presenter by specific deactivator + * @details If this presenter is already deactivated by the deactivator + * or listed in the deactivator exception list this function + * has no effect, otherwise this presenter becomes deactivated + * by the deactivator. + * @param[in] deactivator Pointer to the target deactivator + */ void deactivateBy(const void *deactivator); + /** + * @brief Registers specific widget as a deactivator source + * @details This presenter will be automatically activated/deactivated + * by the events send by the widget. These events may be send + * directly by the call to sendActivate()/sendDeactivate() + * methods or through parant's deactivator sink. + * @param[in] source Reference to the deactivator source widget + */ void addDeactivatorSource(Widget &source); + + /** + * @brief Deregisters specific widget as a deactivator source + * @param[in] source Reference to the deactivator source widget + */ void delDeactivatorSource(Widget &source); protected: + /** + * @brief Enumeration of preparation flags + */ enum { + /** + * @brief Indicates that new presenter needs to be automatically + * activated/deactivated by it's parent or broadcast events + * @details This flag is needed for all presenters that needs to use + * isActive() property, which should be all presenters + * processing user events. Presenters that only display + * information (PASSIVE) does not require this flag. + */ PF_ADD_DEACTIVATOR_SOURCES = 1, + + /** + * @brief Indicates that new presenter needs to add self to the + * deactivator exception list + * @details This flag is needed for all presenters that emit + * activate/deactivate events (DEACTIVATORs) because there + * is a big chance that this events may return to the + * calling presenter and cause undesired effect. + */ PF_ADD_SELF_EXCEPT = 2, + /** + * @brief Helper flag set to use for PASSIVE presenters + */ PF_PASSIVE = 0, + + /** + * @brief Helper flag set to use for DEACTIVATOR presenters + */ PF_DEACTIVATOR = (PF_ADD_DEACTIVATOR_SOURCES | PF_ADD_SELF_EXCEPT), + + /** + * @brief Helper flag set to use for not PASSIVE not DEACTIVATOR + * presenters + */ PF_DEFAULT = PF_ADD_DEACTIVATOR_SOURCES }; protected: + /** + * @brief Constructor + * @param[in] rc Pointer to IRefCountObj (passed automatically) + */ GuiPresenter(IRefCountObj &rc); + + /** + * @brief Destructor + */ ~GuiPresenter(); + /** + * @brief Prepares this presenter instance as a root presenter + * @details Specified widget must have a Window as a top level parent. + * @param[in] widget Any widget to which tree this presenter + * should belong + * @param[in] flags Preparation flags (optional: PF_DEFAULT) + * @retrun RES_OK on success, error otherwise + */ Result prepare(ElmWidget &widget, int flags = PF_DEFAULT); + + /** + * @brief Prepares this presenter instance as a child presenter + * @details Parent presenter must have deactivator sink registered + * unless this presenter does not specify + * PF_ADD_DEACTIVATOR_SOURCES flag. + * @param[in] parent Reference to the parent presenter + * @param[in] flags Preparation flags (optional: PF_DEFAULT) + * @retrun RES_OK on success, error otherwise + */ Result prepare(GuiPresenter &parent, int flags = PF_DEFAULT); + /** + * @brief Gets reference to the Window widget + * @details If Window was not initialized application will terminate + * with assertion. + */ Window &getWindow(); + + /** + * @brief Gets shared reference to the Window widget + * @details Use in destructor and check for NULL, because destructor + * is always called event after prepare() failure + * (Window may be not initialized yet). + */ WindowSRef getWindowRef(); + /** + * @brief Adds specific deactivator as exception + * @details All deactivating functionality will ignore specified + * deactivator. Note however that this does not cancel any + * deactivation effect that was imposed by this deactivator + * before adding exception. Therefore, activation functionality + * will work fo this deactivator. + * @param[in] deactivator Pointer to the target deactivator + */ void addDeactivatorException(const void *deactivator); + + /** + * @brief Sets specified widget as deactivator sink fo this presenter + * @details All activate/deactivate actions that occurs on this + * presenter will be send as events on this widget. This + * function needs to be called if this presenter may be a + * parent for other presenters. This will enable propagation of + * activate/deactivate actions from parent to children. + * @param[in] sink Shared reference to the event sink widget + */ void setDeactivatorSink(const WidgetSRef &sink); + /** + * @brief Gets deactivator that can be used for self deactivation + * @details Self deactivator pointer is garanteed to be unique and + * unknown for external code. So it is not possible to + * accidentally deactivate this presenter by this deactivator + * from external code. + * @return Pointer to the deactivator + */ const void *getSelfDeactivator() const; + + /** + * @brief Activates self using self deactivator + */ void activateSelf(); + + /** + * @brief Deactivates self using self deactivator + */ void deactivateSelf(); + /** + * @brief Sends activation event using specified widget sender + * @details All presenters that added this widget as a deactivator + * source will be activate by this event. + * @param[in] sender Reference to sender widgets + */ void sendActivate(Widget &sender); + + /** + * @brief Sends deactivation event using specified widget sender + * @details All presenters that added this widget as a deactivator + * source will be deactivated by this event. + * @param[in] sender Reference to sender widgets + */ void sendDeactivate(Widget &sender); + /** + * @brief Broadcasts activation event + * @details All root presenters with PF_ADD_DEACTIVATOR_SOURCES flag + * will be activate by this event. + */ void broadcastActivate(); + + /** + * @brief Broadcasts deactivation event + * @details All root presenters with PF_ADD_DEACTIVATOR_SOURCES flag + * will be deactivated by this event. + */ void broadcastDeactivate(); + /** + * @brief Occurs when this presenter becomes active + * @details This event occurs after onActivateBy(). + */ virtual void onActivate(); + + /** + * @brief Occurs when this presenter becomes inactive + * @details This event occurs after onDeactivateBy(). + */ virtual void onDeactivate(); + + /** + * @brief Occurs when this presenter is first time activated by + * specific deactivator + * @details This event occurs after processing the deactivator sink. + * @param[in] info Deactivator info of the deactivator + */ virtual void onActivateBy(const DeactivatorInfo &info); + + /** + * @brief Occurs when this presenter is first time deactivated by + * specific deactivator + * @details This event occurs after processing the deactivator sink. + * @param[in] info Deactivator info of the deactivator + */ virtual void onDeactivateBy(const DeactivatorInfo &info); private: diff --git a/ucl/include/ucl/mvp/IPickable.h b/ucl/include/ucl/mvp/IPickable.h index c0b221d..fdd20b9 100644 --- a/ucl/include/ucl/mvp/IPickable.h +++ b/ucl/include/ucl/mvp/IPickable.h @@ -23,10 +23,21 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(IPickable); + /** + * @brief Abstract interface for a object that can be picked (selected) + */ class IPickable : protected NonCopyable { public: + /** + * @brief Gets IPicker interface to perform picking + * @return Reference to IPicker interface + */ virtual IPicker &getPicker() = 0; + protected: + /** + * @brief Destructor + */ ~IPickable() = default; }; } diff --git a/ucl/include/ucl/mvp/IPicker.h b/ucl/include/ucl/mvp/IPicker.h index c071a87..4fb6959 100644 --- a/ucl/include/ucl/mvp/IPicker.h +++ b/ucl/include/ucl/mvp/IPicker.h @@ -21,13 +21,46 @@ namespace ucl { + /** + * @brief Abstract interface to perform picking process on item (selection) + */ class IPicker : protected NonCopyable { public: + /** + * @brief Assigns a picker host to this picker + * @details Picker host is handles global activities of + * a picking process + * @param[in] host Weak reference to a IPickerHost implementation + */ virtual void setPickerHost(IPickerHostWRef host) = 0; + + /** + * @brief Sets a picked state to this picker + * @details This function may not update any related states + * (such as GUI representing a new state). All synchronizations + * need to be performed eternally. + * param[in] isPicked A picked state. true - picked, false - not picked + */ virtual void setPicked(bool isPicked) = 0; + + /** + * @brief Updates a picked state to this picker + * @details This function is also updates any related states (such as + * GUI representing a new state). + * param[in] isPicked A picked state. true - picked, false - not picked + */ virtual void updatePicked(bool isPicked) = 0; + + /** + * @brief Gets current picked state of this picker + * @return Current picked state. true - picked, false -not picked. + */ virtual bool isPicked() const = 0; + protected: + /** + * @brief Destructor + */ ~IPicker() = default; }; } diff --git a/ucl/include/ucl/mvp/IPickerHost.h b/ucl/include/ucl/mvp/IPickerHost.h index 7ea04e2..9e7cad6 100644 --- a/ucl/include/ucl/mvp/IPickerHost.h +++ b/ucl/include/ucl/mvp/IPickerHost.h @@ -23,12 +23,40 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(IPickerHost); + /** + * @brief Abstract interface that handles global activities of + * a picking process + */ class IPickerHost : protected NonCopyable { public: + /** + * @brief Increments count of picked items + * @details This method must be called whenewer picked state of the + * IPicker changes internally without calls to setPicked() or + * updatePicked() functions (by the user from GUI). + */ virtual void incrementPickCounter() = 0; + + /** + * @brief Decrements count of picked items + * @details This method must be called whenewer picked state of the + * IPicker changes internally without calls to setPicked() or + * updatePicked() functions (by the user from GUI). + */ virtual void decrementPickCounter() = 0; + + /** + * @brief Returs pick mode state + * @details None of the modifying function of this iterface must be + * called if pick mode is not active. + * @return Pick mode state. true - active, false - not active. + */ virtual bool isPickModeActive() const = 0; + protected: + /** + * @brief Destructor + */ ~IPickerHost() = default; }; } diff --git a/ucl/include/ucl/mvp/ListItemPresenter.h b/ucl/include/ucl/mvp/ListItemPresenter.h index b31c29c..bda4546 100644 --- a/ucl/include/ucl/mvp/ListItemPresenter.h +++ b/ucl/include/ucl/mvp/ListItemPresenter.h @@ -28,16 +28,48 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(ListItemPresenter); + /** + * @brief Represents presenter of the ListPresenter item + */ class ListItemPresenter : public RefCountAware, public IDisposable, 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(); + + /** + * @brief Scrolls GUI item of this item to specific position + * with animation + * @param[in] type Scroll type (optional: ELM_GENLIST_ITEM_SCROLLTO_IN) + */ Result bringInItem(Elm_Genlist_Item_Scrollto_Type type = ELM_GENLIST_ITEM_SCROLLTO_IN); + + /** + * @brief Scrolls GUI item of this item to specific position + * without animation + * @param[in] type Scroll type (optional: ELM_GENLIST_ITEM_SCROLLTO_IN) + */ Result showItem(Elm_Genlist_Item_Scrollto_Type type = ELM_GENLIST_ITEM_SCROLLTO_IN); + /** + * @brief Sets GUI item Atspi gesture event handler + * @param[in] handler Handler of the event + */ + void setItemAtspiGestureHandler(AtspiGestureHandler handler); // IDisposable // @@ -48,32 +80,97 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(ItemClass); UCL_DECLARE_REF_ALIASES(ItemClassCache); - // Flags + /** + * @brief Enumeration of behaviour flags + */ enum { + /** + * @brief Automatically unselect GUI item in select callback + */ PF_AUTO_UNSELECT = 1 }; + /** + * @brief Information about GUI item that is used when this item is + * inserted into the ListPresenter + */ struct ItemInsertionParams { + /** + * @brief GUI item style + */ ElmStyle itemStyle; + + /** + * @brief GUI item type + */ GenlistItem::Type itemType; + /** + * @brief Constructor + * @param[in] itemStyle GUI item style + * @param[in] itemType GUI item type + * (optional: GenlistItem::Type::SIMPLE) + */ ItemInsertionParams(ElmStyle itemStyle, GenlistItem::Type itemType = GenlistItem::Type::SIMPLE) : itemStyle(itemStyle), itemType(itemType) {} }; + /** + * @brief Information that is used to create GUI for pick mode + */ struct ItemPickModeParams { + /** + * @brief Part in GUI item for check widget + */ EdjePart checkPart; + + /** + * @brief Style of the check widget + */ 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 + */ bool isValid() const; }; + /** + * @brief Represents GUI item class + */ class ItemClass final : protected NonCopyable { public: + /** + * @brief Creates new instance of ItemClass object + * @param[in] itemStyle GUI item style of new item class + */ static ItemClassSRef newInstance(ElmStyle itemStyle); + public: + /** + * @brief Gets native Elementary genlist itm class object + * @return Pointer to the underlying Elementary genlist ITC + */ Elm_Genlist_Item_Class *get(); + private: ItemClass(ElmStyle itemStyle, Private); ~ItemClass(); @@ -82,49 +179,183 @@ namespace ucl { friend class ReffedObj; }; + /** + * @brief Cache storage and factory for ItemClass objects + */ class ItemClassCache final : protected NonCopyable { public: + /** + * @brief Gets an instance of ItemClass object (new or from cache) + * @param[in] itemStyle GUI item style of item class + */ ItemClassSRef getItemClass(ElmStyle itemStyle); + + /** + * Removes all cached objects + */ void purge(); + private: HashMap m_itcMap; }; protected: + /** + * @brief Constructor + * @param[in] rc Pointer to IRefCountObj (passed automatically) + */ ListItemPresenter(IRefCountObj &rc); + + /** + * @brief Destructor + */ ~ListItemPresenter(); + /** + * @brief Sets behaviour flags to this item presenter + * @param[in] flags New behaviour flags + */ void setFlags(int flags); + + /** + * @brief Gets behaviour flags from this item presenter + * @return Current behaviour flags + */ int getFlags() const; + /** + * @brief Gets activation status of this item presenter + * @return true - if presenter is active, false - if not active + */ bool isActive() const; + /** + * @brief Gets pick mode activation status + * @return true - active, false - not active + */ bool isPickModeActive() const; + + /** + * @brief Handles item pick event + * @param[in] isPicked New item picked state. + * true - picked, false - not picked + */ void handleItemPick(bool isPicked); + /** + * @brief Gets attached GUI item of this item presenter + * @return Attached GUI item + */ GenlistItem getItem(); + + /** + * @brief Gets Atspi of attached GUI item of this presenter + * @return Pointer to Atspi of attached GUI item or NULL + */ + Atspi *getItemAtspi(); + + /** + * @brief Gets constant Atspi of attached GUI item of this presenter + * @return Pointer to Constant Atspi of attached GUI item or NULL + */ + const Atspi *getItemAtspi() const; + + /** + * @brief Gets attached GUI item class cache of this item presenter + * @return Attached GUI item class cache + */ ItemClassCache *getItemClassCache(); + /** + * @brief Updates GUI item style + * @details Internally uses item class cache to get GUI item class for + * specified GUI item style. + * @param[in] newItemStyle New GUI item style to apply + * @return RES_OK on success, error otherwise + */ Result updateItemStyle(ElmStyle newItemStyle); + /** + * @brief Creates GUI item part content for pick mode if in pick mode + * @param[in] part Edje part for which to try create the content widget + * @param[in] parent Parent widget to use for the content widget + * @param[in] params Parameters for the content widget creation + * @return Shared reference to the content widget or NULL + */ WidgetSRef tryCreatePickModeItemPartContent( EdjePart part, ElmWidget &parent, const ItemPickModeParams ¶ms); + /** + * @brief Return GUI item insertion parameters + * @details Called just before item is added to list + * @return Item insertion params structure + */ virtual ItemInsertionParams getItemInsertionParams() = 0; + /** + * @brief Occurs when GUI item is attached to this item presenter + * @details Called after getItemInsertionParams() at the end of + * item to list addition process. + */ virtual void onItemAttached(); + + /** + * @brief Occurs when GUI item is detached from this item presenter + * @details Called when GUI item is removed. + */ virtual void onItemDetached(); + /** + * @brief Gets text for specific GUI item part + * @param[in] part Target GUI item part + * @return Text for specific part or NULL + */ virtual CString getItemPartText(EdjePart part); + + /** + * @brief Gets the content widget for specific GUI item part + * @param[in] part Target GUI item part + * @param[in] parent Parent widget to use for the content widget + * @return Shared reference to the content widget or NULL + */ virtual WidgetSRef getItemPartContent(EdjePart part, ElmWidget &parent); + + /** + * @brief Gets state for specific GUI item part + * @param[in] part Target GUI item part + * @return State of the part + */ virtual bool getItemPartState(EdjePart part); + /** + * @brief Occurs when GUI item is selected + */ virtual void onItemSelected(); + + /** + * @brief Occurs when GUI item is realized + */ virtual void onItemRealized(); + + /** + * @brief Occurs when GUI item is unrealized + */ virtual void onItemUnrealized(); + + /** + * @brief Occurs when GUI item is highlighted + */ virtual void onItemHighlighted(); + + /** + * @brief Occurs when GUI item is unhighlighted + */ virtual void onItemUnhighlighted(); + + /** + * @brief Occurs when GUI item is long pressed + */ virtual void onItemLongpressed(); // IPicker // @@ -135,27 +366,33 @@ namespace ucl { virtual bool isPicked() const final override; private: - void attachItem(GenlistItem item, - ElmWidgetSRef &&parent, - const ItemClassCacheSRef &itcCache, - const SharedRef &isActiveRef); + void attachItem(GenlistItem item, ElmWidgetSRef parent, + ItemClassCacheSRef itcCache, SharedRef isActiveRef); void deleteDetachedItem(bool silent = false); void detachItem(bool silent = false); + void tryEnsureItemAtspi(); + void tryListenToItemAtspiGesture(); void onPickCheckChanged(Widget &widget, void *eventInfo); void onItemSelectedHook(); void onItemDel(Evas_Object *obj, void *eventInfo); + void onItemAtspiGesture(Atspi &atspi, AtspiGestureEventInfo &eventInfo); private: ListItemPresenterSRef m_selfRef; IPickerHostWRef m_pickerHost; + AtspiGestureHandler m_itemAtspiGestureHandler; + GenlistItem m_item; + AtspiSRef m_itemAtspi; + ElmWidgetSRef m_parent; ItemClassCacheSRef m_itcCache; SharedRef m_isActiveRef; - ElmWidgetSRef m_parent; + int m_flags; bool m_isItemPicked; + bool m_isListeningToItemAtspiGesture; friend class ListPresenter; }; diff --git a/ucl/include/ucl/mvp/ListPresenter.h b/ucl/include/ucl/mvp/ListPresenter.h index 7f39899..1415c05 100644 --- a/ucl/include/ucl/mvp/ListPresenter.h +++ b/ucl/include/ucl/mvp/ListPresenter.h @@ -26,27 +26,94 @@ namespace ucl { UCL_DECLARE_REF_ALIASES(ListPresenter); + /** + * @brief Represents presenter of item list using Genlist widget + */ class ListPresenter final : public GuiPresenter { public: + /** + * @brief Enumeration of build flags + */ enum { + /** + * @brief Need to apply homogeneous mode to genlist + */ FLAG_HOMOGENEOUS = (1 << 0), + + /** + * @brief Need to calculate X min size hint for genlist + */ FLAG_CALC_X_MIN = (1 << 1), + + /** + * @brief Need to calculate Y min size hint for genlist + */ FLAG_CALC_Y_MIN = (1 << 2), + /** + * @brief Need to notify item realized event + */ FLAG_NOTIFY_REALIZED = (1 << 8), + + /** + * @brief Need to notify item unrealized event + */ FLAG_NOTIFY_UNREALIZED = (1 << 9), + + /** + * @brief Need to notify item highlighted event + */ FLAG_NOTIFY_HIGHLIGHTED = (1 << 10), + + /** + * @brief Need to notify item unhighlighted event + */ FLAG_NOTIFY_UNHIGHLIGHTED = (1 << 11), + + /** + * @brief Need to notify item long pressed event + */ FLAG_NOTIFY_LONGPRESSED = (1 << 12), }; + /** + * @brief Builder of ListPresenter objects + */ class Builder final { public: + /** + * @brief Constructor + */ Builder(); + + /** + * @brief Sets genlist style of the future object + * @param[in] style Genlist Style of the future object + * @return Reference to this builder + */ Builder &setStyle(ElmStyle style); + + /** + * @brief Sets build flags for the future object + * @param[in] flags Build flags for the future object + * @return Reference to this builder + */ Builder &setFlags(int flags); + + /** + * @brief Sets genlist parent widget of the future object + * @param[in] parentWidget Genlist parent widget + * @return Reference to this builder + */ Builder &setParentWidget(const ElmWidgetSRef &parentWidget); + + /** + * @brief Creates new ListPresenter object using current parameters + * @param[in] parent Reference to parent presenter + * @return Shared reference to new ListPresenter object or NULL + */ ListPresenterSRef build(GuiPresenter &parent) const; + private: ucl::ElmWidgetSRef m_parentWidget; ElmStyle m_style; @@ -54,20 +121,53 @@ namespace ucl { }; public: + /** + * @brief Gets underlying genlist widget + * @return Reference to the Genlist object + */ Genlist &getWidget(); + /** + * @brief Removes all items from the list + */ void clear(); + /** + * @brief Appends an item to the list + * @param[in] itemPresenter Reference to the target item + * @param[in] parent Parent item (optional) + * @return RES_OK on success, error otherwise + */ Result append(ListItemPresenter &itemPresenter, ListItemPresenter *parent = nullptr); + /** + * @brief Prepends an item to the list + * @param[in] itemPresenter Reference to the target item + * @param[in] parent Parent item (optional) + * @return RES_OK on success, error otherwise + */ Result prepend(ListItemPresenter &itemPresenter, ListItemPresenter *parent = nullptr); + /** + * @brief Inserts an item to the list after specific item in this list + * @param[in] after Reference to the "after" item + * @param[in] itemPresenter Reference to the target item + * @param[in] parent Parent item (optional) + * @return RES_OK on success, error otherwise + */ Result insertAfter(const ListItemPresenter &after, ListItemPresenter &itemPresenter, ListItemPresenter *parent = nullptr); + /** + * @brief Inserts an item to the list before specific item in this list + * @param[in] before Reference to the "before" item + * @param[in] itemPresenter Reference to the target item + * @param[in] parent Parent item (optional) + * @return RES_OK on success, error otherwise + */ Result insertBefore(const ListItemPresenter &before, ListItemPresenter &itemPresenter, ListItemPresenter *parent = nullptr); diff --git a/ucl/include/ucl/util/delegation/BaseDelegate.h b/ucl/include/ucl/util/delegation/BaseDelegate.h index e02de8d..11805b9 100644 --- a/ucl/include/ucl/util/delegation/BaseDelegate.h +++ b/ucl/include/ucl/util/delegation/BaseDelegate.h @@ -27,32 +27,96 @@ namespace ucl { template class BaseDelegate2; + /** + * @brief Base class for implementing delegates with 1 function stub + */ template class BaseDelegate { public: + /** + * @brief Callback of this delegate + */ using Cb = Callback; + + /** + * @brief StubA function pointer type of this delegate + */ using StubA = typename Cb::StubA; public: + /** + * @brief Default constructor + * @details Creates NULL delegate + */ constexpr BaseDelegate() noexcept; + + /** + * @brief Constructor + * @details Safe as default constructor + */ constexpr BaseDelegate(std::nullptr_t) noexcept; + /** + * @brief Conversion constructor from BaseDelegate2 + * @param[in] d Source delegate + */ template BaseDelegate(const BaseDelegate2 &d) noexcept; + + /** + * @brief Conversion move constructor from BaseDelegate2 + * @param[in] d Source delegate + */ template BaseDelegate(BaseDelegate2 &&d) noexcept; + /** + * @brief Resets this delegate to NULL + */ void reset() noexcept; + /** + * @brief Gets bound object data pointer + * @details May be used to invoke this delegate from C code. + * @return Bound object data pointer + */ const DATA &getData() const noexcept; + + /** + * @brief Gets bound StubA function pointer + * @details May be used to invoke this delegate from C code. + * @return Pointer to bound StubA function + */ StubA getStubA() const noexcept; + + /** + * @brief Checks if this delegate is not NULL + * @return true - if not NULL, false - if NULL + */ explicit operator bool() const noexcept; protected: + /** + * @brief Constructor + * @param[in] data Object data pointer + * @param[in] stubA StubA function pointer + */ BaseDelegate(DATA data, StubA stubA) noexcept; + /** + * @brief Destructor + */ + ~BaseDelegate() = default; + protected: + /** + * @brief Bound object data pointer + */ DATA m_data; + + /** + * @brief Bound StubA function pointer + */ StubA m_stubA; }; } diff --git a/ucl/include/ucl/util/delegation/BaseDelegate2.h b/ucl/include/ucl/util/delegation/BaseDelegate2.h index dc84bc1..c47d611 100644 --- a/ucl/include/ucl/util/delegation/BaseDelegate2.h +++ b/ucl/include/ucl/util/delegation/BaseDelegate2.h @@ -24,23 +24,56 @@ namespace ucl { template class BaseDelegate2; + /** + * @brief Base class for implementing delegates with 2 function stub + */ template class BaseDelegate2 : public BaseDelegate { public: + /** + * @brief Callback of this delegate + */ using Cb = typename BaseDelegate2::Cb; + + /** + * @brief StubA function pointer type of this delegate + */ using StubA = typename Cb::StubA; + + /** + * @brief StubB function pointer type of this delegate + */ using StubB = typename Cb::StubB; public: using BaseDelegate::BaseDelegate; + /** + * @brief Gets bound StubB function pointer + * @details May be used to invoke this delegate from C code. + * @return Pointer to bound StubB function + */ StubB getStubB() const noexcept; protected: + /** + * @brief Constructor + * @param[in] data Object data pointer + * @param[in] stubA StubA function pointer + * @param[in] stubB StubB function pointer + */ BaseDelegate2(DATA data, StubA stubA, StubB stubB) noexcept; + /** + * @brief Destructor + */ + ~BaseDelegate2() = default; + private: + /** + * @brief Bound StubB function pointer + */ StubB m_stubB; }; } diff --git a/ucl/include/ucl/util/delegation/Callback.h b/ucl/include/ucl/util/delegation/Callback.h index 69724be..76a7345 100644 --- a/ucl/include/ucl/util/delegation/Callback.h +++ b/ucl/include/ucl/util/delegation/Callback.h @@ -24,47 +24,153 @@ namespace ucl { template class Callback; + /** + * @brief Generates function stubs to use in callbacks and delegates + */ template class Callback { public: + /** + * @brief StubA function pointer type + * @details This function takes data argument as first parameter + */ using StubA = R(*)(void *, ARGS...); + + /** + * @brief StubB function pointer type + * @details This function takes data argument as last parameter + */ using StubB = R(*)(ARGS..., void *); public: + /** + * @brief Wraps instance method as StubA + * @param[in] data This pointer of the instance + * @param[in] args Method arguments + * @return R Result of the method call + */ template static R stubA(void *data, ARGS ...args); + + /** + * @brief Wraps instance method as StubB + * @param[in] args Method arguments + * @param[in] data This pointer of the instance + * @return R Result of the method call + */ template static R stubB(ARGS ...args, void *data); + /** + * @brief Wraps constant instance method as StubA + * @param[in] data This pointer of the instance + * @param[in] args Method arguments + * @return R Result of the method call + */ template static R stubA(void *data, ARGS ...args); + + /** + * @brief Wraps constant instance method as StubB + * @param[in] args Method arguments + * @param[in] data This pointer of the instance + * @return R Result of the method call + */ template static R stubB(ARGS ...args, void *data); + /** + * @brief Wraps StubA-style function taking object as StubA + * @param[in] data Pointer of the object + * @param[in] args Function arguments + * @return R Result of the function call + */ template static R stubA2A(void *data, ARGS ...args); + + /** + * @brief Wraps StubA-style function taking object as StubB + * @param[in] args Function arguments + * @param[in] data Pointer of the object + * @return R Result of the function call + */ template static R stubB2A(ARGS ...args, void *data); + /** + * @brief Wraps StubB-style function taking object as StubA + * @param[in] data Pointer of the object + * @param[in] args Function arguments + * @return R Result of the function call + */ template static R stubA2B(void *data, ARGS ...args); + + /** + * @brief Wraps StubB-style function taking object as StubB + * @param[in] args Function arguments + * @param[in] data Pointer of the object + * @return R Result of the function call + */ template static R stubB2B(ARGS ...args, void *data); + /** + * @brief Wraps StubA-style function taking object handle as StubA + * @param[in] data Handle of the object + * @param[in] args Function arguments + * @return R Result of the function call + */ template static R stubA2A(void *data, ARGS ...args); + + /** + * @brief Wraps StubA-style function taking object handle as StubB + * @param[in] args Function arguments + * @param[in] data Handle of the object + * @return R Result of the function call + */ template static R stubB2A(ARGS ...args, void *data); + /** + * @brief Wraps StubB-style function taking object handle as StubA + * @param[in] data Handle of the object + * @param[in] args Function arguments + * @return R Result of the function call + */ template static R stubA2B(void *data, ARGS ...args); + + /** + * @brief Wraps StubB-style function taking object handle as StubB + * @param[in] args Function arguments + * @param[in] data Handle of the object + * @return R Result of the function call + */ template static R stubB2B(ARGS ...args, void *data); + /** + * @brief Wraps static function as StubA + * @param[in] data Not used + * @param[in] args Function arguments + * @return R Result of the function call + */ template static R stubA2V(void *data, ARGS ...args); + + /** + * @brief Wraps static function as StubB + * @param[in] args Function arguments + * @param[in] data Not used + * @return R Result of the function call + */ template static R stubB2V(ARGS ...args, void *data); + + private: + Callback() = delete; }; } diff --git a/ucl/include/ucl/util/delegation/Delegate.h b/ucl/include/ucl/util/delegation/Delegate.h index 714b448..9243ef6 100644 --- a/ucl/include/ucl/util/delegation/Delegate.h +++ b/ucl/include/ucl/util/delegation/Delegate.h @@ -24,33 +24,89 @@ namespace ucl { template class Delegate; + /** + * @brief Delegate that uses "void *" as data pointer + */ template class Delegate : public BaseDelegate { public: + /** + * @brief Result delegate of the lock() method + */ using LockDelegate = Delegate; public: using BaseDelegate::BaseDelegate; + /** + * @brief Locks this delegate before further invoke + * @details This function simply returns copy of this delegate. + * Provided for interface compatibility with other delegate + * types. + * @return Lock delegate + */ LockDelegate lock() const; + /** + * @brief Invokes this delegate + * @details Delgates must be checked for NULL before invoke. + * @params[in] args Arguments of the invoke + * @return Result of the invoke + */ R operator()(ARGS ...args) const; + /** + * @brief Creates delegate to instance method + * @param[in] data This pointer of the instance + * @return Created delegate + */ template static Delegate make(CLASS *data) noexcept; + + /** + * @brief Creates delegate to constant instance method + * @param[in] data Constant this pointer of the instance + * @return Created delegate + */ template static Delegate make(const CLASS *data) noexcept; + /** + * @brief Creates delegate to StubA-style function taking object + * @param[in] data Pointer of the object + * @return Created delegate + */ template static Delegate makeA(CLASS *data) noexcept; + + /** + * @brief Creates delegate to StubB-style function taking object + * @param[in] data Pointer of the object + * @return Created delegate + */ template static Delegate makeB(CLASS *data) noexcept; + /** + * @brief Creates delegate to StubA-style function taking object handle + * @param[in] data Handle of the object + * @return Created delegate + */ template static Delegate makeA(HANDLE data) noexcept; + + /** + * @brief Creates delegate to StubB-style function taking object handle + * @param[in] data Handle of the object + * @return Created delegate + */ template static Delegate makeB(HANDLE data) noexcept; + /** + * @brief Creates delegate to static function + * @return Created delegate + */ template static Delegate make() noexcept; }; diff --git a/ucl/include/ucl/util/delegation/Delegate.hpp b/ucl/include/ucl/util/delegation/Delegate.hpp index ed24a92..18d1228 100644 --- a/ucl/include/ucl/util/delegation/Delegate.hpp +++ b/ucl/include/ucl/util/delegation/Delegate.hpp @@ -88,6 +88,7 @@ namespace ucl { inline Delegate Delegate::make() noexcept { - return {nullptr, Delegate::Cb::template stubA2V}; + const auto fakeData = reinterpret_cast(1); + return {fakeData, Delegate::Cb::template stubA2V}; } } diff --git a/ucl/include/ucl/util/delegation/Delegate2.h b/ucl/include/ucl/util/delegation/Delegate2.h index 7c643ef..330419f 100644 --- a/ucl/include/ucl/util/delegation/Delegate2.h +++ b/ucl/include/ucl/util/delegation/Delegate2.h @@ -24,33 +24,89 @@ namespace ucl { template class Delegate2; + /** + * @brief Delegate2 that uses "void *" as data pointer + */ template class Delegate2 : public BaseDelegate2 { public: + /** + * @brief Result delegate of the lock() method + */ using LockDelegate = Delegate2; public: using BaseDelegate2::BaseDelegate2; + /** + * @brief Locks this delegate before further invoke + * @details This function simply returns copy of this delegate. + * Provided for interface compatibility with other delegate + * types. + * @return Lock delegate + */ LockDelegate lock() const; + /** + * @brief Invokes this delegate + * @details Delgates must be checked for NULL before invoke. + * @params[in] args Arguments of the invoke + * @return Result of the invoke + */ R operator()(ARGS ...args) const; + /** + * @brief Creates delegate to instance method + * @param[in] data This pointer of the instance + * @return Created delegate + */ template static Delegate2 make(CLASS *data) noexcept; + + /** + * @brief Creates delegate to constant instance method + * @param[in] data Constant this pointer of the instance + * @return Created delegate + */ template static Delegate2 make(const CLASS *data) noexcept; + /** + * @brief Creates delegate to StubA-style function taking object + * @param[in] data Pointer of the object + * @return Created delegate + */ template static Delegate2 makeA(CLASS *data) noexcept; + + /** + * @brief Creates delegate to StubB-style function taking object + * @param[in] data Pointer of the object + * @return Created delegate + */ template static Delegate2 makeB(CLASS *data) noexcept; + /** + * @brief Creates delegate to StubA-style function taking object handle + * @param[in] data Handle of the object + * @return Created delegate + */ template static Delegate2 makeA(HANDLE data) noexcept; + + /** + * @brief Creates delegate to StubB-style function taking object handle + * @param[in] data Handle of the object + * @return Created delegate + */ template static Delegate2 makeB(HANDLE data) noexcept; + /** + * @brief Creates delegate to static function + * @return Created delegate + */ template static Delegate2 make() noexcept; }; diff --git a/ucl/include/ucl/util/delegation/Delegate2.hpp b/ucl/include/ucl/util/delegation/Delegate2.hpp index a3ad411..6b6fe09 100644 --- a/ucl/include/ucl/util/delegation/Delegate2.hpp +++ b/ucl/include/ucl/util/delegation/Delegate2.hpp @@ -94,7 +94,8 @@ namespace ucl { inline Delegate2 Delegate2::make() noexcept { - return {nullptr, + const auto fakeData = reinterpret_cast(1); + return {fakeData, Delegate2::Cb::template stubA2V, Delegate2::Cb::template stubB2V}; } diff --git a/ucl/include/ucl/util/delegation/helpers.h b/ucl/include/ucl/util/delegation/helpers.h index d4f574b..2c471b6 100644 --- a/ucl/include/ucl/util/delegation/helpers.h +++ b/ucl/include/ucl/util/delegation/helpers.h @@ -19,83 +19,14 @@ namespace ucl { - // Automatic function signature detection for a specific type // - - template