Support title-aware Window::setGeometry.
This commit is contained in:
parent
84d68e48c0
commit
11aa7bcd4e
7 changed files with 28 additions and 5 deletions
|
|
@ -21,6 +21,7 @@ public:
|
|||
not_null<RpWidget*> body() override;
|
||||
void setTitle(const QString &title) override;
|
||||
void setSizeMin(QSize size) override;
|
||||
void setGeometry(QRect rect) override;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
|
|
|||
|
|
@ -75,9 +75,9 @@ private:
|
|||
class WindowHelper::Private final {
|
||||
public:
|
||||
explicit Private(not_null<WindowHelper*> owner);
|
||||
|
||||
|
||||
[[nodiscard]] int customTitleHeight() const;
|
||||
|
||||
|
||||
private:
|
||||
void init();
|
||||
void initOpenGL();
|
||||
|
|
@ -91,9 +91,9 @@ private:
|
|||
|
||||
NSWindow * __weak _nativeWindow = nil;
|
||||
NSView * __weak _nativeView = nil;
|
||||
|
||||
|
||||
std::unique_ptr<LayerCreationChecker> _layerCreationChecker;
|
||||
|
||||
|
||||
int _customTitleHeight = 0;
|
||||
|
||||
};
|
||||
|
|
@ -205,7 +205,14 @@ void WindowHelper::toggleCustomTitle(bool visible) {
|
|||
}
|
||||
|
||||
void WindowHelper::setSizeMin(QSize size) {
|
||||
_window->setMinimumSize(size.width(), _title->height() + size.height());
|
||||
_window->setMinimumSize(
|
||||
size.width(),
|
||||
(_title ? _title->height() : 0) + size.height());
|
||||
}
|
||||
|
||||
void WindowHelper::setGeometry(QRect rect) {
|
||||
_window->setGeometry(
|
||||
rect.marginsAdded({ 0, (_title ? _title->height() : 0), 0, 0 }));
|
||||
}
|
||||
|
||||
void WindowHelper::init() {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public:
|
|||
[[nodiscard]] virtual not_null<RpWidget*> body() = 0;
|
||||
virtual void setTitle(const QString &title) = 0;
|
||||
virtual void setSizeMin(QSize size) = 0;
|
||||
virtual void setGeometry(QRect rect) = 0;
|
||||
virtual ~BasicWindowHelper() = default;
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -103,6 +103,10 @@ void WindowHelper::setSizeMin(QSize size) {
|
|||
_window->setMinimumSize(size.width(), _title->height() + size.height());
|
||||
}
|
||||
|
||||
void WindowHelper::setGeometry(QRect rect) {
|
||||
_window->setGeometry(rect.marginsAdded({ 0, _title->height(), 0, 0 }));
|
||||
}
|
||||
|
||||
void WindowHelper::init() {
|
||||
style::PaletteChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public:
|
|||
not_null<RpWidget*> body() override;
|
||||
void setTitle(const QString &title) override;
|
||||
void setSizeMin(QSize size) override;
|
||||
void setGeometry(QRect rect) override;
|
||||
|
||||
private:
|
||||
class NativeFilter;
|
||||
|
|
|
|||
|
|
@ -42,4 +42,12 @@ void Window::setSizeMin(QSize size) {
|
|||
}
|
||||
}
|
||||
|
||||
void Window::setGeometry(QRect rect) {
|
||||
if (_helper) {
|
||||
_helper->setGeometry(rect);
|
||||
} else {
|
||||
RpWidget::setGeometry(rect);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public:
|
|||
|
||||
void setTitle(const QString &title);
|
||||
void setSizeMin(QSize size);
|
||||
void setGeometry(QRect rect);
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Platform::BasicWindowHelper> _helper;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue