#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);
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);
#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();
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!");
#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);
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;
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);
#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)>;
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!");
+++ /dev/null
-/*
- * 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__
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;
#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,
#include "ucl/gui/StyledWidget.h"
-#include "Presenter.h"
+#include "ucl/mvp/GuiPresenter.h"
#include "gallery/view/PageContent.h"
UCL_DECLARE_REF_ALIASES(SelectModePresenter);
- class SelectModePresenter final : public Presenter {
+ class SelectModePresenter final : public ucl::GuiPresenter {
public:
UCL_DECLARE_REF_ALIASES(IListener);
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;
const PageContentSRef &content, int flags);
virtual ~SelectModePresenter();
- ucl::Result prepare(Presenter &parent);
+ ucl::Result prepare(GuiPresenter &parent);
void doUpdate();
void onBottomBtnClick(ucl::Widget &widget, void *eventInfo);
Eina_Bool onRotary(Eext_Rotary_Event_Info *info);
- // Presenter //
+ // GuiPresenter //
virtual void onDeactivate() final override;
private:
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;
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
using ucl::ATSPI_ON_GESTURE;
AtspiHighlightHelperSRef AtspiHighlightHelper::newInstance(
- Presenter &parent, ElmWidget &rootWidget)
+ GuiPresenter &parent, ElmWidget &rootWidget)
{
auto result = makeShared<AtspiHighlightHelper>();
}
AtspiHighlightHelper::AtspiHighlightHelper(IRefCountObj &rc) :
- Presenter(rc)
+ GuiPresenter(rc)
{
}
{
}
- 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);
namespace gallery {
Dialog::Dialog(IRefCountObj &rc) :
- Presenter(rc),
+ GuiPresenter(rc),
m_isDismissed(false)
{
}
}
MoreOptionsPresenterSRef MoreOptionsPresenter::Builder::build(
- Presenter &parent) const
+ GuiPresenter &parent) const
{
if (isEmpty()) {
LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Builder is empty!");
MoreOptionsPresenter::MoreOptionsPresenter(IRefCountObj &rc,
const MoreOptionsCSRef &options) :
- Presenter(rc),
+ GuiPresenter(rc),
m_options(options),
m_timer(nullptr),
m_newOpenedState(false)
}
}
- 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) {
Page::Page(IRefCountObj &rc, const NaviframeSRef &navi,
const ExitRequestHandler &onExitRequest) :
- Presenter(rc),
+ GuiPresenter(rc),
m_navi(navi),
m_onExitRequest(onExitRequest)
{
+++ /dev/null
-/*
- * 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)
- {
- }
-}
// ProcessingPresenter //
ProcessingPresenter::ProcessingPresenter(IRefCountObj &rc) :
- Presenter(rc),
+ GuiPresenter(rc),
m_iconType(IconType::NONE),
m_timer(nullptr),
m_state(State::WAITING),
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!");
}
SelectModePresenterSRef SelectModePresenter::Builder::build(
- Presenter &parent) const
+ GuiPresenter &parent) const
{
if (!m_content) {
LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_content is NULL!");
SelectModePresenter::SelectModePresenter(IRefCountObj &rc,
const PageContentSRef &content, const int flags) :
- Presenter(rc),
+ GuiPresenter(rc),
m_content(content),
m_flags(flags),
m_totalCount(0),
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);
--- /dev/null
+/*
+ * 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__
--- /dev/null
+/*
+ * 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__
--- /dev/null
+/*
+ * 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)
+ {
+ }
+}
--- /dev/null
+/*
+ * 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__