mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved out function for painting of color buttons to public interface.
This commit is contained in:
parent
64bd839d2c
commit
df5baba86b
2 changed files with 24 additions and 22 deletions
|
@ -124,27 +124,6 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void PaintColorButton(QPainter &p, QColor color, float64 selected) {
|
|
||||||
const auto size = st::settingsAccentColorSize;
|
|
||||||
const auto rect = QRect(0, 0, size, size);
|
|
||||||
|
|
||||||
p.setBrush(color);
|
|
||||||
p.setPen(Qt::NoPen);
|
|
||||||
p.drawEllipse(rect);
|
|
||||||
|
|
||||||
if (selected > 0.) {
|
|
||||||
const auto startSkip = -st::settingsAccentColorLine / 2.;
|
|
||||||
const auto endSkip = float64(st::settingsAccentColorSkip);
|
|
||||||
const auto skip = startSkip + (endSkip - startSkip) * selected;
|
|
||||||
auto pen = st::boxBg->p;
|
|
||||||
pen.setWidth(st::settingsAccentColorLine);
|
|
||||||
p.setBrush(Qt::NoBrush);
|
|
||||||
p.setPen(pen);
|
|
||||||
p.setOpacity(selected);
|
|
||||||
p.drawEllipse(QRectF(rect).marginsRemoved({ skip, skip, skip, skip }));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PaintCustomButton(QPainter &p, const std::vector<QColor> &colors) {
|
void PaintCustomButton(QPainter &p, const std::vector<QColor> &colors) {
|
||||||
Expects(colors.size() >= kCustomColorButtonParts);
|
Expects(colors.size() >= kCustomColorButtonParts);
|
||||||
|
|
||||||
|
@ -229,7 +208,7 @@ void ColorsPalette::Button::paint() {
|
||||||
PainterHighQualityEnabler hq(p);
|
PainterHighQualityEnabler hq(p);
|
||||||
|
|
||||||
if (_colors.size() == 1) {
|
if (_colors.size() == 1) {
|
||||||
PaintColorButton(
|
PaintRoundColorButton(
|
||||||
p,
|
p,
|
||||||
_colors.front(),
|
_colors.front(),
|
||||||
_selectedAnimation.value(_selected ? 1. : 0.));
|
_selectedAnimation.value(_selected ? 1. : 0.));
|
||||||
|
@ -392,6 +371,27 @@ void ColorsPalette::updateInnerGeometry() {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
void PaintRoundColorButton(QPainter &p, QBrush brush, float64 selected) {
|
||||||
|
const auto size = st::settingsAccentColorSize;
|
||||||
|
const auto rect = QRect(0, 0, size, size);
|
||||||
|
|
||||||
|
p.setBrush(brush);
|
||||||
|
p.setPen(Qt::NoPen);
|
||||||
|
p.drawEllipse(rect);
|
||||||
|
|
||||||
|
if (selected > 0.) {
|
||||||
|
const auto startSkip = -st::settingsAccentColorLine / 2.;
|
||||||
|
const auto endSkip = float64(st::settingsAccentColorSkip);
|
||||||
|
const auto skip = startSkip + (endSkip - startSkip) * selected;
|
||||||
|
auto pen = st::boxBg->p;
|
||||||
|
pen.setWidth(st::settingsAccentColorLine);
|
||||||
|
p.setBrush(Qt::NoBrush);
|
||||||
|
p.setPen(pen);
|
||||||
|
p.setOpacity(selected);
|
||||||
|
p.drawEllipse(QRectF(rect).marginsRemoved({ skip, skip, skip, skip }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class BackgroundRow : public Ui::RpWidget {
|
class BackgroundRow : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
BackgroundRow(
|
BackgroundRow(
|
||||||
|
|
|
@ -31,6 +31,8 @@ void SetupExport(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container);
|
not_null<Ui::VerticalLayout*> container);
|
||||||
|
|
||||||
|
void PaintRoundColorButton(QPainter &p, QBrush brush, float64 selected);
|
||||||
|
|
||||||
class Chat : public Section<Chat> {
|
class Chat : public Section<Chat> {
|
||||||
public:
|
public:
|
||||||
Chat(QWidget *parent, not_null<Window::SessionController*> controller);
|
Chat(QWidget *parent, not_null<Window::SessionController*> controller);
|
||||||
|
|
Loading…
Add table
Reference in a new issue