TizenRefApp-8395 [Gallery] Implement MoreOptionsPresenter 68/125768/1
authorIgor Nazarov <i.nazarov@samsung.com>
Tue, 18 Apr 2017 17:37:09 +0000 (20:37 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Tue, 18 Apr 2017 17:45:15 +0000 (20:45 +0300)
- Implemented MoreOptionsPresenter class;
- "More Option" renamed to "More options" in Page Content;
- Added getImageTheme() helper;
- Added resources for more options;
- Added getUseCount() to UCL smart references;
- Fixed bug in ucl::isEmpty() helper.

Change-Id: I2f4fb34ff148e00a26ef4bdf32f93a1c42c1bb5a

23 files changed:
edc/images.edc
edc/images/gallery_more_opt_delete.png [new file with mode: 0644]
edc/images/gallery_more_opt_save.png [new file with mode: 0644]
edc/images/gallery_more_opt_send_to_mobile.png [new file with mode: 0644]
edc/layouts.edc
inc/presenters/IMoreOptionsListener.h [new file with mode: 0644]
inc/presenters/MoreOptionsPresenter.h [new file with mode: 0644]
inc/presenters/MoreOptionsPresenter.hpp [new file with mode: 0644]
inc/presenters/types.h
inc/resources.h
inc/view/PageContent.h
inc/view/PageContent.hpp [new file with mode: 0644]
inc/view/helpers.h
inc/view/types.h
src/presenters/MoreOptionsPresenter.cpp [new file with mode: 0644]
src/presenters/NoContentPage.cpp
src/view/PageContent.cpp
src/view/helpers.cpp
ucl/inc/ucl/util/helpers.h
ucl/inc/ucl/util/memory/BaseRef.h
ucl/inc/ucl/util/memory/BaseRef.hpp
ucl/inc/ucl/util/memory/RefCountObjBase.h
ucl/inc/ucl/util/memory/RefCountObjBase.hpp

index da436dd3026aa383ef54800a1dbb1b29ab4fdb10..0caacb31385786b196ec9da4d7b0baf41d1b9d64 100644 (file)
@@ -36,3 +36,7 @@
     RES_IMAGE(FILE_NAME, SIZE, SIZE, COLOR)
 
 RES_SQUARE_IMAGE("gallery_icon_no_photos.png", 98, GALLERY_COLOR_WHITE)
+
+RES_SQUARE_IMAGE("gallery_more_opt_delete.png", 68, GALLERY_COLOR_WHITE)
+RES_SQUARE_IMAGE("gallery_more_opt_save.png", 68, GALLERY_COLOR_WHITE)
+RES_SQUARE_IMAGE("gallery_more_opt_send_to_mobile.png", 68, GALLERY_COLOR_WHITE)
diff --git a/edc/images/gallery_more_opt_delete.png b/edc/images/gallery_more_opt_delete.png
new file mode 100644 (file)
index 0000000..79eaec4
Binary files /dev/null and b/edc/images/gallery_more_opt_delete.png differ
diff --git a/edc/images/gallery_more_opt_save.png b/edc/images/gallery_more_opt_save.png
new file mode 100644 (file)
index 0000000..f5fa999
Binary files /dev/null and b/edc/images/gallery_more_opt_save.png differ
diff --git a/edc/images/gallery_more_opt_send_to_mobile.png b/edc/images/gallery_more_opt_send_to_mobile.png
new file mode 100644 (file)
index 0000000..57f4516
Binary files /dev/null and b/edc/images/gallery_more_opt_send_to_mobile.png differ
index c3213228fe36fe9c9551cad0f05cc3e4157bfed3..2502b07b5b6ba81a18d72d6f3606e92f0b1389fe 100644 (file)
  * limitations under the License.
  */
 
-group { "elm/layout/gallery/more_option";
+group { "elm/layout/gallery/more_options";
    parts {
       swallow { "elm.swallow.content";
          desc { "default";
          }
       }
-      swallow { "gallery.swallow.more_option";
+      swallow { "gallery.swallow.more_options";
          desc { "default";
          }
       }
diff --git a/inc/presenters/IMoreOptionsListener.h b/inc/presenters/IMoreOptionsListener.h
new file mode 100644 (file)
index 0000000..9233c29
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GALLERY_PRESENTERS_MORE_OPTIONS_LISTENER_H__
+#define __GALLERY_PRESENTERS_MORE_OPTIONS_LISTENER_H__
+
+#include "types.h"
+
+namespace gallery {
+
+       class IMoreOptionsListener : public ucl::Polymorphic {
+       public:
+               virtual void onMoreOptionsOpened(MoreOptionsPresenter &sender) = 0;
+               virtual void onMoreOptionsClosed(MoreOptionsPresenter &sender) = 0;
+               virtual void onMoreOptionClicked(MoreOptionsPresenter &sender,
+                               const MoreOption &option) = 0;
+               virtual void onMoreOptionSelected(MoreOptionsPresenter &sender,
+                               const MoreOption &option) {};
+       };
+}
+
+#endif // __GALLERY_PRESENTERS_MORE_OPTIONS_LISTENER_H__
diff --git a/inc/presenters/MoreOptionsPresenter.h b/inc/presenters/MoreOptionsPresenter.h
new file mode 100644 (file)
index 0000000..0194885
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __GALLERY_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
+#define __GALLERY_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
+
+#include "ucl/gui/Widget.h"
+#include "ucl/misc/HashMap.h"
+
+#include "types.h"
+
+namespace gallery {
+
+       class MoreOptionsPresenter final : public ucl::RefCountAware {
+       public:
+               class Builder {
+               public:
+                       Builder();
+                       ~Builder();
+                       bool isEmpty() const;
+                       Builder &clear();
+                       Builder &addOption(MoreOption option);
+                       MoreOptionsPresenterSRef build(ucl::Widget &parent) const;
+               private:
+                       ucl::SharedRef<MoreOptions> m_options;
+               };
+
+       public:
+               void setListener(const IMoreOptionsListenerWRef &listener);
+
+               ucl::Widget &getWidget();
+
+               void setOpened(bool isOpened);
+               bool isOpened() const;
+
+       private:
+               using MoreOptionsCSRef = ucl::SharedRef<const MoreOptions>;
+
+       private:
+               friend class ucl::RefCountObj<MoreOptionsPresenter>;
+               MoreOptionsPresenter(ucl::RefCountObjBase &rc,
+                               const MoreOptionsCSRef &options);
+               virtual ~MoreOptionsPresenter();
+
+               ucl::Result prepare(ucl::Widget &parent);
+               ucl::Result addItem(const MoreOption &option);
+
+               void onOpened(ucl::Widget &widget, void *eventInfo);
+               void onClosed(ucl::Widget &widget, void *eventInfo);
+               void onItemClicked(ucl::Widget &widget, void *eventInfo);
+               void onItemSelected(ucl::Widget &widget, void *eventInfo);
+
+       private:
+               const MoreOptionsCSRef m_options;
+               ucl::HashMap<void *, const MoreOption *> m_map;
+               ucl::WidgetSRef m_widget;
+               IMoreOptionsListenerWRef m_listener;
+       };
+
+       // Non-member functions //
+
+       void open(MoreOptionsPresenter &mop);
+       void close(MoreOptionsPresenter &mop);
+}
+
+#include "MoreOptionsPresenter.hpp"
+
+#endif // __GALLERY_PRESENTERS_MORE_OPTIONS_PRESENTER_H__
diff --git a/inc/presenters/MoreOptionsPresenter.hpp b/inc/presenters/MoreOptionsPresenter.hpp
new file mode 100644 (file)
index 0000000..0182bbf
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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 gallery {
+
+       // Non-member functions //
+
+       inline void open(MoreOptionsPresenter &mop)
+       {
+               mop.setOpened(true);
+       }
+
+       inline void close(MoreOptionsPresenter &mop)
+       {
+               mop.setOpened(false);
+       }
+}
index ad884c30805d3ecc73331f7481730364c07a826f..5b13931a1b6e12e72ac06cda4db7d5b9ca62950b 100644 (file)
 #ifndef __GALLERY_PRESENTERS_TYPES_H__
 #define __GALLERY_PRESENTERS_TYPES_H__
 
+#include <list>
+
 #include "../types.h"
 #include "view/types.h"
 #include "model/types.h"
 
 namespace gallery {
 
+       struct MoreOption {
+               int id;
+               ucl::TString text;
+               ucl::TString subText;
+               ucl::LayoutTheme iconTheme;
+       };
+
+       using MoreOptions = std::list<MoreOption>;
+
+       UCL_DECLARE_REF_ALIASES(IMoreOptionsListener);
+       UCL_DECLARE_REF_ALIASES(MoreOptionsPresenter);
+
        UCL_DECLARE_REF_ALIASES(Page);
 
        UCL_DECLARE_REF_ALIASES(NoContentPage);
index 9e087d1d1100cf96a7fc56b3ba53ad91abb5f680..74a566454867910f3f795f100049063be90f7418 100644 (file)
@@ -25,6 +25,12 @@ namespace gallery {
 
        constexpr auto THEME_EDJE_PATH = "edje/theme.edj";
 
+       constexpr auto ICON_NO_PHOTOS = "gallery_icon_no_photos.png";
+
+       constexpr auto ICON_MORE_OPT_DELETE = "gallery_more_opt_delete.png";
+       constexpr auto ICON_MORE_OPT_SAVE = "gallery_more_opt_save.png";
+       constexpr auto ICON_MORE_OPT_SEND = "gallery_more_opt_send_to_mobile.png";
+
        extern const ucl::TString STR_APP_NAME;
        extern const ucl::TString STR_NO_PHOTOS;
 }
index 5f7bfc2dbd15568af4914c2b8f4a3d84c0b12dec..297120749dc4bddc188ad4108bafd83ef88e5532 100644 (file)
@@ -35,17 +35,17 @@ namespace gallery {
                };
 
                enum {
-                       FLAG_MORE_OPTION = 1,
+                       FLAG_MORE_OPTIONS = 1,
                        FLAG_SELECT_BUTTON = 2,
                        FLAG_BOTTOM_BUTTON = 4,
 
                        FLAGS_SELECT_MODE = (FLAG_SELECT_BUTTON | FLAG_BOTTOM_BUTTON),
-                       FLAGS_ALL = (FLAG_MORE_OPTION | FLAGS_SELECT_MODE)
+                       FLAGS_ALL = (FLAG_MORE_OPTIONS | FLAGS_SELECT_MODE)
                };
 
                enum class Part {
                        DEFAULT,
-                       MORE_OPTION,
+                       MORE_OPTIONS,
                        SELECT_BUTTON,
                        BOTTOM_BUTTON
                };
@@ -57,7 +57,7 @@ namespace gallery {
                Evas_Object *get(Part part = Part::DEFAULT) const;
 
                ucl::Result setSelectButtonVisible(bool visible);
-               ucl::Result setMoreOptionVisible(bool visible);
+               ucl::Result setMoreOptionsVisible(bool visible);
 
        private:
                friend class ucl::RefCountObj<PageContent>;
@@ -73,10 +73,20 @@ namespace gallery {
                ucl::Layout *getTopLayout() const;
 
        private:
-               ucl::LayoutWRef m_moreOption;
+               ucl::LayoutWRef m_moreOptions;
                ucl::LayoutSRef m_selectMode;
                ucl::LayoutSRef m_bottomButton;
        };
+
+       // Non-member functions //
+
+       void showSelectButton(PageContent &pc);
+       void hideSelectButton(PageContent &pc);
+
+       void showMoreOptions(PageContent &pc);
+       void hideMoreOptions(PageContent &pc);
 }
 
+#include "PageContent.hpp"
+
 #endif // __GALLERY_VIEW_PAGE_CONTENT_H__
diff --git a/inc/view/PageContent.hpp b/inc/view/PageContent.hpp
new file mode 100644 (file)
index 0000000..2095191
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 gallery {
+
+       // Non-member functions //
+
+       inline void showSelectButton(PageContent &pc)
+       {
+               pc.setSelectButtonVisible(true);
+       }
+
+       inline void hideSelectButton(PageContent &pc)
+       {
+               pc.setSelectButtonVisible(false);
+       }
+
+       inline void showMoreOptions(PageContent &pc)
+       {
+               pc.setMoreOptionsVisible(true);
+       }
+
+       inline void hideMoreOptions(PageContent &pc)
+       {
+               pc.setMoreOptionsVisible(false);
+       }
+}
index dab1486a1e2880822f22c73a2fc831cccd91ea70..1e859667d5052ccaa23eecf01fa6ad36d53ac1b9 100644 (file)
@@ -32,6 +32,8 @@ namespace gallery {
        ucl::Result createCircleSurface(ucl::Naviframe &navi);
 
        Eext_Circle_Surface *getCircleSurface(const ucl::ElmWidget &widget);
+
+       ucl::LayoutTheme getImageTheme(const char *fileName);
 }
 
 #endif // __GALLERY_VIEW_HELPERS_H__
index 461f3fcca0fbbe911f13fc719d1abfd6f0cbd15d..2254f35342b2357951cff1f94a30945da538959e 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef __GALLERY_VIEW_TYPES_H__
 #define __GALLERY_VIEW_TYPES_H__
 
+#include "ucl/gui/types.h"
+
 #include "../types.h"
 
 namespace gallery {
diff --git a/src/presenters/MoreOptionsPresenter.cpp b/src/presenters/MoreOptionsPresenter.cpp
new file mode 100644 (file)
index 0000000..0b2d5c4
--- /dev/null
@@ -0,0 +1,225 @@
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "presenters/MoreOptionsPresenter.h"
+
+#include "ucl/gui/Layout.h"
+
+#include "presenters/IMoreOptionsListener.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+       using namespace ucl;
+
+       constexpr SmartEvent MORE_OPENED {"more,option,opened"};
+       constexpr SmartEvent MORE_CLOSED {"more,option,closed"};
+       constexpr SmartEvent MORE_ITEM_CLICKED {"item,clicked"};
+       constexpr SmartEvent MORE_ITEM_SELECTED {"item,selected"};
+
+       constexpr EdjePart PART_ICON {"item,icon"};
+       constexpr EdjePart PART_MAIN_TEXT {"selector,main_text"};
+       constexpr EdjePart PART_SUB_TEXT {"selector,sub_text"};
+
+       // Warning! Do not mix translatable and not translatable text
+       // on a single item once it is created
+       void setText(Eext_Object_Item *item, const TString &value,
+                       const EdjePart part)
+       {
+               if (value.isTranslatable()) {
+                       eext_more_option_item_domain_translatable_part_text_set(
+                                               item, part.name, value.getDomain(), value);
+               } else {
+                       eext_more_option_item_part_text_set(item, part.name, value);
+               }
+       }
+}}}
+
+namespace gallery {
+
+       using namespace ucl;
+
+       // MoreOptionsPresenter::Builder //
+
+       MoreOptionsPresenter::Builder::Builder()
+       {
+       }
+
+       MoreOptionsPresenter::Builder::~Builder()
+       {
+       }
+
+       bool MoreOptionsPresenter::Builder::isEmpty() const
+       {
+               return ucl::isEmpty(m_options);
+       }
+
+       MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::clear()
+       {
+               m_options = {};
+               return *this;
+       }
+
+       MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::addOption(
+                       MoreOption option)
+       {
+               if (!m_options) {
+                       m_options = makeShared<MoreOptions>();
+               } else if (m_options.getUseCount() > 1) {
+                       m_options = makeShared<MoreOptions>(*m_options);
+               }
+               m_options->emplace_back(std::move(option));
+               return *this;
+       }
+
+       MoreOptionsPresenterSRef MoreOptionsPresenter::Builder::build(
+                       Widget &parent) const
+       {
+               if (isEmpty()) {
+                       LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "Builder is empty!");
+               }
+
+               auto result = makeShared<MoreOptionsPresenter>(m_options);
+
+               FAIL_RETURN_VALUE(result->prepare(parent), {},
+                               "result->prepare() failed!");
+
+               return result;
+       }
+
+       // MoreOptionsPresenter //
+
+       MoreOptionsPresenter::MoreOptionsPresenter(RefCountObjBase &rc,
+                       const MoreOptionsCSRef &options) :
+               RefCountAware(&rc),
+               m_options(options)
+       {
+       }
+
+       MoreOptionsPresenter::~MoreOptionsPresenter()
+       {
+       }
+
+       Result MoreOptionsPresenter::prepare(Widget &parent)
+       {
+               m_widget = makeShared<Layout>(eext_more_option_add(parent), true);
+               if (!m_widget) {
+                       LOG_RETURN(RES_FAIL, "eext_more_option_add() failed!");
+               }
+
+               for (auto &option: *m_options) {
+                       FAIL_RETURN(addItem(option), "addItem() failed!");
+               }
+
+               m_widget->addEventHandler(impl::MORE_OPENED, WEAK_DELEGATE(
+                               MoreOptionsPresenter::onOpened, asWeak(*this)));
+               m_widget->addEventHandler(impl::MORE_CLOSED, WEAK_DELEGATE(
+                               MoreOptionsPresenter::onClosed, asWeak(*this)));
+
+               m_widget->addEventHandler(impl::MORE_ITEM_CLICKED, WEAK_DELEGATE(
+                               MoreOptionsPresenter::onItemClicked, asWeak(*this)));
+               m_widget->addEventHandler(impl::MORE_ITEM_SELECTED, WEAK_DELEGATE(
+                               MoreOptionsPresenter::onItemSelected, asWeak(*this)));
+
+               return RES_OK;
+       }
+
+       Result MoreOptionsPresenter::addItem(const MoreOption &option)
+       {
+               const auto item = eext_more_option_item_append(*m_widget);
+               if (!item) {
+                       LOG_RETURN(RES_FAIL, "eext_more_option_item_append() failed!");
+               }
+
+               if (isValid(option.iconTheme)) {
+                       const auto icon = Layout::Builder().
+                                       setTheme(option.iconTheme).
+                                       build(*m_widget);
+                       if (!icon) {
+                               LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+                       }
+                       eext_more_option_item_part_content_set(item,
+                                       impl::PART_ICON.name, *icon);
+               }
+
+               impl::setText(item, option.text, impl::PART_MAIN_TEXT);
+               impl::setText(item, option.subText, impl::PART_SUB_TEXT);
+
+               m_map.set(item, &option);
+
+               return RES_OK;
+       }
+
+       void MoreOptionsPresenter::onOpened(Widget &widget, void *eventInfo)
+       {
+               if (m_listener) {
+                       m_listener->onMoreOptionsOpened(*this);
+               }
+       }
+
+       void MoreOptionsPresenter::onClosed(Widget &widget, void *eventInfo)
+       {
+               if (m_listener) {
+                       m_listener->onMoreOptionsClosed(*this);
+               }
+       }
+
+       void MoreOptionsPresenter::onItemClicked(Widget &widget, void *eventInfo)
+       {
+               if (m_listener) {
+                       const auto item = m_map.get(eventInfo);
+                       if (item) {
+                               m_listener->onMoreOptionClicked(*this, *item);
+                       } else {
+                               ELOG("Invalid eventInfo!");
+                       }
+               }
+       }
+
+       void MoreOptionsPresenter::onItemSelected(Widget &widget, void *eventInfo)
+       {
+               if (m_listener) {
+                       const auto item = m_map.get(eventInfo);
+                       if (item) {
+                               m_listener->onMoreOptionSelected(*this, *item);
+                       } else {
+                               ELOG("Invalid eventInfo!");
+                       }
+               }
+       }
+
+       void MoreOptionsPresenter::setListener(
+                       const IMoreOptionsListenerWRef &listener)
+       {
+               m_listener = listener;
+       }
+
+       Widget &MoreOptionsPresenter::getWidget()
+       {
+               return *m_widget;
+       }
+
+       void MoreOptionsPresenter::setOpened(const bool isOpened)
+       {
+               eext_more_option_opened_set(*m_widget, toEina(isOpened));
+       }
+
+       bool MoreOptionsPresenter::isOpened() const
+       {
+               return eext_more_option_opened_get(*m_widget);
+       }
+}
index 4ce2e5524a1a89e4375cf9cd5bbe575193371026..8d72c3dc7a1fa247b0d09ea95d1e8c1963f84caa 100644 (file)
 #include "resources.h"
 #include "common.h"
 
-namespace gallery {namespace { namespace impl {
-
-       using namespace ucl;
-
-       constexpr LayoutTheme ICON_THEME
-                       {"layout", "gallery_image", "gallery_icon_no_photos.png"};
-}}}
-
 namespace gallery {
 
        using namespace ucl;
@@ -92,9 +84,9 @@ namespace gallery {
                }
 
                const auto icon = Layout::Builder().
-                               setTheme(impl::ICON_THEME).
+                               setTheme(getImageTheme(ICON_NO_PHOTOS)).
                                build(*layout);
-               if (!layout) {
+               if (!icon) {
                        LOG_RETURN(RES_FAIL, "Layout::build() failed!");
                }
 
index f3e9c69af1df420258e46917d6947141ee65b501..2fe5c97be805f1801992d2d0181581d406293acb 100644 (file)
@@ -22,8 +22,8 @@ namespace gallery { namespace { namespace impl {
 
        using namespace ucl;
 
-       constexpr LayoutTheme LAYOUT_MORE_OPTION
-                       {"layout", "gallery", "more_option"};
+       constexpr LayoutTheme LAYOUT_MORE_OPTIONS
+                       {"layout", "gallery", "more_options"};
 
        constexpr LayoutTheme LAYOUT_SELECT_MODE
                        {"layout", "select_mode", "default"};
@@ -31,13 +31,13 @@ namespace gallery { namespace { namespace impl {
        constexpr LayoutTheme LAYOUT_BOTTOM_BUTTON
                        {"layout", "bottom_button", "default"};
 
-       constexpr EdjePart PART_MORE_OPTION {"gallery.swallow.more_option"};
+       constexpr EdjePart PART_MORE_OPTIONS {"gallery.swallow.more_options"};
 
        constexpr EdjeSignal SIGNAL_SHOW_SELECT_BUTTON {"select_mode,button,show"};
        constexpr EdjeSignal SIGNAL_HIDE_SELECT_BUTTON {"select_mode,button,hide"};
 
-       constexpr EdjeSignal SIGNAL_SHOW_MORE_OPTION {"cue,show"};
-       constexpr EdjeSignal SIGNAL_HIDE_MORE_OPTION {"cue,hide"};
+       constexpr EdjeSignal SIGNAL_SHOW_MORE_OPTIONS {"cue,show"};
+       constexpr EdjeSignal SIGNAL_HIDE_MORE_OPTIONS {"cue,hide"};
        constexpr EdjeSignalSrc SIGNAL_SRC_EXT {"ext"};
 
        template <class OBJ, class FUNC, class ...ARGS>
@@ -71,7 +71,7 @@ namespace gallery {
        PageContentSRef PageContent::Builder::build(Widget &parent) const
        {
                auto layout = Layout::Builder().
-                               setTheme(impl::LAYOUT_MORE_OPTION).
+                               setTheme(impl::LAYOUT_MORE_OPTIONS).
                                setIsOwner(true).
                                build(parent);
                if (!layout) {
@@ -90,7 +90,7 @@ namespace gallery {
        PageContent::PageContent(RefCountObjBase &rc,
                        const ucl::LayoutSRef &layout, const int flags) :
                ElmWidget(&rc, *layout, true),
-               m_moreOption(layout)
+               m_moreOptions(layout)
        {
                prepare(flags);
        }
@@ -101,9 +101,9 @@ namespace gallery {
 
        void PageContent::prepare(const int flags)
        {
-               m_moreOption->setIsOwner(false);
+               m_moreOptions->setIsOwner(false);
 
-               LayoutSRef parent = m_moreOption;
+               LayoutSRef parent = m_moreOptions;
 
                if (flags & FLAG_SELECT_BUTTON) {
                        m_selectMode = Layout::Builder().
@@ -163,17 +163,18 @@ namespace gallery {
                return RES_OK;
        }
 
-       Result PageContent::setMoreOptionVisible(const bool visible)
+       Result PageContent::setMoreOptionsVisible(const bool visible)
        {
-               if (!m_moreOption) {
-                       LOG_RETURN(RES_FAIL, "More option is not supported!");
+               if (!m_moreOptions) {
+                       LOG_RETURN(RES_FAIL, "More options is not supported!");
                }
-               const auto content = m_moreOption->getContent(impl::PART_MORE_OPTION);
+               const auto content = m_moreOptions->getContent(impl::PART_MORE_OPTIONS);
                if (!content) {
                        LOG_RETURN(RES_FAIL, "More option is not created!");
                }
                elm_layout_signal_emit(content, (visible ?
-                               impl::SIGNAL_SHOW_MORE_OPTION : impl::SIGNAL_HIDE_MORE_OPTION),
+                               impl::SIGNAL_SHOW_MORE_OPTIONS :
+                               impl::SIGNAL_HIDE_MORE_OPTIONS),
                                impl::SIGNAL_SRC_EXT);
                return RES_OK;
        }
@@ -184,9 +185,9 @@ namespace gallery {
                switch (part) {
                case Part::DEFAULT:
                        return impl::callSafe(getTopLayout(), func, PART_CONTENT);
-               case Part::MORE_OPTION:
-                       return impl::callSafe(m_moreOption.get(), func,
-                                       impl::PART_MORE_OPTION);
+               case Part::MORE_OPTIONS:
+                       return impl::callSafe(m_moreOptions.get(), func,
+                                       impl::PART_MORE_OPTIONS);
                case Part::SELECT_BUTTON:
                        return impl::callSafe(m_selectMode.get(), func, PART_ICON);
                case Part::BOTTOM_BUTTON:
@@ -203,6 +204,6 @@ namespace gallery {
                if (m_selectMode) {
                        return m_selectMode.get();
                }
-               return m_moreOption.get();
+               return m_moreOptions.get();
        }
 }
index 77b6810b81de0c35daa46389ac5f77e7a711cfcf..b74886515aecc6500f5248d567cba42d15c9b662 100644 (file)
@@ -71,5 +71,10 @@ namespace gallery {
 
                return sfc;
        }
+
+       LayoutTheme getImageTheme(const char *const fileName)
+       {
+               return {"layout", "gallery_image", fileName};
+       }
 }
 
index 82e3d4cd8570cab8d476c9b0f906c8212c63ba85..87485b0506f76f4ca7b3e6b8b1c97758802cbf25 100644 (file)
@@ -33,12 +33,6 @@ namespace ucl {
 
        constexpr bool isEmpty(const char *value);
 
-       template <class T>
-       constexpr auto isEmpty(const T &value) -> decltype(isEmpty(*value))
-       {
-               return isEmpty(*value);
-       }
-
        template <class T>
        constexpr auto isEmpty(const T &value) -> decltype(value.empty())
        {
@@ -51,6 +45,12 @@ namespace ucl {
                return value.isEmpty();
        }
 
+       template <class T>
+       constexpr auto isEmpty(const T &value) -> decltype(isEmpty(*value))
+       {
+               return (!value || isEmpty(*value));
+       }
+
        template <class T>
        constexpr bool isNotEmpty(T &&value);
 
index 6c2b676df99f0f3dcc0ebdd0a021912ccb2c9c5a..0aa1b593cc07a61fafcb61a95efd88656b77f7b8 100644 (file)
@@ -34,6 +34,8 @@ namespace ucl {
                friend class WeakRef;
 
        public:
+               int getUseCount() const;
+
                T *operator->() const noexcept;
                typename std::add_lvalue_reference<T>::type operator*() const noexcept;
 
index 4c670a377c7c9428b0c0967329e9871c1c40b02f..d587bc141ec661167b722e322797913f44c0533a 100644 (file)
@@ -50,6 +50,12 @@ namespace ucl {
                r.m_ptr = nullptr;
        }
 
+       template <class T>
+       inline int BaseRef<T>::getUseCount() const
+       {
+               return (m_rc ? m_rc->getUseCount() : 0);
+       }
+
        template <class T>
        inline T *BaseRef<T>::operator->() const noexcept
        {
index dfbd007bab4b8316792ec21c7ff934c1d28c7789..4e6edf033e49e69bb7718ca639fda5b6c03900bb 100644 (file)
@@ -29,6 +29,7 @@ namespace ucl {
                void refWeak() noexcept;
                void unrefWeak() noexcept;
 
+               int getUseCount() const noexcept;
                bool isDisposed() const noexcept;
 
        protected:
index 76860aabcde56d9b4a543b9184897a7ee0f966e3..c4b5d42e48f1a1e03641b9b029c50b01dbdf5efa 100644 (file)
@@ -57,6 +57,11 @@ namespace ucl {
                }
        }
 
+       inline int RefCountObjBase::getUseCount() const noexcept
+       {
+               return m_useRefs;
+       }
+
        inline bool RefCountObjBase::isDisposed() const noexcept
        {
                return m_isDisposed;