2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-23 10:47:11 +00:00

90 lines
1.9 KiB
C
Raw Normal View History

2020-10-13 13:00:35 +03:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "ui/widgets/buttons.h"
namespace style {
struct SendButton;
} // namespace style
2020-10-13 13:00:35 +03:00
namespace Ui {
class SendButton final : public RippleButton {
public:
SendButton(QWidget *parent, const style::SendButton &st);
2020-10-13 13:00:35 +03:00
static constexpr auto kSlowmodeDelayLimit = 100 * 60;
enum class Type {
Send,
Schedule,
Save,
Record,
2024-10-08 22:43:24 +04:00
Round,
2020-10-13 13:00:35 +03:00
Cancel,
Slowmode,
};
2025-02-27 17:34:20 +04:00
struct State {
Type type = Type::Send;
int slowmodeDelay = 0;
int starsToSend = 0;
friend inline constexpr auto operator<=>(State, State) = default;
friend inline constexpr bool operator==(State, State) = default;
};
2020-10-13 13:00:35 +03:00
[[nodiscard]] Type type() const {
2025-02-27 17:34:20 +04:00
return _state.type;
}
[[nodiscard]] State state() const {
return _state;
2020-10-13 13:00:35 +03:00
}
2025-02-27 17:34:20 +04:00
void setState(State state);
2020-10-13 13:00:35 +03:00
void finishAnimating();
protected:
void paintEvent(QPaintEvent *e) override;
QImage prepareRippleMask() const override;
QPoint prepareRippleStartPosition() const override;
private:
2025-02-27 17:34:20 +04:00
struct StarsGeometry {
QRect inner;
QRect rounded;
QRect outer;
};
2020-10-13 13:00:35 +03:00
[[nodiscard]] QPixmap grabContent();
2025-02-27 17:34:20 +04:00
void updateSize();
[[nodiscard]] StarsGeometry starsGeometry() const;
2020-10-13 13:00:35 +03:00
2022-09-17 00:23:27 +04:00
void paintRecord(QPainter &p, bool over);
2024-10-08 22:43:24 +04:00
void paintRound(QPainter &p, bool over);
2022-09-17 00:23:27 +04:00
void paintSave(QPainter &p, bool over);
void paintCancel(QPainter &p, bool over);
void paintSend(QPainter &p, bool over);
void paintSchedule(QPainter &p, bool over);
void paintSlowmode(QPainter &p);
2025-02-27 17:34:20 +04:00
void paintStarsToSend(QPainter &p, bool over);
2020-10-13 13:00:35 +03:00
const style::SendButton &_st;
2025-02-27 17:34:20 +04:00
State _state;
2020-10-13 13:00:35 +03:00
QPixmap _contentFrom, _contentTo;
2025-02-27 17:34:20 +04:00
Ui::Animations::Simple _stateChangeAnimation;
int _stateChangeFromWidth = 0;
2020-10-13 13:00:35 +03:00
QString _slowmodeDelayText;
2025-02-27 17:34:20 +04:00
Ui::Text::String _starsToSendText;
2020-10-13 13:00:35 +03:00
};
} // namespace Ui