--- /dev/null
+/*
+ * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "ListLayout.h"
+
+#define SEARCH_DIVIDER_H 2
+
+color_classes {
+ color_class {
+ name: "search_divider";
+ color: 61 185 204 38;
+ }
+}
+
+collections {
+ base_scale: 2.6;
+
+ group { LAYOUT_LIST;
+ parts {
+ swallow { PART_SEARCH;
+ desc { "default";
+ align: 0.5 0.0;
+ rel2.relative: 1.0 0.0;
+ }
+ }
+ rect { "rect.search_divider"; scale;
+ after: PART_CONTENT;
+ desc { "default";
+ align: 0.5 0.0;
+ min: 0 SEARCH_DIVIDER_H;
+ rel1 { relative: 0.0 1.0; to_y: PART_SEARCH; }
+ rel2 { relative: 1.0 1.0; to_y: PART_SEARCH; }
+ color_class: "search_divider";
+ }
+ }
+ swallow { PART_CONTENT;
+ desc { "default";
+ align: 0.5 0.0;
+ rel1 { relative: 0.0 1.0; to_y: PART_SEARCH; }
+ rel2 { relative: 1.0 1.0; to_y: PART_SEARCH; }
+ }
+ desc { "expanded";
+ inherit: "default";
+ rel2.to_y: "";
+ }
+ }
+ swallow { PART_NO_CONTENTS;
+ desc { "default";
+ align: 0.5 0.0;
+ rel1 { relative: 0.0 1.0; to_y: PART_CONTENT; }
+ }
+ desc { "hidden";
+ inherit: "default";
+ visible: 0;
+ }
+ }
+ }
+ programs {
+ program {
+ signal: SIGNAL_CONTENT_COMPRESS;
+ source: "*";
+ script {
+ set_state(PART:PART_CONTENT, "default", 0.0);
+ set_state(PART:PART_NO_CONTENTS, "default", 0.0);
+ }
+ }
+ program {
+ signal: SIGNAL_CONTENT_EXPAND;
+ source: "*";
+ script {
+ set_state(PART:PART_CONTENT, "expanded", 0.0);
+ set_state(PART:PART_NO_CONTENTS, "hidden", 0.0);
+ }
+ }
+ }
+ }
+}
#include "Utils/Range.h"
#include "Utils/Thread.h"
-#include "ListPath.h"
+#include "ListLayout.h"
#include <algorithm>
#include <efl_extension.h>
#define SYMBOL_STAR "\uf896"
ListView::ListView(Model::PersonProvider *provider)
- : m_ListLayout(nullptr), m_NoContent(nullptr), m_Genlist(nullptr),
+ : m_Content(nullptr), m_NoContent(nullptr), m_Genlist(nullptr),
m_Index(nullptr), m_SearchField(nullptr), m_AddButton(nullptr),
m_NoContentHelpText("IDS_PB_BODY_AFTER_YOU_CREATE_CONTACTS_THEY_WILL_BE_SHOWN_HERE"),
- m_IsSearching(false), m_IsEmpty(true), m_HasAddButton(true),
+ m_IsSearching(false), m_HasAddButton(true),
m_PersonProvider(provider),
m_SearchProvider(new SearchProvider(*m_PersonProvider, PersonComparator()))
{
}
}
-bool ListView::isListEmpty()
+bool ListView::isEmpty()
{
- return m_IsEmpty;
+ return m_IsSearching ? m_SearchProvider->empty() : m_PersonGroups.empty();;
}
Evas_Object *ListView::onCreate(Evas_Object *parent)
{
- return elm_box_add(parent);
+ return elm_layout_add(parent);
}
void ListView::onCreated()
updateAddButton();
setUpdateEnabled(isCurrent);
- elm_object_focus_set(m_ListLayout, EINA_TRUE);
+ elm_object_focus_set(m_Content, EINA_TRUE);
}
bool ListView::onBackPressed()
void ListView::onMenuPressed()
{
- if (getSelectMode() != SelectNone || (m_IsSearching && m_IsEmpty)) {
+ if (getSelectMode() != SelectNone || (m_IsSearching && isEmpty())) {
return;
}
});
}
- if (!m_IsEmpty) {
+ if (!isEmpty()) {
menu->addItem("IDS_PB_OPT_DELETE", std::bind(&ListView::onDeleteSelected, this));
menu->addItem("IDS_PB_OPT_SHARE", std::bind(&ListView::onShareSelected, this));
void ListView::fillLayout()
{
- Evas_Object *box = getEvasObject();
- evas_object_smart_callback_add(box, "language,changed",
+ Evas_Object *layout = getEvasObject();
+ elm_layout_file_set(layout, App::getResourcePath(LIST_LAYOUT_EDJ).c_str(), LAYOUT_LIST);
+ evas_object_smart_callback_add(layout, "language,changed",
makeCallback(&ListView::onLanguageChanged), this);
- m_ListLayout = createListLayout(box);
- elm_box_pack_end(box, m_ListLayout);
+ elm_object_part_content_set(layout, PART_CONTENT, createContent(layout));
- m_Index = new ListIndex();
- m_Index->setUpdateCallback(std::bind(&ListView::onIndexUpdated, this));
- elm_object_part_content_set(m_ListLayout, "elm.swallow.fastscroll", m_Index->create(m_ListLayout));
-
- m_Genlist = createGenlist(m_ListLayout);
- elm_object_part_content_set(m_ListLayout, "elm.swallow.content", m_Genlist->getEvasObject());
+ m_NoContent = elm_layout_add(layout);
+ elm_layout_theme_set(m_NoContent, "layout", "nocontents", "default");
+ elm_object_part_content_set(layout, PART_NO_CONTENTS, m_NoContent);
- m_NoContent = createEmptyLayout(box);
- elm_box_pack_end(box, m_NoContent);
+ m_SearchField = createSearchField(layout);
+ m_AddButton = createAddButton(layout);
- m_SearchField = createSearchField(box);
- m_AddButton = createAddButton(box);
-
- elm_object_focus_custom_chain_set(box, eina_list_append(nullptr, m_ListLayout));
+ elm_object_focus_custom_chain_set(layout, eina_list_append(nullptr, m_Content));
}
-Evas_Object *ListView::createListLayout(Evas_Object *parent)
+Evas_Object *ListView::createContent(Evas_Object *parent)
{
- Evas_Object *layout = elm_layout_add(parent);
- elm_layout_theme_set(layout, "layout", "application", "fastscroll");
- elm_layout_signal_emit(layout, "elm,state,fastscroll,hide", "");
-
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0);
- evas_object_show(layout);
- return layout;
-}
+ m_Content = elm_layout_add(parent);
+ elm_layout_theme_set(m_Content, "layout", "application", "fastscroll");
+ elm_layout_signal_emit(m_Content, "elm,state,fastscroll,hide", "");
-Ui::Genlist *ListView::createGenlist(Evas_Object *parent)
-{
- auto genlist = new Ui::Genlist();
- genlist->create(parent);
- elm_scroller_content_min_limit(genlist->getEvasObject(), EINA_FALSE, EINA_TRUE);
- return genlist;
-}
-
-Evas_Object *ListView::createEmptyLayout(Evas_Object *parent)
-{
- Evas_Object *layout = elm_layout_add(parent);
- elm_layout_theme_set(layout, "layout", "nocontents", "default");
+ m_Index = new ListIndex();
+ m_Index->setUpdateCallback(std::bind(&ListView::onIndexUpdated, this));
+ elm_object_part_content_set(m_Content, "elm.swallow.fastscroll", m_Index->create(m_Content));
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_show(layout);
+ m_Genlist = new Ui::Genlist();
+ elm_object_part_content_set(m_Content, "elm.swallow.content", m_Genlist->create(m_Content));
- return layout;
+ return m_Content;
}
SearchField *ListView::createSearchField(Evas_Object *parent)
auto control = new SearchField();
control->setChangeCallback(std::bind(&ListView::onSearchChanged, this, _1));
control->create(parent);
-
- evas_object_size_hint_weight_set(control->getEvasObject(), EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(control->getEvasObject(), EVAS_HINT_FILL, 0.0);
return control;
}
void ListView::updateEmptyState()
{
- bool isEmpty = m_IsSearching ? m_SearchProvider->empty() : m_PersonGroups.empty();
-
updateIndex();
updateSearchField();
- if (isEmpty == m_IsEmpty) {
- return;
- }
-
- Evas_Object *genlist = m_Genlist->getEvasObject();
- if (isEmpty) {
- elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_TRUE);
- evas_object_size_hint_weight_set(m_ListLayout, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(m_ListLayout, EVAS_HINT_FILL, 0.0);
-
- evas_object_show(m_NoContent);
- elm_box_pack_end(getEvasObject(), m_NoContent);
- } else {
- elm_scroller_content_min_limit(genlist, EINA_FALSE, EINA_FALSE);
- evas_object_size_hint_weight_set(m_ListLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(m_ListLayout, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
- evas_object_hide(m_NoContent);
- elm_box_unpack(getEvasObject(), m_NoContent);
- }
- m_IsEmpty = isEmpty;
+ elm_scroller_content_min_limit(m_Genlist->getEvasObject(), EINA_FALSE, isEmpty());
+ elm_layout_signal_emit(getEvasObject(), isEmpty() ? SIGNAL_CONTENT_COMPRESS : SIGNAL_CONTENT_EXPAND, "");
}
void ListView::updateEmptyLayout()
}
const char *signal = isVisible ? "elm,state,fastscroll,show" : "elm,state,fastscroll,hide";
- elm_layout_signal_emit(m_ListLayout, signal, "");
+ elm_layout_signal_emit(m_Content, signal, "");
if (isVisible) {
elm_index_level_go(m_Index->getEvasObject(), 0);
}
return;
}
- if (isEmpty) {
- elm_box_unpack(getEvasObject(), searchField);
- evas_object_hide(searchField);
+ if (!isEmpty) {
+ elm_object_part_content_set(getEvasObject(), PART_SEARCH, searchField);
} else {
- elm_box_pack_start(getEvasObject(), searchField);
- evas_object_show(searchField);
+ evas_object_hide(elm_object_part_content_unset(getEvasObject(), PART_SEARCH));
}
}