M changelog.md => changelog.md +4 -0
@@ 11,6 11,10 @@
* `[desktop]` Fixed ScreenlockCheckEvent handler
+### Changed
+
+* `[messages]` Changed fonts of message snippet and its prefix.
+
## [0.47.1 2020-11-20]
### Added
M module-apps/application-messages/data/MessagesStyle.hpp => module-apps/application-messages/data/MessagesStyle.hpp +1 -0
@@ 31,6 31,7 @@ namespace style
inline constexpr uint32_t timestampWidth = 100;
inline constexpr uint32_t numberImportanceWidth = 80;
inline constexpr uint32_t numberImportanceLeftMargin = 10;
+ inline constexpr uint32_t snippetLeftMargin = 5;
inline constexpr uint32_t cotactWidthOffset = timestampWidth + leftMargin + rightMargin;
inline constexpr uint32_t notSentIconWidth = 20;
M module-apps/application-messages/widgets/BaseThreadItem.cpp => module-apps/application-messages/widgets/BaseThreadItem.cpp +43 -18
@@ 24,33 24,39 @@ namespace gui
setPenFocusWidth(window::default_border_focus_w);
setPenWidth(window::default_border_no_focus_w);
- contact = new gui::Label(this, 0, 0, 0, 0);
- contact->setPenFocusWidth(window::default_border_no_focus_w);
- contact->setPenWidth(window::default_border_no_focus_w);
+ contact = createEmptyLabel(this);
contact->setFont(style::window::font::big);
contact->setEllipsis(Ellipsis::Right);
contact->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
- numberImportance = new gui::Label(this, 0, 0, 0, 0);
- numberImportance->setPenFocusWidth(window::default_border_no_focus_w);
- numberImportance->setPenWidth(window::default_border_no_focus_w);
+ numberImportance = createEmptyLabel(this);
numberImportance->setFont(style::window::font::small);
numberImportance->setAlignment(
gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
- timestamp = new gui::Label(this, 0, 0, 0, 0);
- timestamp->setPenFocusWidth(window::default_border_no_focus_w);
- timestamp->setPenWidth(window::default_border_no_focus_w);
+ timestamp = createEmptyLabel(this);
timestamp->setFont(style::window::font::small);
timestamp->setEllipsis(Ellipsis::Right);
timestamp->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Right, gui::Alignment::Vertical::Center});
- preview = new gui::Label(this, 0, 0, 0, 0);
- preview->setPenFocusWidth(window::default_border_no_focus_w);
- preview->setPenWidth(window::default_border_no_focus_w);
- preview->setFont(style::window::font::small);
- preview->setEllipsis(Ellipsis::Right);
- preview->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
+ snippetPrefix = createEmptyLabel(this);
+ snippetPrefix->setFont(style::window::font::mediumlight);
+ snippetPrefix->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
+
+ snippet = createEmptyLabel(this);
+ snippet->setFont(style::window::font::medium);
+ snippet->setEllipsis(Ellipsis::Right);
+ snippet->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
+ }
+
+ gui::Label *BaseThreadItem::createEmptyLabel(Item *parent)
+ {
+ using namespace style;
+
+ auto label = new gui::Label(parent, 0, 0, 0, 0);
+ label->setPenFocusWidth(window::default_border_no_focus_w);
+ label->setPenWidth(window::default_border_no_focus_w);
+ return label;
}
void BaseThreadItem::onDimensionChangedTop(const BoundingBox & /*oldDim*/, const BoundingBox &newDim)
@@ 75,17 81,36 @@ namespace gui
void BaseThreadItem::onDimensionChangedBottom(const BoundingBox & /*oldDim*/, const BoundingBox &newDim)
{
+ resizeSnippet(newDim);
+ }
+
+ void BaseThreadItem::resizeSnippet(const BoundingBox &dimensions, unsigned int leftOffset)
+ {
namespace msgStyle = style::messages::threadItem;
- preview->setPosition(msgStyle::leftMargin, newDim.h / 2);
- preview->setSize(newDim.w - msgStyle::previewWidthOffset, newDim.h / 2 - msgStyle::bottomMargin);
+ const auto leftMargin = msgStyle::leftMargin + leftOffset;
+ if (const auto isPrefixSet = !snippetPrefix->getText().empty(); isPrefixSet) {
+ snippetPrefix->setPosition(leftMargin, dimensions.h / 2);
+ snippetPrefix->setSize(snippetPrefix->getTextNeedSpace(), dimensions.h / 2 - msgStyle::bottomMargin);
+
+ const auto prefixSpace = snippetPrefix->getTextWidth() + msgStyle::snippetLeftMargin;
+ snippet->setPosition(leftMargin + prefixSpace, dimensions.h / 2);
+ snippet->setSize(dimensions.w - msgStyle::previewWidthOffset - prefixSpace - leftOffset,
+ dimensions.h / 2 - msgStyle::bottomMargin);
+ }
+ else {
+ snippetPrefix->setPosition(0, 0);
+ snippetPrefix->setSize(0, 0);
+ snippet->setPosition(leftMargin, dimensions.h / 2);
+ snippet->setSize(dimensions.w - msgStyle::previewWidthOffset - leftOffset,
+ dimensions.h / 2 - msgStyle::bottomMargin);
+ }
}
bool BaseThreadItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
{
onDimensionChangedTop(oldDim, newDim);
onDimensionChangedBottom(oldDim, newDim);
-
return true;
}
M module-apps/application-messages/widgets/BaseThreadItem.hpp => module-apps/application-messages/widgets/BaseThreadItem.hpp +5 -1
@@ 16,10 16,14 @@ namespace gui
gui::Label *contact = nullptr;
gui::Label *numberImportance = nullptr;
gui::Label *timestamp = nullptr;
- gui::Label *preview = nullptr;
+ gui::Label *snippetPrefix = nullptr;
+ gui::Label *snippet = nullptr;
+
+ static gui::Label *createEmptyLabel(Item *parent);
virtual void onDimensionChangedTop(const BoundingBox &oldDim, const BoundingBox &newDim);
virtual void onDimensionChangedBottom(const BoundingBox &oldDim, const BoundingBox &newDim);
+ void resizeSnippet(const BoundingBox &dimensions, unsigned int leftOffset = 0U);
void displayNumberImportance(long int importance);
M module-apps/application-messages/widgets/SearchResultsItem.cpp => module-apps/application-messages/widgets/SearchResultsItem.cpp +2 -2
@@ 19,8 19,8 @@ namespace gui
}
void SearchResultsItem::setPreview(const UTF8 &text)
{
- if (preview != nullptr) {
- preview->setText(text);
+ if (snippet != nullptr) {
+ snippet->setText(text);
}
}
M module-apps/application-messages/widgets/ThreadItem.cpp => module-apps/application-messages/widgets/ThreadItem.cpp +6 -10
@@ 28,22 28,21 @@ namespace gui
void ThreadItem::setPreview()
{
- UTF8 prefix;
switch (threadStruct->thread->type) {
case SMSType::DRAFT:
- prefix = utils::localize.get("app_messages_thread_draft");
+ snippetPrefix->setText(utils::localize.get("app_messages_thread_draft"));
break;
case SMSType::FAILED:
- prefix = utils::localize.get("app_messages_thread_not_sent");
+ snippetPrefix->setText(utils::localize.get("app_messages_thread_not_sent"));
break;
case SMSType::OUTBOX:
case SMSType::QUEUED:
- prefix = utils::localize.get("app_messages_thread_you");
+ snippetPrefix->setText(utils::localize.get("app_messages_thread_you"));
break;
default:
break;
}
- preview->setText(prefix + threadStruct->thread->snippet);
+ snippet->setText(threadStruct->thread->snippet);
}
void ThreadItem::setThreadItem(std::shared_ptr<ThreadListStruct> _threadStruct)
@@ 93,12 92,9 @@ namespace gui
namespace msgStyle = style::messages::threadItem;
const auto indicatorWidth = indicator->getSize(gui::Axis::X) + 6;
- preview->setPosition(msgStyle::leftMargin + indicatorWidth, newDim.h / 2);
- preview->setSize(newDim.w - msgStyle::previewWidthOffset - indicatorWidth,
- newDim.h / 2 - msgStyle::bottomMargin);
-
+ resizeSnippet(newDim, indicatorWidth);
indicator->setPosition(msgStyle::leftMargin,
- newDim.h / 2 + preview->getSize(gui::Axis::Y) / 2 -
+ newDim.h / 2 + snippet->getSize(gui::Axis::Y) / 2 -
indicator->getSize(gui::Axis::Y) / 2); // align with text
}