New style for Genlist 12/241012/12 accepted/tizen_6.0_unified accepted/tizen_6.0_unified_hotfix tizen_6.0 tizen_6.0_hotfix accepted/tizen/6.0/unified/20201030.104238 accepted/tizen/6.0/unified/hotfix/20201103.045848 accepted/tizen/unified/20200824.134435 submit/tizen/20200823.213148 submit/tizen_6.0/20201029.205504 submit/tizen_6.0_hotfix/20201102.192904 submit/tizen_6.0_hotfix/20201103.115104 tizen_6.0.m2_release
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 13 Aug 2020 13:09:16 +0000 (15:09 +0200)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Wed, 19 Aug 2020 10:18:35 +0000 (12:18 +0200)
This commit should change style of Genlist.
Each element of genlist should have additional spaces at right
and left side. Also this commit should make verticles round.

Change-Id: I1c58f5fecc70db97c9586472dde099cd248479fc

CMakeLists.txt
resource/main-layout.edc [new file with mode: 0644]
src/ui/Naviframe.cpp
src/utils/GenlistItemStyle.cpp [new file with mode: 0644]
src/utils/GenlistItemStyle.hpp [new file with mode: 0644]
src/view/ListView.cpp

index efdfb731a5ec7a3d519a39fc2d611a1da8286af1..f9cb7b55b7e1e4412233783bce5b610a303e7658 100644 (file)
@@ -72,7 +72,8 @@ SET(EDC_LIST
        accessibility-smart-switch-accessory-popup;
        genlist;
        spinner-layout;
-       spinner-layout-toggle;)
+       spinner-layout-toggle;
+       main-layout;)
 
 FOREACH(F ${EDC_LIST})
        ADD_CUSTOM_TARGET(${F}.edj
diff --git a/resource/main-layout.edc b/resource/main-layout.edc
new file mode 100644 (file)
index 0000000..15092c6
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#define PADDING_SIZE 40
+
+collections
+{
+       base_scale: 1.8;
+
+       group { "settings/main_layout";
+               parts {
+                       rect { "base";
+                               desc { "default";
+                                       color: 238 239 241 255;
+                               }
+                       }
+                       spacer { "padding.left"; scale;
+                               desc { "default";
+                                       min: PADDING_SIZE 0;
+                                       max: PADDING_SIZE -1;
+                                       fixed: 1 0;
+                                       align: 0.0 0.0;
+                                       rel.to: "base";
+                               }
+                       }
+                       spacer { "padding.right"; scale;
+                               desc { "default";
+                                       min: PADDING_SIZE 0;
+                                       max: PADDING_SIZE -1;
+                                       fixed: 1 0;
+                                       align: 1.0 0.0;
+                                       rel.to: "base";
+                               }
+                       }
+                       swallow { "elm.swallow.content";
+                               desc { "default";
+                                       rel1 { relative: 1.0 0.0; to: "padding.left"; }
+                                       rel2 { relative: 0.0 1.0; to: "padding.right"; }
+                               }
+                       }
+               }
+       }
+}
index 81f86db9946321b12b796cc499a6ccf61f091a3e..ba54aa335d60f49226329ec01103a0628182a60d 100644 (file)
@@ -48,11 +48,15 @@ NaviframeItem Naviframe::pushBack(
        const std::string &style)
 {
        naviframeStack_.push(std::make_pair(content, prevBtn));
+
+       auto layout = Widget::make<Layout>(this, "edje/main-layout.edj", "settings/main_layout");
+       layout->setContent("elm.swallow.content", content);
+
        auto top = elm_naviframe_item_push(uniqueObj_.get(),
                title.c_str(),
                prevBtn ? prevBtn->getObject() : nullptr,
                nullptr,
-               content->getObject(),
+               layout->getObject(),
                style.c_str());
        if (onPopCb) {
                naviframeCallbacks_.insert_or_assign(top, std::move(onPopCb));
diff --git a/src/utils/GenlistItemStyle.cpp b/src/utils/GenlistItemStyle.cpp
new file mode 100644 (file)
index 0000000..5011ce4
--- /dev/null
@@ -0,0 +1,59 @@
+#include <Elementary.h>
+
+#include "GenlistItemStyle.hpp"
+
+namespace {
+
+const char * const GROUP_STYLE = "group_index";
+
+const char * const GENLIST_ITEM_STYLE_SINGLE = "elm,state,group,single";
+const char * const GENLIST_ITEM_STYLE_TOP    = "elm,state,group,top";
+const char * const GENLIST_ITEM_STYLE_BOTTOM = "elm,state,group,bottom";
+const char * const GENLIST_ITEM_STYLE_MIDDLE = "elm,state,group,middle";
+
+bool itemHaveStyle(Elm_Object_Item *item, const char *style) {
+       if (!item)
+               return false;
+
+       const Elm_Genlist_Item_Class *itc = elm_genlist_item_item_class_get(item);
+
+       if (!itc || !itc->item_style || strcmp(itc->item_style, style))
+               return false;
+
+       return true;
+}
+
+} // anonymous namespace
+
+namespace Style {
+
+void setGenlistItemStyle(void *eventInfo) {
+       if (!eventInfo)
+               return;
+
+       Elm_Object_Item *item = static_cast<Elm_Object_Item*>(eventInfo);
+       Elm_Object_Item *prev = elm_genlist_item_prev_get(item);
+       Elm_Object_Item *next = elm_genlist_item_next_get(item);
+
+       bool first = true;
+       bool last  = true;
+
+       if (prev)
+               first = itemHaveStyle(prev, GROUP_STYLE);
+
+       if (next)
+               last = itemHaveStyle(next, GROUP_STYLE);
+
+       if (first && last) {
+               elm_object_item_signal_emit(item, GENLIST_ITEM_STYLE_SINGLE, "elm");
+       } else if (first) {
+               elm_object_item_signal_emit(item, GENLIST_ITEM_STYLE_TOP, "elm");
+       } else if (last) {
+               elm_object_item_signal_emit(item, GENLIST_ITEM_STYLE_BOTTOM, "elm");
+       } else  {
+               elm_object_item_signal_emit(item, GENLIST_ITEM_STYLE_MIDDLE, "elm");
+       }
+}
+
+} // namespace Style
+
diff --git a/src/utils/GenlistItemStyle.hpp b/src/utils/GenlistItemStyle.hpp
new file mode 100644 (file)
index 0000000..b41aab9
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef GENLIST_ITEM_STYLE_HPP
+#define GENLIST_ITEM_STYLE_HPP
+
+namespace Style {
+
+void setGenlistItemStyle(void *eventInfo);
+
+} //namespace Style
+
+#endif
index 9219252bae25a0cf0dce8c5641687a749abf75b3..ec8e8b127597334361a3eeaabd5cefa4202a98a8 100644 (file)
@@ -22,6 +22,7 @@
 #include "ListPresenter.hpp"
 #include "NavigationContext.hpp"
 #include "Singleton.hpp"
+#include "GenlistItemStyle.hpp"
 
 ListView::ListView(const NavigationContext &context, Presenter *presenter)
        : NaviframeView(context), listPresenter_(dynamic_cast<ListPresenter *>(presenter))
@@ -32,6 +33,7 @@ ListView::ListView(const NavigationContext &context, Presenter *presenter)
        genlist_ = Widget::make<Genlist>(naviframe_);
        genlist_->setMode(ELM_LIST_COMPRESS);
        genlist_->setStyle("dialogue");
+       genlist_->setEvasSmartCallback("realized", [](void *infoEvent) {Style::setGenlistItemStyle(infoEvent);});
 
        addItemsToGenlist();
        listPresenter_->setOnListUpdateCallback([this]() {