2017-09-13 16:57:44 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-09-13 16:57:44 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-09-13 16:57:44 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui/wrap/wrap.h"
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
template <typename Widget = RpWidget>
|
|
|
|
class PaddingWrap;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
class PaddingWrap<RpWidget> : public Wrap<RpWidget> {
|
|
|
|
using Parent = Wrap<RpWidget>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PaddingWrap(
|
|
|
|
QWidget *parent,
|
2017-09-30 18:26:45 +00:00
|
|
|
object_ptr<RpWidget> &&child,
|
2017-09-13 16:57:44 +00:00
|
|
|
const style::margins &padding);
|
|
|
|
|
2017-11-23 12:48:56 +00:00
|
|
|
style::margins padding() const {
|
|
|
|
return _padding;
|
|
|
|
}
|
|
|
|
void setPadding(const style::margins &padding);
|
|
|
|
|
2017-09-13 16:57:44 +00:00
|
|
|
int naturalWidth() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int resizeGetHeight(int newWidth) override;
|
|
|
|
void wrappedSizeUpdated(QSize size) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
style::margins _padding;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Widget>
|
|
|
|
class PaddingWrap : public Wrap<Widget, PaddingWrap<RpWidget>> {
|
|
|
|
using Parent = Wrap<Widget, PaddingWrap<RpWidget>>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PaddingWrap(
|
|
|
|
QWidget *parent,
|
2017-09-30 18:26:45 +00:00
|
|
|
object_ptr<Widget> &&child,
|
2017-09-13 16:57:44 +00:00
|
|
|
const style::margins &padding)
|
|
|
|
: Parent(parent, std::move(child), padding) {
|
|
|
|
}
|
|
|
|
|
2017-09-21 19:21:33 +00:00
|
|
|
};
|
|
|
|
|
2018-04-16 17:02:40 +00:00
|
|
|
template <typename Widget = RpWidget>
|
|
|
|
class CenterWrap;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
class CenterWrap<RpWidget> : public Wrap<RpWidget> {
|
|
|
|
using Parent = Wrap<RpWidget>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CenterWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
object_ptr<RpWidget> &&child);
|
|
|
|
|
|
|
|
int naturalWidth() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int resizeGetHeight(int newWidth) override;
|
|
|
|
void wrappedSizeUpdated(QSize size) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void updateWrappedPosition(int forWidth);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Widget>
|
|
|
|
class CenterWrap : public Wrap<Widget, CenterWrap<RpWidget>> {
|
|
|
|
using Parent = Wrap<Widget, CenterWrap<RpWidget>>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CenterWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
object_ptr<Widget> &&child)
|
|
|
|
: Parent(parent, std::move(child)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-09-21 19:21:33 +00:00
|
|
|
class FixedHeightWidget : public RpWidget {
|
|
|
|
public:
|
2018-09-26 11:28:16 +00:00
|
|
|
explicit FixedHeightWidget(QWidget *parent, int height = 0)
|
2017-09-21 19:21:33 +00:00
|
|
|
: RpWidget(parent) {
|
|
|
|
resize(width(), height);
|
2017-09-13 16:57:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-09-21 19:21:33 +00:00
|
|
|
inline object_ptr<FixedHeightWidget> CreateSkipWidget(
|
2017-09-21 10:28:34 +00:00
|
|
|
QWidget *parent,
|
|
|
|
int skip) {
|
2017-09-21 19:21:33 +00:00
|
|
|
return object_ptr<FixedHeightWidget>(
|
2017-09-21 10:28:34 +00:00
|
|
|
parent,
|
2017-09-21 19:21:33 +00:00
|
|
|
skip);
|
2017-09-21 10:28:34 +00:00
|
|
|
}
|
|
|
|
|
2017-09-13 16:57:44 +00:00
|
|
|
} // namespace Ui
|