Decomposed painting of box content divider.

This commit is contained in:
23rd 2022-05-05 12:55:14 +03:00
parent 9b6e11db62
commit 83553d0826
2 changed files with 17 additions and 0 deletions

View file

@ -34,12 +34,20 @@ BoxContentDivider::BoxContentDivider(
void BoxContentDivider::paintEvent(QPaintEvent *e) { void BoxContentDivider::paintEvent(QPaintEvent *e) {
QPainter p(this); QPainter p(this);
p.fillRect(e->rect(), _bg); p.fillRect(e->rect(), _bg);
paintTop(p);
paintBottom(p);
}
void BoxContentDivider::paintTop(QPainter &p) {
const auto dividerFillTop = QRect( const auto dividerFillTop = QRect(
0, 0,
0, 0,
width(), width(),
st::boxDividerTop.height()); st::boxDividerTop.height());
st::boxDividerTop.fill(p, dividerFillTop); st::boxDividerTop.fill(p, dividerFillTop);
}
void BoxContentDivider::paintBottom(QPainter &p) {
const auto dividerFillBottom = myrtlrect( const auto dividerFillBottom = myrtlrect(
0, 0,
height() - st::boxDividerBottom.height(), height() - st::boxDividerBottom.height(),
@ -48,4 +56,8 @@ void BoxContentDivider::paintEvent(QPaintEvent *e) {
st::boxDividerBottom.fill(p, dividerFillBottom); st::boxDividerBottom.fill(p, dividerFillBottom);
} }
const style::color &BoxContentDivider::color() const {
return _bg;
}
} // namespace Ui } // namespace Ui

View file

@ -21,9 +21,14 @@ public:
int height, int height,
const style::color &bg); const style::color &bg);
[[nodiscard]] const style::color &color() const;
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;
void paintTop(QPainter &p);
void paintBottom(QPainter &p);
private: private:
const style::color &_bg; const style::color &_bg;