Allow DividerLabel with only top / bottom part.
This commit is contained in:
parent
b9a702f6e0
commit
b802516ca7
4 changed files with 33 additions and 11 deletions
|
|
@ -25,17 +25,24 @@ BoxContentDivider::BoxContentDivider(QWidget *parent, int height)
|
||||||
BoxContentDivider::BoxContentDivider(
|
BoxContentDivider::BoxContentDivider(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
int height,
|
int height,
|
||||||
const style::color &bg)
|
const style::color &bg,
|
||||||
|
RectParts parts)
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _bg(bg) {
|
, _bg(bg)
|
||||||
|
, _parts(parts) {
|
||||||
resize(width(), height);
|
resize(width(), height);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
if (_parts & RectPart::Top) {
|
||||||
paintBottom(p);
|
paintTop(p);
|
||||||
|
}
|
||||||
|
if (_parts & RectPart::Bottom) {
|
||||||
|
paintBottom(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoxContentDivider::paintTop(QPainter &p) {
|
void BoxContentDivider::paintTop(QPainter &p) {
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
|
#include "ui/rect_part.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
class BoxContentDivider : public Ui::RpWidget {
|
class BoxContentDivider : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
BoxContentDivider(QWidget *parent);
|
BoxContentDivider(QWidget *parent);
|
||||||
BoxContentDivider(
|
BoxContentDivider(QWidget *parent, int height);
|
||||||
QWidget *parent,
|
|
||||||
int height);
|
|
||||||
BoxContentDivider(
|
BoxContentDivider(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
int height,
|
int height,
|
||||||
const style::color &bg);
|
const style::color &bg,
|
||||||
|
RectParts parts = RectPart::Top | RectPart::Bottom);
|
||||||
|
|
||||||
[[nodiscard]] const style::color &color() const;
|
[[nodiscard]] const style::color &color() const;
|
||||||
|
|
||||||
|
|
@ -31,6 +31,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const style::color &_bg;
|
const style::color &_bg;
|
||||||
|
const RectParts _parts;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@
|
||||||
#include "ui/basic_click_handlers.h" // UrlClickHandler
|
#include "ui/basic_click_handlers.h" // UrlClickHandler
|
||||||
#include "ui/inactive_press.h"
|
#include "ui/inactive_press.h"
|
||||||
#include "base/qt/qt_common_adapters.h"
|
#include "base/qt/qt_common_adapters.h"
|
||||||
|
#include "styles/style_layers.h"
|
||||||
|
#include "styles/palette.h"
|
||||||
|
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include <QtGui/QClipboard>
|
#include <QtGui/QClipboard>
|
||||||
|
|
@ -903,6 +905,15 @@ void FlatLabel::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DividerLabel::DividerLabel(
|
||||||
|
QWidget *parent,
|
||||||
|
object_ptr<FlatLabel> &&child,
|
||||||
|
const style::margins &padding,
|
||||||
|
RectParts parts)
|
||||||
|
: PaddingWrap(parent, std::move(child), padding)
|
||||||
|
, _background(this, st::boxDividerHeight, st::boxDividerBg, parts) {
|
||||||
|
}
|
||||||
|
|
||||||
int DividerLabel::naturalWidth() const {
|
int DividerLabel::naturalWidth() const {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,11 @@ private:
|
||||||
|
|
||||||
class DividerLabel : public PaddingWrap<FlatLabel> {
|
class DividerLabel : public PaddingWrap<FlatLabel> {
|
||||||
public:
|
public:
|
||||||
using PaddingWrap::PaddingWrap;
|
DividerLabel(
|
||||||
|
QWidget *parent,
|
||||||
|
object_ptr<FlatLabel> &&child,
|
||||||
|
const style::margins &padding,
|
||||||
|
RectParts parts = RectPart::Top | RectPart::Bottom);
|
||||||
|
|
||||||
int naturalWidth() const override;
|
int naturalWidth() const override;
|
||||||
|
|
||||||
|
|
@ -255,8 +259,7 @@ protected:
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
object_ptr<BoxContentDivider> _background
|
object_ptr<BoxContentDivider> _background;
|
||||||
= object_ptr<BoxContentDivider>(this);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue