TizenRefApp-8716 [Gallery] Rename Presenter to GuiPresenter and move it into UCL 27/135027/4
authorIgor Nazarov <i.nazarov@samsung.com>
Tue, 20 Jun 2017 16:45:04 +0000 (19:45 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Thu, 22 Jun 2017 07:58:06 +0000 (10:58 +0300)
Change-Id: I643d52b396092993912931b38397def1e196b7eb

23 files changed:
inc/gallery/presenters/AtspiHighlightHelper.h
inc/gallery/presenters/Dialog.h
inc/gallery/presenters/Dialog.hpp
inc/gallery/presenters/MoreOptionsPresenter.h
inc/gallery/presenters/Page.h
inc/gallery/presenters/Page.hpp
inc/gallery/presenters/Presenter.h [deleted file]
inc/gallery/presenters/PreviewPage.h
inc/gallery/presenters/ProcessingPresenter.h
inc/gallery/presenters/SelectModePresenter.h
inc/gallery/presenters/ThumbnailPage.h
project_def.prop
src/presenters/AtspiHighlightHelper.cpp
src/presenters/Dialog.cpp
src/presenters/MoreOptionsPresenter.cpp
src/presenters/Page.cpp
src/presenters/Presenter.cpp [deleted file]
src/presenters/ProcessingPresenter.cpp
src/presenters/SelectModePresenter.cpp
ucl/inc/ucl/mvp/GuiPresenter.h [new file with mode: 0644]
ucl/inc/ucl/mvp/types.h [new file with mode: 0644]
ucl/src/mvp/GuiPresenter.cpp [new file with mode: 0644]
ucl/src/mvp/common.h [new file with mode: 0644]

index 4175d571a8830f1124bd4ab0868233a0692eea75..650860ec1130be205bd51c4c2826f110f86b93a2 100644 (file)
 #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);
index 9aa62466e0718e6acfef8c08519b9625ded59888..f820c07c6e30a52fdedf0182fea8d75034681f34 100644 (file)
 
 #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();
index 35487b9307aef4b38c0a44b17f62b6385d066be1..ed2c8f76e2a01c508ff284b3c23263c58b7657fa 100644 (file)
@@ -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!");
index 88f45ca31cfaa273cd96c377c3861f035f4d32f5..72c605a84ec7d4c02d423abb3a3c57ccf754f055 100644 (file)
 
 #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);
index 201ccc736d52e05e5dc8cd010a7e0e8e9932b336..d8132dca436138a005609cb04b1065ae6488f709 100644 (file)
 
 #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)>;
 
index 7a8fdbd8ff9adaafefcd89390c510e377d009cf6..426445a615af261e56b8cf16a72d9835a67ec3ed 100644 (file)
@@ -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/Presenter.h b/inc/gallery/presenters/Presenter.h
deleted file mode 100644 (file)
index ee39f0e..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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 __GALLERY_PRESENTERS_PRESENTER_H__
-#define __GALLERY_PRESENTERS_PRESENTER_H__
-
-#include <unordered_set>
-
-#include "ucl/gui/Window.h"
-
-#include "types.h"
-
-namespace gallery {
-
-       UCL_DECLARE_REF_ALIASES(Presenter);
-
-       class Presenter : public ucl::RefCountAware {
-       public:
-               struct DeactivatorInfo {
-                       const void *deactivator;
-                       bool isBroadcast;
-               };
-
-       public:
-               bool isActive() const;
-               bool isDeactivatedBy(const void *deactivator) const;
-
-               void activateBy(const void *deactivator);
-               void deactivateBy(const void *deactivator);
-
-               void addDeactivatorSource(ucl::Widget &source);
-               void delDeactivatorSource(ucl::Widget &source);
-
-       protected:
-               enum {
-                       PF_ADD_DEACTIVATOR_SOURCES = 1,
-                       PF_ADD_SELF_EXCEPT = 2,
-
-                       PF_PASSIVE = 0,
-                       PF_DEACTIVATOR = (PF_ADD_DEACTIVATOR_SOURCES | PF_ADD_SELF_EXCEPT),
-                       PF_DEFAULT = PF_ADD_DEACTIVATOR_SOURCES
-               };
-
-       protected:
-               Presenter(ucl::IRefCountObj &rc);
-               virtual ~Presenter();
-
-               ucl::Result prepare(ucl::ElmWidget &widget, int flags = PF_DEFAULT);
-               ucl::Result prepare(Presenter &parent, int flags = PF_DEFAULT);
-
-               ucl::Window &getWindow();
-               bool isWindowReady() const;
-
-               void addDeactivatorException(const void *deactivator);
-               void setDeactivatorSink(const ucl::WidgetSRef &sink);
-
-               void sendActivate(ucl::Widget &sender);
-               void sendDeactivate(ucl::Widget &sender);
-
-               void broadcastActivate();
-               void broadcastDeactivate();
-
-               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, const void *deactivator);
-               void broadcastDeactivator(ucl::SmartEvent event,
-                               const 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<const void *> m_deactivatorExceptions;
-               std::unordered_set<const void *> m_deactivators;
-               ucl::WindowSRef m_window;
-               ucl::WidgetSRef m_sink;
-               ucl::WidgetWRef m_parentSink;
-               bool m_hasBuildInSources;
-               bool m_isChild;
-               bool m_isPrepared;
-       };
-}
-
-#endif // __GALLERY_PRESENTERS_PRESENTER_H__
index 38d97981d864e9ce81352629df4ddc616aa15e13..5773ee49d13900e6b1291fd67891d05fd50e3d3a 100644 (file)
@@ -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;
index 94e1e80788362cbb282945b3e7100ae47ae2000d..9b547675bcb9b043a50c7c996d8acdc03829c1c4 100644 (file)
 #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,
index 3cf1fa94c1ed1e68630f2c201d26c1fdc8fd8bfe..75c2e1485d4da149e15a39c18e68a1a62fc18417 100644 (file)
@@ -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:
index 9ad821a1169d30868c216a84dcb9b8e4ec9a242e..46beeed228c51352a993ae565ab3d5c91c83e3bf 100644 (file)
@@ -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;
index 0834ff8879734234cba408dd92020008766f5873..b90d2dac221f1952074d5d4900d15e6192a18042 100644 (file)
@@ -9,7 +9,7 @@ type = app
 profile = wearable-4.0\r
 \r
 # C/CPP Sources\r
-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 \r
+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 \r
 \r
 # EDC Sources\r
 USER_EDCS =  \r
index d6f05c9684f04f533c888ae8ac26d8023504b4d4..d960cb0f3c5dd55d964c21e08e8f0b68eb736cd1 100644 (file)
@@ -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);
 
index 3f16630090e571d12786bba4fb95643438b7e697..826b9fabd01cfd7914c801762cab349fe001e087 100644 (file)
@@ -21,7 +21,7 @@
 namespace gallery {
 
        Dialog::Dialog(IRefCountObj &rc) :
-               Presenter(rc),
+               GuiPresenter(rc),
                m_isDismissed(false)
        {
        }
index 6a20b2dbc0d46af76c2ddf6ac10ee9005dd4ae06..f444293690e5e4277ebacc89ee6197e301b161aa 100644 (file)
@@ -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) {
index 9ccf2ed1fd181c97d6c45870503bae1d8f781595..ae3f71e1d5b3de9a0f022efbf8ff5c0148e50af2 100644 (file)
@@ -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/Presenter.cpp b/src/presenters/Presenter.cpp
deleted file mode 100644 (file)
index c2e34f0..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * 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 "gallery/presenters/Presenter.h"
-
-#include "common.h"
-
-namespace gallery { namespace { namespace impl {
-
-       constexpr SmartEvent ACTIVATE_BY {"gallery,activate,by"};
-       constexpr SmartEvent DEACTIVATE_BY {"gallery,deactivate,by"};
-}}}
-
-namespace gallery {
-
-       using ucl::Window;
-
-       Presenter::Presenter(IRefCountObj &rc) :
-               RefCountAware(&rc),
-               m_hasBuildInSources(false),
-               m_isChild(false),
-               m_isPrepared(false)
-       {
-       }
-
-       Presenter::~Presenter()
-       {
-               if (m_hasBuildInSources) {
-                       if (m_isChild) {
-                               if (const auto parentSink = m_parentSink.lock()) {
-                                       delDeactivatorSource(*parentSink);
-                               }
-                       } else if (m_window) {
-                               delDeactivatorSource(*m_window);
-                       }
-               }
-       }
-
-       Result Presenter::prepare(ElmWidget &widget, const int flags)
-       {
-               m_window = asShared(widget.getWindow());
-               if (!m_window) {
-                       LOG_RETURN(RES_FAIL, "m_window is NULL!");
-               }
-
-               if (flags & PF_ADD_DEACTIVATOR_SOURCES) {
-                       addDeactivatorSource(*m_window);
-                       m_hasBuildInSources = true;
-               }
-
-               if (flags & PF_ADD_SELF_EXCEPT) {
-                       addDeactivatorException(m_rc->getObjPtr());
-               }
-
-               m_isPrepared = true;
-
-               return RES_OK;
-       }
-
-       Result Presenter::prepare(Presenter &parent, const int flags)
-       {
-               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_hasBuildInSources = true;
-               }
-
-               if (flags & PF_ADD_SELF_EXCEPT) {
-                       addDeactivatorException(m_rc->getObjPtr());
-               }
-
-               m_window = parent.m_window;
-               m_parentSink = parent.m_sink;
-               m_isChild = true;
-               m_isPrepared = true;
-
-               return RES_OK;
-       }
-
-       Window &Presenter::getWindow()
-       {
-               UCL_ASSERT(isWindowReady(), "m_window is NULL!");
-               return *m_window;
-       }
-
-       bool Presenter::isWindowReady() const
-       {
-               return !!m_window;
-       }
-
-       void Presenter::addDeactivatorException(const void *const deactivator)
-       {
-               const auto pair = m_deactivatorExceptions.insert(deactivator);
-               if (pair.second) {
-                       activateBy(deactivator);
-               }
-       }
-
-       void Presenter::setDeactivatorSink(const WidgetSRef &sink)
-       {
-               m_sink = sink;
-       }
-
-       void Presenter::sendActivate(Widget &sender)
-       {
-               sendDeactivator(sender, impl::ACTIVATE_BY, m_rc->getObjPtr());
-       }
-
-       void Presenter::sendDeactivate(Widget &sender)
-       {
-               sendDeactivator(sender, impl::DEACTIVATE_BY, m_rc->getObjPtr());
-       }
-
-       void Presenter::broadcastActivate()
-       {
-               broadcastDeactivator(impl::ACTIVATE_BY, m_rc->getObjPtr());
-       }
-
-       void Presenter::broadcastDeactivate()
-       {
-               broadcastDeactivator(impl::DEACTIVATE_BY, m_rc->getObjPtr());
-       }
-
-       void Presenter::sendDeactivator(Widget &sender,
-                       SmartEvent event, const void *deactivator)
-       {
-               sendDeactivatorInfo(sender, event, {deactivator, false});
-       }
-
-       void Presenter::broadcastDeactivator(const SmartEvent event,
-                       const void *const deactivator)
-       {
-               sendDeactivatorInfo(*m_window, event, {deactivator, true});
-       }
-
-       void Presenter::sendDeactivatorInfo(Widget &sender,
-                       const SmartEvent event, const DeactivatorInfo &info)
-       {
-               sender.callEvent(event, const_cast<DeactivatorInfo *>(&info));
-       }
-
-       bool Presenter::isActive() const
-       {
-               return isEmpty(m_deactivators);
-       }
-
-       bool Presenter::isDeactivatedBy(const void *const deactivator) const
-       {
-               return (m_deactivators.find(deactivator) != m_deactivators.end());
-       }
-
-       void Presenter::activateBy(const void *const deactivator)
-       {
-               activateByImpl({deactivator, false});
-       }
-
-       void Presenter::deactivateBy(const void *const deactivator)
-       {
-               deactivateByImpl({deactivator, false});
-       }
-
-       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::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)));
-       }
-
-       void Presenter::activateByImpl(const DeactivatorInfo &info)
-       {
-               const auto count = m_deactivators.erase(info.deactivator);
-               if (m_isPrepared && (count > 0)) {
-                       if (m_sink) {
-                               sendDeactivatorInfo(*m_sink, impl::ACTIVATE_BY, info);
-                       }
-                       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) {
-                       if (m_sink) {
-                               sendDeactivatorInfo(*m_sink, impl::DEACTIVATE_BY, info);
-                       }
-                       onDeactivateBy(info);
-                       if (m_deactivators.size() == 1) {
-                               onDeactivate();
-                       }
-               }
-       }
-
-       void Presenter::onActivateBySmart(Widget &widget, void *eventInfo)
-       {
-               activateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
-       }
-
-       void Presenter::onDeactivateBySmart(Widget &widget, void *eventInfo)
-       {
-               deactivateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
-       }
-
-       void Presenter::onActivate()
-       {
-       }
-
-       void Presenter::onDeactivate()
-       {
-       }
-
-       void Presenter::onActivateBy(const DeactivatorInfo &info)
-       {
-       }
-
-       void Presenter::onDeactivateBy(const DeactivatorInfo &info)
-       {
-       }
-}
index 3d1ad21ff927389802051163cf28374e91df6ef1..7238837d953f725661c204886707dc665839470a 100644 (file)
@@ -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!");
index b9b333cfedc4b735d005444405a88324a1272e49..a63c624c4f7d51faf8eeb189639f944a1f4e76b8 100644 (file)
@@ -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/ucl/inc/ucl/mvp/GuiPresenter.h b/ucl/inc/ucl/mvp/GuiPresenter.h
new file mode 100644 (file)
index 0000000..f81bcac
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * 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_GUI_PRESENTER_H__
+#define __UCL_MVP_GUI_PRESENTER_H__
+
+#include <unordered_set>
+
+#include "ucl/gui/Window.h"
+
+#include "types.h"
+
+namespace ucl {
+
+       UCL_DECLARE_REF_ALIASES(GuiPresenter);
+
+       class GuiPresenter : public RefCountAware {
+       public:
+               struct DeactivatorInfo {
+                       const void *deactivator;
+                       bool isBroadcast;
+               };
+
+       public:
+               bool isActive() const;
+               bool isDeactivatedBy(const void *deactivator) const;
+
+               void activateBy(const void *deactivator);
+               void deactivateBy(const void *deactivator);
+
+               void addDeactivatorSource(Widget &source);
+               void delDeactivatorSource(Widget &source);
+
+       protected:
+               enum {
+                       PF_ADD_DEACTIVATOR_SOURCES = 1,
+                       PF_ADD_SELF_EXCEPT = 2,
+
+                       PF_PASSIVE = 0,
+                       PF_DEACTIVATOR = (PF_ADD_DEACTIVATOR_SOURCES | PF_ADD_SELF_EXCEPT),
+                       PF_DEFAULT = PF_ADD_DEACTIVATOR_SOURCES
+               };
+
+       protected:
+               GuiPresenter(IRefCountObj &rc);
+               virtual ~GuiPresenter();
+
+               Result prepare(ElmWidget &widget, int flags = PF_DEFAULT);
+               Result prepare(GuiPresenter &parent, int flags = PF_DEFAULT);
+
+               Window &getWindow();
+               bool isWindowReady() const;
+
+               void addDeactivatorException(const void *deactivator);
+               void setDeactivatorSink(const WidgetSRef &sink);
+
+               void sendActivate(Widget &sender);
+               void sendDeactivate(Widget &sender);
+
+               void broadcastActivate();
+               void broadcastDeactivate();
+
+               virtual void onActivate();
+               virtual void onDeactivate();
+               virtual void onActivateBy(const DeactivatorInfo &info);
+               virtual void onDeactivateBy(const DeactivatorInfo &info);
+
+       private:
+               void sendDeactivator(Widget &sender,
+                               SmartEvent event, const void *deactivator);
+               void broadcastDeactivator(SmartEvent event,
+                               const void *deactivator);
+
+               void sendDeactivatorInfo(Widget &sender, SmartEvent event,
+                               const DeactivatorInfo &info);
+
+               void activateByImpl(const DeactivatorInfo &info);
+               void deactivateByImpl(const DeactivatorInfo &info);
+
+               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;
+               WindowSRef m_window;
+               WidgetSRef m_sink;
+               WidgetWRef m_parentSink;
+               bool m_hasBuildInSources;
+               bool m_isChild;
+               bool m_isPrepared;
+       };
+}
+
+#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 (file)
index 0000000..6c263e2
--- /dev/null
@@ -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/ucl/src/mvp/GuiPresenter.cpp b/ucl/src/mvp/GuiPresenter.cpp
new file mode 100644 (file)
index 0000000..e7d7bd9
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * 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/mvp/GuiPresenter.h"
+
+#include "common.h"
+
+namespace ucl { namespace { namespace impl {
+
+       constexpr SmartEvent ACTIVATE_BY {"ucl,activate,by"};
+       constexpr SmartEvent DEACTIVATE_BY {"ucl,deactivate,by"};
+}}}
+
+namespace ucl {
+
+       GuiPresenter::GuiPresenter(IRefCountObj &rc) :
+               RefCountAware(&rc),
+               m_hasBuildInSources(false),
+               m_isChild(false),
+               m_isPrepared(false)
+       {
+       }
+
+       GuiPresenter::~GuiPresenter()
+       {
+               if (m_hasBuildInSources) {
+                       if (m_isChild) {
+                               if (const auto parentSink = m_parentSink.lock()) {
+                                       delDeactivatorSource(*parentSink);
+                               }
+                       } else if (m_window) {
+                               delDeactivatorSource(*m_window);
+                       }
+               }
+       }
+
+       Result GuiPresenter::prepare(ElmWidget &widget, const int flags)
+       {
+               m_window = asShared(widget.getWindow());
+               if (!m_window) {
+                       LOG_RETURN(RES_FAIL, "m_window is NULL!");
+               }
+
+               if (flags & PF_ADD_DEACTIVATOR_SOURCES) {
+                       addDeactivatorSource(*m_window);
+                       m_hasBuildInSources = true;
+               }
+
+               if (flags & PF_ADD_SELF_EXCEPT) {
+                       addDeactivatorException(m_rc->getObjPtr());
+               }
+
+               m_isPrepared = true;
+
+               return RES_OK;
+       }
+
+       Result GuiPresenter::prepare(GuiPresenter &parent, const int flags)
+       {
+               if (flags & PF_ADD_DEACTIVATOR_SOURCES) {
+
+                       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);
+                               }
+                       }
+
+                       addDeactivatorSource(*parent.m_sink);
+                       m_parentSink = parent.m_sink;
+                       m_hasBuildInSources = true;
+               }
+
+               if (flags & PF_ADD_SELF_EXCEPT) {
+                       addDeactivatorException(m_rc->getObjPtr());
+               }
+
+               m_window = parent.m_window;
+               m_isChild = true;
+               m_isPrepared = true;
+
+               return RES_OK;
+       }
+
+       Window &GuiPresenter::getWindow()
+       {
+               UCL_ASSERT(isWindowReady(), "m_window is NULL!");
+               return *m_window;
+       }
+
+       bool GuiPresenter::isWindowReady() const
+       {
+               return !!m_window;
+       }
+
+       void GuiPresenter::addDeactivatorException(const void *const deactivator)
+       {
+               const auto pair = m_deactivatorExceptions.insert(deactivator);
+               if (pair.second) {
+                       activateBy(deactivator);
+               }
+       }
+
+       void GuiPresenter::setDeactivatorSink(const WidgetSRef &sink)
+       {
+               m_sink = sink;
+       }
+
+       void GuiPresenter::sendActivate(Widget &sender)
+       {
+               sendDeactivator(sender, impl::ACTIVATE_BY, m_rc->getObjPtr());
+       }
+
+       void GuiPresenter::sendDeactivate(Widget &sender)
+       {
+               sendDeactivator(sender, impl::DEACTIVATE_BY, m_rc->getObjPtr());
+       }
+
+       void GuiPresenter::broadcastActivate()
+       {
+               broadcastDeactivator(impl::ACTIVATE_BY, m_rc->getObjPtr());
+       }
+
+       void GuiPresenter::broadcastDeactivate()
+       {
+               broadcastDeactivator(impl::DEACTIVATE_BY, m_rc->getObjPtr());
+       }
+
+       void GuiPresenter::sendDeactivator(Widget &sender,
+                       SmartEvent event, const void *deactivator)
+       {
+               sendDeactivatorInfo(sender, event, {deactivator, false});
+       }
+
+       void GuiPresenter::broadcastDeactivator(const SmartEvent event,
+                       const void *const deactivator)
+       {
+               sendDeactivatorInfo(*m_window, event, {deactivator, true});
+       }
+
+       void GuiPresenter::sendDeactivatorInfo(Widget &sender,
+                       const SmartEvent event, const DeactivatorInfo &info)
+       {
+               sender.callEvent(event, const_cast<DeactivatorInfo *>(&info));
+       }
+
+       bool GuiPresenter::isActive() const
+       {
+               return isEmpty(m_deactivators);
+       }
+
+       bool GuiPresenter::isDeactivatedBy(const void *const deactivator) const
+       {
+               return (m_deactivators.find(deactivator) != m_deactivators.end());
+       }
+
+       void GuiPresenter::activateBy(const void *const deactivator)
+       {
+               activateByImpl({deactivator, false});
+       }
+
+       void GuiPresenter::deactivateBy(const void *const deactivator)
+       {
+               deactivateByImpl({deactivator, false});
+       }
+
+       void GuiPresenter::addDeactivatorSource(Widget &source)
+       {
+               source.addEventHandler(impl::ACTIVATE_BY, WEAK_DELEGATE(
+                               GuiPresenter::onActivateBySmart, asWeak(*this)));
+               source.addEventHandler(impl::DEACTIVATE_BY, WEAK_DELEGATE(
+                               GuiPresenter::onDeactivateBySmart, asWeak(*this)));
+       }
+
+       void GuiPresenter::delDeactivatorSource(Widget &source)
+       {
+               source.delEventHandler(impl::ACTIVATE_BY, WEAK_DELEGATE(
+                               GuiPresenter::onActivateBySmart, asWeak(*this)));
+               source.delEventHandler(impl::DEACTIVATE_BY, WEAK_DELEGATE(
+                               GuiPresenter::onDeactivateBySmart, asWeak(*this)));
+       }
+
+       void GuiPresenter::activateByImpl(const DeactivatorInfo &info)
+       {
+               const auto count = m_deactivators.erase(info.deactivator);
+               if (m_isPrepared && (count > 0)) {
+                       if (m_sink) {
+                               sendDeactivatorInfo(*m_sink, impl::ACTIVATE_BY, info);
+                       }
+                       onActivateBy(info);
+                       if (m_deactivators.size() == 0) {
+                               onActivate();
+                       }
+               }
+       }
+
+       void GuiPresenter::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) {
+                       if (m_sink) {
+                               sendDeactivatorInfo(*m_sink, impl::DEACTIVATE_BY, info);
+                       }
+                       onDeactivateBy(info);
+                       if (m_deactivators.size() == 1) {
+                               onDeactivate();
+                       }
+               }
+       }
+
+       void GuiPresenter::onActivateBySmart(Widget &widget, void *eventInfo)
+       {
+               activateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
+       }
+
+       void GuiPresenter::onDeactivateBySmart(Widget &widget, void *eventInfo)
+       {
+               deactivateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
+       }
+
+       void GuiPresenter::onActivate()
+       {
+       }
+
+       void GuiPresenter::onDeactivate()
+       {
+       }
+
+       void GuiPresenter::onActivateBy(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 (file)
index 0000000..2894a14
--- /dev/null
@@ -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__