summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Nazarov <i.nazarov@samsung.com>2017-04-18 20:37:09 +0300
committerIgor Nazarov <i.nazarov@samsung.com>2017-04-18 20:45:15 +0300
commit2ce5963e779a74c4c2a37717265951f7971db0db (patch)
tree89e12c3a64b664d5fd7bd4fbb6c3aa991aa33287
parente0a96496df034b83dd7852c89031b3b0ce8df812 (diff)
downloadgallery-2ce5963e779a74c4c2a37717265951f7971db0db.tar.gz
gallery-2ce5963e779a74c4c2a37717265951f7971db0db.tar.bz2
gallery-2ce5963e779a74c4c2a37717265951f7971db0db.zip
TizenRefApp-8395 [Gallery] Implement MoreOptionsPresenter
- 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
-rw-r--r--edc/images.edc4
-rw-r--r--edc/images/gallery_more_opt_delete.pngbin0 -> 1325 bytes
-rw-r--r--edc/images/gallery_more_opt_save.pngbin0 -> 1241 bytes
-rw-r--r--edc/images/gallery_more_opt_send_to_mobile.pngbin0 -> 1600 bytes
-rw-r--r--edc/layouts.edc4
-rw-r--r--inc/presenters/IMoreOptionsListener.h35
-rw-r--r--inc/presenters/MoreOptionsPresenter.h81
-rw-r--r--inc/presenters/MoreOptionsPresenter.hpp30
-rw-r--r--inc/presenters/types.h14
-rw-r--r--inc/resources.h6
-rw-r--r--inc/view/PageContent.h20
-rw-r--r--inc/view/PageContent.hpp40
-rw-r--r--inc/view/helpers.h2
-rw-r--r--inc/view/types.h2
-rw-r--r--src/presenters/MoreOptionsPresenter.cpp225
-rw-r--r--src/presenters/NoContentPage.cpp12
-rw-r--r--src/view/PageContent.cpp37
-rw-r--r--src/view/helpers.cpp5
-rw-r--r--ucl/inc/ucl/util/helpers.h12
-rw-r--r--ucl/inc/ucl/util/memory/BaseRef.h2
-rw-r--r--ucl/inc/ucl/util/memory/BaseRef.hpp6
-rw-r--r--ucl/inc/ucl/util/memory/RefCountObjBase.h1
-rw-r--r--ucl/inc/ucl/util/memory/RefCountObjBase.hpp5
23 files changed, 502 insertions, 41 deletions
diff --git a/edc/images.edc b/edc/images.edc
index da436dd..0caacb3 100644
--- a/edc/images.edc
+++ b/edc/images.edc
@@ -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
index 0000000..79eaec4
--- /dev/null
+++ b/edc/images/gallery_more_opt_delete.png
Binary files differ
diff --git a/edc/images/gallery_more_opt_save.png b/edc/images/gallery_more_opt_save.png
new file mode 100644
index 0000000..f5fa999
--- /dev/null
+++ b/edc/images/gallery_more_opt_save.png
Binary files 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
index 0000000..57f4516
--- /dev/null
+++ b/edc/images/gallery_more_opt_send_to_mobile.png
Binary files differ
diff --git a/edc/layouts.edc b/edc/layouts.edc
index c321322..2502b07 100644
--- a/edc/layouts.edc
+++ b/edc/layouts.edc
@@ -14,13 +14,13 @@
* 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
index 0000000..9233c29
--- /dev/null
+++ b/inc/presenters/IMoreOptionsListener.h
@@ -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
index 0000000..0194885
--- /dev/null
+++ b/inc/presenters/MoreOptionsPresenter.h
@@ -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
index 0000000..0182bbf
--- /dev/null
+++ b/inc/presenters/MoreOptionsPresenter.hpp
@@ -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);
+ }
+}
diff --git a/inc/presenters/types.h b/inc/presenters/types.h
index ad884c3..5b13931 100644
--- a/inc/presenters/types.h
+++ b/inc/presenters/types.h
@@ -17,12 +17,26 @@
#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);
diff --git a/inc/resources.h b/inc/resources.h
index 9e087d1..74a5664 100644
--- a/inc/resources.h
+++ b/inc/resources.h
@@ -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;
}
diff --git a/inc/view/PageContent.h b/inc/view/PageContent.h
index 5f7bfc2..2971207 100644
--- a/inc/view/PageContent.h
+++ b/inc/view/PageContent.h
@@ -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
index 0000000..2095191
--- /dev/null
+++ b/inc/view/PageContent.hpp
@@ -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);
+ }
+}
diff --git a/inc/view/helpers.h b/inc/view/helpers.h
index dab1486..1e85966 100644
--- a/inc/view/helpers.h
+++ b/inc/view/helpers.h
@@ -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__
diff --git a/inc/view/types.h b/inc/view/types.h
index 461f3fc..2254f35 100644
--- a/inc/view/types.h
+++ b/inc/view/types.h
@@ -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
index 0000000..0b2d5c4
--- /dev/null
+++ b/src/presenters/MoreOptionsPresenter.cpp
@@ -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);
+ }
+}
diff --git a/src/presenters/NoContentPage.cpp b/src/presenters/NoContentPage.cpp
index 4ce2e55..8d72c3d 100644
--- a/src/presenters/NoContentPage.cpp
+++ b/src/presenters/NoContentPage.cpp
@@ -21,14 +21,6 @@
#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!");
}
diff --git a/src/view/PageContent.cpp b/src/view/PageContent.cpp
index f3e9c69..2fe5c97 100644
--- a/src/view/PageContent.cpp
+++ b/src/view/PageContent.cpp
@@ -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();
}
}
diff --git a/src/view/helpers.cpp b/src/view/helpers.cpp
index 77b6810..b748865 100644
--- a/src/view/helpers.cpp
+++ b/src/view/helpers.cpp
@@ -71,5 +71,10 @@ namespace gallery {
return sfc;
}
+
+ LayoutTheme getImageTheme(const char *const fileName)
+ {
+ return {"layout", "gallery_image", fileName};
+ }
}
diff --git a/ucl/inc/ucl/util/helpers.h b/ucl/inc/ucl/util/helpers.h
index 82e3d4c..87485b0 100644
--- a/ucl/inc/ucl/util/helpers.h
+++ b/ucl/inc/ucl/util/helpers.h
@@ -34,12 +34,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())
{
return value.empty();
@@ -52,6 +46,12 @@ namespace ucl {
}
template <class T>
+ constexpr auto isEmpty(const T &value) -> decltype(isEmpty(*value))
+ {
+ return (!value || isEmpty(*value));
+ }
+
+ template <class T>
constexpr bool isNotEmpty(T &&value);
template <class T>
diff --git a/ucl/inc/ucl/util/memory/BaseRef.h b/ucl/inc/ucl/util/memory/BaseRef.h
index 6c2b676..0aa1b59 100644
--- a/ucl/inc/ucl/util/memory/BaseRef.h
+++ b/ucl/inc/ucl/util/memory/BaseRef.h
@@ -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;
diff --git a/ucl/inc/ucl/util/memory/BaseRef.hpp b/ucl/inc/ucl/util/memory/BaseRef.hpp
index 4c670a3..d587bc1 100644
--- a/ucl/inc/ucl/util/memory/BaseRef.hpp
+++ b/ucl/inc/ucl/util/memory/BaseRef.hpp
@@ -51,6 +51,12 @@ namespace ucl {
}
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
{
return m_ptr;
diff --git a/ucl/inc/ucl/util/memory/RefCountObjBase.h b/ucl/inc/ucl/util/memory/RefCountObjBase.h
index dfbd007..4e6edf0 100644
--- a/ucl/inc/ucl/util/memory/RefCountObjBase.h
+++ b/ucl/inc/ucl/util/memory/RefCountObjBase.h
@@ -29,6 +29,7 @@ namespace ucl {
void refWeak() noexcept;
void unrefWeak() noexcept;
+ int getUseCount() const noexcept;
bool isDisposed() const noexcept;
protected:
diff --git a/ucl/inc/ucl/util/memory/RefCountObjBase.hpp b/ucl/inc/ucl/util/memory/RefCountObjBase.hpp
index 76860aa..c4b5d42 100644
--- a/ucl/inc/ucl/util/memory/RefCountObjBase.hpp
+++ b/ucl/inc/ucl/util/memory/RefCountObjBase.hpp
@@ -57,6 +57,11 @@ namespace ucl {
}
}
+ inline int RefCountObjBase::getUseCount() const noexcept
+ {
+ return m_useRefs;
+ }
+
inline bool RefCountObjBase::isDisposed() const noexcept
{
return m_isDisposed;