From: Bartlomiej Grzelewski Date: Thu, 13 Aug 2020 13:09:16 +0000 (+0200) Subject: New style for Genlist X-Git-Tag: submit/tizen/20200823.213148^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a82c7d783e451cd9ae9389c351a48625dc4926bd;p=profile%2Fcommon%2Fapps%2Fnative%2Faccessibility-setting.git New style for Genlist 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index efdfb73..f9cb7b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 0000000..15092c6 --- /dev/null +++ b/resource/main-layout.edc @@ -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"; } + } + } + } + } +} diff --git a/src/ui/Naviframe.cpp b/src/ui/Naviframe.cpp index 81f86db..ba54aa3 100644 --- a/src/ui/Naviframe.cpp +++ b/src/ui/Naviframe.cpp @@ -48,11 +48,15 @@ NaviframeItem Naviframe::pushBack( const std::string &style) { naviframeStack_.push(std::make_pair(content, prevBtn)); + + auto layout = Widget::make(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 index 0000000..5011ce4 --- /dev/null +++ b/src/utils/GenlistItemStyle.cpp @@ -0,0 +1,59 @@ +#include + +#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(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 index 0000000..b41aab9 --- /dev/null +++ b/src/utils/GenlistItemStyle.hpp @@ -0,0 +1,10 @@ +#ifndef GENLIST_ITEM_STYLE_HPP +#define GENLIST_ITEM_STYLE_HPP + +namespace Style { + +void setGenlistItemStyle(void *eventInfo); + +} //namespace Style + +#endif diff --git a/src/view/ListView.cpp b/src/view/ListView.cpp index 9219252..ec8e8b1 100644 --- a/src/view/ListView.cpp +++ b/src/view/ListView.cpp @@ -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(presenter)) @@ -32,6 +33,7 @@ ListView::ListView(const NavigationContext &context, Presenter *presenter) genlist_ = Widget::make(naviframe_); genlist_->setMode(ELM_LIST_COMPRESS); genlist_->setStyle("dialogue"); + genlist_->setEvasSmartCallback("realized", [](void *infoEvent) {Style::setGenlistItemStyle(infoEvent);}); addItemsToGenlist(); listPresenter_->setOnListUpdateCallback([this]() {