mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Limit attached emoji phrase to two lines.
This commit is contained in:
@@ -1267,6 +1267,7 @@ void AddEmojiPacksAction(
|
||||
, _dummyAction(new QAction(parent)) {
|
||||
enableMouseSelecting();
|
||||
_text->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
updateMinWidth();
|
||||
parent->widthValue() | rpl::start_with_next([=](int width) {
|
||||
const auto top = st::historyHasCustomEmojiPosition.y();
|
||||
const auto skip = st::historyHasCustomEmojiPosition.x();
|
||||
@@ -1297,6 +1298,28 @@ void AddEmojiPacksAction(
|
||||
RippleButton::paintRipple(p, 0, 0);
|
||||
}
|
||||
|
||||
void updateMinWidth() {
|
||||
const auto skip = st::historyHasCustomEmojiPosition.x();
|
||||
auto min = _text->naturalWidth() / 2;
|
||||
auto max = _text->naturalWidth() - skip;
|
||||
_text->resizeToWidth(max);
|
||||
const auto height = _text->height();
|
||||
_text->resizeToWidth(min);
|
||||
const auto heightMax = _text->height();
|
||||
if (heightMax > height) {
|
||||
while (min + 1 < max) {
|
||||
const auto middle = (max + min) / 2;
|
||||
_text->resizeToWidth(middle);
|
||||
if (_text->height() > height) {
|
||||
min = middle;
|
||||
} else {
|
||||
max = middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
setMinWidth(skip * 2 + max);
|
||||
}
|
||||
|
||||
const style::Menu &_st;
|
||||
const base::unique_qptr<Ui::FlatLabel> _text;
|
||||
const not_null<QAction*> _dummyAction;
|
||||
|
||||
@@ -1090,9 +1090,9 @@ msgServiceGiftBoxStickerSize: size(140px, 140px);
|
||||
|
||||
historyHasCustomEmoji: FlatLabel(defaultFlatLabel) {
|
||||
style: TextStyle(defaultTextStyle) {
|
||||
font: font(12px);
|
||||
linkFont: font(12px underline);
|
||||
linkFontOver: font(12px underline);
|
||||
font: font(11px);
|
||||
linkFont: font(11px underline);
|
||||
linkFontOver: font(11px underline);
|
||||
}
|
||||
minWidth: 80px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user