Allow changing SeparatePanel title height.

This commit is contained in:
John Preston 2022-08-04 18:25:45 +03:00
parent 303947c78c
commit dcb4a33eef
3 changed files with 15 additions and 3 deletions

View file

@ -160,6 +160,7 @@ boxDividerHeight: 10px;
separatePanelBorderCacheSize: 60px;
separatePanelTitleHeight: 62px;
separatePanelNoTitleHeight: 32px;
separatePanelClose: IconButton(boxTitleClose) {
width: 60px;
height: 60px;

View file

@ -93,7 +93,8 @@ SeparatePanel::SeparatePanel(QWidget *parent)
: RpWidget(parent)
, _close(this, st::separatePanelClose)
, _back(this, object_ptr<Ui::IconButton>(this, st::separatePanelBack))
, _body(this) {
, _body(this)
, _titleHeight(st::separatePanelTitleHeight) {
setMouseTracking(true);
setWindowIcon(QGuiApplication::windowIcon());
initControls();
@ -107,6 +108,11 @@ void SeparatePanel::setTitle(rpl::producer<QString> title) {
updateTitleGeometry(width());
}
void SeparatePanel::setTitleHeight(int height) {
_titleHeight = height;
updateControlsGeometry();
}
void SeparatePanel::initControls() {
widthValue(
) | rpl::start_with_next([=](int width) {
@ -127,6 +133,9 @@ void SeparatePanel::initControls() {
}, _back->lifetime());
_back->hide(anim::type::instant);
_titleLeft.stop();
_back->raise();
_close->raise();
}
void SeparatePanel::updateTitleGeometry(int newWidth) {
@ -552,7 +561,7 @@ void SeparatePanel::resizeEvent(QResizeEvent *e) {
}
void SeparatePanel::updateControlsGeometry() {
const auto top = _padding.top() + st::separatePanelTitleHeight;
const auto top = _padding.top() + _titleHeight;
_body->setGeometry(
_padding.left(),
top,
@ -716,7 +725,7 @@ void SeparatePanel::mousePressEvent(QMouseEvent *e) {
_padding.left(),
_padding.top(),
width() - _padding.left() - _padding.right(),
st::separatePanelTitleHeight);
_titleHeight);
if (e->button() == Qt::LeftButton) {
if (dragArea.contains(e->pos())) {
const auto dragViaSystem = [&] {

View file

@ -34,6 +34,7 @@ public:
explicit SeparatePanel(QWidget *parent = nullptr);
void setTitle(rpl::producer<QString> title);
void setTitleHeight(int height);
void setInnerSize(QSize size);
[[nodiscard]] QRect innerGeometry() const;
@ -105,6 +106,7 @@ private:
rpl::event_stream<> _userCloseRequests;
rpl::event_stream<> _closeEvents;
int _titleHeight = 0;
bool _hideOnDeactivate = false;
bool _useTransparency = true;
style::margins _padding;