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)
* 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";
}
}
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __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__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __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__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace gallery {
+
+ // Non-member functions //
+
+ inline void open(MoreOptionsPresenter &mop)
+ {
+ mop.setOpened(true);
+ }
+
+ inline void close(MoreOptionsPresenter &mop)
+ {
+ mop.setOpened(false);
+ }
+}
#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);
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;
}
};
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
};
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>;
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__
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace 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);
+ }
+}
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__
#ifndef __GALLERY_VIEW_TYPES_H__
#define __GALLERY_VIEW_TYPES_H__
+#include "ucl/gui/types.h"
+
#include "../types.h"
namespace gallery {
--- /dev/null
+/*
+ * Copyright 2017 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "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);
+ }
+}
#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;
}
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!");
}
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"};
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>
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) {
PageContent::PageContent(RefCountObjBase &rc,
const ucl::LayoutSRef &layout, const int flags) :
ElmWidget(&rc, *layout, true),
- m_moreOption(layout)
+ m_moreOptions(layout)
{
prepare(flags);
}
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().
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;
}
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:
if (m_selectMode) {
return m_selectMode.get();
}
- return m_moreOption.get();
+ return m_moreOptions.get();
}
}
return sfc;
}
+
+ LayoutTheme getImageTheme(const char *const fileName)
+ {
+ return {"layout", "gallery_image", fileName};
+ }
}
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.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);
friend class WeakRef;
public:
+ int getUseCount() const;
+
T *operator->() const noexcept;
typename std::add_lvalue_reference<T>::type operator*() const noexcept;
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
{
void refWeak() noexcept;
void unrefWeak() noexcept;
+ int getUseCount() const noexcept;
bool isDisposed() const noexcept;
protected:
}
}
+ inline int RefCountObjBase::getUseCount() const noexcept
+ {
+ return m_useRefs;
+ }
+
inline bool RefCountObjBase::isDisposed() const noexcept
{
return m_isDisposed;