UCL_DECLARE_REF_ALIASES(IActiveCall);
- class IActiveCall : public ucl::Polymorphic {
+ class IActiveCall : protected ucl::NonCopyable {
public:
virtual ICallInfoSCRef getInfo() const = 0;
virtual bool isDialingMode() const = 0;
virtual ucl::Result hold() = 0;
virtual ucl::Result end() = 0;
virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) = 0;
+
+ protected:
+ ~IActiveCall() = default;
};
}
namespace callui {
- class IBaseCallInfo : public ucl::Polymorphic {
+ class IBaseCallInfo : protected ucl::NonCopyable {
public:
virtual unsigned int getCallId() const = 0;
virtual const std::string &getPhoneNumber() const = 0;
virtual IContactInfoSCRef getContactInfo() const = 0;
+
+ protected:
+ ~IBaseCallInfo() = default;
};
}
UCL_DECLARE_REF_ALIASES(ICallListener);
- class ICallListener : public ucl::Polymorphic {
+ class ICallListener : protected ucl::NonCopyable {
public:
virtual void onCallEvent(CallEventType type) = 0;
virtual void onError(CallErr err) = 0;
+
+ protected:
+ ~ICallListener() = default;
};
}
UCL_DECLARE_REF_ALIASES(ICallManager);
- class ICallManager : public ucl::Polymorphic {
+ class ICallManager : protected ucl::NonCopyable {
public:
virtual IIncomingCallSRef getIncomingCall() = 0;
virtual IActiveCallSRef getActiveCall() = 0;
virtual IHeldCallSRef getHeldCall() = 0;
virtual IEndCallSRef getEndCall() = 0;
virtual CallMask getAvailableCalls() const = 0;
+
+ protected:
+ ~ICallManager() = default;
};
}
UCL_DECLARE_REF_ALIASES(ICallUI);
- class ICallUI : public ucl::Polymorphic {
+ class ICallUI : protected ucl::NonCopyable {
public:
virtual void setListener(const ICallListenerWRef &listener) = 0;
virtual ucl::Result processAppControl(app_control_h appControl) = 0;
virtual ISoundManagerSRef getSoundManager() = 0;
virtual ICallManagerSRef getCallManager() = 0;
virtual IIndicatorStateProviderSRef getIndicatorStateProvider() = 0;
+
+ protected:
+ ~ICallUI() = default;
};
}
UCL_DECLARE_REF_ALIASES(IContactInfo);
- class IContactInfo : public ucl::Polymorphic {
+ class IContactInfo : protected ucl::NonCopyable {
public:
virtual const std::string &getName() const = 0;
virtual const std::string &getImagePath() const = 0;
virtual ContactNameSourceType getNameSourceType() const = 0;
+
+ protected:
+ ~IContactInfo() = default;
};
}
UCL_DECLARE_REF_ALIASES(IEndCall);
- class IEndCall : public ucl::Polymorphic {
+ class IEndCall : protected ucl::NonCopyable {
public:
virtual ICallInfoSCRef getInfo() const = 0;
virtual ucl::Result callBack() = 0;
virtual ucl::Result writeMessage() = 0;
+
+ protected:
+ ~IEndCall() = default;
};
}
UCL_DECLARE_REF_ALIASES(IHeldCall);
- class IHeldCall : public ucl::Polymorphic {
+ class IHeldCall : protected ucl::NonCopyable {
public:
virtual ICallInfoSCRef getInfo() const = 0;
virtual ucl::Result unhold() = 0;
virtual ucl::Result swapWithActive() = 0;
virtual ucl::Result end() = 0;
virtual ucl::Result split(const IConferenceCallInfoSCRef &confCallInfo) = 0;
+
+ protected:
+ ~IHeldCall() = default;
};
}
UCL_DECLARE_REF_ALIASES(IIncomingCall);
- class IIncomingCall : public ucl::Polymorphic {
+ class IIncomingCall : protected ucl::NonCopyable {
public:
virtual ICallInfoSCRef getInfo() const = 0;
virtual IRejectMsgProviderSRef getRejectMsgProvider() const = 0;
virtual ucl::Result reject() = 0;
virtual ucl::Result rejectWithMessage(IRejectMsgSRef message) = 0;
virtual ucl::Result stopAlert() = 0;
+
+ protected:
+ ~IIncomingCall() = default;
};
}
UCL_DECLARE_REF_ALIASES(IIndicatorStateListener);
- class IIndicatorStateListener: public ucl::Polymorphic {
+ class IIndicatorStateListener: protected ucl::NonCopyable {
public:
virtual void onStateChanged(IndicatorProperty property) = 0;
+
+ protected:
+ ~IIndicatorStateListener() = default;
};
}
UCL_DECLARE_REF_ALIASES(IIndicatorStateProvider);
- class IIndicatorStateProvider : public ucl::Polymorphic {
+ class IIndicatorStateProvider : protected ucl::NonCopyable {
public:
virtual IndicatorState getState(IndicatorProperty property) const = 0;
virtual void setListener(IIndicatorStateListenerWRef listener) = 0;
+
+ protected:
+ ~IIndicatorStateProvider() = default;
};
}
UCL_DECLARE_REF_ALIASES(IRejectMsg);
- class IRejectMsg : public ucl::Polymorphic {
+ class IRejectMsg : protected ucl::NonCopyable {
public:
virtual std::string getText() const = 0;
+ protected:
+ ~IRejectMsg() = default;
};
}
UCL_DECLARE_REF_ALIASES(IRejectMsgProvider);
- class IRejectMsgProvider : public ucl::Polymorphic {
+ class IRejectMsgProvider : protected ucl::NonCopyable {
public:
using RejectMsgList = std::vector<IRejectMsgSRef>;
public:
virtual RejectMsgList getMsgList() const = 0;
virtual int getMsgCount() const = 0;
+
+ protected:
+ ~IRejectMsgProvider() = default;
};
}
UCL_DECLARE_REF_ALIASES(ISoundManager);
- class ISoundManager: public ucl::Polymorphic {
+ class ISoundManager: protected ucl::NonCopyable {
public:
virtual ucl::Result setSpeakerState(bool isEnable) = 0;
virtual ucl::Result setBluetoothState(bool isEnable) = 0;
NotiHandler handler) = 0;
virtual void delBTHeadsetConnectionChangeHandler(
const NotiHandler &handler) = 0;
+
+ protected:
+ ~ISoundManager() = default;
};
}
UCL_DECLARE_REF_ALIASES(ICallManagerListener);
- class ICallManagerListener : public ucl::Polymorphic {
+ class ICallManagerListener : protected ucl::NonCopyable {
public:
virtual void onCallEvent(CallEventType type) = 0;
virtual void onError(CallManagerErr err) = 0;
+
+ protected:
+ ~ICallManagerListener() = default;
};
}
UCL_DECLARE_REF_ALIASES(IIndicatorStateSource);
- class IIndicatorStateSource : public ucl::Polymorphic {
+ class IIndicatorStateSource : protected ucl::NonCopyable {
public:
virtual IndicatorState getState() const = 0;
virtual void setStateChangeHandler(const NotiHandler &handler) = 0;
+
+ protected:
+ ~IIndicatorStateSource() = default;
};
}
bool SoundManager::isBTSupported() const
{
- return (m_btManager != nullptr);
+ return (m_btManager.get() != nullptr);
}
bool SoundManager::isBTHeadsetConnected() const
Result AccessoryPresenter::launchBluetoothSettings()
{
- AutoAppCtrl appCtrl;
+ AppCtrlAuto appCtrl;
FAIL_RETURN(util::getNz(app_control_create, appCtrl),
"app_control_create() failed!");
Result AccessoryPresenter::launchContacts()
{
- AutoAppCtrl appCtrl;
+ AppCtrlAuto appCtrl;
FAIL_RETURN(util::getNz(app_control_create, appCtrl),
"app_control_create() failed!");
}
if (win->getData(impl::CIRCLE_SURFACE)) {
- LOG_RETURN(RES_ILLEGAL_STATE, "Circle Surface data already set!");
+ LOG_RETURN(RES_INVALID_OPERATION, "Circle Surface data already set!");
}
const auto sfc = eext_circle_surface_conformant_add(win->getConformant());
UCL_DECLARE_REF_ALIASES(IInstance);
- class IInstance : public Polymorphic {
+ class IInstance : protected NonCopyable {
public:
virtual Result onCreate(IInstanceContext *context) = 0;
virtual void onPause() = 0;
virtual void onResume() = 0;
+ protected:
+ ~IInstance() = default;
};
}
namespace ucl {
- class IInstanceAppControlExt : public Polymorphic {
+ class IInstanceAppControlExt : protected NonCopyable {
public:
virtual void onAppControl(app_control_h appControl) = 0;
+ protected:
+ ~IInstanceAppControlExt() = default;
};
}
namespace ucl {
- class IInstanceContext : public Polymorphic {
+ class IInstanceContext : protected NonCopyable {
public:
virtual AppType getAppType() const = 0;
virtual WindowSRef getWindow() = 0;
virtual void exitApp() = 0;
+ protected:
+ ~IInstanceContext() = default;
};
}
namespace ucl {
- class InstanceManagerBase : public Polymorphic {
+ class InstanceManagerBase : protected NonCopyable {
public:
- InstanceManagerBase(AppParams appParams);
- virtual ~InstanceManagerBase();
-
const AppParams &getAppParams() const;
void setSysEventProvider(SysEventProviderUPtr provider);
virtual IInstanceSRef newInstance() const = 0;
protected:
+ InstanceManagerBase(AppParams appParams);
+ ~InstanceManagerBase();
+
SysEventProvider &getSysEventProvider() const;
private:
class SysEventProvider;
using SysEventProviderUPtr = std::unique_ptr<SysEventProvider>;
- class SysEventProvider final : public NonCopyable {
+ class SysEventProvider final : protected NonCopyable {
public:
using EventHandlerAddFunc = int (*)(app_event_handler_h *,
app_event_type_e, app_event_cb, void *);
class UIApp final : private IInstanceContext {
public:
UIApp(InstanceManagerBase &instanceMgr);
- virtual ~UIApp();
+ ~UIApp();
int run(int argc, char *argv[]);
#include "ucl/misc/HashMap.h"
#include "ucl/misc/Event.h"
-#include "ucl/misc/AutoHandle.h"
+#include "ucl/misc/AutoObject.h"
namespace ucl {
using SysEventHandler = WeakDelegate<void(SysEvent)>;
- using AutoAppCtrl = AutoHandle<app_control_h, int, app_control_destroy>;
+ using AppCtrlAuto = AutoObject<app_control_h, int, app_control_destroy>;
}
#endif // __UCL_APPFW_TYPES_H__
class ElmWidget : public Widget {
public:
explicit ElmWidget(Evas_Object *eo, bool isOwner = true);
+ ElmWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true);
virtual ~ElmWidget();
void setEnabled(bool value);
Window *getWindow() const;
protected:
- friend class ReffedObj<ElmWidget>;
- ElmWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true);
-
virtual void setFocusedImpl(bool value) final override;
virtual bool isFocusedImpl() const final override;
virtual bool ensureFwdEvent(SmartEvent fwdEvent) override;
private:
bool m_isAtspiGestureCbSet;
+
+ friend class ReffedObj<ElmWidget>;
};
// Non-member functions //
};
public:
- friend class ReffedObj<Genlist>;
using StyledWidget::StyledWidget;
void setMode(Mode mode);
SmartCbHandler onSelect = nullptr,
GenlistItem::Type type = GenlistItem::Type::SIMPLE,
GenlistItem parent = nullptr);
+
+ private:
+ friend class ReffedObj<Genlist>;
};
}
};
public:
- friend class ReffedObj<Layout>;
using EdjeWidget::EdjeWidget;
explicit Layout(Evas_Object *eo, bool isOwner = true);
bool setEdjeFile(const std::string &filePath, EdjeGroup group);
Variant getData(EdjeDataKey key);
+
+ private:
+ friend class ReffedObj<Layout>;
};
}
std::vector<NaviItem> getItems() const;
private:
- friend class ReffedObj<Naviframe>;
- Naviframe(IRefCountObj &rc, Evas_Object *eo);
+ Naviframe(IRefCountObj &rc, Evas_Object *eo, Private);
void onTransitionFinished(Widget &widget, void *eventInfo);
private:
bool m_isInTransition;
+
+ friend class ReffedObj<Naviframe>;
};
}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_GUI_RADIO_BOX_H__
+#define __UCL_GUI_RADIO_BOX_H__
+
+#include "StyledWidget.h"
+
+namespace ucl {
+
+ UCL_DECLARE_REF_ALIASES(RadioBox);
+
+ class RadioBox final : public StyledWidget {
+ public:
+ class Builder final {
+ public:
+ Builder();
+ Builder &setStyle(ElmStyle style);
+ Builder &setIsOwner(bool value);
+ Builder &setNeedBindToEo(bool value);
+ RadioBoxSRef build(ElmWidget &parent) const;
+ private:
+ ElmStyle m_style;
+ bool m_isOwner;
+ bool m_needBindToEo;
+ };
+
+ public:
+ using StyledWidget::StyledWidget;
+
+ void setItemValue(int value);
+ int getItemValue() const;
+
+ void addToGroup(Elm_Radio *group);
+
+ void setGroupValue(int value);
+ int getGroupValue() const;
+
+ void setGroupValuePointer(int *valuePtr);
+
+ Elm_Radio *getSelectedObject() const;
+
+ private:
+ friend class ReffedObj<RadioBox>;
+ };
+}
+
+#include "RadioBox.hpp"
+
+#endif // __UCL_GUI_RADIO_BOX_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace ucl {
+
+ // RadioBox::Builder //
+
+ inline RadioBox::Builder::Builder() :
+ m_isOwner(true),
+ m_needBindToEo(true)
+ {
+ }
+
+ inline RadioBox::Builder &RadioBox::Builder::setStyle(const ElmStyle style)
+ {
+ m_style = style;
+ return *this;
+ }
+
+ inline RadioBox::Builder &RadioBox::Builder::setIsOwner(const bool value)
+ {
+ m_isOwner = value;
+ return *this;
+ }
+
+ inline RadioBox::Builder &
+ RadioBox::Builder::setNeedBindToEo(const bool value)
+ {
+ m_needBindToEo = value;
+ return *this;
+ }
+
+ // RadioBox //
+
+ inline void RadioBox::setItemValue(const int value)
+ {
+ elm_radio_state_value_set(getEo(), value);
+ }
+
+ inline int RadioBox::getItemValue() const
+ {
+ return elm_radio_state_value_get(getEo());
+ }
+
+ inline void RadioBox::addToGroup(Elm_Radio *const group)
+ {
+ elm_radio_group_add(getEo(), group);
+ }
+
+ inline void RadioBox::setGroupValue(const int value)
+ {
+ elm_radio_value_set(getEo(), value);
+ }
+
+ inline int RadioBox::getGroupValue() const
+ {
+ return elm_radio_value_get(getEo());
+ }
+
+ inline void RadioBox::setGroupValuePointer(int *const valuePtr)
+ {
+ elm_radio_value_pointer_set(getEo(), valuePtr);
+ }
+
+ inline Elm_Radio *RadioBox::getSelectedObject() const
+ {
+ return elm_radio_selected_object_get(getEo());
+ }
+}
class StyledWidget : public EdjeWidget {
public:
- friend class ReffedObj<StyledWidget>;
using EdjeWidget::EdjeWidget;
explicit StyledWidget(Evas_Object *eo, bool isOwner = true);
void setStyle(ElmStyle style);
+
+ private:
+ friend class ReffedObj<StyledWidget>;
};
}
public:
explicit Widget(Evas_Object *eo, bool isOwner = true);
+ Widget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true);
virtual ~Widget();
void bindToEo();
bool isFocused() const;
protected:
- friend class ReffedObj<Widget>;
- Widget(IRefCountObj *rc, Evas_Object *eo, bool isOwner = true);
-
virtual void setFocusedImpl(bool value);
virtual bool isFocusedImpl() const;
virtual bool ensureFwdEvent(SmartEvent fwdEvent);
bool m_isBoundToEo;
bool m_isEoRefKept;
bool m_isSelfRefUnique;
+
+ friend class ReffedObj<Widget>;
};
// Non-member functions //
Elm_Object_Item *getIt() const;
operator Elm_Object_Item *() const;
- operator bool() const;
+ explicit operator bool() const;
Evas_Object *getWidget() const;
void lower();
private:
- friend class ReffedObj<Window>;
Window(IRefCountObj *rc, Evas_Object *eo,
- bool isOwner, Evas_Object *conform);
+ bool isOwner, Evas_Object *conform, Private);
private:
StyledWidget m_conform;
+
+ friend class ReffedObj<Window>;
};
// Non-member functions //
// Window //
inline Window::Window(IRefCountObj *const rc, Evas_Object *const eo,
- const bool isOwner, Evas_Object *const conform) :
+ const bool isOwner, Evas_Object *const conform, Private) :
ElmWidget(rc, eo, isOwner),
m_conform(conform)
{
+++ /dev/null
-/*
- * Copyright 2017 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __UCL_MISC_AUTO_HANDLE_H__
-#define __UCL_MISC_AUTO_HANDLE_H__
-
-#include "ucl/util/types.h"
-
-namespace ucl {
-
- template <class HANDLE, class DEL_RET, DEL_RET(*DEL_FUNC)(HANDLE)>
- struct AutoHandle final : ucl::NonCopyable {
- using Handle = HANDLE;
-
- HANDLE value;
-
- AutoHandle() :
- value()
- {
- }
-
- AutoHandle(std::nullptr_t) :
- AutoHandle()
- {
- }
-
- AutoHandle(HANDLE value) :
- value(value)
- {
- }
-
- ~AutoHandle()
- {
- if (value) {
- DEL_FUNC(value);
- }
- }
-
- AutoHandle(AutoHandle &&src) :
- value(src.value)
- {
- src.value = nullptr;
- }
-
- AutoHandle &operator=(AutoHandle src)
- {
- swap(*this, src);
- return *this;
- }
-
- AutoHandle &operator=(HANDLE value)
- {
- AutoHandle src{value};
- swap(*this, src);
- return *this;
- }
-
- HANDLE *operator&()
- {
- return &value;
- }
-
- operator HANDLE()
- {
- return value;
- }
- };
-
- // Non-member functions //
-
- template <class HANDLE, class DEL_RET, DEL_RET(*DEL_FUNC)(HANDLE)>
- inline void swap(AutoHandle<HANDLE, DEL_RET, DEL_FUNC> &x,
- AutoHandle<HANDLE, DEL_RET, DEL_FUNC> &y) noexcept
- {
- std::swap(x.value, y.value);
- }
-}
-
-#endif // __UCL_MISC_AUTO_HANDLE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_MISC_AUTO_OBJECT_H__
+#define __UCL_MISC_AUTO_OBJECT_H__
+
+#include "ucl/util/types.h"
+
+namespace ucl {
+
+ template <class OBJ_TYPE, class DEL_RET, DEL_RET(*DEL_FUNC)(OBJ_TYPE)>
+ struct AutoObject final : ucl::NonCopyable {
+ using Handle = OBJ_TYPE;
+
+ OBJ_TYPE obj;
+
+ AutoObject() :
+ obj{}
+ {
+ }
+
+ AutoObject(std::nullptr_t) :
+ AutoObject()
+ {
+ }
+
+ AutoObject(const OBJ_TYPE &obj) :
+ obj{obj}
+ {
+ }
+
+ ~AutoObject()
+ {
+ if (obj) {
+ DEL_FUNC(obj);
+ }
+ }
+
+ AutoObject(AutoObject &&src) :
+ obj{src.obj}
+ {
+ src.obj = {};
+ }
+
+ AutoObject &operator=(AutoObject src)
+ {
+ swap(*this, src);
+ return *this;
+ }
+
+ OBJ_TYPE *operator&()
+ {
+ return &obj;
+ }
+
+ operator const OBJ_TYPE &() const
+ {
+ return obj;
+ }
+ };
+
+ // Non-member functions //
+
+ template <class OBJ_TYPE, class DEL_RET, DEL_RET(*DEL_FUNC)(OBJ_TYPE)>
+ inline void swap(AutoObject<OBJ_TYPE, DEL_RET, DEL_FUNC> &x,
+ AutoObject<OBJ_TYPE, DEL_RET, DEL_FUNC> &y) noexcept
+ {
+ using std::swap;
+ swap(x.obj, y.obj);
+ }
+}
+
+#endif // __UCL_MISC_AUTO_HANDLE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_MISC_CARRAY_H__
+#define __UCL_MISC_CARRAY_H__
+
+#include "ucl/util/types.h"
+
+namespace ucl {
+
+ template <class T>
+ struct CArray {
+ T *data;
+ int length;
+
+ CArray() noexcept;
+ CArray(std::nullptr_t) noexcept;
+
+ explicit operator bool() const noexcept;
+ };
+
+ // Non-member functions //
+
+ template <class T>
+ bool isValid(const CArray<T> &array);
+
+ template <class T>
+ bool isEmpty(const CArray<T> &array);
+
+ template <class T, class ITEM_DEL_CB>
+ void performDestroy(const CArray<T> &array, ITEM_DEL_CB &&itemDelCb);
+}
+
+namespace ucl { namespace aux {
+
+ template <class T>
+ void destroyUsingFree(CArray<T> array);
+}}
+
+#include "CArray.hpp"
+
+#endif // __UCL_MISC_CARRAY_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace ucl {
+
+ template <class T>
+ inline CArray<T>::CArray() noexcept :
+ data{nullptr},
+ length{0}
+ {
+ }
+
+ template <class T>
+ inline CArray<T>::CArray(std::nullptr_t) noexcept :
+ CArray()
+ {
+ }
+
+ template <class T>
+ inline CArray<T>::operator bool() const noexcept
+ {
+ return !!data;
+ }
+
+ // Non-member functions //
+
+ template <class T>
+ inline bool isValid(const CArray<T> &array)
+ {
+ return (isEmpty(array) || (array.data && (array.length > 0)));
+ }
+
+ template <class T>
+ inline bool isEmpty(const CArray<T> &array)
+ {
+ return (array.length == 0);
+ }
+
+ template <class T, class ITEM_DEL_CB>
+ inline void performDestroy(const CArray<T> &array, ITEM_DEL_CB &&itemDelCb)
+ {
+ if (array.data) {
+ for (int i = 0; i < array.length; ++i) {
+ itemDelCb(array.data[i]);
+ }
+ free(array.data);
+ }
+ }
+}
+
+namespace ucl { namespace aux {
+
+ template <class T>
+ inline void destroyUsingFree(CArray<T> array)
+ {
+ performDestroy(array, ::free);
+ }
+}}
namespace ucl {
- class CString final : public NonCopyable {
+ class CString final : protected NonCopyable {
public:
friend void swap(CString &x, CString &y) noexcept;
namespace ucl {
- class ConstCString final : public NonCopyable {
+ class ConstCString final : protected NonCopyable {
public:
friend void swap(ConstCString &x, ConstCString &y) noexcept;
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_MISC_MONO_OBSERVABLE_H__
+#define __UCL_MISC_MONO_OBSERVABLE_H__
+
+#include "ucl/util/types.h"
+
+#include "types.h"
+
+namespace ucl {
+
+ template <class T>
+ class MonoObservable final : protected NonCopyable {
+ public:
+ template <class U>
+ friend void swap(MonoObservable<U> &x, MonoObservable<U> &y) noexcept;
+
+ public:
+ MonoObservable() noexcept;
+ explicit MonoObservable(T value) noexcept;
+ MonoObservable(T value, NotiHandler handler) noexcept;
+ MonoObservable(MonoObservable &&rv) noexcept;
+
+ MonoObservable &operator=(MonoObservable v) noexcept;
+
+ void setObserver(NotiHandler handler) noexcept;
+
+ const T &getValue() const noexcept;
+
+ operator const T &() const noexcept;
+
+ MonoObservable &operator=(const T &value);
+ MonoObservable &operator=(T &&value);
+
+ public:
+ T m_value;
+ NotiHandler m_onValueChanged;
+ };
+}
+
+#include "MonoObservable.hpp"
+
+#endif // __UCL_MISC_MONO_OBSERVABLE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace ucl {
+
+ template <class T>
+ inline MonoObservable<T>::MonoObservable() noexcept :
+ m_value{}
+ {
+ }
+
+ template <class T>
+ inline MonoObservable<T>::MonoObservable(T value) noexcept :
+ m_value{std::move(value)}
+ {
+ }
+
+ template <class T>
+ inline MonoObservable<T>::MonoObservable(
+ T value, NotiHandler handler) noexcept :
+ m_value{std::move(value)},
+ m_onValueChanged{std::move(handler)}
+ {
+ }
+
+ template <class T>
+ inline MonoObservable<T>::MonoObservable(MonoObservable &&rv) noexcept :
+ m_value{std::move(rv.m_value)},
+ m_onValueChanged{std::move(rv.m_onValueChanged)}
+ {
+ rv.m_onValueChanged = {};
+ }
+
+ template <class T>
+ inline MonoObservable<T> &
+ MonoObservable<T>::operator=(MonoObservable v) noexcept
+ {
+ swap(*this, v);
+ }
+
+ template <class T>
+ inline void MonoObservable<T>::setObserver(NotiHandler handler) noexcept
+ {
+ m_onValueChanged = std::move(handler);
+ }
+
+ template <class T>
+ inline const T &MonoObservable<T>::getValue() const noexcept
+ {
+ return m_value;
+ }
+
+ template <class T>
+ inline MonoObservable<T>::operator const T &() const noexcept
+ {
+ return getValue();
+ }
+
+ template <class T>
+ inline MonoObservable<T> &MonoObservable<T>::operator=(const T &value)
+ {
+ if (!(value == m_value)) {
+ m_value = value;
+ if (m_onValueChanged) {
+ m_onValueChanged();
+ }
+ }
+ return *this;
+ }
+
+ template <class T>
+ inline MonoObservable<T> &MonoObservable<T>::operator=(T &&value)
+ {
+ if (!(value == m_value)) {
+ m_value = std::move(value);
+ if (m_onValueChanged) {
+ m_onValueChanged();
+ }
+ }
+ return *this;
+ }
+
+ // Non-member functions //
+
+ template <class T>
+ inline void swap(MonoObservable<T> &x, MonoObservable<T> &y) noexcept
+ {
+ using std::swap;
+ swap(x.m_value, y.m_value);
+ swap(x.m_onValueChanged, y.m_onValueChanged);
+ }
+}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_MISC_OBSERVABLE_H__
+#define __UCL_MISC_OBSERVABLE_H__
+
+#include "types.h"
+#include "Event.h"
+
+namespace ucl {
+
+ template <class T>
+ class Observable final : protected NonCopyable {
+ public:
+ template <class U>
+ friend void swap(Observable<U> &x, Observable<U> &y) noexcept;
+
+ public:
+ Observable() noexcept;
+ explicit Observable(T value) noexcept;
+ Observable(Observable &&rv) noexcept;
+
+ Observable &operator=(Observable v) noexcept;
+
+ void addObserver(NotiHandler handler);
+ void removeObserver(const NotiHandler &handler);
+
+ const T &getValue() const noexcept;
+
+ operator const T &() const noexcept;
+
+ Observable &operator=(const T &value);
+ Observable &operator=(T &&value);
+
+ public:
+ T m_value;
+ Event<NotiHandler> m_onValueChanged;
+ };
+}
+
+#include "Observable.hpp"
+
+#endif // __UCL_MISC_OBSERVABLE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace ucl {
+
+ template <class T>
+ inline Observable<T>::Observable() noexcept :
+ m_value{}
+ {
+ }
+
+ template <class T>
+ inline Observable<T>::Observable(T value) noexcept :
+ m_value{std::move(value)}
+ {
+ }
+
+ template <class T>
+ inline Observable<T>::Observable(Observable &&rv) noexcept :
+ m_value{std::move(rv.m_value)},
+ m_onValueChanged{std::move(rv.m_onValueChanged)}
+ {
+ rv.m_onValueChanged = {};
+ }
+
+ template <class T>
+ inline Observable<T> &Observable<T>::operator=(Observable v) noexcept
+ {
+ swap(*this, v);
+ }
+
+ template <class T>
+ inline void Observable<T>::addObserver(NotiHandler handler)
+ {
+ m_onValueChanged += std::move(handler);
+ }
+
+ template <class T>
+ inline void Observable<T>::removeObserver(const NotiHandler &handler)
+ {
+ m_onValueChanged -= handler;
+ }
+
+ template <class T>
+ inline const T &Observable<T>::getValue() const noexcept
+ {
+ return m_value;
+ }
+
+ template <class T>
+ inline Observable<T>::operator const T &() const noexcept
+ {
+ return getValue();
+ }
+
+ template <class T>
+ inline Observable<T> &Observable<T>::operator=(const T &value)
+ {
+ if (!(value == m_value)) {
+ m_value = value;
+ m_onValueChanged.dispatch();
+ }
+ return *this;
+ }
+
+ template <class T>
+ inline Observable<T> &Observable<T>::operator=(T &&value)
+ {
+ if (!(value == m_value)) {
+ m_value = std::move(value);
+ m_onValueChanged.dispatch();
+ }
+ return *this;
+ }
+
+ // Non-member functions //
+
+ template <class T>
+ inline void swap(Observable<T> &x, Observable<T> &y) noexcept
+ {
+ using std::swap;
+ swap(x.m_value, y.m_value);
+ swap(x.m_onValueChanged, y.m_onValueChanged);
+ }
+}
UCL_DECLARE_REF_ALIASES(RefCountAware);
- class RefCountAware : public Polymorphic {
+ class RefCountAware : protected NonCopyable {
public:
bool isShared() const;
UInt getUseCount() const;
protected:
RefCountAware(IRefCountObj *rc);
- virtual ~RefCountAware() = default;
+ ~RefCountAware() = default;
+
+ private:
+ virtual void polymorphismEnabler() final {}
public:
// This section MUST be public!
UCL_DECLARE_REF_ALIASES(Timeout);
- class Timeout final : public NonCopyable {
+ class Timeout final : protected NonCopyable {
public:
using TimeoutHandler = WeakDelegate<void(Timeout *sender)>;
bool isExpired() const;
private:
- friend class ReffedObj<Timeout>;
- Timeout(const TimeoutHandler &handler);
+ Timeout(const TimeoutHandler &handler, Private);
~Timeout();
Result prepare(double timeoutSec);
private:
Ecore_Timer *m_timer;
TimeoutHandler m_handler;
+
+ friend class ReffedObj<Timeout>;
};
}
template <size_t N>
using VarArray = std::array<Variant, N>;
- struct VarInitList final {
- VarInitList(const std::initializer_list<Variant> &il) : il(il) {}
- const std::initializer_list<Variant> &il;
- };
-
class Variant final {
public:
enum Type {
Variant(const VarVector &anArray);
template <size_t N>
Variant(const VarArray<N> &anArray);
- Variant(const VarInitList &anArray);
+ Variant(std::initializer_list<Variant> anArray);
~Variant();
{
}
- inline Variant::Variant(const VarInitList &anArray) :
- Variant(anArray.il.begin(), anArray.il.size())
+ inline Variant::Variant(std::initializer_list<Variant> anArray) :
+ Variant(anArray.begin(), anArray.size())
{
}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_MISC_TYPES_H__
+#define __UCL_MISC_TYPES_H__
+
+#include "ucl/util/smartDelegation.h"
+
+namespace ucl {
+
+ using NotiHandler = WeakDelegate<void()>;
+}
+
+#endif // __UCL_MISC_TYPES_H__
protected:
GuiPresenter(IRefCountObj &rc);
- virtual ~GuiPresenter();
+ ~GuiPresenter();
Result prepare(ElmWidget &widget, int flags = PF_DEFAULT);
Result prepare(GuiPresenter &parent, int flags = PF_DEFAULT);
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_MVP_I_PICKABLE_H__
+#define __UCL_MVP_I_PICKABLE_H__
+
+#include "IPicker.h"
+
+namespace ucl {
+
+ UCL_DECLARE_REF_ALIASES(IPickable);
+
+ class IPickable : protected NonCopyable {
+ public:
+ virtual IPicker &getPicker() = 0;
+ protected:
+ ~IPickable() = default;
+ };
+}
+
+#endif // __UCL_MVP_I_PICKABLE_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_MVP_I_PICKER_H__
+#define __UCL_MVP_I_PICKER_H__
+
+#include "IPickerHost.h"
+
+namespace ucl {
+
+ class IPicker : protected NonCopyable {
+ public:
+ virtual void setPickerHost(IPickerHostWRef host) = 0;
+ virtual void setPicked(bool isPicked) = 0;
+ virtual void updatePicked(bool isPicked) = 0;
+ virtual bool isPicked() const = 0;
+ protected:
+ ~IPicker() = default;
+ };
+}
+
+#endif // __UCL_MVP_I_PICKER_H__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __UCL_MVP_I_PICKER_HOST_H__
+#define __UCL_MVP_I_PICKER_HOST_H__
+
+#include "types.h"
+
+namespace ucl {
+
+ UCL_DECLARE_REF_ALIASES(IPickerHost);
+
+ class IPickerHost : protected NonCopyable {
+ public:
+ virtual void incrementPickCounter() = 0;
+ virtual void decrementPickCounter() = 0;
+ virtual bool isPickModeActive() const = 0;
+ protected:
+ ~IPickerHost() = default;
+ };
+}
+
+#endif // __UCL_MVP_I_PICKER_HOST_H__
#include "ucl/misc/HashMap.h"
-#include "types.h"
+#include "IPicker.h"
namespace ucl {
UCL_DECLARE_REF_ALIASES(ListItemPresenter);
class ListItemPresenter : public RefCountAware,
- public IDisposable {
+ public IDisposable,
+ protected IPicker {
public:
+ Result updateItem();
+
// 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);
itemStyle(itemStyle), itemType(itemType) {}
};
- class ItemClass final : public NonCopyable {
+ struct ItemPickModeParams {
+ EdjePart checkPart;
+ ElmStyle checkStyle;
+
+ bool isValid() const;
+ };
+
+ class ItemClass final : protected NonCopyable {
public:
static ItemClassSRef newInstance(ElmStyle itemStyle);
public:
Elm_Genlist_Item_Class *get();
private:
- friend class ReffedObj<ItemClass>;
- ItemClass(ElmStyle itemStyle);
+ ItemClass(ElmStyle itemStyle, Private);
~ItemClass();
private:
Elm_Genlist_Item_Class *const m_itc;
+ friend class ReffedObj<ItemClass>;
};
- class ItemClassCache final : public NonCopyable {
+ class ItemClassCache final : protected NonCopyable {
public:
ItemClassSRef getItemClass(ElmStyle itemStyle);
void purge();
protected:
ListItemPresenter(IRefCountObj &rc);
- virtual ~ListItemPresenter();
+ ~ListItemPresenter();
void setFlags(int flags);
int getFlags() const;
bool isActive() const;
+ bool isPickModeActive() const;
+ void handleItemPick(bool isPicked);
+
GenlistItem getItem();
ItemClassCache *getItemClassCache();
Result updateItemStyle(ElmStyle newItemStyle);
+ WidgetSRef tryCreatePickModeItemPartContent(
+ EdjePart part, ElmWidget &parent,
+ const ItemPickModeParams ¶ms);
+
virtual ItemInsertionParams getItemInsertionParams() = 0;
virtual void onItemAttached();
virtual void onItemUnrealized();
virtual void onItemHighlighted();
virtual void onItemUnhighlighted();
+ virtual void onItemLongpressed();
+
+ // IPicker //
+
+ virtual void setPickerHost(IPickerHostWRef host) final override;
+ virtual void setPicked(bool isPicked) final override;
+ virtual void updatePicked(bool isPicked) final override;
+ virtual bool isPicked() const final override;
private:
void attachItem(GenlistItem item,
void deleteDetachedItem(bool silent = false);
void detachItem(bool silent = false);
+ void onPickCheckChanged(Widget &widget, void *eventInfo);
void onItemSelectedHook();
void onItemDel(Evas_Object *obj, void *eventInfo);
private:
ListItemPresenterSRef m_selfRef;
+ IPickerHostWRef m_pickerHost;
GenlistItem m_item;
ItemClassCacheSRef m_itcCache;
SharedRef<bool> m_isActiveRef;
ElmWidgetSRef m_parent;
int m_flags;
+ bool m_isItemPicked;
+
+ friend class ListPresenter;
};
}
FLAG_NOTIFY_UNREALIZED = (1 << 9),
FLAG_NOTIFY_HIGHLIGHTED = (1 << 10),
FLAG_NOTIFY_UNHIGHLIGHTED = (1 << 11),
+ FLAG_NOTIFY_LONGPRESSED = (1 << 12),
};
class Builder final {
ListItemPresenter *parent = nullptr);
private:
- friend class ReffedObj<ListPresenter>;
- ListPresenter(IRefCountObj &rc);
- virtual ~ListPresenter();
+ ListPresenter(IRefCountObj &rc, Private);
+ ~ListPresenter();
Result prepare(GuiPresenter &parent, ElmWidget &parentWidget,
ElmStyle style, int flags);
+ void registerItemEvents(int flags);
template <class INSERT_FUNC>
Result insert(ListItemPresenter &itemPresenter,
void onItemUnrealized(Widget &widget, void *eventInfo);
void onItemHighlighted(Widget &widget, void *eventInfo);
void onItemUnhighlighted(Widget &widget, void *eventInfo);
+ void onItemLongpressed(Widget &widget, void *eventInfo);
// GuiPresenter //
GenlistSRef m_genlist;
ListItemPresenter::ItemClassCacheSRef m_itcCache;
SharedRef<bool> m_isActiveRef;
+
+ friend class ReffedObj<ListPresenter>;
};
}
const DATA &getData() const noexcept;
StubA getStubA() const noexcept;
- operator bool() const noexcept;
+ explicit operator bool() const noexcept;
protected:
BaseDelegate(const DATA &data, StubA stubA) noexcept;
#define _UCL_AFS(DELEGATE, FUNC) \
::ucl::AutoFuncSig<DELEGATE, void *, decltype(&FUNC)>
+#define _UCL_AFS_V(DELEGATE, FUNC) \
+ ::ucl::AutoFuncSig<DELEGATE, void, decltype(&FUNC)>
// Helper macro to automatically generate different delegate objects //
-#define _UCL_DELEGATE(DELEGATE, FUNC, DATA) (_UCL_AFS(DELEGATE, FUNC):: \
- Type::make<_UCL_AFS(DELEGATE, FUNC)::Data, &FUNC>(DATA))
+#define _UCL_DELEGATE(DELEGATE, FUNC, DATA) _UCL_AFS(DELEGATE, FUNC)::Type:: \
+ template make<typename _UCL_AFS(DELEGATE, FUNC)::Data, &FUNC>(DATA)
-#define _UCL_DELEGATE_A(DELEGATE, FUNC, DATA) (_UCL_AFS(DELEGATE, FUNC):: \
- Type::makeA<_UCL_AFS(DELEGATE, FUNC)::Data, &FUNC>(DATA))
+#define _UCL_DELEGATE_A(DELEGATE, FUNC, DATA) _UCL_AFS(DELEGATE, FUNC)::Type:: \
+ template makeA<typename _UCL_AFS(DELEGATE, FUNC)::Data, &FUNC>(DATA)
-#define _UCL_DELEGATE_V(DELEGATE, FUNC) \
- (::ucl::AutoFuncSig<DELEGATE, void, decltype(&FUNC)>::\
- Type::make<&FUNC>())
+#define _UCL_DELEGATE_V(DELEGATE, FUNC) _UCL_AFS_V(DELEGATE, FUNC)::Type:: \
+ template make<&FUNC>()
// Helper macro to automatically generate Delegate objects //
// Helper macro to automatically generate Callback stubs //
-#define UCL_CALLBACK_A(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC):: \
- Type::stubA<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
-#define UCL_CALLBACK_B(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC):: \
- Type::stubB<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
+#define UCL_CALLBACK_A(FUNC) &_UCL_AFS(::ucl::Callback, FUNC)::Type:: \
+ template stubA<typename _UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>
+#define UCL_CALLBACK_B(FUNC) &_UCL_AFS(::ucl::Callback, FUNC)::Type:: \
+ template stubB<typename _UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>
-#define UCL_CALLBACK_A2A(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC)::Type:: \
- stubA2A<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
-#define UCL_CALLBACK_B2A(FUNC) (&_UCL_AFS(::ucl::Callback, FUNC)::Type:: \
- stubB2A<_UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>)
+#define UCL_CALLBACK_A2A(FUNC) &_UCL_AFS(::ucl::Callback, FUNC)::Type:: \
+ template stubA2A<typename _UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>
+#define UCL_CALLBACK_B2A(FUNC) &_UCL_AFS(::ucl::Callback, FUNC)::Type:: \
+ template stubB2A<typename _UCL_AFS(::ucl::Callback, FUNC)::Data, &FUNC>
-#define UCL_CALLBACK_A2V(FUNC) (&::ucl::AutoFuncSig<::ucl::Callback, void, \
- decltype(&FUNC)>::Type::stubA2V<&FUNC>)
-#define UCL_CALLBACK_B2V(FUNC) (&::ucl::AutoFuncSig<::ucl::Callback, void, \
- decltype(&FUNC)>::Type::stubB2V<&FUNC>)
+#define UCL_CALLBACK_A2V(FUNC) &_UCL_AFS_V(::ucl::Callback, FUNC)::Type:: \
+ template stubA2V<&FUNC>
+#define UCL_CALLBACK_B2V(FUNC) &_UCL_AFS_V(::ucl::Callback, FUNC)::Type:: \
+ template stubB2V<&FUNC>
#endif // __UCL_UTIL_DELEGATION_MACRO_H__
return (!value || isEmpty(*value));
}
+ template <class T>
+ constexpr auto isValid(const T &value) -> decltype(value.valid())
+ {
+ return value.valid();
+ }
+
+ template <class T>
+ constexpr auto isValid(const T &value) -> decltype(value.isValid())
+ {
+ return value.isValid();
+ }
+
+ template <class T>
+ constexpr auto isValid(const T &value) -> decltype(isValid(*value))
+ {
+ return (value && isValid(*value));
+ }
+
template <class T>
constexpr bool isNotEmpty(T &&value);
public:
using Type = T;
- template <class U>
- friend class BaseRef;
- template <class U>
- friend class SharedRef;
- template <class U>
- friend class WeakRef;
-
public:
UInt getUseCount() const noexcept;
protected:
IRefCountObj *m_rc;
T *m_ptr;
+
+ template <class U>
+ friend class BaseRef;
+ template <class U>
+ friend class SharedRef;
+ template <class U>
+ friend class WeakRef;
};
}
namespace ucl {
- class IRefCountObj : public Polymorphic {
+ class IRefCountObj : protected NonCopyable {
public:
virtual void ref() noexcept = 0;
virtual void unref() noexcept = 0;
virtual UInt getUseCount() const noexcept = 0;
virtual const void *getObjPtr() const noexcept = 0;
protected:
- virtual ~IRefCountObj() = default;
+ ~IRefCountObj() = default;
};
}
std::true_type {};
private:
- virtual ~RefCountObj() = default;
-
template <class T2, class ...ARGS, class =
typename std::enable_if<!IsRefCountAware<T2>::value>::type>
void createObj(const P<0> &, ARGS &&...args)
template <class T>
class ReffedObj final {
private:
- friend class RefCountObj<T, RefCounterST>;
- friend class RefCountObj<T, RefCounterMT>;
-
template <class ...ARGS>
void create(ARGS &&...args);
void destroy() noexcept;
private:
typename std::aligned_storage<sizeof(T), alignof(T)>::type m_obj;
+
+ friend class RefCountObj<T, RefCounterST>;
+ friend class RefCountObj<T, RefCounterMT>;
};
}
void reset() noexcept;
T *get() const noexcept;
- operator bool() const noexcept;
+ explicit operator bool() const noexcept;
T *operator->() const noexcept;
typename std::add_lvalue_reference<T>::type operator*() const noexcept;
SharedRef<T> lock() const noexcept;
T *getUnsafePtr() const noexcept;
- operator bool() const noexcept;
+ explicit operator bool() const noexcept;
template <class U, class = typename std::enable_if<
std::is_convertible<T *, U *>::value && (
#ifndef __UCL_UTIL_MEMORY_MACRO_H__
#define __UCL_UTIL_MEMORY_MACRO_H__
+#define UCL_DECLARE_REF_ALIASES_NOFW(TYPE_NAME) \
+ using TYPE_NAME##SRef = ::ucl::SharedRef<TYPE_NAME>; \
+ using TYPE_NAME##WRef = ::ucl::WeakRef<TYPE_NAME>; \
+ using TYPE_NAME##SCRef = ::ucl::SharedRef<const TYPE_NAME>; \
+ using TYPE_NAME##WCRef = ::ucl::WeakRef<const TYPE_NAME>
+
#define UCL_DECLARE_REF_ALIASES(CLASS_NAME) \
class CLASS_NAME; \
- using CLASS_NAME##SRef = ::ucl::SharedRef<CLASS_NAME>; \
- using CLASS_NAME##WRef = ::ucl::WeakRef<CLASS_NAME>; \
- using CLASS_NAME##SCRef = ::ucl::SharedRef<const CLASS_NAME>; \
- using CLASS_NAME##WCRef = ::ucl::WeakRef<const CLASS_NAME>
+ UCL_DECLARE_REF_ALIASES_NOFW(CLASS_NAME)
#define UCL_USING_REF_ALIASES(CLASS_NAME) \
using CLASS_NAME; \
namespace ucl {
- class CondVar final : public NonCopyable {
+ class CondVar final : protected NonCopyable {
public:
CondVar();
~CondVar();
namespace ucl {
- class Mutex final : public NonCopyable {
+ class Mutex final : protected NonCopyable {
public:
Mutex(bool recursive = false);
~Mutex();
namespace ucl {
- class MutexLock final : public NonCopyable {
+ class MutexLock final : protected NonCopyable {
public:
MutexLock(Mutex &mutex);
~MutexLock();
namespace ucl {
- class Thread final : public NonCopyable {
+ class Thread final : protected NonCopyable {
public:
Thread();
template <class FUNC>
RES_FAIL = -1,
RES_INVALID_ARGUMENTS = -2,
- RES_ILLEGAL_STATE = -3,
+ RES_INVALID_OPERATION = -3,
RES_OUT_OF_MEMORY = -4,
RES_IO_ERROR = -5,
RES_NOT_SUPPORTED = -6,
public:
NonCopyable(const NonCopyable &) = delete;
NonCopyable &operator=(const NonCopyable &) = delete;
+ private:
+ struct PrivateType {};
+ protected:
+ using Private = const PrivateType &;
+ static const PrivateType PRIVATE;
protected:
NonCopyable() = default;
~NonCopyable() = default;
};
- class Polymorphic : public NonCopyable {
- protected:
- Polymorphic() = default;
- virtual ~Polymorphic() = default;
- };
-
- class IDisposable : public Polymorphic {
+ class IDisposable : protected NonCopyable {
public:
virtual void dispose() = 0;
virtual bool isDisposed() const = 0;
protected:
- virtual ~IDisposable() = default;
+ ~IDisposable() = default;
};
template <class IPRODUCT>
- class IFactory : public Polymorphic {
+ class IFactory : protected NonCopyable {
public:
using IProduct = IPRODUCT;
public:
virtual IPRODUCT *newInstance() const = 0;
protected:
- virtual ~IFactory() = default;
+ ~IFactory() = default;
};
template <class PRODUCT, class IPRODUCT>
// SysEventProvider::EventProxy //
- class SysEventProvider::EventProxy : public NonCopyable {
+ class SysEventProvider::EventProxy : protected NonCopyable {
public:
EventProxy(SysEventProvider &provider,
const SysEvent sysEvent,
#include "ucl/gui/Window.h"
#include "ucl/gui/helpers.h"
+#include "common.h"
+
namespace ucl {
ElmWidget::ElmWidget(IRefCountObj *rc, Evas_Object *eo, bool isOwner) :
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include "ucl/gui/Genlist.h"
#include "common.h"
return {};
}
- auto result = makeShared<Naviframe>(eo);
+ auto result = makeShared<Naviframe>(eo, PRIVATE);
if (m_needBindToEo) {
result->bindToEo();
// Naviframe //
- Naviframe::Naviframe(IRefCountObj &rc, Evas_Object *eo) :
+ Naviframe::Naviframe(IRefCountObj &rc, Evas_Object *eo, Private) :
StyledWidget(&rc, eo),
m_isInTransition(false)
{
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ucl/gui/RadioBox.h"
+
+#include "common.h"
+
+namespace ucl {
+
+ // RadioBox::Builder //
+
+ RadioBoxSRef RadioBox::Builder::build(ElmWidget &parent) const
+ {
+ Evas_Object *const eo = elm_radio_add(parent);
+ if (!eo) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "elm_genlist_add() failed!");
+ }
+
+ auto result = makeShared<RadioBox>(eo, m_isOwner);
+
+ if (m_needBindToEo) {
+ result->bindToEo();
+ }
+
+ if (isValid(m_style)) {
+ result->setStyle(m_style);
+ }
+
+ show(*result);
+
+ return result;
+ }
+}
// Widget::EventProxy //
- class Widget::EventProxy : public NonCopyable {
+ class Widget::EventProxy : protected NonCopyable {
public:
EventProxy(Widget &widget, const WidgetEvent event,
const WidgetEventHandler handler) :
elm_win_indicator_opacity_set(winEo, ELM_WIN_INDICATOR_OPAQUE);
elm_win_conformant_set(winEo, EINA_TRUE);
- auto result = makeShared<Window>(winEo, isOwner, conform);
+ auto result = makeShared<Window>(winEo, isOwner, conform, PRIVATE);
if (m_needBindToEo) {
result->bindToEo();
TimeoutSRef Timeout::create(double timeoutSec,
const TimeoutHandler &handler)
{
- auto result = makeShared<Timeout>(handler);
+ auto result = makeShared<Timeout>(handler, PRIVATE);
FAIL_RETURN_VALUE(result->prepare(timeoutSec), {},
"result->prepare() failed!");
return result;
}
- Timeout::Timeout(const TimeoutHandler &handler) :
+ Timeout::Timeout(const TimeoutHandler &handler, Private) :
m_timer(nullptr),
m_handler(handler)
{
#include "ucl/mvp/ListItemPresenter.h"
+#include "ucl/gui/StyledWidget.h"
+#include "ucl/gui/helpers.h"
+
#include "common.h"
+namespace ucl { namespace { namespace impl {
+
+ constexpr SmartEvent CHECK_CHANGED {"changed"};
+}}}
+
namespace ucl {
// ListItemPresenter::ItemClass //
ListItemPresenter::ItemClassSRef ListItemPresenter::ItemClass::
newInstance(const ElmStyle itemStyle)
{
- auto result = makeShared<ItemClass>(itemStyle);
+ auto result = makeShared<ItemClass>(itemStyle, PRIVATE);
if (!result->get()) {
LOG_RETURN_VALUE(RES_FAIL, {}, "Failed to create ItemClass()!");
}
return result;
}
- ListItemPresenter::ItemClass::ItemClass(const ElmStyle itemStyle) :
+ ListItemPresenter::ItemClass::ItemClass(const ElmStyle itemStyle, Private) :
m_itc(elm_genlist_item_class_new())
{
if (!m_itc) {
m_itcMap.clear();
}
+ // ListItemPresenter::ItemPickModeParams //
+
+ bool ListItemPresenter::ItemPickModeParams::isValid() const
+ {
+ using ucl::isValid;
+ return (isValid(checkPart) && isValid(checkStyle));
+ }
+
// ListItemPresenter //
ListItemPresenter::ListItemPresenter(IRefCountObj &rc) :
RefCountAware(&rc),
- m_flags(PF_AUTO_UNSELECT)
+ m_flags(PF_AUTO_UNSELECT),
+ m_isItemPicked(false)
{
}
return (m_isActiveRef ? *m_isActiveRef : false);
}
+ bool ListItemPresenter::isPickModeActive() const
+ {
+ if (const auto host = m_pickerHost.lock()) {
+ return host->isPickModeActive();
+ }
+ return false;
+ }
+
+ void ListItemPresenter::handleItemPick(const bool isPicked)
+ {
+ if (const auto host = m_pickerHost.lock()) {
+
+ if (!host->isPickModeActive()) {
+ WLOG("Pick mode is not active!");
+ return;
+ }
+
+ if (isPicked != m_isItemPicked) {
+ m_isItemPicked = isPicked;
+ if (isPicked) {
+ host->incrementPickCounter();
+ } else {
+ host->decrementPickCounter();
+ }
+ }
+
+ } else {
+ WLOG("m_pickerHost is NULL");
+ }
+ }
+
+ void ListItemPresenter::setPickerHost(IPickerHostWRef host)
+ {
+ m_pickerHost = std::move(host);
+ }
+
+ void ListItemPresenter::setPicked(const bool isPicked)
+ {
+ m_isItemPicked = isPicked;
+ }
+
+ void ListItemPresenter::updatePicked(const bool isPicked)
+ {
+ if (isPicked != m_isItemPicked) {
+ m_isItemPicked = isPicked;
+ updateItem();
+ }
+ }
+
+ bool ListItemPresenter::isPicked() const
+ {
+ return m_isItemPicked;
+ }
+
+ WidgetSRef ListItemPresenter::tryCreatePickModeItemPartContent(
+ EdjePart part, ElmWidget &parent,
+ const ItemPickModeParams ¶ms)
+ {
+ if (isNotValid(params)) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "params is not Valid!");
+ }
+ if (!isPickModeActive()) {
+ return nullptr;
+ }
+ if (part != params.checkPart) {
+ return nullptr;
+ }
+
+ auto check = makeShared<StyledWidget>(elm_check_add(parent));
+ check->setStyle(params.checkStyle);
+
+ elm_check_state_set(*check, toEina(m_isItemPicked));
+ evas_object_repeat_events_set(*check, EINA_FALSE);
+ evas_object_propagate_events_set(*check, EINA_FALSE);
+
+ check->addEventHandler(impl::CHECK_CHANGED, WEAK_DELEGATE(
+ ListItemPresenter::onPickCheckChanged, asWeak(*this)));
+
+ return check;
+ }
+
+ void ListItemPresenter::onPickCheckChanged(Widget &widget, void *eventInfo)
+ {
+ if (!isActive()) {
+ elm_check_state_set(widget, toEina(m_isItemPicked));
+ return;
+ }
+
+ handleItemPick(elm_check_state_get(widget));
+
+ if (m_item) {
+ elm_genlist_item_bring_in(m_item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
+ } else {
+ WLOG("m_item is NULL");
+ }
+ }
+
GenlistItem ListItemPresenter::getItem()
{
return m_item;
return m_itcCache.get();
}
+ Result ListItemPresenter::updateItem()
+ {
+ if (!m_item) {
+ LOG_RETURN(RES_INVALID_OPERATION, "m_item is NULL!");
+ }
+
+ m_item.update();
+
+ return RES_OK;
+ }
+
Result ListItemPresenter::updateItemStyle(const ElmStyle newItemStyle)
{
if (!m_item) {
- LOG_RETURN(RES_ILLEGAL_STATE, "m_item is NULL!");
+ LOG_RETURN(RES_INVALID_OPERATION, "m_item is NULL!");
}
if (!m_itcCache) {
LOG_RETURN(RES_FATAL, "m_itcCache is NULL!");
void ListItemPresenter::onItemUnhighlighted()
{
}
+
+ void ListItemPresenter::onItemLongpressed()
+ {
+ }
}
constexpr SmartEvent ITEM_UNREALIZED {"unrealized"};
constexpr SmartEvent ITEM_HIGHLIGHTED {"highlighted"};
constexpr SmartEvent ITEM_UNHIGHLIGHTED {"unhighlighted"};
+ constexpr SmartEvent ITEM_LONGPRESSED {"longpressed"};
ListItemPresenter *toItemPresenter(void *eventInfo)
{
"m_parentWidget is NULL!");
}
- auto result = makeShared<ListPresenter>();
+ auto result = makeShared<ListPresenter>(PRIVATE);
FAIL_RETURN_VALUE(result->prepare(
parent, *m_parentWidget, m_style, m_flags),
// ListPresenter //
- ListPresenter::ListPresenter(IRefCountObj &rc) :
+ ListPresenter::ListPresenter(IRefCountObj &rc, Private) :
GuiPresenter(rc)
{
}
m_isActiveRef = makeShared<bool>();
*m_isActiveRef = isActive();
+ registerItemEvents(flags);
+
+ return RES_OK;
+ }
+
+ void ListPresenter::registerItemEvents(int flags)
+ {
m_genlist->addEventHandler(impl::ITEM_SELECTED, WEAK_DELEGATE(
ListPresenter::onItemSelected, asWeak(*this)));
m_genlist->addEventHandler(impl::ITEM_UNHIGHLIGHTED, WEAK_DELEGATE(
ListPresenter::onItemUnhighlighted, asWeak(*this)));
}
-
- return RES_OK;
+ if (flags & FLAG_NOTIFY_LONGPRESSED) {
+ m_genlist->addEventHandler(impl::ITEM_LONGPRESSED, WEAK_DELEGATE(
+ ListPresenter::onItemLongpressed, asWeak(*this)));
+ }
}
Genlist &ListPresenter::getWidget()
itemPresenter->onItemUnhighlighted();
}
+ void ListPresenter::onItemLongpressed(Widget &widget, void *eventInfo)
+ {
+ const auto itemPresenter = impl::toItemPresenter(eventInfo);
+ if (!itemPresenter) {
+ LOG_RETURN_VOID(RES_FATAL, "itemPresenter is NULL");
+ }
+ itemPresenter->onItemLongpressed();
+ }
+
void ListPresenter::onActivate()
{
setIsActiveRef(true);
{"RES_NOT_SUPPORTED", DLOG_ERROR},
{"RES_IO_ERROR", DLOG_ERROR},
{"RES_OUT_OF_MEMORY", DLOG_ERROR},
- {"RES_ILLEGAL_STATE", DLOG_ERROR},
+ {"RES_INVALID_OPERATION", DLOG_ERROR},
{"RES_INVALID_ARGUMENTS", DLOG_ERROR},
{"RES_FAIL", DLOG_ERROR},
{"RES_OK", DLOG_INFO},
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ucl/util/types/classTypes.h"
+
+namespace ucl {
+
+ const NonCopyable::PrivateType NonCopyable::PRIVATE;
+}