mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Replaced empty icon buttons with simple circle ripple buttons.
This commit is contained in:
parent
78937d716f
commit
6787ea883e
3 changed files with 26 additions and 59 deletions
|
@ -83,39 +83,6 @@ public:
|
||||||
|
|
||||||
AbstractButton::setDisabled(true);
|
AbstractButton::setDisabled(true);
|
||||||
|
|
||||||
class SmallButton final : public Ui::IconButton {
|
|
||||||
public:
|
|
||||||
SmallButton(
|
|
||||||
not_null<Ui::RpWidget*> parent,
|
|
||||||
QChar c,
|
|
||||||
float64 skip,
|
|
||||||
const style::color &color)
|
|
||||||
: Ui::IconButton(parent, st::ivPlusMinusZoom)
|
|
||||||
, _color(color)
|
|
||||||
, _skip(style::ConvertFloatScale(skip))
|
|
||||||
, _c(c) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *event) override {
|
|
||||||
auto p = Painter(this);
|
|
||||||
Ui::RippleButton::paintRipple(
|
|
||||||
p,
|
|
||||||
st::ivPlusMinusZoom.rippleAreaPosition);
|
|
||||||
p.setPen(_color);
|
|
||||||
p.setFont(st::normalFont);
|
|
||||||
p.drawText(
|
|
||||||
QRectF(rect()).translated(0, _skip),
|
|
||||||
_c,
|
|
||||||
style::al_center);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const style::color _color;
|
|
||||||
const float64 _skip;
|
|
||||||
const QChar _c;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto processTooltip = [=, this](not_null<Ui::RpWidget*> w) {
|
const auto processTooltip = [=, this](not_null<Ui::RpWidget*> w) {
|
||||||
w->events() | rpl::start_with_next([=](not_null<QEvent*> e) {
|
w->events() | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||||
if (e->type() == QEvent::Enter) {
|
if (e->type() == QEvent::Enter) {
|
||||||
|
@ -141,11 +108,16 @@ public:
|
||||||
_delegate->ivSetZoom(kDefaultZoom);
|
_delegate->ivSetZoom(kDefaultZoom);
|
||||||
});
|
});
|
||||||
reset->show();
|
reset->show();
|
||||||
const auto plus = Ui::CreateChild<SmallButton>(
|
const auto plus = Ui::CreateSimpleCircleButton(
|
||||||
this,
|
this,
|
||||||
'+',
|
st::defaultRippleAnimationBgOver);
|
||||||
0,
|
plus->resize(Size(st::ivZoomButtonsSize));
|
||||||
_st.itemFg);
|
plus->paintRequest() | rpl::start_with_next([=, fg = _st.itemFg] {
|
||||||
|
auto p = QPainter(plus);
|
||||||
|
p.setPen(fg);
|
||||||
|
p.setFont(st::normalFont);
|
||||||
|
p.drawText(plus->rect(), QChar('+'), style::al_center);
|
||||||
|
}, plus->lifetime());
|
||||||
processTooltip(plus);
|
processTooltip(plus);
|
||||||
const auto step = [] {
|
const auto step = [] {
|
||||||
return base::IsAltPressed()
|
return base::IsAltPressed()
|
||||||
|
@ -158,11 +130,20 @@ public:
|
||||||
_delegate->ivSetZoom(_delegate->ivZoom() + step());
|
_delegate->ivSetZoom(_delegate->ivZoom() + step());
|
||||||
});
|
});
|
||||||
plus->show();
|
plus->show();
|
||||||
const auto minus = Ui::CreateChild<SmallButton>(
|
const auto minus = Ui::CreateSimpleCircleButton(
|
||||||
this,
|
this,
|
||||||
QChar(0x2013),
|
st::defaultRippleAnimationBgOver);
|
||||||
-1,
|
minus->resize(Size(st::ivZoomButtonsSize));
|
||||||
_st.itemFg);
|
minus->paintRequest() | rpl::start_with_next([=, fg = _st.itemFg] {
|
||||||
|
auto p = QPainter(minus);
|
||||||
|
const auto r = minus->rect();
|
||||||
|
p.setPen(fg);
|
||||||
|
p.setFont(st::normalFont);
|
||||||
|
p.drawText(
|
||||||
|
QRectF(r).translated(0, style::ConvertFloatScale(-1)),
|
||||||
|
QChar(0x2013),
|
||||||
|
style::al_center);
|
||||||
|
}, minus->lifetime());
|
||||||
processTooltip(minus);
|
processTooltip(minus);
|
||||||
minus->setClickedCallback([this, step] {
|
minus->setClickedCallback([this, step] {
|
||||||
_delegate->ivSetZoom(_delegate->ivZoom() - step());
|
_delegate->ivSetZoom(_delegate->ivZoom() - step());
|
||||||
|
|
|
@ -896,24 +896,10 @@ void SetupMessages(
|
||||||
Quick::React,
|
Quick::React,
|
||||||
tr::lng_settings_chat_quick_action_react(tr::now));
|
tr::lng_settings_chat_quick_action_react(tr::now));
|
||||||
|
|
||||||
class EmptyButton final : public Ui::IconButton {
|
const auto buttonRight = Ui::CreateSimpleCircleButton(
|
||||||
public:
|
|
||||||
EmptyButton(not_null<Ui::RpWidget*> p, const style::IconButton &st)
|
|
||||||
: Ui::IconButton(p, st)
|
|
||||||
, _rippleAreaPosition(st.rippleAreaPosition) {
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *e) override {
|
|
||||||
auto p = QPainter(this);
|
|
||||||
|
|
||||||
paintRipple(p, _rippleAreaPosition, nullptr);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
const QPoint _rippleAreaPosition;
|
|
||||||
};
|
|
||||||
const auto buttonRight = Ui::CreateChild<EmptyButton>(
|
|
||||||
inner,
|
inner,
|
||||||
st::stickersRemove);
|
st::stickersRemove.ripple);
|
||||||
|
buttonRight->resize(st::stickersRemove.width, st::stickersRemove.height);
|
||||||
const auto toggleButtonRight = [=](bool value) {
|
const auto toggleButtonRight = [=](bool value) {
|
||||||
buttonRight->setAttribute(Qt::WA_TransparentForMouseEvents, !value);
|
buttonRight->setAttribute(Qt::WA_TransparentForMouseEvents, !value);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0198796f9011aeb8b1449e42a3cae02222df12fc
|
Subproject commit cdbde2988aea6a98fb8810d8f7d15b323aa64941
|
Loading…
Add table
Reference in a new issue