Hide titlebar & border when there are no controls
If the user doesn't want to control the window with buttons, then he moves/resizes the window in other way as well
This commit is contained in:
parent
74224fe06e
commit
94c5754b42
5 changed files with 34 additions and 16 deletions
|
|
@ -10,16 +10,24 @@ namespace Ui {
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
rpl::event_stream<> TitleControlsLayoutChanges;
|
rpl::event_stream<TitleControls::Layout> TitleControlsLayoutChanges;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
rpl::producer<> TitleControlsLayoutChanged() {
|
rpl::producer<TitleControls::Layout> TitleControlsLayoutValue() {
|
||||||
|
return rpl::single(
|
||||||
|
TitleControlsLayout()
|
||||||
|
) | rpl::then(
|
||||||
|
TitleControlsLayoutChanged()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<TitleControls::Layout> TitleControlsLayoutChanged() {
|
||||||
return TitleControlsLayoutChanges.events();
|
return TitleControlsLayoutChanges.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyTitleControlsLayoutChanged() {
|
void NotifyTitleControlsLayoutChanged() {
|
||||||
TitleControlsLayoutChanges.fire({});
|
TitleControlsLayoutChanges.fire_copy(TitleControlsLayout());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ void UnsetWindowExtents(QWindow *window);
|
||||||
bool ShowWindowMenu(QWindow *window);
|
bool ShowWindowMenu(QWindow *window);
|
||||||
|
|
||||||
[[nodiscard]] TitleControls::Layout TitleControlsLayout();
|
[[nodiscard]] TitleControls::Layout TitleControlsLayout();
|
||||||
[[nodiscard]] rpl::producer<> TitleControlsLayoutChanged();
|
[[nodiscard]] rpl::producer<TitleControls::Layout> TitleControlsLayoutValue();
|
||||||
|
[[nodiscard]] rpl::producer<TitleControls::Layout> TitleControlsLayoutChanged();
|
||||||
void NotifyTitleControlsLayoutChanged();
|
void NotifyTitleControlsLayoutChanged();
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
|
||||||
|
|
@ -202,29 +202,35 @@ void DefaultWindowHelper::init() {
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
window()->widthValue(),
|
window()->widthValue(),
|
||||||
_windowState.value(),
|
_windowState.value(),
|
||||||
_title->shownValue()
|
_title->shownValue(),
|
||||||
|
TitleControlsLayoutValue()
|
||||||
) | rpl::start_with_next([=](
|
) | rpl::start_with_next([=](
|
||||||
int width,
|
int width,
|
||||||
Qt::WindowStates windowState,
|
Qt::WindowStates windowState,
|
||||||
bool shown) {
|
bool shown,
|
||||||
|
TitleControls::Layout controlsLayout) {
|
||||||
const auto area = resizeArea();
|
const auto area = resizeArea();
|
||||||
_title->setGeometry(
|
_title->setGeometry(
|
||||||
area.left(),
|
area.left(),
|
||||||
area.top(),
|
area.top(),
|
||||||
width - area.left() - area.right(),
|
width - area.left() - area.right(),
|
||||||
_title->st()->height);
|
_title->controlsGeometry().height()
|
||||||
|
? _title->st()->height
|
||||||
|
: 0);
|
||||||
}, _title->lifetime());
|
}, _title->lifetime());
|
||||||
|
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
window()->sizeValue(),
|
window()->sizeValue(),
|
||||||
_windowState.value(),
|
_windowState.value(),
|
||||||
_title->heightValue(),
|
_title->heightValue(),
|
||||||
_title->shownValue()
|
_title->shownValue(),
|
||||||
|
TitleControlsLayoutValue()
|
||||||
) | rpl::start_with_next([=](
|
) | rpl::start_with_next([=](
|
||||||
QSize size,
|
QSize size,
|
||||||
Qt::WindowStates windowState,
|
Qt::WindowStates windowState,
|
||||||
int titleHeight,
|
int titleHeight,
|
||||||
bool titleShown) {
|
bool titleShown,
|
||||||
|
TitleControls::Layout controlsLayout) {
|
||||||
const auto area = resizeArea();
|
const auto area = resizeArea();
|
||||||
|
|
||||||
const auto sizeWithoutMargins = size
|
const auto sizeWithoutMargins = size
|
||||||
|
|
@ -342,7 +348,8 @@ bool DefaultWindowHelper::hasShadow() const {
|
||||||
QMargins DefaultWindowHelper::resizeArea() const {
|
QMargins DefaultWindowHelper::resizeArea() const {
|
||||||
if (window()->isMaximized()
|
if (window()->isMaximized()
|
||||||
|| window()->isFullScreen()
|
|| window()->isFullScreen()
|
||||||
|| _title->isHidden()) {
|
|| _title->isHidden()
|
||||||
|
|| (!hasShadow() && !_title->controlsGeometry().height())) {
|
||||||
return QMargins();
|
return QMargins();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -167,12 +167,9 @@ void TitleControls::init(Fn<void(bool maximized)> maximize) {
|
||||||
});
|
});
|
||||||
_close->setPointerCursor(false);
|
_close->setPointerCursor(false);
|
||||||
|
|
||||||
parent()->widthValue(
|
rpl::combine(
|
||||||
) | rpl::start_with_next([=](int width) {
|
parent()->widthValue(),
|
||||||
updateControlsPosition();
|
TitleControlsLayoutValue()
|
||||||
}, _close->lifetime());
|
|
||||||
|
|
||||||
TitleControlsLayoutChanged(
|
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
updateControlsPosition();
|
updateControlsPosition();
|
||||||
}, _close->lifetime());
|
}, _close->lifetime());
|
||||||
|
|
@ -417,6 +414,10 @@ not_null<const style::WindowTitle*> DefaultTitleWidget::st() const {
|
||||||
return _controls.st();
|
return _controls.st();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRect DefaultTitleWidget::controlsGeometry() const {
|
||||||
|
return _controls.geometry();
|
||||||
|
}
|
||||||
|
|
||||||
void DefaultTitleWidget::setText(const QString &text) {
|
void DefaultTitleWidget::setText(const QString &text) {
|
||||||
window()->setWindowTitle(text);
|
window()->setWindowTitle(text);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ public:
|
||||||
explicit DefaultTitleWidget(not_null<RpWidget*> parent);
|
explicit DefaultTitleWidget(not_null<RpWidget*> parent);
|
||||||
|
|
||||||
[[nodiscard]] not_null<const style::WindowTitle*> st() const;
|
[[nodiscard]] not_null<const style::WindowTitle*> st() const;
|
||||||
|
[[nodiscard]] QRect controlsGeometry() const;
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
void setStyle(const style::WindowTitle &st);
|
void setStyle(const style::WindowTitle &st);
|
||||||
void setResizeEnabled(bool enabled);
|
void setResizeEnabled(bool enabled);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue