init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
This commit is contained in:
67
Telegram/SourceFiles/ui/controls/jump_down_button.cpp
Normal file
67
Telegram/SourceFiles/ui/controls/jump_down_button.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
#include "ui/controls/jump_down_button.h"
|
||||
|
||||
#include "ui/effects/ripple_animation.h"
|
||||
#include "ui/unread_badge_paint.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
|
||||
namespace Ui {
|
||||
|
||||
JumpDownButton::JumpDownButton(
|
||||
QWidget *parent,
|
||||
const style::TwoIconButton &st)
|
||||
: RippleButton(parent, st.ripple)
|
||||
, _st(st) {
|
||||
resize(_st.width, _st.height);
|
||||
setCursor(style::cur_pointer);
|
||||
|
||||
hide();
|
||||
}
|
||||
|
||||
QImage JumpDownButton::prepareRippleMask() const {
|
||||
return Ui::RippleAnimation::EllipseMask(
|
||||
QSize(_st.rippleAreaSize, _st.rippleAreaSize));
|
||||
}
|
||||
|
||||
QPoint JumpDownButton::prepareRippleStartPosition() const {
|
||||
return mapFromGlobal(QCursor::pos()) - _st.rippleAreaPosition;
|
||||
}
|
||||
|
||||
void JumpDownButton::paintEvent(QPaintEvent *e) {
|
||||
auto p = QPainter(this);
|
||||
|
||||
const auto over = isOver();
|
||||
const auto down = isDown();
|
||||
((over || down)
|
||||
? _st.iconBelowOver
|
||||
: _st.iconBelow).paint(p, _st.iconPosition, width());
|
||||
paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y());
|
||||
((over || down)
|
||||
? _st.iconAboveOver
|
||||
: _st.iconAbove).paint(p, _st.iconPosition, width());
|
||||
if (_unreadCount > 0) {
|
||||
auto unreadString = QString::number(_unreadCount);
|
||||
|
||||
Ui::UnreadBadgeStyle st;
|
||||
st.align = style::al_center;
|
||||
st.font = st::historyToDownBadgeFont;
|
||||
st.size = st::historyToDownBadgeSize;
|
||||
st.sizeId = Ui::UnreadBadgeSize::HistoryToDown;
|
||||
Ui::PaintUnreadBadge(p, unreadString, width(), 0, st, 4);
|
||||
}
|
||||
}
|
||||
|
||||
void JumpDownButton::setUnreadCount(int unreadCount) {
|
||||
if (_unreadCount != unreadCount) {
|
||||
_unreadCount = unreadCount;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
Reference in New Issue
Block a user