init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
69
Telegram/SourceFiles/history/view/history_view_object.h
Normal file
69
Telegram/SourceFiles/history/view/history_view_object.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
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;
|
||||
}
|
||||
|
||||
[[nodiscard]] QSize optimalSize() const {
|
||||
return { _maxWidth, _minHeight };
|
||||
}
|
||||
[[nodiscard]] QSize currentSize() const {
|
||||
return { _width, _height };
|
||||
}
|
||||
|
||||
[[nodiscard]] int maxWidth() const {
|
||||
return _maxWidth;
|
||||
}
|
||||
[[nodiscard]] int minHeight() const {
|
||||
return _minHeight;
|
||||
}
|
||||
[[nodiscard]] int width() const {
|
||||
return _width;
|
||||
}
|
||||
[[nodiscard]] 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
|
||||
Reference in New Issue
Block a user