Support internal static custom emoji.
This commit is contained in:
		
							parent
							
								
									1ae65d2cba
								
							
						
					
					
						commit
						3c645c8ea0
					
				
					 2 changed files with 46 additions and 0 deletions
				
			
		|  | @ -858,4 +858,33 @@ void Object::repaint() { | ||||||
| 	_repaint(); | 	_repaint(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | Internal::Internal(QString entityData, QImage image, bool colored) | ||||||
|  | : _entityData(std::move(entityData)) | ||||||
|  | , _image(std::move(image)) | ||||||
|  | , _colored(colored) { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | QString Internal::entityData() { | ||||||
|  | 	return _entityData; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void Internal::paint(QPainter &p, const Context &context) { | ||||||
|  | 	context.internal.colorized = _colored; | ||||||
|  | 
 | ||||||
|  | 	const auto size = _image.size() / style::DevicePixelRatio(); | ||||||
|  | 	const auto rect = QRect(context.position, size); | ||||||
|  | 	PaintScaledImage(p, rect, { &_image }, context); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void Internal::unload() { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool Internal::ready() { | ||||||
|  | 	return true; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool Internal::readyInDefaultState() { | ||||||
|  | 	return true; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| } // namespace Ui::CustomEmoji
 | } // namespace Ui::CustomEmoji
 | ||||||
|  |  | ||||||
|  | @ -273,4 +273,21 @@ private: | ||||||
| 
 | 
 | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | class Internal final : public Ui::Text::CustomEmoji { | ||||||
|  | public: | ||||||
|  | 	Internal(QString entityData, QImage image, bool colored); | ||||||
|  | 
 | ||||||
|  | 	QString entityData() override; | ||||||
|  | 	void paint(QPainter &p, const Context &context) override; | ||||||
|  | 	void unload() override; | ||||||
|  | 	bool ready() override; | ||||||
|  | 	bool readyInDefaultState() override; | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  | 	const QString _entityData; | ||||||
|  | 	const QImage _image; | ||||||
|  | 	const bool _colored = false; | ||||||
|  | 
 | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| } // namespace Ui::CustomEmoji
 | } // namespace Ui::CustomEmoji
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 John Preston
						John Preston