stickers pan with packs buttons

This commit is contained in:
John Preston 2015-06-05 18:02:20 +03:00
parent 6d8f277904
commit 95e5b7be0b
6 changed files with 403 additions and 29 deletions

View File

@ -1650,6 +1650,12 @@ stickerPanSize: size(55px, 55px);
stickerPanPadding: 11px;
stickerPanDelete: sprite(123px, 132px, 12px, 12px);
stickerPanDeleteOpacity: 0.5;
stickerIconPadding: 3px;
stickerIconHover: #e8ecef;
stickerIconSel: #dfe3e6;
stickerIconRecent: sprite(342px, 50px, 21px, 22px);
stickerIconLeft: sprite(342px, 72px, 40px, 1px);
stickerIconRight: sprite(342px, 73px, 40px, 1px);
mvBgColor: #222;
mvBgOpacity: 0.92;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 KiB

After

Width:  |  Height:  |  Size: 218 KiB

View File

@ -1154,10 +1154,12 @@ void StickerPanInner::setScrollTop(int top) {
}
int StickerPanInner::countHeight() {
int result = 0;
int result = 0, minLastH = st::emojiPanFullSize.height() - st::rbEmoji.height - st::stickerPanPadding;
for (int i = 0; i < _sets.size(); ++i) {
int cnt = _sets.at(i).size(), rows = (cnt / StickerPanPerRow) + ((cnt % StickerPanPerRow) ? 1 : 0);
result += st::emojiPanHeader + rows * st::stickerPanSize.height();
int h = st::emojiPanHeader + rows * st::stickerPanSize.height();
if (i == _sets.size() - 1 && _setIds.at(i) != CustomStickerSetId && h < minLastH) h = minLastH;
result += h;
}
return result + st::stickerPanPadding;
}
@ -1395,6 +1397,8 @@ void StickerPanInner::refreshStickers() {
int32 h = countHeight();
if (h != height()) resize(width(), h);
emit refreshIcons();
updateSelected();
}
@ -1428,6 +1432,19 @@ void StickerPanInner::preloadImages() {
}
}
uint64 StickerPanInner::currentSet(int yOffset) const {
int y, ytill = 0;
for (int i = 0, l = _sets.size(); i < l; ++i) {
int cnt = _sets.at(i).size();
y = ytill;
ytill = y + st::emojiPanHeader + ((cnt / StickerPanPerRow) + ((cnt % StickerPanPerRow) ? 1 : 0)) * st::stickerPanSize.height();
if (yOffset < ytill) {
return _setIds.at(i);
}
}
return _setIds.isEmpty() ? RecentStickerSetId : _setIds.back();
}
void StickerPanInner::appendSet(uint64 setId) {
const StickerSets &sets(cStickerSets());
StickerSets::const_iterator it = sets.constFind(setId);
@ -1479,6 +1496,30 @@ void StickerPanInner::refreshRecent(bool performResize) {
}
}
void StickerPanInner::fillIcons(QVector<StickerIcon> &icons) {
icons.clear();
icons.reserve(_sets.size());
int32 i = 0;
if (_setIds.at(0) == RecentStickerSetId) ++i;
if (_setIds.at(0) == CustomStickerSetId || _setIds.at(1) == CustomStickerSetId) ++i;
if (i > 0) icons.push_back(StickerIcon());
for (int32 l = _sets.size(); i < l; ++i) {
DocumentData *s = _sets.at(i).at(0);
int32 availw = st::rbEmoji.width - 2 * st::stickerIconPadding, availh = st::rbEmoji.height - 2 * st::stickerIconPadding;
int32 thumbw = s->thumb->width(), thumbh = s->thumb->height(), pixw = 1, pixh = 1;
if (availw * thumbh > availh * thumbw) {
pixh = availh;
pixw = (pixh * thumbw) / thumbh;
} else {
pixw = availw;
pixh = thumbw ? ((pixw * thumbh) / thumbw) : 1;
}
if (pixw < 1) pixw = 1;
if (pixh < 1) pixh = 1;
icons.push_back(StickerIcon(_setIds.at(i), s, pixw, pixh));
}
}
void StickerPanInner::updateSelected() {
if (_pressedSel >= 0) return;
@ -1605,7 +1646,7 @@ void StickerPanInner::showStickerSet(uint64 setId) {
}
EmojiPan::EmojiPan(QWidget *parent) : TWidget(parent),
_noTabUpdate(false), _hiding(false), a_opacity(0), _shadow(st::dropdownDef.shadow),
_horizontal(false), _noTabUpdate(false), _hiding(false), a_opacity(0), _shadow(st::dropdownDef.shadow),
_recent(this , qsl("emoji_group"), dbietRecent , QString(), true , st::rbEmojiRecent),
_people(this , qsl("emoji_group"), dbietPeople , QString(), false, st::rbEmojiPeople),
_nature(this , qsl("emoji_group"), dbietNature , QString(), false, st::rbEmojiNature),
@ -1614,6 +1655,9 @@ _celebration(this, qsl("emoji_group"), dbietCelebration, QString(), false, st::r
_activity(this , qsl("emoji_group"), dbietActivity , QString(), false, st::rbEmojiActivity),
_travel(this , qsl("emoji_group"), dbietTravel , QString(), false, st::rbEmojiTravel),
_objects(this , qsl("emoji_group"), dbietObjects , QString(), false, st::rbEmojiObjects),
_iconOver(-1), _iconSel(0), _iconDown(-1), _iconsDragging(false),
_iconAnim(animFunc(this, &EmojiPan::iconAnim)),
_iconsLeft(0), _iconsTop(0), _iconsX(0), _iconsStartX(0), _iconsMax(0),
_stickersShown(false), _moveStart(0),
e_scroll(this, st::emojiScroll), e_inner(), s_scroll(this, st::emojiScroll), s_inner(), _removingSetId(0) {
setFocusPolicy(Qt::NoFocus);
@ -1626,8 +1670,8 @@ e_scroll(this, st::emojiScroll), e_inner(), s_scroll(this, st::emojiScroll), s_i
_height = st::dropdownDef.padding.top() + st::emojiPanFullSize.height() + st::dropdownDef.padding.bottom();
resize(_width, _height);
e_scroll.resize(st::emojiPanFullSize.width(), st::emojiPanFullSize.height() - _recent.height());
s_scroll.resize(st::emojiPanFullSize.width(), st::emojiPanFullSize.height());
e_scroll.resize(st::emojiPanFullSize.width(), st::emojiPanFullSize.height() - st::rbEmoji.height);
s_scroll.resize(st::emojiPanFullSize.width(), st::emojiPanFullSize.height() - st::rbEmoji.height);
e_scroll.move(st::dropdownDef.padding.left(), st::dropdownDef.padding.top());
e_scroll.setWidget(&e_inner);
@ -1639,8 +1683,8 @@ e_scroll(this, st::emojiScroll), e_inner(), s_scroll(this, st::emojiScroll), s_i
s_inner.setAttribute(Qt::WA_OpaquePaintEvent);
s_scroll.setAutoFillBackground(true);
int32 left = st::dropdownDef.padding.left() + (st::emojiPanFullSize.width() - 8 * _recent.width()) / 2;
int32 top = st::dropdownDef.padding.top() + st::emojiPanFullSize.height() - _recent.height();
int32 left = _iconsLeft = st::dropdownDef.padding.left() + (st::emojiPanFullSize.width() - 8 * st::rbEmoji.width) / 2;
int32 top = _iconsTop = st::dropdownDef.padding.top() + st::emojiPanFullSize.height() - st::rbEmoji.height;
prepareTab(left, top, _width, _recent);
prepareTab(left, top, _width, _people);
prepareTab(left, top, _width, _nature);
@ -1668,10 +1712,14 @@ e_scroll(this, st::emojiScroll), e_inner(), s_scroll(this, st::emojiScroll), s_i
connect(&s_inner, SIGNAL(switchToEmoji()), this, SLOT(onSwitch()));
connect(&s_inner, SIGNAL(removing(uint64)), this, SLOT(onRemoveSet(uint64)));
connect(&s_inner, SIGNAL(refreshIcons()), this, SLOT(onRefreshIcons()));
if (cPlatform() == dbipMac) {
connect(App::wnd()->windowHandle(), SIGNAL(activeChanged()), this, SLOT(onWndActiveChanged()));
}
setMouseTracking(true);
setAttribute(Qt::WA_AcceptTouchEvents);
}
void EmojiPan::prepareTab(int32 &left, int32 top, int32 _width, FlatRadiobutton &tab) {
@ -1688,7 +1736,7 @@ void EmojiPan::onWndActiveChanged() {
}
void EmojiPan::paintEvent(QPaintEvent *e) {
QPainter p(this);
Painter p(this);
float64 o = 1;
if (!_cache.isNull()) {
@ -1701,17 +1749,65 @@ void EmojiPan::paintEvent(QPaintEvent *e) {
if (_toCache.isNull()) {
if (_cache.isNull()) {
if (!_stickersShown) {
p.fillRect(r.left(), _recent.y(), (rtl() ? _objects.x() : _recent.x() - r.left()), _recent.height(), st::emojiPanCategories->b);
if (_stickersShown) {
p.fillRect(r.left(), _iconsTop, r.width(), st::rbEmoji.height, st::emojiPanCategories->b);
if (!_icons.isEmpty()) {
int32 x = _iconsLeft, i = 0;
if (!_icons.at(i).sticker) {
if (_iconSel == i) {
p.fillRect(rtl() ? (width() - x - st::rbEmoji.width) : x, _iconsTop, st::rbEmoji.width, st::rbEmoji.height, st::stickerIconSel->b);
} else if (_iconHovers.at(i) > 0) {
p.setOpacity(_iconHovers.at(i));
p.fillRect(rtl() ? (width() - x - st::rbEmoji.width) : x, _iconsTop, st::rbEmoji.width, st::rbEmoji.height, st::stickerIconHover->b);
p.setOpacity(1);
}
p.drawSpriteLeft(x + st::rbEmojiRecent.imagePos.x(), _iconsTop + st::rbEmojiRecent.imagePos.y(), width(), st::stickerIconRecent);
x += st::rbEmoji.width;
++i;
}
QRect clip(x, _iconsTop, _iconsLeft + 8 * st::rbEmoji.width - x, st::rbEmoji.height);
if (rtl()) clip.moveLeft(width() - x - clip.width());
p.setClipRect(clip);
i += _iconsX / int(st::rbEmoji.width);
x -= _iconsX % int(st::rbEmoji.width);
for (int32 l = qMin(_icons.size(), i + 8 + (_icons.at(0).sticker ? 1 : 0)); i < l; ++i) {
const StickerIcon &s(_icons.at(i));
QPixmap pix(s.sticker->thumb->pix(s.pixw, s.pixh));
if (_iconSel == i) {
p.fillRect(rtl() ? (width() - x - st::rbEmoji.width) : x, _iconsTop, st::rbEmoji.width, st::rbEmoji.height, st::stickerIconSel->b);
} else if (_iconHovers.at(i) > 0) {
p.setOpacity(_iconHovers.at(i));
p.fillRect(rtl() ? (width() - x - st::rbEmoji.width) : x, _iconsTop, st::rbEmoji.width, st::rbEmoji.height, st::stickerIconHover->b);
p.setOpacity(1);
}
p.drawPixmapLeft(x + (st::rbEmoji.width - s.pixw) / 2, _iconsTop + (st::rbEmoji.height - s.pixh) / 2, width(), pix);
x += st::rbEmoji.width;
}
float64 o_left = snap(float64(_iconsX) / st::stickerIconLeft.pxWidth(), 0., 1.);
if (o_left > 0) {
p.setOpacity(o_left);
p.drawSpriteLeft(QRect(_iconsLeft + (_icons.at(0).sticker ? 0 : st::rbEmoji.width), _iconsTop, st::stickerIconLeft.pxWidth(), st::rbEmoji.height), width(), st::stickerIconLeft);
}
float64 o_right = snap(float64(_iconsMax - _iconsX) / st::stickerIconRight.pxWidth(), 0., 1.);
if (o_right > 0) {
p.setOpacity(o_right);
p.drawSpriteRight(QRect(width() - _iconsLeft - 8 * st::rbEmoji.width, _iconsTop, st::stickerIconRight.pxWidth(), st::rbEmoji.height), width(), st::stickerIconRight);
}
}
} else {
p.fillRect(r.left(), _recent.y(), (rtl() ? _objects.x() : _recent.x() - r.left()), st::rbEmoji.height, st::emojiPanCategories->b);
int32 x = rtl() ? (_recent.x() + _recent.width()) : (_objects.x() + _objects.width());
p.fillRect(x, _recent.y(), r.left() + r.width() - x, _recent.height(), st::emojiPanCategories->b);
p.fillRect(x, _recent.y(), r.left() + r.width() - x, st::rbEmoji.height, st::emojiPanCategories->b);
}
} else {
p.fillRect(r, st::white->b);
p.drawPixmap(r.left(), r.top(), _cache);
}
} else {
p.fillRect(r, st::white->b);
p.fillRect(QRect(r.left(), r.top(), r.width(), r.height() - st::rbEmoji.height), st::white->b);
p.fillRect(QRect(r.left(), _iconsTop, r.width(), st::rbEmoji.height), st::emojiPanCategories->b);
p.setOpacity(o * a_fromAlpha.current());
QRect fromDst = QRect(r.left() + a_fromCoord.current(), r.top(), _fromCache.width() / cIntRetinaFactor(), _fromCache.height() / cIntRetinaFactor());
QRect fromSrc = QRect(0, 0, _fromCache.width(), _fromCache.height());
@ -1768,6 +1864,78 @@ void EmojiPan::otherLeave() {
}
}
void EmojiPan::mousePressEvent(QMouseEvent *e) {
if (!_stickersShown || _icons.isEmpty()) return;
_iconsMousePos = e ? e->globalPos() : QCursor::pos();
updateSelected();
_iconDown = _iconOver;
_iconsMouseDown = _iconsMousePos;
_iconsStartX = _iconsX;
}
void EmojiPan::mouseMoveEvent(QMouseEvent *e) {
if (!_stickersShown || _icons.isEmpty()) return;
_iconsMousePos = e ? e->globalPos() : QCursor::pos();
updateSelected();
if (!_iconsDragging && _iconDown >= (_icons.at(0).sticker ? 0 : 1)) {
if ((_iconsMousePos - _iconsMouseDown).manhattanLength() >= QApplication::startDragDistance()) {
_iconsDragging = true;
}
}
if (_iconsDragging) {
int32 newX = snap(_iconsStartX + _iconsMouseDown.x() - _iconsMousePos.x(), 0, _iconsMax);
if (newX != _iconsX) {
_iconsX = newX;
updateIcons();
}
}
}
void EmojiPan::mouseReleaseEvent(QMouseEvent *e) {
if (!_stickersShown || _icons.isEmpty()) return;
int32 wasDown = _iconDown;
_iconDown = -1;
_iconsMousePos = e ? e->globalPos() : QCursor::pos();
if (_iconsDragging) {
int32 newX = snap(_iconsStartX + _iconsMouseDown.x() - _iconsMousePos.x(), 0, _iconsMax);
if (newX != _iconsX) {
_iconsX = newX;
updateIcons();
}
_iconsDragging = false;
updateSelected();
} else {
updateSelected();
if (wasDown == _iconOver && _iconOver >= 0) {
s_inner.showStickerSet(_icons.at(_iconOver).setId);
}
}
}
bool EmojiPan::event(QEvent *e) {
if (e->type() == QEvent::TouchBegin) {
int a = 0;
} else if (e->type() == QEvent::Wheel && _iconOver >= ((_icons.isEmpty() || _icons.at(0).sticker) ? 0 : 1)) {
QWheelEvent *ev = static_cast<QWheelEvent*>(e);
if (ev->angleDelta().x() != 0 || ev->orientation() == Qt::Horizontal) _horizontal = true;
if (/*_horizontal && */ev->orientation() == Qt::Horizontal) {
_iconsX = snap(_iconsX - (rtl() ? -1 : 1) * ev->angleDelta().x(), 0, _iconsMax);
updateSelected();
updateIcons();
} else if (/*!_horizontal && */ev->orientation() == Qt::Vertical) {
_iconsX = snap(_iconsX - ev->angleDelta().y(), 0, _iconsMax);
updateSelected();
updateIcons();
}
}
return TWidget::event(e);
}
void EmojiPan::fastHide() {
if (animating()) {
anim::stop(this);
@ -1785,6 +1953,103 @@ void EmojiPan::refreshStickers() {
}
}
void EmojiPan::onRefreshIcons() {
_iconOver = -1;
_iconHovers.clear();
_iconAnimations.clear();
s_inner.fillIcons(_icons);
_iconsX = 0;
if (_icons.isEmpty()) {
_iconsMax = 0;
} else {
_iconHovers = QVector<float64>(_icons.size(), 0);
_iconsMax = qMax(int((_icons.size() - 8) * st::rbEmoji.width), 0);
}
updateSelected();
updateIcons();
}
void EmojiPan::leaveToChildEvent(QEvent *e) {
if (!_stickersShown) return;
_iconsMousePos = QCursor::pos();
updateSelected();
}
void EmojiPan::updateSelected() {
if (_icons.isEmpty() || _iconDown >= 0) return;
QPoint p(mapFromGlobal(_iconsMousePos));
int32 x = p.x(), y = p.y(), newOver = -1;
if (rtl()) x = width() - x;
x -= _iconsLeft;
if (y >= _iconsTop && y < _iconsTop + st::rbEmoji.height && x >= 0 && x < 8 * st::rbEmoji.width && x < _icons.size() * st::rbEmoji.width) {
if (!_icons.at(0).sticker) {
if (x < st::rbEmoji.width) {
newOver = 0;
} else {
x -= st::rbEmoji.width;
}
}
if (newOver < 0) {
x += _iconsX;
newOver = qFloor(x / st::rbEmoji.width) + (_icons.at(0).sticker ? 0 : 1);
}
}
if (newOver != _iconOver) {
if (newOver < 0) {
setCursor(style::cur_default);
} else if (_iconOver < 0) {
setCursor(style::cur_pointer);
}
bool startanim = false;
if (_iconOver >= 0) {
_iconAnimations.remove(_iconOver + 1);
if (_iconAnimations.find(-_iconOver - 1) == _iconAnimations.end()) {
if (_iconAnimations.isEmpty()) startanim = true;
_iconAnimations.insert(-_iconOver - 1, getms());
}
}
_iconOver = newOver;
if (_iconOver >= 0) {
_iconAnimations.remove(-_iconOver - 1);
if (_iconAnimations.find(_iconOver + 1) == _iconAnimations.end()) {
if (_iconAnimations.isEmpty()) startanim = true;
_iconAnimations.insert(_iconOver + 1, getms());
}
}
if (startanim) _iconAnim.start();
}
}
void EmojiPan::updateIcons() {
QRect r(st::dropdownDef.padding.left(), st::dropdownDef.padding.top(), _width - st::dropdownDef.padding.left() - st::dropdownDef.padding.right(), _height - st::dropdownDef.padding.top() - st::dropdownDef.padding.bottom());
update(r.left(), _iconsTop, r.width(), st::rbEmoji.height);
}
bool EmojiPan::iconAnim(float64 ms) {
if (!_stickersShown) return false;
uint64 now = getms();
for (Animations::iterator i = _iconAnimations.begin(); i != _iconAnimations.end();) {
int index = qAbs(i.key()) - 1;
float64 dt = float64(now - i.value()) / st::emojiPanDuration;
if (index >= _iconHovers.size()) {
i = _iconAnimations.erase(i);
} else if (dt >= 1) {
_iconHovers[index] = (i.key() > 0) ? 1 : 0;
i = _iconAnimations.erase(i);
} else {
_iconHovers[index] = (i.key() > 0) ? dt : (1 - dt);
++i;
}
}
updateIcons();
return !_iconAnimations.isEmpty();
}
bool EmojiPan::animStep(float64 ms) {
bool res1 = false;
if (_moveStart) {
@ -1847,9 +2112,20 @@ void EmojiPan::hideFinish() {
e_inner.hideFinish();
_cache = _toCache = _fromCache = QPixmap();
_moveStart = 0;
_horizontal = false;
e_scroll.scrollToY(0);
if (!_recent.checked()) {
_noTabUpdate = true;
_recent.setChecked(true);
_noTabUpdate = false;
}
s_scroll.scrollToY(0);
_iconOver = _iconDown = -1;
_iconSel = 0;
_iconsX = 0;
_iconHovers = _icons.isEmpty() ? QVector<float64>() : QVector<float64>(_icons.size(), 0);
_iconAnimations.clear();
}
void EmojiPan::showStart() {
@ -1971,25 +2247,45 @@ void EmojiPan::onTabChange() {
void EmojiPan::onScroll() {
int top = e_scroll.scrollTop();
DBIEmojiTab tab = e_inner.currentTab(top);
FlatRadiobutton *check = 0;
switch (tab) {
case dbietRecent : check = &_recent ; break;
case dbietPeople : check = &_people ; break;
case dbietNature : check = &_nature ; break;
case dbietFood : check = &_food ; break;
case dbietCelebration: check = &_celebration; break;
case dbietActivity : check = &_activity ; break;
case dbietTravel : check = &_travel ; break;
case dbietObjects : check = &_objects ; break;
}
if (check && !check->checked()) {
_noTabUpdate = true;
check->setChecked(true);
_noTabUpdate = false;
if (!_stickersShown) {
DBIEmojiTab tab = e_inner.currentTab(top);
FlatRadiobutton *check = 0;
switch (tab) {
case dbietRecent : check = &_recent ; break;
case dbietPeople : check = &_people ; break;
case dbietNature : check = &_nature ; break;
case dbietFood : check = &_food ; break;
case dbietCelebration: check = &_celebration; break;
case dbietActivity : check = &_activity ; break;
case dbietTravel : check = &_travel ; break;
case dbietObjects : check = &_objects ; break;
}
if (check && !check->checked()) {
_noTabUpdate = true;
check->setChecked(true);
_noTabUpdate = false;
}
}
e_inner.setScrollTop(top);
s_inner.setScrollTop(s_scroll.scrollTop());
top = s_scroll.scrollTop();
if (_stickersShown) {
uint64 setId = s_inner.currentSet(top);
int32 newSel = 0;
for (int32 i = 0, l = _icons.size(); i < l; ++i) {
if (_icons.at(i).setId == setId) {
newSel = i;
break;
}
}
if (newSel != _iconSel) {
_iconSel = newSel;
_iconsX = snap((2 * newSel - 7 - ((_icons.isEmpty() || _icons.at(0).sticker) ? 0 : 1)) * int(st::rbEmoji.width) / 2, 0, _iconsMax);
updateSelected();
updateIcons();
}
}
s_inner.setScrollTop(top);
}
void EmojiPan::onSwitch() {
@ -1997,6 +2293,11 @@ void EmojiPan::onSwitch() {
_fromCache = myGrab(this, rect().marginsRemoved(st::dropdownDef.padding));
_stickersShown = !_stickersShown;
_iconOver = -1;
_iconHovers = _icons.isEmpty() ? QVector<float64>() : QVector<float64>(_icons.size(), 0);
_iconAnimations.clear();
_iconAnim.stop();
_cache = QPixmap();
showAll();
_toCache = myGrab(this, rect().marginsRemoved(st::dropdownDef.padding));

View File

@ -269,6 +269,16 @@ private:
int32 _stickersWidth;
};
struct StickerIcon {
StickerIcon() : setId(RecentStickerSetId), sticker(0), pixw(0), pixh(0) {
}
StickerIcon(uint64 setId, DocumentData *sticker, int32 pixw, int32 pixh) : setId(setId), sticker(sticker), pixw(pixw), pixh(pixh) {
}
uint64 setId;
DocumentData *sticker;
int32 pixw, pixh;
};
class StickerPanInner : public TWidget, public Animated {
Q_OBJECT
@ -294,9 +304,13 @@ public:
void refreshStickers();
void refreshRecent(bool resize = true);
void fillIcons(QVector<StickerIcon> &icons);
void setScrollTop(int top);
void preloadImages();
uint64 currentSet(int yOffset) const;
public slots:
void updateSelected();
@ -306,6 +320,8 @@ signals:
void selected(DocumentData *sticker);
void removing(uint64 setId);
void refreshIcons();
void switchToEmoji();
void scrollToY(int y);
@ -349,6 +365,12 @@ public:
void otherEnter();
void otherLeave();
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
bool event(QEvent *e);
void fastHide();
bool hiding() const {
return _hiding || _hideTimer.isActive();
@ -356,6 +378,8 @@ public:
bool animStep(float64 ms);
bool iconAnim(float64 ms);
bool eventFilter(QObject *obj, QEvent *e);
void stickersInstalled(uint64 setId);
@ -377,6 +401,8 @@ public slots:
void onRemoveSetSure();
void onDelayedHide();
void onRefreshIcons();
signals:
void emojiSelected(EmojiPtr emoji);
@ -385,6 +411,13 @@ signals:
private:
bool _horizontal;
void leaveToChildEvent(QEvent *e);
void updateSelected();
void updateIcons();
void prepareTab(int32 &left, int32 top, int32 _width, FlatRadiobutton &tab);
void showAll();
@ -403,6 +436,16 @@ private:
BoxShadow _shadow;
FlatRadiobutton _recent, _people, _nature, _food, _celebration, _activity, _travel, _objects;
QVector<StickerIcon> _icons;
QVector<float64> _iconHovers;
int32 _iconOver, _iconSel, _iconDown;
bool _iconsDragging;
typedef QMap<int32, uint64> Animations; // index - showing, -index - hiding
Animations _iconAnimations;
Animation _iconAnim;
QPoint _iconsMousePos, _iconsMouseDown;
int32 _iconsLeft, _iconsTop;
int32 _iconsX, _iconsStartX, _iconsMax;
bool _stickersShown;
QPixmap _fromCache, _toCache;

View File

@ -56,6 +56,12 @@ public:
void drawPixmapLeft(const QPoint &p, int outerw, const QPixmap &pix, const QRect &from) {
return drawPixmapLeft(p.x(), p.y(), outerw, pix, from);
}
void drawPixmapLeft(int x, int y, int w, int h, int outerw, const QPixmap &pix, const QRect &from) {
drawPixmap(QRect(rtl() ? (outerw - x - w) : x, y, w, h), pix, from);
}
void drawPixmapLeft(const QRect &r, int outerw, const QPixmap &pix, const QRect &from) {
return drawPixmapLeft(r.x(), r.y(), r.width(), r.height(), outerw, pix, from);
}
void drawPixmapLeft(int x, int y, int outerw, const QPixmap &pix) {
drawPixmap(QPoint(rtl() ? (outerw - x - (pix.width() / pix.devicePixelRatio())) : x, y), pix);
}
@ -68,6 +74,12 @@ public:
void drawPixmapRight(const QPoint &p, int outerw, const QPixmap &pix, const QRect &from) {
return drawPixmapRight(p.x(), p.y(), outerw, pix, from);
}
void drawPixmapRight(int x, int y, int w, int h, int outerw, const QPixmap &pix, const QRect &from) {
drawPixmap(QRect(rtl() ? x : (outerw - x - w), y, w, h), pix, from);
}
void drawPixmapRight(const QRect &r, int outerw, const QPixmap &pix, const QRect &from) {
return drawPixmapRight(r.x(), r.y(), r.width(), r.height(), outerw, pix, from);
}
void drawPixmapRight(int x, int y, int outerw, const QPixmap &pix) {
drawPixmap(QPoint(rtl() ? x : (outerw - x - (pix.width() / pix.devicePixelRatio())), y), pix);
}
@ -86,12 +98,24 @@ public:
void drawSpriteLeft(const QPoint &p, int outerw, const style::sprite &sprite) {
return drawPixmapLeft(p, outerw, App::sprite(), sprite);
}
void drawSpriteLeft(int x, int y, int w, int h, int outerw, const style::sprite &sprite) {
return drawPixmapLeft(x, y, w, h, outerw, App::sprite(), sprite);
}
void drawSpriteLeft(const QRect &r, int outerw, const style::sprite &sprite) {
return drawPixmapLeft(r, outerw, App::sprite(), sprite);
}
void drawSpriteRight(int x, int y, int outerw, const style::sprite &sprite) {
return drawPixmapRight(x, y, outerw, App::sprite(), sprite);
}
void drawSpriteRight(const QPoint &p, int outerw, const style::sprite &sprite) {
return drawPixmapRight(p, outerw, App::sprite(), sprite);
}
void drawSpriteRight(int x, int y, int w, int h, int outerw, const style::sprite &sprite) {
return drawPixmapRight(x, y, w, h, outerw, App::sprite(), sprite);
}
void drawSpriteRight(const QRect &r, int outerw, const style::sprite &sprite) {
return drawPixmapRight(r, outerw, App::sprite(), sprite);
}
void drawSpriteCenter(const QRect &in, const style::sprite &sprite) {
return drawPixmap(QPoint(in.x() + (in.width() - sprite.pxWidth()) / 2, in.y() + (in.height() - sprite.pxHeight()) / 2), App::sprite(), sprite);
}