mirror of https://github.com/procxx/kepka.git
				
				
				
			More large emoji layout improvements.
This commit is contained in:
		
							parent
							
								
									169db40e9f
								
							
						
					
					
						commit
						230dd29af5
					
				| 
						 | 
					@ -2759,6 +2759,11 @@ void History::resizeToWidth(int newWidth) {
 | 
				
			||||||
	_height = y;
 | 
						_height = y;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void History::forceFullResize() {
 | 
				
			||||||
 | 
						_width = 0;
 | 
				
			||||||
 | 
						_flags |= Flag::f_has_pending_resized_items;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ChannelId History::channelId() const {
 | 
					ChannelId History::channelId() const {
 | 
				
			||||||
	return peerToChannel(peer->id);
 | 
						return peerToChannel(peer->id);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -207,6 +207,7 @@ public:
 | 
				
			||||||
	HistoryItem *lastSentMessage() const;
 | 
						HistoryItem *lastSentMessage() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void resizeToWidth(int newWidth);
 | 
						void resizeToWidth(int newWidth);
 | 
				
			||||||
 | 
						void forceFullResize();
 | 
				
			||||||
	int height() const;
 | 
						int height() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void itemRemoved(not_null<HistoryItem*> item);
 | 
						void itemRemoved(not_null<HistoryItem*> item);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -455,7 +455,16 @@ HistoryWidget::HistoryWidget(
 | 
				
			||||||
		ActivateWindow(controller);
 | 
							ActivateWindow(controller);
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	subscribe(Adaptive::Changed(), [=] { update(); });
 | 
						subscribe(Adaptive::Changed(), [=] {
 | 
				
			||||||
 | 
							if (_history) {
 | 
				
			||||||
 | 
								_history->forceFullResize();
 | 
				
			||||||
 | 
								if (_migrated) {
 | 
				
			||||||
 | 
									_migrated->forceFullResize();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								updateHistoryGeometry();
 | 
				
			||||||
 | 
								update();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
	session().data().itemRemoved(
 | 
						session().data().itemRemoved(
 | 
				
			||||||
	) | rpl::start_with_next([=](not_null<const HistoryItem*> item) {
 | 
						) | rpl::start_with_next([=](not_null<const HistoryItem*> item) {
 | 
				
			||||||
		itemRemoved(item);
 | 
							itemRemoved(item);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,6 +29,10 @@ public:
 | 
				
			||||||
	QSize size() override;
 | 
						QSize size() override;
 | 
				
			||||||
	void draw(Painter &p, const QRect &r, bool selected) override;
 | 
						void draw(Painter &p, const QRect &r, bool selected) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool alwaysShowOutTimestamp() override {
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	const not_null<Element*> _parent;
 | 
						const not_null<Element*> _parent;
 | 
				
			||||||
	const std::array<
 | 
						const std::array<
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,7 +45,7 @@ int unitedLineHeight();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[nodiscard]] inline QSize DownscaledSize(QSize size, QSize box) {
 | 
					[[nodiscard]] inline QSize DownscaledSize(QSize size, QSize box) {
 | 
				
			||||||
	return (size.width() > box.width() || size.height() > box.height())
 | 
						return (size.width() > box.width() || size.height() > box.height())
 | 
				
			||||||
		? size.scaled(box, Qt::IgnoreAspectRatio)
 | 
							? size.scaled(box, Qt::KeepAspectRatio)
 | 
				
			||||||
		: size;
 | 
							: size;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,12 +32,7 @@ QSize UnwrappedMedia::countOptimalSize() {
 | 
				
			||||||
		_content->size(),
 | 
							_content->size(),
 | 
				
			||||||
		{ st::maxStickerSize, st::maxStickerSize }));
 | 
							{ st::maxStickerSize, st::maxStickerSize }));
 | 
				
			||||||
	auto maxWidth = _contentSize.width();
 | 
						auto maxWidth = _contentSize.width();
 | 
				
			||||||
	const auto infoHeight = st::msgDateImgPadding.y() * 2
 | 
						const auto minimal = st::largeEmojiSize + 2 * st::largeEmojiOutline;
 | 
				
			||||||
		+ st::msgDateFont->height;
 | 
					 | 
				
			||||||
	const auto minimal = st::largeEmojiSize
 | 
					 | 
				
			||||||
		+ 2 * st::largeEmojiOutline
 | 
					 | 
				
			||||||
		+ st::msgDateImgDelta
 | 
					 | 
				
			||||||
		+ infoHeight;
 | 
					 | 
				
			||||||
	auto minHeight = std::max(_contentSize.height(), minimal);
 | 
						auto minHeight = std::max(_contentSize.height(), minimal);
 | 
				
			||||||
	if (_parent->media() == this) {
 | 
						if (_parent->media() == this) {
 | 
				
			||||||
		const auto item = _parent->data();
 | 
							const auto item = _parent->data();
 | 
				
			||||||
| 
						 | 
					@ -45,6 +40,8 @@ QSize UnwrappedMedia::countOptimalSize() {
 | 
				
			||||||
		const auto reply = item->Get<HistoryMessageReply>();
 | 
							const auto reply = item->Get<HistoryMessageReply>();
 | 
				
			||||||
		maxWidth += additionalWidth(via, reply);
 | 
							maxWidth += additionalWidth(via, reply);
 | 
				
			||||||
		if (const auto surrounding = surroundingHeight(via, reply)) {
 | 
							if (const auto surrounding = surroundingHeight(via, reply)) {
 | 
				
			||||||
 | 
								const auto infoHeight = st::msgDateImgPadding.y() * 2
 | 
				
			||||||
 | 
									+ st::msgDateFont->height;
 | 
				
			||||||
			const auto minimal = surrounding
 | 
								const auto minimal = surrounding
 | 
				
			||||||
				+ st::msgDateImgDelta
 | 
									+ st::msgDateImgDelta
 | 
				
			||||||
				+ infoHeight;
 | 
									+ infoHeight;
 | 
				
			||||||
| 
						 | 
					@ -72,7 +69,17 @@ QSize UnwrappedMedia::countCurrentSize(int newWidth) {
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return { newWidth, minHeight() };
 | 
						auto newHeight = minHeight();
 | 
				
			||||||
 | 
						if (_parent->hasOutLayout() && !Adaptive::ChatWide()) {
 | 
				
			||||||
 | 
							// Add some height to isolated emoji for the timestamp info.
 | 
				
			||||||
 | 
							const auto infoHeight = st::msgDateImgPadding.y() * 2
 | 
				
			||||||
 | 
								+ st::msgDateFont->height;
 | 
				
			||||||
 | 
							const auto minimal = st::largeEmojiSize
 | 
				
			||||||
 | 
								+ 2 * st::largeEmojiOutline
 | 
				
			||||||
 | 
								+ (st::msgDateImgDelta + infoHeight);
 | 
				
			||||||
 | 
							accumulate_max(newHeight, minimal);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return { newWidth, newHeight };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void UnwrappedMedia::draw(
 | 
					void UnwrappedMedia::draw(
 | 
				
			||||||
| 
						 | 
					@ -285,7 +292,11 @@ TextState UnwrappedMedia::textState(QPoint point, StateRequest request) const {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool UnwrappedMedia::needInfoDisplay() const {
 | 
					bool UnwrappedMedia::needInfoDisplay() const {
 | 
				
			||||||
	return (_parent->data()->id < 0 || _parent->isUnderCursor());
 | 
						return (_parent->data()->id < 0)
 | 
				
			||||||
 | 
							|| (_parent->isUnderCursor())
 | 
				
			||||||
 | 
							|| (_parent->hasOutLayout()
 | 
				
			||||||
 | 
								&& !Adaptive::ChatWide()
 | 
				
			||||||
 | 
								&& _content->alwaysShowOutTimestamp());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int UnwrappedMedia::additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply *reply) const {
 | 
					int UnwrappedMedia::additionalWidth(const HistoryMessageVia *via, const HistoryMessageReply *reply) const {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -38,6 +38,9 @@ public:
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		virtual void refreshLink() {
 | 
							virtual void refreshLink() {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							[[nodiscard]] virtual bool alwaysShowOutTimestamp() {
 | 
				
			||||||
 | 
								return false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		virtual ~Content() = 0;
 | 
							virtual ~Content() = 0;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue