#include "ucl/gui/StyledWidget.h"
#include "ucl/gui/Layout.h"
-#include "types.h"
+#include "Presenter.h"
namespace gallery {
- class AlertDialog final : public ucl::RefCountAware,
+ class AlertDialog final : public Presenter,
public ucl::IDisposable {
public:
enum class Type {
Builder &setTitle(ucl::TString title);
Builder &setText(ucl::TString text);
Builder &setHandler(const EventHandler &handler);
- AlertDialogWRef build(ucl::Widget &parent) const;
+ AlertDialogWRef build(ucl::ElmWidget &parent) const;
private:
Type m_type;
ucl::TString m_title;
const EventHandler &handler);
virtual ~AlertDialog();
- ucl::Result prepare(ucl::Widget &parent, Type type);
- ucl::Result createPopup(ucl::Widget &parent, ucl::ElmStyle style);
+ ucl::Result prepare(ucl::ElmWidget &parent, Type type);
+ ucl::Result createPopup(ucl::ElmWidget &parent, ucl::ElmStyle style);
ucl::Result createLayout(ucl::LayoutTheme theme);
ucl::Result createButton(Event event, ucl::EdjePart part,
ucl::ElmStyle btnStyle, ucl::LayoutTheme iconTheme,
void onPopupDismissed(ucl::Widget &widget, void *eventInfo);
void onPopupHWBackKey(Evas_Object *obj, void *eventInfo);
- void onPopupDel(ucl::Widget &widget, void *eventInfo);
void onBtnClick(ucl::Widget &widget, void *eventInfo);
#ifndef __GALLERY_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
#define __GALLERY_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
-#include "ucl/gui/Widget.h"
#include "ucl/misc/HashMap.h"
-#include "types.h"
+#include "Presenter.h"
namespace gallery {
- class MoreOptionsPresenter final : public ucl::RefCountAware {
+ class MoreOptionsPresenter final : public Presenter {
public:
class Builder {
public:
bool isEmpty() const;
Builder &clear();
Builder &addOption(MoreOption option);
- MoreOptionsPresenterSRef build(ucl::Widget &parent) const;
+ MoreOptionsPresenterSRef build(ucl::ElmWidget &parent) const;
private:
ucl::SharedRef<MoreOptions> m_options;
};
const MoreOptionsCSRef &options);
virtual ~MoreOptionsPresenter();
- ucl::Result prepare(ucl::Widget &parent);
+ ucl::Result prepare(ucl::ElmWidget &parent);
ucl::Result addItem(const MoreOption &option);
void onOpened(ucl::Widget &widget, void *eventInfo);
private:
const MoreOptionsCSRef m_options;
ucl::HashMap<void *, const MoreOption *> m_map;
- ucl::WidgetSRef m_widget;
+ ucl::ElmWidgetSRef m_widget;
IMoreOptionsListenerWRef m_listener;
};
}
#include "ucl/gui/Naviframe.h"
-#include "types.h"
+#include "Presenter.h"
namespace gallery {
- class Page : public ucl::RefCountAware {
+ class Page : public Presenter {
public:
using ExitRequestHandler = ucl::Delegate<void(Page &page)>;
public:
ucl::Naviframe &getNaviframe();
- bool isActive() const;
-
bool isAtTop() const;
bool isAtBottom() const;
void requestExit();
- virtual void onActivate();
- virtual void onDeactivate();
virtual void onBackKey();
private:
void dispatchTopPageChanged();
- void activate();
- void deactivate();
void updateActiveState();
void onTransitionStarted(ucl::Widget &widget, void *eventInfo);
const ucl::NaviframeSRef m_navi;
const ExitRequestHandler m_onExitRequest;
ucl::NaviItem m_item;
- bool m_isActive;
};
// Non-member functions //
return *m_navi;
}
- inline bool Page::isActive() const
- {
- return m_isActive;
- }
-
inline bool Page::isAtTop() const
{
return (m_navi->getTopItem() == m_item);
--- /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/ElmWidget.h"
+
+#include "types.h"
+
+namespace gallery {
+
+ class Presenter : public ucl::RefCountAware {
+ public:
+ struct DeactivatorInfo {
+ void *deactivator;
+ bool isBroadcast;
+ };
+
+ public:
+ bool isActive() const;
+ bool isDeactivatedBy(void *deactivator) const;
+
+ void activateBy(void *deactivator);
+ void deactivateBy(void *deactivator);
+
+ protected:
+ Presenter(ucl::RefCountObjBase &rc);
+ virtual ~Presenter();
+
+ ucl::Result prepare(ucl::ElmWidget &widget);
+
+ void addDeactivatorSource(ucl::Widget &source);
+ void addDeactivatorException(void *deactivator);
+
+ void sendActivateBy(ucl::Widget &sender, void *deactivator);
+ void sendDeactivateBy(ucl::Widget &sender, void *deactivator);
+
+ void broadcastActivateBy(void *deactivator);
+ void broadcastDeactivateBy(void *deactivator);
+
+ virtual void onActivate();
+ virtual void onDeactivate();
+ virtual void onActivateBy(const DeactivatorInfo &info);
+ virtual void onDeactivateBy(const DeactivatorInfo &info);
+
+ private:
+ void sendDeactivator(ucl::Widget &sender,
+ ucl::SmartEvent event, void *deactivator);
+ void broadcastDeactivator(ucl::SmartEvent event, void *deactivator);
+
+ void sendDeactivatorInfo(ucl::Widget &sender, ucl::SmartEvent event,
+ const DeactivatorInfo &info);
+
+ void activateByImpl(const DeactivatorInfo &info);
+ void deactivateByImpl(const DeactivatorInfo &info);
+
+ void onActivateBySmart(ucl::Widget &widget, void *eventInfo);
+ void onDeactivateBySmart(ucl::Widget &widget, void *eventInfo);
+
+ private:
+ std::unordered_set<void *> m_deactivatorExceptions;
+ std::unordered_set<void *> m_deactivators;
+ ucl::WidgetWRef m_topWidget;
+ bool m_isPrepared;
+ };
+}
+
+#endif // __GALLERY_PRESENTERS_PRESENTER_H__
Builder &setCompleteText(ucl::TString text);
Builder &setIconType(IconType value);
Builder &setForceProgress(bool value);
- ProcessingPresenterSRef build(ucl::Widget &parent) const;
+ ProcessingPresenterSRef build(ucl::ElmWidget &parent) const;
private:
ucl::TString m_processingText;
ucl::TString m_completeText;
ProcessingPresenter(ucl::RefCountObjBase &rc, IconType iconType);
virtual ~ProcessingPresenter();
- ucl::Result prepare(ucl::Widget &parent,
+ ucl::Result prepare(ucl::ElmWidget &parent,
const ucl::TString &processingText,
const ucl::TString &completeText,
bool forceProgress);
- ucl::Result createWidget(ucl::Widget &parent,
+ ucl::Result createWidget(ucl::ElmWidget &parent,
const ucl::TString &processingText);
ucl::Result createProgress();
ucl::Result createPopup(const ucl::TString &completeText);
#include "ucl/gui/StyledWidget.h"
-#include "types.h"
+#include "Presenter.h"
namespace gallery {
- class SelectModePresenter final : public ucl::RefCountAware {
+ class SelectModePresenter final : public Presenter {
public:
enum {
FLAG_NO_BOTTOM_BUTTON = 1,
void setVisible(bool value);
bool isVisible() const;
- void setActive(bool value);
- bool isActive() const;
-
void setBottomButtonText(const ucl::TString &value);
void update(int selectCount, int totalCount = -1);
void showPopup();
void movePopup();
- void dismissPopup(bool force = false);
+ void dismissPopup();
+ void deletePopup();
void dispatchEvent(Event event);
void onBottomBtnClick(ucl::Widget &widget, void *eventInfo);
Eina_Bool onRotary(Eext_Rotary_Event_Info *info);
+ // Presenter //
+ virtual void onDeactivate() final override;
+
private:
const PageContentSRef m_content;
const int m_flags;
ucl::StyledWidgetSRef m_selectButton;
ucl::StyledWidgetSRef m_bottomButton;
- ucl::StyledWidgetWRef m_popup;
+ ucl::StyledWidgetSRef m_popup;
ISelectModeListenerWRef m_listener;
int m_totalCount;
int m_selectCount;
bool m_isVisible;
- bool m_isActive;
+ bool m_isPopupDismissed;
};
}
using MoreOptions = std::list<MoreOption>;
+ UCL_DECLARE_REF_ALIASES(Presenter);
+
UCL_DECLARE_REF_ALIASES(IMoreOptionsListener);
UCL_DECLARE_REF_ALIASES(MoreOptionsPresenter);
Builder &setType(Type value);
Builder &setListener(IImageGridListener *value);
Builder &setSelectModeStartup(bool value);
- ImageGridSRef build(Widget &parent) const;
+ ImageGridSRef build(ElmWidget &parent) const;
private:
Type m_type;
IImageGridListener *m_listener;
public:
Builder();
Builder &setImageSize(int w, int h);
- ImageViewerSRef build(ucl::Widget &parent) const;
+ ImageViewerSRef build(ucl::ElmWidget &parent) const;
private:
int m_imageW;
int m_imageH;
public:
Builder();
Builder &setFlags(int flags);
- PageContentSRef build(ucl::Widget &parent) const;
+ PageContentSRef build(ucl::ElmWidget &parent) const;
private:
int m_flags;
};
class Naviframe;
}
-namespace gallery {
+namespace gallery { namespace util {
ucl::Result createCircleSurface(ucl::Naviframe &navi);
Eext_Circle_Surface *getCircleSurface(const ucl::ElmWidget &widget);
+}}
+
+namespace gallery {
void addRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data);
void delRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data);
return *this;
}
- AlertDialogWRef AlertDialog::Builder::build(Widget &parent) const
+ AlertDialogWRef AlertDialog::Builder::build(ElmWidget &parent) const
{
if (!m_handler) {
LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_handler is NULL");
AlertDialog::AlertDialog(RefCountObjBase &rc,
const EventHandler &handler) :
- RefCountAware(&rc),
+ Presenter(rc),
m_handler(handler),
m_isDismissed(false)
{
{
}
- Result AlertDialog::prepare(Widget &parent, const Type type)
+ Result AlertDialog::prepare(ElmWidget &parent, const Type type)
{
+ FAIL_RETURN(Presenter::prepare(parent),
+ "Presenter::prepare() failed!");
+
FAIL_RETURN(createPopup(parent, impl::POPUP_STYLE),
"createPopup() failed!");
impl::RIGHT_POPUP_BTN_STYLE, getImageTheme(ICON_POPUP_OK)),
"createButton() failed!");
- m_popup->addEventHandler(WidgetEvent::DEL, WEAK_DELEGATE(
- AlertDialog::onPopupDel, asWeak(*this)));
- m_popup->setIsOwner(false);
m_rc->ref();
- return RES_OK;
- }
+ addDeactivatorException(this);
+ broadcastDeactivateBy(this);
- void AlertDialog::onPopupDel(Widget &widget, void *eventInfo)
- {
- eext_object_event_callback_del(widget, EEXT_CALLBACK_BACK,
- CALLBACK_A(AlertDialog::onPopupHWBackKey));
- m_rc->unref();
+ return RES_OK;
}
- Result AlertDialog::createPopup(Widget &parent, const ElmStyle style)
+ Result AlertDialog::createPopup(ElmWidget &parent, const ElmStyle style)
{
Evas_Object *const popupEo = elm_popup_add(parent);
if (!popupEo) {
{
if (m_popup && !m_isDismissed) {
m_isDismissed = true;
+ deactivateBy(m_popup.get());
elm_popup_dismiss(*m_popup);
}
}
void AlertDialog::dispose()
{
if (m_popup) {
- m_popup->markForDeletion();
+ eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
+ CALLBACK_A(AlertDialog::onPopupHWBackKey));
+
m_popup.reset();
+
+ deactivateBy(m_popup.get());
+ broadcastActivateBy(this);
+ m_rc->unref();
}
}
void AlertDialog::onPopupHWBackKey(Evas_Object *obj, void *eventInfo)
{
- if (!m_isDismissed) {
+ if (isActive()) {
handleEvent(EVENT_BACK);
}
}
void AlertDialog::onBtnClick(Widget &widget, void *eventInfo)
{
- if (!m_isDismissed) {
+ if (isActive()) {
handleEvent(impl::getEvent(widget));
}
}
m_win->getConformant().setContent(*m_navi);
- FAIL_RETURN(createCircleSurface(*m_navi),
- "createCircleSurface() failed!");
+ FAIL_RETURN(util::createCircleSurface(*m_navi),
+ "util::createCircleSurface() failed!");
m_sysEventProvider.addEventHandler(
DELEGATE(Instance::onSysEvent, this));
}
MoreOptionsPresenterSRef MoreOptionsPresenter::Builder::build(
- Widget &parent) const
+ ElmWidget &parent) const
{
if (isEmpty()) {
LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Builder is empty!");
MoreOptionsPresenter::MoreOptionsPresenter(RefCountObjBase &rc,
const MoreOptionsCSRef &options) :
- RefCountAware(&rc),
+ Presenter(rc),
m_options(options)
{
}
MoreOptionsPresenter::~MoreOptionsPresenter()
{
+ if (m_widget) {
+ sendActivateBy(*m_widget, this);
+ }
}
- Result MoreOptionsPresenter::prepare(Widget &parent)
+ Result MoreOptionsPresenter::prepare(ElmWidget &parent)
{
- m_widget = makeShared<Layout>(eext_more_option_add(parent), true);
- if (!m_widget) {
+ FAIL_RETURN(Presenter::prepare(parent), "Presenter::prepare() failed!");
+
+ Evas_Object *const more = eext_more_option_add(parent);
+ if (!more) {
LOG_RETURN(RES_FAIL, "eext_more_option_add() failed!");
}
+ const auto layout = makeShared<Layout>(more, true);
+ m_widget = layout;
+
for (auto &option: *m_options) {
FAIL_RETURN(addItem(option), "addItem() failed!");
}
void MoreOptionsPresenter::onOpened(Widget &widget, void *eventInfo)
{
+ sendDeactivateBy(*m_widget, this);
+ activateBy(m_widget.get());
if (m_listener) {
m_listener->onMoreOptionsOpened(*this);
}
void MoreOptionsPresenter::onClosed(Widget &widget, void *eventInfo)
{
+ deactivateBy(m_widget.get());
+ sendActivateBy(*m_widget, this);
if (m_listener) {
m_listener->onMoreOptionsClosed(*this);
}
void MoreOptionsPresenter::onItemClicked(Widget &widget, void *eventInfo)
{
- if (m_listener && isOpened()) {
+ if (m_listener && isActive() && isOpened()) {
const auto item = m_map.get(eventInfo);
if (item) {
m_listener->onMoreOptionClicked(*this, *item);
void MoreOptionsPresenter::onItemSelected(Widget &widget, void *eventInfo)
{
- if (m_listener && isOpened()) {
+ if (m_listener) {
const auto item = m_map.get(eventInfo);
if (item) {
m_listener->onMoreOptionSelected(*this, *item);
Page::Page(RefCountObjBase &rc, const NaviframeSRef &navi,
const ExitRequestHandler onExitRequest) :
- RefCountAware(&rc),
+ Presenter(rc),
m_navi(navi),
- m_onExitRequest(onExitRequest),
- m_isActive(false)
+ m_onExitRequest(onExitRequest)
{
UCL_ASSERT(navi, "navi is NULL!");
UCL_ASSERT(onExitRequest, "onExitRequest is NULL!");
+
+ deactivateBy(m_navi.get());
}
Page::~Page()
Result Page::preparePart2()
{
+ FAIL_RETURN(Presenter::prepare(*m_navi),
+ "Presenter::prepare() failed!");
+
Evas_Object *content = m_item.getContent();
if (!content) {
LOG_RETURN(RES_FAIL, "content is NULL");
m_onExitRequest(*this);
}
- void Page::activate()
- {
- if (!m_isActive) {
- m_isActive = true;
- onActivate();
- }
- }
-
- void Page::deactivate()
- {
- if (m_isActive) {
- m_isActive = false;
- onDeactivate();
- }
- }
-
void Page::updateActiveState()
{
if (isAtTop()) {
- activate();
+ activateBy(m_navi.get());
} else {
- deactivate();
+ deactivateBy(m_navi.get());
}
}
void Page::onTransitionStarted(Widget &widget, void *eventInfo)
{
- deactivate();
+ deactivateBy(m_navi.get());
}
void Page::onTransitionFinished(Widget &widget, void *eventInfo)
void Page::onHWBackKey(Evas_Object *obj, void *eventInfo)
{
- if (m_isActive) {
+ if (isActive()) {
onBackKey();
}
}
- void Page::onActivate()
- {
- }
-
- void Page::onDeactivate()
- {
- }
-
void Page::onBackKey()
{
requestExit();
--- /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 "presenters/Presenter.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr SmartEvent ACTIVATE_BY {"gallery,activate,by"};
+ constexpr SmartEvent DEACTIVATE_BY {"gallery,deactivate,by"};
+}}}
+
+namespace gallery {
+
+ using namespace ucl;
+
+ Presenter::Presenter(RefCountObjBase &rc) :
+ RefCountAware(&rc),
+ m_isPrepared(false)
+ {
+ }
+
+ Presenter::~Presenter()
+ {
+ }
+
+ Result Presenter::prepare(ElmWidget &widget)
+ {
+ m_topWidget = asWeak(asWidget(widget.getTopWidget()));
+ if (!m_topWidget) {
+ LOG_RETURN(RES_FAIL, "m_topWidget is NULL!");
+ }
+
+ addDeactivatorSource(*m_topWidget);
+
+ m_isPrepared = true;
+
+ return RES_OK;
+ }
+
+ void Presenter::addDeactivatorSource(Widget &source)
+ {
+ source.addEventHandler(impl::ACTIVATE_BY,
+ WEAK_DELEGATE(Presenter::onActivateBySmart, asWeak(*this)));
+ source.addEventHandler(impl::DEACTIVATE_BY,
+ WEAK_DELEGATE(Presenter::onDeactivateBySmart, asWeak(*this)));
+ }
+
+ void Presenter::addDeactivatorException(void *const deactivator)
+ {
+ const auto pair = m_deactivatorExceptions.insert(deactivator);
+ if (pair.second) {
+ activateBy(deactivator);
+ }
+ }
+
+ void Presenter::sendActivateBy(Widget &sender, void *const deactivator)
+ {
+ sendDeactivator(sender, impl::ACTIVATE_BY, deactivator);
+ }
+
+ void Presenter::sendDeactivateBy(Widget &sender, void *const deactivator)
+ {
+ sendDeactivator(sender, impl::DEACTIVATE_BY, deactivator);
+ }
+
+ void Presenter::broadcastActivateBy(void *const deactivator)
+ {
+ broadcastDeactivator(impl::ACTIVATE_BY, deactivator);
+ }
+
+ void Presenter::broadcastDeactivateBy(void *const deactivator)
+ {
+ broadcastDeactivator(impl::DEACTIVATE_BY, deactivator);
+ }
+
+ void Presenter::sendDeactivator(Widget &sender,
+ SmartEvent event, void *deactivator)
+ {
+ sendDeactivatorInfo(sender, event, {deactivator, false});
+ }
+
+ void Presenter::broadcastDeactivator(const SmartEvent event,
+ void *const deactivator)
+ {
+ if (m_topWidget) {
+ sendDeactivatorInfo(*m_topWidget, event, {deactivator, true});
+ } else {
+ ELOG("m_topWidget is NULL!");
+ }
+ }
+
+ void Presenter::sendDeactivatorInfo(Widget &sender,
+ const SmartEvent event, const DeactivatorInfo &info)
+ {
+ sender.callEvent(event, const_cast<DeactivatorInfo *>(&info));
+ }
+
+ bool Presenter::isActive() const
+ {
+ return isEmpty(m_deactivators);
+ }
+
+ bool Presenter::isDeactivatedBy(void *const deactivator) const
+ {
+ return (m_deactivators.find(deactivator) != m_deactivators.end());
+ }
+
+ void Presenter::activateBy(void *const deactivator)
+ {
+ activateByImpl({deactivator, false});
+ }
+
+ void Presenter::deactivateBy(void *const deactivator)
+ {
+ deactivateByImpl({deactivator, false});
+ }
+
+ void Presenter::activateByImpl(const DeactivatorInfo &info)
+ {
+ const auto count = m_deactivators.erase(info.deactivator);
+ if (m_isPrepared && (count > 0)) {
+ onActivateBy(info);
+ if (m_deactivators.size() == 0) {
+ onActivate();
+ }
+ }
+ }
+
+ void Presenter::deactivateByImpl(const DeactivatorInfo &info)
+ {
+ if (m_deactivatorExceptions.find(info.deactivator) !=
+ m_deactivatorExceptions.end()) {
+ return;
+ }
+ const auto pair = m_deactivators.insert(info.deactivator);
+ if (m_isPrepared && pair.second) {
+ onDeactivateBy(info);
+ if (m_deactivators.size() == 1) {
+ onDeactivate();
+ }
+ }
+ }
+
+ void Presenter::onActivateBySmart(Widget &widget, void *eventInfo)
+ {
+ activateByImpl(*static_cast<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)
+ {
+ }
+}
}
ProcessingPresenterSRef ProcessingPresenter::Builder::
- build(Widget &parent) const
+ build(ElmWidget &parent) const
{
auto result = makeShared<ProcessingPresenter>(m_iconType);
dismissPopup(true);
}
- Result ProcessingPresenter::prepare(Widget &parent,
+ Result ProcessingPresenter::prepare(ElmWidget &parent,
const TString &processingText,
const TString &completeText,
const bool forceProgress)
return RES_OK;
}
- Result ProcessingPresenter::createWidget(Widget &parent,
+ Result ProcessingPresenter::createWidget(ElmWidget &parent,
const TString &processingText)
{
m_widget = Layout::Builder().
SelectModePresenter::SelectModePresenter(RefCountObjBase &rc,
PageContent &content, const int flags) :
- RefCountAware(&rc),
+ Presenter(rc),
m_content(asShared(content)),
m_flags(flags),
m_totalCount(0),
m_selectCount(0),
m_isVisible(false),
- m_isActive(true)
+ m_isPopupDismissed(false)
{
}
delRotaryEventHandler(CALLBACK_A(
SelectModePresenter::onRotary), this);
}
- dismissPopup(true);
+ deletePopup();
}
Result SelectModePresenter::prepare()
{
+ FAIL_RETURN(Presenter::prepare(*m_content),
+ "Presenter::prepare() failed!");
+
m_selectButton = makeShared<StyledWidget>(
elm_button_add(*m_content), true);
m_selectButton->setStyle(impl::SELECT_BTN_STYLE);
SelectModePresenter::onRotary), this);
}
+ addDeactivatorException(this);
+ Presenter::prepare(*m_selectButton);
+
return RES_OK;
}
}
if (m_isVisible) {
+ activateBy(m_selectButton.get());
doUpdate();
} else {
- dismissPopup(true);
+ deactivateBy(m_selectButton.get());
if ((m_flags & (FLAG_NO_MORE_OPTIONS |
FLAG_NO_DIM_ON_ZERO_SELECT)) == 0) {
m_content->setMoreOptionsVisible(true);
return m_isVisible;
}
- void SelectModePresenter::setActive(const bool value)
+ void SelectModePresenter::onDeactivate()
{
- if (value == m_isActive) {
- return;
- }
- m_isActive = value;
-
- if (!m_isActive) {
- dismissPopup(true);
- }
- }
-
- bool SelectModePresenter::isActive() const
- {
- return m_isActive;
+ deletePopup();
}
void SelectModePresenter::setBottomButtonText(const TString &value)
void SelectModePresenter::showPopup()
{
- m_popup = makeShared<StyledWidget>(elm_ctxpopup_add(*m_content));
+ m_isPopupDismissed = false;
+
+ m_popup = makeShared<StyledWidget>(elm_ctxpopup_add(*m_content), true);
m_popup->setStyle(impl::SELECT_POPUP_STYLE);
elm_ctxpopup_direction_priority_set(*m_popup,
eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
CALLBACK_A(SelectModePresenter::onPopupHWBackKey), this);
+
+ broadcastDeactivateBy(this);
}
void SelectModePresenter::movePopup()
m_popup->move(cx + (cw / 2), cy + ((ch - ph) / 2));
}
- void SelectModePresenter::dismissPopup(const bool force)
+ void SelectModePresenter::dismissPopup()
+ {
+ if (m_popup && !m_isPopupDismissed) {
+ m_isPopupDismissed = true;
+ elm_ctxpopup_dismiss(*m_popup);
+ }
+ }
+
+ void SelectModePresenter::deletePopup()
{
if (m_popup) {
eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
CALLBACK_A(SelectModePresenter::onPopupHWBackKey));
- if (force) {
- m_popup->markForDeletion();
- } else {
- elm_ctxpopup_dismiss(*m_popup);
- }
+
m_popup.reset();
+
+ broadcastActivateBy(this);
}
}
void SelectModePresenter::onPopupDismissed(
Widget &widget, void *eventInfo)
{
- widget.markForDeletion();
+ deletePopup();
}
void SelectModePresenter::onPopupHWBackKey(
Evas_Object *obj, void *eventInfo)
{
- dismissPopup();
+ if (isActive()) {
+ dismissPopup();
+ }
}
void SelectModePresenter::onSelectAll(
void SelectModePresenter::onSelectBtnClick(
Widget &widget, void *eventInfo)
{
- if (m_isVisible && m_isActive && !m_popup && (m_totalCount > 0)) {
+ if (isActive() && !m_popup && (m_totalCount > 0)) {
showPopup();
}
}
void SelectModePresenter::onBottomBtnClick(
Widget &widget, void *eventInfo)
{
- if (m_isVisible && m_isActive && !m_popup && (m_selectCount > 0)) {
+ if (isActive() && !m_popup && (m_selectCount > 0)) {
dispatchEvent(EVENT_BOTTOM_BUTTON_CLICK);
}
}
Eina_Bool SelectModePresenter::onRotary(Eext_Rotary_Event_Info *info)
{
- if (m_isVisible && m_isActive) {
+ if (isActive()) {
dismissPopup();
}
return EINA_TRUE;
return *this;
}
- ImageGridSRef ImageGrid::Builder::build(Widget &parent) const
+ ImageGridSRef ImageGrid::Builder::build(ElmWidget &parent) const
{
Evas_Object *const scrollerEo = elm_scroller_add(parent);
if (!scrollerEo) {
public:
friend class RefCountObj<Item>;
Item(RefCountObjBase &rc,
- const ImageGrid &imageGrid, Widget &parent) :
+ const ImageGrid &imageGrid, ElmWidget &parent) :
RefCountAware(&rc),
m_imageGrid(imageGrid),
m_btn(elm_button_add(parent)),
void ImageGrid::createCircleScroller()
{
- const auto sfc = getCircleSurface(*m_scroller);
+ const auto sfc = util::getCircleSurface(*m_scroller);
if (!sfc) {
- LOG_RETURN_VOID(RES_FAIL, "getCircleSurface() failed!");
+ LOG_RETURN_VOID(RES_FAIL, "util::getCircleSurface() failed!");
}
m_circleScroller = eext_circle_object_scroller_add(*m_scroller, sfc);
for (int i = m_slotCount; i < newSlotCount; ++i) {
const bool isOdd = ((m_beginSlotIndex + i) & 1);
- auto slot = util::makeUnique(new Slot(*this, isOdd));
+ auto slot = ucl::util::makeUnique(new Slot(*this, isOdd));
if (m_slotSize == 0) {
UCL_ASSERT(!isOdd, "Must be even!");
return *this;
}
- ImageViewerSRef ImageViewer::Builder::build(Widget &parent) const
+ ImageViewerSRef ImageViewer::Builder::build(ElmWidget &parent) const
{
if ((m_imageW <= 0) || (m_imageH <= 0)) {
LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Image size is invalid");
return *this;
}
- PageContentSRef PageContent::Builder::build(Widget &parent) const
+ PageContentSRef PageContent::Builder::build(ElmWidget &parent) const
{
auto layout = Layout::Builder().
setTheme(impl::LAYOUT_MORE_OPTIONS).
constexpr EoDataKey CIRCLE_SURFACE {"gallery,eext,circle,surface"};
}}}
-namespace gallery {
+namespace gallery { namespace util {
using namespace ucl;
return sfc;
}
+}}
+
+namespace gallery {
+
+ using namespace ucl;
void addRotaryEventHandler(Eext_Rotary_Handler_Cb func, void *data)
{
return {"layout", "gallery_image", fileName};
}
}
-
Builder &setEdjeFile(std::string filePath, EdjeGroup group);
Builder &setIsOwner(bool value);
Builder &setNeedBindToEo(bool value);
- LayoutSRef build(Widget &parent) const;
+ LayoutSRef build(ElmWidget &parent) const;
private:
LayoutTheme m_theme;
std::string m_edjeFilePath;
Builder();
Builder &setStyle(ElmStyle value);
Builder &setNeedBindToEo(bool value);
- NaviframeSRef build(Widget &parent) const;
+ NaviframeSRef build(ElmWidget &parent) const;
private:
ElmStyle m_style;
bool m_needBindToEo;
// Layout::Builder //
- LayoutSRef Layout::Builder::build(Widget &parent) const
+ LayoutSRef Layout::Builder::build(ElmWidget &parent) const
{
Evas_Object *const eo = elm_layout_add(parent);
if (!eo) {
// Naviframe::Builder //
- NaviframeSRef Naviframe::Builder::build(Widget &parent) const
+ NaviframeSRef Naviframe::Builder::build(ElmWidget &parent) const
{
Evas_Object *const eo = elm_naviframe_add(parent);
if (!eo) {