From 512788edf30551e187436cf8d5a09fd837ec16c0 Mon Sep 17 00:00:00 2001 From: Igor Olshevskyi Date: Wed, 17 May 2017 13:40:55 +0300 Subject: [PATCH] TizenRefApp-8520 [Call UI] Update UCL Change-Id: I2b07daf83f17bfd73e707c2f4de378bce462466d --- inc/presenters/AcceptDialog.h | 4 +- inc/presenters/AcceptRejectPresenter.h | 8 +- inc/presenters/CallInfoPresenter.h | 8 +- inc/presenters/Indicator.h | 7 +- inc/presenters/Page.h | 13 +- inc/presenters/Page.hpp | 7 +- inc/presenters/Presenter.h | 84 ++++++++++ src/model/SoundManager.cpp | 4 +- src/presenters/AcceptDialog.cpp | 5 +- src/presenters/AcceptRejectPresenter.cpp | 12 +- src/presenters/CallInfoPresenter.cpp | 8 +- src/presenters/Indicator.cpp | 9 +- src/presenters/Page.cpp | 49 +++--- src/presenters/Presenter.cpp | 186 +++++++++++++++++++++++ ucl/inc/ucl/gui/Layout.h | 2 +- ucl/inc/ucl/gui/Naviframe.h | 6 +- ucl/inc/ucl/gui/Naviframe.hpp | 4 +- ucl/inc/ucl/misc/Event.h | 6 +- ucl/inc/ucl/misc/Event.hpp | 13 +- ucl/inc/ucl/misc/SharedObject.h | 47 ------ ucl/inc/ucl/misc/SharedObject.hpp | 81 ---------- ucl/inc/ucl/util/threading/Mutex.h | 2 +- ucl/inc/ucl/util/threading/Mutex.hpp | 12 +- ucl/src/appfw/InstanceManagerBase.cpp | 2 +- ucl/src/appfw/SysEventProvider.cpp | 4 +- ucl/src/appfw/UIApp.cpp | 2 +- ucl/src/appfw/common.h | 22 +++ ucl/src/appfw/helpers.cpp | 2 +- ucl/src/gui/Layout.cpp | 4 +- ucl/src/gui/NaviItem.cpp | 4 +- ucl/src/gui/Naviframe.cpp | 16 +- ucl/src/gui/Widget.cpp | 2 +- ucl/src/gui/Window.cpp | 2 +- ucl/src/gui/common.h | 22 +++ ucl/src/misc/Variant.cpp | 2 +- ucl/src/misc/common.h | 22 +++ 36 files changed, 444 insertions(+), 239 deletions(-) create mode 100644 inc/presenters/Presenter.h create mode 100644 src/presenters/Presenter.cpp delete mode 100644 ucl/inc/ucl/misc/SharedObject.h delete mode 100644 ucl/inc/ucl/misc/SharedObject.hpp create mode 100644 ucl/src/appfw/common.h create mode 100644 ucl/src/gui/common.h create mode 100644 ucl/src/misc/common.h diff --git a/inc/presenters/AcceptDialog.h b/inc/presenters/AcceptDialog.h index 8319efe..1efaa4f 100644 --- a/inc/presenters/AcceptDialog.h +++ b/inc/presenters/AcceptDialog.h @@ -17,6 +17,8 @@ #ifndef __CALLUI_VIEW_ACCEPT_DIALOG_H__ #define __CALLUI_VIEW_ACCEPT_DIALOG_H__ +#include "Presenter.h" + #include "ucl/gui/StyledWidget.h" #include "ucl/gui/ElmWidget.h" @@ -25,7 +27,7 @@ namespace callui { class AcceptDialog final : - public ucl::RefCountAware, + public Presenter, public ucl::IDisposable { public: class Builder { diff --git a/inc/presenters/AcceptRejectPresenter.h b/inc/presenters/AcceptRejectPresenter.h index 194ebe6..31eae7f 100644 --- a/inc/presenters/AcceptRejectPresenter.h +++ b/inc/presenters/AcceptRejectPresenter.h @@ -17,6 +17,8 @@ #ifndef __CALLUI_PRESENTERS_ACCEPT_REJECT_PRESENTER_H__ #define __CALLUI_PRESENTERS_ACCEPT_REJECT_PRESENTER_H__ +#include "Presenter.h" + #include "ucl/gui/Layout.h" #include "ucl/gui/StyledWidget.h" @@ -24,7 +26,7 @@ namespace callui { - class AcceptRejectPresenter final : public ucl::RefCountAware { + class AcceptRejectPresenter final : public Presenter { public: class Builder { public: @@ -52,9 +54,9 @@ namespace callui { const IIncomingCallSRef &call, CallMask calls); - ucl::Result prepare(ucl::Widget &parent); + ucl::Result prepare(ucl::ElmWidget &parent); - ucl::Result createWidget(ucl::Widget &parent); + ucl::Result createWidget(ucl::ElmWidget &parent); ucl::Result createAcceptBtn(); ucl::Result createRejectBtn(); diff --git a/inc/presenters/CallInfoPresenter.h b/inc/presenters/CallInfoPresenter.h index 3320306..1d69705 100644 --- a/inc/presenters/CallInfoPresenter.h +++ b/inc/presenters/CallInfoPresenter.h @@ -17,6 +17,8 @@ #ifndef __CALLUI_PRESENTERS_CALL_INFO_PRESENTER_H__ #define __CALLUI_PRESENTERS_CALL_INFO_PRESENTER_H__ +#include "Presenter.h" + #include "ucl/gui/Layout.h" #include "ucl/gui/StyledWidget.h" @@ -24,7 +26,7 @@ namespace callui { - class CallInfoPresenter final : public ucl::RefCountAware { + class CallInfoPresenter final : public Presenter { public: class Builder { public: @@ -51,11 +53,11 @@ namespace callui { const ICallManagerSRef &cm, CallInfoMode mode); - ucl::Result prepare(ucl::Widget &parent); + ucl::Result prepare(ucl::ElmWidget &parent); void initCallInfos(const ICallManagerSRef &cm); - ucl::Result createWidget(ucl::Widget &parent); + ucl::Result createWidget(ucl::ElmWidget &parent); ucl::Result createLabel(const std::string &text); ucl::Result createCallStatus(); diff --git a/inc/presenters/Indicator.h b/inc/presenters/Indicator.h index 6958df4..ed98432 100644 --- a/inc/presenters/Indicator.h +++ b/inc/presenters/Indicator.h @@ -17,6 +17,7 @@ #ifndef __CALLUI_PRESENTERS_INDICATOR_H__ #define __CALLUI_PRESENTERS_INDICATOR_H__ +#include "Presenter.h" #include "model/IIndicatorStateListener.h" #include "ucl/gui/Layout.h" @@ -28,7 +29,7 @@ namespace callui { class Indicator final : public IIndicatorStateListener, - public ucl::RefCountAware { + public Presenter { public: class Builder { public: @@ -50,9 +51,9 @@ namespace callui { Indicator(ucl::RefCountObjBase &rc, const IIndicatorStateProviderSRef &provider); - ucl::Result prepare(ucl::Widget &parent); + ucl::Result prepare(ucl::ElmWidget &parent); - ucl::Result createWidget(ucl::Widget &parent); + ucl::Result createWidget(ucl::ElmWidget &parent); ucl::Result createConnectionLayout(); ucl::Result createRssiLayout(); ucl::Result createBatteryLayout(); diff --git a/inc/presenters/Page.h b/inc/presenters/Page.h index bfe3ac2..1d6b37e 100644 --- a/inc/presenters/Page.h +++ b/inc/presenters/Page.h @@ -19,19 +19,17 @@ #include "ucl/gui/Naviframe.h" -#include "types.h" +#include "Presenter.h" namespace callui { - class Page : public ucl::RefCountAware { + class Page : public Presenter { public: using ExitRequestHandler = ucl::Delegate; public: ucl::Naviframe &getNaviframe(); - bool isActive() const; - bool isAtTop() const; bool isAtBottom() const; @@ -60,8 +58,6 @@ namespace callui { void requestExit(); - virtual void onActivate(); - virtual void onDeactivate(); virtual void onBackKey(); private: @@ -69,8 +65,6 @@ namespace callui { void dispatchTopPageChanged(); - void activate(); - void deactivate(); void updateActiveState(); void onTransitionStarted(ucl::Widget &widget, void *eventInfo); @@ -84,10 +78,9 @@ namespace callui { const ucl::NaviframeSRef m_navi; const ExitRequestHandler m_onExitRequest; ucl::NaviItem m_item; - bool m_isActive; }; - // Non-member functions + // Non-member functions // bool isLast(const Page &page); } diff --git a/inc/presenters/Page.hpp b/inc/presenters/Page.hpp index 58e11c5..2f777e4 100644 --- a/inc/presenters/Page.hpp +++ b/inc/presenters/Page.hpp @@ -46,11 +46,6 @@ namespace callui { return *m_navi; } - inline bool Page::isActive() const - { - return m_isActive; - } - inline bool Page::isAtTop() const { return (m_navi->getTopItem() == m_item); @@ -61,7 +56,7 @@ namespace callui { return (m_navi->getBottomItem() == m_item); } - // Non-member functions + // Non-member functions // inline bool isLast(const Page &page) { diff --git a/inc/presenters/Presenter.h b/inc/presenters/Presenter.h new file mode 100644 index 0000000..677abe0 --- /dev/null +++ b/inc/presenters/Presenter.h @@ -0,0 +1,84 @@ +/* + * 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 __CALLUI_PRESENTERS_PRESENTER_H__ +#define __CALLUI_PRESENTERS_PRESENTER_H__ + +#include + +#include "ucl/gui/ElmWidget.h" + +#include "types.h" + +namespace callui { + + class Presenter : public ucl::RefCountAware { + public: + struct DeactivatorInfo { + void *deactivator; + bool isBroadcast; + }; + + public: + bool isActive() const; + bool isDeactivatedBy(void *deactivator) const; + + void activateBy(void *deactivator); + void deactivateBy(void *deactivator); + + protected: + Presenter(ucl::RefCountObjBase &rc); + virtual ~Presenter(); + + ucl::Result prepare(ucl::ElmWidget &widget); + + void addDeactivatorSource(ucl::Widget &source); + void addDeactivatorException(void *deactivator); + + void sendActivateBy(ucl::Widget &sender, void *deactivator); + void sendDeactivateBy(ucl::Widget &sender, void *deactivator); + + void broadcastActivateBy(void *deactivator); + void broadcastDeactivateBy(void *deactivator); + + virtual void onActivate(); + virtual void onDeactivate(); + virtual void onActivateBy(const DeactivatorInfo &info); + virtual void onDeactivateBy(const DeactivatorInfo &info); + + private: + void sendDeactivator(ucl::Widget &sender, + ucl::SmartEvent event, void *deactivator); + void broadcastDeactivator(ucl::SmartEvent event, void *deactivator); + + void sendDeactivatorInfo(ucl::Widget &sender, ucl::SmartEvent event, + const DeactivatorInfo &info); + + void activateByImpl(const DeactivatorInfo &info); + void deactivateByImpl(const DeactivatorInfo &info); + + void onActivateBySmart(ucl::Widget &widget, void *eventInfo); + void onDeactivateBySmart(ucl::Widget &widget, void *eventInfo); + + private: + std::unordered_set m_deactivatorExceptions; + std::unordered_set m_deactivators; + ucl::WidgetWRef m_topWidget; + bool m_isPrepared; + }; +} + +#endif // __CALLUI_PRESENTERS_PRESENTER_H__ diff --git a/src/model/SoundManager.cpp b/src/model/SoundManager.cpp index bcd5d95..6092986 100644 --- a/src/model/SoundManager.cpp +++ b/src/model/SoundManager.cpp @@ -49,12 +49,12 @@ namespace callui { return; } - m_audioStateEvent.invoke(convertCMAudioState(state)); + m_audioStateEvent.dispatch(convertCMAudioState(state)); } void SoundManager::muteStateChangedCb(cm_mute_status_e status) { - m_muteStateEvent.invoke(status == CM_MUTE_STATUS_ON); + m_muteStateEvent.dispatch(status == CM_MUTE_STATUS_ON); } Result SoundManager::prepare() diff --git a/src/presenters/AcceptDialog.cpp b/src/presenters/AcceptDialog.cpp index 2c7de25..e2687d6 100644 --- a/src/presenters/AcceptDialog.cpp +++ b/src/presenters/AcceptDialog.cpp @@ -73,7 +73,7 @@ namespace callui { AcceptDialog::AcceptDialog(RefCountObjBase &rc, const AcceptDialogHandler &handler): - RefCountAware(&rc), + Presenter(rc), m_handler(handler), m_isDismissed(false) { @@ -85,6 +85,9 @@ namespace callui { Result AcceptDialog::prepare(ElmWidget &parent) { + FAIL_RETURN(Presenter::prepare(parent), + "Presenter::prepare() failed!"); + FAIL_RETURN(createPopup(parent, impl::POPUP_STYLE), "createPopup() failed!"); diff --git a/src/presenters/AcceptRejectPresenter.cpp b/src/presenters/AcceptRejectPresenter.cpp index d1a0c90..dd5a8d0 100644 --- a/src/presenters/AcceptRejectPresenter.cpp +++ b/src/presenters/AcceptRejectPresenter.cpp @@ -89,7 +89,7 @@ namespace callui { AcceptRejectPresenter::AcceptRejectPresenter(RefCountObjBase &rc, const IIncomingCallSRef &call, CallMask calls): - RefCountAware(&rc), + Presenter(rc), m_call(call), m_callMask(calls) { @@ -101,14 +101,14 @@ namespace callui { m_popup->dispose(); } - eext_rotary_object_event_activated_set(m_widget->getEo(), EINA_FALSE); - delRotaryEventHandler(CALLBACK_A( AcceptRejectPresenter::onRotaryEvent), this); } - Result AcceptRejectPresenter::prepare(Widget &parent) + Result AcceptRejectPresenter::prepare(ElmWidget &parent) { + FAIL_RETURN(Presenter::prepare(parent), "Presenter::prepare() failed!"); + FAIL_RETURN(createWidget(parent), "createWidget() failed!"); FAIL_RETURN(createAcceptBtn(), "createAcceptBtn() failed!"); @@ -118,8 +118,6 @@ namespace callui { addRotaryEventHandler(CALLBACK_A( AcceptRejectPresenter::onRotaryEvent), this); - eext_rotary_object_event_activated_set(m_widget->getEo(), EINA_TRUE); - return RES_OK; } @@ -140,7 +138,7 @@ namespace callui { } } - Result AcceptRejectPresenter::createWidget(Widget &parent) + Result AcceptRejectPresenter::createWidget(ElmWidget &parent) { m_widget = Layout::Builder(). setTheme(impl::LAYOUT_ACCEPT_REJECT_WIDGET). diff --git a/src/presenters/CallInfoPresenter.cpp b/src/presenters/CallInfoPresenter.cpp index 7699ddc..d105717 100644 --- a/src/presenters/CallInfoPresenter.cpp +++ b/src/presenters/CallInfoPresenter.cpp @@ -124,7 +124,7 @@ namespace callui { CallInfoPresenter::CallInfoPresenter(RefCountObjBase &rc, const ICallManagerSRef &cm, CallInfoMode mode): - RefCountAware(&rc), + Presenter(rc), m_mode(mode), m_isCallerIdEnable(false), m_isEmergency(false), @@ -138,8 +138,10 @@ namespace callui { { } - Result CallInfoPresenter::prepare(Widget &parent) + Result CallInfoPresenter::prepare(ElmWidget &parent) { + FAIL_RETURN(Presenter::prepare(parent), "Presenter::prepare() failed!"); + FAIL_RETURN(createWidget(parent), "createWidget() failed!"); FAIL_RETURN(createCallStatus(), "createCallStatus() failed!"); @@ -149,7 +151,7 @@ namespace callui { return RES_OK; } - Result CallInfoPresenter::createWidget(Widget &parent) + Result CallInfoPresenter::createWidget(ElmWidget &parent) { m_widget = Layout::Builder(). setTheme(impl::LAYOUT_CALLER_INFO_WIDGET). diff --git a/src/presenters/Indicator.cpp b/src/presenters/Indicator.cpp index 284373d..d26083c 100644 --- a/src/presenters/Indicator.cpp +++ b/src/presenters/Indicator.cpp @@ -190,7 +190,7 @@ namespace callui { Indicator::Indicator(RefCountObjBase &rc, const IIndicatorStateProviderSRef &provider): - RefCountAware(&rc), + Presenter(rc), m_provider(provider) { } @@ -199,8 +199,11 @@ namespace callui { { } - Result Indicator::prepare(Widget &parent) + Result Indicator::prepare(ElmWidget &parent) { + FAIL_RETURN(Presenter::prepare(parent), + "Presenter::prepare() failed!"); + FAIL_RETURN(createWidget(parent), "createWidget() failed!"); @@ -224,7 +227,7 @@ namespace callui { return RES_OK; } - Result Indicator::createWidget(Widget &parent) + Result Indicator::createWidget(ElmWidget &parent) { m_widget = Layout::Builder(). setTheme(impl::LAYOUT_INDICATOR_WIDGET). diff --git a/src/presenters/Page.cpp b/src/presenters/Page.cpp index 19e8a9f..48afd5f 100644 --- a/src/presenters/Page.cpp +++ b/src/presenters/Page.cpp @@ -31,13 +31,14 @@ namespace callui { Page::Page(RefCountObjBase &rc, const NaviframeSRef &navi, const ExitRequestHandler onExitRequest) : - RefCountAware(&rc), + Presenter(rc), m_navi(navi), - m_onExitRequest(onExitRequest), - m_isActive(false) + m_onExitRequest(onExitRequest) { UCL_ASSERT(navi, "navi is NULL!"); UCL_ASSERT(onExitRequest, "onExitRequest is NULL!"); + + deactivateBy(m_navi.get()); } Page::~Page() @@ -46,6 +47,9 @@ namespace callui { Result Page::preparePart2() { + FAIL_RETURN(Presenter::prepare(*m_navi), + "Presenter::prepare() failed!"); + Evas_Object *content = m_item.getContent(); if (!content) { LOG_RETURN(RES_FAIL, "content is NULL"); @@ -77,7 +81,12 @@ namespace callui { void Page::dispatchTopPageChanged() { - m_navi->callEvent(impl::TOP_PAGE_CHANGED, nullptr); + if (!m_navi->isInTransition()) { + m_navi->callEvent(impl::TOP_PAGE_CHANGED, nullptr); + } else { + WLOG("Forcig Transition Finished!"); + m_navi->setInTransition(false); + } } void Page::onItemDel(Evas_Object *obj, void *eventInfo) @@ -140,34 +149,18 @@ namespace callui { m_onExitRequest(*this); } - void Page::activate() - { - if (!m_isActive) { - m_isActive = true; - onActivate(); - } - } - - void Page::deactivate() - { - if (m_isActive) { - m_isActive = false; - onDeactivate(); - } - } - void Page::updateActiveState() { if (isAtTop()) { - activate(); + activateBy(m_navi.get()); } else { - deactivate(); + deactivateBy(m_navi.get()); } } void Page::onTransitionStarted(Widget &widget, void *eventInfo) { - deactivate(); + deactivateBy(m_navi.get()); } void Page::onTransitionFinished(Widget &widget, void *eventInfo) @@ -182,19 +175,11 @@ namespace callui { void Page::onHWBackKey(Evas_Object *obj, void *eventInfo) { - if (m_isActive) { + if (isActive()) { onBackKey(); } } - void Page::onActivate() - { - } - - void Page::onDeactivate() - { - } - void Page::onBackKey() { requestExit(); diff --git a/src/presenters/Presenter.cpp b/src/presenters/Presenter.cpp new file mode 100644 index 0000000..0dddce7 --- /dev/null +++ b/src/presenters/Presenter.cpp @@ -0,0 +1,186 @@ +/* + * 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 "presenters/Presenter.h" + +#include "common.h" + +namespace callui { namespace { namespace impl { + + using namespace ucl; + + constexpr SmartEvent ACTIVATE_BY {"callui,activate,by"}; + constexpr SmartEvent DEACTIVATE_BY {"callui,deactivate,by"}; +}}} + +namespace callui { + + using namespace ucl; + + Presenter::Presenter(RefCountObjBase &rc) : + RefCountAware(&rc), + m_isPrepared(false) + { + } + + Presenter::~Presenter() + { + } + + Result Presenter::prepare(ElmWidget &widget) + { + m_topWidget = asWeak(asWidget(widget.getTopWidget())); + if (!m_topWidget) { + LOG_RETURN(RES_FAIL, "m_topWidget is NULL!"); + } + + addDeactivatorSource(*m_topWidget); + + m_isPrepared = true; + + return RES_OK; + } + + void Presenter::addDeactivatorSource(Widget &source) + { + source.addEventHandler(impl::ACTIVATE_BY, + WEAK_DELEGATE(Presenter::onActivateBySmart, asWeak(*this))); + source.addEventHandler(impl::DEACTIVATE_BY, + WEAK_DELEGATE(Presenter::onDeactivateBySmart, asWeak(*this))); + } + + void Presenter::addDeactivatorException(void *const deactivator) + { + const auto pair = m_deactivatorExceptions.insert(deactivator); + if (pair.second) { + activateBy(deactivator); + } + } + + void Presenter::sendActivateBy(Widget &sender, void *const deactivator) + { + sendDeactivator(sender, impl::ACTIVATE_BY, deactivator); + } + + void Presenter::sendDeactivateBy(Widget &sender, void *const deactivator) + { + sendDeactivator(sender, impl::DEACTIVATE_BY, deactivator); + } + + void Presenter::broadcastActivateBy(void *const deactivator) + { + broadcastDeactivator(impl::ACTIVATE_BY, deactivator); + } + + void Presenter::broadcastDeactivateBy(void *const deactivator) + { + broadcastDeactivator(impl::DEACTIVATE_BY, deactivator); + } + + void Presenter::sendDeactivator(Widget &sender, + SmartEvent event, void *deactivator) + { + sendDeactivatorInfo(sender, event, {deactivator, false}); + } + + void Presenter::broadcastDeactivator(const SmartEvent event, + void *const deactivator) + { + if (m_topWidget) { + sendDeactivatorInfo(*m_topWidget, event, {deactivator, true}); + } else { + ELOG("m_topWidget is NULL!"); + } + } + + void Presenter::sendDeactivatorInfo(Widget &sender, + const SmartEvent event, const DeactivatorInfo &info) + { + sender.callEvent(event, const_cast(&info)); + } + + bool Presenter::isActive() const + { + return isEmpty(m_deactivators); + } + + bool Presenter::isDeactivatedBy(void *const deactivator) const + { + return (m_deactivators.find(deactivator) != m_deactivators.end()); + } + + void Presenter::activateBy(void *const deactivator) + { + activateByImpl({deactivator, false}); + } + + void Presenter::deactivateBy(void *const deactivator) + { + deactivateByImpl({deactivator, false}); + } + + void Presenter::activateByImpl(const DeactivatorInfo &info) + { + const auto count = m_deactivators.erase(info.deactivator); + if (m_isPrepared && (count > 0)) { + onActivateBy(info); + if (m_deactivators.size() == 0) { + onActivate(); + } + } + } + + void Presenter::deactivateByImpl(const DeactivatorInfo &info) + { + if (m_deactivatorExceptions.find(info.deactivator) != + m_deactivatorExceptions.end()) { + return; + } + const auto pair = m_deactivators.insert(info.deactivator); + if (m_isPrepared && pair.second) { + onDeactivateBy(info); + if (m_deactivators.size() == 1) { + onDeactivate(); + } + } + } + + void Presenter::onActivateBySmart(Widget &widget, void *eventInfo) + { + activateByImpl(*static_cast(eventInfo)); + } + + void Presenter::onDeactivateBySmart(Widget &widget, void *eventInfo) + { + deactivateByImpl(*static_cast(eventInfo)); + } + + void Presenter::onActivate() + { + } + + void Presenter::onDeactivate() + { + } + + void Presenter::onActivateBy(const DeactivatorInfo &info) + { + } + + void Presenter::onDeactivateBy(const DeactivatorInfo &info) + { + } +} diff --git a/ucl/inc/ucl/gui/Layout.h b/ucl/inc/ucl/gui/Layout.h index 0df33ab..ec21f45 100644 --- a/ucl/inc/ucl/gui/Layout.h +++ b/ucl/inc/ucl/gui/Layout.h @@ -32,7 +32,7 @@ namespace ucl { Builder &setEdjeFile(std::string filePath, EdjeGroup group); Builder &setIsOwner(bool value); Builder &setNeedBindToEo(bool value); - LayoutSRef build(Widget &parent) const; + LayoutSRef build(ElmWidget &parent) const; private: LayoutTheme m_theme; std::string m_edjeFilePath; diff --git a/ucl/inc/ucl/gui/Naviframe.h b/ucl/inc/ucl/gui/Naviframe.h index 73c1d51..0cf36f6 100644 --- a/ucl/inc/ucl/gui/Naviframe.h +++ b/ucl/inc/ucl/gui/Naviframe.h @@ -36,13 +36,14 @@ namespace ucl { Builder(); Builder &setStyle(ElmStyle value); Builder &setNeedBindToEo(bool value); - NaviframeSRef build(Widget &parent) const; + NaviframeSRef build(ElmWidget &parent) const; private: ElmStyle m_style; bool m_needBindToEo; }; public: + void setInTransition(bool inTransition); bool isInTransition() const; void setAutoBackBtn(bool value); @@ -85,11 +86,8 @@ namespace ucl { private: friend class RefCountObj; - friend class NaviItem; Naviframe(RefCountObjBase &rc, Evas_Object *eo); - void startTransition(); - void onTransitionFinished(Widget &widget, void *eventInfo); private: diff --git a/ucl/inc/ucl/gui/Naviframe.hpp b/ucl/inc/ucl/gui/Naviframe.hpp index 4c56f4a..e8fdc19 100644 --- a/ucl/inc/ucl/gui/Naviframe.hpp +++ b/ucl/inc/ucl/gui/Naviframe.hpp @@ -78,7 +78,7 @@ namespace ucl { { auto result = elm_naviframe_item_pop(getEo()); if (getBottomItem()) { - startTransition(); + setInTransition(true); } return result; } @@ -91,7 +91,7 @@ namespace ucl { nullptr, backBtn, moreBtn, content, style.name)); result.setTitle(title); if (result != getBottomItem()) { - startTransition(); + setInTransition(true); } return result; } diff --git a/ucl/inc/ucl/misc/Event.h b/ucl/inc/ucl/misc/Event.h index efa93ce..420954a 100644 --- a/ucl/inc/ucl/misc/Event.h +++ b/ucl/inc/ucl/misc/Event.h @@ -36,13 +36,13 @@ namespace ucl { bool isEmpty() const; template - void invoke(ARGS &&...args); + void dispatch(ARGS &&...args); template - void invokePred(PREDICATE &&pred, ARGS &&...args); + void dispatchPred(PREDICATE &&pred, ARGS &&...args); private: template - void invokeImpl(const DO_INVOKE &doInvoke, ARGS &&...args); + void dispatchImpl(const DO_INVOKE &doInvoke, ARGS &&...args); void lock(); void unlock(); diff --git a/ucl/inc/ucl/misc/Event.hpp b/ucl/inc/ucl/misc/Event.hpp index 53e58a2..f0caec0 100644 --- a/ucl/inc/ucl/misc/Event.hpp +++ b/ucl/inc/ucl/misc/Event.hpp @@ -78,9 +78,9 @@ namespace ucl { template template - void Event::invoke(ARGS &&...args) + void Event::dispatch(ARGS &&...args) { - invokeImpl( + dispatchImpl( [](const DELEGATE &delegate, ARGS &&...args) { delegate(std::forward(args)...); @@ -91,9 +91,9 @@ namespace ucl { template template - void Event::invokePred(PREDICATE &&pred, ARGS &&...args) + void Event::dispatchPred(PREDICATE &&pred, ARGS &&...args) { - invokeImpl( + dispatchImpl( [&pred](const DELEGATE &delegate, ARGS &&...args) { return impl::doInvokePred(std::forward(pred), @@ -104,10 +104,11 @@ namespace ucl { template template - void Event::invokeImpl(const DO_INVOKE &doInvoke, ARGS &&...args) + void Event::dispatchImpl(const DO_INVOKE &doInvoke, ARGS &&...args) { lock(); - for (size_t i = 0; i < m_delegates.size(); ++i) { + const auto size = m_delegates.size(); + for (size_t i = 0; i < size; ++i) { const auto &delegate = m_delegates[i]; if (delegate) { if (!doInvoke(delegate, std::forward(args)...)) { diff --git a/ucl/inc/ucl/misc/SharedObject.h b/ucl/inc/ucl/misc/SharedObject.h deleted file mode 100644 index a62fefd..0000000 --- a/ucl/inc/ucl/misc/SharedObject.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __UCL_MISC_SHARED_OBJECT_H__ -#define __UCL_MISC_SHARED_OBJECT_H__ - -#include "ucl/util/types.h" -#include "ucl/util/memory.h" - -namespace ucl { - - UCL_DECLARE_REF_ALIASES(SharedObject); - - class SharedObject : public NonCopyable { - public: - template - SharedRef asShared(); - template - WeakRef asWeak(); - - template - SharedRef asShared() const; - template - WeakRef asWeak() const; - - SharedObjectSRef asShared(); - SharedObjectWRef asWeak(); - - SharedObjectSCRef asShared() const; - SharedObjectWCRef asWeak() const; - - protected: - SharedObject(RefCountObjBase *rc); - ~SharedObject() = default; - - protected: - RefCountObjBase *const m_rc; - }; - - // Non-member functions // - - template - SharedRef asShared(T *obj); - template - WeakRef asWeak(T *obj); -} - -#include "SharedObject.hpp" - -#endif // __UCL_MISC_SHARED_OBJECT_H__ diff --git a/ucl/inc/ucl/misc/SharedObject.hpp b/ucl/inc/ucl/misc/SharedObject.hpp deleted file mode 100644 index 75a09a2..0000000 --- a/ucl/inc/ucl/misc/SharedObject.hpp +++ /dev/null @@ -1,81 +0,0 @@ -namespace ucl { - - inline SharedObject::SharedObject(RefCountObjBase *const rc) : - m_rc(rc) - { - } - - template - inline SharedRef SharedObject::asShared() - { - if (!m_rc) { - return {}; - } - return {m_rc, static_cast(this)}; - } - - template - inline WeakRef SharedObject::asWeak() - { - if (!m_rc) { - return {}; - } - return {m_rc, static_cast(this)}; - } - - template - inline SharedRef SharedObject::asShared() const - { - if (!m_rc) { - return {}; - } - return {m_rc, static_cast(this)}; - } - - template - inline WeakRef SharedObject::asWeak() const - { - if (!m_rc) { - return {}; - } - return {m_rc, static_cast(this)}; - } - - inline SharedObjectSRef SharedObject::asShared() - { - return asShared(); - } - - inline SharedObjectWRef SharedObject::asWeak() - { - return asWeak(); - } - - inline SharedObjectSCRef SharedObject::asShared() const - { - return asShared(); - } - - inline SharedObjectWCRef SharedObject::asWeak() const - { - return asWeak(); - } - - // Non-member functions // - - template - inline SharedRef asShared(T *obj) - { - return (obj ? - obj->asShared::type>() : - SharedRef()); - } - - template - inline WeakRef asWeak(T *obj) - { - return (obj ? - obj->asWeak::type>() : - WeakRef()); - } -} diff --git a/ucl/inc/ucl/util/threading/Mutex.h b/ucl/inc/ucl/util/threading/Mutex.h index a6280cc..e1951bc 100644 --- a/ucl/inc/ucl/util/threading/Mutex.h +++ b/ucl/inc/ucl/util/threading/Mutex.h @@ -27,7 +27,7 @@ namespace ucl { class Mutex : public NonCopyable { public: - Mutex(); + Mutex(bool recursive = false); ~Mutex(); void lock(); void unlock(); diff --git a/ucl/inc/ucl/util/threading/Mutex.hpp b/ucl/inc/ucl/util/threading/Mutex.hpp index d152df3..c3b75be 100644 --- a/ucl/inc/ucl/util/threading/Mutex.hpp +++ b/ucl/inc/ucl/util/threading/Mutex.hpp @@ -16,10 +16,18 @@ namespace ucl { - inline Mutex::Mutex() : + inline Mutex::Mutex(const bool recursive) : m_mutex() { - pthread_mutex_init(&m_mutex, NULL); + if (recursive) { + pthread_mutexattr_t attr = {}; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&m_mutex, &attr); + pthread_mutexattr_destroy(&attr); + } else { + pthread_mutex_init(&m_mutex, nullptr); + } } inline Mutex::~Mutex() diff --git a/ucl/src/appfw/InstanceManagerBase.cpp b/ucl/src/appfw/InstanceManagerBase.cpp index a643b38..2e90b24 100644 --- a/ucl/src/appfw/InstanceManagerBase.cpp +++ b/ucl/src/appfw/InstanceManagerBase.cpp @@ -16,7 +16,7 @@ #include "ucl/appfw/InstanceManagerBase.h" -#include "../common.h" +#include "common.h" namespace ucl { diff --git a/ucl/src/appfw/SysEventProvider.cpp b/ucl/src/appfw/SysEventProvider.cpp index 3b8994e..8958aaf 100644 --- a/ucl/src/appfw/SysEventProvider.cpp +++ b/ucl/src/appfw/SysEventProvider.cpp @@ -16,7 +16,7 @@ #include "ucl/appfw/SysEventProvider.h" -#include "../common.h" +#include "common.h" namespace ucl { @@ -108,6 +108,6 @@ namespace ucl { void SysEventProvider::dispatch(SysEvent sysEvent) { - m_event.invoke(sysEvent); + m_event.dispatch(sysEvent); } } diff --git a/ucl/src/appfw/UIApp.cpp b/ucl/src/appfw/UIApp.cpp index 49c5e67..4012eca 100644 --- a/ucl/src/appfw/UIApp.cpp +++ b/ucl/src/appfw/UIApp.cpp @@ -19,7 +19,7 @@ #include #include "ucl/appfw/IInstanceAppControlExt.h" -#include "../common.h" +#include "common.h" namespace ucl { diff --git a/ucl/src/appfw/common.h b/ucl/src/appfw/common.h new file mode 100644 index 0000000..b612dfb --- /dev/null +++ b/ucl/src/appfw/common.h @@ -0,0 +1,22 @@ +/* + * 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_APPFW_COMMON_H__ +#define __UCL_APPFW_COMMON_H__ + +#include "../common.h" + +#endif // __UCL_APPFW_COMMON_H__ diff --git a/ucl/src/appfw/helpers.cpp b/ucl/src/appfw/helpers.cpp index a87e4ac..c547dce 100644 --- a/ucl/src/appfw/helpers.cpp +++ b/ucl/src/appfw/helpers.cpp @@ -16,7 +16,7 @@ #include "ucl/appfw/helpers.h" -#include "../common.h" +#include "common.h" namespace ucl { diff --git a/ucl/src/gui/Layout.cpp b/ucl/src/gui/Layout.cpp index 070a8d6..1509fc5 100644 --- a/ucl/src/gui/Layout.cpp +++ b/ucl/src/gui/Layout.cpp @@ -18,13 +18,13 @@ #include "ucl/gui/stdTheme/layout.h" -#include "../common.h" +#include "common.h" namespace ucl { // Layout::Builder // - LayoutSRef Layout::Builder::build(Widget &parent) const + LayoutSRef Layout::Builder::build(ElmWidget &parent) const { Evas_Object *const eo = elm_layout_add(parent); if (!eo) { diff --git a/ucl/src/gui/NaviItem.cpp b/ucl/src/gui/NaviItem.cpp index 052a8ea..dd212bf 100644 --- a/ucl/src/gui/NaviItem.cpp +++ b/ucl/src/gui/NaviItem.cpp @@ -30,7 +30,7 @@ namespace ucl { elm_naviframe_item_pop_to(getIt()); if (needStartTransition) { - navi->startTransition(); + navi->setInTransition(true); } } @@ -43,7 +43,7 @@ namespace ucl { elm_naviframe_item_promote(getIt()); if (needStartTransition) { - navi->startTransition(); + navi->setInTransition(true); } } } diff --git a/ucl/src/gui/Naviframe.cpp b/ucl/src/gui/Naviframe.cpp index 1f8a589..881390c 100644 --- a/ucl/src/gui/Naviframe.cpp +++ b/ucl/src/gui/Naviframe.cpp @@ -16,13 +16,13 @@ #include "ucl/gui/Naviframe.h" -#include "../common.h" +#include "common.h" namespace ucl { // Naviframe::Builder // - NaviframeSRef Naviframe::Builder::build(Widget &parent) const + NaviframeSRef Naviframe::Builder::build(ElmWidget &parent) const { Evas_Object *const eo = elm_naviframe_add(parent); if (!eo) { @@ -55,11 +55,15 @@ namespace ucl { Naviframe::onTransitionFinished, asWeak(*this))); } - void Naviframe::startTransition() + void Naviframe::setInTransition(const bool inTransition) { - if (!m_isInTransition) { - m_isInTransition = true; - callEvent(NAVI_TRANSITION_STARTED); + if (inTransition != m_isInTransition) { + m_isInTransition = inTransition; + if (inTransition) { + callEvent(NAVI_TRANSITION_STARTED); + } else { + callEvent(NAVI_TRANSITION_FINISHED); + } } } diff --git a/ucl/src/gui/Widget.cpp b/ucl/src/gui/Widget.cpp index 5012a6a..5129f18 100644 --- a/ucl/src/gui/Widget.cpp +++ b/ucl/src/gui/Widget.cpp @@ -16,7 +16,7 @@ #include "ucl/gui/Widget.h" -#include "../common.h" +#include "common.h" namespace ucl { namespace { namespace impl { diff --git a/ucl/src/gui/Window.cpp b/ucl/src/gui/Window.cpp index e63a0e7..3f74e9e 100644 --- a/ucl/src/gui/Window.cpp +++ b/ucl/src/gui/Window.cpp @@ -16,7 +16,7 @@ #include "ucl/gui/Window.h" -#include "../common.h" +#include "common.h" namespace ucl { diff --git a/ucl/src/gui/common.h b/ucl/src/gui/common.h new file mode 100644 index 0000000..6b543d3 --- /dev/null +++ b/ucl/src/gui/common.h @@ -0,0 +1,22 @@ +/* + * 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_COMMON_H__ +#define __UCL_GUI_COMMON_H__ + +#include "../common.h" + +#endif // __UCL_GUI_COMMON_H__ diff --git a/ucl/src/misc/Variant.cpp b/ucl/src/misc/Variant.cpp index 6513076..3859bc5 100644 --- a/ucl/src/misc/Variant.cpp +++ b/ucl/src/misc/Variant.cpp @@ -16,7 +16,7 @@ #include "ucl/misc/Variant.h" -#include "../common.h" +#include "common.h" namespace ucl { diff --git a/ucl/src/misc/common.h b/ucl/src/misc/common.h new file mode 100644 index 0000000..372ad4d --- /dev/null +++ b/ucl/src/misc/common.h @@ -0,0 +1,22 @@ +/* + * 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_MISC_COMMON_H__ +#define __UCL_MISC_COMMON_H__ + +#include "../common.h" + +#endif // __UCL_MISC_COMMON_H__ -- 2.34.1