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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void History::forceFullResize() {
 | 
			
		||||
	_width = 0;
 | 
			
		||||
	_flags |= Flag::f_has_pending_resized_items;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ChannelId History::channelId() const {
 | 
			
		||||
	return peerToChannel(peer->id);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -207,6 +207,7 @@ public:
 | 
			
		|||
	HistoryItem *lastSentMessage() const;
 | 
			
		||||
 | 
			
		||||
	void resizeToWidth(int newWidth);
 | 
			
		||||
	void forceFullResize();
 | 
			
		||||
	int height() const;
 | 
			
		||||
 | 
			
		||||
	void itemRemoved(not_null<HistoryItem*> item);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -455,7 +455,16 @@ HistoryWidget::HistoryWidget(
 | 
			
		|||
		ActivateWindow(controller);
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	subscribe(Adaptive::Changed(), [=] { update(); });
 | 
			
		||||
	subscribe(Adaptive::Changed(), [=] {
 | 
			
		||||
		if (_history) {
 | 
			
		||||
			_history->forceFullResize();
 | 
			
		||||
			if (_migrated) {
 | 
			
		||||
				_migrated->forceFullResize();
 | 
			
		||||
			}
 | 
			
		||||
			updateHistoryGeometry();
 | 
			
		||||
			update();
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
	session().data().itemRemoved(
 | 
			
		||||
	) | rpl::start_with_next([=](not_null<const HistoryItem*> item) {
 | 
			
		||||
		itemRemoved(item);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,6 +29,10 @@ public:
 | 
			
		|||
	QSize size() override;
 | 
			
		||||
	void draw(Painter &p, const QRect &r, bool selected) override;
 | 
			
		||||
 | 
			
		||||
	bool alwaysShowOutTimestamp() override {
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	const not_null<Element*> _parent;
 | 
			
		||||
	const std::array<
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ int unitedLineHeight();
 | 
			
		|||
 | 
			
		||||
[[nodiscard]] inline QSize DownscaledSize(QSize size, QSize box) {
 | 
			
		||||
	return (size.width() > box.width() || size.height() > box.height())
 | 
			
		||||
		? size.scaled(box, Qt::IgnoreAspectRatio)
 | 
			
		||||
		? size.scaled(box, Qt::KeepAspectRatio)
 | 
			
		||||
		: size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,12 +32,7 @@ QSize UnwrappedMedia::countOptimalSize() {
 | 
			
		|||
		_content->size(),
 | 
			
		||||
		{ st::maxStickerSize, st::maxStickerSize }));
 | 
			
		||||
	auto maxWidth = _contentSize.width();
 | 
			
		||||
	const auto infoHeight = st::msgDateImgPadding.y() * 2
 | 
			
		||||
		+ st::msgDateFont->height;
 | 
			
		||||
	const auto minimal = st::largeEmojiSize
 | 
			
		||||
		+ 2 * st::largeEmojiOutline
 | 
			
		||||
		+ st::msgDateImgDelta
 | 
			
		||||
		+ infoHeight;
 | 
			
		||||
	const auto minimal = st::largeEmojiSize + 2 * st::largeEmojiOutline;
 | 
			
		||||
	auto minHeight = std::max(_contentSize.height(), minimal);
 | 
			
		||||
	if (_parent->media() == this) {
 | 
			
		||||
		const auto item = _parent->data();
 | 
			
		||||
| 
						 | 
				
			
			@ -45,6 +40,8 @@ QSize UnwrappedMedia::countOptimalSize() {
 | 
			
		|||
		const auto reply = item->Get<HistoryMessageReply>();
 | 
			
		||||
		maxWidth += additionalWidth(via, reply);
 | 
			
		||||
		if (const auto surrounding = surroundingHeight(via, reply)) {
 | 
			
		||||
			const auto infoHeight = st::msgDateImgPadding.y() * 2
 | 
			
		||||
				+ st::msgDateFont->height;
 | 
			
		||||
			const auto minimal = surrounding
 | 
			
		||||
				+ st::msgDateImgDelta
 | 
			
		||||
				+ 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(
 | 
			
		||||
| 
						 | 
				
			
			@ -285,7 +292,11 @@ TextState UnwrappedMedia::textState(QPoint point, StateRequest request) 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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,6 +38,9 @@ public:
 | 
			
		|||
		}
 | 
			
		||||
		virtual void refreshLink() {
 | 
			
		||||
		}
 | 
			
		||||
		[[nodiscard]] virtual bool alwaysShowOutTimestamp() {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
		virtual ~Content() = 0;
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue