summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Olshevskyi <i.olshevskyi@samsung.com>2017-07-11 07:45:57 +0300
committerIgor Olshevskyi <i.olshevskyi@samsung.com>2017-07-17 08:57:47 +0300
commit3fbf738e51d6e905272fc06ca379957e40f8a23d (patch)
tree36a086be83166e6f94f69e6c21a7b59d2ae90b41
parentdda636ff229af26d617b91d94d234723bd49b0e3 (diff)
downloadcall-ui-3fbf738e51d6e905272fc06ca379957e40f8a23d.tar.gz
call-ui-3fbf738e51d6e905272fc06ca379957e40f8a23d.tar.bz2
call-ui-3fbf738e51d6e905272fc06ca379957e40f8a23d.zip
TizenRefApp-8857 [Call UI] Update application with ucl::GuiPresenter
Change-Id: I7cd78c0224417cdcc3d889fd160b0fece100b89a
-rw-r--r--.cproject10
-rw-r--r--edc/call_info.edc15
-rw-r--r--inc/presenters/AcceptDialog.h7
-rw-r--r--inc/presenters/AcceptRejectPresenter.h8
-rw-r--r--inc/presenters/AccessoryPresenter.h8
-rw-r--r--inc/presenters/CallInfoPresenter.h12
-rw-r--r--inc/presenters/CallStatusPresenter.h8
-rw-r--r--inc/presenters/IndicatorPresenter.h11
-rw-r--r--inc/presenters/MainPage.h3
-rw-r--r--inc/presenters/MoreOptionsPresenter.h8
-rw-r--r--inc/presenters/MotionSensorPresenter.h3
-rw-r--r--inc/presenters/Page.h11
-rw-r--r--inc/presenters/Page.hpp6
-rw-r--r--inc/presenters/RejectMsgPresenter.h8
-rw-r--r--inc/presenters/types.h2
-rw-r--r--inc/view/helpers.h2
-rw-r--r--src/presenters/AcceptDialog.cpp8
-rw-r--r--src/presenters/AcceptRejectPresenter.cpp8
-rw-r--r--src/presenters/AccessoryPresenter.cpp8
-rw-r--r--src/presenters/CallInfoPresenter.cpp10
-rw-r--r--src/presenters/CallStatusPresenter.cpp8
-rw-r--r--src/presenters/IndicatorPresenter.cpp8
-rw-r--r--src/presenters/MoreOptionsPresenter.cpp8
-rw-r--r--src/presenters/Page.cpp6
-rw-r--r--src/presenters/RejectMsgPresenter.cpp8
-rw-r--r--src/view/helpers.cpp5
-rw-r--r--ucl/inc/ucl/appfw/SysEventProvider.h2
-rw-r--r--ucl/inc/ucl/appfw/UIApp.h2
-rw-r--r--ucl/inc/ucl/gui/Genlist.h92
-rw-r--r--ucl/inc/ucl/gui/Genlist.hpp132
-rw-r--r--ucl/inc/ucl/gui/GenlistItem.h63
-rw-r--r--ucl/inc/ucl/gui/GenlistItem.hpp58
-rw-r--r--ucl/inc/ucl/gui/Layout.h2
-rw-r--r--ucl/inc/ucl/gui/Naviframe.h2
-rw-r--r--ucl/inc/ucl/gui/Widget.h10
-rw-r--r--ucl/inc/ucl/gui/Window.h2
-rw-r--r--ucl/inc/ucl/gui/helpers.h32
-rw-r--r--ucl/inc/ucl/gui/types.h9
-rw-r--r--ucl/inc/ucl/misc/Aspect.h4
-rw-r--r--ucl/inc/ucl/misc/Aspect.hpp16
-rw-r--r--ucl/inc/ucl/misc/CString.h55
-rw-r--r--ucl/inc/ucl/misc/CString.hpp93
-rw-r--r--ucl/inc/ucl/misc/ConstCString.h53
-rw-r--r--ucl/inc/ucl/misc/ConstCString.hpp86
-rw-r--r--ucl/inc/ucl/misc/Event.h2
-rw-r--r--ucl/inc/ucl/misc/HashMap.h26
-rw-r--r--ucl/inc/ucl/misc/HashMap.hpp14
-rw-r--r--ucl/inc/ucl/misc/RefCountAware.h4
-rw-r--r--ucl/inc/ucl/misc/RefCountAware.hpp18
-rw-r--r--ucl/inc/ucl/misc/TString.h2
-rw-r--r--ucl/inc/ucl/misc/Variant.h23
-rw-r--r--ucl/inc/ucl/misc/Variant.hpp39
-rw-r--r--ucl/inc/ucl/mvp/GuiPresenter.h (renamed from inc/presenters/Presenter.h)52
-rw-r--r--ucl/inc/ucl/mvp/ListItemPresenter.h128
-rw-r--r--ucl/inc/ucl/mvp/ListPresenter.h113
-rw-r--r--ucl/inc/ucl/mvp/types.h22
-rw-r--r--ucl/inc/ucl/util/memory/BaseRef.h2
-rw-r--r--ucl/inc/ucl/util/memory/BaseRef.hpp2
-rw-r--r--ucl/inc/ucl/util/memory/IRefCountObj.h2
-rw-r--r--ucl/inc/ucl/util/memory/RefCountObj.h2
-rw-r--r--ucl/inc/ucl/util/memory/RefCountObj.hpp2
-rw-r--r--ucl/inc/ucl/util/threading/CondVar.h2
-rw-r--r--ucl/inc/ucl/util/threading/Mutex.h2
-rw-r--r--ucl/inc/ucl/util/threading/MutexLock.h2
-rw-r--r--ucl/inc/ucl/util/types/Result.h4
-rw-r--r--ucl/inc/ucl/util/types/classTypes.h2
-rw-r--r--ucl/src/appfw/UIApp.cpp8
-rw-r--r--ucl/src/gui/ElmWidget.cpp2
-rw-r--r--ucl/src/gui/Genlist.cpp48
-rw-r--r--ucl/src/gui/NaviItem.cpp4
-rw-r--r--ucl/src/gui/Widget.cpp26
-rw-r--r--ucl/src/misc/Variant.cpp18
-rw-r--r--ucl/src/mvp/GuiPresenter.cpp (renamed from src/presenters/Presenter.cpp)119
-rw-r--r--ucl/src/mvp/ListItemPresenter.cpp292
-rw-r--r--ucl/src/mvp/ListPresenter.cpp326
-rw-r--r--ucl/src/mvp/common.h22
76 files changed, 1928 insertions, 314 deletions
diff --git a/.cproject b/.cproject
index c8bc4cf..c3ed9e8 100644
--- a/.cproject
+++ b/.cproject
@@ -25,12 +25,12 @@
<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="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
@@ -147,12 +147,12 @@
</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="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
@@ -357,7 +357,7 @@
<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">
diff --git a/edc/call_info.edc b/edc/call_info.edc
index 2186773..f6d5862 100644
--- a/edc/call_info.edc
+++ b/edc/call_info.edc
@@ -345,6 +345,21 @@ group { "elm/layout/callui/call_info";
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 {
diff --git a/inc/presenters/AcceptDialog.h b/inc/presenters/AcceptDialog.h
index cdbd4d1..e10dc02 100644
--- a/inc/presenters/AcceptDialog.h
+++ b/inc/presenters/AcceptDialog.h
@@ -17,17 +17,17 @@
#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 {
@@ -76,6 +76,7 @@ namespace callui {
ucl::StyledWidgetSRef m_popup;
ucl::StyledWidgetSRef m_genlist;
AcceptDialogHandler m_handler;
+ AcceptDialogSRef m_selfRef;
bool m_isDismissed;
};
diff --git a/inc/presenters/AcceptRejectPresenter.h b/inc/presenters/AcceptRejectPresenter.h
index 41f426e..cd44997 100644
--- a/inc/presenters/AcceptRejectPresenter.h
+++ b/inc/presenters/AcceptRejectPresenter.h
@@ -17,7 +17,7 @@
#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"
@@ -26,7 +26,7 @@
namespace callui {
- class AcceptRejectPresenter final : public Presenter {
+ class AcceptRejectPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
@@ -35,7 +35,7 @@ namespace callui {
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;
@@ -56,7 +56,7 @@ namespace callui {
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);
diff --git a/inc/presenters/AccessoryPresenter.h b/inc/presenters/AccessoryPresenter.h
index 31bc625..c4c9f38 100644
--- a/inc/presenters/AccessoryPresenter.h
+++ b/inc/presenters/AccessoryPresenter.h
@@ -17,7 +17,7 @@
#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"
@@ -26,7 +26,7 @@
namespace callui {
- class AccessoryPresenter final : public Presenter {
+ class AccessoryPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
@@ -34,7 +34,7 @@ namespace callui {
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;
@@ -54,7 +54,7 @@ namespace callui {
AccessoryPresenter(ucl::IRefCountObj &rc,
const ISoundManagerSRef &sm);
- ucl::Result prepare(Presenter &parent,
+ ucl::Result prepare(ucl::GuiPresenter &parent,
ucl::ElmWidget &parentWidget,
bool isMuteControlDisabled = false);
diff --git a/inc/presenters/CallInfoPresenter.h b/inc/presenters/CallInfoPresenter.h
index 6a836b1..6502152 100644
--- a/inc/presenters/CallInfoPresenter.h
+++ b/inc/presenters/CallInfoPresenter.h
@@ -17,7 +17,7 @@
#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"
@@ -26,7 +26,7 @@
namespace callui {
- class CallInfoPresenter final : public Presenter {
+ class CallInfoPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
@@ -35,7 +35,7 @@ namespace callui {
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;
@@ -55,7 +55,7 @@ namespace callui {
const ICallManagerSRef &cm,
CallMode mode);
- ucl::Result prepare(Presenter &parent,
+ ucl::Result prepare(ucl::GuiPresenter &parent,
ucl::ElmWidget &parentWidget);
void initCallInfos(const ICallManagerSRef &cm);
@@ -63,7 +63,7 @@ namespace callui {
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();
@@ -84,7 +84,7 @@ namespace callui {
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;
diff --git a/inc/presenters/CallStatusPresenter.h b/inc/presenters/CallStatusPresenter.h
index e4c7b4a..0f788b3 100644
--- a/inc/presenters/CallStatusPresenter.h
+++ b/inc/presenters/CallStatusPresenter.h
@@ -17,7 +17,7 @@
#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>
@@ -27,7 +27,7 @@
namespace callui {
- class CallStatusPresenter final : public Presenter {
+ class CallStatusPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
@@ -37,7 +37,7 @@ namespace callui {
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;
@@ -55,7 +55,7 @@ namespace callui {
const ICallInfoWCRef &info,
bool isOnHold);
- ucl::Result prepare(Presenter &parent);
+ ucl::Result prepare(ucl::GuiPresenter &parent);
ucl::Result processIncomingMode();
ucl::Result processOutgoingMode();
diff --git a/inc/presenters/IndicatorPresenter.h b/inc/presenters/IndicatorPresenter.h
index b0ac5dd..47a098e 100644
--- a/inc/presenters/IndicatorPresenter.h
+++ b/inc/presenters/IndicatorPresenter.h
@@ -17,7 +17,7 @@
#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"
@@ -27,9 +27,8 @@
namespace callui {
- class IndicatorPresenter final :
- public IIndicatorStateListener,
- public Presenter {
+ class IndicatorPresenter final : public ucl::GuiPresenter,
+ public IIndicatorStateListener {
public:
class Builder {
public:
@@ -39,7 +38,7 @@ namespace callui {
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;
@@ -57,7 +56,7 @@ namespace callui {
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();
diff --git a/inc/presenters/MainPage.h b/inc/presenters/MainPage.h
index 1d3ae89..ce28028 100644
--- a/inc/presenters/MainPage.h
+++ b/inc/presenters/MainPage.h
@@ -28,8 +28,7 @@
namespace callui {
- class MainPage final :
- public Page,
+ class MainPage final : public Page,
public ICallListener {
public:
class Builder {
diff --git a/inc/presenters/MoreOptionsPresenter.h b/inc/presenters/MoreOptionsPresenter.h
index f6ab91a..2b994b1 100644
--- a/inc/presenters/MoreOptionsPresenter.h
+++ b/inc/presenters/MoreOptionsPresenter.h
@@ -17,7 +17,7 @@
#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"
@@ -29,7 +29,7 @@
namespace callui {
- class MoreOptionsPresenter final : public Presenter {
+ class MoreOptionsPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
@@ -38,7 +38,7 @@ namespace callui {
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;
@@ -58,7 +58,7 @@ namespace callui {
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);
diff --git a/inc/presenters/MotionSensorPresenter.h b/inc/presenters/MotionSensorPresenter.h
index 4e6041f..0805c38 100644
--- a/inc/presenters/MotionSensorPresenter.h
+++ b/inc/presenters/MotionSensorPresenter.h
@@ -23,8 +23,7 @@
namespace callui {
- class MotionSensorPresenter final
- {
+ class MotionSensorPresenter final {
public:
class Builder {
public:
diff --git a/inc/presenters/Page.h b/inc/presenters/Page.h
index 8c63c6e..b25fc3a 100644
--- a/inc/presenters/Page.h
+++ b/inc/presenters/Page.h
@@ -19,13 +19,13 @@
#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)>;
@@ -80,9 +80,10 @@ namespace callui {
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);
}
diff --git a/inc/presenters/Page.hpp b/inc/presenters/Page.hpp
index 886f114..2ef28d2 100644
--- a/inc/presenters/Page.hpp
+++ b/inc/presenters/Page.hpp
@@ -21,8 +21,8 @@ namespace callui {
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!");
@@ -57,7 +57,7 @@ namespace callui {
return (m_navi->getBottomItem() == m_item);
}
- // Non-member functions //
+ // Non-member functions
inline bool isLast(const Page &page)
{
diff --git a/inc/presenters/RejectMsgPresenter.h b/inc/presenters/RejectMsgPresenter.h
index 40cb2ae..31740fb 100644
--- a/inc/presenters/RejectMsgPresenter.h
+++ b/inc/presenters/RejectMsgPresenter.h
@@ -17,7 +17,7 @@
#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"
@@ -26,7 +26,7 @@
namespace callui {
- class RejectMsgPresenter final : public Presenter {
+ class RejectMsgPresenter final : public ucl::GuiPresenter {
public:
class Builder {
public:
@@ -36,7 +36,7 @@ namespace callui {
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;
@@ -67,7 +67,7 @@ namespace callui {
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);
diff --git a/inc/presenters/types.h b/inc/presenters/types.h
index 516fc87..7139437 100644
--- a/inc/presenters/types.h
+++ b/inc/presenters/types.h
@@ -77,6 +77,8 @@ namespace callui {
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)>;
diff --git a/inc/view/helpers.h b/inc/view/helpers.h
index e830901..d0d3395 100644
--- a/inc/view/helpers.h
+++ b/inc/view/helpers.h
@@ -42,6 +42,8 @@ namespace callui {
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__
diff --git a/src/presenters/AcceptDialog.cpp b/src/presenters/AcceptDialog.cpp
index 79df682..df1efbf 100644
--- a/src/presenters/AcceptDialog.cpp
+++ b/src/presenters/AcceptDialog.cpp
@@ -75,7 +75,7 @@ namespace callui {
AcceptDialog::AcceptDialog(IRefCountObj &rc,
const AcceptDialogHandler &handler):
- Presenter(rc),
+ GuiPresenter(rc),
m_handler(handler),
m_isDismissed(false)
{
@@ -87,7 +87,7 @@ namespace callui {
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),
@@ -96,7 +96,7 @@ namespace callui {
FAIL_RETURN(createGenlist(),
"createGenlist() failed!");
- m_rc->ref();
+ m_selfRef = asShared(*this);
addDeactivatorException(this);
broadcastDeactivate();
@@ -286,7 +286,7 @@ namespace callui {
m_popup.reset();
- m_rc->unref();
+ m_selfRef.reset();
}
}
diff --git a/src/presenters/AcceptRejectPresenter.cpp b/src/presenters/AcceptRejectPresenter.cpp
index 33ba40c..90bb88f 100644
--- a/src/presenters/AcceptRejectPresenter.cpp
+++ b/src/presenters/AcceptRejectPresenter.cpp
@@ -90,7 +90,7 @@ namespace callui {
}
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");
@@ -107,7 +107,7 @@ namespace callui {
AcceptRejectPresenter::AcceptRejectPresenter(IRefCountObj &rc,
const IIncomingCallSRef &call,
CallMask calls):
- Presenter(rc),
+ GuiPresenter(rc),
m_call(call),
m_callMask(calls)
{
@@ -123,10 +123,10 @@ namespace callui {
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),
diff --git a/src/presenters/AccessoryPresenter.cpp b/src/presenters/AccessoryPresenter.cpp
index e0ea5c5..90c39f7 100644
--- a/src/presenters/AccessoryPresenter.cpp
+++ b/src/presenters/AccessoryPresenter.cpp
@@ -72,7 +72,7 @@ namespace callui {
}
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");
@@ -86,7 +86,7 @@ namespace callui {
AccessoryPresenter::AccessoryPresenter(IRefCountObj &rc,
const ISoundManagerSRef &sm):
- Presenter(rc),
+ GuiPresenter(rc),
m_sm(sm),
m_vcTimer(nullptr),
m_audioState(m_sm->getAudioState())
@@ -99,11 +99,11 @@ namespace callui {
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");
diff --git a/src/presenters/CallInfoPresenter.cpp b/src/presenters/CallInfoPresenter.cpp
index cfccf52..ab1932b 100644
--- a/src/presenters/CallInfoPresenter.cpp
+++ b/src/presenters/CallInfoPresenter.cpp
@@ -122,7 +122,7 @@ namespace callui {
}
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");
@@ -138,7 +138,7 @@ namespace callui {
CallInfoPresenter::CallInfoPresenter(IRefCountObj &rc,
const ICallManagerSRef &cm,
CallMode mode):
- Presenter(rc),
+ GuiPresenter(rc),
m_mode(mode),
m_isSubTxtEnable(false),
m_needModifyCallStatus(false)
@@ -150,10 +150,10 @@ namespace callui {
{
}
- 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);
@@ -576,7 +576,7 @@ namespace callui {
return RES_OK;
}
- Result CallInfoPresenter::createCallStatus(Presenter &parent)
+ Result CallInfoPresenter::createCallStatus(GuiPresenter &parent)
{
ICallInfoWCRef callInfo;
bool isOnHold = false;
diff --git a/src/presenters/CallStatusPresenter.cpp b/src/presenters/CallStatusPresenter.cpp
index 6274d89..61e6d6e 100644
--- a/src/presenters/CallStatusPresenter.cpp
+++ b/src/presenters/CallStatusPresenter.cpp
@@ -82,7 +82,7 @@ namespace callui {
}
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");
@@ -102,7 +102,7 @@ namespace callui {
CallMode mode,
const ICallInfoWCRef &info,
bool isHeld):
- Presenter(rc),
+ GuiPresenter(rc),
m_ly(layout),
m_mode(mode),
m_info(info),
@@ -122,9 +122,9 @@ namespace callui {
}
}
- 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);
diff --git a/src/presenters/IndicatorPresenter.cpp b/src/presenters/IndicatorPresenter.cpp
index 3ef7cb8..531afe8 100644
--- a/src/presenters/IndicatorPresenter.cpp
+++ b/src/presenters/IndicatorPresenter.cpp
@@ -188,7 +188,7 @@ namespace callui {
}
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");
@@ -202,7 +202,7 @@ namespace callui {
IndicatorPresenter::IndicatorPresenter(IRefCountObj &rc,
const IIndicatorStateProviderSRef &provider):
- Presenter(rc),
+ GuiPresenter(rc),
m_provider(provider),
m_isIncomingCallMode(false)
{
@@ -212,10 +212,10 @@ namespace callui {
{
}
- 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!");
diff --git a/src/presenters/MoreOptionsPresenter.cpp b/src/presenters/MoreOptionsPresenter.cpp
index 60ce201..bbb0e1c 100644
--- a/src/presenters/MoreOptionsPresenter.cpp
+++ b/src/presenters/MoreOptionsPresenter.cpp
@@ -105,7 +105,7 @@ namespace callui {
}
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");
@@ -124,7 +124,7 @@ namespace callui {
const ICallManagerSRef &cm,
const ISoundManagerSRef &sm,
const NaviframeSRef &navi):
- Presenter(rc),
+ GuiPresenter(rc),
m_cm(cm),
m_sm(sm),
m_navi(navi),
@@ -151,10 +151,10 @@ namespace callui {
}
}
- 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!");
diff --git a/src/presenters/Page.cpp b/src/presenters/Page.cpp
index 8695f63..1f5e85d 100644
--- a/src/presenters/Page.cpp
+++ b/src/presenters/Page.cpp
@@ -29,7 +29,7 @@ namespace callui {
Page::Page(IRefCountObj &rc, const NaviframeSRef &navi,
const ExitRequestHandler &onExitRequest) :
- Presenter(rc),
+ GuiPresenter(rc),
m_navi(navi),
m_onExitRequest(onExitRequest)
{
@@ -69,7 +69,7 @@ namespace callui {
m_item.setData(this);
m_item.setDelCallback(CALLBACK_A(Page::onItemDel));
- m_rc->ref();
+ m_selfRef = asShared(*this);
if (!m_navi->isInTransition() && isAtTop()) {
dispatchTopPageChanged();
@@ -91,7 +91,7 @@ namespace callui {
void Page::onItemDel(Evas_Object *obj, void *eventInfo)
{
m_item = nullptr;
- m_rc->unref();
+ m_selfRef.reset();
}
void Page::exit()
diff --git a/src/presenters/RejectMsgPresenter.cpp b/src/presenters/RejectMsgPresenter.cpp
index ec041ff..ee3cd8b 100644
--- a/src/presenters/RejectMsgPresenter.cpp
+++ b/src/presenters/RejectMsgPresenter.cpp
@@ -121,7 +121,7 @@ namespace callui {
}
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");
@@ -140,7 +140,7 @@ namespace callui {
const IRejectMsgProviderSRef &provider,
const RejectMsgStateHandler &stateHandler,
const RejectMsgSelectHandler &selectHandler):
- Presenter(rc),
+ GuiPresenter(rc),
m_circleEo(nullptr),
m_provider(provider),
m_stateHandler(stateHandler),
@@ -156,10 +156,10 @@ namespace callui {
}
}
- 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),
diff --git a/src/view/helpers.cpp b/src/view/helpers.cpp
index 03fb991..e4f8595 100644
--- a/src/view/helpers.cpp
+++ b/src/view/helpers.cpp
@@ -108,5 +108,10 @@ namespace callui {
return itc;
}
+ LayoutTheme getImageTheme(const char *const fileName)
+ {
+ return {"layout", "callui_image", fileName};
+ }
+
}
diff --git a/ucl/inc/ucl/appfw/SysEventProvider.h b/ucl/inc/ucl/appfw/SysEventProvider.h
index 64c6f5f..8a72758 100644
--- a/ucl/inc/ucl/appfw/SysEventProvider.h
+++ b/ucl/inc/ucl/appfw/SysEventProvider.h
@@ -26,7 +26,7 @@ namespace ucl {
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 *);
diff --git a/ucl/inc/ucl/appfw/UIApp.h b/ucl/inc/ucl/appfw/UIApp.h
index f482ce4..a8b4dbc 100644
--- a/ucl/inc/ucl/appfw/UIApp.h
+++ b/ucl/inc/ucl/appfw/UIApp.h
@@ -23,7 +23,7 @@
namespace ucl {
- class UIApp : private IInstanceContext {
+ class UIApp final : private IInstanceContext {
public:
UIApp(InstanceManagerBase &instanceMgr);
virtual ~UIApp();
diff --git a/ucl/inc/ucl/gui/Genlist.h b/ucl/inc/ucl/gui/Genlist.h
new file mode 100644
index 0000000..ebbb43e
--- /dev/null
+++ b/ucl/inc/ucl/gui/Genlist.h
@@ -0,0 +1,92 @@
+/*
+ * 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__
diff --git a/ucl/inc/ucl/gui/Genlist.hpp b/ucl/inc/ucl/gui/Genlist.hpp
new file mode 100644
index 0000000..d3cfed0
--- /dev/null
+++ b/ucl/inc/ucl/gui/Genlist.hpp
@@ -0,0 +1,132 @@
+/*
+ * 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()));
+ }
+}
diff --git a/ucl/inc/ucl/gui/GenlistItem.h b/ucl/inc/ucl/gui/GenlistItem.h
new file mode 100644
index 0000000..2c96b9c
--- /dev/null
+++ b/ucl/inc/ucl/gui/GenlistItem.h
@@ -0,0 +1,63 @@
+/*
+ * 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__
diff --git a/ucl/inc/ucl/gui/GenlistItem.hpp b/ucl/inc/ucl/gui/GenlistItem.hpp
new file mode 100644
index 0000000..6920a88
--- /dev/null
+++ b/ucl/inc/ucl/gui/GenlistItem.hpp
@@ -0,0 +1,58 @@
+/*
+ * 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));
+ }
+}
diff --git a/ucl/inc/ucl/gui/Layout.h b/ucl/inc/ucl/gui/Layout.h
index 37732ce..9eb108e 100644
--- a/ucl/inc/ucl/gui/Layout.h
+++ b/ucl/inc/ucl/gui/Layout.h
@@ -25,7 +25,7 @@ namespace ucl {
class Layout : public EdjeWidget {
public:
- class Builder {
+ class Builder final {
public:
Builder();
Builder &setTheme(const LayoutTheme &value);
diff --git a/ucl/inc/ucl/gui/Naviframe.h b/ucl/inc/ucl/gui/Naviframe.h
index 4e4336c..66693f2 100644
--- a/ucl/inc/ucl/gui/Naviframe.h
+++ b/ucl/inc/ucl/gui/Naviframe.h
@@ -31,7 +31,7 @@ namespace ucl {
class Naviframe final : public StyledWidget {
public:
- class Builder {
+ class Builder final {
public:
Builder();
Builder &setStyle(ElmStyle value);
diff --git a/ucl/inc/ucl/gui/Widget.h b/ucl/inc/ucl/gui/Widget.h
index 2048a7d..e60c5ec 100644
--- a/ucl/inc/ucl/gui/Widget.h
+++ b/ucl/inc/ucl/gui/Widget.h
@@ -135,11 +135,11 @@ namespace ucl {
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 //
diff --git a/ucl/inc/ucl/gui/Window.h b/ucl/inc/ucl/gui/Window.h
index b611b25..9aa598d 100644
--- a/ucl/inc/ucl/gui/Window.h
+++ b/ucl/inc/ucl/gui/Window.h
@@ -33,7 +33,7 @@ namespace ucl {
BASIC = ELM_WIN_BASIC
};
- class Builder {
+ class Builder final {
public:
Builder();
diff --git a/ucl/inc/ucl/gui/helpers.h b/ucl/inc/ucl/gui/helpers.h
index f598c17..d42eccb 100644
--- a/ucl/inc/ucl/gui/helpers.h
+++ b/ucl/inc/ucl/gui/helpers.h
@@ -29,59 +29,59 @@ namespace ucl {
// 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));
}
}
diff --git a/ucl/inc/ucl/gui/types.h b/ucl/inc/ucl/gui/types.h
index 454b6bc..6d43d76 100644
--- a/ucl/inc/ucl/gui/types.h
+++ b/ucl/inc/ucl/gui/types.h
@@ -26,6 +26,7 @@
#include "ucl/misc/Aspect.h"
#include "ucl/misc/TString.h"
+#include "ucl/misc/ConstCString.h"
#include "ucl/misc/Variant.h"
namespace ucl {
@@ -45,6 +46,10 @@ namespace ucl {
struct EoDataKey : Aspect<EoDataKey> { using Aspect::Aspect; };
+ // Delegates //
+
+ using SmartCbHandler = Delegate<void(Evas_Object *obj, void *eventInfo)>;
+
// WidgetEventHandler //
class Widget;
@@ -89,7 +94,7 @@ namespace ucl {
// AtspiGestureEventInfo //
- struct AtspiGestureEventInfo {
+ struct AtspiGestureEventInfo final {
Elm_Atspi_Gesture_Info gestureInfo;
bool preventDefault;
bool stopPropagation;
@@ -107,7 +112,7 @@ namespace ucl {
// LayoutTheme //
- struct LayoutTheme {
+ struct LayoutTheme final {
const char *klass;
const char *group;
const char *style;
diff --git a/ucl/inc/ucl/misc/Aspect.h b/ucl/inc/ucl/misc/Aspect.h
index 082cd91..0c55bf6 100644
--- a/ucl/inc/ucl/misc/Aspect.h
+++ b/ucl/inc/ucl/misc/Aspect.h
@@ -30,6 +30,10 @@ namespace ucl {
explicit constexpr Aspect(const char *name);
constexpr operator const char *() const;
+
+ struct Hash final {
+ size_t operator()(const Aspect &key) const;
+ };
};
// Non-member functions //
diff --git a/ucl/inc/ucl/misc/Aspect.hpp b/ucl/inc/ucl/misc/Aspect.hpp
index aac7ddb..9894681 100644
--- a/ucl/inc/ucl/misc/Aspect.hpp
+++ b/ucl/inc/ucl/misc/Aspect.hpp
@@ -20,6 +20,22 @@
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)
diff --git a/ucl/inc/ucl/misc/CString.h b/ucl/inc/ucl/misc/CString.h
new file mode 100644
index 0000000..396f37d
--- /dev/null
+++ b/ucl/inc/ucl/misc/CString.h
@@ -0,0 +1,55 @@
+/*
+ * 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__
diff --git a/ucl/inc/ucl/misc/CString.hpp b/ucl/inc/ucl/misc/CString.hpp
new file mode 100644
index 0000000..086b3c2
--- /dev/null
+++ b/ucl/inc/ucl/misc/CString.hpp
@@ -0,0 +1,93 @@
+/*
+ * 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);
+ }
+}
diff --git a/ucl/inc/ucl/misc/ConstCString.h b/ucl/inc/ucl/misc/ConstCString.h
new file mode 100644
index 0000000..7f600f0
--- /dev/null
+++ b/ucl/inc/ucl/misc/ConstCString.h
@@ -0,0 +1,53 @@
+/*
+ * 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__
diff --git a/ucl/inc/ucl/misc/ConstCString.hpp b/ucl/inc/ucl/misc/ConstCString.hpp
new file mode 100644
index 0000000..50df605
--- /dev/null
+++ b/ucl/inc/ucl/misc/ConstCString.hpp
@@ -0,0 +1,86 @@
+/*
+ * 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);
+ }
+}
diff --git a/ucl/inc/ucl/misc/Event.h b/ucl/inc/ucl/misc/Event.h
index 420954a..cd27f29 100644
--- a/ucl/inc/ucl/misc/Event.h
+++ b/ucl/inc/ucl/misc/Event.h
@@ -24,7 +24,7 @@
namespace ucl {
template <class DELEGATE>
- class Event {
+ class Event final {
public:
Event();
diff --git a/ucl/inc/ucl/misc/HashMap.h b/ucl/inc/ucl/misc/HashMap.h
index e8c078c..8470fed 100644
--- a/ucl/inc/ucl/misc/HashMap.h
+++ b/ucl/inc/ucl/misc/HashMap.h
@@ -32,7 +32,7 @@ namespace ucl {
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);
@@ -42,16 +42,34 @@ namespace ucl {
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;
diff --git a/ucl/inc/ucl/misc/HashMap.hpp b/ucl/inc/ucl/misc/HashMap.hpp
index 05a0652..2ba4ffd 100644
--- a/ucl/inc/ucl/misc/HashMap.hpp
+++ b/ucl/inc/ucl/misc/HashMap.hpp
@@ -18,7 +18,7 @@ namespace ucl {
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));
@@ -26,7 +26,7 @@ namespace ucl {
}
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);
@@ -35,7 +35,7 @@ namespace ucl {
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);
@@ -47,7 +47,7 @@ namespace ucl {
}
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);
@@ -56,4 +56,10 @@ namespace ucl {
}
return it->second;
}
+
+ template <class KEY, class VALUE>
+ inline void HashMap<KEY, VALUE>::clear()
+ {
+ m_map.clear();
+ }
}
diff --git a/ucl/inc/ucl/misc/RefCountAware.h b/ucl/inc/ucl/misc/RefCountAware.h
index e75ecb9..6ea5ee9 100644
--- a/ucl/inc/ucl/misc/RefCountAware.h
+++ b/ucl/inc/ucl/misc/RefCountAware.h
@@ -27,6 +27,8 @@ namespace ucl {
class RefCountAware : public Polymorphic {
public:
bool isShared() const;
+ UInt getUseCount() const;
+ const void *getObjPtr() const;
template <class T>
SharedRef<T> asSharedThis(T *thisAlias) const;
@@ -43,7 +45,7 @@ namespace ucl {
// Signal to RefCountObj<T, C> to pass IRefCountObj to constructor
enum { _IS_REF_COUNT_AWARE };
- protected:
+ private:
IRefCountObj *const m_rc;
};
diff --git a/ucl/inc/ucl/misc/RefCountAware.hpp b/ucl/inc/ucl/misc/RefCountAware.hpp
index 3906d0e..8fb3812 100644
--- a/ucl/inc/ucl/misc/RefCountAware.hpp
+++ b/ucl/inc/ucl/misc/RefCountAware.hpp
@@ -28,6 +28,24 @@ namespace ucl {
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
{
diff --git a/ucl/inc/ucl/misc/TString.h b/ucl/inc/ucl/misc/TString.h
index 5ad240d..71ca2d9 100644
--- a/ucl/inc/ucl/misc/TString.h
+++ b/ucl/inc/ucl/misc/TString.h
@@ -21,7 +21,7 @@
namespace ucl {
- class TString {
+ class TString final {
public:
TString();
diff --git a/ucl/inc/ucl/misc/Variant.h b/ucl/inc/ucl/misc/Variant.h
index 3bfa6d6..6542358 100644
--- a/ucl/inc/ucl/misc/Variant.h
+++ b/ucl/inc/ucl/misc/Variant.h
@@ -21,7 +21,7 @@
#include <vector>
#include <initializer_list>
-#include "ucl/util/types.h"
+#include "ConstCString.h"
namespace ucl {
@@ -32,12 +32,12 @@ 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,
@@ -49,21 +49,6 @@ namespace ucl {
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;
@@ -106,7 +91,7 @@ namespace ucl {
float asFloat() const noexcept;
double asDouble() const noexcept;
- CStr asString() const noexcept;
+ ConstCString asString() const noexcept;
Variant *asArray() noexcept;
const Variant *asArray() const noexcept;
diff --git a/ucl/inc/ucl/misc/Variant.hpp b/ucl/inc/ucl/misc/Variant.hpp
index 04c6650..fe6d977 100644
--- a/ucl/inc/ucl/misc/Variant.hpp
+++ b/ucl/inc/ucl/misc/Variant.hpp
@@ -28,45 +28,6 @@ namespace ucl { namespace { namespace impl {
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 :
diff --git a/inc/presenters/Presenter.h b/ucl/inc/ucl/mvp/GuiPresenter.h
index 5bf2b3b..5a94af4 100644
--- a/inc/presenters/Presenter.h
+++ b/ucl/inc/ucl/mvp/GuiPresenter.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef __CALLUI_PRESENTERS_PRESENTER_H__
-#define __CALLUI_PRESENTERS_PRESENTER_H__
+#ifndef __UCL_MVP_GUI_PRESENTER_H__
+#define __UCL_MVP_GUI_PRESENTER_H__
#include <unordered_set>
@@ -23,13 +23,13 @@
#include "types.h"
-namespace callui {
+namespace ucl {
- UCL_DECLARE_REF_ALIASES(Presenter);
+ UCL_DECLARE_REF_ALIASES(GuiPresenter);
- class Presenter : public ucl::RefCountAware {
+ class GuiPresenter : public RefCountAware {
public:
- struct DeactivatorInfo {
+ struct DeactivatorInfo final {
const void *deactivator;
bool isBroadcast;
};
@@ -41,8 +41,8 @@ namespace callui {
void activateBy(const void *deactivator);
void deactivateBy(const void *deactivator);
- void addDeactivatorSource(ucl::Widget &source);
- void delDeactivatorSource(ucl::Widget &source);
+ void addDeactivatorSource(Widget &source);
+ void delDeactivatorSource(Widget &source);
protected:
enum {
@@ -55,20 +55,20 @@ namespace callui {
};
protected:
- Presenter(ucl::IRefCountObj &rc);
- virtual ~Presenter();
+ GuiPresenter(IRefCountObj &rc);
+ virtual ~GuiPresenter();
- ucl::Result prepare(ucl::ElmWidget &widget, int flags = PF_DEFAULT);
- ucl::Result prepare(Presenter &parent, int flags = PF_DEFAULT);
+ Result prepare(ElmWidget &widget, int flags = PF_DEFAULT);
+ Result prepare(GuiPresenter &parent, int flags = PF_DEFAULT);
- ucl::Window &getWindow();
+ Window &getWindow();
bool isWindowReady() const;
void addDeactivatorException(const void *deactivator);
- void setDeactivatorSink(const ucl::WidgetSRef &sink);
+ void setDeactivatorSink(const WidgetSRef &sink);
- void sendActivate(ucl::Widget &sender);
- void sendDeactivate(ucl::Widget &sender);
+ void sendActivate(Widget &sender);
+ void sendDeactivate(Widget &sender);
void broadcastActivate();
void broadcastDeactivate();
@@ -79,30 +79,30 @@ namespace callui {
virtual void onDeactivateBy(const DeactivatorInfo &info);
private:
- void sendDeactivator(ucl::Widget &sender,
- ucl::SmartEvent event, const void *deactivator);
- void broadcastDeactivator(ucl::SmartEvent event,
+ void sendDeactivator(Widget &sender,
+ SmartEvent event, const void *deactivator);
+ void broadcastDeactivator(SmartEvent event,
const void *deactivator);
- void sendDeactivatorInfo(ucl::Widget &sender, ucl::SmartEvent event,
+ void sendDeactivatorInfo(Widget &sender, SmartEvent event,
const DeactivatorInfo &info);
void activateByImpl(const DeactivatorInfo &info);
void deactivateByImpl(const DeactivatorInfo &info);
- void onActivateBySmart(ucl::Widget &widget, void *eventInfo);
- void onDeactivateBySmart(ucl::Widget &widget, void *eventInfo);
+ void onActivateBySmart(Widget &widget, void *eventInfo);
+ void onDeactivateBySmart(Widget &widget, void *eventInfo);
private:
std::unordered_set<const void *> m_deactivatorExceptions;
std::unordered_set<const void *> m_deactivators;
- ucl::WindowSRef m_window;
- ucl::WidgetSRef m_sink;
- ucl::WidgetWRef m_parentSink;
+ WindowSRef m_window;
+ WidgetSRef m_sink;
+ WidgetWRef m_parentSink;
bool m_hasBuildInSources;
bool m_isChild;
bool m_isPrepared;
};
}
-#endif // __CALLUI_PRESENTERS_PRESENTER_H__
+#endif // __UCL_MVP_GUI_PRESENTER_H__
diff --git a/ucl/inc/ucl/mvp/ListItemPresenter.h b/ucl/inc/ucl/mvp/ListItemPresenter.h
new file mode 100644
index 0000000..2c90f42
--- /dev/null
+++ b/ucl/inc/ucl/mvp/ListItemPresenter.h
@@ -0,0 +1,128 @@
+/*
+ * 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__
diff --git a/ucl/inc/ucl/mvp/ListPresenter.h b/ucl/inc/ucl/mvp/ListPresenter.h
new file mode 100644
index 0000000..1d62e41
--- /dev/null
+++ b/ucl/inc/ucl/mvp/ListPresenter.h
@@ -0,0 +1,113 @@
+/*
+ * 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__
diff --git a/ucl/inc/ucl/mvp/types.h b/ucl/inc/ucl/mvp/types.h
new file mode 100644
index 0000000..6c263e2
--- /dev/null
+++ b/ucl/inc/ucl/mvp/types.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_MVP_TYPES_H__
+#define __UCL_MVP_TYPES_H__
+
+#include "ucl/gui/types.h"
+
+#endif // __UCL_MVP_TYPES_H__
diff --git a/ucl/inc/ucl/util/memory/BaseRef.h b/ucl/inc/ucl/util/memory/BaseRef.h
index f82a2c9..8146eae 100644
--- a/ucl/inc/ucl/util/memory/BaseRef.h
+++ b/ucl/inc/ucl/util/memory/BaseRef.h
@@ -34,7 +34,7 @@ namespace ucl {
friend class WeakRef;
public:
- int getUseCount() const noexcept;
+ UInt getUseCount() const noexcept;
protected:
constexpr BaseRef() noexcept;
diff --git a/ucl/inc/ucl/util/memory/BaseRef.hpp b/ucl/inc/ucl/util/memory/BaseRef.hpp
index adde1c9..312c38e 100644
--- a/ucl/inc/ucl/util/memory/BaseRef.hpp
+++ b/ucl/inc/ucl/util/memory/BaseRef.hpp
@@ -51,7 +51,7 @@ namespace ucl {
}
template <class T>
- inline int BaseRef<T>::getUseCount() const noexcept
+ inline UInt BaseRef<T>::getUseCount() const noexcept
{
return (m_rc ? m_rc->getUseCount() : 0);
}
diff --git a/ucl/inc/ucl/util/memory/IRefCountObj.h b/ucl/inc/ucl/util/memory/IRefCountObj.h
index c2397d4..69d6a1c 100644
--- a/ucl/inc/ucl/util/memory/IRefCountObj.h
+++ b/ucl/inc/ucl/util/memory/IRefCountObj.h
@@ -28,7 +28,7 @@ namespace ucl {
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;
diff --git a/ucl/inc/ucl/util/memory/RefCountObj.h b/ucl/inc/ucl/util/memory/RefCountObj.h
index 9832ff6..7237aa4 100644
--- a/ucl/inc/ucl/util/memory/RefCountObj.h
+++ b/ucl/inc/ucl/util/memory/RefCountObj.h
@@ -37,7 +37,7 @@ namespace ucl {
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:
diff --git a/ucl/inc/ucl/util/memory/RefCountObj.hpp b/ucl/inc/ucl/util/memory/RefCountObj.hpp
index d3b4e97..8a2c065 100644
--- a/ucl/inc/ucl/util/memory/RefCountObj.hpp
+++ b/ucl/inc/ucl/util/memory/RefCountObj.hpp
@@ -79,7 +79,7 @@ namespace ucl {
}
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();
}
diff --git a/ucl/inc/ucl/util/threading/CondVar.h b/ucl/inc/ucl/util/threading/CondVar.h
index 58d16d3..e73a763 100644
--- a/ucl/inc/ucl/util/threading/CondVar.h
+++ b/ucl/inc/ucl/util/threading/CondVar.h
@@ -21,7 +21,7 @@
namespace ucl {
- class CondVar : public NonCopyable {
+ class CondVar final : public NonCopyable {
public:
CondVar();
~CondVar();
diff --git a/ucl/inc/ucl/util/threading/Mutex.h b/ucl/inc/ucl/util/threading/Mutex.h
index e1951bc..eda90ff 100644
--- a/ucl/inc/ucl/util/threading/Mutex.h
+++ b/ucl/inc/ucl/util/threading/Mutex.h
@@ -25,7 +25,7 @@
namespace ucl {
- class Mutex : public NonCopyable {
+ class Mutex final : public NonCopyable {
public:
Mutex(bool recursive = false);
~Mutex();
diff --git a/ucl/inc/ucl/util/threading/MutexLock.h b/ucl/inc/ucl/util/threading/MutexLock.h
index 854d0b3..062837f 100644
--- a/ucl/inc/ucl/util/threading/MutexLock.h
+++ b/ucl/inc/ucl/util/threading/MutexLock.h
@@ -21,7 +21,7 @@
namespace ucl {
- class MutexLock : public NonCopyable {
+ class MutexLock final : public NonCopyable {
public:
MutexLock(Mutex &mutex);
~MutexLock();
diff --git a/ucl/inc/ucl/util/types/Result.h b/ucl/inc/ucl/util/types/Result.h
index 69815a7..099223f 100644
--- a/ucl/inc/ucl/util/types/Result.h
+++ b/ucl/inc/ucl/util/types/Result.h
@@ -23,14 +23,14 @@ namespace ucl {
// ResultData declaration //
- struct ResultData {
+ struct ResultData final {
const char *name;
int logPrio;
};
// Result declaration //
- struct Result {
+ struct Result final {
int value;
Result() = default;
diff --git a/ucl/inc/ucl/util/types/classTypes.h b/ucl/inc/ucl/util/types/classTypes.h
index 1b1402d..5c708d2 100644
--- a/ucl/inc/ucl/util/types/classTypes.h
+++ b/ucl/inc/ucl/util/types/classTypes.h
@@ -55,7 +55,7 @@ namespace ucl {
};
template <class PRODUCT, class IPRODUCT>
- class Factory : public IFactory<IPRODUCT> {
+ class Factory final : public IFactory<IPRODUCT> {
public:
using Product = PRODUCT;
public:
diff --git a/ucl/src/appfw/UIApp.cpp b/ucl/src/appfw/UIApp.cpp
index 4012eca..4e1a4de 100644
--- a/ucl/src/appfw/UIApp.cpp
+++ b/ucl/src/appfw/UIApp.cpp
@@ -123,13 +123,13 @@ namespace ucl {
}
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;
@@ -157,7 +157,7 @@ namespace ucl {
m_window = Window::Builder().
setType(winType).
- setName({paramValue.asString()}).
+ setName(paramValue.asString().get()).
setIsOwner(true).
build();
if (!m_window) {
diff --git a/ucl/src/gui/ElmWidget.cpp b/ucl/src/gui/ElmWidget.cpp
index 7c39f81..b7d227e 100644
--- a/ucl/src/gui/ElmWidget.cpp
+++ b/ucl/src/gui/ElmWidget.cpp
@@ -70,6 +70,6 @@ namespace ucl {
Window *ElmWidget::getWindow() const
{
- return dynamicCast<Window>(getTopWidget());
+ return dynamicWidgetCast<Window>(getTopWidget());
}
}
diff --git a/ucl/src/gui/Genlist.cpp b/ucl/src/gui/Genlist.cpp
new file mode 100644
index 0000000..b0e31a5
--- /dev/null
+++ b/ucl/src/gui/Genlist.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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;
+ }
+}
diff --git a/ucl/src/gui/NaviItem.cpp b/ucl/src/gui/NaviItem.cpp
index dd212bf..02f5da2 100644
--- a/ucl/src/gui/NaviItem.cpp
+++ b/ucl/src/gui/NaviItem.cpp
@@ -23,7 +23,7 @@ namespace ucl {
void NaviItem::popTo() const
{
- const auto navi = dynamicCast<Naviframe>(getWidget());
+ const auto navi = dynamicWidgetCast<Naviframe>(getWidget());
const bool needStartTransition =
(navi && (navi->getTopItem() != *this));
@@ -36,7 +36,7 @@ namespace ucl {
void NaviItem::promote() const
{
- const auto navi = dynamicCast<Naviframe>(getWidget());
+ const auto navi = dynamicWidgetCast<Naviframe>(getWidget());
const bool needStartTransition =
(navi && (navi->getTopItem() != *this));
diff --git a/ucl/src/gui/Widget.cpp b/ucl/src/gui/Widget.cpp
index d2c0dd6..096c6e1 100644
--- a/ucl/src/gui/Widget.cpp
+++ b/ucl/src/gui/Widget.cpp
@@ -117,12 +117,11 @@ namespace ucl {
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);
@@ -139,7 +138,7 @@ namespace ucl {
unbindFromEo();
}
- if (m_rc) {
+ if (isShared()) {
evas_object_event_callback_del_full(m_eo, EVAS_CALLBACK_DEL,
CALLBACK_A(Widget::onEoDel), this);
}
@@ -177,7 +176,7 @@ namespace ucl {
{
updateEoRef();
- if (m_rc) {
+ if (isShared()) {
updateSelfRef();
}
}
@@ -202,14 +201,10 @@ namespace ucl {
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);
}
}
@@ -228,8 +223,8 @@ namespace ucl {
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;
}
@@ -239,8 +234,7 @@ namespace ucl {
m_isOwner, m_isEoRefKept, m_isSelfRefUnique);
m_eo = nullptr;
}
- m_isSelfRefKept = false;
- m_rc->unref();
+ m_selfRef.reset();
}
void Widget::onUniqueChanged(bool isUnique)
diff --git a/ucl/src/misc/Variant.cpp b/ucl/src/misc/Variant.cpp
index 4509118..f723f34 100644
--- a/ucl/src/misc/Variant.cpp
+++ b/ucl/src/misc/Variant.cpp
@@ -27,9 +27,9 @@ namespace ucl {
{
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);
@@ -164,14 +164,14 @@ namespace ucl {
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;
@@ -183,14 +183,14 @@ namespace ucl {
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 //
diff --git a/src/presenters/Presenter.cpp b/ucl/src/mvp/GuiPresenter.cpp
index b17f5cd..e23bc02 100644
--- a/src/presenters/Presenter.cpp
+++ b/ucl/src/mvp/GuiPresenter.cpp
@@ -14,21 +14,19 @@
* limitations under the License.
*/
-#include "presenters/Presenter.h"
+#include "ucl/mvp/GuiPresenter.h"
#include "common.h"
-namespace callui { namespace { namespace impl {
+namespace ucl { namespace { namespace impl {
- constexpr SmartEvent ACTIVATE_BY {"callui,activate,by"};
- constexpr SmartEvent DEACTIVATE_BY {"callui,deactivate,by"};
+ constexpr SmartEvent ACTIVATE_BY {"ucl,activate,by"};
+ constexpr SmartEvent DEACTIVATE_BY {"ucl,deactivate,by"};
}}}
-namespace callui {
+namespace ucl {
- using namespace ucl;
-
- Presenter::Presenter(IRefCountObj &rc) :
+ GuiPresenter::GuiPresenter(IRefCountObj &rc) :
RefCountAware(&rc),
m_hasBuildInSources(false),
m_isChild(false),
@@ -36,7 +34,7 @@ namespace callui {
{
}
- Presenter::~Presenter()
+ GuiPresenter::~GuiPresenter()
{
if (m_hasBuildInSources) {
if (m_isChild) {
@@ -49,7 +47,7 @@ namespace callui {
}
}
- Result Presenter::prepare(ElmWidget &widget, const int flags)
+ Result GuiPresenter::prepare(ElmWidget &widget, const int flags)
{
m_window = asShared(widget.getWindow());
if (!m_window) {
@@ -62,7 +60,7 @@ namespace callui {
}
if (flags & PF_ADD_SELF_EXCEPT) {
- addDeactivatorException(m_rc->getObjPtr());
+ addDeactivatorException(getObjPtr());
}
m_isPrepared = true;
@@ -70,48 +68,49 @@ namespace callui {
return RES_OK;
}
- Result Presenter::prepare(Presenter &parent, const int flags)
+ Result GuiPresenter::prepare(GuiPresenter &parent, const int flags)
{
- if (!parent.m_sink) {
- LOG_RETURN(RES_FAIL, "parent.m_sink is NULL!");
- }
+ if (flags & PF_ADD_DEACTIVATOR_SOURCES) {
- for (auto deactivator: parent.m_deactivators) {
- if (m_deactivatorExceptions.find(deactivator) ==
- m_deactivatorExceptions.end()) {
- m_deactivators.insert(deactivator);
+ if (!parent.m_sink) {
+ LOG_RETURN(RES_FAIL, "parent.m_sink is NULL!");
+ }
+
+ for (auto deactivator: parent.m_deactivators) {
+ if (m_deactivatorExceptions.find(deactivator) ==
+ m_deactivatorExceptions.end()) {
+ m_deactivators.insert(deactivator);
+ }
}
- }
- if (flags & PF_ADD_DEACTIVATOR_SOURCES) {
addDeactivatorSource(*parent.m_sink);
+ m_parentSink = parent.m_sink;
m_hasBuildInSources = true;
}
if (flags & PF_ADD_SELF_EXCEPT) {
- addDeactivatorException(m_rc->getObjPtr());
+ addDeactivatorException(getObjPtr());
}
m_window = parent.m_window;
- m_parentSink = parent.m_sink;
m_isChild = true;
m_isPrepared = true;
return RES_OK;
}
- Window &Presenter::getWindow()
+ Window &GuiPresenter::getWindow()
{
UCL_ASSERT(isWindowReady(), "m_window is NULL!");
return *m_window;
}
- bool Presenter::isWindowReady() const
+ bool GuiPresenter::isWindowReady() const
{
return !!m_window;
}
- void Presenter::addDeactivatorException(const void *const deactivator)
+ void GuiPresenter::addDeactivatorException(const void *const deactivator)
{
const auto pair = m_deactivatorExceptions.insert(deactivator);
if (pair.second) {
@@ -119,86 +118,86 @@ namespace callui {
}
}
- void Presenter::setDeactivatorSink(const WidgetSRef &sink)
+ void GuiPresenter::setDeactivatorSink(const WidgetSRef &sink)
{
m_sink = sink;
}
- void Presenter::sendActivate(Widget &sender)
+ void GuiPresenter::sendActivate(Widget &sender)
{
- sendDeactivator(sender, impl::ACTIVATE_BY, m_rc->getObjPtr());
+ sendDeactivator(sender, impl::ACTIVATE_BY, getObjPtr());
}
- void Presenter::sendDeactivate(Widget &sender)
+ void GuiPresenter::sendDeactivate(Widget &sender)
{
- sendDeactivator(sender, impl::DEACTIVATE_BY, m_rc->getObjPtr());
+ sendDeactivator(sender, impl::DEACTIVATE_BY, getObjPtr());
}
- void Presenter::broadcastActivate()
+ void GuiPresenter::broadcastActivate()
{
- broadcastDeactivator(impl::ACTIVATE_BY, m_rc->getObjPtr());
+ broadcastDeactivator(impl::ACTIVATE_BY, getObjPtr());
}
- void Presenter::broadcastDeactivate()
+ void GuiPresenter::broadcastDeactivate()
{
- broadcastDeactivator(impl::DEACTIVATE_BY, m_rc->getObjPtr());
+ broadcastDeactivator(impl::DEACTIVATE_BY, getObjPtr());
}
- void Presenter::sendDeactivator(Widget &sender,
+ void GuiPresenter::sendDeactivator(Widget &sender,
SmartEvent event, const void *deactivator)
{
sendDeactivatorInfo(sender, event, {deactivator, false});
}
- void Presenter::broadcastDeactivator(const SmartEvent event,
+ void GuiPresenter::broadcastDeactivator(const SmartEvent event,
const void *const deactivator)
{
sendDeactivatorInfo(*m_window, event, {deactivator, true});
}
- void Presenter::sendDeactivatorInfo(Widget &sender,
+ void GuiPresenter::sendDeactivatorInfo(Widget &sender,
const SmartEvent event, const DeactivatorInfo &info)
{
sender.callEvent(event, const_cast<DeactivatorInfo *>(&info));
}
- bool Presenter::isActive() const
+ bool GuiPresenter::isActive() const
{
return isEmpty(m_deactivators);
}
- bool Presenter::isDeactivatedBy(const void *const deactivator) const
+ bool GuiPresenter::isDeactivatedBy(const void *const deactivator) const
{
return (m_deactivators.find(deactivator) != m_deactivators.end());
}
- void Presenter::activateBy(const void *const deactivator)
+ void GuiPresenter::activateBy(const void *const deactivator)
{
activateByImpl({deactivator, false});
}
- void Presenter::deactivateBy(const void *const deactivator)
+ void GuiPresenter::deactivateBy(const void *const deactivator)
{
deactivateByImpl({deactivator, false});
}
- void Presenter::addDeactivatorSource(Widget &source)
+ void GuiPresenter::addDeactivatorSource(Widget &source)
{
- source.addEventHandler(impl::ACTIVATE_BY,
- WEAK_DELEGATE(Presenter::onActivateBySmart, asWeak(*this)));
- source.addEventHandler(impl::DEACTIVATE_BY,
- WEAK_DELEGATE(Presenter::onDeactivateBySmart, asWeak(*this)));
+ source.addEventHandler(impl::ACTIVATE_BY, WEAK_DELEGATE(
+ GuiPresenter::onActivateBySmart, asWeak(*this)));
+ source.addEventHandler(impl::DEACTIVATE_BY, WEAK_DELEGATE(
+ GuiPresenter::onDeactivateBySmart, asWeak(*this)));
}
- void Presenter::delDeactivatorSource(Widget &source)
+ void GuiPresenter::delDeactivatorSource(Widget &source)
{
- source.delEventHandler(impl::ACTIVATE_BY,
- WEAK_DELEGATE(Presenter::onActivateBySmart, asWeak(*this)));
- source.delEventHandler(impl::DEACTIVATE_BY,
- WEAK_DELEGATE(Presenter::onDeactivateBySmart, asWeak(*this)));
+ source.delEventHandler(impl::ACTIVATE_BY, WEAK_DELEGATE(
+ GuiPresenter::onActivateBySmart, asWeak(*this)));
+ source.delEventHandler(impl::DEACTIVATE_BY, WEAK_DELEGATE(
+ GuiPresenter::onDeactivateBySmart, asWeak(*this)));
}
- void Presenter::activateByImpl(const DeactivatorInfo &info)
+ void GuiPresenter::activateByImpl(const DeactivatorInfo &info)
{
const auto count = m_deactivators.erase(info.deactivator);
if (m_isPrepared && (count > 0)) {
@@ -212,7 +211,7 @@ namespace callui {
}
}
- void Presenter::deactivateByImpl(const DeactivatorInfo &info)
+ void GuiPresenter::deactivateByImpl(const DeactivatorInfo &info)
{
if (m_deactivatorExceptions.find(info.deactivator) !=
m_deactivatorExceptions.end()) {
@@ -230,29 +229,29 @@ namespace callui {
}
}
- void Presenter::onActivateBySmart(Widget &widget, void *eventInfo)
+ void GuiPresenter::onActivateBySmart(Widget &widget, void *eventInfo)
{
activateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
}
- void Presenter::onDeactivateBySmart(Widget &widget, void *eventInfo)
+ void GuiPresenter::onDeactivateBySmart(Widget &widget, void *eventInfo)
{
deactivateByImpl(*static_cast<DeactivatorInfo *>(eventInfo));
}
- void Presenter::onActivate()
+ void GuiPresenter::onActivate()
{
}
- void Presenter::onDeactivate()
+ void GuiPresenter::onDeactivate()
{
}
- void Presenter::onActivateBy(const DeactivatorInfo &info)
+ void GuiPresenter::onActivateBy(const DeactivatorInfo &info)
{
}
- void Presenter::onDeactivateBy(const DeactivatorInfo &info)
+ void GuiPresenter::onDeactivateBy(const DeactivatorInfo &info)
{
}
}
diff --git a/ucl/src/mvp/ListItemPresenter.cpp b/ucl/src/mvp/ListItemPresenter.cpp
new file mode 100644
index 0000000..e2ad69a
--- /dev/null
+++ b/ucl/src/mvp/ListItemPresenter.cpp
@@ -0,0 +1,292 @@
+/*
+ * 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()
+ {
+ }
+}
diff --git a/ucl/src/mvp/ListPresenter.cpp b/ucl/src/mvp/ListPresenter.cpp
new file mode 100644
index 0000000..220b10e
--- /dev/null
+++ b/ucl/src/mvp/ListPresenter.cpp
@@ -0,0 +1,326 @@
+/*
+ * 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);
+ }
+}
diff --git a/ucl/src/mvp/common.h b/ucl/src/mvp/common.h
new file mode 100644
index 0000000..2894a14
--- /dev/null
+++ b/ucl/src/mvp/common.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_MVP_COMMON_H__
+#define __UCL_MVP_COMMON_H__
+
+#include "../common.h"
+
+#endif // __UCL_MVP_COMMON_H__