diff options
21 files changed, 168 insertions, 125 deletions
diff --git a/inc/gallery/presenters/AtspiHighlightHelper.h b/inc/gallery/presenters/AtspiHighlightHelper.h index 4175d57..650860e 100644 --- a/inc/gallery/presenters/AtspiHighlightHelper.h +++ b/inc/gallery/presenters/AtspiHighlightHelper.h @@ -17,19 +17,19 @@ #ifndef __GALLERY_PRESENTERS_ATSPI_HIGHLIGH_HELPER_H__ #define __GALLERY_PRESENTERS_ATSPI_HIGHLIGH_HELPER_H__ -#include "Presenter.h" +#include "ucl/mvp/GuiPresenter.h" namespace gallery { UCL_DECLARE_REF_ALIASES(AtspiHighlightHelper); - class AtspiHighlightHelper final : public Presenter { + class AtspiHighlightHelper final : public ucl::GuiPresenter { public: using EventHandler = ucl::WeakDelegate<Elm_Interface_Atspi_Accessible *( ucl::Widget &widget, Elm_Atspi_Relation_Type flowRelation)>; public: - static AtspiHighlightHelperSRef newInstance(Presenter &parent, + static AtspiHighlightHelperSRef newInstance(GuiPresenter &parent, ucl::ElmWidget &rootWidget); void setEventHandler(EventHandler handler); @@ -40,7 +40,7 @@ namespace gallery { AtspiHighlightHelper(ucl::IRefCountObj &rc); virtual ~AtspiHighlightHelper(); - ucl::Result prepare(Presenter &parent, ucl::ElmWidget &rootWidget); + ucl::Result prepare(GuiPresenter &parent, ucl::ElmWidget &rootWidget); private: void onAtspiGesture(ucl::Widget &widget, void *eventInfo); diff --git a/inc/gallery/presenters/Dialog.h b/inc/gallery/presenters/Dialog.h index 9aa6246..f820c07 100644 --- a/inc/gallery/presenters/Dialog.h +++ b/inc/gallery/presenters/Dialog.h @@ -19,13 +19,13 @@ #include "ucl/gui/StyledWidget.h" -#include "Presenter.h" +#include "ucl/mvp/GuiPresenter.h" namespace gallery { UCL_DECLARE_REF_ALIASES(Dialog); - class Dialog : public Presenter, + class Dialog : public ucl::GuiPresenter, public ucl::IDisposable { public: void open(); diff --git a/inc/gallery/presenters/Dialog.hpp b/inc/gallery/presenters/Dialog.hpp index 35487b9..ed2c8f7 100644 --- a/inc/gallery/presenters/Dialog.hpp +++ b/inc/gallery/presenters/Dialog.hpp @@ -22,8 +22,8 @@ namespace gallery { inline ucl::Result Dialog::prepare(ucl::ElmWidget &parent, const PopupType popupType, ON_PREPARE &&onPrepare) { - UCL_FAIL_RETURN(Presenter::prepare(parent, PF_DEACTIVATOR), - "Presenter::prepare() failed!"); + UCL_FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR), + "GuiPresenter::prepare() failed!"); UCL_FAIL_RETURN(createPopup(parent, popupType), "createPopup() failed!"); diff --git a/inc/gallery/presenters/MoreOptionsPresenter.h b/inc/gallery/presenters/MoreOptionsPresenter.h index 88f45ca..72c605a 100644 --- a/inc/gallery/presenters/MoreOptionsPresenter.h +++ b/inc/gallery/presenters/MoreOptionsPresenter.h @@ -21,13 +21,13 @@ #include "ucl/misc/HashMap.h" -#include "Presenter.h" +#include "ucl/mvp/GuiPresenter.h" namespace gallery { UCL_DECLARE_REF_ALIASES(MoreOptionsPresenter); - class MoreOptionsPresenter final : public Presenter { + class MoreOptionsPresenter final : public ucl::GuiPresenter { public: UCL_DECLARE_REF_ALIASES(IListener); @@ -48,7 +48,7 @@ namespace gallery { Builder &clear(); Builder &addOption(Option option); Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget); - MoreOptionsPresenterSRef build(Presenter &parent) const; + MoreOptionsPresenterSRef build(GuiPresenter &parent) const; private: ucl::SharedRef<MoreOptions> m_options; ucl::ElmWidgetSRef m_parentWidget; @@ -83,7 +83,7 @@ namespace gallery { const MoreOptionsCSRef &options); virtual ~MoreOptionsPresenter(); - ucl::Result prepare(Presenter &parent, ucl::ElmWidget &parentWidget); + ucl::Result prepare(GuiPresenter &parent, ucl::ElmWidget &parentWidget); ucl::Result addItem(const Option &option); bool resetTimer(double timeout); diff --git a/inc/gallery/presenters/Page.h b/inc/gallery/presenters/Page.h index 201ccc7..d8132dc 100644 --- a/inc/gallery/presenters/Page.h +++ b/inc/gallery/presenters/Page.h @@ -19,13 +19,13 @@ #include "ucl/gui/Naviframe.h" -#include "Presenter.h" +#include "ucl/mvp/GuiPresenter.h" namespace gallery { UCL_DECLARE_REF_ALIASES(Page); - class Page : public Presenter { + class Page : public ucl::GuiPresenter { public: using ExitRequestHandler = ucl::WeakDelegate<void(Page &page)>; diff --git a/inc/gallery/presenters/Page.hpp b/inc/gallery/presenters/Page.hpp index 7a8fdbd..426445a 100644 --- a/inc/gallery/presenters/Page.hpp +++ b/inc/gallery/presenters/Page.hpp @@ -21,8 +21,8 @@ namespace gallery { template <class ON_PREPARE> inline ucl::Result Page::prepare(ON_PREPARE &&onPrepare) { - UCL_FAIL_RETURN(Presenter::prepare(*m_navi), - "Presenter::prepare() failed!"); + UCL_FAIL_RETURN(GuiPresenter::prepare(*m_navi), + "GuiPresenter::prepare() failed!"); UCL_FAIL_RETURN(onPrepare(m_item), "onPrepare() failed!"); diff --git a/inc/gallery/presenters/PreviewPage.h b/inc/gallery/presenters/PreviewPage.h index 38d9798..5773ee4 100644 --- a/inc/gallery/presenters/PreviewPage.h +++ b/inc/gallery/presenters/PreviewPage.h @@ -94,7 +94,7 @@ namespace gallery { Elm_Interface_Atspi_Accessible *onAtspiHighlight( ucl::Widget &widget, Elm_Atspi_Relation_Type flowRelation); - // Presenter // + // GuiPresenter // virtual void onActivateBy(const DeactivatorInfo &info) final override; virtual void onDeactivateBy(const DeactivatorInfo &info) final override; diff --git a/inc/gallery/presenters/ProcessingPresenter.h b/inc/gallery/presenters/ProcessingPresenter.h index 94e1e80..9b54767 100644 --- a/inc/gallery/presenters/ProcessingPresenter.h +++ b/inc/gallery/presenters/ProcessingPresenter.h @@ -20,13 +20,13 @@ #include "ucl/gui/Layout.h" #include "ucl/gui/StyledWidget.h" -#include "Presenter.h" +#include "ucl/mvp/GuiPresenter.h" namespace gallery { UCL_DECLARE_REF_ALIASES(ProcessingPresenter); - class ProcessingPresenter final : public Presenter { + class ProcessingPresenter final : public ucl::GuiPresenter { public: enum class IconType { NONE, diff --git a/inc/gallery/presenters/SelectModePresenter.h b/inc/gallery/presenters/SelectModePresenter.h index 3cf1fa9..75c2e14 100644 --- a/inc/gallery/presenters/SelectModePresenter.h +++ b/inc/gallery/presenters/SelectModePresenter.h @@ -19,7 +19,7 @@ #include "ucl/gui/StyledWidget.h" -#include "Presenter.h" +#include "ucl/mvp/GuiPresenter.h" #include "gallery/view/PageContent.h" @@ -27,7 +27,7 @@ namespace gallery { UCL_DECLARE_REF_ALIASES(SelectModePresenter); - class SelectModePresenter final : public Presenter { + class SelectModePresenter final : public ucl::GuiPresenter { public: UCL_DECLARE_REF_ALIASES(IListener); @@ -43,7 +43,7 @@ namespace gallery { Builder(); Builder &setFlags(int flags); Builder &setPageContent(const PageContentSRef &content); - SelectModePresenterSRef build(Presenter &parent) const; + SelectModePresenterSRef build(GuiPresenter &parent) const; private: PageContentSRef m_content; int m_flags; @@ -79,7 +79,7 @@ namespace gallery { const PageContentSRef &content, int flags); virtual ~SelectModePresenter(); - ucl::Result prepare(Presenter &parent); + ucl::Result prepare(GuiPresenter &parent); void doUpdate(); @@ -100,7 +100,7 @@ namespace gallery { void onBottomBtnClick(ucl::Widget &widget, void *eventInfo); Eina_Bool onRotary(Eext_Rotary_Event_Info *info); - // Presenter // + // GuiPresenter // virtual void onDeactivate() final override; private: diff --git a/inc/gallery/presenters/ThumbnailPage.h b/inc/gallery/presenters/ThumbnailPage.h index 9ad821a..46beeed 100644 --- a/inc/gallery/presenters/ThumbnailPage.h +++ b/inc/gallery/presenters/ThumbnailPage.h @@ -69,7 +69,7 @@ namespace gallery { Elm_Interface_Atspi_Accessible *onAtspiHighlight( ucl::Widget &widget, Elm_Atspi_Relation_Type flowRelation); - // Presenter // + // GuiPresenter // virtual void onActivateBy(const DeactivatorInfo &info) final override; virtual void onDeactivateBy(const DeactivatorInfo &info) final override; diff --git a/project_def.prop b/project_def.prop index 0834ff8..b90d2da 100644 --- a/project_def.prop +++ b/project_def.prop @@ -9,7 +9,7 @@ type = app profile = wearable-4.0
# C/CPP Sources
-USER_SRCS = ucl/src/gui/NaviItem.cpp src/resources.cpp ucl/src/gui/Layout.cpp src/model/Gallery.cpp src/presenters/ThumbnailPage.cpp src/view/PageContent.cpp src/presenters/ViewerPage.cpp src/presenters/Presenter.cpp ucl/src/appfw/UIApp.cpp src/model/MediaItem.cpp ucl/src/gui/ElmWidget.cpp ucl/src/appfw/helpers.cpp src/presenters/SelectModePresenter.cpp ucl/src/gui/EdjeWidget.cpp src/view/ImageViewer.cpp src/view/TouchParser.cpp ucl/src/gui/Window.cpp ucl/src/gui/Widget.cpp ucl/src/util/types/Result.cpp src/model/SoundManager.cpp src/model/GalleryAlbum.cpp src/presenters/Instance.cpp ucl/src/misc/Variant.cpp src/main.cpp src/presenters/internal.cpp src/presenters/InstanceManager.cpp src/presenters/AlertDialog.cpp src/model/BaseJob.cpp ucl/src/appfw/InstanceManagerBase.cpp src/presenters/VideoPlayerPage.cpp ucl/src/util/logging.cpp ucl/src/appfw/SysEventProvider.cpp src/view/helpers.cpp src/presenters/MoreOptionsPresenter.cpp src/presenters/PreviewPage.cpp src/presenters/NoContentPage.cpp src/model/internal.cpp src/presenters/ProcessingPresenter.cpp ucl/src/gui/Naviframe.cpp src/presenters/Page.cpp src/view/ImageGrid.cpp ucl/src/gui/WidgetItem.cpp
+USER_SRCS = ucl/src/gui/NaviItem.cpp src/resources.cpp ucl/src/gui/Layout.cpp src/model/Gallery.cpp src/presenters/ThumbnailPage.cpp ucl/src/misc/Timeout.cpp src/view/PageContent.cpp src/presenters/ViewerPage.cpp ucl/src/appfw/UIApp.cpp src/model/MediaItem.cpp ucl/src/gui/ElmWidget.cpp ucl/src/appfw/helpers.cpp src/presenters/SelectModePresenter.cpp ucl/src/gui/EdjeWidget.cpp src/model/helpers.cpp src/view/ImageViewer.cpp src/presenters/AtspiHighlightHelper.cpp src/view/TouchParser.cpp ucl/src/gui/Window.cpp ucl/src/gui/Widget.cpp ucl/src/util/types/Result.cpp src/model/SoundManager.cpp src/model/GalleryAlbum.cpp src/presenters/Instance.cpp ucl/src/misc/Variant.cpp src/main.cpp src/presenters/InstanceManager.cpp src/presenters/AlertDialog.cpp src/model/BaseJob.cpp ucl/src/appfw/InstanceManagerBase.cpp src/presenters/VideoPlayerPage.cpp ucl/src/util/logging.cpp ucl/src/appfw/SysEventProvider.cpp src/view/helpers.cpp src/presenters/MoreOptionsPresenter.cpp src/presenters/PreviewPage.cpp ucl/src/mvp/GuiPresenter.cpp src/presenters/NoContentPage.cpp src/presenters/ProcessingPresenter.cpp ucl/src/gui/Naviframe.cpp src/presenters/Dialog.cpp src/presenters/Page.cpp src/view/ImageGrid.cpp src/presenters/helpers.cpp ucl/src/gui/WidgetItem.cpp
# EDC Sources
USER_EDCS =
diff --git a/src/presenters/AtspiHighlightHelper.cpp b/src/presenters/AtspiHighlightHelper.cpp index d6f05c9..d960cb0 100644 --- a/src/presenters/AtspiHighlightHelper.cpp +++ b/src/presenters/AtspiHighlightHelper.cpp @@ -30,7 +30,7 @@ namespace gallery { using ucl::ATSPI_ON_GESTURE; AtspiHighlightHelperSRef AtspiHighlightHelper::newInstance( - Presenter &parent, ElmWidget &rootWidget) + GuiPresenter &parent, ElmWidget &rootWidget) { auto result = makeShared<AtspiHighlightHelper>(); @@ -41,7 +41,7 @@ namespace gallery { } AtspiHighlightHelper::AtspiHighlightHelper(IRefCountObj &rc) : - Presenter(rc) + GuiPresenter(rc) { } @@ -49,11 +49,11 @@ namespace gallery { { } - Result AtspiHighlightHelper::prepare(Presenter &parent, + Result AtspiHighlightHelper::prepare(GuiPresenter &parent, ElmWidget &rootWidget) { - FAIL_RETURN(Presenter::prepare(parent), - "Presenter::prepare() failed!"); + FAIL_RETURN(GuiPresenter::prepare(parent), + "GuiPresenter::prepare() failed!"); registerWidget(rootWidget); diff --git a/src/presenters/Dialog.cpp b/src/presenters/Dialog.cpp index 3f16630..826b9fa 100644 --- a/src/presenters/Dialog.cpp +++ b/src/presenters/Dialog.cpp @@ -21,7 +21,7 @@ namespace gallery { Dialog::Dialog(IRefCountObj &rc) : - Presenter(rc), + GuiPresenter(rc), m_isDismissed(false) { } diff --git a/src/presenters/MoreOptionsPresenter.cpp b/src/presenters/MoreOptionsPresenter.cpp index 6a20b2d..f444293 100644 --- a/src/presenters/MoreOptionsPresenter.cpp +++ b/src/presenters/MoreOptionsPresenter.cpp @@ -90,7 +90,7 @@ namespace gallery { } MoreOptionsPresenterSRef MoreOptionsPresenter::Builder::build( - Presenter &parent) const + GuiPresenter &parent) const { if (isEmpty()) { LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Builder is empty!"); @@ -112,7 +112,7 @@ namespace gallery { MoreOptionsPresenter::MoreOptionsPresenter(IRefCountObj &rc, const MoreOptionsCSRef &options) : - Presenter(rc), + GuiPresenter(rc), m_options(options), m_timer(nullptr), m_newOpenedState(false) @@ -127,11 +127,11 @@ namespace gallery { } } - Result MoreOptionsPresenter::prepare(Presenter &parent, + Result MoreOptionsPresenter::prepare(GuiPresenter &parent, ElmWidget &parentWidget) { - FAIL_RETURN(Presenter::prepare(parent, PF_DEACTIVATOR), - "Presenter::prepare() failed!"); + FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR), + "GuiPresenter::prepare() failed!"); Evas_Object *const more = eext_more_option_add(parentWidget); if (!more) { diff --git a/src/presenters/Page.cpp b/src/presenters/Page.cpp index 9ccf2ed..ae3f71e 100644 --- a/src/presenters/Page.cpp +++ b/src/presenters/Page.cpp @@ -33,7 +33,7 @@ namespace gallery { Page::Page(IRefCountObj &rc, const NaviframeSRef &navi, const ExitRequestHandler &onExitRequest) : - Presenter(rc), + GuiPresenter(rc), m_navi(navi), m_onExitRequest(onExitRequest) { diff --git a/src/presenters/ProcessingPresenter.cpp b/src/presenters/ProcessingPresenter.cpp index 3d1ad21..7238837 100644 --- a/src/presenters/ProcessingPresenter.cpp +++ b/src/presenters/ProcessingPresenter.cpp @@ -87,7 +87,7 @@ namespace gallery { // ProcessingPresenter // ProcessingPresenter::ProcessingPresenter(IRefCountObj &rc) : - Presenter(rc), + GuiPresenter(rc), m_iconType(IconType::NONE), m_timer(nullptr), m_state(State::WAITING), @@ -107,8 +107,8 @@ namespace gallery { const TString &processingText, const bool forceProgress) { - FAIL_RETURN(Presenter::prepare(parent, PF_PASSIVE), - "Presenter::prepare() failed!"); + FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE), + "GuiPresenter::prepare() failed!"); FAIL_RETURN(createWidget(parent, processingText), "createWidget() failed!"); diff --git a/src/presenters/SelectModePresenter.cpp b/src/presenters/SelectModePresenter.cpp index b9b333c..a63c624 100644 --- a/src/presenters/SelectModePresenter.cpp +++ b/src/presenters/SelectModePresenter.cpp @@ -60,7 +60,7 @@ namespace gallery { } SelectModePresenterSRef SelectModePresenter::Builder::build( - Presenter &parent) const + GuiPresenter &parent) const { if (!m_content) { LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_content is NULL!"); @@ -78,7 +78,7 @@ namespace gallery { SelectModePresenter::SelectModePresenter(IRefCountObj &rc, const PageContentSRef &content, const int flags) : - Presenter(rc), + GuiPresenter(rc), m_content(content), m_flags(flags), m_totalCount(0), @@ -97,10 +97,10 @@ namespace gallery { deletePopup(); } - Result SelectModePresenter::prepare(Presenter &parent) + Result SelectModePresenter::prepare(GuiPresenter &parent) { - FAIL_RETURN(Presenter::prepare(parent, PF_DEACTIVATOR), - "Presenter::prepare() failed!"); + FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR), + "GuiPresenter::prepare() failed!"); m_selectButton = makeShared<StyledWidget>( elm_button_add(*m_content), true); diff --git a/inc/gallery/presenters/Presenter.h b/ucl/inc/ucl/mvp/GuiPresenter.h index ee39f0e..f81bcac 100644 --- a/inc/gallery/presenters/Presenter.h +++ b/ucl/inc/ucl/mvp/GuiPresenter.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef __GALLERY_PRESENTERS_PRESENTER_H__ -#define __GALLERY_PRESENTERS_PRESENTER_H__ +#ifndef __UCL_MVP_GUI_PRESENTER_H__ +#define __UCL_MVP_GUI_PRESENTER_H__ #include <unordered_set> @@ -23,11 +23,11 @@ #include "types.h" -namespace gallery { +namespace ucl { - UCL_DECLARE_REF_ALIASES(Presenter); + UCL_DECLARE_REF_ALIASES(GuiPresenter); - class Presenter : public ucl::RefCountAware { + class GuiPresenter : public RefCountAware { public: struct DeactivatorInfo { const void *deactivator; @@ -41,8 +41,8 @@ namespace gallery { void activateBy(const void *deactivator); void deactivateBy(const void *deactivator); - void addDeactivatorSource(ucl::Widget &source); - void delDeactivatorSource(ucl::Widget &source); + void addDeactivatorSource(Widget &source); + void delDeactivatorSource(Widget &source); protected: enum { @@ -55,20 +55,20 @@ namespace gallery { }; protected: - Presenter(ucl::IRefCountObj &rc); - virtual ~Presenter(); + GuiPresenter(IRefCountObj &rc); + virtual ~GuiPresenter(); - ucl::Result prepare(ucl::ElmWidget &widget, int flags = PF_DEFAULT); - ucl::Result prepare(Presenter &parent, int flags = PF_DEFAULT); + Result prepare(ElmWidget &widget, int flags = PF_DEFAULT); + Result prepare(GuiPresenter &parent, int flags = PF_DEFAULT); - ucl::Window &getWindow(); + Window &getWindow(); bool isWindowReady() const; void addDeactivatorException(const void *deactivator); - void setDeactivatorSink(const ucl::WidgetSRef &sink); + void setDeactivatorSink(const WidgetSRef &sink); - void sendActivate(ucl::Widget &sender); - void sendDeactivate(ucl::Widget &sender); + void sendActivate(Widget &sender); + void sendDeactivate(Widget &sender); void broadcastActivate(); void broadcastDeactivate(); @@ -79,30 +79,30 @@ namespace gallery { virtual void onDeactivateBy(const DeactivatorInfo &info); private: - void sendDeactivator(ucl::Widget &sender, - ucl::SmartEvent event, const void *deactivator); - void broadcastDeactivator(ucl::SmartEvent event, + void sendDeactivator(Widget &sender, + SmartEvent event, const void *deactivator); + void broadcastDeactivator(SmartEvent event, const void *deactivator); - void sendDeactivatorInfo(ucl::Widget &sender, ucl::SmartEvent event, + void sendDeactivatorInfo(Widget &sender, 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); + void onActivateBySmart(Widget &widget, void *eventInfo); + void onDeactivateBySmart(Widget &widget, void *eventInfo); private: std::unordered_set<const void *> m_deactivatorExceptions; std::unordered_set<const void *> m_deactivators; - ucl::WindowSRef m_window; - ucl::WidgetSRef m_sink; - ucl::WidgetWRef m_parentSink; + WindowSRef m_window; + WidgetSRef m_sink; + WidgetWRef m_parentSink; bool m_hasBuildInSources; bool m_isChild; bool m_isPrepared; }; } -#endif // __GALLERY_PRESENTERS_PRESENTER_H__ +#endif // __UCL_MVP_GUI_PRESENTER_H__ diff --git a/ucl/inc/ucl/mvp/types.h b/ucl/inc/ucl/mvp/types.h new file mode 100644 index 0000000..6c263e2 --- /dev/null +++ b/ucl/inc/ucl/mvp/types.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_MVP_TYPES_H__ +#define __UCL_MVP_TYPES_H__ + +#include "ucl/gui/types.h" + +#endif // __UCL_MVP_TYPES_H__ diff --git a/src/presenters/Presenter.cpp b/ucl/src/mvp/GuiPresenter.cpp index c2e34f0..e7d7bd9 100644 --- a/src/presenters/Presenter.cpp +++ b/ucl/src/mvp/GuiPresenter.cpp @@ -14,21 +14,19 @@ * limitations under the License. */ -#include "gallery/presenters/Presenter.h" +#include "ucl/mvp/GuiPresenter.h" #include "common.h" -namespace gallery { namespace { namespace impl { +namespace ucl { namespace { namespace impl { - constexpr SmartEvent ACTIVATE_BY {"gallery,activate,by"}; - constexpr SmartEvent DEACTIVATE_BY {"gallery,deactivate,by"}; + constexpr SmartEvent ACTIVATE_BY {"ucl,activate,by"}; + constexpr SmartEvent DEACTIVATE_BY {"ucl,deactivate,by"}; }}} -namespace gallery { +namespace ucl { - using ucl::Window; - - Presenter::Presenter(IRefCountObj &rc) : + GuiPresenter::GuiPresenter(IRefCountObj &rc) : RefCountAware(&rc), m_hasBuildInSources(false), m_isChild(false), @@ -36,7 +34,7 @@ namespace gallery { { } - Presenter::~Presenter() + GuiPresenter::~GuiPresenter() { if (m_hasBuildInSources) { if (m_isChild) { @@ -49,7 +47,7 @@ namespace gallery { } } - Result Presenter::prepare(ElmWidget &widget, const int flags) + Result GuiPresenter::prepare(ElmWidget &widget, const int flags) { m_window = asShared(widget.getWindow()); if (!m_window) { @@ -70,21 +68,23 @@ namespace gallery { return RES_OK; } - Result Presenter::prepare(Presenter &parent, const int flags) + Result GuiPresenter::prepare(GuiPresenter &parent, const int flags) { - if (!parent.m_sink) { - LOG_RETURN(RES_FAIL, "parent.m_sink is NULL!"); - } + if (flags & PF_ADD_DEACTIVATOR_SOURCES) { - for (auto deactivator: parent.m_deactivators) { - if (m_deactivatorExceptions.find(deactivator) == - m_deactivatorExceptions.end()) { - m_deactivators.insert(deactivator); + if (!parent.m_sink) { + LOG_RETURN(RES_FAIL, "parent.m_sink is NULL!"); + } + + for (auto deactivator: parent.m_deactivators) { + if (m_deactivatorExceptions.find(deactivator) == + m_deactivatorExceptions.end()) { + m_deactivators.insert(deactivator); + } } - } - if (flags & PF_ADD_DEACTIVATOR_SOURCES) { addDeactivatorSource(*parent.m_sink); + m_parentSink = parent.m_sink; m_hasBuildInSources = true; } @@ -93,25 +93,24 @@ namespace gallery { } m_window = parent.m_window; - m_parentSink = parent.m_sink; m_isChild = true; m_isPrepared = true; return RES_OK; } - Window &Presenter::getWindow() + Window &GuiPresenter::getWindow() { UCL_ASSERT(isWindowReady(), "m_window is NULL!"); return *m_window; } - bool Presenter::isWindowReady() const + bool GuiPresenter::isWindowReady() const { return !!m_window; } - void Presenter::addDeactivatorException(const void *const deactivator) + void GuiPresenter::addDeactivatorException(const void *const deactivator) { const auto pair = m_deactivatorExceptions.insert(deactivator); if (pair.second) { @@ -119,86 +118,86 @@ namespace gallery { } } - void Presenter::setDeactivatorSink(const WidgetSRef &sink) + void GuiPresenter::setDeactivatorSink(const WidgetSRef &sink) { m_sink = sink; } - void Presenter::sendActivate(Widget &sender) + void GuiPresenter::sendActivate(Widget &sender) { sendDeactivator(sender, impl::ACTIVATE_BY, m_rc->getObjPtr()); } - void Presenter::sendDeactivate(Widget &sender) + void GuiPresenter::sendDeactivate(Widget &sender) { sendDeactivator(sender, impl::DEACTIVATE_BY, m_rc->getObjPtr()); } - void Presenter::broadcastActivate() + void GuiPresenter::broadcastActivate() { broadcastDeactivator(impl::ACTIVATE_BY, m_rc->getObjPtr()); } - void Presenter::broadcastDeactivate() + void GuiPresenter::broadcastDeactivate() { broadcastDeactivator(impl::DEACTIVATE_BY, m_rc->getObjPtr()); } - void Presenter::sendDeactivator(Widget &sender, + void GuiPresenter::sendDeactivator(Widget &sender, SmartEvent event, const void *deactivator) { sendDeactivatorInfo(sender, event, {deactivator, false}); } - void Presenter::broadcastDeactivator(const SmartEvent event, + void GuiPresenter::broadcastDeactivator(const SmartEvent event, const void *const deactivator) { sendDeactivatorInfo(*m_window, event, {deactivator, true}); } - void Presenter::sendDeactivatorInfo(Widget &sender, + void GuiPresenter::sendDeactivatorInfo(Widget &sender, const SmartEvent event, const DeactivatorInfo &info) { sender.callEvent(event, const_cast<DeactivatorInfo *>(&info)); } - bool Presenter::isActive() const + bool GuiPresenter::isActive() const { return isEmpty(m_deactivators); } - bool Presenter::isDeactivatedBy(const void *const deactivator) const + bool GuiPresenter::isDeactivatedBy(const void *const deactivator) const { return (m_deactivators.find(deactivator) != m_deactivators.end()); } - void Presenter::activateBy(const void *const deactivator) + void GuiPresenter::activateBy(const void *const deactivator) { activateByImpl({deactivator, false}); } - void Presenter::deactivateBy(const void *const deactivator) + void GuiPresenter::deactivateBy(const void *const deactivator) { deactivateByImpl({deactivator, false}); } - void Presenter::addDeactivatorSource(Widget &source) + void GuiPresenter::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))); + source.addEventHandler(impl::ACTIVATE_BY, WEAK_DELEGATE( + GuiPresenter::onActivateBySmart, asWeak(*this))); + source.addEventHandler(impl::DEACTIVATE_BY, WEAK_DELEGATE( + GuiPresenter::onDeactivateBySmart, asWeak(*this))); } - void Presenter::delDeactivatorSource(Widget &source) + void GuiPresenter::delDeactivatorSource(Widget &source) { - source.delEventHandler(impl::ACTIVATE_BY, - WEAK_DELEGATE(Presenter::onActivateBySmart, asWeak(*this))); - source.delEventHandler(impl::DEACTIVATE_BY, - WEAK_DELEGATE(Presenter::onDeactivateBySmart, asWeak(*this))); + source.delEventHandler(impl::ACTIVATE_BY, WEAK_DELEGATE( + GuiPresenter::onActivateBySmart, asWeak(*this))); + source.delEventHandler(impl::DEACTIVATE_BY, WEAK_DELEGATE( + GuiPresenter::onDeactivateBySmart, asWeak(*this))); } - void Presenter::activateByImpl(const DeactivatorInfo &info) + void GuiPresenter::activateByImpl(const DeactivatorInfo &info) { const auto count = m_deactivators.erase(info.deactivator); if (m_isPrepared && (count > 0)) { @@ -212,7 +211,7 @@ namespace gallery { } } - void Presenter::deactivateByImpl(const DeactivatorInfo &info) + void GuiPresenter::deactivateByImpl(const DeactivatorInfo &info) { if (m_deactivatorExceptions.find(info.deactivator) != m_deactivatorExceptions.end()) { @@ -230,29 +229,29 @@ namespace gallery { } } - void Presenter::onActivateBySmart(Widget &widget, void *eventInfo) + void GuiPresenter::onActivateBySmart(Widget &widget, void *eventInfo) { activateByImpl(*static_cast<DeactivatorInfo *>(eventInfo)); } - void Presenter::onDeactivateBySmart(Widget &widget, void *eventInfo) + void GuiPresenter::onDeactivateBySmart(Widget &widget, void *eventInfo) { deactivateByImpl(*static_cast<DeactivatorInfo *>(eventInfo)); } - void Presenter::onActivate() + void GuiPresenter::onActivate() { } - void Presenter::onDeactivate() + void GuiPresenter::onDeactivate() { } - void Presenter::onActivateBy(const DeactivatorInfo &info) + void GuiPresenter::onActivateBy(const DeactivatorInfo &info) { } - void Presenter::onDeactivateBy(const DeactivatorInfo &info) + void GuiPresenter::onDeactivateBy(const DeactivatorInfo &info) { } } diff --git a/ucl/src/mvp/common.h b/ucl/src/mvp/common.h new file mode 100644 index 0000000..2894a14 --- /dev/null +++ b/ucl/src/mvp/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_MVP_COMMON_H__ +#define __UCL_MVP_COMMON_H__ + +#include "../common.h" + +#endif // __UCL_MVP_COMMON_H__ |