From: Igor Olshevskyi Date: Wed, 29 Mar 2017 11:05:42 +0000 (+0300) Subject: Update ucl X-Git-Tag: submit/tizen/20170630.111746~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af8b4e1eb008abd85f65f942bed8bbd2da102910;p=profile%2Fwearable%2Fapps%2Fnative%2Fcall-ui.git Update ucl Change-Id: I183f38fca5eb0a0c04ee922df61c7d3301983903 Signed-off-by: Igor Olshevskyi --- diff --git a/inc/main/InstanceManager.h b/inc/main/InstanceManager.h index 7154dff..9bca1da 100644 --- a/inc/main/InstanceManager.h +++ b/inc/main/InstanceManager.h @@ -29,7 +29,7 @@ namespace callui { // ucl::InstanceManagerBase // - virtual ucl::IInstance *newInstance() const final override; + virtual ucl::IInstanceSRef newInstance() const final override; }; } diff --git a/src/main/InstanceManager.cpp b/src/main/InstanceManager.cpp index a42e593..92e6dfa 100644 --- a/src/main/InstanceManager.cpp +++ b/src/main/InstanceManager.cpp @@ -29,8 +29,8 @@ namespace callui { { } - IInstance *InstanceManager::newInstance() const + IInstanceSRef InstanceManager::newInstance() const { - return new Instance(getSysEventProvider()); + return makeShared(getSysEventProvider()); } } diff --git a/ucl/inc/ucl/appfw/IInstance.h b/ucl/inc/ucl/appfw/IInstance.h index 7d69f33..dc94d90 100644 --- a/ucl/inc/ucl/appfw/IInstance.h +++ b/ucl/inc/ucl/appfw/IInstance.h @@ -5,8 +5,7 @@ namespace ucl { - class IInstance; - using IInstanceUPtr = std::unique_ptr; + UCL_DECLARE_REF_ALIASES(IInstance); class IInstance : public Polymorphic { public: diff --git a/ucl/inc/ucl/appfw/InstanceManagerBase.h b/ucl/inc/ucl/appfw/InstanceManagerBase.h index 27decbd..af161bd 100644 --- a/ucl/inc/ucl/appfw/InstanceManagerBase.h +++ b/ucl/inc/ucl/appfw/InstanceManagerBase.h @@ -15,7 +15,7 @@ namespace ucl { void setSysEventProvider(SysEventProviderUPtr provider); - virtual IInstance *newInstance() const = 0; + virtual IInstanceSRef newInstance() const = 0; protected: SysEventProvider &getSysEventProvider() const; diff --git a/ucl/inc/ucl/appfw/UIApp.h b/ucl/inc/ucl/appfw/UIApp.h index ccd628a..417fc35 100644 --- a/ucl/inc/ucl/appfw/UIApp.h +++ b/ucl/inc/ucl/appfw/UIApp.h @@ -36,7 +36,7 @@ namespace ucl { private: InstanceManagerBase &m_instanceMgr; WindowSRef m_window; - IInstanceUPtr m_instance; + IInstanceSRef m_instance; }; } diff --git a/ucl/inc/ucl/appfw/helpers.h b/ucl/inc/ucl/appfw/helpers.h new file mode 100644 index 0000000..fe598d9 --- /dev/null +++ b/ucl/inc/ucl/appfw/helpers.h @@ -0,0 +1,27 @@ +/* + * 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_APPFW_HELPERS_H__ +#define __UCL_APPFW_HELPERS_H__ + +#include "types.h" + +namespace ucl { + + std::string getResPath(const char *relativePath); +} + +#endif // __UCL_APPFW_HELPERS_H__ diff --git a/ucl/inc/ucl/config.h b/ucl/inc/ucl/config.h index ba0a30c..d012c6b 100644 --- a/ucl/inc/ucl/config.h +++ b/ucl/inc/ucl/config.h @@ -20,7 +20,7 @@ #define UCL_MAX_LOG_LEVEL UCL_LOG_LEVEL_INFO #endif -#define UCL_DEFAULT_LOG_TAG "UCL" +#define UCL_DEFAULT_LOG_TAG "CALLUI_UCL" #define UCL_INCLUDE_DELEGATION_SHORT_MACRO_H 1 #define UCL_INCLUDE_SMART_DELEGATION_SHORT_MACRO_H 1 diff --git a/ucl/inc/ucl/gui/EdjeWidget.h b/ucl/inc/ucl/gui/EdjeWidget.h index 4724e86..d89747d 100644 --- a/ucl/inc/ucl/gui/EdjeWidget.h +++ b/ucl/inc/ucl/gui/EdjeWidget.h @@ -10,18 +10,18 @@ namespace ucl { class EdjeWidget : public ElmWidget { public: void setText(const TString &value); - void setPartText(EdjePart part, const TString &value); + void setText(EdjePart part, const TString &value); TString getText() const; - TString getPartText(EdjePart part) const; + TString getText(EdjePart part) const; void setContent(Evas_Object *content); - void setPartContent(EdjePart part, Evas_Object *content); + void setContent(EdjePart part, Evas_Object *content); Evas_Object *unsetContent(); - Evas_Object *unsetPartContent(EdjePart part); + Evas_Object *unsetContent(EdjePart part); Evas_Object *getContent() const; - Evas_Object *getPartContent(EdjePart part) const; + Evas_Object *getContent(EdjePart part) const; void emitSignal(EdjeSignal signal, EdjeSignalSrc source); diff --git a/ucl/inc/ucl/gui/EdjeWidget.hpp b/ucl/inc/ucl/gui/EdjeWidget.hpp index ee75045..7105fcc 100644 --- a/ucl/inc/ucl/gui/EdjeWidget.hpp +++ b/ucl/inc/ucl/gui/EdjeWidget.hpp @@ -11,7 +11,7 @@ namespace ucl { return elm_object_text_get(getEo()); } - inline TString EdjeWidget::getPartText(const EdjePart part) const + inline TString EdjeWidget::getText(const EdjePart part) const { return elm_object_part_text_get(getEo(), part.name); } @@ -21,7 +21,7 @@ namespace ucl { elm_object_content_set(getEo(), content); } - inline void EdjeWidget::setPartContent(const EdjePart part, + inline void EdjeWidget::setContent(const EdjePart part, Evas_Object *const content) { elm_object_part_content_set(getEo(), part.name, content); @@ -32,7 +32,7 @@ namespace ucl { return elm_object_content_unset(getEo()); } - inline Evas_Object *EdjeWidget::unsetPartContent(const EdjePart part) + inline Evas_Object *EdjeWidget::unsetContent(const EdjePart part) { return elm_object_part_content_unset(getEo(), part.name); } @@ -42,7 +42,7 @@ namespace ucl { return elm_object_content_get(getEo()); } - inline Evas_Object *EdjeWidget::getPartContent(const EdjePart part) const + inline Evas_Object *EdjeWidget::getContent(const EdjePart part) const { return elm_object_part_content_get(getEo(), part.name); } diff --git a/ucl/inc/ucl/gui/ElmWidget.h b/ucl/inc/ucl/gui/ElmWidget.h index 108bbd5..b0df1ad 100644 --- a/ucl/inc/ucl/gui/ElmWidget.h +++ b/ucl/inc/ucl/gui/ElmWidget.h @@ -5,6 +5,8 @@ namespace ucl { + class Window; + UCL_DECLARE_REF_ALIASES(ElmWidget); class ElmWidget : public Widget { @@ -15,6 +17,15 @@ namespace ucl { void setEnabled(bool value); bool isEnabled() const; + void setFocusAlowed(bool value); + bool isFocusAlowed() const; + + void setTheme(Elm_Theme *th); + Elm_Theme *getTheme(); + + Evas_Object *getTopWidget() const; + Window *getWindow() const; + protected: virtual void setFocusedImpl(bool value) final override; virtual bool isFocusedImpl() const final override; diff --git a/ucl/inc/ucl/gui/ElmWidget.hpp b/ucl/inc/ucl/gui/ElmWidget.hpp index 3febf5f..814b258 100644 --- a/ucl/inc/ucl/gui/ElmWidget.hpp +++ b/ucl/inc/ucl/gui/ElmWidget.hpp @@ -10,6 +10,31 @@ namespace ucl { return !elm_object_disabled_get(getEo()); } + inline void ElmWidget::setFocusAlowed(const bool value) + { + elm_object_focus_allow_set(getEo(), toEina(value)); + } + + inline bool ElmWidget::isFocusAlowed() const + { + return elm_object_focus_allow_get(getEo()); + } + + inline void ElmWidget::setTheme(Elm_Theme *th) + { + elm_object_theme_set(getEo(), th); + } + + inline Elm_Theme *ElmWidget::getTheme() + { + return elm_object_theme_get(getEo()); + } + + inline Evas_Object *ElmWidget::getTopWidget() const + { + return elm_object_top_widget_get(getEo()); + } + // Non-member functions // inline void enable(ElmWidget &widget) diff --git a/ucl/inc/ucl/gui/Layout.h b/ucl/inc/ucl/gui/Layout.h index a068416..80f3f26 100644 --- a/ucl/inc/ucl/gui/Layout.h +++ b/ucl/inc/ucl/gui/Layout.h @@ -30,8 +30,10 @@ namespace ucl { using EdjeWidget::EdjeWidget; explicit Layout(Evas_Object *eo, bool isOwner = false); - void setTheme(const LayoutTheme &theme); - void setEdjeFile(const std::string &filePath, EdjeGroup group); + bool setTheme(const LayoutTheme &theme); + bool setEdjeFile(const std::string &filePath, EdjeGroup group); + + Variant getEdjeData(EdjeDataKey key); }; } diff --git a/ucl/inc/ucl/gui/Layout.hpp b/ucl/inc/ucl/gui/Layout.hpp index bfad60c..3516b4a 100644 --- a/ucl/inc/ucl/gui/Layout.hpp +++ b/ucl/inc/ucl/gui/Layout.hpp @@ -41,14 +41,20 @@ namespace ucl { { } - inline void Layout::setTheme(const LayoutTheme &theme) + inline bool Layout::setTheme(const LayoutTheme &theme) { - elm_layout_theme_set(getEo(), theme.klass, theme.group, theme.style); + return elm_layout_theme_set(getEo(), + theme.klass, theme.group, theme.style); } - inline void Layout::setEdjeFile(const std::string &filePath, + inline bool Layout::setEdjeFile(const std::string &filePath, const EdjeGroup group) { - elm_layout_file_set(getEo(), filePath.c_str(), group.name); + return elm_layout_file_set(getEo(), filePath.c_str(), group.name); + } + + inline Variant Layout::getEdjeData(EdjeDataKey key) + { + return elm_layout_data_get(getEo(), key); } } diff --git a/ucl/inc/ucl/gui/NaviItem.h b/ucl/inc/ucl/gui/NaviItem.h index 941d510..6b3bd6a 100644 --- a/ucl/inc/ucl/gui/NaviItem.h +++ b/ucl/inc/ucl/gui/NaviItem.h @@ -5,7 +5,7 @@ namespace ucl { - class NaviItem : public WidgetItem { + class NaviItem final : public WidgetItem { public: using PopHandler = Delegate; diff --git a/ucl/inc/ucl/gui/NaviItem.hpp b/ucl/inc/ucl/gui/NaviItem.hpp index db2705b..ef60d29 100644 --- a/ucl/inc/ucl/gui/NaviItem.hpp +++ b/ucl/inc/ucl/gui/NaviItem.hpp @@ -6,16 +6,6 @@ namespace ucl { handler.getStubA(), handler.getData()); } - inline void NaviItem::popTo() const - { - elm_naviframe_item_pop_to(getIt()); - } - - inline void NaviItem::promote() const - { - elm_naviframe_item_promote(getIt()); - } - inline void NaviItem::setTitleEnabled( const bool value, const bool useTransition) const { diff --git a/ucl/inc/ucl/gui/Naviframe.h b/ucl/inc/ucl/gui/Naviframe.h index 0f2aa2a..b516813 100644 --- a/ucl/inc/ucl/gui/Naviframe.h +++ b/ucl/inc/ucl/gui/Naviframe.h @@ -8,12 +8,13 @@ namespace ucl { + constexpr SmartEvent NAVI_TRANSITION_STARTED {"ucl,transition,started"}; + constexpr SmartEvent NAVI_TRANSITION_FINISHED {"transition,finished"}; + UCL_DECLARE_REF_ALIASES(Naviframe); - class Naviframe : public StyledWidget { + class Naviframe final : public StyledWidget { public: - static constexpr SmartEvent TRANSITION_FINISHED {"transition,finished"}; - class Builder { public: Builder(); @@ -28,9 +29,10 @@ namespace ucl { }; public: - friend class RefCountObj; using StyledWidget::StyledWidget; + bool isInTransition() const; + void setAutoBackBtn(bool value); bool isAutoBackBtn() const; @@ -47,18 +49,18 @@ namespace ucl { NaviItem push(const TString &title, Evas_Object *content); NaviItem push(Evas_Object *content); - NaviItem insertAfter(const TString &title, NaviItem after, + NaviItem insertAfter(NaviItem after, const TString &title, Evas_Object *backBtn, Evas_Object *moreBtn, Evas_Object *content, ElmStyle style); - NaviItem insertAfter(const TString &title, NaviItem after, + NaviItem insertAfter(NaviItem after, const TString &title, Evas_Object *content); NaviItem insertAfter(NaviItem after, Evas_Object *content); - NaviItem insertBefore(const TString &title, NaviItem before, + NaviItem insertBefore(NaviItem before, const TString &title, Evas_Object *backBtn, Evas_Object *moreBtn, Evas_Object *content, ElmStyle style); - NaviItem insertBefore(const TString &title, NaviItem before, + NaviItem insertBefore(NaviItem before, const TString &title, Evas_Object *content); NaviItem insertBefore(NaviItem before, Evas_Object *content); @@ -66,6 +68,18 @@ namespace ucl { NaviItem getTopItem()const; NaviItem getBottomItem() const; std::vector getItems() const; + + private: + friend class RefCountObj; + friend class NaviItem; + Naviframe(RefCountObjBase &rc, Evas_Object *eo); + + void startTransition(); + + void onTransitionFinished(Widget &widget, void *eventInfo); + + private: + bool m_isInTransition; }; } diff --git a/ucl/inc/ucl/gui/Naviframe.hpp b/ucl/inc/ucl/gui/Naviframe.hpp index 7141377..e6d68bf 100644 --- a/ucl/inc/ucl/gui/Naviframe.hpp +++ b/ucl/inc/ucl/gui/Naviframe.hpp @@ -30,6 +30,11 @@ namespace ucl { // Naviframe // + inline bool Naviframe::isInTransition() const + { + return m_isInTransition; + } + inline void Naviframe::setAutoBackBtn(const bool value) { elm_naviframe_prev_btn_auto_pushed_set(getEo(), toEina(value)); @@ -62,7 +67,11 @@ namespace ucl { inline Evas_Object *Naviframe::pop() { - return elm_naviframe_item_pop(getEo()); + auto result = elm_naviframe_item_pop(getEo()); + if (isValid(getBottomItem())) { + startTransition(); + } + return result; } inline NaviItem Naviframe::push(const TString &title, @@ -72,6 +81,9 @@ namespace ucl { auto result = NaviItem(elm_naviframe_item_push(getEo(), nullptr, backBtn, moreBtn, content, style.name)); result.setTitle(title); + if (result != getBottomItem()) { + startTransition(); + } return result; } @@ -86,8 +98,8 @@ namespace ucl { return push(nullptr, nullptr, nullptr, content, nullptr); } - inline NaviItem Naviframe::insertAfter(const TString &title, - NaviItem after, + inline NaviItem Naviframe::insertAfter(NaviItem after, + const TString &title, Evas_Object *const backBtn, Evas_Object *const moreBtn, Evas_Object *const content, const ElmStyle style) { @@ -97,20 +109,20 @@ namespace ucl { return result; } - inline NaviItem Naviframe::insertAfter(const TString &title, - NaviItem after, Evas_Object *const content) + inline NaviItem Naviframe::insertAfter(NaviItem after, + const TString &title, Evas_Object *const content) { - return insertAfter(title, after, nullptr, nullptr, content, nullptr); + return insertAfter(after, title, nullptr, nullptr, content, nullptr); } inline NaviItem Naviframe::insertAfter(NaviItem after, Evas_Object *const content) { - return insertAfter(nullptr, after, nullptr, nullptr, content, nullptr); + return insertAfter(after, nullptr, nullptr, nullptr, content, nullptr); } - inline NaviItem Naviframe::insertBefore(const TString &title, - NaviItem before, + inline NaviItem Naviframe::insertBefore(NaviItem before, + const TString &title, Evas_Object *const backBtn, Evas_Object *const moreBtn, Evas_Object *const content, const ElmStyle style) { @@ -120,16 +132,16 @@ namespace ucl { return result; } - inline NaviItem Naviframe::insertBefore(const TString &title, - NaviItem before, Evas_Object *const content) + inline NaviItem Naviframe::insertBefore(NaviItem before, + const TString &title, Evas_Object *const content) { - return insertAfter(title, before, nullptr, nullptr, content, nullptr); + return insertAfter(before, title, nullptr, nullptr, content, nullptr); } inline NaviItem Naviframe::insertBefore(NaviItem before, Evas_Object *const content) { - return insertAfter(nullptr, before, nullptr, nullptr, content, nullptr); + return insertAfter(before, nullptr, nullptr, nullptr, content, nullptr); } inline NaviItem Naviframe::getTopItem()const diff --git a/ucl/inc/ucl/gui/Theme.h b/ucl/inc/ucl/gui/Theme.h new file mode 100644 index 0000000..f82d675 --- /dev/null +++ b/ucl/inc/ucl/gui/Theme.h @@ -0,0 +1,59 @@ +/* + * 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_THEME_H__ +#define __UCL_GUI_THEME_H__ + +#include "types.h" + +namespace ucl { + + class Theme final : NonCopyable { + public: + static Theme create(); + + friend void swap(Theme &x, Theme &y); + + public: + Theme(); + Theme(nullptr_t); + explicit Theme(Elm_Theme *th, bool isOwner = false); + Theme(Theme &&tmp); + Theme &operator=(Theme &&tmp); + ~Theme(); + + Elm_Theme *getTh(); + const Elm_Theme *getTh() const; + + operator Elm_Theme *(); + operator const Elm_Theme *() const; + + void addExtension(const std::string edjePath); + void addOverlay(const std::string edjePath); + + private: + Elm_Theme *m_th; + bool m_isOwner; + }; + + // Non-member functions // + + bool isValid(const Theme &item); +} + +#include "Theme.hpp" + +#endif // __UCL_GUI_THEME_H__ diff --git a/ucl/inc/ucl/gui/Theme.hpp b/ucl/inc/ucl/gui/Theme.hpp new file mode 100644 index 0000000..dac1d57 --- /dev/null +++ b/ucl/inc/ucl/gui/Theme.hpp @@ -0,0 +1,106 @@ +/* + * 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 Theme Theme::create() + { + Elm_Theme *const th = elm_theme_new(); + if (th) { + elm_theme_ref_set(th, nullptr); + } + return Theme(th, true); + } + + inline Theme::Theme() : + m_th(nullptr), + m_isOwner(false) + { + } + + inline Theme::Theme(nullptr_t) : + Theme() + { + } + + inline Theme::Theme(Elm_Theme *const th, const bool isOwner) : + m_th(th), + m_isOwner(isOwner) + { + } + + inline Theme::Theme(Theme &&tmp) + { + m_th = tmp.m_th; + tmp.m_th = nullptr; + } + + inline Theme &Theme::operator=(Theme &&tmp) + { + swap(*this, tmp); + return *this; + } + + inline Theme::~Theme() + { + if (m_isOwner && m_th) { + elm_theme_free(m_th); + } + } + + inline Elm_Theme *Theme::getTh() + { + return m_th; + } + + inline const Elm_Theme *Theme::getTh() const + { + return m_th; + } + + inline Theme::operator Elm_Theme *() + { + return getTh(); + } + + inline Theme::operator const Elm_Theme *() const + { + return getTh(); + } + + inline void Theme::addExtension(const std::string edjePath) + { + elm_theme_extension_add(getTh(), edjePath.c_str()); + } + + inline void Theme::addOverlay(const std::string edjePath) + { + elm_theme_overlay_add(getTh(), edjePath.c_str()); + } + + // Non-member functions // + + inline bool isValid(const Theme &item) + { + return !!item.getTh(); + } + + inline void swap(Theme &x, Theme &y) + { + std::swap(x.m_th, y.m_th); + std::swap(x.m_isOwner, y.m_isOwner); + } +} diff --git a/ucl/inc/ucl/gui/Widget.h b/ucl/inc/ucl/gui/Widget.h index 6003ba9..d197f80 100644 --- a/ucl/inc/ucl/gui/Widget.h +++ b/ucl/inc/ucl/gui/Widget.h @@ -5,13 +5,13 @@ #include "types.h" -#include "ucl/misc/SharedObject.h" +#include "ucl/misc/RefCountAware.h" namespace ucl { UCL_DECLARE_REF_ALIASES(Widget); - class Widget : public SharedObject { + class Widget : public RefCountAware { public: static constexpr auto EXPAND = EVAS_HINT_EXPAND; static constexpr auto FILL = EVAS_HINT_FILL; @@ -33,17 +33,29 @@ namespace ucl { Evas *getEvas() const; + void setData(EoDataKey key, void *data); + void delData(EoDataKey key); + void *getData(EoDataKey key) const; + void addEventHandler(WidgetEvent event, WidgetEventHandler handler); void addEventHandler(SmartEvent event, WidgetEventHandler handler); void delEventHandler(WidgetEvent event, WidgetEventHandler handler); void delEventHandler(SmartEvent event, WidgetEventHandler handler); + void callSmartEvent(SmartEvent event, void *eventInfo = nullptr); + void markForDeletion(); void setVisible(bool value); bool isVisible() const; + void setColor(int r, int g, int b, int a = 255); + void setColor(int l, int a = 255); + void getColor(int &r, int &g, int &b, int &a) const; + + void calculate(); + void setGeometry(int x, int y, int w, int h); void move(int x, int y); void resize(int w, int h); @@ -60,6 +72,9 @@ namespace ucl { void getMin(int *w, int *h) const; void getMax(int *w, int *h) const; + void setARHint(WidgetARHint arControl, int w, int h); + void getARHint(WidgetARHint &arControl, int &w, int &h); + void setFocused(bool value); bool isFocused() const; @@ -85,7 +100,7 @@ namespace ucl { void setSelfRefUnique(const bool value); - void onEoFree(Evas *e, Evas_Object *obj, void *event_info); + void onEoDel(Evas *e, Evas_Object *obj, void *event_info); void delEventProxy(const EventProxiesIt it); @@ -107,12 +122,15 @@ namespace ucl { // Non-member functions // - void getPosition(const Widget &widget, int &x, int &y); - void getSize(const Widget &widget, int &w, int &h); + void getPosition(const Widget &widget, int *x, int *y); + void getSize(const Widget &widget, int *w, int *h); void show(Widget &widget); void hide(Widget &widget); + void makeTransparent(Widget &widget); + void makeWhite(Widget &widget); + void focus(Widget &widget); void unfocus(Widget &widget); diff --git a/ucl/inc/ucl/gui/Widget.hpp b/ucl/inc/ucl/gui/Widget.hpp index 9ab4692..301dbf9 100644 --- a/ucl/inc/ucl/gui/Widget.hpp +++ b/ucl/inc/ucl/gui/Widget.hpp @@ -43,6 +43,26 @@ namespace ucl { return evas_object_evas_get(getEo()); } + inline void Widget::setData(const EoDataKey key, void *const data) + { + evas_object_data_set(getEo(), key.name, data); + } + + inline void Widget::delData(const EoDataKey key) + { + evas_object_data_del(getEo(), key.name); + } + + inline void *Widget::getData(const EoDataKey key) const + { + return evas_object_data_get(getEo(), key.name); + } + + inline void Widget::callSmartEvent(SmartEvent event, void *eventInfo) + { + evas_object_smart_callback_call(getEo(), event, eventInfo); + } + inline void Widget::markForDeletion() { evas_object_del(getEo()); @@ -62,6 +82,27 @@ namespace ucl { return evas_object_visible_get(getEo()); } + inline void Widget::setColor(const int r, const int g, + const int b, const int a) + { + evas_object_color_set(getEo(), r, g, b, a); + } + + inline void Widget::setColor(const int l, const int a) + { + evas_object_color_set(getEo(), l, l, l, a); + } + + inline void Widget::getColor(int &r, int &g, int &b, int &a) const + { + evas_object_color_get(getEo(), &r, &g, &b, &a); + } + + inline void Widget::calculate() + { + evas_object_smart_calculate(getEo()); + } + inline void Widget::setGeometry(const int x, const int y, const int w, const int h) { @@ -124,6 +165,19 @@ namespace ucl { evas_object_size_hint_max_get(getEo(), w, h); } + inline void Widget::setARHint(WidgetARHint arControl, int w, int h) + { + evas_object_size_hint_aspect_set(getEo(), + static_cast(arControl), w, h); + } + + inline void Widget::getARHint(WidgetARHint &arControl, int &w, int &h) + { + Evas_Aspect_Control tmp = EVAS_ASPECT_CONTROL_NEITHER; + evas_object_size_hint_aspect_get(getEo(), &tmp, &w, &h); + arControl = static_cast(tmp); + } + inline void Widget::setFocused(const bool value) { setFocusedImpl(value); @@ -136,14 +190,14 @@ namespace ucl { // Non-member functions // - inline void getPosition(const Widget &widget, int &x, int &y) + inline void getPosition(const Widget &widget, int *x, int *y) { - widget.getGeometry(&x, &y, nullptr, nullptr); + widget.getGeometry(x, y, nullptr, nullptr); } - inline void getSize(const Widget &widget, int &w, int &h) + inline void getSize(const Widget &widget, int *w, int *h) { - widget.getGeometry(nullptr, nullptr, &w, &h); + widget.getGeometry(nullptr, nullptr, w, h); } inline void show(Widget &widget) @@ -156,6 +210,16 @@ namespace ucl { widget.setVisible(false); } + inline void makeTransparent(Widget &widget) + { + widget.setColor(0, 0); + } + + inline void makeWhite(Widget &widget) + { + widget.setColor(255); + } + inline void focus(Widget &widget) { widget.setFocused(true); diff --git a/ucl/inc/ucl/gui/WidgetItem.h b/ucl/inc/ucl/gui/WidgetItem.h index 859f324..16a2751 100644 --- a/ucl/inc/ucl/gui/WidgetItem.h +++ b/ucl/inc/ucl/gui/WidgetItem.h @@ -15,6 +15,8 @@ namespace ucl { operator Elm_Object_Item *() const; + Evas_Object *getWidget() const; + void setDelCallback(Evas_Smart_Cb cb) const; void del(); @@ -26,18 +28,18 @@ namespace ucl { bool isEnabled() const; void setText(const TString &value) const; - void setPartText(EdjePart part, const TString &value) const; + void setText(EdjePart part, const TString &value) const; TString getText() const; - TString getPartText(EdjePart part) const; + TString getText(EdjePart part) const; void setContent(Evas_Object *content) const; - void setPartContent(EdjePart part, Evas_Object *content) const; + void setContent(EdjePart part, Evas_Object *content) const; Evas_Object *unsetContent() const; - Evas_Object *unsetPartContent(EdjePart part) const; + Evas_Object *unsetContent(EdjePart part) const; Evas_Object *getContent() const; - Evas_Object *getPartContent(EdjePart part) const; + Evas_Object *getContent(EdjePart part) const; void emitSignal(EdjeSignal signal, EdjeSignalSrc source) const; @@ -51,6 +53,9 @@ namespace ucl { void disable(WidgetItem item); bool isValid(WidgetItem item); + + bool operator==(WidgetItem lhs, WidgetItem rhs); + bool operator!=(WidgetItem lhs, WidgetItem rhs); } #include "WidgetItem.hpp" diff --git a/ucl/inc/ucl/gui/WidgetItem.hpp b/ucl/inc/ucl/gui/WidgetItem.hpp index 95c42ad..ef2badc 100644 --- a/ucl/inc/ucl/gui/WidgetItem.hpp +++ b/ucl/inc/ucl/gui/WidgetItem.hpp @@ -25,6 +25,11 @@ namespace ucl { return m_it; } + inline Evas_Object *WidgetItem::getWidget() const + { + return elm_object_item_widget_get(getIt()); + } + inline void WidgetItem::setDelCallback(const Evas_Smart_Cb cb) const { elm_object_item_del_cb_set(getIt(), cb); @@ -61,7 +66,7 @@ namespace ucl { return elm_object_item_text_get(getIt()); } - inline TString WidgetItem::getPartText(const EdjePart part) const + inline TString WidgetItem::getText(const EdjePart part) const { return elm_object_item_part_text_get(getIt(), part.name); } @@ -71,7 +76,7 @@ namespace ucl { elm_object_item_content_set(getIt(), content); } - inline void WidgetItem::setPartContent(const EdjePart part, + inline void WidgetItem::setContent(const EdjePart part, Evas_Object *const content) const { elm_object_item_part_content_set(getIt(), part.name, content); @@ -82,7 +87,7 @@ namespace ucl { return elm_object_item_content_unset(getIt()); } - inline Evas_Object *WidgetItem::unsetPartContent(const EdjePart part) const + inline Evas_Object *WidgetItem::unsetContent(const EdjePart part) const { return elm_object_item_part_content_unset(getIt(), part.name); } @@ -92,7 +97,7 @@ namespace ucl { return elm_object_item_content_get(getIt()); } - inline Evas_Object *WidgetItem::getPartContent(const EdjePart part) const + inline Evas_Object *WidgetItem::getContent(const EdjePart part) const { return elm_object_item_part_content_get(getIt(), part.name); } @@ -105,18 +110,28 @@ namespace ucl { // Non-member functions // - inline void enable(WidgetItem item) + inline void enable(const WidgetItem item) { item.setEnabled(true); } - inline void disable(WidgetItem item) + inline void disable(const WidgetItem item) { item.setEnabled(false); } - inline bool isValid(WidgetItem item) + inline bool isValid(const WidgetItem item) { return !!item.getIt(); } + + inline bool operator==(const WidgetItem lhs, const WidgetItem rhs) + { + return (lhs.getIt() == rhs.getIt()); + } + + inline bool operator!=(const WidgetItem lhs, const WidgetItem rhs) + { + return (lhs.getIt() != rhs.getIt()); + } } diff --git a/ucl/inc/ucl/gui/Window.h b/ucl/inc/ucl/gui/Window.h index e0d49ed..d26dfaf 100644 --- a/ucl/inc/ucl/gui/Window.h +++ b/ucl/inc/ucl/gui/Window.h @@ -7,12 +7,12 @@ namespace ucl { + constexpr SmartEvent WIN_ROTATION_CHANGED {"wm,rotation,changed"}; + UCL_DECLARE_REF_ALIASES(Window); - class Window : public ElmWidget { + class Window final : public ElmWidget { public: - static constexpr SmartEvent ROTATION_CHANGED {"wm,rotation,changed"}; - enum class Type { BASIC = ELM_WIN_BASIC }; diff --git a/ucl/inc/ucl/gui/types.h b/ucl/inc/ucl/gui/types.h index f14ea3d..697e39a 100644 --- a/ucl/inc/ucl/gui/types.h +++ b/ucl/inc/ucl/gui/types.h @@ -10,6 +10,7 @@ #include "ucl/misc/smartDelegation.h" #include "ucl/misc/Aspect.h" #include "ucl/misc/TString.h" +#include "ucl/misc/Variant.h" namespace ucl { @@ -17,6 +18,7 @@ namespace ucl { struct EdjePart : Aspect { using Aspect::Aspect; }; struct EdjeGroup : Aspect { using Aspect::Aspect; }; + struct EdjeDataKey : Aspect { using Aspect::Aspect; }; struct EdjeSignal : Aspect { using Aspect::Aspect; }; struct EdjeSignalSrc : Aspect { using Aspect::Aspect; }; @@ -25,6 +27,8 @@ namespace ucl { struct SmartEvent : Aspect { using Aspect::Aspect; }; + struct EoDataKey : Aspect { using Aspect::Aspect; }; + // WidgetEventHandler // class Widget; @@ -36,7 +40,6 @@ namespace ucl { enum class WidgetEvent { DEL = EVAS_CALLBACK_DEL, - FREE = EVAS_CALLBACK_FREE, MOUSE_IN = EVAS_CALLBACK_MOUSE_IN, MOUSE_OUT = EVAS_CALLBACK_MOUSE_OUT, @@ -68,6 +71,16 @@ namespace ucl { IMAGE_PRELOADED = EVAS_CALLBACK_IMAGE_PRELOADED }; + // WidgetARHint // + + enum class WidgetARHint + { + NEITHER = EVAS_ASPECT_CONTROL_NEITHER, + HORIZONTAL = EVAS_ASPECT_CONTROL_HORIZONTAL, + VERTICAL = EVAS_ASPECT_CONTROL_VERTICAL, + BOTH = EVAS_ASPECT_CONTROL_BOTH + }; + // LayoutTheme // struct LayoutTheme { diff --git a/ucl/inc/ucl/misc/RefCountAware.h b/ucl/inc/ucl/misc/RefCountAware.h new file mode 100644 index 0000000..f037baa --- /dev/null +++ b/ucl/inc/ucl/misc/RefCountAware.h @@ -0,0 +1,80 @@ +/* + * 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_REF_COUNT_AWARE_H__ +#define __UCL_MISC_REF_COUNT_AWARE_H__ + +#include "ucl/util/types.h" +#include "ucl/util/memory.h" + +namespace ucl { + + UCL_DECLARE_REF_ALIASES(RefCountAware); + + class RefCountAware : public Polymorphic { + public: + template + static SharedRef asShared(T *obj); + template + static WeakRef asWeak(T *obj); + + template + static SharedRef asShared(T &obj); + template + static WeakRef asWeak(T &obj); + + bool isShared() const; + + template + SharedRef asShared(); + template + WeakRef asWeak(); + + template + SharedRef asShared() const; + template + WeakRef asWeak() const; + + RefCountAwareSRef asShared(); + RefCountAwareWRef asWeak(); + + RefCountAwareSCRef asShared() const; + RefCountAwareWCRef asWeak() const; + + protected: + RefCountAware(RefCountObjBase *rc); + virtual ~RefCountAware() = default; + + protected: + RefCountObjBase *const m_rc; + }; + + // Non-member functions // + + template + SharedRef asShared(T *obj); + template + WeakRef asWeak(T *obj); + + template + SharedRef asShared(T &obj); + template + WeakRef asWeak(T &obj); +} + +#include "RefCountAware.hpp" + +#endif // __UCL_MISC_REF_COUNT_AWARE_H__ diff --git a/ucl/inc/ucl/misc/RefCountAware.hpp b/ucl/inc/ucl/misc/RefCountAware.hpp new file mode 100644 index 0000000..7969289 --- /dev/null +++ b/ucl/inc/ucl/misc/RefCountAware.hpp @@ -0,0 +1,140 @@ +/* + * 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/logging.h" + +namespace ucl { + + inline RefCountAware::RefCountAware(RefCountObjBase *const rc) : + m_rc(rc) + { + } + + template + inline SharedRef RefCountAware::asShared(T *obj) + { + return (obj ? asShared(*obj) : SharedRef()); + } + + template + inline WeakRef RefCountAware::asWeak(T *obj) + { + return (obj ? asWeak(*obj) : WeakRef()); + } + + template + inline SharedRef RefCountAware::asShared(T &obj) + { + return obj.template asShared::type>(); + } + + template + inline WeakRef RefCountAware::asWeak(T &obj) + { + return obj.template asWeak::type>(); + } + + inline bool RefCountAware::isShared() const + { + return !!m_rc; + } + + template + inline SharedRef RefCountAware::asShared() + { + if (!isShared()) { + UCL_ELOG("NOT SHARED: %s", typeid(*this).name()); + return {}; + } + return {m_rc, static_cast(this)}; + } + + template + inline WeakRef RefCountAware::asWeak() + { + if (!isShared()) { + UCL_ELOG("NOT SHARED: %s", typeid(*this).name()); + return {}; + } + return {m_rc, static_cast(this)}; + } + + template + inline SharedRef RefCountAware::asShared() const + { + if (!isShared()) { + UCL_ELOG("NOT SHARED: %s", typeid(*this).name()); + return {}; + } + return {m_rc, static_cast(this)}; + } + + template + inline WeakRef RefCountAware::asWeak() const + { + if (!isShared()) { + UCL_ELOG("NOT SHARED: %s", typeid(*this).name()); + return {}; + } + return {m_rc, static_cast(this)}; + } + + inline RefCountAwareSRef RefCountAware::asShared() + { + return asShared(); + } + + inline RefCountAwareWRef RefCountAware::asWeak() + { + return asWeak(); + } + + inline RefCountAwareSCRef RefCountAware::asShared() const + { + return asShared(); + } + + inline RefCountAwareWCRef RefCountAware::asWeak() const + { + return asWeak(); + } + + // Non-member functions // + + template + inline SharedRef asShared(T *obj) + { + return RefCountAware::asShared(obj); + } + + template + inline WeakRef asWeak(T *obj) + { + return RefCountAware::asWeak(obj); + } + + template + inline SharedRef asShared(T &obj) + { + return RefCountAware::asShared(obj); + } + + template + inline WeakRef asWeak(T &obj) + { + return RefCountAware::asWeak(obj); + } +} diff --git a/ucl/inc/ucl/util/delegation/Delegate.h b/ucl/inc/ucl/util/delegation/Delegate.h index 214482c..ad9a1fd 100644 --- a/ucl/inc/ucl/util/delegation/Delegate.h +++ b/ucl/inc/ucl/util/delegation/Delegate.h @@ -19,14 +19,14 @@ namespace ucl { static Delegate make(const CLASS *data) noexcept; template - static Delegate make(CLASS &data) noexcept; + static Delegate makeA(CLASS &data) noexcept; template - static Delegate make(CLASS &data) noexcept; + static Delegate makeB(CLASS &data) noexcept; template - static Delegate make(HANDLE data) noexcept; + static Delegate makeA(HANDLE data) noexcept; template - static Delegate make(HANDLE data) noexcept; + static Delegate makeB(HANDLE data) noexcept; template static Delegate make() noexcept; diff --git a/ucl/inc/ucl/util/delegation/Delegate.hpp b/ucl/inc/ucl/util/delegation/Delegate.hpp index adb595b..680745d 100644 --- a/ucl/inc/ucl/util/delegation/Delegate.hpp +++ b/ucl/inc/ucl/util/delegation/Delegate.hpp @@ -21,7 +21,7 @@ namespace ucl { template template inline Delegate - Delegate::make(CLASS &data) noexcept + Delegate::makeA(CLASS &data) noexcept { return {const_cast(static_cast(&data)), Delegate::Cb::template stubA2A}; @@ -30,7 +30,7 @@ namespace ucl { template template inline Delegate - Delegate::make(CLASS &data) noexcept + Delegate::makeB(CLASS &data) noexcept { return {const_cast(static_cast(&data)), Delegate::Cb::template stubA2B}; @@ -39,7 +39,7 @@ namespace ucl { template template inline Delegate - Delegate::make(const HANDLE data) noexcept + Delegate::makeA(const HANDLE data) noexcept { return {const_cast(static_cast(data)), Delegate::Cb::template stubA2A}; @@ -48,7 +48,7 @@ namespace ucl { template template inline Delegate - Delegate::make(const HANDLE data) noexcept + Delegate::makeB(const HANDLE data) noexcept { return {const_cast(static_cast(data)), Delegate::Cb::template stubA2B}; diff --git a/ucl/inc/ucl/util/delegation/Delegate2.h b/ucl/inc/ucl/util/delegation/Delegate2.h index b780af7..7669857 100644 --- a/ucl/inc/ucl/util/delegation/Delegate2.h +++ b/ucl/inc/ucl/util/delegation/Delegate2.h @@ -19,14 +19,14 @@ namespace ucl { static Delegate2 make(const CLASS *data) noexcept; template - static Delegate2 make(CLASS &data) noexcept; + static Delegate2 makeA(CLASS &data) noexcept; template - static Delegate2 make(CLASS &data) noexcept; + static Delegate2 makeB(CLASS &data) noexcept; template - static Delegate2 make(HANDLE data) noexcept; + static Delegate2 makeA(HANDLE data) noexcept; template - static Delegate2 make(HANDLE data) noexcept; + static Delegate2 makeB(HANDLE data) noexcept; template static Delegate2 make() noexcept; diff --git a/ucl/inc/ucl/util/delegation/Delegate2.hpp b/ucl/inc/ucl/util/delegation/Delegate2.hpp index 88246a3..4128406 100644 --- a/ucl/inc/ucl/util/delegation/Delegate2.hpp +++ b/ucl/inc/ucl/util/delegation/Delegate2.hpp @@ -23,7 +23,7 @@ namespace ucl { template template inline Delegate2 - Delegate2::make(CLASS &data) noexcept + Delegate2::makeA(CLASS &data) noexcept { return {const_cast(static_cast(&data)), Delegate2::Cb::template stubA2A, @@ -33,7 +33,7 @@ namespace ucl { template template inline Delegate2 - Delegate2::make(CLASS &data) noexcept + Delegate2::makeB(CLASS &data) noexcept { return {const_cast(static_cast(&data)), Delegate2::Cb::template stubA2B, @@ -43,7 +43,7 @@ namespace ucl { template template inline Delegate2 - Delegate2::make(const HANDLE data) noexcept + Delegate2::makeA(const HANDLE data) noexcept { return {const_cast(static_cast(data)), Delegate2::Cb::template stubA2A, @@ -53,7 +53,7 @@ namespace ucl { template template inline Delegate2 - Delegate2::make(const HANDLE data) noexcept + Delegate2::makeB(const HANDLE data) noexcept { return {const_cast(static_cast(data)), Delegate2::Cb::template stubA2B, diff --git a/ucl/inc/ucl/util/delegation/macro.h b/ucl/inc/ucl/util/delegation/macro.h index d58bd57..4b1640f 100644 --- a/ucl/inc/ucl/util/delegation/macro.h +++ b/ucl/inc/ucl/util/delegation/macro.h @@ -11,6 +11,9 @@ #define _UCL_DELEGATE(DELEGATE, FUNC, DATA) (_UCL_AFS(DELEGATE, FUNC):: \ Type::make<_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_V(DELEGATE, FUNC) \ (::ucl::AutoFuncSig::\ Type::make<&FUNC>()) @@ -18,11 +21,14 @@ // Helper macro to automatically generate Delegate objects // #define UCL_DELEGATE(FUNC, DATA) _UCL_DELEGATE(::ucl::Delegate, FUNC, DATA) +#define UCL_DELEGATE_A(FUNC, DATA) _UCL_DELEGATE_A(::ucl::Delegate, FUNC, DATA) #define UCL_DELEGATE_V(FUNC) _UCL_DELEGATE_V(::ucl::Delegate, FUNC) // Helper macro to automatically generate Delegate2 objects // #define UCL_DELEGATE2(FUNC, DATA) _UCL_DELEGATE(::ucl::Delegate2, FUNC, DATA) +#define UCL_DELEGATE2_A(FUNC, DATA) \ + _UCL_DELEGATE_A(::ucl::Delegate2, FUNC, DATA) #define UCL_DELEGATE2_V(FUNC) _UCL_DELEGATE_V(::ucl::Delegate2, FUNC) // Helper macro to automatically generate Callback stubs // diff --git a/ucl/inc/ucl/util/delegation/shortMacro.h b/ucl/inc/ucl/util/delegation/shortMacro.h index ed0c806..f9b6c06 100644 --- a/ucl/inc/ucl/util/delegation/shortMacro.h +++ b/ucl/inc/ucl/util/delegation/shortMacro.h @@ -3,13 +3,15 @@ // Helper macro to automatically generate Delegate objects // -#define DELEGATE(FUNC, DATA) UCL_DELEGATE(FUNC, DATA) -#define DELEGATE_V(FUNC) UCL_DELEGATE_V(FUNC) +#define DELEGATE(FUNC, DATA) UCL_DELEGATE(FUNC, DATA) +#define DELEGATE_A(FUNC, DATA) UCL_DELEGATE_A(FUNC, DATA) +#define DELEGATE_V(FUNC) UCL_DELEGATE_V(FUNC) // Helper macro to automatically generate Delegate2 objects // -#define DELEGATE2(FUNC, DATA) UCL_DELEGATE2(FUNC, DATA) -#define DELEGATE2_V(FUNC) UCL_DELEGATE2_V(FUNC) +#define DELEGATE2(FUNC, DATA) UCL_DELEGATE2(FUNC, DATA) +#define DELEGATE2_A(FUNC, DATA) UCL_DELEGATE2_A(FUNC, DATA) +#define DELEGATE2_V(FUNC) UCL_DELEGATE2_V(FUNC) // Helper macro to automatically generate Callback stubs // diff --git a/ucl/inc/ucl/util/helpers.h b/ucl/inc/ucl/util/helpers.h index c0ddccb..7c19f2a 100644 --- a/ucl/inc/ucl/util/helpers.h +++ b/ucl/inc/ucl/util/helpers.h @@ -59,7 +59,10 @@ namespace ucl { constexpr const T &max(const T &a, const T &b); template - constexpr bool isPot(T value); + constexpr bool isPot(T value) + { + return (((value - 1) & value) == 0); + } template constexpr T ceilDiv(T value); diff --git a/ucl/inc/ucl/util/helpers.hpp b/ucl/inc/ucl/util/helpers.hpp index bafaff2..7c45c5f 100644 --- a/ucl/inc/ucl/util/helpers.hpp +++ b/ucl/inc/ucl/util/helpers.hpp @@ -10,6 +10,12 @@ namespace ucl { return (value ? value : zValue); } + template + constexpr bool isNotEmpty(T &&value) + { + return !isEmpty(std::forward(value)); + } + constexpr const char *ne(const char *const value, const char *const eValue) { return (isNotEmpty(value) ? value : eValue); @@ -20,12 +26,6 @@ namespace ucl { return (!value || (value[0] == '\0')); } - template - constexpr bool isNotEmpty(T &&value) - { - return !isEmpty(std::forward(value)); - } - template constexpr bool isNotValid(T &&value) { @@ -54,12 +54,6 @@ namespace ucl { return ((a > b) ? a : b); } - template - constexpr bool isPot(const T value) - { - return (((value - 1) & value) == 0); - } - template constexpr T ceilDiv(T value) { diff --git a/ucl/inc/ucl/util/logging.h b/ucl/inc/ucl/util/logging.h index 6fb60f5..c957f19 100644 --- a/ucl/inc/ucl/util/logging.h +++ b/ucl/inc/ucl/util/logging.h @@ -128,7 +128,7 @@ const ::ucl::Result __RESULT__ = (result); \ if (isBad(__RESULT__)) { \ UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \ - return (value); \ + return value; \ } \ } while (false) @@ -152,7 +152,7 @@ do { \ const ::ucl::Result __RESULT__ = (result); \ UCL_RESLOG(__RESULT__, msg, ##__VA_ARGS__); \ - return (value); \ + return value; \ } while (false) #define UCL_LOG_RETURN_VOID(result, msg, ...) \ diff --git a/ucl/inc/ucl/util/threading/Thread.h b/ucl/inc/ucl/util/threading/Thread.h index 52bef4b..aa2cfba 100644 --- a/ucl/inc/ucl/util/threading/Thread.h +++ b/ucl/inc/ucl/util/threading/Thread.h @@ -9,18 +9,24 @@ namespace ucl { - class Thread : public NonCopyable { + class Thread final : public NonCopyable { public: - explicit Thread(bool createSuspended = false); - virtual ~Thread(); + Thread(); + template + explicit Thread(FUNC &&func); + ~Thread(); + bool wasStarted() const; bool wasJoinded() const; - bool start(); + + template + bool start(FUNC &&func); void join(); + pthread_t *getHandle(); - protected: - virtual void execute() = 0; + private: + std::function m_func; pthread_t m_thread; bool m_wasStarted; bool m_wasJoined; diff --git a/ucl/inc/ucl/util/threading/Thread.hpp b/ucl/inc/ucl/util/threading/Thread.hpp index 2027f44..4e5255b 100644 --- a/ucl/inc/ucl/util/threading/Thread.hpp +++ b/ucl/inc/ucl/util/threading/Thread.hpp @@ -2,14 +2,18 @@ namespace ucl { - inline Thread::Thread(bool createSuspended) : + inline Thread::Thread() : m_thread(), m_wasStarted(false), m_wasJoined(false) { - if (!createSuspended) { - start(); - } + } + + template + inline Thread::Thread(FUNC &&func) : + Thread() + { + start(func); } inline Thread::~Thread() @@ -29,21 +33,24 @@ namespace ucl { return m_wasJoined; } - inline bool Thread::start() + template + inline bool Thread::start(FUNC &&func) { if (m_wasStarted) { UCL_WLOG("Already started!"); return false; } + m_func = std::forward(func); const int res = pthread_create(&m_thread, NULL, [](void *data) -> void * { - static_cast(data)->execute(); + static_cast(data)->m_func(); return nullptr; }, this); if (res != 0) { UCL_ELOG("pthread_create() failed: %d", res); + m_func = {}; return false; } m_wasStarted = true; @@ -62,6 +69,7 @@ namespace ucl { } m_wasJoined = true; pthread_join(m_thread, NULL); + m_func = {}; } inline pthread_t *Thread::getHandle() diff --git a/ucl/inc/ucl/util/types/Result.h b/ucl/inc/ucl/util/types/Result.h index 8f83301..83ac56d 100644 --- a/ucl/inc/ucl/util/types/Result.h +++ b/ucl/inc/ucl/util/types/Result.h @@ -49,8 +49,9 @@ namespace ucl { RES_IO_ERROR = -5, RES_NOT_SUPPORTED = -6, RES_INVALID_DATA = -7, + RES_FATAL = -8, // TODO MUST match previous item! - _RES_BEGIN = RES_INVALID_DATA + _RES_BEGIN = RES_FATAL }; } diff --git a/ucl/inc/ucl/util/types/baseTypes.h b/ucl/inc/ucl/util/types/baseTypes.h index 50bcfba..f118bf4 100644 --- a/ucl/inc/ucl/util/types/baseTypes.h +++ b/ucl/inc/ucl/util/types/baseTypes.h @@ -7,6 +7,7 @@ #include #include +#include #include #include diff --git a/ucl/src/appfw/UIApp.cpp b/ucl/src/appfw/UIApp.cpp index c33a34e..61b1e47 100644 --- a/ucl/src/appfw/UIApp.cpp +++ b/ucl/src/appfw/UIApp.cpp @@ -161,7 +161,7 @@ namespace ucl { Result UIApp::createInstance() { - auto instance = util::makeUnique(m_instanceMgr.newInstance()); + auto instance = m_instanceMgr.newInstance(); if (!instance) { LOG_RETURN(RES_FAIL, "m_instanceMgr.newInstance() failed!"); } diff --git a/ucl/src/appfw/helpers.cpp b/ucl/src/appfw/helpers.cpp new file mode 100644 index 0000000..a87e4ac --- /dev/null +++ b/ucl/src/appfw/helpers.cpp @@ -0,0 +1,36 @@ +/* + * 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/appfw/helpers.h" + +#include "../common.h" + +namespace ucl { + + std::string getResPath(const char *const relativePath) + { + std::string result; + char *const resDir = app_get_resource_path(); + if (resDir) { + result = resDir; + free(resDir); + } else { + ELOG("app_get_resource_path() failed!"); + } + result += relativePath; + return result; + } +} diff --git a/ucl/src/gui/EdjeWidget.cpp b/ucl/src/gui/EdjeWidget.cpp index 0ca9c0c..57293db 100644 --- a/ucl/src/gui/EdjeWidget.cpp +++ b/ucl/src/gui/EdjeWidget.cpp @@ -18,7 +18,7 @@ namespace ucl { } } - void EdjeWidget::setPartText(const EdjePart part, const TString &value) + void EdjeWidget::setText(const EdjePart part, const TString &value) { if (value.isTranslatable()) { if (value.hasDomain()) { diff --git a/ucl/src/gui/ElmWidget.cpp b/ucl/src/gui/ElmWidget.cpp index 68ee5af..4451c16 100644 --- a/ucl/src/gui/ElmWidget.cpp +++ b/ucl/src/gui/ElmWidget.cpp @@ -1,5 +1,8 @@ #include "ucl/gui/ElmWidget.h" +#include "ucl/gui/Window.h" +#include "ucl/gui/helpers.h" + namespace ucl { void ElmWidget::setFocusedImpl(const bool value) @@ -11,4 +14,9 @@ namespace ucl { { return elm_object_focus_get(getEo()); } + + Window *ElmWidget::getWindow() const + { + return dynamicCast(getTopWidget()); + } } diff --git a/ucl/src/gui/NaviItem.cpp b/ucl/src/gui/NaviItem.cpp new file mode 100644 index 0000000..052a8ea --- /dev/null +++ b/ucl/src/gui/NaviItem.cpp @@ -0,0 +1,49 @@ +/* + * 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/NaviItem.h" + +#include "ucl/gui/Naviframe.h" +#include "ucl/gui/helpers.h" + +namespace ucl { + + void NaviItem::popTo() const + { + const auto navi = dynamicCast(getWidget()); + const bool needStartTransition = + (navi && (navi->getTopItem() != *this)); + + elm_naviframe_item_pop_to(getIt()); + + if (needStartTransition) { + navi->startTransition(); + } + } + + void NaviItem::promote() const + { + const auto navi = dynamicCast(getWidget()); + const bool needStartTransition = + (navi && (navi->getTopItem() != *this)); + + elm_naviframe_item_promote(getIt()); + + if (needStartTransition) { + navi->startTransition(); + } + } +} diff --git a/ucl/src/gui/Naviframe.cpp b/ucl/src/gui/Naviframe.cpp index d7d2776..0814cb5 100644 --- a/ucl/src/gui/Naviframe.cpp +++ b/ucl/src/gui/Naviframe.cpp @@ -28,4 +28,27 @@ namespace ucl { return result; } + + // Naviframe // + + Naviframe::Naviframe(RefCountObjBase &rc, Evas_Object *eo) : + StyledWidget(&rc, eo, true), + m_isInTransition(false) + { + addEventHandler(NAVI_TRANSITION_FINISHED, WEAK_DELEGATE( + Naviframe::onTransitionFinished, asWeak(*this))); + } + + void Naviframe::startTransition() + { + if (!m_isInTransition) { + m_isInTransition = true; + callSmartEvent(NAVI_TRANSITION_STARTED); + } + } + + void Naviframe::onTransitionFinished(Widget &widget, void *eventInfo) + { + m_isInTransition = false; + } } diff --git a/ucl/src/gui/Widget.cpp b/ucl/src/gui/Widget.cpp index d8f519f..6f4b631 100644 --- a/ucl/src/gui/Widget.cpp +++ b/ucl/src/gui/Widget.cpp @@ -96,7 +96,7 @@ namespace ucl { Widget::Widget(RefCountObjBase *const rc, Evas_Object *const eo, const bool isOwner) : - SharedObject(rc), + RefCountAware(rc), m_eo(eo), m_isOwner(isOwner), m_isBoundToEo(false), @@ -107,9 +107,9 @@ namespace ucl { UCL_ASSERT(m_eo, "m_eo is NULL!"); if (m_rc) { - evas_object_event_callback_priority_add(m_eo, EVAS_CALLBACK_FREE, + evas_object_event_callback_priority_add(m_eo, EVAS_CALLBACK_DEL, EO_CALLBACK_PRIORITY_AFTER, - CALLBACK_A(Widget::onEoFree), this); + CALLBACK_A(Widget::onEoDel), this); } updateRefs(); @@ -124,8 +124,8 @@ namespace ucl { } if (m_rc) { - evas_object_event_callback_del_full(m_eo, EVAS_CALLBACK_FREE, - CALLBACK_A(Widget::onEoFree), this); + evas_object_event_callback_del_full(m_eo, EVAS_CALLBACK_DEL, + CALLBACK_A(Widget::onEoDel), this); } if (m_isOwner) { @@ -212,7 +212,7 @@ namespace ucl { } } - void Widget::onEoFree(Evas *e, Evas_Object *obj, void *event_info) + void Widget::onEoDel(Evas *e, Evas_Object *obj, void *event_info) { if (!m_isSelfRefKept) { FLOG("UNEXPECTED! m_isSelfRefKept: %d;", m_isSelfRefKept); diff --git a/ucl/src/gui/WidgetItem.cpp b/ucl/src/gui/WidgetItem.cpp index 3bc242a..05ab85a 100644 --- a/ucl/src/gui/WidgetItem.cpp +++ b/ucl/src/gui/WidgetItem.cpp @@ -17,7 +17,7 @@ namespace ucl { } } - void WidgetItem::setPartText( + void WidgetItem::setText( const EdjePart part, const TString &value) const { if (value.isTranslatable()) { diff --git a/ucl/src/util/types/Result.cpp b/ucl/src/util/types/Result.cpp index dee8d6c..7e0464f 100644 --- a/ucl/src/util/types/Result.cpp +++ b/ucl/src/util/types/Result.cpp @@ -5,6 +5,7 @@ namespace ucl { namespace { namespace impl { constexpr ResultData RESUT_DATA[] = { + {"RES_FATAL", DLOG_FATAL}, {"RES_INVALID_DATA", DLOG_ERROR}, {"RES_NOT_SUPPORTED", DLOG_ERROR}, {"RES_IO_ERROR", DLOG_ERROR},