Allow custom rounded corners in boxes.
This commit is contained in:
parent
674391524b
commit
aa16cd0c16
3 changed files with 22 additions and 8 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include "ui/widgets/shadow.h"
|
||||
#include "ui/wrap/fade_wrap.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/rect_part.h"
|
||||
#include "ui/painter.h"
|
||||
#include "base/timer.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
|
@ -103,6 +104,10 @@ void BoxContent::scrollToWidget(not_null<QWidget*> widget) {
|
|||
}
|
||||
}
|
||||
|
||||
RectParts BoxContent::customCornersFilling() {
|
||||
return {};
|
||||
}
|
||||
|
||||
void BoxContent::onScrollToY(int top, int bottom) {
|
||||
if (_scroll) {
|
||||
_scroll->scrollToY(top, bottom);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@
|
|||
#include "ui/text/text_entity.h"
|
||||
#include "ui/rp_widget.h"
|
||||
|
||||
enum class RectPart;
|
||||
using RectParts = base::flags<RectPart>;
|
||||
|
||||
namespace style {
|
||||
struct RoundButton;
|
||||
struct IconButton;
|
||||
|
|
@ -128,6 +131,7 @@ public:
|
|||
|
||||
virtual void showFinished() {
|
||||
}
|
||||
virtual RectParts customCornersFilling();
|
||||
void clearButtons() {
|
||||
getDelegate()->clearButtons();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,16 +115,21 @@ QRect BoxLayerWidget::loadingRect() const {
|
|||
|
||||
void BoxLayerWidget::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
auto clip = e->rect();
|
||||
auto paintTopRounded = clip.intersects(QRect(0, 0, width(), st::boxRadius));
|
||||
auto paintBottomRounded = clip.intersects(QRect(0, height() - st::boxRadius, width(), st::boxRadius));
|
||||
|
||||
const auto custom = _content->customCornersFilling();
|
||||
const auto clip = e->rect();
|
||||
const auto paintTopRounded = !(custom & RectPart::FullTop)
|
||||
&& clip.intersects(QRect(0, 0, width(), st::boxRadius));
|
||||
const auto paintBottomRounded = !(custom & RectPart::FullBottom)
|
||||
&& clip.intersects(
|
||||
QRect(0, height() - st::boxRadius, width(), st::boxRadius));
|
||||
if (paintTopRounded || paintBottomRounded) {
|
||||
auto parts = RectPart::None | 0;
|
||||
if (paintTopRounded) parts |= RectPart::FullTop;
|
||||
if (paintBottomRounded) parts |= RectPart::FullBottom;
|
||||
_roundRect.paint(p, rect(), parts);
|
||||
_roundRect.paint(p, rect(), RectPart::None
|
||||
| (paintTopRounded ? RectPart::FullTop : RectPart::None)
|
||||
| (paintBottomRounded ? RectPart::FullBottom : RectPart::None));
|
||||
}
|
||||
auto other = e->region().intersected(QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius));
|
||||
const auto other = e->region().intersected(
|
||||
QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius));
|
||||
if (!other.isEmpty()) {
|
||||
for (const auto &rect : other) {
|
||||
p.fillRect(rect, st().bg);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue