--- /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.
+ */
+
+group { "elm/layout/gallery/more_option";
+ parts {
+ swallow { "elm.swallow.content";
+ desc { "default";
+ }
+ }
+ swallow { "gallery.swallow.more_option";
+ desc { "default";
+ }
+ }
+ }
+}
namespace gallery {
- class ImageGrid : public ucl::Widget {
+ class ImageGrid : public ucl::ElmWidget {
public:
enum class Type {
HCOMB_3X3,
constexpr ucl::SmartEvent IMAGE_VIEWER_ZOOM_END {"gallery,zoom,end"};
- class ImageViewer final : public ucl::Widget {
+ class ImageViewer final : public ucl::ElmWidget {
public:
class Builder {
public:
--- /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_VIEW_PAGE_CONTENT_H__
+#define __GALLERY_VIEW_PAGE_CONTENT_H__
+
+#include "ucl/gui/Layout.h"
+
+#include "types.h"
+
+namespace gallery {
+
+ class PageContent : public ucl::ElmWidget {
+ public:
+ class Builder {
+ public:
+ Builder();
+ Builder &setFlags(int flags);
+ PageContentSRef build(ucl::Widget &parent) const;
+ private:
+ int m_flags;
+ };
+
+ enum {
+ FLAG_MORE_OPTION = 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)
+ };
+
+ enum class Part {
+ DEFAULT,
+ MORE_OPTION,
+ SELECT_BUTTON,
+ BOTTOM_BUTTON
+ };
+
+ public:
+ ucl::Result set(Evas_Object *eo, Part part = Part::DEFAULT);
+ Evas_Object *unset(Part part = Part::DEFAULT);
+
+ Evas_Object *get(Part part = Part::DEFAULT) const;
+
+ ucl::Result setSelectButtonVisible(bool visible);
+ ucl::Result setMoreOptionVisible(bool visible);
+
+ private:
+ friend class ucl::RefCountObj<PageContent>;
+ PageContent(ucl::RefCountObjBase &rc,
+ const ucl::LayoutSRef &layout, int flags);
+ virtual ~PageContent();
+
+ void prepare(int flags);
+
+ template <class FUNC>
+ ucl::Result doWithPart(Part part, FUNC &&func) const;
+
+ ucl::Layout *getTopLayout() const;
+
+ private:
+ ucl::LayoutWRef m_moreOption;
+ ucl::LayoutSRef m_selectMode;
+ ucl::LayoutSRef m_bottomButton;
+ };
+}
+
+#endif // __GALLERY_VIEW_PAGE_CONTENT_H__
UCL_DECLARE_REF_ALIASES(TouchParser);
+ UCL_DECLARE_REF_ALIASES(PageContent);
+
UCL_DECLARE_REF_ALIASES(ImageGrid);
UCL_DECLARE_REF_ALIASES(ImageViewer);
}
#include "../../edc/images.edc"
#include "../../edc/image-grid.edc"
#include "../../edc/button.edc"
+ #include "../../edc/layouts.edc"
}
}
layout->setContent(*icon);
- layout->setText(PART_TITLE, STR_APP_NAME);
+ layout->setText(STR_APP_NAME, PART_TITLE);
layout->setText(STR_NO_PHOTOS);
FAIL_RETURN(Page::prepare(
void Page::dispatchTopPageChanged()
{
- m_navi->callSmartEvent(impl::TOP_PAGE_CHANGED, nullptr);
+ m_navi->callEvent(impl::TOP_PAGE_CHANGED, nullptr);
}
void Page::onItemDel(Evas_Object *obj, void *eventInfo)
if (params.flags & UF_BLOCK_CLICKS) {
if (!m_isClicksBlocked) {
m_isClicksBlocked = true;
- m_btn.emitSignal(impl::BTN_BLOCK_CLICKS);
+ m_btn.emit(impl::BTN_BLOCK_CLICKS);
}
} else if (m_isClicksBlocked) {
m_isClicksBlocked = false;
- m_btn.emitSignal(impl::BTN_UNBLOCK_CLICKS);
+ m_btn.emit(impl::BTN_UNBLOCK_CLICKS);
}
}
evas_object_image_filled_add(m_btn.getEvas()));
evas_object_image_load_size_set(*m_bgImage,
m_imageLoadSize, m_imageLoadSize);
- m_btn.setContent(impl::BTN_PART_BG, *m_bgImage);
+ m_btn.setContent(*m_bgImage, impl::BTN_PART_BG);
show(*m_bgImage);
}
if (!m_layout.setTheme(m_info.slotThemes[isOdd])) {
ELOG("setTheme() failed!");
} else if (imageGrid.m_isInSelectMode) {
- m_layout.emitSignal(impl::SIGNAL_FORCE_SELECT_MODE);
+ m_layout.emit(impl::SIGNAL_FORCE_SELECT_MODE);
}
}
fill(m_layout);
m_items.emplace_back(makeShared<Item>(imageGrid, m_layout));
const auto partName = impl::SLOT_PART_FMT.format(i);
- m_layout.setContent(EdjePart(partName.c_str()),
- m_items.back()->getWidget());
+ m_layout.setContent(m_items.back()->getWidget(),
+ EdjePart(partName.c_str()));
}
}
const auto signalName = (selected ?
impl::SIGNAL_SELECT_ITEM_FMT.format(itemOffset) :
impl::SIGNAL_UNSELECT_ITEM_FMT.format(itemOffset));
- m_layout.emitSignal(EdjeSignal(signalName.c_str()));
+ m_layout.emit(EdjeSignal(signalName.c_str()));
}
private:
ImageGrid::ImageGrid(RefCountObjBase *const rc, Evas_Object *const scroller,
const Type type, const bool selectModeStartup) :
- Widget(rc, scroller, true),
+ ElmWidget(rc, scroller, true),
m_info(getInfo(type)),
m_scroller(makeShared<StyledWidget>(scroller)),
impl::SIGNAL_ENABLE_SELECT_MODE :
impl::SIGNAL_DISABLE_SELECT_MODE);
for (auto &slot: m_slots) {
- slot->getLayout().emitSignal(aSignal);
+ slot->getLayout().emit(aSignal);
}
m_animator = ecore_animator_add(
ImageViewer::ImageViewer(RefCountObjBase &rc,
const int imageW, const int imageH,
Evas_Object *const scroller) :
- Widget(&rc, scroller, true),
+ ElmWidget(&rc, scroller, true),
m_imageW(imageW),
m_imageH(imageH),
m_state = State::ZOOMED_OUT;
elm_object_scroll_freeze_push(*m_scroller);
}
- callSmartEvent(IMAGE_VIEWER_ZOOM_END, nullptr);
+ callEvent(IMAGE_VIEWER_ZOOM_END, nullptr);
return ECORE_CALLBACK_CANCEL;
}
--- /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 "view/PageContent.h"
+
+#include "common.h"
+
+namespace gallery { namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr LayoutTheme LAYOUT_MORE_OPTION
+ {"layout", "gallery", "more_option"};
+
+ 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 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 EdjeSignalSrc SIGNAL_SRC_EXT {"ext"};
+
+ template <class OBJ, class FUNC, class ...ARGS>
+ Result callSafe(OBJ *obj, FUNC &&func, ARGS &&...args)
+ {
+ if (!obj) {
+ FAIL_RETURN(RES_FAIL, "obj is NULL!");
+ }
+ func(*obj, std::forward<ARGS>(args)...);
+ return RES_OK;
+ }
+}}}
+
+namespace gallery {
+
+ using namespace ucl;
+
+ // PageContent::Builder //
+
+ PageContent::Builder::Builder() :
+ m_flags(0)
+ {
+ }
+
+ PageContent::Builder &PageContent::Builder::setFlags(const int flags)
+ {
+ m_flags = flags;
+ return *this;
+ }
+
+ PageContentSRef PageContent::Builder::build(Widget &parent) const
+ {
+ auto layout = Layout::Builder().
+ setTheme(impl::LAYOUT_MORE_OPTION).
+ setIsOwner(true).
+ build(parent);
+ if (!layout) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!");
+ }
+
+ auto result = makeShared<PageContent>(layout, m_flags);
+
+ result->bindToEo();
+
+ return result;
+ }
+
+ // PageContent //
+
+ PageContent::PageContent(RefCountObjBase &rc,
+ const ucl::LayoutSRef &layout, const int flags) :
+ ElmWidget(&rc, *layout, true),
+ m_moreOption(layout)
+ {
+ prepare(flags);
+ }
+
+ PageContent::~PageContent()
+ {
+ }
+
+ void PageContent::prepare(const int flags)
+ {
+ m_moreOption->setIsOwner(false);
+
+ LayoutSRef parent = m_moreOption;
+
+ if (flags & FLAG_SELECT_BUTTON) {
+ m_selectMode = Layout::Builder().
+ setTheme(impl::LAYOUT_SELECT_MODE).
+ build(*parent);
+ parent->setContent(*m_selectMode);
+ parent = m_selectMode;
+ }
+
+ if (flags & FLAG_BOTTOM_BUTTON) {
+ m_bottomButton = Layout::Builder().
+ setTheme(impl::LAYOUT_BOTTOM_BUTTON).
+ build(*parent);
+ parent->setContent(*m_bottomButton);
+ parent = m_bottomButton;
+ }
+ }
+
+ Result PageContent::set(Evas_Object *const eo, const Part part)
+ {
+ return doWithPart(part,
+ [eo](Layout &layout, const EdjePart part)
+ {
+ layout.setContent(eo, part);
+ });
+ }
+
+ Evas_Object *PageContent::unset(const Part part)
+ {
+ Evas_Object *result = {};
+ doWithPart(part,
+ [&result](Layout &layout, const EdjePart part)
+ {
+ result = layout.unsetContent(part);
+ });
+ return result;
+ }
+
+ Evas_Object *PageContent::get(const Part part) const
+ {
+ Evas_Object *result = {};
+ doWithPart(part,
+ [&result](Layout &layout, const EdjePart part)
+ {
+ result = layout.getContent(part);
+ });
+ return result;
+ }
+
+ Result PageContent::setSelectButtonVisible(const bool visible)
+ {
+ if (!m_selectMode) {
+ LOG_RETURN(RES_FAIL, "Select button is not supported!");
+ }
+ m_selectMode->emit(visible ? impl::SIGNAL_SHOW_SELECT_BUTTON :
+ impl::SIGNAL_HIDE_SELECT_BUTTON);
+ return RES_OK;
+ }
+
+ Result PageContent::setMoreOptionVisible(const bool visible)
+ {
+ if (!m_moreOption) {
+ LOG_RETURN(RES_FAIL, "More option is not supported!");
+ }
+ const auto content = m_moreOption->getContent(impl::PART_MORE_OPTION);
+ 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_SRC_EXT);
+ return RES_OK;
+ }
+
+ template <class FUNC>
+ Result PageContent::doWithPart(const Part part, FUNC &&func) const
+ {
+ 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::SELECT_BUTTON:
+ return impl::callSafe(m_selectMode.get(), func, PART_ICON);
+ case Part::BOTTOM_BUTTON:
+ return impl::callSafe(m_bottomButton.get(), func, PART_BUTTON);
+ }
+ LOG_RETURN(RES_FATAL, "Should not be here!");
+ }
+
+ Layout *PageContent::getTopLayout() const
+ {
+ if (m_bottomButton) {
+ return m_bottomButton.get();
+ }
+ if (m_selectMode) {
+ return m_selectMode.get();
+ }
+ return m_moreOption.get();
+ }
+}
class EdjeWidget : public ElmWidget {
public:
void setText(const TString &value);
- void setText(EdjePart part, const TString &value);
+ void setText(const TString &value, EdjePart part);
TString getText() const;
TString getText(EdjePart part) const;
void setContent(Evas_Object *content);
- void setContent(EdjePart part, Evas_Object *content);
+ void setContent(Evas_Object *content, EdjePart part);
Evas_Object *unsetContent();
Evas_Object *unsetContent(EdjePart part);
Evas_Object *getContent() const;
Evas_Object *getContent(EdjePart part) const;
- void emitSignal(EdjeSignal signal, EdjeSignalSrc source =
+ void emit(EdjeSignal signal, EdjeSignalSrc source =
EdjeSignalSrc(""));
protected:
elm_object_content_set(getEo(), content);
}
- inline void EdjeWidget::setContent(const EdjePart part,
- Evas_Object *const content)
+ inline void EdjeWidget::setContent(Evas_Object *const content,
+ const EdjePart part)
{
elm_object_part_content_set(getEo(), part.name, content);
}
return elm_object_part_content_get(getEo(), part.name);
}
- inline void EdjeWidget::emitSignal(const EdjeSignal signal,
+ inline void EdjeWidget::emit(const EdjeSignal signal,
const EdjeSignalSrc source)
{
elm_object_signal_emit(getEo(), signal.name, source.name);
bool setTheme(const LayoutTheme &theme);
bool setEdjeFile(const std::string &filePath, EdjeGroup group);
- Variant getEdjeData(EdjeDataKey key);
+ Variant getData(EdjeDataKey key);
};
}
return elm_layout_file_set(getEo(), filePath.c_str(), group.name);
}
- inline Variant Layout::getEdjeData(EdjeDataKey key)
+ inline Variant Layout::getData(EdjeDataKey key)
{
return elm_layout_data_get(getEo(), key);
}
void delEventHandler(WidgetEvent event, WidgetEventHandler handler);
void delEventHandler(SmartEvent event, WidgetEventHandler handler);
- void callSmartEvent(SmartEvent event, void *eventInfo = nullptr);
+ void callEvent(SmartEvent event, void *eventInfo = nullptr);
void markForDeletion();
return evas_object_data_get(getEo(), key.name);
}
- inline void Widget::callSmartEvent(SmartEvent event, void *eventInfo)
+ inline void Widget::callEvent(SmartEvent event, void *eventInfo)
{
evas_object_smart_callback_call(getEo(), event, eventInfo);
}
bool isEnabled() const;
void setText(const TString &value) const;
- void setText(EdjePart part, const TString &value) const;
+ void setText(const TString &value, EdjePart part) const;
TString getText() const;
TString getText(EdjePart part) const;
void setContent(Evas_Object *content) const;
- void setContent(EdjePart part, Evas_Object *content) const;
+ void setContent(Evas_Object *content, EdjePart part) const;
Evas_Object *unsetContent() const;
Evas_Object *unsetContent(EdjePart part) const;
Evas_Object *getContent() const;
Evas_Object *getContent(EdjePart part) const;
- void emitSignal(EdjeSignal signal,EdjeSignalSrc source =
+ void emit(EdjeSignal signal,EdjeSignalSrc source =
EdjeSignalSrc("")) const;
private:
elm_object_item_content_set(getIt(), content);
}
- inline void WidgetItem::setContent(const EdjePart part,
- Evas_Object *const content) const
+ inline void WidgetItem::setContent(Evas_Object *const content,
+ const EdjePart part) const
{
elm_object_item_part_content_set(getIt(), part.name, content);
}
return elm_object_item_part_content_get(getIt(), part.name);
}
- inline void WidgetItem::emitSignal(const EdjeSignal signal,
+ inline void WidgetItem::emit(const EdjeSignal signal,
const EdjeSignalSrc source) const
{
elm_object_item_signal_emit(getIt(), signal.name, source.name);
constexpr EdjePart PART_CONTENT {"elm.swallow.content"};
constexpr EdjePart PART_ICON {"elm.swallow.icon"};
+ constexpr EdjePart PART_BUTTON {"elm.swallow.button"};
}
#endif // __UCL_GUI_STD_THEME_COMMON_H__
}
}
- void EdjeWidget::setText(const EdjePart part, const TString &value)
+ void EdjeWidget::setText(const TString &value, const EdjePart part)
{
if (value.isTranslatable()) {
if (value.hasDomain()) {
result->bindToEo();
}
- bool isOk = false;
+ bool isOk = true;
if (isNotEmpty(m_edjeFilePath) && isValid(m_edjeGroup)) {
isOk = result->setEdjeFile(m_edjeFilePath, m_edjeGroup);
- } else {
- isOk = result->setTheme(isValid(m_theme) ?
- m_theme : LAYOUT_DEFAULT);
+ } else if (isValid(m_theme)) {
+ isOk = result->setTheme(m_theme);
}
if (!isOk) {
{
if (!m_isInTransition) {
m_isInTransition = true;
- callSmartEvent(NAVI_TRANSITION_STARTED);
+ callEvent(NAVI_TRANSITION_STARTED);
}
}
}
}
- void WidgetItem::setText(
- const EdjePart part, const TString &value) const
+ void WidgetItem::setText(const TString &value,
+ const EdjePart part) const
{
if (value.isTranslatable()) {
if (value.hasDomain()) {