<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.299151930" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
<builder autoBuildTarget="all" buildPath="${workspace_loc:/call-ui}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.287909858" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
<tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.850939844" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
- <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.66050065" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
+ <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.66050065" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
<option id="gnu.cpp.compiler.option.optimization.level.1977572256" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.1003532466" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.58197076" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.compiler.option.1780411914" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_llvm40.i386.core.app"/>
+ <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_gcc49.i386.core.app"/>
</option>
<option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.2060575755" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.27127097" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
</tool>
- <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1049599195" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
+ <tool command="i386-linux-gnueabi-gcc" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.1049599195" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1400861396" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
<option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.1157370620" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
<option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.1654013693" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
<option id="sbi.gnu.c.compiler.option.551225658" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
- <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_llvm40.i386.core.app"/>
+ <listOptionValue builtIn="false" value="wearable-4.0-emulator.core.private_gcc49.i386.core.app"/>
</option>
<option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1481628386" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
<listOptionValue builtIn="false" value=""${SBI_SYSROOT}/usr/include/libxml2""/>
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.890993403" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
</tool>
<tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1743186514" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
- <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1743878166" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
+ <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1743878166" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
<option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.1017885244" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
<option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.219138009" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
<option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.588492684" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
color: 0 0 0 0;
}
}
+
+ rect { "event";
+ mouse;
+ scale;
+ desc { "default";
+ rel1.to: "bg";
+ rel2.to: "bg";
+ color: 0 0 0 0;
+ hid;
+ }
+ desc { "enable";
+ inherit: "default";
+ vis;
+ }
+ }
}
programs {
script {
#ifndef __CALLUI_VIEW_ACCEPT_DIALOG_H__
#define __CALLUI_VIEW_ACCEPT_DIALOG_H__
-#include "Presenter.h"
+#include "ucl/mvp/GuiPresenter.h"
#include "ucl/gui/StyledWidget.h"
#include "ucl/gui/ElmWidget.h"
+#include "ucl/gui/ElmWidget.h"
#include "types.h"
namespace callui {
- class AcceptDialog final :
- public Presenter,
+ class AcceptDialog final : public ucl::GuiPresenter,
public ucl::IDisposable {
public:
class Builder {
ucl::StyledWidgetSRef m_popup;
ucl::StyledWidgetSRef m_genlist;
AcceptDialogHandler m_handler;
+ AcceptDialogSRef m_selfRef;
bool m_isDismissed;
};
#ifndef __CALLUI_PRESENTERS_ACCEPT_REJECT_PRESENTER_H__
#define __CALLUI_PRESENTERS_ACCEPT_REJECT_PRESENTER_H__
-#include "Presenter.h"
+#include "ucl/mvp/GuiPresenter.h"
#include "ucl/gui/Layout.h"
#include "ucl/gui/StyledWidget.h"
namespace callui {
- class AcceptRejectPresenter final : public Presenter {
+ class AcceptRejectPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
Builder &setIncomingCall(const IIncomingCallSRef &call);
Builder &setAvailableCallsFlag(CallMask calls);
Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
- AcceptRejectPresenterSRef build(Presenter &parent) const;
+ AcceptRejectPresenterSRef build(ucl::GuiPresenter &parent) const;
private:
IIncomingCallSRef m_call;
const IIncomingCallSRef &call,
CallMask calls);
- ucl::Result prepare(Presenter &parent,
+ ucl::Result prepare(ucl::GuiPresenter &parent,
ucl::ElmWidget &parentWidget);
ucl::Result createWidget(ucl::ElmWidget &parent);
#ifndef __CALLUI_PRESENTERS_ACCESSORY_PRESENTER_H__
#define __CALLUI_PRESENTERS_ACCESSORY_PRESENTER_H__
-#include "Presenter.h"
+#include "ucl/mvp/GuiPresenter.h"
#include "ucl/gui/Layout.h"
#include "ucl/gui/StyledWidget.h"
namespace callui {
- class AccessoryPresenter final : public Presenter {
+ class AccessoryPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
Builder &setSoundManager(const ISoundManagerSRef &sm);
Builder &setMuteControlDisabled(bool isDisabled);
Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
- AccessoryPresenterSRef build(Presenter &parent) const;
+ AccessoryPresenterSRef build(ucl::GuiPresenter &parent) const;
private:
ISoundManagerSRef m_sm;
AccessoryPresenter(ucl::IRefCountObj &rc,
const ISoundManagerSRef &sm);
- ucl::Result prepare(Presenter &parent,
+ ucl::Result prepare(ucl::GuiPresenter &parent,
ucl::ElmWidget &parentWidget,
bool isMuteControlDisabled = false);
#ifndef __CALLUI_PRESENTERS_CALL_INFO_PRESENTER_H__
#define __CALLUI_PRESENTERS_CALL_INFO_PRESENTER_H__
-#include "Presenter.h"
+#include "ucl/mvp/GuiPresenter.h"
#include "ucl/gui/Layout.h"
#include "ucl/gui/StyledWidget.h"
namespace callui {
- class CallInfoPresenter final : public Presenter {
+ class CallInfoPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
Builder &setCallManager(const ICallManagerSRef &cm);
Builder &setMode(CallMode mode);
Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
- CallInfoPresenterSRef build(Presenter &parent) const;
+ CallInfoPresenterSRef build(ucl::GuiPresenter &parent) const;
private:
ICallManagerSRef m_cm;
CallMode m_mode;
const ICallManagerSRef &cm,
CallMode mode);
- ucl::Result prepare(Presenter &parent,
+ ucl::Result prepare(ucl::GuiPresenter &parent,
ucl::ElmWidget &parentWidget);
void initCallInfos(const ICallManagerSRef &cm);
ucl::Result createWidget(ucl::ElmWidget &parent);
ucl::Result createLabel(const std::string &text);
ucl::Result createCallerIdImage(const std::string &imagePath);
- ucl::Result createCallStatus(Presenter &parent);
+ ucl::Result createCallStatus(ucl::GuiPresenter &parent);
ucl::Result update();
ucl::Result updateCallerId();
ucl::LayoutSRef m_widget;
ucl::StyledWidgetSRef m_callerId;
ucl::StyledWidgetSRef m_label;
- PresenterWRef m_parent;
+ ucl::GuiPresenterWRef m_parent;
CallMode m_mode;
ICallInfoSCRef m_incomCallInfo;
ICallInfoSCRef m_activeCallInfo;
#ifndef __CALLUI_PRESENTERS_CALL_STATUS_PRESENTER_H__
#define __CALLUI_PRESENTERS_CALL_STATUS_PRESENTER_H__
-#include "Presenter.h"
+#include "ucl/mvp/GuiPresenter.h"
#include <time.h>
namespace callui {
- class CallStatusPresenter final : public Presenter {
+ class CallStatusPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
Builder &setCallInfo(const ICallInfoWCRef &info);
Builder &setCallHoldState(bool isOnHold);
Builder &setLayout(const ucl::LayoutSRef &layout);
- CallStatusPresenterSRef build(Presenter &parent) const;
+ CallStatusPresenterSRef build(ucl::GuiPresenter &parent) const;
private:
ucl::LayoutSRef m_ly;
CallMode m_mode;
const ICallInfoWCRef &info,
bool isOnHold);
- ucl::Result prepare(Presenter &parent);
+ ucl::Result prepare(ucl::GuiPresenter &parent);
ucl::Result processIncomingMode();
ucl::Result processOutgoingMode();
#ifndef __CALLUI_PRESENTERS_INDICATOR_PRESENTER_H__
#define __CALLUI_PRESENTERS_INDICATOR_PRESENTER_H__
-#include "Presenter.h"
+#include "ucl/mvp/GuiPresenter.h"
#include "model/IIndicatorStateListener.h"
#include "ucl/gui/Layout.h"
namespace callui {
- class IndicatorPresenter final :
- public IIndicatorStateListener,
- public Presenter {
+ class IndicatorPresenter final : public ucl::GuiPresenter,
+ public IIndicatorStateListener {
public:
class Builder {
public:
const IIndicatorStateProviderSRef &provider);
Builder &setParentWidget(const ucl::ElmWidgetSRef
&parentWidget);
- IndicatorPresenterSRef build(Presenter &parent) const;
+ IndicatorPresenterSRef build(ucl::GuiPresenter &parent) const;
private:
IIndicatorStateProviderSRef m_provider;
ucl::ElmWidgetSRef m_parentWidget;
IndicatorPresenter(ucl::IRefCountObj &rc,
const IIndicatorStateProviderSRef &provider);
- ucl::Result prepare(Presenter &parent, ucl::ElmWidget &parentWidget);
+ ucl::Result prepare(ucl::GuiPresenter &parent, ucl::ElmWidget &parentWidget);
ucl::Result createWidget(ucl::ElmWidget &parent);
ucl::Result createConnectionLayout();
namespace callui {
- class MainPage final :
- public Page,
+ class MainPage final : public Page,
public ICallListener {
public:
class Builder {
#ifndef __CALLUI_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
#define __CALLUI_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
-#include "Presenter.h"
+#include "ucl/mvp/GuiPresenter.h"
#include "ucl/gui/Layout.h"
#include "ucl/gui/StyledWidget.h"
namespace callui {
- class MoreOptionsPresenter final : public Presenter {
+ class MoreOptionsPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
Builder &setSoundManager(const ISoundManagerSRef &sm);
Builder &setNaviframe(const ucl::NaviframeSRef &navi);
Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
- MoreOptionsPresenterSRef build(Presenter &parent) const;
+ MoreOptionsPresenterSRef build(ucl::GuiPresenter &parent) const;
private:
ICallManagerSRef m_cm;
ISoundManagerSRef m_sm;
const ucl::NaviframeSRef &navi);
virtual ~MoreOptionsPresenter();
- ucl::Result prepare(Presenter &parent,
+ ucl::Result prepare(ucl::GuiPresenter &parent,
ucl::ElmWidget &parentWidget);
ucl::Result createWidget(ucl::ElmWidget &parent);
namespace callui {
- class MotionSensorPresenter final
- {
+ class MotionSensorPresenter final {
public:
class Builder {
public:
#include "ucl/gui/Naviframe.h"
-#include "Presenter.h"
-
-#include "types.h"
+#include "ucl/mvp/GuiPresenter.h"
namespace callui {
- class Page : public Presenter {
+ UCL_DECLARE_REF_ALIASES(Page);
+
+ class Page : public ucl::GuiPresenter {
public:
using ExitRequestHandler = ucl::WeakDelegate<void(Page &page)>;
const ucl::NaviframeSRef m_navi;
const ExitRequestHandler m_onExitRequest;
ucl::NaviItem m_item;
+ PageSRef m_selfRef;
};
- // Non-member functions //
+ // Non-member functions
bool isLast(const 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!");
return (m_navi->getBottomItem() == m_item);
}
- // Non-member functions //
+ // Non-member functions
inline bool isLast(const Page &page)
{
+++ /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 __CALLUI_PRESENTERS_PRESENTER_H__
-#define __CALLUI_PRESENTERS_PRESENTER_H__
-
-#include <unordered_set>
-
-#include "ucl/gui/Window.h"
-
-#include "types.h"
-
-namespace callui {
-
- 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 // __CALLUI_PRESENTERS_PRESENTER_H__
#ifndef __CALLUI_PRESENTERS_REJECT_MESSAGE_PRESENTER_H__
#define __CALLUI_PRESENTERS_REJECT_MESSAGE_PRESENTER_H__
-#include "Presenter.h"
+#include "ucl/mvp/GuiPresenter.h"
#include "ucl/gui/Layout.h"
#include "ucl/gui/StyledWidget.h"
namespace callui {
- class RejectMsgPresenter final : public Presenter {
+ class RejectMsgPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
Builder &setStateHandler(const RejectMsgStateHandler &handler);
Builder &setSelectHandler(const RejectMsgSelectHandler &handler);
Builder &setParentWidget(const ucl::ElmWidgetSRef &parentWidget);
- RejectMsgPresenterSRef build(Presenter &parent) const;
+ RejectMsgPresenterSRef build(ucl::GuiPresenter &parent) const;
private:
IRejectMsgProviderSRef m_provider;
const RejectMsgStateHandler &stateHandler,
const RejectMsgSelectHandler &selectHandler);
- ucl::Result prepare(Presenter &parent,
+ ucl::Result prepare(ucl::GuiPresenter &parent,
ucl::ElmWidget &parentWidget);
ucl::Result createWidget(ucl::ElmWidget &parent);
UCL_DECLARE_REF_ALIASES(DeviceStatePresenter);
UCL_DECLARE_REF_ALIASES(MotionSensorPresenter);
+ UCL_DECLARE_REF_ALIASES(AlertBaseViewController);
+
using AcceptDialogHandler = ucl::WeakDelegate<bool(AcceptDialog &, AcceptDialogEvent)>;
using RejectMsgStateHandler = ucl::WeakDelegate<void(RejectMsgState)>;
using RejectMsgSelectHandler = ucl::WeakDelegate<void(const IRejectMsgSRef &rm)>;
Elm_Gen_Item_Content_Get_Cb contentCb = nullptr,
Elm_Gen_Item_State_Get_Cb stateCb = nullptr,
Elm_Gen_Item_Del_Cb delCb = nullptr);
+
+ ucl::LayoutTheme getImageTheme(const char *fileName);
}
#endif // __CALLUI_VIEW_HELPERS_H__
AcceptDialog::AcceptDialog(IRefCountObj &rc,
const AcceptDialogHandler &handler):
- Presenter(rc),
+ GuiPresenter(rc),
m_handler(handler),
m_isDismissed(false)
{
Result AcceptDialog::prepare(ElmWidget &parent)
{
- FAIL_RETURN(Presenter::prepare(parent, PF_DEACTIVATOR),
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
"Presenter::prepare() failed!");
FAIL_RETURN(createPopup(parent, impl::POPUP_STYLE),
FAIL_RETURN(createGenlist(),
"createGenlist() failed!");
- m_rc->ref();
+ m_selfRef = asShared(*this);
addDeactivatorException(this);
broadcastDeactivate();
m_popup.reset();
- m_rc->unref();
+ m_selfRef.reset();
}
}
}
AcceptRejectPresenterSRef
- AcceptRejectPresenter::Builder::build(Presenter &parent) const
+ AcceptRejectPresenter::Builder::build(GuiPresenter &parent) const
{
if (!m_parentWidget) {
LOG_RETURN_VALUE(RES_FAIL, {}, "m_parentWidget is NULL");
AcceptRejectPresenter::AcceptRejectPresenter(IRefCountObj &rc,
const IIncomingCallSRef &call,
CallMask calls):
- Presenter(rc),
+ GuiPresenter(rc),
m_call(call),
m_callMask(calls)
{
CALLBACK_A(AcceptRejectPresenter::onRotaryEvent), this);
}
- Result AcceptRejectPresenter::prepare(Presenter &parent,
+ Result AcceptRejectPresenter::prepare(GuiPresenter &parent,
ElmWidget &parentWidget)
{
- FAIL_RETURN(Presenter::prepare(parent),
+ FAIL_RETURN(GuiPresenter::prepare(parent),
"Presenter::prepare() failed!");
FAIL_RETURN(createWidget(parentWidget),
}
AccessoryPresenterSRef
- AccessoryPresenter::Builder::build(Presenter &parent) const
+ AccessoryPresenter::Builder::build(GuiPresenter &parent) const
{
if (!m_sm || !m_parentWidget) {
LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
AccessoryPresenter::AccessoryPresenter(IRefCountObj &rc,
const ISoundManagerSRef &sm):
- Presenter(rc),
+ GuiPresenter(rc),
m_sm(sm),
m_vcTimer(nullptr),
m_audioState(m_sm->getAudioState())
unregisterCallbacks();
}
- Result AccessoryPresenter::prepare(Presenter &parent,
+ Result AccessoryPresenter::prepare(GuiPresenter &parent,
ElmWidget &parentWidget,
bool isMuteControlDisabled)
{
- FAIL_RETURN(Presenter::prepare(parent), "Presenter::prepare() failed");
+ FAIL_RETURN(GuiPresenter::prepare(parent), "Presenter::prepare() failed");
FAIL_RETURN(createWidget(parentWidget), "createWidget() failed");
}
CallInfoPresenterSRef
- CallInfoPresenter::Builder::build(Presenter &parent) const
+ CallInfoPresenter::Builder::build(GuiPresenter &parent) const
{
if (m_mode == CallMode::UNDEFINED || !m_cm || !m_parentWidget) {
LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are are set");
CallInfoPresenter::CallInfoPresenter(IRefCountObj &rc,
const ICallManagerSRef &cm,
CallMode mode):
- Presenter(rc),
+ GuiPresenter(rc),
m_mode(mode),
m_isSubTxtEnable(false),
m_needModifyCallStatus(false)
{
}
- Result CallInfoPresenter::prepare(Presenter &parent,
+ Result CallInfoPresenter::prepare(GuiPresenter &parent,
ElmWidget &parentWidget)
{
- FAIL_RETURN(Presenter::prepare(parent, PF_PASSIVE),
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE),
"Presenter::prepare() failed!");
m_parent = asWeak(parent);
return RES_OK;
}
- Result CallInfoPresenter::createCallStatus(Presenter &parent)
+ Result CallInfoPresenter::createCallStatus(GuiPresenter &parent)
{
ICallInfoWCRef callInfo;
bool isOnHold = false;
}
CallStatusPresenterSRef
- CallStatusPresenter::Builder::build(Presenter &parent) const
+ CallStatusPresenter::Builder::build(GuiPresenter &parent) const
{
if (m_mode == CallMode::UNDEFINED || !m_ly) {
LOG_RETURN_VALUE(RES_FAIL, {}, "Not all params are set");
CallMode mode,
const ICallInfoWCRef &info,
bool isHeld):
- Presenter(rc),
+ GuiPresenter(rc),
m_ly(layout),
m_mode(mode),
m_info(info),
}
}
- Result CallStatusPresenter::prepare(Presenter &parent)
+ Result CallStatusPresenter::prepare(GuiPresenter &parent)
{
- FAIL_RETURN(Presenter::prepare(parent, PF_PASSIVE),
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE),
"Presenter::prepare() failed!");
m_ly->emit(impl::SIGN_RESET, impl::SIGN_SRC_DOT);
}
IndicatorPresenterSRef
- IndicatorPresenter::Builder::build(Presenter &parent) const
+ IndicatorPresenter::Builder::build(GuiPresenter &parent) const
{
if (!m_provider || !m_parentWidget) {
LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
IndicatorPresenter::IndicatorPresenter(IRefCountObj &rc,
const IIndicatorStateProviderSRef &provider):
- Presenter(rc),
+ GuiPresenter(rc),
m_provider(provider),
m_isIncomingCallMode(false)
{
{
}
- Result IndicatorPresenter::prepare(Presenter &parent,
+ Result IndicatorPresenter::prepare(GuiPresenter &parent,
ElmWidget &parentWidget)
{
- FAIL_RETURN(Presenter::prepare(parent, PF_PASSIVE),
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_PASSIVE),
"Presenter::prepare() failed!");
FAIL_RETURN(createWidget(parentWidget),
"createWidget() failed!");
}
MoreOptionsPresenterSRef
- MoreOptionsPresenter::Builder::build(Presenter &parent) const
+ MoreOptionsPresenter::Builder::build(GuiPresenter &parent) const
{
if (!m_cm || !m_sm || !m_navi || !m_parentWidget) {
LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
const ICallManagerSRef &cm,
const ISoundManagerSRef &sm,
const NaviframeSRef &navi):
- Presenter(rc),
+ GuiPresenter(rc),
m_cm(cm),
m_sm(sm),
m_navi(navi),
}
}
- Result MoreOptionsPresenter::prepare(Presenter &parent,
+ Result MoreOptionsPresenter::prepare(GuiPresenter &parent,
ElmWidget &parentWidget)
{
- FAIL_RETURN(Presenter::prepare(parent, PF_DEACTIVATOR),
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
"Presenter::prepare() failed!");
FAIL_RETURN(createWidget(parentWidget), "createWidget() failed!");
Page::Page(IRefCountObj &rc, const NaviframeSRef &navi,
const ExitRequestHandler &onExitRequest) :
- Presenter(rc),
+ GuiPresenter(rc),
m_navi(navi),
m_onExitRequest(onExitRequest)
{
m_item.setData(this);
m_item.setDelCallback(CALLBACK_A(Page::onItemDel));
- m_rc->ref();
+ m_selfRef = asShared(*this);
if (!m_navi->isInTransition() && isAtTop()) {
dispatchTopPageChanged();
void Page::onItemDel(Evas_Object *obj, void *eventInfo)
{
m_item = nullptr;
- m_rc->unref();
+ m_selfRef.reset();
}
void Page::exit()
+++ /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 callui { namespace { namespace impl {
-
- constexpr SmartEvent ACTIVATE_BY {"callui,activate,by"};
- constexpr SmartEvent DEACTIVATE_BY {"callui,deactivate,by"};
-}}}
-
-namespace callui {
-
- using namespace ucl;
-
- 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)
- {
- }
-}
}
RejectMsgPresenterSRef
- RejectMsgPresenter::Builder::build(Presenter &parent) const
+ RejectMsgPresenter::Builder::build(GuiPresenter &parent) const
{
if (!m_provider || !m_parentWidget) {
LOG_RETURN_VALUE(RES_FAIL, {}, "Main params are not set");
const IRejectMsgProviderSRef &provider,
const RejectMsgStateHandler &stateHandler,
const RejectMsgSelectHandler &selectHandler):
- Presenter(rc),
+ GuiPresenter(rc),
m_circleEo(nullptr),
m_provider(provider),
m_stateHandler(stateHandler),
}
}
- Result RejectMsgPresenter::prepare(Presenter &parent,
+ Result RejectMsgPresenter::prepare(GuiPresenter &parent,
ElmWidget &parentWidget)
{
- FAIL_RETURN(Presenter::prepare(parent, PF_DEACTIVATOR),
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
"Presenter::prepare() failed!");
FAIL_RETURN(createWidget(parentWidget),
return itc;
}
+ LayoutTheme getImageTheme(const char *const fileName)
+ {
+ return {"layout", "callui_image", fileName};
+ }
+
}
class SysEventProvider;
using SysEventProviderUPtr = std::unique_ptr<SysEventProvider>;
- class SysEventProvider : public NonCopyable {
+ class SysEventProvider final : public NonCopyable {
public:
using EventHandlerAddFunc = int (*)(app_event_handler_h *,
app_event_type_e, app_event_cb, void *);
namespace ucl {
- class UIApp : private IInstanceContext {
+ class UIApp final : private IInstanceContext {
public:
UIApp(InstanceManagerBase &instanceMgr);
virtual ~UIApp();
--- /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_GUI_GENLIST_H__
+#define __UCL_GUI_GENLIST_H__
+
+#include "StyledWidget.h"
+#include "GenlistItem.h"
+
+namespace ucl {
+
+ UCL_DECLARE_REF_ALIASES(Genlist);
+
+ class Genlist : public StyledWidget {
+ public:
+ enum class Mode {
+ COMPRESS = ELM_LIST_COMPRESS,
+ SCROLL = ELM_LIST_SCROLL,
+ LIMIT = ELM_LIST_LIMIT,
+ EXPAND = ELM_LIST_EXPAND
+ };
+
+ class Builder final {
+ public:
+ Builder();
+ Builder &setStyle(ElmStyle style);
+ Builder &setMode(Mode mode);
+ Builder &setHomogeneous(bool value);
+ Builder &setIsOwner(bool value);
+ Builder &setNeedBindToEo(bool value);
+ GenlistSRef build(ElmWidget &parent) const;
+ private:
+ ElmStyle m_style;
+ Mode m_mode;
+ bool m_isHomogeneous;
+ bool m_isOwner;
+ bool m_needBindToEo;
+ };
+
+ public:
+ friend class ReffedObj<Genlist>;
+ using StyledWidget::StyledWidget;
+
+ void setMode(Mode mode);
+ Mode getMode() const;
+
+ void setHomogeneous(bool isHomogeneous);
+ bool isHomogeneous() const;
+
+ void updateRealizedItems();
+ void clear();
+
+ GenlistItem append(const Elm_Genlist_Item_Class *itc,
+ const void *data, SmartCbHandler onSelect = nullptr,
+ GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+ GenlistItem parent = nullptr);
+
+ GenlistItem prepend(const Elm_Genlist_Item_Class *itc,
+ const void *data, SmartCbHandler onSelect = nullptr,
+ GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+ GenlistItem parent = nullptr);
+
+ GenlistItem insertAfter(GenlistItem after,
+ const Elm_Genlist_Item_Class *itc, const void *data,
+ SmartCbHandler onSelect = nullptr,
+ GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+ GenlistItem parent = nullptr);
+
+ GenlistItem insertBefore(GenlistItem before,
+ const Elm_Genlist_Item_Class *itc, const void *data,
+ SmartCbHandler onSelect = nullptr,
+ GenlistItem::Type type = GenlistItem::Type::SIMPLE,
+ GenlistItem parent = nullptr);
+ };
+}
+
+#include "Genlist.hpp"
+
+#endif // __UCL_GUI_GENLIST_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.
+ */
+
+namespace ucl {
+
+ // Genlist::Builder //
+
+ inline Genlist::Builder::Builder() :
+ m_mode(Mode::COMPRESS),
+ m_isHomogeneous(true),
+ m_isOwner(false),
+ m_needBindToEo(false)
+ {
+ }
+
+ inline Genlist::Builder &Genlist::Builder::setStyle(const ElmStyle style)
+ {
+ m_style = style;
+ return *this;
+ }
+
+ inline Genlist::Builder &Genlist::Builder::setMode(const Mode mode)
+ {
+ m_mode = mode;
+ return *this;
+ }
+
+ inline Genlist::Builder &Genlist::Builder::setHomogeneous(const bool value)
+ {
+ m_isHomogeneous = value;
+ return *this;
+ }
+
+ inline Genlist::Builder &Genlist::Builder::setIsOwner(const bool value)
+ {
+ m_isOwner = value;
+ return *this;
+ }
+
+ inline Genlist::Builder &Genlist::Builder::setNeedBindToEo(const bool value)
+ {
+ m_needBindToEo = value;
+ return *this;
+ }
+
+ // Genlist //
+
+ inline void Genlist::setMode(const Mode mode)
+ {
+ elm_genlist_mode_set(getEo(), static_cast<Elm_List_Mode>(mode));
+ }
+
+ inline Genlist::Mode Genlist::getMode() const
+ {
+ return static_cast<Mode>(elm_genlist_mode_get(getEo()));
+ }
+
+ inline void Genlist::setHomogeneous(const bool isHomogeneous)
+ {
+ elm_genlist_homogeneous_set(getEo(), toEina(isHomogeneous));
+ }
+
+ inline bool Genlist::isHomogeneous() const
+ {
+ return elm_genlist_homogeneous_get(getEo());
+ }
+
+ inline void Genlist::updateRealizedItems()
+ {
+ elm_genlist_realized_items_update(getEo());
+ }
+
+ inline void Genlist::clear()
+ {
+ elm_genlist_clear(getEo());
+ }
+
+ inline GenlistItem Genlist::append(const Elm_Genlist_Item_Class *const itc,
+ const void *const data, const SmartCbHandler onSelect,
+ const GenlistItem::Type type, const GenlistItem parent)
+ {
+ return GenlistItem(elm_genlist_item_append(
+ getEo(), itc, data, parent,
+ static_cast<Elm_Genlist_Item_Type>(type),
+ onSelect.getStubA(), onSelect.getData()));
+ }
+
+ inline GenlistItem Genlist::prepend(const Elm_Genlist_Item_Class *const itc,
+ const void *const data, SmartCbHandler onSelect,
+ const GenlistItem::Type type, const GenlistItem parent)
+ {
+ return GenlistItem(elm_genlist_item_prepend(
+ getEo(), itc, data, parent,
+ static_cast<Elm_Genlist_Item_Type>(type),
+ onSelect.getStubA(), onSelect.getData()));
+ }
+
+ inline GenlistItem Genlist::insertAfter(const GenlistItem after,
+ const Elm_Genlist_Item_Class *const itc, const void *const data,
+ const SmartCbHandler onSelect, const GenlistItem::Type type,
+ const GenlistItem parent)
+ {
+ return GenlistItem(elm_genlist_item_insert_after(
+ getEo(), itc, data, parent, after,
+ static_cast<Elm_Genlist_Item_Type>(type),
+ onSelect.getStubA(), onSelect.getData()));
+ }
+
+ inline GenlistItem Genlist::insertBefore(const GenlistItem before,
+ const Elm_Genlist_Item_Class *itc, const void *data,
+ const SmartCbHandler onSelect, const GenlistItem::Type type,
+ const GenlistItem parent)
+ {
+ return GenlistItem(elm_genlist_item_insert_before(
+ getEo(), itc, data, parent, before,
+ static_cast<Elm_Genlist_Item_Type>(type),
+ onSelect.getStubA(), onSelect.getData()));
+ }
+}
--- /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_GUI_GENLIST_ITEM_H__
+#define __UCL_GUI_GENLIST_ITEM_H__
+
+#include "WidgetItem.h"
+
+namespace ucl {
+
+ class GenlistItem final : public WidgetItem {
+ public:
+ enum class Type {
+ SIMPLE = ELM_GENLIST_ITEM_NONE,
+ TREE = ELM_GENLIST_ITEM_TREE,
+ GROUP = ELM_GENLIST_ITEM_GROUP
+ };
+
+ enum class SelectMode {
+ DEFAULT = ELM_OBJECT_SELECT_MODE_DEFAULT,
+ ALWAYS = ELM_OBJECT_SELECT_MODE_ALWAYS,
+ NONE = ELM_OBJECT_SELECT_MODE_NONE,
+ DISPLAY_ONLY = ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY
+ };
+
+ enum {
+ FIELD_ALL = ELM_GENLIST_ITEM_FIELD_ALL,
+ FIELD_TEXT = ELM_GENLIST_ITEM_FIELD_TEXT,
+ FIELD_CONTENT = ELM_GENLIST_ITEM_FIELD_CONTENT,
+ FIELD_STATE = ELM_GENLIST_ITEM_FIELD_STATE,
+ };
+
+ public:
+ using WidgetItem::WidgetItem;
+
+ void setSelectMode(SelectMode mode) const;
+ SelectMode getSelectMode() const;
+
+ void setSelected(bool isSelected) const;
+ bool isSelected() const;
+
+ void update() const;
+ void update(const Elm_Genlist_Item_Class *newItc) const;
+ void update(const char *parts, int fields = FIELD_ALL) const;
+ };
+}
+
+#include "GenlistItem.hpp"
+
+#endif // __UCL_GUI_GENLIST_ITEM_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.
+ */
+
+namespace ucl {
+
+ inline void GenlistItem::setSelectMode(const SelectMode mode) const
+ {
+ elm_genlist_item_select_mode_set(getIt(),
+ static_cast<Elm_Object_Select_Mode>(mode));
+ }
+
+ inline GenlistItem::SelectMode GenlistItem::getSelectMode() const
+ {
+ return static_cast<GenlistItem::SelectMode>(
+ elm_genlist_item_select_mode_get(getIt()));
+ }
+
+ inline void GenlistItem::setSelected(const bool isSelected) const
+ {
+ elm_genlist_item_selected_set(getIt(), toEina(isSelected));
+ }
+
+ inline bool GenlistItem::isSelected() const
+ {
+ return elm_genlist_item_selected_get(getIt());
+ }
+
+ inline void GenlistItem::update() const
+ {
+ elm_genlist_item_update(getIt());
+ }
+
+ inline void GenlistItem::update(
+ const Elm_Genlist_Item_Class *const newItc) const
+ {
+ elm_genlist_item_item_class_update(getIt(), newItc);
+ }
+
+ inline void GenlistItem::update(
+ const char *const parts, const int fields) const
+ {
+ elm_genlist_item_fields_update(getIt(), parts,
+ static_cast<Elm_Genlist_Item_Field_Type>(fields));
+ }
+}
class Layout : public EdjeWidget {
public:
- class Builder {
+ class Builder final {
public:
Builder();
Builder &setTheme(const LayoutTheme &value);
class Naviframe final : public StyledWidget {
public:
- class Builder {
+ class Builder final {
public:
Builder();
Builder &setStyle(ElmStyle value);
private:
Evas_Object *m_eo;
EventProxies m_eventProxies;
- bool m_isOwner: 1;
- bool m_isBoundToEo: 1;
- bool m_isEoRefKept: 1;
- bool m_isSelfRefKept: 1;
- bool m_isSelfRefUnique: 1;
+ WidgetSRef m_selfRef;
+ bool m_isOwner;
+ bool m_isBoundToEo;
+ bool m_isEoRefKept;
+ bool m_isSelfRefUnique;
};
// Non-member functions //
BASIC = ELM_WIN_BASIC
};
- class Builder {
+ class Builder final {
public:
Builder();
// Widget casting functions from Evas_Object //
template <class WIDGET_TYPE>
- inline auto staticCast(Evas_Object *eo) ->
+ inline auto staticWidgetCast(Evas_Object *eo) ->
decltype(static_cast<WIDGET_TYPE *>(asWidget(eo)))
{
return static_cast<WIDGET_TYPE *>(asWidget(eo));
}
template <class WIDGET_TYPE>
- inline auto staticCast(const Evas_Object *eo) ->
+ inline auto staticWidgetCast(const Evas_Object *eo) ->
decltype(static_cast<WIDGET_TYPE *>(asWidget(eo)))
{
return static_cast<WIDGET_TYPE *>(asWidget(eo));
}
template <class WIDGET_TYPE>
- inline auto dynamicCast(Evas_Object *eo) ->
+ inline auto dynamicWidgetCast(Evas_Object *eo) ->
decltype(dynamic_cast<WIDGET_TYPE *>(asWidget(eo)))
{
return dynamic_cast<WIDGET_TYPE *>(asWidget(eo));
}
template <class WIDGET_TYPE>
- inline auto dynamicCast(const Evas_Object *eo) ->
+ inline auto dynamicWidgetCast(const Evas_Object *eo) ->
decltype(dynamic_cast<WIDGET_TYPE *>(asWidget(eo)))
{
return dynamic_cast<WIDGET_TYPE *>(asWidget(eo));
}
template <class WIDGET_TYPE>
- inline auto staticRefCast(Evas_Object *eo) ->
- decltype(asShared(staticCast<WIDGET_TYPE>(eo)))
+ inline auto staticWidgetRefCast(Evas_Object *eo) ->
+ decltype(asShared(staticWidgetCast<WIDGET_TYPE>(eo)))
{
- return asShared(staticCast<WIDGET_TYPE>(eo));
+ return asShared(staticWidgetCast<WIDGET_TYPE>(eo));
}
template <class WIDGET_TYPE>
- inline auto staticRefCast(const Evas_Object *eo) ->
- decltype(asShared(staticCast<WIDGET_TYPE>(eo)))
+ inline auto staticWidgetRefCast(const Evas_Object *eo) ->
+ decltype(asShared(staticWidgetCast<WIDGET_TYPE>(eo)))
{
- return asShared(staticCast<WIDGET_TYPE>(eo));
+ return asShared(staticWidgetCast<WIDGET_TYPE>(eo));
}
template <class WIDGET_TYPE>
- inline auto dynamicRefCast(Evas_Object *eo) ->
- decltype(asShared(dynamicCast<WIDGET_TYPE>(eo)))
+ inline auto dynamicWidgetRefCast(Evas_Object *eo) ->
+ decltype(asShared(dynamicWidgetCast<WIDGET_TYPE>(eo)))
{
- return asShared(dynamicCast<WIDGET_TYPE>(eo));
+ return asShared(dynamicWidgetCast<WIDGET_TYPE>(eo));
}
template <class WIDGET_TYPE>
- inline auto dynamicRefCast(const Evas_Object *eo) ->
- decltype(asShared(dynamicCast<WIDGET_TYPE>(eo)))
+ inline auto dynamicWidgetRefCast(const Evas_Object *eo) ->
+ decltype(asShared(dynamicWidgetCast<WIDGET_TYPE>(eo)))
{
- return asShared(dynamicCast<WIDGET_TYPE>(eo));
+ return asShared(dynamicWidgetCast<WIDGET_TYPE>(eo));
}
}
#include "ucl/misc/Aspect.h"
#include "ucl/misc/TString.h"
+#include "ucl/misc/ConstCString.h"
#include "ucl/misc/Variant.h"
namespace ucl {
struct EoDataKey : Aspect<EoDataKey> { using Aspect::Aspect; };
+ // Delegates //
+
+ using SmartCbHandler = Delegate<void(Evas_Object *obj, void *eventInfo)>;
+
// WidgetEventHandler //
class Widget;
// AtspiGestureEventInfo //
- struct AtspiGestureEventInfo {
+ struct AtspiGestureEventInfo final {
Elm_Atspi_Gesture_Info gestureInfo;
bool preventDefault;
bool stopPropagation;
// LayoutTheme //
- struct LayoutTheme {
+ struct LayoutTheme final {
const char *klass;
const char *group;
const char *style;
explicit constexpr Aspect(const char *name);
constexpr operator const char *() const;
+
+ struct Hash final {
+ size_t operator()(const Aspect &key) const;
+ };
};
// Non-member functions //
namespace ucl {
+ // Aspect<CHILD>::Hash //
+
+ template <class CHILD>
+ size_t Aspect<CHILD>::Hash::operator()(const Aspect<CHILD> &key) const
+ {
+ constexpr size_t PRIME = 31;
+ size_t result = 0;
+ for (size_t i = 0; (key.name[i] != '\0'); ++i) {
+ result *= PRIME;
+ result += key.name[i];
+ }
+ return result;
+ }
+
+ // Aspect<CHILD> //
+
template <class CHILD>
constexpr Aspect<CHILD>::Aspect() :
name(nullptr)
--- /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_MISC_CSTRING_H__
+#define __UCL_MISC_CSTRING_H__
+
+#include "ucl/util/types.h"
+
+namespace ucl {
+
+ class CString final : public NonCopyable {
+ public:
+ friend void swap(CString &x, CString &y) noexcept;
+
+ static CString dup(const char *ptr);
+ static CString takeover(char *ptr) noexcept;
+
+ CString() noexcept;
+ CString(std::nullptr_t) noexcept;
+ CString(CString &&s) noexcept;
+ CString(const std::string &s);
+ ~CString() noexcept;
+
+ CString &operator=(CString s) noexcept;
+
+ bool isEmpty() const;
+
+ char *release() noexcept;
+
+ char *get() const noexcept;
+
+ private:
+ explicit CString(char *ptr) noexcept;
+
+ private:
+ char *m_ptr;
+ };
+}
+
+#include "CString.hpp"
+
+#endif // __UCL_MISC_CSTRING_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/util/helpers.h"
+
+namespace ucl {
+
+ // CString //
+
+ inline CString CString::dup(const char *const ptr)
+ {
+ return CString(strDupSafe(ptr));
+ }
+
+ inline CString CString::takeover(char *const ptr) noexcept
+ {
+ return CString(ptr);
+ }
+
+ inline CString::CString(char *const ptr) noexcept :
+ m_ptr(ptr)
+ {
+ }
+
+ inline CString::CString() noexcept :
+ m_ptr(nullptr)
+ {
+ }
+
+ inline CString::CString(std::nullptr_t) noexcept :
+ CString()
+ {
+ }
+
+ inline CString::CString(CString &&s) noexcept :
+ m_ptr(s.m_ptr)
+ {
+ s.m_ptr = nullptr;
+ }
+
+ inline CString::CString(const std::string &s) :
+ m_ptr(s.empty() ? nullptr : strdup(s.c_str()))
+ {
+ }
+
+ inline CString::~CString() noexcept
+ {
+ free(m_ptr);
+ }
+
+ inline CString &CString::operator=(CString s) noexcept
+ {
+ swap(*this, s);
+ return *this;
+ }
+
+ inline bool CString::isEmpty() const
+ {
+ return !m_ptr;
+ }
+
+ inline char *CString::release() noexcept
+ {
+ char *const result = m_ptr;
+ m_ptr = nullptr;
+ return result;
+ }
+
+ inline char *CString::get() const noexcept
+ {
+ return m_ptr;
+ }
+
+ // Non-member functions //
+
+ inline void swap(CString &x, CString &y) noexcept
+ {
+ std::swap(x.m_ptr, y.m_ptr);
+ }
+}
--- /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_MISC_CONST_CSTRING_H__
+#define __UCL_MISC_CONST_CSTRING_H__
+
+#include "CString.h"
+
+namespace ucl {
+
+ class ConstCString final : public NonCopyable {
+ public:
+ friend void swap(ConstCString &x, ConstCString &y) noexcept;
+
+ static ConstCString wrap(const char *ptr) noexcept;
+
+ ConstCString() noexcept;
+ ConstCString(std::nullptr_t) noexcept;
+ ConstCString(ConstCString &&s) noexcept;
+ ConstCString(CString &&s) noexcept;
+ ~ConstCString() noexcept;
+
+ ConstCString &operator=(ConstCString s) noexcept;
+
+ bool isEmpty() const;
+
+ const char *get() const noexcept;
+
+ private:
+ explicit ConstCString(const char *ptr) noexcept;
+
+ private:
+ const char *m_ptr;
+ bool m_isOwner;
+ };
+}
+
+#include "ConstCString.hpp"
+
+#endif // __UCL_MISC_CONST_CSTRING_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.
+ */
+
+namespace ucl {
+
+ // ConstCString //
+
+ inline ConstCString ConstCString::wrap(const char *ptr) noexcept
+ {
+ return ConstCString(ptr);
+ }
+
+ inline ConstCString::ConstCString(const char *ptr) noexcept :
+ m_ptr(ptr),
+ m_isOwner(false)
+ {
+ }
+
+ inline ConstCString::ConstCString() noexcept :
+ m_ptr(nullptr),
+ m_isOwner(false)
+ {
+ }
+
+ inline ConstCString::ConstCString(std::nullptr_t) noexcept :
+ ConstCString()
+ {
+ }
+
+ inline ConstCString::ConstCString(ConstCString &&s) noexcept :
+ m_ptr(s.m_ptr),
+ m_isOwner(s.m_isOwner)
+ {
+ s.m_isOwner = false;
+ }
+
+ inline ConstCString::ConstCString(CString &&s) noexcept :
+ m_ptr(s.release()),
+ m_isOwner(true)
+ {
+ }
+
+ inline ConstCString::~ConstCString() noexcept
+ {
+ if (m_isOwner) {
+ free(const_cast<char *>(m_ptr));
+ }
+ }
+
+ inline ConstCString &ConstCString::operator=(ConstCString s) noexcept
+ {
+ swap(*this, s);
+ return *this;
+ }
+
+ inline bool ConstCString::isEmpty() const
+ {
+ return !m_ptr;
+ }
+
+ inline const char *ConstCString::get() const noexcept
+ {
+ return m_ptr;
+ }
+
+ // Non-member functions //
+
+ inline void swap(ConstCString &x, ConstCString &y) noexcept
+ {
+ std::swap(x.m_ptr, y.m_ptr);
+ std::swap(x.m_isOwner, y.m_isOwner);
+ }
+}
namespace ucl {
template <class DELEGATE>
- class Event {
+ class Event final {
public:
Event();
using VarDict = Dict<Variant>;
template <class KEY, class VALUE>
- class HashMap {
+ class HashMap final {
public:
template <class VALUE2>
HashMap &set(const KEY &key, VALUE2 &&value);
bool get(const KEY &key, VALUE2 &value) const;
VALUE get(const KEY &key) const;
+ void clear();
+
private:
template <class ENUM_CLASS>
- struct EnumClassHash {
+ struct EnumClassHash final {
size_t operator()(ENUM_CLASS key) const {
return static_cast<size_t>(key);
}
};
- using Hash = typename std::conditional<std::is_enum<KEY>::value,
- EnumClassHash<KEY>, std::hash<KEY>>::type;
+ template <class KEY2, class = void>
+ struct GetHash final {
+ using Type = std::hash<KEY2>;
+ };
+
+ template <class KEY2>
+ struct GetHash<KEY2, typename std::enable_if<
+ std::is_enum<KEY2>::value>::type> {
+ using Type = EnumClassHash<KEY2>;
+ };
+
+ template <class KEY2>
+ struct GetHash<KEY2, typename std::enable_if<
+ std::is_class<typename KEY2::Hash>::value>::type> {
+ using Type = typename KEY2::Hash;
+ };
+
+ using Hash = typename GetHash<KEY>::Type;
private:
std::unordered_map<KEY, VALUE, Hash> m_map;
template <class KEY, class VALUE>
template <class VALUE2>
- HashMap<KEY, VALUE> &HashMap<KEY, VALUE>::
+ inline HashMap<KEY, VALUE> &HashMap<KEY, VALUE>::
set(const KEY &key, VALUE2 &&value)
{
m_map.emplace(key, std::forward<VALUE2>(value));
}
template <class KEY, class VALUE>
- HashMap<KEY, VALUE> &HashMap<KEY, VALUE>::
+ inline HashMap<KEY, VALUE> &HashMap<KEY, VALUE>::
unset(const KEY &key)
{
m_map.erase(key);
template <class KEY, class VALUE>
template <class VALUE2>
- bool HashMap<KEY, VALUE>::
+ inline bool HashMap<KEY, VALUE>::
get(const KEY &key, VALUE2 &value) const
{
const auto it = m_map.find(key);
}
template <class KEY, class VALUE>
- VALUE HashMap<KEY, VALUE>::
+ inline VALUE HashMap<KEY, VALUE>::
get(const KEY &key) const
{
const auto it = m_map.find(key);
}
return it->second;
}
+
+ template <class KEY, class VALUE>
+ inline void HashMap<KEY, VALUE>::clear()
+ {
+ m_map.clear();
+ }
}
class RefCountAware : public Polymorphic {
public:
bool isShared() const;
+ UInt getUseCount() const;
+ const void *getObjPtr() const;
template <class T>
SharedRef<T> asSharedThis(T *thisAlias) const;
// Signal to RefCountObj<T, C> to pass IRefCountObj to constructor
enum { _IS_REF_COUNT_AWARE };
- protected:
+ private:
IRefCountObj *const m_rc;
};
return !!m_rc;
}
+ inline UInt RefCountAware::getUseCount() const
+ {
+ if (!isShared()) {
+ UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
+ return 0;
+ }
+ return m_rc->getUseCount();
+ }
+
+ inline const void *RefCountAware::getObjPtr() const
+ {
+ if (!isShared()) {
+ UCL_ELOG("NOT SHARED: %s", typeid(*this).name());
+ return nullptr;
+ }
+ return m_rc->getObjPtr();
+ }
+
template <class T>
inline SharedRef<T> RefCountAware::asSharedThis(T *const thisAlias) const
{
namespace ucl {
- class TString {
+ class TString final {
public:
TString();
#include <vector>
#include <initializer_list>
-#include "ucl/util/types.h"
+#include "ConstCString.h"
namespace ucl {
template <size_t N>
using VarArray = std::array<Variant, N>;
- struct VarInitList {
+ struct VarInitList final {
VarInitList(const std::initializer_list<Variant> &il) : il(il) {}
const std::initializer_list<Variant> &il;
};
- class Variant {
+ class Variant final {
public:
enum Type {
TYPE_NIL,
TYPE_ARRAY
};
- private:
- // Helper to wrap "const char *" and manage its lifetime
- class CStr : NonCopyable {
- public:
- CStr(const char *ptr);
- CStr(const char *ptr, bool isOwner) noexcept;
- CStr(CStr &&s);
- ~CStr() noexcept;
- const char *get() const noexcept;
- operator const char *() const noexcept;
- private:
- const char *const m_ptr;
- bool m_isOwner;
- };
-
public:
friend void swap(Variant &x, Variant &y) noexcept;
float asFloat() const noexcept;
double asDouble() const noexcept;
- CStr asString() const noexcept;
+ ConstCString asString() const noexcept;
Variant *asArray() noexcept;
const Variant *asArray() const noexcept;
namespace ucl {
- // Variant::CStr //
-
- inline Variant::CStr::CStr(const char *const ptr) :
- m_ptr(strdup(ptr)),
- m_isOwner(true)
- {
- }
-
- inline Variant::CStr::CStr(const char *const ptr,
- const bool isOwner) noexcept :
- m_ptr(ptr),
- m_isOwner(isOwner)
- {
- }
-
- inline Variant::CStr::CStr(CStr &&s) :
- m_ptr(s.m_ptr),
- m_isOwner(s.m_isOwner)
- {
- s.m_isOwner = false;
- }
-
- inline Variant::CStr::~CStr() noexcept
- {
- if (m_isOwner) {
- free(const_cast<char *>(m_ptr));
- }
- }
-
- inline const char *Variant::CStr::get() const noexcept
- {
- return m_ptr;
- }
-
- inline Variant::CStr::operator const char *() const noexcept
- {
- return m_ptr;
- }
-
// Variant //
inline Variant::Variant() noexcept :
--- /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 final {
+ 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_LIST_ITEM_PRESENTER_H__
+#define __UCL_MVP_LIST_ITEM_PRESENTER_H__
+
+#include "ucl/gui/GenlistItem.h"
+
+#include "ucl/misc/HashMap.h"
+
+#include "types.h"
+
+namespace ucl {
+
+ UCL_DECLARE_REF_ALIASES(ListItemPresenter);
+
+ class ListItemPresenter : public RefCountAware,
+ public IDisposable {
+ public:
+ // IDisposable //
+
+ virtual void dispose() final override;
+ virtual bool isDisposed() const final override;
+
+ protected:
+ friend class ListPresenter;
+
+ UCL_DECLARE_REF_ALIASES(ItemClass);
+ UCL_DECLARE_REF_ALIASES(ItemClassCache);
+
+ // Flags
+ enum {
+ PF_AUTO_UNSELECT = 1
+ };
+
+ struct ItemInsertionParams {
+ ElmStyle itemStyle;
+ GenlistItem::Type itemType;
+
+ ItemInsertionParams(ElmStyle itemStyle,
+ GenlistItem::Type itemType = GenlistItem::Type::SIMPLE) :
+ itemStyle(itemStyle), itemType(itemType) {}
+ };
+
+ class ItemClass final : public NonCopyable {
+ public:
+ static ItemClassSRef newInstance(ElmStyle itemStyle);
+ public:
+ Elm_Genlist_Item_Class *get();
+ private:
+ friend class ReffedObj<ItemClass>;
+ ItemClass(ElmStyle itemStyle);
+ ~ItemClass();
+ private:
+ Elm_Genlist_Item_Class *const m_itc;
+ };
+
+ class ItemClassCache final : public NonCopyable {
+ public:
+ ItemClassSRef getItemClass(ElmStyle itemStyle);
+ void purge();
+ private:
+ HashMap<ElmStyle, ItemClassSRef> m_itcMap;
+ };
+
+ protected:
+ ListItemPresenter(IRefCountObj &rc);
+ virtual ~ListItemPresenter();
+
+ void setFlags(int flags);
+ int getFlags() const;
+
+ bool isActive() const;
+
+ GenlistItem getItem();
+ ItemClassCacheSRef getItemClassCache();
+
+ Result updateItemStyle(ElmStyle newItemStyle);
+
+ virtual ItemInsertionParams getItemInsertionParams() = 0;
+
+ virtual void onItemAttached();
+ virtual void onItemDetached();
+
+ virtual CString getItemPartText(EdjePart part);
+ virtual WidgetSRef getItemPartContent(EdjePart part);
+ virtual bool getItemPartState(EdjePart part);
+
+ virtual void onItemSelected();
+ virtual void onItemRealized();
+ virtual void onItemUnrealized();
+ virtual void onItemHighlighted();
+ virtual void onItemUnhighlighted();
+
+ private:
+ void attachItem(GenlistItem item,
+ const ItemClassCacheSRef &itcCache,
+ const SharedRef<bool> &isActiveRef);
+
+ void deleteDetachedItem(bool silent = false);
+ void detachItem(bool silent = false);
+
+ void onItemSelectedHook();
+ void onItemDel(Evas_Object *obj, void *eventInfo);
+
+ private:
+ ListItemPresenterSRef m_selfRef;
+ GenlistItem m_item;
+ ItemClassCacheWRef m_itcCache;
+ SharedRef<bool> m_isActiveRef;
+ int m_flags;
+ };
+}
+
+#endif // __UCL_MVP_LIST_ITEM_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_LIST_PRESENTER_H__
+#define __UCL_MVP_LIST_PRESENTER_H__
+
+#include "ucl/gui/Genlist.h"
+
+#include "GuiPresenter.h"
+#include "ListItemPresenter.h"
+
+namespace ucl {
+
+ UCL_DECLARE_REF_ALIASES(ListPresenter);
+
+ class ListPresenter final : public GuiPresenter {
+ public:
+ enum {
+ FLAG_HOMOGENEOUS = (1 << 0),
+ FLAG_CALC_X_MIN = (1 << 1),
+ FLAG_CALC_Y_MIN = (1 << 2),
+
+ FLAG_NOTIFY_REALIZED = (1 << 8),
+ FLAG_NOTIFY_UNREALIZED = (1 << 9),
+ FLAG_NOTIFY_HIGHLIGHTED = (1 << 10),
+ FLAG_NOTIFY_UNHIGHLIGHTED = (1 << 11),
+ };
+
+ class Builder final {
+ public:
+ Builder();
+ Builder &setStyle(ElmStyle style);
+ Builder &setFlags(int flags);
+ Builder &setParentWidget(const ElmWidgetSRef &parentWidget);
+ ListPresenterSRef build(GuiPresenter &parent) const;
+ private:
+ ucl::ElmWidgetSRef m_parentWidget;
+ ElmStyle m_style;
+ int m_flags;
+ };
+
+ public:
+ Genlist &getWidget();
+
+ void clear();
+
+ Result append(ListItemPresenter &itemPresenter,
+ ListItemPresenter *parent = nullptr);
+
+ Result prepend(ListItemPresenter &itemPresenter,
+ ListItemPresenter *parent = nullptr);
+
+ Result insertAfter(const ListItemPresenter &after,
+ ListItemPresenter &itemPresenter,
+ ListItemPresenter *parent = nullptr);
+
+ Result insertBefore(const ListItemPresenter &before,
+ ListItemPresenter &itemPresenter,
+ ListItemPresenter *parent = nullptr);
+
+ private:
+ friend class ReffedObj<ListPresenter>;
+ ListPresenter(IRefCountObj &rc);
+ virtual ~ListPresenter();
+
+ Result prepare(GuiPresenter &parent, ElmWidget &parentWidget,
+ ElmStyle style, int flags);
+
+ template <class INSERT_FUNC>
+ Result insert(ListItemPresenter &itemPresenter,
+ ListItemPresenter *parent,
+ INSERT_FUNC &&insertFunc);
+
+ template <class INSERT_FUNC>
+ Result insertRelative(const ListItemPresenter &relative,
+ ListItemPresenter &itemPresenter,
+ ListItemPresenter *parent, INSERT_FUNC &&insertFunc);
+
+ void setIsActiveRef(bool value);
+
+ void onItemSelected(Widget &widget, void *eventInfo);
+
+ void onItemRealized(Widget &widget, void *eventInfo);
+ void onItemUnrealized(Widget &widget, void *eventInfo);
+ void onItemHighlighted(Widget &widget, void *eventInfo);
+ void onItemUnhighlighted(Widget &widget, void *eventInfo);
+
+ // GuiPresenter //
+
+ virtual void onActivate() final override;
+ virtual void onDeactivate() final override;
+
+ private:
+ GenlistSRef m_genlist;
+ ListItemPresenter::ItemClassCacheSRef m_itcCache;
+ SharedRef<bool> m_isActiveRef;
+ };
+}
+
+#endif // __UCL_MVP_LIST_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__
friend class WeakRef;
public:
- int getUseCount() const noexcept;
+ UInt getUseCount() const noexcept;
protected:
constexpr BaseRef() noexcept;
}
template <class T>
- inline int BaseRef<T>::getUseCount() const noexcept
+ inline UInt BaseRef<T>::getUseCount() const noexcept
{
return (m_rc ? m_rc->getUseCount() : 0);
}
virtual bool refNz() noexcept = 0;
virtual void refWeak() noexcept = 0;
virtual void unrefWeak() noexcept = 0;
- virtual unsigned getUseCount() const noexcept = 0;
+ virtual UInt getUseCount() const noexcept = 0;
virtual const void *getObjPtr() const noexcept = 0;
protected:
virtual ~IRefCountObj() = default;
virtual bool refNz() noexcept final override;
virtual void refWeak() noexcept final override;
virtual void unrefWeak() noexcept final override;
- virtual unsigned getUseCount() const noexcept final override;
+ virtual UInt getUseCount() const noexcept final override;
virtual const void *getObjPtr() const noexcept final override;
private:
}
template <class T, class C>
- inline unsigned RefCountObj<T, C>::getUseCount() const noexcept
+ inline UInt RefCountObj<T, C>::getUseCount() const noexcept
{
return m_useCounter.get();
}
namespace ucl {
- class CondVar : public NonCopyable {
+ class CondVar final : public NonCopyable {
public:
CondVar();
~CondVar();
namespace ucl {
- class Mutex : public NonCopyable {
+ class Mutex final : public NonCopyable {
public:
Mutex(bool recursive = false);
~Mutex();
namespace ucl {
- class MutexLock : public NonCopyable {
+ class MutexLock final : public NonCopyable {
public:
MutexLock(Mutex &mutex);
~MutexLock();
// ResultData declaration //
- struct ResultData {
+ struct ResultData final {
const char *name;
int logPrio;
};
// Result declaration //
- struct Result {
+ struct Result final {
int value;
Result() = default;
};
template <class PRODUCT, class IPRODUCT>
- class Factory : public IFactory<IPRODUCT> {
+ class Factory final : public IFactory<IPRODUCT> {
public:
using Product = PRODUCT;
public:
}
if (appParams.get(AppParam::ACCELERATION_PREFERENECE, paramValue)) {
- const char *const accelPreference = paramValue.asString();
+ const auto accelPreference = paramValue.asString();
if (isEmpty(accelPreference)) {
LOG_RETURN(RES_INVALID_DATA,
"Invalid parameter ACCELERATION_PREFERENECE: %s",
- accelPreference);
+ accelPreference.get());
}
- elm_config_accel_preference_set(accelPreference);
+ elm_config_accel_preference_set(accelPreference.get());
}
return RES_OK;
m_window = Window::Builder().
setType(winType).
- setName({paramValue.asString()}).
+ setName(paramValue.asString().get()).
setIsOwner(true).
build();
if (!m_window) {
Window *ElmWidget::getWindow() const
{
- return dynamicCast<Window>(getTopWidget());
+ return dynamicWidgetCast<Window>(getTopWidget());
}
}
--- /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/gui/Genlist.h"
+
+#include "common.h"
+
+namespace ucl {
+
+ // Genlist::Builder //
+
+ GenlistSRef Genlist::Builder::build(ElmWidget &parent) const
+ {
+ Evas_Object *const eo = elm_genlist_add(parent);
+ if (!eo) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "elm_genlist_add() failed!");
+ }
+
+ auto result = makeShared<Genlist>(eo, m_isOwner);
+
+ if (m_needBindToEo) {
+ result->bindToEo();
+ }
+
+ if (isValid(m_style)) {
+ result->setStyle(m_style);
+ }
+
+ result->setMode(m_mode);
+ result->setHomogeneous(m_isHomogeneous);
+
+ show(*result);
+
+ return result;
+ }
+}
void NaviItem::popTo() const
{
- const auto navi = dynamicCast<Naviframe>(getWidget());
+ const auto navi = dynamicWidgetCast<Naviframe>(getWidget());
const bool needStartTransition =
(navi && (navi->getTopItem() != *this));
void NaviItem::promote() const
{
- const auto navi = dynamicCast<Naviframe>(getWidget());
+ const auto navi = dynamicWidgetCast<Naviframe>(getWidget());
const bool needStartTransition =
(navi && (navi->getTopItem() != *this));
m_isOwner(isOwner),
m_isBoundToEo(false),
m_isEoRefKept(false),
- m_isSelfRefKept(false),
m_isSelfRefUnique(false)
{
UCL_ASSERT(m_eo, "m_eo is NULL!");
- if (m_rc) {
+ if (isShared()) {
evas_object_event_callback_priority_add(m_eo, EVAS_CALLBACK_DEL,
EO_CALLBACK_PRIORITY_AFTER,
CALLBACK_A(Widget::onEoDel), this);
unbindFromEo();
}
- if (m_rc) {
+ if (isShared()) {
evas_object_event_callback_del_full(m_eo, EVAS_CALLBACK_DEL,
CALLBACK_A(Widget::onEoDel), this);
}
{
updateEoRef();
- if (m_rc) {
+ if (isShared()) {
updateSelfRef();
}
}
void Widget::updateSelfRef()
{
- if (needKeepSelfRef()) {
- if (!m_isSelfRefKept) {
- m_isSelfRefKept = true;
- m_rc->ref();
- }
- } else if (m_isSelfRefKept) {
- m_isSelfRefKept = false;
- m_rc->unref();
+ if (!needKeepSelfRef()) {
+ m_selfRef.reset();
+ } else if (!m_selfRef) {
+ m_selfRef = asShared(*this);
}
}
void Widget::onEoDel(Evas *e, Evas_Object *obj, void *event_info)
{
- if (!m_isSelfRefKept) {
- FLOG("UNEXPECTED! m_isSelfRefKept: %d;", m_isSelfRefKept);
+ if (!m_selfRef) {
+ FLOG("UNEXPECTED! m_selfRef is NULL!");
m_eo = nullptr;
return;
}
m_isOwner, m_isEoRefKept, m_isSelfRefUnique);
m_eo = nullptr;
}
- m_isSelfRefKept = false;
- m_rc->unref();
+ m_selfRef.reset();
}
void Widget::onUniqueChanged(bool isUnique)
{
if (aString) {
const int realLength = ((length < 0) ? strlen(aString) : length);
- const UInt size = (realLength + 1);
- if (size <= sizeof(m_aSmallStr.buffer)) {
- strncpy(m_aSmallStr.buffer, aString, size);
+ if (realLength < sizeof(m_aSmallStr.buffer)) {
+ strncpy(m_aSmallStr.buffer, aString, realLength);
+ m_aSmallStr.buffer[realLength] = '\0';
m_type |= impl::FLAG_SMALL_STR;
} else {
m_aString.data = strndup(aString, realLength);
return 0.0;
}
- Variant::CStr Variant::asString() const noexcept
+ ConstCString Variant::asString() const noexcept
{
char strBuff[impl::TMP_STR_BUFF_SIZE] = {};
switch (m_type) {
case TYPE_NIL:
- return {"", false};
+ return ConstCString::wrap("");
case TYPE_BOOLEAN:
- return {(m_aBool.value ? "true" : "false"), false};
+ return ConstCString::wrap(m_aBool.value ? "true" : "false");
case TYPE_INTEGER:
snprintf(strBuff, sizeof(strBuff), "%d", m_anInt.value);
break;
snprintf(strBuff, sizeof(strBuff), "%f", m_aDouble.value);
break;
case impl::TYPE_SMALL_STR:
- return m_aSmallStr.buffer;
+ return ConstCString::wrap(m_aSmallStr.buffer);
case TYPE_STRING:
- return {m_aString.data, false};
+ return ConstCString::wrap(m_aString.data);
case TYPE_ARRAY:
snprintf(strBuff, sizeof(strBuff), "%d", m_anArray.length);
break;
}
- return strBuff;
+ return CString::dup(strBuff);
}
// Non-member functions //
--- /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(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(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, getObjPtr());
+ }
+
+ void GuiPresenter::sendDeactivate(Widget &sender)
+ {
+ sendDeactivator(sender, impl::DEACTIVATE_BY, getObjPtr());
+ }
+
+ void GuiPresenter::broadcastActivate()
+ {
+ broadcastDeactivator(impl::ACTIVATE_BY, getObjPtr());
+ }
+
+ void GuiPresenter::broadcastDeactivate()
+ {
+ broadcastDeactivator(impl::DEACTIVATE_BY, 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.
+ */
+
+#include "ucl/mvp/ListItemPresenter.h"
+
+#include "common.h"
+
+namespace ucl {
+
+ // ListItemPresenter::ItemClass //
+
+ ListItemPresenter::ItemClassSRef ListItemPresenter::ItemClass::
+ newInstance(const ElmStyle itemStyle)
+ {
+ auto result = makeShared<ItemClass>(itemStyle);
+ if (!result->get()) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Failed to create ItemClass()!");
+ }
+ return result;
+ }
+
+ ListItemPresenter::ItemClass::ItemClass(const ElmStyle itemStyle) :
+ m_itc(elm_genlist_item_class_new())
+ {
+ if (!m_itc) {
+ return;
+ }
+
+ m_itc->item_style = itemStyle.name;
+
+ m_itc->func.text_get =
+ [](void *data, Evas_Object *obj, const char *part) -> char *
+ {
+ if (!data) {
+ LOG_RETURN_VALUE(RES_FATAL, nullptr, "data is NULL");
+ }
+ return static_cast<ListItemPresenter *>(data)->
+ getItemPartText(EdjePart(part)).release();
+ };
+
+ m_itc->func.content_get =
+ [](void *data, Evas_Object *obj, const char *part) -> Evas_Object *
+ {
+ if (!data) {
+ LOG_RETURN_VALUE(RES_FATAL, nullptr, "data is NULL");
+ }
+ if (const auto widget = static_cast<ListItemPresenter *>(data)->
+ getItemPartContent(EdjePart(part))) {
+ widget->setIsOwner(false);
+ return widget->getEo();
+ }
+ return nullptr;
+ };
+
+ m_itc->func.state_get =
+ [](void *data, Evas_Object *obj, const char *part) -> Eina_Bool
+ {
+ if (!data) {
+ LOG_RETURN_VALUE(RES_FATAL, false, "data is NULL");
+ }
+ return static_cast<ListItemPresenter *>(data)->
+ getItemPartState(EdjePart(part));
+ };
+ }
+
+ ListItemPresenter::ItemClass::~ItemClass()
+ {
+ if (m_itc) {
+ elm_genlist_item_class_free(m_itc);
+ }
+ }
+
+ Elm_Genlist_Item_Class *ListItemPresenter::ItemClass::get()
+ {
+ return m_itc;
+ }
+
+ // ListItemPresenter::ItemClassCache //
+
+ ListItemPresenter::ItemClassSRef ListItemPresenter::ItemClassCache::
+ getItemClass(const ElmStyle itemStyle)
+ {
+ ItemClassSRef result;
+
+ if (!m_itcMap.get(itemStyle, result)) {
+ result = ItemClass::newInstance(itemStyle);
+ if (result) {
+ m_itcMap.set(itemStyle, result);
+ } else {
+ ELOG("ItemClass::newInstance() failed!");
+ }
+ }
+
+ return result;
+ }
+
+ void ListItemPresenter::ItemClassCache::purge()
+ {
+ m_itcMap.clear();
+ }
+
+ // ListItemPresenter //
+
+ ListItemPresenter::ListItemPresenter(IRefCountObj &rc) :
+ RefCountAware(&rc),
+ m_flags(PF_AUTO_UNSELECT)
+ {
+ }
+
+ ListItemPresenter::~ListItemPresenter()
+ {
+ if (m_item) {
+ FLOG("m_item is still alive!");
+ deleteDetachedItem(true);
+ }
+ }
+
+ void ListItemPresenter::attachItem(GenlistItem item,
+ const ItemClassCacheSRef &itcCache,
+ const SharedRef<bool> &isActiveRef)
+ {
+ if (!item) {
+ LOG_RETURN_VOID(RES_FAIL, "item is NULL!");
+ }
+
+ if (m_item) {
+ deleteDetachedItem();
+ }
+
+ m_item = item;
+ m_item.setData(this);
+ m_item.setDelCallback(CALLBACK_A(ListItemPresenter::onItemDel));
+
+ m_itcCache = itcCache;
+ m_isActiveRef = isActiveRef;
+
+ if (!m_selfRef) {
+ m_selfRef = asShared(*this);
+ }
+
+ onItemAttached();
+ }
+
+ void ListItemPresenter::deleteDetachedItem(const bool silent)
+ {
+ auto item = m_item;
+ detachItem(silent);
+ item.del();
+ }
+
+ void ListItemPresenter::detachItem(const bool silent)
+ {
+ m_item.setData(nullptr);
+ m_item.setDelCallback(nullptr);
+ m_item = nullptr;
+ if (!silent) {
+ onItemDetached();
+ }
+ }
+
+ void ListItemPresenter::onItemDel(Evas_Object *obj, void *eventInfo)
+ {
+ if (m_item) {
+ detachItem();
+ }
+ m_selfRef.reset();
+ }
+
+ void ListItemPresenter::setFlags(const int flags)
+ {
+ m_flags = flags;
+ }
+
+ int ListItemPresenter::getFlags() const
+ {
+ return m_flags;
+ }
+
+ bool ListItemPresenter::isActive() const
+ {
+ return (m_isActiveRef ? *m_isActiveRef : false);
+ }
+
+ GenlistItem ListItemPresenter::getItem()
+ {
+ return m_item;
+ }
+
+ ListItemPresenter::ItemClassCacheSRef
+ ListItemPresenter::getItemClassCache()
+ {
+ return m_itcCache.lock();
+ }
+
+ Result ListItemPresenter::updateItemStyle(const ElmStyle newItemStyle)
+ {
+ if (!m_item) {
+ LOG_RETURN(RES_ILLEGAL_STATE, "m_item is NULL!");
+ }
+
+ const auto itcCache = getItemClassCache();
+ if (!itcCache) {
+ LOG_RETURN(RES_FATAL, "itcCache is NULL!");
+ }
+
+ const auto itc = itcCache->getItemClass(newItemStyle);
+ if (!itc) {
+ LOG_RETURN(RES_FAIL, "itcCache.getItemClass() failed!");
+ }
+
+ m_item.update(itc->get());
+
+ return RES_OK;
+ }
+
+ void ListItemPresenter::dispose()
+ {
+ if (m_item) {
+ deleteDetachedItem();
+ m_selfRef.reset();
+ }
+ }
+
+ bool ListItemPresenter::isDisposed() const
+ {
+ return !m_item;
+ }
+
+ void ListItemPresenter::onItemAttached()
+ {
+ }
+
+ void ListItemPresenter::onItemDetached()
+ {
+ }
+
+ WidgetSRef ListItemPresenter::getItemPartContent(const EdjePart part)
+ {
+ return nullptr;
+ }
+
+ CString ListItemPresenter::getItemPartText(const EdjePart part)
+ {
+ return nullptr;
+ }
+
+ bool ListItemPresenter::getItemPartState(const EdjePart part)
+ {
+ return false;
+ }
+
+ void ListItemPresenter::onItemSelectedHook()
+ {
+ if (m_flags & PF_AUTO_UNSELECT) {
+ m_item.setSelected(false);
+ }
+ onItemSelected();
+ }
+
+ void ListItemPresenter::onItemSelected()
+ {
+ }
+
+ void ListItemPresenter::onItemRealized()
+ {
+ }
+
+ void ListItemPresenter::onItemUnrealized()
+ {
+ }
+
+ void ListItemPresenter::onItemHighlighted()
+ {
+ }
+
+ void ListItemPresenter::onItemUnhighlighted()
+ {
+ }
+}
--- /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/ListPresenter.h"
+
+#include "common.h"
+
+namespace ucl { namespace { namespace impl {
+
+ constexpr SmartEvent ITEM_SELECTED {"selected"};
+
+ constexpr SmartEvent ITEM_REALIZED {"realized"};
+ constexpr SmartEvent ITEM_UNREALIZED {"unrealized"};
+ constexpr SmartEvent ITEM_HIGHLIGHTED {"highlighted"};
+ constexpr SmartEvent ITEM_UNHIGHLIGHTED {"unhighlighted"};
+
+ ListItemPresenter *toItemPresenter(void *eventInfo)
+ {
+ if (!eventInfo) {
+ LOG_RETURN_VALUE(RES_FATAL, nullptr, "eventInfo is NULL");
+ }
+
+ const GenlistItem item{static_cast<Elm_Object_Item *>(eventInfo)};
+ const auto data = item.getData();
+ if (!data) {
+ LOG_RETURN_VALUE(RES_FATAL, nullptr, "data is NULL");
+ }
+
+ return static_cast<ListItemPresenter *>(data);
+ }
+}}}
+
+namespace ucl {
+
+ // ListPresenter::Builder //
+
+ ListPresenter::Builder::Builder() :
+ m_flags(FLAG_HOMOGENEOUS)
+ {
+ }
+
+ ListPresenter::Builder &ListPresenter::Builder::setStyle(
+ const ElmStyle style)
+ {
+ m_style = style;
+ return *this;
+ }
+
+ ListPresenter::Builder &ListPresenter::Builder::setFlags(const int flags)
+ {
+ m_flags = flags;
+ return *this;
+ }
+
+ ListPresenter::Builder &ListPresenter::Builder::setParentWidget(
+ const ElmWidgetSRef &parentWidget)
+ {
+ m_parentWidget = parentWidget;
+ return *this;
+ }
+
+ ListPresenterSRef ListPresenter::Builder::build(GuiPresenter &parent) const
+ {
+ if (!m_parentWidget) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+ "m_parentWidget is NULL!");
+ }
+
+ auto result = makeShared<ListPresenter>();
+
+ FAIL_RETURN_VALUE(result->prepare(
+ parent, *m_parentWidget, m_style, m_flags),
+ {}, "result->prepare() failed!");
+
+ return result;
+ }
+
+ // ListPresenter //
+
+ ListPresenter::ListPresenter(IRefCountObj &rc) :
+ GuiPresenter(rc)
+ {
+ }
+
+ ListPresenter::~ListPresenter()
+ {
+ }
+
+ Result ListPresenter::prepare(
+ GuiPresenter &parent, ElmWidget &parentWidget,
+ const ElmStyle style, const int flags)
+ {
+ FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
+ "GuiPresenter::prepare() failed!");
+
+ m_genlist = Genlist::Builder().
+ setStyle(style).
+ setMode(Genlist::Mode::COMPRESS).
+ setHomogeneous(flags & FLAG_HOMOGENEOUS).
+ setIsOwner(true).
+ setNeedBindToEo(true).
+ build(parentWidget);
+ if (!m_genlist) {
+ LOG_RETURN(RES_FAIL, "Genlist::build() failed!");
+ }
+
+ expandAndFill(*m_genlist);
+
+ // TODO Add Scroller widget.
+ elm_scroller_content_min_limit(*m_genlist,
+ toEina((flags & FLAG_CALC_X_MIN) != 0),
+ toEina((flags & FLAG_CALC_Y_MIN) != 0));
+
+ m_itcCache = makeShared<ListItemPresenter::ItemClassCache>();
+
+ m_isActiveRef = makeShared<bool>();
+ *m_isActiveRef = isActive();
+
+ m_genlist->addEventHandler(impl::ITEM_SELECTED, WEAK_DELEGATE(
+ ListPresenter::onItemSelected, asWeak(*this)));
+
+ if (flags & FLAG_NOTIFY_REALIZED) {
+ m_genlist->addEventHandler(impl::ITEM_REALIZED, WEAK_DELEGATE(
+ ListPresenter::onItemRealized, asWeak(*this)));
+ }
+ if (flags & FLAG_NOTIFY_UNREALIZED) {
+ m_genlist->addEventHandler(impl::ITEM_UNREALIZED, WEAK_DELEGATE(
+ ListPresenter::onItemUnrealized, asWeak(*this)));
+ }
+ if (flags & FLAG_NOTIFY_HIGHLIGHTED) {
+ m_genlist->addEventHandler(impl::ITEM_HIGHLIGHTED, WEAK_DELEGATE(
+ ListPresenter::onItemHighlighted, asWeak(*this)));
+ }
+ if (flags & FLAG_NOTIFY_UNHIGHLIGHTED) {
+ m_genlist->addEventHandler(impl::ITEM_UNHIGHLIGHTED, WEAK_DELEGATE(
+ ListPresenter::onItemUnhighlighted, asWeak(*this)));
+ }
+
+ return RES_OK;
+ }
+
+ Genlist &ListPresenter::getWidget()
+ {
+ return *m_genlist;
+ }
+
+ void ListPresenter::clear()
+ {
+ m_genlist->clear();
+ m_itcCache->purge();
+ }
+
+ Result ListPresenter::append(ListItemPresenter &itemPresenter,
+ ListItemPresenter *parent)
+ {
+ return insert(itemPresenter, parent,
+ [this](const Elm_Genlist_Item_Class *itc, const void *data,
+ GenlistItem parent, GenlistItem::Type type)
+ {
+ return m_genlist->append(itc, data, nullptr, type, parent);
+ });
+ }
+
+ Result ListPresenter::prepend(ListItemPresenter &itemPresenter,
+ ListItemPresenter *parent)
+ {
+ return insert(itemPresenter, parent,
+ [this](const Elm_Genlist_Item_Class *itc, const void *data,
+ GenlistItem parent, GenlistItem::Type type)
+ {
+ return m_genlist->prepend(itc, data, nullptr, type, parent);
+ });
+ }
+
+ Result ListPresenter::insertAfter(const ListItemPresenter &after,
+ ListItemPresenter &itemPresenter,
+ ListItemPresenter *parent)
+ {
+ return insertRelative(after, itemPresenter, parent,
+ [this](GenlistItem rel, const Elm_Genlist_Item_Class *itc,
+ const void *data, GenlistItem parent, GenlistItem::Type type)
+ {
+ return m_genlist->insertAfter(
+ rel, itc, data, nullptr, type, parent);
+ });
+ }
+
+ Result ListPresenter::insertBefore(const ListItemPresenter &before,
+ ListItemPresenter &itemPresenter,
+ ListItemPresenter *parent)
+ {
+ return insertRelative(before, itemPresenter, parent,
+ [this](GenlistItem rel, const Elm_Genlist_Item_Class *itc,
+ const void *data, GenlistItem parent, GenlistItem::Type type)
+ {
+ return m_genlist->insertBefore(
+ rel, itc, data, nullptr, type, parent);
+ });
+ }
+
+ template <class INSERT_FUNC>
+ Result ListPresenter::insert(ListItemPresenter &itemPresenter,
+ ListItemPresenter *parent, INSERT_FUNC &&insertFunc)
+ {
+ const auto params = itemPresenter.getItemInsertionParams();
+
+ const auto itc = m_itcCache->getItemClass(params.itemStyle);
+ if (!itc) {
+ LOG_RETURN(RES_FAIL, "m_itcCache.getItemClass() failed!");
+ }
+
+ GenlistItem parentItem;
+ if (parent) {
+ parentItem = parent->m_item;
+ if (!parentItem) {
+ ELOG("parentItem is NULL");
+ }
+ }
+
+ const auto item = insertFunc(itc->get(),
+ &itemPresenter, parentItem, params.itemType);
+ if (!item) {
+ LOG_RETURN(RES_FAIL, "insertFunc() failed!");
+ }
+
+ itemPresenter.attachItem(item, m_itcCache, m_isActiveRef);
+
+ return RES_OK;
+ }
+
+ template <class INSERT_FUNC>
+ Result ListPresenter::insertRelative(const ListItemPresenter &relative,
+ ListItemPresenter &itemPresenter, ListItemPresenter *parent,
+ INSERT_FUNC &&insertFunc)
+ {
+ const auto relItem = relative.m_item;
+ if (!relItem) {
+ LOG_RETURN(RES_FAIL, "relItem is NULL!");
+ }
+ if (relItem.getWidget() != m_genlist->getEo()) {
+ LOG_RETURN(RES_FAIL, "relItem has wrong genlist!");
+ }
+ return insert(itemPresenter, parent,
+ [relItem, &insertFunc](const Elm_Genlist_Item_Class *itc,
+ const void *data, GenlistItem parent, GenlistItem::Type type)
+ {
+ return insertFunc(relItem, itc, data, parent, type);
+ });
+ }
+
+ void ListPresenter::setIsActiveRef(const bool value)
+ {
+ if (!m_isActiveRef) {
+ LOG_RETURN_VOID(RES_FATAL, "m_isActiveRef is NULL");
+ }
+ *m_isActiveRef = value;
+ }
+
+ void ListPresenter::onItemSelected(Widget &widget, void *eventInfo)
+ {
+ const auto itemPresenter = impl::toItemPresenter(eventInfo);
+ if (!itemPresenter) {
+ LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
+ }
+ itemPresenter->onItemSelectedHook();
+ }
+
+ void ListPresenter::onItemRealized(Widget &widget, void *eventInfo)
+ {
+ const auto itemPresenter = impl::toItemPresenter(eventInfo);
+ if (!itemPresenter) {
+ LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
+ }
+ itemPresenter->onItemRealized();
+ }
+
+ void ListPresenter::onItemUnrealized(Widget &widget, void *eventInfo)
+ {
+ const auto itemPresenter = impl::toItemPresenter(eventInfo);
+ if (!itemPresenter) {
+ LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
+ }
+ itemPresenter->onItemUnrealized();
+ }
+
+ void ListPresenter::onItemHighlighted(Widget &widget, void *eventInfo)
+ {
+ const auto itemPresenter = impl::toItemPresenter(eventInfo);
+ if (!itemPresenter) {
+ LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
+ }
+ itemPresenter->onItemHighlighted();
+ }
+
+ void ListPresenter::onItemUnhighlighted(Widget &widget, void *eventInfo)
+ {
+ const auto itemPresenter = impl::toItemPresenter(eventInfo);
+ if (!itemPresenter) {
+ LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
+ }
+ itemPresenter->onItemUnhighlighted();
+ }
+
+ void ListPresenter::onActivate()
+ {
+ setIsActiveRef(true);
+ }
+
+ void ListPresenter::onDeactivate()
+ {
+ setIsActiveRef(false);
+ }
+}
--- /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__