Add setting to make baloons adaptive (#1)
This commit is contained in:
parent
82e8d064ea
commit
68345bd044
21 changed files with 169 additions and 26 deletions
|
|
@ -2263,6 +2263,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ktg_settings_kotato" = "Kotatogram Settings";
|
||||
"ktg_settings_chats" = "Chats";
|
||||
"ktg_settings_sticker_height" = "Sticker height: {pixels}px";
|
||||
"ktg_settings_adaptive_baloons" = "Adaptive baloons";
|
||||
"ktg_settings_emoji_outline" = "Big emoji outline";
|
||||
"ktg_settings_always_show_scheduled" = "Always show scheduled";
|
||||
"ktg_settings_fonts" = "Change application fonts";
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
"ktg_settings_kotato": "Настройки Kotatogram",
|
||||
"ktg_settings_chats": "Чаты",
|
||||
"ktg_settings_sticker_height": "Высота стикеров: {pixels} пикс.",
|
||||
"ktg_settings_adaptive_baloons": "Адаптивные пузырьки сообщений",
|
||||
"ktg_settings_emoji_outline": "Обводка у больших эмодзи",
|
||||
"ktg_settings_always_show_scheduled": "Всегда показывать отложенные",
|
||||
"ktg_settings_fonts": "Изменить шрифты приложения",
|
||||
|
|
|
|||
|
|
@ -152,6 +152,11 @@ bool Manager::readCustomFile() {
|
|||
}
|
||||
}
|
||||
|
||||
const auto settingsAdaptiveBaloonsIt = settings.constFind(qsl("adaptive_baloons"));
|
||||
if (settingsAdaptiveBaloonsIt != settings.constEnd() && (*settingsAdaptiveBaloonsIt).isBool()) {
|
||||
cSetAdaptiveBaloons((*settingsAdaptiveBaloonsIt).toBool());
|
||||
}
|
||||
|
||||
const auto settingsBigEmojiOutlineIt = settings.constFind(qsl("big_emoji_outline"));
|
||||
if (settingsBigEmojiOutlineIt != settings.constEnd() && (*settingsBigEmojiOutlineIt).isBool()) {
|
||||
SetBigEmojiOutline((*settingsBigEmojiOutlineIt).toBool());
|
||||
|
|
@ -235,6 +240,7 @@ void Manager::writeDefaultFile() {
|
|||
settings.insert(qsl("fonts"), settingsFonts);
|
||||
|
||||
settings.insert(qsl("sticker_height"), StickerHeight());
|
||||
settings.insert(qsl("adaptive_baloons"), cAdaptiveBaloons());
|
||||
settings.insert(qsl("big_emoji_outline"), BigEmojiOutline());
|
||||
settings.insert(qsl("always_show_scheduled"), cAlwaysShowScheduled());
|
||||
settings.insert(qsl("show_chat_id"), cShowChatId());
|
||||
|
|
@ -286,6 +292,7 @@ void Manager::writeCurrentSettings() {
|
|||
settings.insert(qsl("fonts"), settingsFonts);
|
||||
|
||||
settings.insert(qsl("sticker_height"), StickerHeight());
|
||||
settings.insert(qsl("adaptive_baloons"), cAdaptiveBaloons());
|
||||
settings.insert(qsl("big_emoji_outline"), BigEmojiOutline());
|
||||
settings.insert(qsl("always_show_scheduled"), cAlwaysShowScheduled());
|
||||
settings.insert(qsl("show_chat_id"), cShowChatId());
|
||||
|
|
|
|||
|
|
@ -2038,7 +2038,7 @@ void HistoryInner::recountHistoryGeometry() {
|
|||
updateBotInfo(false);
|
||||
if (_botAbout && !_botAbout->info->text.isEmpty()) {
|
||||
int32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right();
|
||||
if (tw > st::msgMaxWidth) tw = st::msgMaxWidth;
|
||||
if (!cAdaptiveBaloons() && tw > st::msgMaxWidth) tw = st::msgMaxWidth;
|
||||
tw -= st::msgPadding.left() + st::msgPadding.right();
|
||||
int32 mw = qMax(_botAbout->info->text.maxWidth(), st::msgNameFont->width(tr::lng_bot_description(tr::now)));
|
||||
if (tw > mw) tw = mw;
|
||||
|
|
@ -2048,7 +2048,7 @@ void HistoryInner::recountHistoryGeometry() {
|
|||
|
||||
int32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom();
|
||||
int32 descMaxWidth = _scroll->width();
|
||||
if (Adaptive::ChatWide()) {
|
||||
if (Adaptive::ChatWide() && !cAdaptiveBaloons()) {
|
||||
descMaxWidth = qMin(descMaxWidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
|
||||
}
|
||||
int32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left();
|
||||
|
|
@ -2085,7 +2085,7 @@ void HistoryInner::updateBotInfo(bool recount) {
|
|||
Ui::ItemTextBotNoMonoOptions());
|
||||
if (recount) {
|
||||
int32 tw = _scroll->width() - st::msgMargin.left() - st::msgMargin.right();
|
||||
if (tw > st::msgMaxWidth) tw = st::msgMaxWidth;
|
||||
if (!cAdaptiveBaloons() && tw > st::msgMaxWidth) tw = st::msgMaxWidth;
|
||||
tw -= st::msgPadding.left() + st::msgPadding.right();
|
||||
int32 mw = qMax(_botAbout->info->text.maxWidth(), st::msgNameFont->width(tr::lng_bot_description(tr::now)));
|
||||
if (tw > mw) tw = mw;
|
||||
|
|
@ -2240,7 +2240,7 @@ void HistoryInner::updateSize() {
|
|||
if (_botAbout && _botAbout->height > 0) {
|
||||
int32 descH = st::msgMargin.top() + st::msgPadding.top() + st::msgNameFont->height + st::botDescSkip + _botAbout->height + st::msgPadding.bottom() + st::msgMargin.bottom();
|
||||
int32 descMaxWidth = _scroll->width();
|
||||
if (Adaptive::ChatWide()) {
|
||||
if (Adaptive::ChatWide() && !cAdaptiveBaloons()) {
|
||||
descMaxWidth = qMin(descMaxWidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
|
||||
}
|
||||
int32 descAtX = (descMaxWidth - _botAbout->width) / 2 - st::msgPadding.left();
|
||||
|
|
@ -2566,7 +2566,7 @@ void HistoryInner::mouseActionUpdate() {
|
|||
dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
|
||||
auto dateLeft = st::msgServiceMargin.left();
|
||||
auto maxwidth = _contentWidth;
|
||||
if (Adaptive::ChatWide()) {
|
||||
if (Adaptive::ChatWide() && !cAdaptiveBaloons()) {
|
||||
maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
|
||||
}
|
||||
auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ void UnreadBar::paint(Painter &p, int y, int w) const {
|
|||
|
||||
int left = st::msgServiceMargin.left();
|
||||
int maxwidth = w;
|
||||
if (Adaptive::ChatWide()) {
|
||||
if (Adaptive::ChatWide() && !cAdaptiveBaloons()) {
|
||||
maxwidth = qMin(
|
||||
maxwidth,
|
||||
st::msgMaxWidth
|
||||
|
|
@ -315,6 +315,10 @@ int Element::infoWidth() const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Element::plainMaxWidth() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Element::isHiddenByGroup() const {
|
||||
return _flags & Flag::HiddenByGroup;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ public:
|
|||
int skipBlockHeight() const;
|
||||
QString skipBlock() const;
|
||||
virtual int infoWidth() const;
|
||||
virtual int plainMaxWidth() const;
|
||||
|
||||
bool isHiddenByGroup() const;
|
||||
virtual bool isHidden() const;
|
||||
|
|
|
|||
|
|
@ -2151,7 +2151,7 @@ void ListWidget::mouseActionUpdate() {
|
|||
dateWidth += st::msgServicePadding.left() + st::msgServicePadding.right();
|
||||
auto dateLeft = st::msgServiceMargin.left();
|
||||
auto maxwidth = view->width();
|
||||
if (Adaptive::ChatWide()) {
|
||||
if (Adaptive::ChatWide() && !cAdaptiveBaloons()) {
|
||||
maxwidth = qMin(maxwidth, int32(st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
|
||||
}
|
||||
auto widthForDate = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
|
||||
|
|
|
|||
|
|
@ -1616,7 +1616,9 @@ QRect Message::countGeometry() const {
|
|||
// contentLeft += st::msgPhotoSkip - (hmaxwidth - hwidth);
|
||||
}
|
||||
accumulate_min(contentWidth, maxWidth());
|
||||
accumulate_min(contentWidth, st::msgMaxWidth);
|
||||
if (!cAdaptiveBaloons()) {
|
||||
accumulate_min(contentWidth, st::msgMaxWidth);
|
||||
}
|
||||
if (mediaWidth < contentWidth) {
|
||||
const auto textualWidth = plainMaxWidth();
|
||||
if (mediaWidth < textualWidth
|
||||
|
|
@ -1658,7 +1660,9 @@ int Message::resizeContentGetHeight(int newWidth) {
|
|||
contentWidth -= st::msgPhotoSkip;
|
||||
}
|
||||
accumulate_min(contentWidth, maxWidth());
|
||||
accumulate_min(contentWidth, st::msgMaxWidth);
|
||||
if (!cAdaptiveBaloons()) {
|
||||
accumulate_min(contentWidth, st::msgMaxWidth);
|
||||
}
|
||||
if (mediaDisplayed) {
|
||||
media->resizeGetHeight(contentWidth);
|
||||
if (media->width() < contentWidth) {
|
||||
|
|
@ -1681,7 +1685,7 @@ int Message::resizeContentGetHeight(int newWidth) {
|
|||
auto mediaOnBottom = (mediaDisplayed && media->isBubbleBottom()) || (entry/* && entry->isBubbleBottom()*/);
|
||||
auto mediaOnTop = (mediaDisplayed && media->isBubbleTop()) || (entry && entry->isBubbleTop());
|
||||
|
||||
if (contentWidth == maxWidth()) {
|
||||
if (!cAdaptiveBaloons() && contentWidth == maxWidth()) {
|
||||
if (mediaDisplayed) {
|
||||
if (entry) {
|
||||
newHeight += entry->resizeGetHeight(contentWidth);
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ public:
|
|||
bool displayEditedBadge() const override;
|
||||
TimeId displayedEditDate() const override;
|
||||
int infoWidth() const override;
|
||||
int plainMaxWidth() const override;
|
||||
|
||||
protected:
|
||||
void refreshDataIdHook() override;
|
||||
|
|
@ -146,7 +147,6 @@ private:
|
|||
HistoryMessageEdited *displayedEditBadge();
|
||||
void initTime();
|
||||
int timeLeft() const;
|
||||
int plainMaxWidth() const;
|
||||
|
||||
WebPage *logEntryOriginal() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ void paintBubblePart(Painter &p, int x, int y, int width, int height, SideStyle
|
|||
void paintPreparedDate(Painter &p, const QString &dateText, int dateTextWidth, int y, int w) {
|
||||
int left = st::msgServiceMargin.left();
|
||||
int maxwidth = w;
|
||||
if (Adaptive::ChatWide()) {
|
||||
if (Adaptive::ChatWide() && !cAdaptiveBaloons()) {
|
||||
maxwidth = qMin(maxwidth, WideChatWidth());
|
||||
}
|
||||
w = maxwidth - st::msgServiceMargin.left() - st::msgServiceMargin.left();
|
||||
|
|
@ -315,7 +315,7 @@ not_null<HistoryService*> Service::message() const {
|
|||
|
||||
QRect Service::countGeometry() const {
|
||||
auto result = QRect(0, 0, width(), height());
|
||||
if (Adaptive::ChatWide()) {
|
||||
if (Adaptive::ChatWide() && !cAdaptiveBaloons()) {
|
||||
result.setWidth(qMin(result.width(), st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left()));
|
||||
}
|
||||
return result.marginsRemoved(st::msgServiceMargin);
|
||||
|
|
@ -338,7 +338,7 @@ QSize Service::performCountCurrentSize(int newWidth) {
|
|||
item->_textHeight = 0;
|
||||
} else {
|
||||
auto contentWidth = newWidth;
|
||||
if (Adaptive::ChatWide()) {
|
||||
if (Adaptive::ChatWide() && !cAdaptiveBaloons()) {
|
||||
accumulate_min(contentWidth, st::msgMaxWidth + 2 * st::msgPhotoSkip + 2 * st::msgMargin.left());
|
||||
}
|
||||
contentWidth -= st::msgServiceMargin.left() + st::msgServiceMargin.left(); // two small margins
|
||||
|
|
|
|||
|
|
@ -150,7 +150,11 @@ QSize Document::countOptimalSize() {
|
|||
|
||||
if (auto named = Get<HistoryDocumentNamed>()) {
|
||||
accumulate_max(maxWidth, tleft + named->_namew + tright);
|
||||
accumulate_min(maxWidth, st::msgMaxWidth);
|
||||
if (cAdaptiveBaloons() && captioned) {
|
||||
accumulate_max(maxWidth, captioned->_caption.maxWidth() + st::msgPadding.left() + st::msgPadding.right());
|
||||
} else {
|
||||
accumulate_min(maxWidth, st::msgMaxWidth);
|
||||
}
|
||||
}
|
||||
|
||||
auto minHeight = 0;
|
||||
|
|
|
|||
|
|
@ -74,15 +74,21 @@ QSize Gif::countOptimalSize() {
|
|||
setClipReader(::Media::Clip::ReaderPointer::Bad());
|
||||
}
|
||||
|
||||
const auto captionWithPaddings = _caption.maxWidth()
|
||||
+ st::msgPadding.left()
|
||||
+ st::msgPadding.right();
|
||||
const auto maxSize = _data->isVideoMessage()
|
||||
? st::maxVideoMessageSize
|
||||
: st::maxGifSize;
|
||||
const auto size = style::ConvertScale(videoSize());
|
||||
auto tw = size.width();
|
||||
auto th = size.height();
|
||||
if (tw > maxSize) {
|
||||
if ((!cAdaptiveBaloons() || captionWithPaddings <= maxSize) && tw > maxSize) {
|
||||
th = (maxSize * th) / tw;
|
||||
tw = maxSize;
|
||||
} else if (cAdaptiveBaloons() && captionWithPaddings > maxSize && tw > captionWithPaddings) {
|
||||
th = (captionWithPaddings * th) / tw;
|
||||
tw = captionWithPaddings;
|
||||
}
|
||||
if (th > maxSize) {
|
||||
tw = (maxSize * tw) / th;
|
||||
|
|
@ -101,6 +107,9 @@ QSize Gif::countOptimalSize() {
|
|||
}
|
||||
if (_parent->hasBubble()) {
|
||||
if (!_caption.isEmpty()) {
|
||||
if (cAdaptiveBaloons()) {
|
||||
accumulate_max(maxWidth, captionWithPaddings);
|
||||
}
|
||||
auto captionw = maxWidth - st::msgPadding.left() - st::msgPadding.right();
|
||||
minHeight += st::mediaCaptionSkip + _caption.countHeight(captionw);
|
||||
if (isBubbleBottom()) {
|
||||
|
|
@ -123,15 +132,21 @@ QSize Gif::countOptimalSize() {
|
|||
QSize Gif::countCurrentSize(int newWidth) {
|
||||
auto availableWidth = newWidth;
|
||||
|
||||
const auto captionWithPaddings = _caption.maxWidth()
|
||||
+ st::msgPadding.left()
|
||||
+ st::msgPadding.right();
|
||||
const auto maxSize = _data->isVideoMessage()
|
||||
? st::maxVideoMessageSize
|
||||
: st::maxGifSize;
|
||||
const auto size = style::ConvertScale(videoSize());
|
||||
auto tw = size.width();
|
||||
auto th = size.height();
|
||||
if (tw > maxSize) {
|
||||
if ((!cAdaptiveBaloons() || captionWithPaddings <= maxSize) && tw > maxSize) {
|
||||
th = (maxSize * th) / tw;
|
||||
tw = maxSize;
|
||||
} else if (cAdaptiveBaloons() && captionWithPaddings > maxSize && tw > captionWithPaddings) {
|
||||
th = (captionWithPaddings * th) / tw;
|
||||
tw = captionWithPaddings;
|
||||
}
|
||||
if (th > maxSize) {
|
||||
tw = (maxSize * tw) / th;
|
||||
|
|
@ -183,6 +198,10 @@ QSize Gif::countCurrentSize(int newWidth) {
|
|||
}
|
||||
if (_parent->hasBubble()) {
|
||||
if (!_caption.isEmpty()) {
|
||||
if (cAdaptiveBaloons()) {
|
||||
accumulate_max(newWidth, captionWithPaddings);
|
||||
accumulate_min(newWidth, availableWidth);
|
||||
}
|
||||
auto captionw = newWidth - st::msgPadding.left() - st::msgPadding.right();
|
||||
newHeight += st::mediaCaptionSkip + _caption.countHeight(captionw);
|
||||
if (isBubbleBottom()) {
|
||||
|
|
|
|||
|
|
@ -61,9 +61,15 @@ QSize Location::countOptimalSize() {
|
|||
|
||||
if (_parent->hasBubble()) {
|
||||
if (!_title.isEmpty()) {
|
||||
if (cAdaptiveBaloons()) {
|
||||
maxWidth = qMax(maxWidth, _title.maxWidth() + st::msgPadding.left() + st::msgPadding.right());
|
||||
}
|
||||
minHeight += qMin(_title.countHeight(maxWidth - st::msgPadding.left() - st::msgPadding.right()), 2 * st::webPageTitleFont->height);
|
||||
}
|
||||
if (!_description.isEmpty()) {
|
||||
if (cAdaptiveBaloons()) {
|
||||
maxWidth = qMax(maxWidth, _description.maxWidth() + st::msgPadding.left() + st::msgPadding.right());
|
||||
}
|
||||
minHeight += qMin(_description.countHeight(maxWidth - st::msgPadding.left() - st::msgPadding.right()), 3 * st::webPageDescriptionFont->height);
|
||||
}
|
||||
if (!_title.isEmpty() || !_description.isEmpty()) {
|
||||
|
|
@ -88,8 +94,10 @@ QSize Location::countCurrentSize(int newWidth) {
|
|||
auto newHeight = th;
|
||||
if (tw > newWidth) {
|
||||
newHeight = (newWidth * newHeight / tw);
|
||||
} else {
|
||||
} else if (!cAdaptiveBaloons()) {
|
||||
newWidth = tw;
|
||||
} else {
|
||||
newHeight = (newWidth * newHeight / tw);
|
||||
}
|
||||
auto minWidth = qMax(st::minPhotoSize, _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x()));
|
||||
accumulate_max(newWidth, minWidth);
|
||||
|
|
|
|||
|
|
@ -76,9 +76,17 @@ QSize GroupedMedia::countOptimalSize() {
|
|||
sizes.push_back(media->sizeForGrouping());
|
||||
}
|
||||
|
||||
const auto captionWithPaddings = _caption.maxWidth()
|
||||
+ st::msgPadding.left()
|
||||
+ st::msgPadding.right();
|
||||
auto groupMaxWidth = st::historyGroupWidthMax;
|
||||
if (cAdaptiveBaloons()) {
|
||||
accumulate_max(groupMaxWidth, captionWithPaddings);
|
||||
}
|
||||
|
||||
const auto layout = Ui::LayoutMediaGroup(
|
||||
sizes,
|
||||
st::historyGroupWidthMax,
|
||||
groupMaxWidth,
|
||||
st::historyGroupWidthMin,
|
||||
st::historyGroupSkip);
|
||||
Assert(layout.size() == _parts.size());
|
||||
|
|
@ -94,6 +102,9 @@ QSize GroupedMedia::countOptimalSize() {
|
|||
}
|
||||
|
||||
if (!_caption.isEmpty()) {
|
||||
if (cAdaptiveBaloons()) {
|
||||
maxWidth = qMax(maxWidth, captionWithPaddings);
|
||||
}
|
||||
auto captionw = maxWidth - st::msgPadding.left() - st::msgPadding.right();
|
||||
minHeight += st::mediaCaptionSkip + _caption.countHeight(captionw);
|
||||
if (isBubbleBottom()) {
|
||||
|
|
|
|||
|
|
@ -71,14 +71,21 @@ QSize Photo::countOptimalSize() {
|
|||
auto maxWidth = 0;
|
||||
auto minHeight = 0;
|
||||
|
||||
const auto captionWithPaddings = _caption.maxWidth()
|
||||
+ st::msgPadding.left()
|
||||
+ st::msgPadding.right();
|
||||
auto inWebPage = (_parent->media() != this);
|
||||
auto tw = style::ConvertScale(_data->width());
|
||||
auto th = style::ConvertScale(_data->height());
|
||||
if (!tw || !th) {
|
||||
tw = th = 1;
|
||||
}
|
||||
if (tw > st::maxMediaSize) {
|
||||
if ((!cAdaptiveBaloons() || (captionWithPaddings <= st::maxMediaSize && !inWebPage)) && tw > st::maxMediaSize) {
|
||||
th = (st::maxMediaSize * th) / tw;
|
||||
tw = st::maxMediaSize;
|
||||
} else if (cAdaptiveBaloons() && captionWithPaddings > st::maxMediaSize && tw > captionWithPaddings) {
|
||||
th = (captionWithPaddings * th) / tw;
|
||||
tw = captionWithPaddings;
|
||||
}
|
||||
if (th > st::maxMediaSize) {
|
||||
tw = (st::maxMediaSize * tw) / th;
|
||||
|
|
@ -89,10 +96,14 @@ QSize Photo::countOptimalSize() {
|
|||
return { _serviceWidth, _serviceWidth };
|
||||
}
|
||||
const auto minWidth = qMax((_parent->hasBubble() ? st::historyPhotoBubbleMinWidth : st::minPhotoSize), _parent->infoWidth() + 2 * (st::msgDateImgDelta + st::msgDateImgPadding.x()));
|
||||
const auto maxActualWidth = qMax(tw, minWidth);
|
||||
auto maxActualWidth = qMax(tw, minWidth);
|
||||
maxWidth = qMax(maxActualWidth, th);
|
||||
minHeight = qMax(th, st::minPhotoSize);
|
||||
if (_parent->hasBubble() && !_caption.isEmpty()) {
|
||||
if (cAdaptiveBaloons()) {
|
||||
maxActualWidth = qMax(maxActualWidth, captionWithPaddings);
|
||||
maxWidth = qMax(maxWidth, captionWithPaddings);
|
||||
}
|
||||
auto captionw = maxActualWidth - st::msgPadding.left() - st::msgPadding.right();
|
||||
minHeight += st::mediaCaptionSkip + _caption.countHeight(captionw);
|
||||
if (isBubbleBottom()) {
|
||||
|
|
@ -103,11 +114,20 @@ QSize Photo::countOptimalSize() {
|
|||
}
|
||||
|
||||
QSize Photo::countCurrentSize(int newWidth) {
|
||||
auto availableWidth = newWidth;
|
||||
|
||||
const auto captionWithPaddings = _caption.maxWidth()
|
||||
+ st::msgPadding.left()
|
||||
+ st::msgPadding.right();
|
||||
auto inWebPage = (_parent->media() != this);
|
||||
auto tw = style::ConvertScale(_data->width());
|
||||
auto th = style::ConvertScale(_data->height());
|
||||
if (tw > st::maxMediaSize) {
|
||||
if ((!cAdaptiveBaloons() || (captionWithPaddings <= st::maxMediaSize && !inWebPage)) && tw > st::maxMediaSize) {
|
||||
th = (st::maxMediaSize * th) / tw;
|
||||
tw = st::maxMediaSize;
|
||||
} else if (cAdaptiveBaloons() && captionWithPaddings > st::maxMediaSize && tw > captionWithPaddings) {
|
||||
th = (captionWithPaddings * th) / tw;
|
||||
tw = captionWithPaddings;
|
||||
}
|
||||
if (th > st::maxMediaSize) {
|
||||
tw = (st::maxMediaSize * tw) / th;
|
||||
|
|
@ -132,6 +152,10 @@ QSize Photo::countCurrentSize(int newWidth) {
|
|||
newWidth = qMax(_pixw, minWidth);
|
||||
auto newHeight = qMax(_pixh, st::minPhotoSize);
|
||||
if (_parent->hasBubble() && !_caption.isEmpty()) {
|
||||
if (cAdaptiveBaloons()) {
|
||||
newWidth = qMax(newWidth, captionWithPaddings);
|
||||
newWidth = qMin(newWidth, availableWidth);
|
||||
}
|
||||
const auto captionw = newWidth
|
||||
- st::msgPadding.left()
|
||||
- st::msgPadding.right();
|
||||
|
|
|
|||
|
|
@ -58,15 +58,22 @@ QSize Video::sizeForAspectRatio() const {
|
|||
}
|
||||
|
||||
QSize Video::countOptimalDimensions() const {
|
||||
const auto captionWithPaddings = _caption.maxWidth()
|
||||
+ st::msgPadding.left()
|
||||
+ st::msgPadding.right();
|
||||
auto inWebPage = (_parent->media() != this);
|
||||
const auto desired = style::ConvertScale(_data->dimensions);
|
||||
const auto size = desired.isEmpty() ? sizeForAspectRatio() : desired;
|
||||
auto tw = size.width();
|
||||
auto th = size.height();
|
||||
if (!tw || !th) {
|
||||
tw = th = 1;
|
||||
} else if (tw >= th && tw > st::maxMediaSize) {
|
||||
} else if ((!cAdaptiveBaloons() || (captionWithPaddings <= st::maxMediaSize && !inWebPage)) && tw >= th && tw > st::maxMediaSize) {
|
||||
th = qRound((st::maxMediaSize / float64(tw)) * th);
|
||||
tw = st::maxMediaSize;
|
||||
} else if (cAdaptiveBaloons() && tw >= th && captionWithPaddings > st::maxMediaSize && tw > captionWithPaddings) {
|
||||
th = qRound((captionWithPaddings / float64(tw)) * th);
|
||||
tw = captionWithPaddings;
|
||||
} else if (tw < th && th > st::maxMediaSize) {
|
||||
tw = qRound((st::maxMediaSize / float64(th)) * tw);
|
||||
th = st::maxMediaSize;
|
||||
|
|
@ -104,6 +111,9 @@ QSize Video::countOptimalSize() {
|
|||
auto maxWidth = qMax(_thumbw, minWidth);
|
||||
auto minHeight = qMax(th, st::minVideoSize);
|
||||
if (_parent->hasBubble() && !_caption.isEmpty()) {
|
||||
if (cAdaptiveBaloons()) {
|
||||
maxWidth = qMax(maxWidth, _caption.maxWidth() + st::msgPadding.left() + st::msgPadding.right());
|
||||
}
|
||||
const auto captionw = maxWidth
|
||||
- st::msgPadding.left()
|
||||
- st::msgPadding.right();
|
||||
|
|
@ -116,6 +126,8 @@ QSize Video::countOptimalSize() {
|
|||
}
|
||||
|
||||
QSize Video::countCurrentSize(int newWidth) {
|
||||
auto availableWidth = newWidth;
|
||||
|
||||
const auto size = countOptimalDimensions();
|
||||
auto tw = size.width();
|
||||
auto th = size.height();
|
||||
|
|
@ -131,6 +143,10 @@ QSize Video::countCurrentSize(int newWidth) {
|
|||
newWidth = qMax(_thumbw, minWidth);
|
||||
auto newHeight = qMax(th, st::minPhotoSize);
|
||||
if (_parent->hasBubble() && !_caption.isEmpty()) {
|
||||
if (cAdaptiveBaloons()) {
|
||||
newWidth = qMax(newWidth, _caption.maxWidth() + st::msgPadding.left() + st::msgPadding.right());
|
||||
newWidth = qMin(newWidth, availableWidth);
|
||||
}
|
||||
const auto captionw = newWidth
|
||||
- st::msgPadding.left()
|
||||
- st::msgPadding.right();
|
||||
|
|
|
|||
|
|
@ -278,6 +278,10 @@ QSize WebPage::countOptimalSize() {
|
|||
_durationWidth = st::msgDateFont->width(_duration);
|
||||
}
|
||||
maxWidth += st::msgPadding.left() + st::webPageLeft + st::msgPadding.right();
|
||||
if (cAdaptiveBaloons()) {
|
||||
accumulate_min(maxWidth, st::msgMaxWidth);
|
||||
accumulate_max(maxWidth, _parent->plainMaxWidth());
|
||||
}
|
||||
auto padding = inBubblePadding();
|
||||
minHeight += padding.top() + padding.bottom();
|
||||
|
||||
|
|
@ -292,6 +296,10 @@ QSize WebPage::countCurrentSize(int newWidth) {
|
|||
return { newWidth, minHeight() };
|
||||
}
|
||||
|
||||
if (cAdaptiveBaloons() && !asArticle()) {
|
||||
accumulate_min(newWidth, maxWidth());
|
||||
}
|
||||
|
||||
auto innerWidth = newWidth - st::msgPadding.left() - st::webPageLeft - st::msgPadding.right();
|
||||
auto newHeight = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -232,6 +232,7 @@ rpl::producer<bool> BigEmojiOutlineChanges() {
|
|||
return gBigEmojiOutline.changes();
|
||||
}
|
||||
|
||||
bool gAdaptiveBaloons = false;
|
||||
bool gAlwaysShowScheduled = true;
|
||||
bool gShowChatId = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@ void SetStickerHeight(int height);
|
|||
[[nodiscard]] int StickerHeight();
|
||||
[[nodiscard]] rpl::producer<int> StickerHeightChanges();
|
||||
|
||||
DeclareSetting(bool, AdaptiveBaloons);
|
||||
DeclareSetting(bool, AlwaysShowScheduled);
|
||||
DeclareSetting(bool, ShowChatId);
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,33 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
|
|||
updateStickerHeight);
|
||||
updateStickerHeightLabel(StickerHeight());
|
||||
|
||||
const auto adaptiveBaloonsToggled = Ui::CreateChild<rpl::event_stream<bool>>(
|
||||
container.get());
|
||||
AddButton(
|
||||
container,
|
||||
tr::ktg_settings_adaptive_baloons(),
|
||||
st::settingsButton
|
||||
)->toggleOn(
|
||||
adaptiveBaloonsToggled->events_starting_with_copy(cAdaptiveBaloons())
|
||||
)->toggledValue(
|
||||
) | rpl::filter([](bool enabled) {
|
||||
return (enabled != cAdaptiveBaloons());
|
||||
}) | rpl::start_with_next([=](bool enabled) {
|
||||
const auto confirmed = [=] {
|
||||
cSetAdaptiveBaloons(enabled);
|
||||
KotatoSettings::Write();
|
||||
App::restart();
|
||||
};
|
||||
const auto cancelled = [=] {
|
||||
adaptiveBaloonsToggled->fire(cAdaptiveBaloons() == true);
|
||||
};
|
||||
Ui::show(Box<ConfirmBox>(
|
||||
tr::lng_settings_need_restart(tr::now),
|
||||
tr::lng_settings_restart_now(tr::now),
|
||||
confirmed,
|
||||
cancelled));
|
||||
}, container->lifetime());
|
||||
|
||||
AddButton(
|
||||
container,
|
||||
tr::ktg_settings_emoji_outline(),
|
||||
|
|
|
|||
|
|
@ -248,7 +248,9 @@ void Generator::addAudioBubble(QVector<int> waveform, int waveactive, QString wa
|
|||
tleft = st::msgFilePadding.left() + st::msgFileSize + st::msgFilePadding.right();
|
||||
tright = st::msgFileThumbPadding.left();
|
||||
accumulate_max(width, tleft + st::normalFont->width(wavestatus) + skipBlock.width() + st::msgPadding.right());
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
if (!cAdaptiveBaloons()) {
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
}
|
||||
|
||||
auto height = st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom();
|
||||
addBubble(std::move(bubble), width, height, date, status);
|
||||
|
|
@ -276,7 +278,9 @@ void Generator::addTextBubble(QString text, QString date, Status status) {
|
|||
|
||||
auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right();
|
||||
accumulate_min(width, st::msgPadding.left() + bubble.text.maxWidth() + st::msgPadding.right());
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
if (!cAdaptiveBaloons()) {
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
}
|
||||
|
||||
auto textWidth = qMax(width - st::msgPadding.left() - st::msgPadding.right(), 1);
|
||||
auto textHeight = bubble.text.countHeight(textWidth);
|
||||
|
|
@ -300,7 +304,9 @@ void Generator::addPhotoBubble(QString image, QString caption, QString date, Sta
|
|||
|
||||
auto width = _history.width() - st::msgMargin.left() - st::msgMargin.right();
|
||||
accumulate_min(width, bubble.photoWidth);
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
if (!cAdaptiveBaloons()) {
|
||||
accumulate_min(width, st::msgMaxWidth);
|
||||
}
|
||||
|
||||
auto textWidth = qMax(width - st::msgPadding.left() - st::msgPadding.right(), 1);
|
||||
auto textHeight = bubble.text.countHeight(textWidth);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue