mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Added initial ability to create credit icon as non-session custom emoji.
This commit is contained in:
parent
eb3419f3fc
commit
f34835463d
2 changed files with 64 additions and 0 deletions
|
@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/empty_userpic.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/text/text_custom_emoji.h"
|
||||
#include "ui/widgets/fields/number_input.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
|
@ -42,6 +43,55 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Ui {
|
||||
namespace {
|
||||
|
||||
class CreditsIconEmoji final : public Ui::Text::CustomEmoji {
|
||||
public:
|
||||
CreditsIconEmoji(int height, int count);
|
||||
|
||||
int width() override;
|
||||
QString entityData() override;
|
||||
|
||||
void paint(QPainter &p, const Context &context) override;
|
||||
void unload() override;
|
||||
bool ready() override;
|
||||
bool readyInDefaultState() override;
|
||||
|
||||
private:
|
||||
const int _height;
|
||||
const int _count;
|
||||
QImage _image;
|
||||
|
||||
};
|
||||
|
||||
CreditsIconEmoji::CreditsIconEmoji(int height, int count)
|
||||
: _height(height)
|
||||
, _count(count)
|
||||
, _image(GenerateStars(height, count)) {
|
||||
}
|
||||
|
||||
int CreditsIconEmoji::width() {
|
||||
return _image.width() / style::DevicePixelRatio();
|
||||
}
|
||||
|
||||
QString CreditsIconEmoji::entityData() {
|
||||
return u"credits_icon:%1:%2"_q.arg(_height).arg(_count);
|
||||
}
|
||||
|
||||
void CreditsIconEmoji::paint(QPainter &p, const Context &context) {
|
||||
p.drawImage(context.position, _image);
|
||||
}
|
||||
|
||||
void CreditsIconEmoji::unload() {
|
||||
_image = QImage();
|
||||
}
|
||||
|
||||
bool CreditsIconEmoji::ready() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CreditsIconEmoji::readyInDefaultState() {
|
||||
return true;
|
||||
}
|
||||
|
||||
PaintRoundImageCallback MultiThumbnail(
|
||||
PaintRoundImageCallback first,
|
||||
PaintRoundImageCallback second,
|
||||
|
@ -678,4 +728,10 @@ QImage CreditsWhiteDoubledIcon(int size, float64 outlineRatio) {
|
|||
return result;
|
||||
}
|
||||
|
||||
std::unique_ptr<Ui::Text::CustomEmoji> MakeCreditsIconEmoji(
|
||||
int height,
|
||||
int count) {
|
||||
return std::make_unique<CreditsIconEmoji>(height, count);
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
|
|
|
@ -19,6 +19,10 @@ namespace Main {
|
|||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Ui::Text {
|
||||
class CustomEmoji;
|
||||
} // namespace Ui::Text
|
||||
|
||||
namespace Ui {
|
||||
|
||||
class MaskedInputField;
|
||||
|
@ -82,4 +86,8 @@ Fn<void(QPainter &)> PaintOutlinedColoredCreditsIconCallback(
|
|||
|
||||
[[nodiscard]] QImage CreditsWhiteDoubledIcon(int size, float64 outlineRatio);
|
||||
|
||||
std::unique_ptr<Ui::Text::CustomEmoji> MakeCreditsIconEmoji(
|
||||
int height,
|
||||
int count);
|
||||
|
||||
} // namespace Ui
|
||||
|
|
Loading…
Add table
Reference in a new issue