mirror of https://github.com/procxx/kepka.git
				
				
				
			
		
			
				
	
	
		
			63 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
/*
 | 
						|
This file is part of Telegram Desktop,
 | 
						|
the official desktop application for the Telegram messaging service.
 | 
						|
 | 
						|
For license and copyright information please follow this link:
 | 
						|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
						|
*/
 | 
						|
#pragma once
 | 
						|
 | 
						|
namespace HistoryView {
 | 
						|
 | 
						|
class Object {
 | 
						|
public:
 | 
						|
	Object() = default;
 | 
						|
	Object(const Object &other) = delete;
 | 
						|
	Object &operator=(const Object &other) = delete;
 | 
						|
 | 
						|
	void initDimensions() {
 | 
						|
		setOptimalSize(countOptimalSize());
 | 
						|
	}
 | 
						|
	int resizeGetHeight(int newWidth) {
 | 
						|
		setCurrentSize(countCurrentSize(newWidth));
 | 
						|
		return _height;
 | 
						|
	}
 | 
						|
 | 
						|
	int maxWidth() const {
 | 
						|
		return _maxWidth;
 | 
						|
	}
 | 
						|
	int minHeight() const {
 | 
						|
		return _minHeight;
 | 
						|
	}
 | 
						|
	int width() const {
 | 
						|
		return _width;
 | 
						|
	}
 | 
						|
	int height() const {
 | 
						|
		return _height;
 | 
						|
	}
 | 
						|
 | 
						|
	virtual ~Object() = default;
 | 
						|
 | 
						|
protected:
 | 
						|
	void setOptimalSize(QSize size) {
 | 
						|
		_maxWidth = size.width();
 | 
						|
		_minHeight = size.height();
 | 
						|
	}
 | 
						|
	void setCurrentSize(QSize size) {
 | 
						|
		_width = size.width();
 | 
						|
		_height = size.height();
 | 
						|
	}
 | 
						|
 | 
						|
private:
 | 
						|
	virtual QSize countOptimalSize() = 0;
 | 
						|
	virtual QSize countCurrentSize(int newWidth) = 0;
 | 
						|
 | 
						|
	int _maxWidth = 0;
 | 
						|
	int _minHeight = 0;
 | 
						|
	int _width = 0;
 | 
						|
	int _height = 0;
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
} // namespace HistoryView
 |