Update TextDecorator class.
Change-Id: I4d25fe0b7e0a101cab65582a960d249316a39667
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
}
}
- group { name: "elm/genlist/item/1lineitem/default";
+ group {
+ name: "elm/genlist/item/conv_title/default";
+ data.item: "contents" "swl.content";
+ parts{
+ PADDING_TOP("pad.top", 37);
+ PADDING_BOTTOM("pad.bottom", 7);
+ swallow { "swl.content"; scale; nomouse;
+ desc { "default";
+ align: 0.5 1.0;
+ min: 0 39;
+ max: 240 39;
+ rel1 { relative : 0.0 1.0; to_y: "pad.top"; }
+ rel2 { relative : 1.0 0.0; to_y: "pad.bottom"; }
+ }
+ }
+ }
+ }
+
+ group {
+ name: "elm/genlist/item/1lineitem/default";
inherit: "elm/genlist/item/dateline/default";
parts {
spacer { "pad.top"; scale; nomouse;
#include <string>
namespace Msg {
- enum class TextAlign {
- None,
- Left,
- Center,
- Right
- };
-
class TextStyle {
public:
+ enum class Align {
+ None,
+ Left,
+ Center,
+ Right
+ };
+
+ enum class Weight {
+ None,
+ Bold
+ };
+
static const char *defaultColor;
static const char *whiteColor;
static const int defaultFontSize;
public:
TextStyle();
- TextStyle(int size, const std::string &color, TextAlign align = TextAlign::None);
+ TextStyle(int size, const std::string &color, Align align = Align::None);
~TextStyle();
- void setColor(const std::string &color);
- void setSize(int size);
- void setAlign(TextAlign align);
+ TextStyle &setColor(const std::string &color);
+ TextStyle &setSize(int size);
+ TextStyle &setAlign(Align align);
+ TextStyle &setWeight(Weight weight);
const std::string &getColor() const;
int getSize() const;
- TextAlign getAlign() const;
+ Align getAlign() const;
+ Weight getWeight() const;
private:
+ Weight m_Weight;
std::string m_Color;
- TextAlign m_Align;
+ Align m_Align;
int m_Size;
};
std::string make(const std::string &text,
int size = TextStyle::defaultFontSize,
const std::string &color = TextStyle::defaultColor,
- TextAlign align = TextAlign::None);
+ TextStyle::Align align = TextStyle::Align::None,
+ TextStyle::Weight weight = TextStyle::Weight::None);
std::string makePlainText(const std::string &text);
/**
namespace
{
- const char *alignAsString(TextAlign align)
+ const char *alignAsString(TextStyle::Align align)
{
switch (align)
{
- case TextAlign::Center:
+ case TextStyle::Align::Center:
return "center";
- case TextAlign::Left:
+ case TextStyle::Align::Left:
return "left";
- case TextAlign::Right:
+ case TextStyle::Align::Right:
return "right";
- case TextAlign::None:
+ case TextStyle::Align::None:
+ default:
+ break;
+ }
+
+ assert(false);
+ return "";
+ }
+
+ const char *weightAsString(TextStyle::Weight wight)
+ {
+ switch (wight)
+ {
+ case TextStyle::Weight::Bold:
+ return "bold";
+ case TextStyle::Weight::None:
default:
break;
}
}
TextStyle::TextStyle()
- : m_Color(defaultColor)
- , m_Align(TextAlign::None)
+ : m_Weight(Weight::None)
+ , m_Color(defaultColor)
+ , m_Align(Align::None)
, m_Size(defaultFontSize)
{
}
-TextStyle::TextStyle(int size, const std::string &color, TextAlign align)
- : m_Color(color)
+TextStyle::TextStyle(int size, const std::string &color, Align align)
+ : m_Weight(Weight::None)
+ , m_Color(color)
, m_Align(align)
, m_Size(size)
{
{
}
-void TextStyle::setColor(const std::string &color)
+TextStyle &TextStyle::setColor(const std::string &color)
{
m_Color = color;
+ return *this;
}
-void TextStyle::setSize(int size)
+TextStyle &TextStyle::setSize(int size)
{
m_Size = size;
+ return *this;
}
-void TextStyle::setAlign(TextAlign align)
+TextStyle &TextStyle::setAlign(Align align)
{
m_Align = align;
+ return *this;
+}
+
+TextStyle &TextStyle::setWeight(Weight weight)
+{
+ m_Weight = weight;
+ return *this;
}
const std::string &TextStyle::getColor() const
return m_Size;
}
-TextAlign TextStyle::getAlign() const
+TextStyle::Align TextStyle::getAlign() const
{
return m_Align;
}
+TextStyle::Weight TextStyle::getWeight() const
+{
+ return m_Weight;
+}
+
namespace Msg {
namespace TextDecorator {
std::string make(const std::string &text, const TextStyle &style)
{
- return make(text, style.getSize(), style.getColor(), style.getAlign());
+ return make(text, style.getSize(), style.getColor(), style.getAlign(), style.getWeight());
}
std::string make(const std::string &text, const std::string &color)
std::string make(const std::string &text,
int size,
const std::string &color,
- TextAlign align)
+ TextStyle::Align align,
+ TextStyle::Weight weight)
{
std::ostringstream ss;
- ss << OPEN_TAG("font_size", size) << OPEN_TAG("color", color);
- if (align != TextAlign::None)
- {
+ bool isAlign = align != TextStyle::Align::None;
+ bool isWeight = weight != TextStyle::Weight::None;
+
+ ss << OPEN_TAG("font_size", size);
+ ss << OPEN_TAG("color", color);
+
+ if (isAlign)
ss << OPEN_TAG("align", alignAsString(align));
- }
+
+ if (isWeight)
+ ss << OPEN_TAG("font_weight", weightAsString(weight));
+
ss << text;
- if (align != TextAlign::None)
- {
+ if (isAlign)
ss << CLOSE_TAG("align");
- }
- ss << CLOSE_TAG("color") << CLOSE_TAG("font_size");
+ if (isWeight)
+ ss << CLOSE_TAG("font_weight");
+
+ ss << CLOSE_TAG("color");
+ ss << CLOSE_TAG("font_size");
return ss.str();
}
inline void View::setText(Evas_Object *obj, const std::string &text, const char *part)
{
- setText(obj, part, text.c_str());
+ setText(obj, text.c_str(), part);
}
inline void View::setText(Evas_Object *obj, const char *text, const char *part)
class PaddingListViewItem;
class ConvReplyListItem;
class IConvListListener;
+ class ConvTitleListItem;
class ConvList
: public ListView
void onListItemChecked(ListItem &listItem) override;
void fillList();
+ void updateTitle();
MsgStorage &getMsgStorage();
void insertItem(const MsgConversationItem &item);
IConvListListener *m_pListener;
PaddingListViewItem *m_pBottomPadItem;
ConvReplyListItem *m_pReplyItem;
+ ConvTitleListItem *m_pConvTitleItem;
WorkingDirRef m_WorkingDir;
BubbleEntityFactory m_BubbleEntityFactory;
ConvListItemMap m_ConvListItemMap;
#include "Window.h"
#include "ConvReplyListItem.h"
#include "PaddingListViewItem.h"
+#include "ConvTitleListItem.h"
using namespace Msg;
, m_pListener(nullptr)
, m_pBottomPadItem(nullptr)
, m_pReplyItem(nullptr)
+ , m_pConvTitleItem(nullptr)
, m_WorkingDir(workingDir)
, m_BubbleEntityFactory(m_WorkingDir)
{
return App::getInst().getMsgEngine().getStorage();
}
+void ConvList::updateTitle()
+{
+ MsgAddressListRef list = getMsgStorage().getAddressList(m_ThreadId);
+ if (list && !list->isEmpty() && m_pConvTitleItem) {
+ m_pConvTitleItem->setTitle(list->at(0).getAddress());
+ // TODO: Find address in contacts
+ }
+}
+
void ConvList::fillList()
{
clear();
+ // Recipient name:
+ m_pConvTitleItem = new ConvTitleListItem;
+ ListView::appendItem(*m_pConvTitleItem);
+
MsgConversationListRef convList = getMsgStorage().getConversationList(m_ThreadId);
int convListLen = convList->getLength();
if (m_ThreadId != id) {
m_ThreadId = id;
fillList();
+ updateTitle();
}
}
--- /dev/null
+/*
+ * Copyright 2016 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 ConvTitleListItem_h_
+#define ConvTitleListItem_h_
+
+#include "ListItem.h"
+
+namespace Msg {
+ class ConvTitleListItem
+ : public ListItem {
+ public:
+ ConvTitleListItem();
+
+ void setTitle(const std::string &title);
+
+ private:
+ Evas_Object *getContent(ListItem &item, const char *part) override;
+ Evas_Object *createLabel() const;
+
+ private:
+ std::string m_Title;
+ };
+}
+
+#endif /* ConvTitleListItem_h_ */
--- /dev/null
+/*
+ * Copyright 2016 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 "ConvTitleListItem.h"
+#include "ListView.h"
+#include "TextDecorator.h"
+
+using namespace Msg;
+
+const TextStyle titleTextStyle = TextStyle().
+ setSize(30).
+ setAlign(TextStyle::Align::Center).
+ setWeight(TextStyle::Weight::Bold).
+ setColor("#ffae0d");
+
+ConvTitleListItem::ConvTitleListItem()
+ : ListItem(ListItemStyle::create("conv_title"))
+{
+}
+
+void ConvTitleListItem::setTitle(const std::string &title)
+{
+ m_Title = TextDecorator::make(title, titleTextStyle);
+}
+
+Evas_Object *ConvTitleListItem::createLabel() const
+{
+ static const double slideDuration = 3.0;
+
+ Evas_Object *label = elm_label_add(*getOwner());
+ elm_object_focus_allow_set(label, false);
+ elm_object_style_set(label, "slide_roll");
+ elm_label_ellipsis_set(label, true);
+ elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_AUTO);
+ elm_label_slide_duration_set(label, slideDuration);
+ elm_label_slide_go(label);
+ View::setText(label, m_Title);
+ return label;
+}
+
+Evas_Object *ConvTitleListItem::getContent(ListItem &item, const char *part)
+{
+ return createLabel();
+}