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 {
|
||||
|
||||
rpl::event_stream<> TitleControlsLayoutChanges;
|
||||
rpl::event_stream<TitleControls::Layout> TitleControlsLayoutChanges;
|
||||
|
||||
} // namespace
|
||||
|
||||
rpl::producer<> TitleControlsLayoutChanged() {
|
||||
rpl::producer<TitleControls::Layout> TitleControlsLayoutValue() {
|
||||
return rpl::single(
|
||||
TitleControlsLayout()
|
||||
) | rpl::then(
|
||||
TitleControlsLayoutChanged()
|
||||
);
|
||||
}
|
||||
|
||||
rpl::producer<TitleControls::Layout> TitleControlsLayoutChanged() {
|
||||
return TitleControlsLayoutChanges.events();
|
||||
}
|
||||
|
||||
void NotifyTitleControlsLayoutChanged() {
|
||||
TitleControlsLayoutChanges.fire({});
|
||||
TitleControlsLayoutChanges.fire_copy(TitleControlsLayout());
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ void UnsetWindowExtents(QWindow *window);
|
|||
bool ShowWindowMenu(QWindow *window);
|
||||
|
||||
[[nodiscard]] TitleControls::Layout TitleControlsLayout();
|
||||
[[nodiscard]] rpl::producer<> TitleControlsLayoutChanged();
|
||||
[[nodiscard]] rpl::producer<TitleControls::Layout> TitleControlsLayoutValue();
|
||||
[[nodiscard]] rpl::producer<TitleControls::Layout> TitleControlsLayoutChanged();
|
||||
void NotifyTitleControlsLayoutChanged();
|
||||
|
||||
} // namespace Platform
|
||||
|
|
|
|||
|
|
@ -202,29 +202,35 @@ void DefaultWindowHelper::init() {
|
|||
rpl::combine(
|
||||
window()->widthValue(),
|
||||
_windowState.value(),
|
||||
_title->shownValue()
|
||||
_title->shownValue(),
|
||||
TitleControlsLayoutValue()
|
||||
) | rpl::start_with_next([=](
|
||||
int width,
|
||||
Qt::WindowStates windowState,
|
||||
bool shown) {
|
||||
bool shown,
|
||||
TitleControls::Layout controlsLayout) {
|
||||
const auto area = resizeArea();
|
||||
_title->setGeometry(
|
||||
area.left(),
|
||||
area.top(),
|
||||
width - area.left() - area.right(),
|
||||
_title->st()->height);
|
||||
_title->controlsGeometry().height()
|
||||
? _title->st()->height
|
||||
: 0);
|
||||
}, _title->lifetime());
|
||||
|
||||
rpl::combine(
|
||||
window()->sizeValue(),
|
||||
_windowState.value(),
|
||||
_title->heightValue(),
|
||||
_title->shownValue()
|
||||
_title->shownValue(),
|
||||
TitleControlsLayoutValue()
|
||||
) | rpl::start_with_next([=](
|
||||
QSize size,
|
||||
Qt::WindowStates windowState,
|
||||
int titleHeight,
|
||||
bool titleShown) {
|
||||
bool titleShown,
|
||||
TitleControls::Layout controlsLayout) {
|
||||
const auto area = resizeArea();
|
||||
|
||||
const auto sizeWithoutMargins = size
|
||||
|
|
@ -342,7 +348,8 @@ bool DefaultWindowHelper::hasShadow() const {
|
|||
QMargins DefaultWindowHelper::resizeArea() const {
|
||||
if (window()->isMaximized()
|
||||
|| window()->isFullScreen()
|
||||
|| _title->isHidden()) {
|
||||
|| _title->isHidden()
|
||||
|| (!hasShadow() && !_title->controlsGeometry().height())) {
|
||||
return QMargins();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -167,12 +167,9 @@ void TitleControls::init(Fn<void(bool maximized)> maximize) {
|
|||
});
|
||||
_close->setPointerCursor(false);
|
||||
|
||||
parent()->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
updateControlsPosition();
|
||||
}, _close->lifetime());
|
||||
|
||||
TitleControlsLayoutChanged(
|
||||
rpl::combine(
|
||||
parent()->widthValue(),
|
||||
TitleControlsLayoutValue()
|
||||
) | rpl::start_with_next([=] {
|
||||
updateControlsPosition();
|
||||
}, _close->lifetime());
|
||||
|
|
@ -417,6 +414,10 @@ not_null<const style::WindowTitle*> DefaultTitleWidget::st() const {
|
|||
return _controls.st();
|
||||
}
|
||||
|
||||
QRect DefaultTitleWidget::controlsGeometry() const {
|
||||
return _controls.geometry();
|
||||
}
|
||||
|
||||
void DefaultTitleWidget::setText(const QString &text) {
|
||||
window()->setWindowTitle(text);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ public:
|
|||
explicit DefaultTitleWidget(not_null<RpWidget*> parent);
|
||||
|
||||
[[nodiscard]] not_null<const style::WindowTitle*> st() const;
|
||||
[[nodiscard]] QRect controlsGeometry() const;
|
||||
void setText(const QString &text);
|
||||
void setStyle(const style::WindowTitle &st);
|
||||
void setResizeEnabled(bool enabled);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue