Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fixed parameter to SeparatePanel::setInnerSize for resizeable panels #237

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions ui/widgets/separate_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,21 +788,21 @@ void SeparatePanel::focusInEvent(QFocusEvent *e) {
});
}

void SeparatePanel::setInnerSize(QSize size) {
void SeparatePanel::setInnerSize(QSize size, bool fixed) {
Expects(!size.isEmpty());

if (rect().isEmpty()) {
initGeometry(size);
initGeometry(size, fixed);
} else {
updateGeometry(size);
updateGeometry(size, fixed);
}
}

QRect SeparatePanel::innerGeometry() const {
return _body->geometry();
}

void SeparatePanel::initGeometry(QSize size) {
void SeparatePanel::initGeometry(QSize size, bool fixed) {
const auto active = QApplication::activeWindow();
const auto available = !active
? QGuiApplication::primaryScreen()->availableGeometry()
Expand Down Expand Up @@ -847,14 +847,24 @@ void SeparatePanel::initGeometry(QSize size) {
return initRect.translated(center - initRect.center()).marginsAdded(_padding);
}();
move(rect.topLeft());
setFixedSize(rect.size());
if (fixed) {
setFixedSize(rect.size());
} else {
resize(rect.size());
}
updateControlsGeometry();
}

void SeparatePanel::updateGeometry(QSize size) {
setFixedSize(
_padding.left() + size.width() + _padding.right(),
_padding.top() + size.height() + _padding.bottom());
void SeparatePanel::updateGeometry(QSize size, bool fixed) {
if (fixed) {
setFixedSize(
_padding.left() + size.width() + _padding.right(),
_padding.top() + size.height() + _padding.bottom());
} else {
resize(
_padding.left() + size.width() + _padding.right(),
_padding.top() + size.height() + _padding.bottom());
}
updateControlsGeometry();
update();
}
Expand Down
6 changes: 3 additions & 3 deletions ui/widgets/separate_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SeparatePanel final : public RpWidget {

void setTitle(rpl::producer<QString> title);
void setTitleHeight(int height);
void setInnerSize(QSize size);
void setInnerSize(QSize size, bool fixed = true);
[[nodiscard]] QRect innerGeometry() const;

void setHideOnDeactivate(bool hideOnDeactivate);
Expand Down Expand Up @@ -118,8 +118,8 @@ class SeparatePanel final : public RpWidget {
private:
void initControls();
void initLayout(const SeparatePanelArgs &args);
void initGeometry(QSize size);
void updateGeometry(QSize size);
void initGeometry(QSize size, bool fixed = true);
void updateGeometry(QSize size, bool fixed = true);
void showControls();
void updateControlsGeometry();
void validateBorderImage();
Expand Down