mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
Top bar buttons design improved, emoji pan animations removed.
This commit is contained in:
parent
d313bd56a6
commit
2ada4d841f
20 changed files with 244 additions and 526 deletions
|
@ -471,10 +471,6 @@ toastPadding: margins(19px, 13px, 19px, 12px);
|
||||||
toastFadeInDuration: 200;
|
toastFadeInDuration: 200;
|
||||||
toastFadeOutDuration: 1000;
|
toastFadeOutDuration: 1000;
|
||||||
|
|
||||||
// forward declaration for single "title_back" usage.
|
|
||||||
profileTopBarBackIconFg: #0290d7;
|
|
||||||
profileTopBarBackIcon: icon {{ "title_back", profileTopBarBackIconFg }};
|
|
||||||
|
|
||||||
historyReplyCancelIcon: icon {{ "box_button_close", historyReplyCancelFg }};
|
historyReplyCancelIcon: icon {{ "box_button_close", historyReplyCancelFg }};
|
||||||
historyReplyCancelIconOver: icon {{ "box_button_close", historyReplyCancelFgOver }};
|
historyReplyCancelIconOver: icon {{ "box_button_close", historyReplyCancelFgOver }};
|
||||||
boxSearchCancelIcon: icon {{ "box_button_close", boxSearchCancelIconFg }};
|
boxSearchCancelIcon: icon {{ "box_button_close", boxSearchCancelIconFg }};
|
||||||
|
|
BIN
Telegram/Resources/icons/box_button_back.png
Normal file
BIN
Telegram/Resources/icons/box_button_back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 218 B |
BIN
Telegram/Resources/icons/box_button_back@2x.png
Normal file
BIN
Telegram/Resources/icons/box_button_back@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 282 B |
|
@ -116,11 +116,7 @@ boxLabel: FlatLabel(defaultFlatLabel) {
|
||||||
align: align(topleft);
|
align: align(topleft);
|
||||||
}
|
}
|
||||||
|
|
||||||
boxScroll: FlatScroll(defaultSolidScroll) {
|
boxScroll: defaultSolidScroll;
|
||||||
round: 3px;
|
|
||||||
width: 18px;
|
|
||||||
deltax: 6px;
|
|
||||||
}
|
|
||||||
boxScrollSkip: 6px;
|
boxScrollSkip: 6px;
|
||||||
boxScrollShadowBg: #00000012;
|
boxScrollShadowBg: #00000012;
|
||||||
|
|
||||||
|
@ -353,11 +349,7 @@ notificationSampleSize: size(64px, 16px);
|
||||||
|
|
||||||
membersAboutLimitPadding: margins(0px, 12px, 0px, 12px);
|
membersAboutLimitPadding: margins(0px, 12px, 0px, 12px);
|
||||||
|
|
||||||
sessionsScroll: FlatScroll(boxScroll) {
|
sessionsScroll: boxScroll;
|
||||||
round: 2px;
|
|
||||||
deltax: 5px;
|
|
||||||
width: 14px;
|
|
||||||
}
|
|
||||||
sessionsHeight: 440px;
|
sessionsHeight: 440px;
|
||||||
sessionHeight: 70px;
|
sessionHeight: 70px;
|
||||||
sessionCurrentPadding: margins(0px, 7px, 0px, 4px);
|
sessionCurrentPadding: margins(0px, 7px, 0px, 4px);
|
||||||
|
@ -482,9 +474,6 @@ langsButton: Radiobutton(defaultRadiobutton) {
|
||||||
backgroundPadding: 10px;
|
backgroundPadding: 10px;
|
||||||
backgroundSize: size(108px, 193px);
|
backgroundSize: size(108px, 193px);
|
||||||
backgroundScroll: FlatScroll(boxScroll) {
|
backgroundScroll: FlatScroll(boxScroll) {
|
||||||
round: 2px;
|
|
||||||
width: 10px;
|
|
||||||
deltax: 3px;
|
|
||||||
deltat: 10px;
|
deltat: 10px;
|
||||||
deltab: 0px;
|
deltab: 0px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,10 +390,7 @@ botKbTinyButton: BotKeyboardButton {
|
||||||
textTop: 2px;
|
textTop: 2px;
|
||||||
ripple: defaultRippleAnimation;
|
ripple: defaultRippleAnimation;
|
||||||
}
|
}
|
||||||
botKbScroll: FlatScroll(defaultSolidScroll) {
|
botKbScroll: defaultSolidScroll;
|
||||||
deltax: 3px;
|
|
||||||
width: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
mentionHeight: 40px;
|
mentionHeight: 40px;
|
||||||
mentionScroll: FlatScroll(defaultFlatScroll) {
|
mentionScroll: FlatScroll(defaultFlatScroll) {
|
||||||
|
|
|
@ -6304,7 +6304,7 @@ void HistoryWidget::onForwardHere() {
|
||||||
App::forward(_peer->id, ForwardContextMessage);
|
App::forward(_peer->id, ForwardContextMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::paintTopBar(Painter &p, float64 over, int32 decreaseWidth) {
|
bool HistoryWidget::paintTopBar(Painter &p, int decreaseWidth) {
|
||||||
if (_a_show.animating()) {
|
if (_a_show.animating()) {
|
||||||
int retina = cIntRetinaFactor();
|
int retina = cIntRetinaFactor();
|
||||||
if (a_coordOver.current() > 0) {
|
if (a_coordOver.current() > 0) {
|
||||||
|
@ -6337,9 +6337,7 @@ bool HistoryWidget::paintTopBar(Painter &p, float64 over, int32 decreaseWidth) {
|
||||||
_peer->dialogName().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
_peer->dialogName().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||||
|
|
||||||
if (Adaptive::OneColumn() || !App::main()->stackIsEmpty()) {
|
if (Adaptive::OneColumn() || !App::main()->stackIsEmpty()) {
|
||||||
p.setOpacity(st::topBarForwardAlpha + (1 - st::topBarForwardAlpha) * over);
|
|
||||||
st::topBarBackward.paint(p, (st::topBarArrowPadding.left() - st::topBarBackward.width()) / 2, (st::topBarHeight - st::topBarBackward.height()) / 2, width());
|
st::topBarBackward.paint(p, (st::topBarArrowPadding.left() - st::topBarBackward.width()) / 2, (st::topBarHeight - st::topBarBackward.height()) / 2, width());
|
||||||
p.setOpacity(1.);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,7 +550,7 @@ public:
|
||||||
|
|
||||||
void updateTopBarSelection();
|
void updateTopBarSelection();
|
||||||
|
|
||||||
bool paintTopBar(Painter &p, float64 over, int32 decreaseWidth);
|
bool paintTopBar(Painter &p, int decreaseWidth);
|
||||||
QRect getMembersShowAreaGeometry() const;
|
QRect getMembersShowAreaGeometry() const;
|
||||||
void setMembersShowAreaActive(bool active);
|
void setMembersShowAreaActive(bool active);
|
||||||
void topBarClick();
|
void topBarClick();
|
||||||
|
|
|
@ -2976,11 +2976,11 @@ bool MainWidget::needBackButton() {
|
||||||
return _overview || _wideSection || _history->peer();
|
return _overview || _wideSection || _history->peer();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::paintTopBar(Painter &p, float64 over, int32 decreaseWidth) {
|
bool MainWidget::paintTopBar(Painter &p, int decreaseWidth) {
|
||||||
if (_overview) {
|
if (_overview) {
|
||||||
return _overview->paintTopBar(p, over, decreaseWidth);
|
return _overview->paintTopBar(p, decreaseWidth);
|
||||||
} else if (!_wideSection) {
|
} else if (!_wideSection) {
|
||||||
return _history->paintTopBar(p, over, decreaseWidth);
|
return _history->paintTopBar(p, decreaseWidth);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ public:
|
||||||
bool needBackButton();
|
bool needBackButton();
|
||||||
|
|
||||||
// Temporary methods, while top bar was not done inside HistoryWidget / OverviewWidget.
|
// Temporary methods, while top bar was not done inside HistoryWidget / OverviewWidget.
|
||||||
bool paintTopBar(Painter &p, float64 over, int32 decreaseWidth);
|
bool paintTopBar(Painter &, int decreaseWidth);
|
||||||
QRect getMembersShowAreaGeometry() const;
|
QRect getMembersShowAreaGeometry() const;
|
||||||
void setMembersShowAreaActive(bool active);
|
void setMembersShowAreaActive(bool active);
|
||||||
Window::TopBarWidget *topBar();
|
Window::TopBarWidget *topBar();
|
||||||
|
|
|
@ -1971,7 +1971,7 @@ void OverviewWidget::scrollReset() {
|
||||||
_scroll->scrollToY((type() == OverviewMusicFiles || type() == OverviewVoiceFiles) ? _scroll->scrollTopMax() : 0);
|
_scroll->scrollToY((type() == OverviewMusicFiles || type() == OverviewVoiceFiles) ? _scroll->scrollTopMax() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OverviewWidget::paintTopBar(Painter &p, float64 over, int32 decreaseWidth) {
|
bool OverviewWidget::paintTopBar(Painter &p, int decreaseWidth) {
|
||||||
if (_a_show.animating()) {
|
if (_a_show.animating()) {
|
||||||
int retina = cIntRetinaFactor();
|
int retina = cIntRetinaFactor();
|
||||||
if (a_coordOver.current() > 0) {
|
if (a_coordOver.current() > 0) {
|
||||||
|
@ -1985,12 +1985,10 @@ bool OverviewWidget::paintTopBar(Painter &p, float64 over, int32 decreaseWidth)
|
||||||
st::slideShadow.fill(p, QRect(a_coordOver.current() - st::slideShadow.width(), 0, st::slideShadow.width(), st::topBarHeight));
|
st::slideShadow.fill(p, QRect(a_coordOver.current() - st::slideShadow.width(), 0, st::slideShadow.width(), st::topBarHeight));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
p.setOpacity(st::topBarBackAlpha + (1 - st::topBarBackAlpha) * over);
|
|
||||||
st::topBarBack.paint(p, (st::topBarArrowPadding.left() - st::topBarBack.width()) / 2, (st::topBarHeight - st::topBarBack.height()) / 2, width());
|
st::topBarBack.paint(p, (st::topBarArrowPadding.left() - st::topBarBack.width()) / 2, (st::topBarHeight - st::topBarBack.height()) / 2, width());
|
||||||
p.setFont(st::topBarBackFont);
|
p.setFont(st::defaultLightButton.font);
|
||||||
p.setPen(st::topBarBackColor);
|
p.setPen(st::defaultLightButton.textFg);
|
||||||
p.drawText(st::topBarArrowPadding.left(), (st::topBarHeight - st::topBarBackFont->height) / 2 + st::topBarBackFont->ascent, _header);
|
p.drawTextLeft(st::topBarArrowPadding.left(), st::topBarButton.padding.top() + st::topBarButton.textTop, width(), _header);
|
||||||
p.setOpacity(1.);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2025,6 +2023,8 @@ void OverviewWidget::switchType(MediaOverviewType type) {
|
||||||
case OverviewVoiceFiles: _header = lang(lng_profile_audios_header); break;
|
case OverviewVoiceFiles: _header = lang(lng_profile_audios_header); break;
|
||||||
case OverviewLinks: _header = lang(lng_profile_shared_links_header); break;
|
case OverviewLinks: _header = lang(lng_profile_shared_links_header); break;
|
||||||
}
|
}
|
||||||
|
_header = _header.toUpper();
|
||||||
|
|
||||||
noSelectingScroll();
|
noSelectingScroll();
|
||||||
App::main()->topBar()->showSelected(0);
|
App::main()->topBar()->showSelected(0);
|
||||||
updateTopBarSelection();
|
updateTopBarSelection();
|
||||||
|
|
|
@ -281,7 +281,7 @@ public:
|
||||||
void scrollBy(int32 add);
|
void scrollBy(int32 add);
|
||||||
void scrollReset();
|
void scrollReset();
|
||||||
|
|
||||||
bool paintTopBar(Painter &p, float64 over, int32 decreaseWidth);
|
bool paintTopBar(Painter &p, int decreaseWidth);
|
||||||
void topBarClick();
|
void topBarClick();
|
||||||
|
|
||||||
PeerData *peer() const;
|
PeerData *peer() const;
|
||||||
|
|
|
@ -26,10 +26,6 @@ using "window/window.style";
|
||||||
profileBg: windowBg;
|
profileBg: windowBg;
|
||||||
|
|
||||||
profileTopBarHeight: topBarHeight;
|
profileTopBarHeight: topBarHeight;
|
||||||
profileTopBarBackIconPosition: point(12px, 20px);
|
|
||||||
profileTopBarBackFont: font(14px);
|
|
||||||
profileTopBarBackFg: #1485c2;
|
|
||||||
profileTopBarBackPosition: point(39px, 17px);
|
|
||||||
profileFixedBarButton: topBarButton;
|
profileFixedBarButton: topBarButton;
|
||||||
|
|
||||||
profileMarginTop: 13px;
|
profileMarginTop: 13px;
|
||||||
|
|
|
@ -36,7 +36,8 @@ namespace Profile {
|
||||||
|
|
||||||
class BackButton final : public Ui::AbstractButton, private base::Subscriber {
|
class BackButton final : public Ui::AbstractButton, private base::Subscriber {
|
||||||
public:
|
public:
|
||||||
BackButton(QWidget *parent) : Ui::AbstractButton(parent) {
|
BackButton(QWidget *parent) : Ui::AbstractButton(parent)
|
||||||
|
, _text(lang(lng_menu_back).toUpper()) {
|
||||||
setCursor(style::cur_pointer);
|
setCursor(style::cur_pointer);
|
||||||
|
|
||||||
subscribe(Adaptive::Changed(), [this] { updateAdaptiveLayout(); });
|
subscribe(Adaptive::Changed(), [this] { updateAdaptiveLayout(); });
|
||||||
|
@ -51,11 +52,11 @@ protected:
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
|
||||||
p.fillRect(e->rect(), st::profileBg);
|
p.fillRect(e->rect(), st::profileBg);
|
||||||
st::profileTopBarBackIcon.paint(p, st::profileTopBarBackIconPosition, width());
|
st::topBarBack.paint(p, (st::topBarArrowPadding.left() - st::topBarBack.width()) / 2, (st::topBarHeight - st::topBarBack.height()) / 2, width());
|
||||||
|
|
||||||
p.setFont(st::profileTopBarBackFont);
|
p.setFont(st::topBarButton.font);
|
||||||
p.setPen(st::profileTopBarBackFg);
|
p.setPen(st::topBarButton.textFg);
|
||||||
p.drawTextLeft(st::profileTopBarBackPosition.x(), st::profileTopBarBackPosition.y(), width(), lang(lng_menu_back));
|
p.drawTextLeft(st::topBarArrowPadding.left(), st::topBarButton.padding.top() + st::topBarButton.textTop, width(), _text);
|
||||||
|
|
||||||
Window::TopBarWidget::paintUnreadCounter(p, width());
|
Window::TopBarWidget::paintUnreadCounter(p, width());
|
||||||
}
|
}
|
||||||
|
@ -77,6 +78,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
int _unreadCounterSubscription = 0;
|
int _unreadCounterSubscription = 0;
|
||||||
|
QString _text;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -187,7 +189,6 @@ void FixedBar::addRightAction(RightActionType type, const QString &text, const c
|
||||||
_rightActions[_currentAction].type = type;
|
_rightActions[_currentAction].type = type;
|
||||||
delete _rightActions[_currentAction].button;
|
delete _rightActions[_currentAction].button;
|
||||||
_rightActions[_currentAction].button = new Ui::RoundButton(this, text, st::profileFixedBarButton);
|
_rightActions[_currentAction].button = new Ui::RoundButton(this, text, st::profileFixedBarButton);
|
||||||
_rightActions[_currentAction].button->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
|
|
||||||
connect(_rightActions[_currentAction].button, SIGNAL(clicked()), this, slot);
|
connect(_rightActions[_currentAction].button, SIGNAL(clicked()), this, slot);
|
||||||
bool showButton = !_animatingMode && (type != RightActionType::ShareContact || !_hideShareContactButton);
|
bool showButton = !_animatingMode && (type != RightActionType::ShareContact || !_hideShareContactButton);
|
||||||
_rightActions[_currentAction].button->setVisible(showButton);
|
_rightActions[_currentAction].button->setVisible(showButton);
|
||||||
|
|
|
@ -42,12 +42,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
EmojiColorPicker::EmojiColorPicker() : TWidget()
|
EmojiColorPicker::EmojiColorPicker() : TWidget()
|
||||||
, _a_selected(animation(this, &EmojiColorPicker::step_selected))
|
|
||||||
, a_opacity(0)
|
, a_opacity(0)
|
||||||
, _a_appearance(animation(this, &EmojiColorPicker::step_appearance))
|
, _a_appearance(animation(this, &EmojiColorPicker::step_appearance))
|
||||||
, _shadow(st::defaultDropdownShadow) {
|
, _shadow(st::defaultDropdownShadow) {
|
||||||
memset(_variants, 0, sizeof(_variants));
|
memset(_variants, 0, sizeof(_variants));
|
||||||
memset(_hovers, 0, sizeof(_hovers));
|
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
|
@ -128,7 +126,11 @@ void EmojiColorPicker::mousePressEvent(QMouseEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiColorPicker::mouseReleaseEvent(QMouseEvent *e) {
|
void EmojiColorPicker::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
_lastMousePos = e ? e->globalPos() : QCursor::pos();
|
handleMouseRelease(e->globalPos());
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmojiColorPicker::handleMouseRelease(QPoint globalPos) {
|
||||||
|
_lastMousePos = globalPos;
|
||||||
int32 pressed = _pressedSel;
|
int32 pressed = _pressedSel;
|
||||||
_pressedSel = -1;
|
_pressedSel = -1;
|
||||||
|
|
||||||
|
@ -140,11 +142,15 @@ void EmojiColorPicker::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
hideAnimated();
|
hideAnimated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiColorPicker::mouseMoveEvent(QMouseEvent *e) {
|
void EmojiColorPicker::handleMouseMove(QPoint globalPos) {
|
||||||
_lastMousePos = e ? e->globalPos() : QCursor::pos();
|
_lastMousePos = globalPos;
|
||||||
updateSelected();
|
updateSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmojiColorPicker::mouseMoveEvent(QMouseEvent *e) {
|
||||||
|
handleMouseMove(e->globalPos());
|
||||||
|
}
|
||||||
|
|
||||||
void EmojiColorPicker::step_appearance(float64 ms, bool timer) {
|
void EmojiColorPicker::step_appearance(float64 ms, bool timer) {
|
||||||
if (_cache.isNull()) {
|
if (_cache.isNull()) {
|
||||||
_a_appearance.stop();
|
_a_appearance.stop();
|
||||||
|
@ -168,28 +174,9 @@ void EmojiColorPicker::step_appearance(float64 ms, bool timer) {
|
||||||
if (timer) update();
|
if (timer) update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiColorPicker::step_selected(uint64 ms, bool timer) {
|
|
||||||
QRegion toUpdate;
|
|
||||||
for (EmojiAnimations::iterator i = _emojiAnimations.begin(); i != _emojiAnimations.end();) {
|
|
||||||
int index = qAbs(i.key()) - 1;
|
|
||||||
float64 dt = float64(ms - i.value()) / st::emojiPanDuration;
|
|
||||||
if (dt >= 1) {
|
|
||||||
_hovers[index] = (i.key() > 0) ? 1 : 0;
|
|
||||||
i = _emojiAnimations.erase(i);
|
|
||||||
} else {
|
|
||||||
_hovers[index] = (i.key() > 0) ? dt : (1 - dt);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
toUpdate += QRect(st::defaultDropdownShadow.width() + st::emojiColorsPadding + index * st::emojiPanSize.width() + (index ? 2 * st::emojiColorsPadding + st::emojiColorsSep : 0), st::defaultDropdownShadow.height() + st::emojiColorsPadding, st::emojiPanSize.width(), st::emojiPanSize.height());
|
|
||||||
}
|
|
||||||
if (timer) rtlupdate(toUpdate.boundingRect());
|
|
||||||
if (_emojiAnimations.isEmpty()) _a_selected.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EmojiColorPicker::hideFast() {
|
void EmojiColorPicker::hideFast() {
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
if (_a_appearance.animating()) _a_appearance.stop();
|
if (_a_appearance.animating()) _a_appearance.stop();
|
||||||
if (_a_selected.animating()) _a_selected.stop();
|
|
||||||
a_opacity = anim::fvalue(0);
|
a_opacity = anim::fvalue(0);
|
||||||
_cache = QPixmap();
|
_cache = QPixmap();
|
||||||
hide();
|
hide();
|
||||||
|
@ -198,9 +185,9 @@ void EmojiColorPicker::hideFast() {
|
||||||
|
|
||||||
void EmojiColorPicker::hideAnimated() {
|
void EmojiColorPicker::hideAnimated() {
|
||||||
if (_cache.isNull()) {
|
if (_cache.isNull()) {
|
||||||
int32 w = st::defaultDropdownShadow.width(), h = st::defaultDropdownShadow.height();
|
auto w = st::defaultDropdownShadow.width(), h = st::defaultDropdownShadow.height();
|
||||||
_cache = myGrab(this, QRect(w, h, width() - 2 * w, height() - 2 * h));
|
_cache = myGrab(this, QRect(w, h, width() - 2 * w, height() - 2 * h));
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
}
|
}
|
||||||
_hiding = true;
|
_hiding = true;
|
||||||
a_opacity.start(0);
|
a_opacity.start(0);
|
||||||
|
@ -219,83 +206,67 @@ void EmojiColorPicker::showAnimated() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_cache.isNull()) {
|
if (_cache.isNull()) {
|
||||||
int32 w = st::defaultDropdownShadow.width(), h = st::defaultDropdownShadow.height();
|
auto w = st::defaultDropdownShadow.width(), h = st::defaultDropdownShadow.height();
|
||||||
_cache = myGrab(this, QRect(w, h, width() - 2 * w, height() - 2 * h));
|
_cache = myGrab(this, QRect(w, h, width() - 2 * w, height() - 2 * h));
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
}
|
}
|
||||||
show();
|
show();
|
||||||
a_opacity.start(1);
|
a_opacity.start(1);
|
||||||
_a_appearance.start();
|
_a_appearance.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiColorPicker::clearSelection(bool fast) {
|
void EmojiColorPicker::clearSelection() {
|
||||||
_pressedSel = -1;
|
_pressedSel = -1;
|
||||||
|
setSelected(-1);
|
||||||
_lastMousePos = mapToGlobal(QPoint(-10, -10));
|
_lastMousePos = mapToGlobal(QPoint(-10, -10));
|
||||||
if (fast) {
|
|
||||||
_selected = -1;
|
|
||||||
memset(_hovers, 0, sizeof(_hovers));
|
|
||||||
_emojiAnimations.clear();
|
|
||||||
} else {
|
|
||||||
updateSelected();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiColorPicker::updateSelected() {
|
void EmojiColorPicker::updateSelected() {
|
||||||
int32 selIndex = -1;
|
auto newSelected = -1;
|
||||||
QPoint p(mapFromGlobal(_lastMousePos));
|
auto p = mapFromGlobal(_lastMousePos);
|
||||||
int32 sx = rtl() ? (width() - p.x()) : p.x(), y = p.y() - st::defaultDropdownShadow.height() - st::emojiColorsPadding;
|
int32 sx = rtl() ? (width() - p.x()) : p.x(), y = p.y() - st::defaultDropdownShadow.height() - st::emojiColorsPadding;
|
||||||
if (y >= 0 && y < st::emojiPanSize.height()) {
|
if (y >= 0 && y < st::emojiPanSize.height()) {
|
||||||
int32 x = sx - st::defaultDropdownShadow.width() - st::emojiColorsPadding;
|
int32 x = sx - st::defaultDropdownShadow.width() - st::emojiColorsPadding;
|
||||||
if (x >= 0 && x < st::emojiPanSize.width()) {
|
if (x >= 0 && x < st::emojiPanSize.width()) {
|
||||||
selIndex = 0;
|
newSelected = 0;
|
||||||
} else {
|
} else {
|
||||||
x -= st::emojiPanSize.width() + 2 * st::emojiColorsPadding + st::emojiColorsSep;
|
x -= st::emojiPanSize.width() + 2 * st::emojiColorsPadding + st::emojiColorsSep;
|
||||||
if (x >= 0 && x < st::emojiPanSize.width() * EmojiColorsCount) {
|
if (x >= 0 && x < st::emojiPanSize.width() * EmojiColorsCount) {
|
||||||
selIndex = (x / st::emojiPanSize.width()) + 1;
|
newSelected = (x / st::emojiPanSize.width()) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool startanim = false;
|
setSelected(newSelected);
|
||||||
if (selIndex != _selected) {
|
}
|
||||||
if (_selected >= 0) {
|
|
||||||
_emojiAnimations.remove(_selected + 1);
|
void EmojiColorPicker::setSelected(int newSelected) {
|
||||||
if (_emojiAnimations.find(-_selected - 1) == _emojiAnimations.end()) {
|
if (_selected == newSelected) {
|
||||||
if (_emojiAnimations.isEmpty()) startanim = true;
|
return;
|
||||||
_emojiAnimations.insert(-_selected - 1, getms());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_selected = selIndex;
|
|
||||||
if (_selected >= 0) {
|
|
||||||
_emojiAnimations.remove(-_selected - 1);
|
|
||||||
if (_emojiAnimations.find(_selected + 1) == _emojiAnimations.end()) {
|
|
||||||
if (_emojiAnimations.isEmpty()) startanim = true;
|
|
||||||
_emojiAnimations.insert(_selected + 1, getms());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setCursor((_selected >= 0) ? style::cur_pointer : style::cur_default);
|
|
||||||
}
|
}
|
||||||
if (startanim && !_a_selected.animating()) _a_selected.start();
|
auto updateSelectedRect = [this] {
|
||||||
|
if (_selected < 0) return;
|
||||||
|
rtlupdate(st::defaultDropdownShadow.width() + st::emojiColorsPadding + _selected * st::emojiPanSize.width() + (_selected ? 2 * st::emojiColorsPadding + st::emojiColorsSep : 0), st::defaultDropdownShadow.height() + st::emojiColorsPadding, st::emojiPanSize.width(), st::emojiPanSize.height());
|
||||||
|
};
|
||||||
|
updateSelectedRect();
|
||||||
|
_selected = newSelected;
|
||||||
|
updateSelectedRect();
|
||||||
|
setCursor((_selected >= 0) ? style::cur_pointer : style::cur_default);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiColorPicker::drawVariant(Painter &p, int variant) {
|
void EmojiColorPicker::drawVariant(Painter &p, int variant) {
|
||||||
float64 hover = _hovers[variant];
|
|
||||||
|
|
||||||
QPoint w(st::defaultDropdownShadow.width() + st::emojiColorsPadding + variant * st::emojiPanSize.width() + (variant ? 2 * st::emojiColorsPadding + st::emojiColorsSep : 0), st::defaultDropdownShadow.height() + st::emojiColorsPadding);
|
QPoint w(st::defaultDropdownShadow.width() + st::emojiColorsPadding + variant * st::emojiPanSize.width() + (variant ? 2 * st::emojiColorsPadding + st::emojiColorsSep : 0), st::defaultDropdownShadow.height() + st::emojiColorsPadding);
|
||||||
if (hover > 0) {
|
if (variant == _selected) {
|
||||||
p.setOpacity(hover);
|
|
||||||
QPoint tl(w);
|
QPoint tl(w);
|
||||||
if (rtl()) tl.setX(width() - tl.x() - st::emojiPanSize.width());
|
if (rtl()) tl.setX(width() - tl.x() - st::emojiPanSize.width());
|
||||||
App::roundRect(p, QRect(tl, st::emojiPanSize), st::emojiPanHover, StickerHoverCorners);
|
App::roundRect(p, QRect(tl, st::emojiPanSize), st::emojiPanHover, StickerHoverCorners);
|
||||||
p.setOpacity(1.);
|
|
||||||
}
|
}
|
||||||
int esize = EmojiSizes[EIndex + 1];
|
int esize = EmojiSizes[EIndex + 1];
|
||||||
p.drawPixmapLeft(w.x() + (st::emojiPanSize.width() - (esize / cIntRetinaFactor())) / 2, w.y() + (st::emojiPanSize.height() - (esize / cIntRetinaFactor())) / 2, width(), App::emojiLarge(), QRect(_variants[variant]->x * esize, _variants[variant]->y * esize, esize, esize));
|
p.drawPixmapLeft(w.x() + (st::emojiPanSize.width() - (esize / cIntRetinaFactor())) / 2, w.y() + (st::emojiPanSize.height() - (esize / cIntRetinaFactor())) / 2, width(), App::emojiLarge(), QRect(_variants[variant]->x * esize, _variants[variant]->y * esize, esize, esize));
|
||||||
}
|
}
|
||||||
|
|
||||||
EmojiPanInner::EmojiPanInner(QWidget *parent) : TWidget(parent)
|
EmojiPanInner::EmojiPanInner(QWidget *parent) : TWidget(parent)
|
||||||
, _maxHeight(int(st::emojiPanMaxHeight) - st::emojiCategory.height)
|
, _maxHeight(int(st::emojiPanMaxHeight) - st::emojiCategory.height) {
|
||||||
, _a_selected(animation(this, &EmojiPanInner::step_selected)) {
|
|
||||||
resize(st::emojiPanWidth - st::emojiScroll.width - st::buttonRadius, countHeight());
|
resize(st::emojiPanWidth - st::emojiScroll.width - st::buttonRadius, countHeight());
|
||||||
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
@ -305,9 +276,8 @@ EmojiPanInner::EmojiPanInner(QWidget *parent) : TWidget(parent)
|
||||||
|
|
||||||
_esize = EmojiSizes[EIndex + 1];
|
_esize = EmojiSizes[EIndex + 1];
|
||||||
|
|
||||||
for (int32 i = 0; i < emojiTabCount; ++i) {
|
for (auto i = 0; i != emojiTabCount; ++i) {
|
||||||
_counts[i] = emojiPackCount(emojiTabAtIndex(i));
|
_counts[i] = emojiPackCount(emojiTabAtIndex(i));
|
||||||
_hovers[i] = QVector<float64>(_counts[i], 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_showPickerTimer.setSingleShot(true);
|
_showPickerTimer.setSingleShot(true);
|
||||||
|
@ -387,15 +357,13 @@ void EmojiPanInner::paintEvent(QPaintEvent *e) {
|
||||||
int32 index = i * EmojiPanPerRow + j;
|
int32 index = i * EmojiPanPerRow + j;
|
||||||
if (index >= size) break;
|
if (index >= size) break;
|
||||||
|
|
||||||
float64 hover = (!_picker.isHidden() && c * MatrixRowShift + index == _pickerSel) ? 1 : _hovers[c][index];
|
auto selected = (!_picker.isHidden() && c * MatrixRowShift + index == _pickerSel) || (c * MatrixRowShift + index == _selected);
|
||||||
|
|
||||||
QPoint w(st::emojiPanPadding + j * st::emojiPanSize.width(), y + i * st::emojiPanSize.height());
|
QPoint w(st::emojiPanPadding + j * st::emojiPanSize.width(), y + i * st::emojiPanSize.height());
|
||||||
if (hover > 0) {
|
if (selected) {
|
||||||
p.setOpacity(hover);
|
|
||||||
QPoint tl(w);
|
QPoint tl(w);
|
||||||
if (rtl()) tl.setX(width() - tl.x() - st::emojiPanSize.width());
|
if (rtl()) tl.setX(width() - tl.x() - st::emojiPanSize.width());
|
||||||
App::roundRect(p, QRect(tl, st::emojiPanSize), st::emojiPanHover, StickerHoverCorners);
|
App::roundRect(p, QRect(tl, st::emojiPanSize), st::emojiPanHover, StickerHoverCorners);
|
||||||
p.setOpacity(1.);
|
|
||||||
}
|
}
|
||||||
p.drawPixmapLeft(w.x() + (st::emojiPanSize.width() - (_esize / cIntRetinaFactor())) / 2, w.y() + (st::emojiPanSize.height() - (_esize / cIntRetinaFactor())) / 2, width(), App::emojiLarge(), QRect(_emojis[c][index]->x * _esize, _emojis[c][index]->y * _esize, _esize, _esize));
|
p.drawPixmapLeft(w.x() + (st::emojiPanSize.width() - (_esize / cIntRetinaFactor())) / 2, w.y() + (st::emojiPanSize.height() - (_esize / cIntRetinaFactor())) / 2, width(), App::emojiLarge(), QRect(_emojis[c][index]->x * _esize, _emojis[c][index]->y * _esize, _esize, _esize));
|
||||||
}
|
}
|
||||||
|
@ -404,7 +372,7 @@ void EmojiPanInner::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EmojiPanInner::checkPickerHide() {
|
bool EmojiPanInner::checkPickerHide() {
|
||||||
if (!_picker.isHidden() && _selected == _pickerSel) {
|
if (!_picker.isHidden() && _pickerSel >= 0) {
|
||||||
_picker.hideAnimated();
|
_picker.hideAnimated();
|
||||||
_pickerSel = -1;
|
_pickerSel = -1;
|
||||||
updateSelected();
|
updateSelected();
|
||||||
|
@ -442,7 +410,7 @@ void EmojiPanInner::mouseReleaseEvent(QMouseEvent *e) {
|
||||||
_lastMousePos = e->globalPos();
|
_lastMousePos = e->globalPos();
|
||||||
if (!_picker.isHidden()) {
|
if (!_picker.isHidden()) {
|
||||||
if (_picker.rect().contains(_picker.mapFromGlobal(_lastMousePos))) {
|
if (_picker.rect().contains(_picker.mapFromGlobal(_lastMousePos))) {
|
||||||
return _picker.mouseReleaseEvent(0);
|
return _picker.handleMouseRelease(QCursor::pos());
|
||||||
} else if (_pickerSel >= 0) {
|
} else if (_pickerSel >= 0) {
|
||||||
int tab = (_pickerSel / MatrixRowShift), sel = _pickerSel % MatrixRowShift;
|
int tab = (_pickerSel / MatrixRowShift), sel = _pickerSel % MatrixRowShift;
|
||||||
if (tab < emojiTabCount && sel < _emojis[tab].size() && _emojis[tab][sel]->color) {
|
if (tab < emojiTabCount && sel < _emojis[tab].size() && _emojis[tab][sel]->color) {
|
||||||
|
@ -584,7 +552,7 @@ void EmojiPanInner::mouseMoveEvent(QMouseEvent *e) {
|
||||||
_lastMousePos = e->globalPos();
|
_lastMousePos = e->globalPos();
|
||||||
if (!_picker.isHidden()) {
|
if (!_picker.isHidden()) {
|
||||||
if (_picker.rect().contains(_picker.mapFromGlobal(_lastMousePos))) {
|
if (_picker.rect().contains(_picker.mapFromGlobal(_lastMousePos))) {
|
||||||
return _picker.mouseMoveEvent(0);
|
return _picker.handleMouseMove(QCursor::pos());
|
||||||
} else {
|
} else {
|
||||||
_picker.clearSelection();
|
_picker.clearSelection();
|
||||||
}
|
}
|
||||||
|
@ -605,27 +573,10 @@ void EmojiPanInner::enterFromChildEvent(QEvent *e, QWidget *child) {
|
||||||
updateSelected();
|
updateSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiPanInner::clearSelection(bool fast) {
|
void EmojiPanInner::clearSelection() {
|
||||||
_lastMousePos = mapToGlobal(QPoint(-10, -10));
|
_lastMousePos = mapToGlobal(QPoint(-10, -10));
|
||||||
if (fast) {
|
_pressedSel = -1;
|
||||||
for (Animations::const_iterator i = _animations.cbegin(); i != _animations.cend(); ++i) {
|
setSelected(-1);
|
||||||
int index = qAbs(i.key()) - 1, tab = (index / MatrixRowShift), sel = index % MatrixRowShift;
|
|
||||||
_hovers[tab][sel] = 0;
|
|
||||||
}
|
|
||||||
_animations.clear();
|
|
||||||
if (_selected >= 0) {
|
|
||||||
int index = qAbs(_selected), tab = (index / MatrixRowShift), sel = index % MatrixRowShift;
|
|
||||||
_hovers[tab][sel] = 0;
|
|
||||||
}
|
|
||||||
if (_pressedSel >= 0) {
|
|
||||||
int index = qAbs(_pressedSel), tab = (index / MatrixRowShift), sel = index % MatrixRowShift;
|
|
||||||
_hovers[tab][sel] = 0;
|
|
||||||
}
|
|
||||||
_selected = _pressedSel = -1;
|
|
||||||
_a_selected.stop();
|
|
||||||
} else {
|
|
||||||
updateSelected();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DBIEmojiTab EmojiPanInner::currentTab(int yOffset) const {
|
DBIEmojiTab EmojiPanInner::currentTab(int yOffset) const {
|
||||||
|
@ -645,14 +596,13 @@ void EmojiPanInner::hideFinish() {
|
||||||
if (!_picker.isHidden()) {
|
if (!_picker.isHidden()) {
|
||||||
_picker.hideFast();
|
_picker.hideFast();
|
||||||
_pickerSel = -1;
|
_pickerSel = -1;
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiPanInner::refreshRecent() {
|
void EmojiPanInner::refreshRecent() {
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
_counts[0] = emojiPackCount(dbietRecent);
|
_counts[0] = emojiPackCount(dbietRecent);
|
||||||
if (_hovers[0].size() != _counts[0]) _hovers[0] = QVector<float64>(_counts[0], 0);
|
|
||||||
_emojis[0] = emojiPack(dbietRecent);
|
_emojis[0] = emojiPack(dbietRecent);
|
||||||
int32 h = countHeight();
|
int32 h = countHeight();
|
||||||
if (h != height()) {
|
if (h != height()) {
|
||||||
|
@ -697,8 +647,8 @@ void EmojiPanInner::refreshPanels(QVector<EmojiPanel*> &panels) {
|
||||||
void EmojiPanInner::updateSelected() {
|
void EmojiPanInner::updateSelected() {
|
||||||
if (_pressedSel >= 0 || _pickerSel >= 0) return;
|
if (_pressedSel >= 0 || _pickerSel >= 0) return;
|
||||||
|
|
||||||
int32 selIndex = -1;
|
auto newSelected = -1;
|
||||||
QPoint p(mapFromGlobal(_lastMousePos));
|
auto p = mapFromGlobal(_lastMousePos);
|
||||||
int y, ytill = 0, sx = (rtl() ? width() - p.x() : p.x()) - st::emojiPanPadding;
|
int y, ytill = 0, sx = (rtl() ? width() - p.x() : p.x()) - st::emojiPanPadding;
|
||||||
for (int c = 0; c < emojiTabCount; ++c) {
|
for (int c = 0; c < emojiTabCount; ++c) {
|
||||||
int cnt = _counts[c];
|
int cnt = _counts[c];
|
||||||
|
@ -707,65 +657,40 @@ void EmojiPanInner::updateSelected() {
|
||||||
if (p.y() >= y && p.y() < ytill) {
|
if (p.y() >= y && p.y() < ytill) {
|
||||||
y += st::emojiPanHeader;
|
y += st::emojiPanHeader;
|
||||||
if (p.y() >= y && sx >= 0 && sx < EmojiPanPerRow * st::emojiPanSize.width()) {
|
if (p.y() >= y && sx >= 0 && sx < EmojiPanPerRow * st::emojiPanSize.width()) {
|
||||||
selIndex = qFloor((p.y() - y) / st::emojiPanSize.height()) * EmojiPanPerRow + qFloor(sx / st::emojiPanSize.width());
|
newSelected = qFloor((p.y() - y) / st::emojiPanSize.height()) * EmojiPanPerRow + qFloor(sx / st::emojiPanSize.width());
|
||||||
if (selIndex >= _emojis[c].size()) {
|
if (newSelected >= _emojis[c].size()) {
|
||||||
selIndex = -1;
|
newSelected = -1;
|
||||||
} else {
|
} else {
|
||||||
selIndex += c * MatrixRowShift;
|
newSelected += c * MatrixRowShift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool startanim = false;
|
setSelected(newSelected);
|
||||||
int oldSel = _selected, newSel = selIndex;
|
|
||||||
|
|
||||||
if (newSel != oldSel) {
|
|
||||||
if (oldSel >= 0) {
|
|
||||||
_animations.remove(oldSel + 1);
|
|
||||||
if (_animations.find(-oldSel - 1) == _animations.end()) {
|
|
||||||
if (_animations.isEmpty()) startanim = true;
|
|
||||||
_animations.insert(-oldSel - 1, getms());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (newSel >= 0) {
|
|
||||||
_animations.remove(-newSel - 1);
|
|
||||||
if (_animations.find(newSel + 1) == _animations.end()) {
|
|
||||||
if (_animations.isEmpty()) startanim = true;
|
|
||||||
_animations.insert(newSel + 1, getms());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setCursor((newSel >= 0) ? style::cur_pointer : style::cur_default);
|
|
||||||
if (newSel >= 0 && !_picker.isHidden()) {
|
|
||||||
if (newSel != _pickerSel) {
|
|
||||||
_picker.hideAnimated();
|
|
||||||
} else {
|
|
||||||
_picker.showAnimated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_selected = selIndex;
|
|
||||||
if (startanim && !_a_selected.animating()) _a_selected.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiPanInner::step_selected(uint64 ms, bool timer) {
|
void EmojiPanInner::setSelected(int newSelected) {
|
||||||
QRegion toUpdate;
|
if (_selected == newSelected) {
|
||||||
for (Animations::iterator i = _animations.begin(); i != _animations.end();) {
|
return;
|
||||||
int index = qAbs(i.key()) - 1, tab = (index / MatrixRowShift), sel = index % MatrixRowShift;
|
}
|
||||||
float64 dt = float64(ms - i.value()) / st::emojiPanDuration;
|
auto updateSelected = [this]() {
|
||||||
if (dt >= 1) {
|
if (_selected < 0) return;
|
||||||
_hovers[tab][sel] = (i.key() > 0) ? 1 : 0;
|
rtlupdate(emojiRect(_selected / MatrixRowShift, _selected % MatrixRowShift));
|
||||||
i = _animations.erase(i);
|
};
|
||||||
} else {
|
updateSelected();
|
||||||
_hovers[tab][sel] = (i.key() > 0) ? dt : (1 - dt);
|
_selected = newSelected;
|
||||||
++i;
|
updateSelected();
|
||||||
}
|
|
||||||
toUpdate += emojiRect(tab, sel);
|
setCursor((_selected >= 0) ? style::cur_pointer : style::cur_default);
|
||||||
|
if (_selected >= 0 && !_picker.isHidden()) {
|
||||||
|
if (_selected != _pickerSel) {
|
||||||
|
_picker.hideAnimated();
|
||||||
|
} else {
|
||||||
|
_picker.showAnimated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (timer) rtlupdate(toUpdate.boundingRect());
|
|
||||||
if (_animations.isEmpty()) _a_selected.stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InlineCacheEntry::clearResults() {
|
void InlineCacheEntry::clearResults() {
|
||||||
|
@ -776,7 +701,7 @@ void InlineCacheEntry::clearResults() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiPanInner::showEmojiPack(DBIEmojiTab packIndex) {
|
void EmojiPanInner::showEmojiPack(DBIEmojiTab packIndex) {
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
|
|
||||||
refreshRecent();
|
refreshRecent();
|
||||||
|
|
||||||
|
@ -795,7 +720,6 @@ void EmojiPanInner::showEmojiPack(DBIEmojiTab packIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
StickerPanInner::StickerPanInner(QWidget *parent) : TWidget(parent)
|
StickerPanInner::StickerPanInner(QWidget *parent) : TWidget(parent)
|
||||||
, _a_selected(animation(this, &StickerPanInner::step_selected))
|
|
||||||
, _section(cShowingSavedGifs() ? Section::Gifs : Section::Stickers)
|
, _section(cShowingSavedGifs() ? Section::Gifs : Section::Stickers)
|
||||||
, _addText(lang(lng_stickers_featured_add).toUpper())
|
, _addText(lang(lng_stickers_featured_add).toUpper())
|
||||||
, _addWidth(st::stickersTrendingAdd.font->width(_addText))
|
, _addWidth(st::stickersTrendingAdd.font->width(_addText))
|
||||||
|
@ -1004,9 +928,19 @@ void StickerPanInner::paintStickers(Painter &p, const QRect &r) {
|
||||||
tocol = StickerPanPerRow - tocol;
|
tocol = StickerPanPerRow - tocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto &sets = shownSets();
|
||||||
|
auto seltab = (_selected >= 0) ? (_selected / MatrixRowShift) : -1;
|
||||||
|
auto selindex = (seltab >= 0) ? (_selected % MatrixRowShift) : -1;
|
||||||
|
auto seldelete = false;
|
||||||
|
if (seltab >= sets.size()) {
|
||||||
|
seltab = -1;
|
||||||
|
} else if (seltab >= 0 && selindex >= sets[seltab].pack.size()) {
|
||||||
|
selindex -= sets[seltab].pack.size();
|
||||||
|
seldelete = true;
|
||||||
|
}
|
||||||
|
|
||||||
auto tilly = 0;
|
auto tilly = 0;
|
||||||
auto ms = getms();
|
auto ms = getms();
|
||||||
auto &sets = shownSets();
|
|
||||||
if (_section == Section::Featured) {
|
if (_section == Section::Featured) {
|
||||||
tilly += st::emojiPanHeader;
|
tilly += st::emojiPanHeader;
|
||||||
for (int c = 0, l = sets.size(); c < l; ++c) {
|
for (int c = 0, l = sets.size(); c < l; ++c) {
|
||||||
|
@ -1076,7 +1010,9 @@ void StickerPanInner::paintStickers(Painter &p, const QRect &r) {
|
||||||
int index = j;
|
int index = j;
|
||||||
if (index >= size) break;
|
if (index >= size) break;
|
||||||
|
|
||||||
paintSticker(p, set, y, index);
|
auto selected = (seltab == c && selindex == index);
|
||||||
|
auto deleteSelected = selected && seldelete;
|
||||||
|
paintSticker(p, set, y, index, selected, deleteSelected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1099,28 +1035,26 @@ void StickerPanInner::paintStickers(Painter &p, const QRect &r) {
|
||||||
int index = i * StickerPanPerRow + j;
|
int index = i * StickerPanPerRow + j;
|
||||||
if (index >= size) break;
|
if (index >= size) break;
|
||||||
|
|
||||||
paintSticker(p, set, y, index);
|
auto selected = (seltab == c && selindex == index);
|
||||||
|
auto deleteSelected = selected && seldelete;
|
||||||
|
paintSticker(p, set, y, index, selected, deleteSelected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickerPanInner::paintSticker(Painter &p, Set &set, int y, int index) {
|
void StickerPanInner::paintSticker(Painter &p, Set &set, int y, int index, bool selected, bool deleteSelected) {
|
||||||
float64 hover = set.hovers[index];
|
|
||||||
|
|
||||||
auto sticker = set.pack[index];
|
auto sticker = set.pack[index];
|
||||||
if (!sticker->sticker()) return;
|
if (!sticker->sticker()) return;
|
||||||
|
|
||||||
int row = (index / StickerPanPerRow), col = (index % StickerPanPerRow);
|
int row = (index / StickerPanPerRow), col = (index % StickerPanPerRow);
|
||||||
|
|
||||||
QPoint pos(stickersLeft() + col * st::stickerPanSize.width(), y + row * st::stickerPanSize.height());
|
QPoint pos(stickersLeft() + col * st::stickerPanSize.width(), y + row * st::stickerPanSize.height());
|
||||||
if (hover > 0) {
|
if (selected) {
|
||||||
p.setOpacity(hover);
|
|
||||||
QPoint tl(pos);
|
QPoint tl(pos);
|
||||||
if (rtl()) tl.setX(width() - tl.x() - st::stickerPanSize.width());
|
if (rtl()) tl.setX(width() - tl.x() - st::stickerPanSize.width());
|
||||||
App::roundRect(p, QRect(tl, st::stickerPanSize), st::emojiPanHover, StickerHoverCorners);
|
App::roundRect(p, QRect(tl, st::stickerPanSize), st::emojiPanHover, StickerHoverCorners);
|
||||||
p.setOpacity(1.);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool goodThumb = !sticker->thumb->isNull() && ((sticker->thumb->width() >= 128) || (sticker->thumb->height() >= 128));
|
bool goodThumb = !sticker->thumb->isNull() && ((sticker->thumb->width() >= 128) || (sticker->thumb->height() >= 128));
|
||||||
|
@ -1142,13 +1076,11 @@ void StickerPanInner::paintSticker(Painter &p, Set &set, int y, int index) {
|
||||||
p.drawPixmapLeft(ppos, width(), sticker->sticker()->img->pix(w, h));
|
p.drawPixmapLeft(ppos, width(), sticker->sticker()->img->pix(w, h));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hover > 0 && set.id == Stickers::RecentSetId && _custom.at(index)) {
|
if (selected && set.id == Stickers::RecentSetId && _custom.at(index)) {
|
||||||
float64 xHover = set.hovers[set.pack.size() + index];
|
|
||||||
|
|
||||||
QPoint xPos = pos + QPoint(st::stickerPanSize.width() - st::stickerPanDelete.width(), 0);
|
QPoint xPos = pos + QPoint(st::stickerPanSize.width() - st::stickerPanDelete.width(), 0);
|
||||||
p.setOpacity(hover * (xHover + (1 - xHover) * st::stickerPanDeleteOpacity));
|
if (!deleteSelected) p.setOpacity(st::stickerPanDeleteOpacity);
|
||||||
st::stickerPanDelete.paint(p, xPos, width());
|
st::stickerPanDelete.paint(p, xPos, width());
|
||||||
p.setOpacity(1.);
|
if (!deleteSelected) p.setOpacity(1.);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1293,7 +1225,7 @@ void StickerPanInner::removeRecentSticker(int tab, int index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
bool refresh = false;
|
bool refresh = false;
|
||||||
auto sticker = _mySets[tab].pack[index];
|
auto sticker = _mySets[tab].pack[index];
|
||||||
auto &recent = cGetRecentStickers();
|
auto &recent = cGetRecentStickers();
|
||||||
|
@ -1349,53 +1281,22 @@ bool StickerPanInner::showSectionIcons() const {
|
||||||
return !inlineResultsShown();
|
return !inlineResultsShown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickerPanInner::clearSelection(bool fast) {
|
void StickerPanInner::clearSelection() {
|
||||||
if (fast) {
|
if (showingInlineItems()) {
|
||||||
if (showingInlineItems()) {
|
|
||||||
if (_selected >= 0) {
|
|
||||||
int srow = _selected / MatrixRowShift, scol = _selected % MatrixRowShift;
|
|
||||||
t_assert(srow >= 0 && srow < _inlineRows.size() && scol >= 0 && scol < _inlineRows.at(srow).items.size());
|
|
||||||
ClickHandler::clearActive(_inlineRows.at(srow).items.at(scol));
|
|
||||||
setCursor(style::cur_default);
|
|
||||||
}
|
|
||||||
_selected = _pressed = -1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto &sets = shownSets();
|
|
||||||
for (auto i = _animations.cbegin(); i != _animations.cend(); ++i) {
|
|
||||||
int index = qAbs(i.key()) - 1, tab = (index / MatrixRowShift), sel = index % MatrixRowShift;
|
|
||||||
sets[tab].hovers[sel] = 0;
|
|
||||||
}
|
|
||||||
_animations.clear();
|
|
||||||
if (_selected >= 0) {
|
if (_selected >= 0) {
|
||||||
int index = qAbs(_selected), tab = (index / MatrixRowShift), sel = index % MatrixRowShift;
|
int srow = _selected / MatrixRowShift, scol = _selected % MatrixRowShift;
|
||||||
if (index >= 0 && tab < sets.size() && sets[tab].id == Stickers::RecentSetId && sel >= tab * MatrixRowShift + sets[tab].pack.size()) {
|
t_assert(srow >= 0 && srow < _inlineRows.size() && scol >= 0 && scol < _inlineRows.at(srow).items.size());
|
||||||
sets[tab].hovers[sel] = 0;
|
ClickHandler::clearActive(_inlineRows.at(srow).items.at(scol));
|
||||||
sel -= sets[tab].pack.size();
|
setCursor(style::cur_default);
|
||||||
}
|
|
||||||
sets[tab].hovers[sel] = 0;
|
|
||||||
}
|
|
||||||
if (_pressed >= 0) {
|
|
||||||
int index = qAbs(_pressed), tab = (index / MatrixRowShift), sel = index % MatrixRowShift;
|
|
||||||
if (index >= 0 && tab < sets.size() && sets[tab].id == Stickers::RecentSetId && sel >= tab * MatrixRowShift + sets[tab].pack.size()) {
|
|
||||||
sets[tab].hovers[sel] = 0;
|
|
||||||
sel -= sets[tab].pack.size();
|
|
||||||
}
|
|
||||||
sets[tab].hovers[sel] = 0;
|
|
||||||
}
|
}
|
||||||
_selected = _pressed = -1;
|
_selected = _pressed = -1;
|
||||||
_selectedFeaturedSet = _pressedFeaturedSet = -1;
|
|
||||||
_selectedFeaturedSetAdd = -1;
|
|
||||||
setPressedFeaturedSetAdd(-1);
|
|
||||||
_a_selected.stop();
|
|
||||||
update();
|
|
||||||
} else {
|
} else {
|
||||||
auto pos = _lastMousePos;
|
_pressed = -1;
|
||||||
_lastMousePos = mapToGlobal(QPoint(-10, -10));
|
_pressedFeaturedSet = -1;
|
||||||
updateSelected();
|
setSelected(-1, -1, -1);
|
||||||
_lastMousePos = pos;
|
setPressedFeaturedSetAdd(-1);
|
||||||
}
|
}
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickerPanInner::hideFinish(bool completely) {
|
void StickerPanInner::hideFinish(bool completely) {
|
||||||
|
@ -1434,7 +1335,7 @@ void StickerPanInner::hideFinish(bool completely) {
|
||||||
void StickerPanInner::refreshStickers() {
|
void StickerPanInner::refreshStickers() {
|
||||||
auto stickersShown = (_section == Section::Stickers || _section == Section::Featured);
|
auto stickersShown = (_section == Section::Stickers || _section == Section::Featured);
|
||||||
if (stickersShown) {
|
if (stickersShown) {
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
_mySets.clear();
|
_mySets.clear();
|
||||||
|
@ -1463,31 +1364,7 @@ void StickerPanInner::refreshStickers() {
|
||||||
|
|
||||||
emit refreshIcons(kRefreshIconsNoAnimation);
|
emit refreshIcons(kRefreshIconsNoAnimation);
|
||||||
|
|
||||||
// Hack: skip over animations to the very end,
|
if (stickersShown) updateSelected();
|
||||||
// so that currently selected sticker won't get
|
|
||||||
// blinking background when refreshing stickers.
|
|
||||||
if (stickersShown) {
|
|
||||||
updateSelected();
|
|
||||||
int sel = _selected, tab = sel / MatrixRowShift, xsel = -1;
|
|
||||||
if (sel >= 0) {
|
|
||||||
auto &sets = shownSets();
|
|
||||||
if (tab < sets.size() && sets[tab].id == Stickers::RecentSetId && sel >= tab * MatrixRowShift + sets[tab].pack.size()) {
|
|
||||||
xsel = sel;
|
|
||||||
sel -= sets[tab].pack.size();
|
|
||||||
}
|
|
||||||
auto i = _animations.find(sel + 1);
|
|
||||||
if (i != _animations.cend()) {
|
|
||||||
i.value() = (i.value() >= static_cast<uint32>(st::emojiPanDuration)) ? (i.value() - st::emojiPanDuration) : 0;
|
|
||||||
}
|
|
||||||
if (xsel >= 0) {
|
|
||||||
auto j = _animations.find(xsel + 1);
|
|
||||||
if (j != _animations.cend()) {
|
|
||||||
j.value() = (j.value() >= static_cast<uint32>(st::emojiPanDuration)) ? (j.value() - st::emojiPanDuration) : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
step_selected(getms(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StickerPanInner::inlineRowsAddItem(DocumentData *savedGif, InlineResult *result, InlineRow &row, int32 &sumWidth) {
|
bool StickerPanInner::inlineRowsAddItem(DocumentData *savedGif, InlineResult *result, InlineRow &row, int32 &sumWidth) {
|
||||||
|
@ -1571,7 +1448,7 @@ void StickerPanInner::clearInlineRows(bool resultsDeleted) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (showingInlineItems()) {
|
if (showingInlineItems()) {
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
}
|
}
|
||||||
for_const (auto &row, _inlineRows) {
|
for_const (auto &row, _inlineRows) {
|
||||||
for_const (auto &item, row.items) {
|
for_const (auto &item, row.items) {
|
||||||
|
@ -1793,7 +1670,7 @@ int StickerPanInner::refreshInlineRows(UserData *bot, const InlineCacheEntry *en
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
|
|
||||||
t_assert(_inlineBot != 0);
|
t_assert(_inlineBot != 0);
|
||||||
_inlineBotTitle = lng_inline_bot_results(lt_inline_bot, _inlineBot->username.isEmpty() ? _inlineBot->name : ('@' + _inlineBot->username));
|
_inlineBotTitle = lng_inline_bot_results(lt_inline_bot, _inlineBot->username.isEmpty() ? _inlineBot->name : ('@' + _inlineBot->username));
|
||||||
|
@ -1956,7 +1833,7 @@ void StickerPanInner::refreshRecent() {
|
||||||
|
|
||||||
void StickerPanInner::refreshRecentStickers(bool performResize) {
|
void StickerPanInner::refreshRecentStickers(bool performResize) {
|
||||||
_custom.clear();
|
_custom.clear();
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
auto &sets = Global::StickerSets();
|
auto &sets = Global::StickerSets();
|
||||||
auto &recent = cGetRecentStickers();
|
auto &recent = cGetRecentStickers();
|
||||||
auto customIt = sets.constFind(Stickers::CustomSetId);
|
auto customIt = sets.constFind(Stickers::CustomSetId);
|
||||||
|
@ -1999,7 +1876,6 @@ void StickerPanInner::refreshRecentStickers(bool performResize) {
|
||||||
_mySets.push_back(Set(Stickers::RecentSetId, MTPDstickerSet::Flag::f_official | MTPDstickerSet_ClientFlag::f_special, lang(lng_recent_stickers), recentPack.size() * 2, recentPack));
|
_mySets.push_back(Set(Stickers::RecentSetId, MTPDstickerSet::Flag::f_official | MTPDstickerSet_ClientFlag::f_special, lang(lng_recent_stickers), recentPack.size() * 2, recentPack));
|
||||||
} else {
|
} else {
|
||||||
_mySets[0].pack = recentPack;
|
_mySets[0].pack = recentPack;
|
||||||
_mySets[0].hovers.resize(recentPack.size() * 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2109,7 +1985,7 @@ void StickerPanInner::updateSelected() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int selIndex = -1;
|
auto newSelected = -1;
|
||||||
auto p = mapFromGlobal(_lastMousePos);
|
auto p = mapFromGlobal(_lastMousePos);
|
||||||
|
|
||||||
if (showingInlineItems()) {
|
if (showingInlineItems()) {
|
||||||
|
@ -2184,8 +2060,8 @@ void StickerPanInner::updateSelected() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int selectedFeaturedSet = -1;
|
auto newSelectedFeaturedSet = -1;
|
||||||
int selectedFeaturedSetAdd = -1;
|
auto newSelectedFeaturedSetAdd = -1;
|
||||||
auto featured = (_section == Section::Featured);
|
auto featured = (_section == Section::Featured);
|
||||||
auto &sets = shownSets();
|
auto &sets = shownSets();
|
||||||
int y, ytill = 0, sx = (rtl() ? width() - p.x() : p.x()) - stickersLeft();
|
int y, ytill = 0, sx = (rtl() ? width() - p.x() : p.x()) - stickersLeft();
|
||||||
|
@ -2207,9 +2083,9 @@ void StickerPanInner::updateSelected() {
|
||||||
if (featured) {
|
if (featured) {
|
||||||
if (p.y() < y + st::stickersTrendingHeader) {
|
if (p.y() < y + st::stickersTrendingHeader) {
|
||||||
if (featuredHasAddButton(c) && myrtlrect(featuredAddRect(c)).contains(p.x(), p.y())) {
|
if (featuredHasAddButton(c) && myrtlrect(featuredAddRect(c)).contains(p.x(), p.y())) {
|
||||||
selectedFeaturedSetAdd = c;
|
newSelectedFeaturedSetAdd = c;
|
||||||
} else {
|
} else {
|
||||||
selectedFeaturedSet = c;
|
newSelectedFeaturedSet = c;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2220,17 +2096,18 @@ void StickerPanInner::updateSelected() {
|
||||||
if (p.y() >= y && sx >= 0 && sx < StickerPanPerRow * st::stickerPanSize.width()) {
|
if (p.y() >= y && sx >= 0 && sx < StickerPanPerRow * st::stickerPanSize.width()) {
|
||||||
auto rowIndex = qFloor((p.y() - y) / st::stickerPanSize.height());
|
auto rowIndex = qFloor((p.y() - y) / st::stickerPanSize.height());
|
||||||
if (!featured || !rowIndex) {
|
if (!featured || !rowIndex) {
|
||||||
selIndex = rowIndex * StickerPanPerRow + qFloor(sx / st::stickerPanSize.width());
|
newSelected = rowIndex * StickerPanPerRow + qFloor(sx / st::stickerPanSize.width());
|
||||||
if (selIndex >= set.pack.size()) {
|
if (newSelected >= set.pack.size()) {
|
||||||
selIndex = -1;
|
newSelected = -1;
|
||||||
} else {
|
} else {
|
||||||
if (set.id == Stickers::RecentSetId && _custom[selIndex]) {
|
if (set.id == Stickers::RecentSetId && _custom[newSelected]) {
|
||||||
int inx = sx - (selIndex % StickerPanPerRow) * st::stickerPanSize.width(), iny = p.y() - y - ((selIndex / StickerPanPerRow) * st::stickerPanSize.height());
|
auto inx = sx - (newSelected % StickerPanPerRow) * st::stickerPanSize.width();
|
||||||
|
auto iny = p.y() - y - ((newSelected / StickerPanPerRow) * st::stickerPanSize.height());
|
||||||
if (inx >= st::stickerPanSize.width() - st::stickerPanDelete.width() && iny < st::stickerPanDelete.height()) {
|
if (inx >= st::stickerPanSize.width() - st::stickerPanDelete.width() && iny < st::stickerPanDelete.height()) {
|
||||||
selIndex += set.pack.size();
|
newSelected += set.pack.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selIndex += c * MatrixRowShift;
|
newSelected += c * MatrixRowShift;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2238,66 +2115,42 @@ void StickerPanInner::updateSelected() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool startanim = false;
|
setSelected(newSelected, newSelectedFeaturedSet, newSelectedFeaturedSetAdd);
|
||||||
int oldSel = _selected, oldSelTab = oldSel / MatrixRowShift, xOldSel = -1, newSel = selIndex, newSelTab = newSel / MatrixRowShift, xNewSel = -1;
|
}
|
||||||
if (oldSel >= 0 && oldSelTab < sets.size() && sets[oldSelTab].id == Stickers::RecentSetId && oldSel >= oldSelTab * MatrixRowShift + sets[oldSelTab].pack.size()) {
|
|
||||||
xOldSel = oldSel;
|
void StickerPanInner::setSelected(int newSelected, int newSelectedFeaturedSet, int newSelectedFeaturedSetAdd) {
|
||||||
oldSel -= sets[oldSelTab].pack.size();
|
if (_selected != newSelected || _selectedFeaturedSet != newSelectedFeaturedSet || _selectedFeaturedSetAdd != newSelectedFeaturedSetAdd) {
|
||||||
|
setCursor((newSelected >= 0 || newSelectedFeaturedSet >= 0 || newSelectedFeaturedSetAdd >= 0) ? style::cur_pointer : style::cur_default);
|
||||||
}
|
}
|
||||||
if (newSel >= 0 && newSelTab < sets.size() && sets[newSelTab].id == Stickers::RecentSetId && newSel >= newSelTab * MatrixRowShift + sets[newSelTab].pack.size()) {
|
if (_selected != newSelected) {
|
||||||
xNewSel = newSel;
|
auto &sets = shownSets();
|
||||||
newSel -= sets[newSelTab].pack.size();
|
auto updateSelected = [this, &sets]() {
|
||||||
}
|
if (_selected < 0) return;
|
||||||
if (newSel != oldSel || selectedFeaturedSet != _selectedFeaturedSet || selectedFeaturedSetAdd != _selectedFeaturedSetAdd) {
|
auto tab = _selected / MatrixRowShift, sel = _selected % MatrixRowShift;
|
||||||
setCursor((newSel >= 0 || selectedFeaturedSet >= 0 || selectedFeaturedSetAdd >= 0) ? style::cur_pointer : style::cur_default);
|
if (tab < sets.size() && sel >= sets[tab].pack.size()) {
|
||||||
}
|
sel -= sets[tab].pack.size();
|
||||||
if (newSel != oldSel) {
|
|
||||||
if (oldSel >= 0) {
|
|
||||||
_animations.remove(oldSel + 1);
|
|
||||||
if (_animations.find(-oldSel - 1) == _animations.end()) {
|
|
||||||
if (_animations.isEmpty()) startanim = true;
|
|
||||||
_animations.insert(-oldSel - 1, getms());
|
|
||||||
}
|
}
|
||||||
}
|
rtlupdate(stickerRect(tab, sel));
|
||||||
if (newSel >= 0) {
|
};
|
||||||
_animations.remove(-newSel - 1);
|
updateSelected();
|
||||||
if (_animations.find(newSel + 1) == _animations.end()) {
|
_selected = newSelected;
|
||||||
if (_animations.isEmpty()) startanim = true;
|
updateSelected();
|
||||||
_animations.insert(newSel + 1, getms());
|
|
||||||
|
if (_previewShown && _selected >= 0 && _pressed != _selected) {
|
||||||
|
_pressed = _selected;
|
||||||
|
auto tab = _selected / MatrixRowShift, sel = _selected % MatrixRowShift;
|
||||||
|
if (tab < sets.size() && sel < sets[tab].pack.size()) {
|
||||||
|
Ui::showMediaPreview(sets[tab].pack[sel]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selectedFeaturedSet != _selectedFeaturedSet) {
|
if (_selectedFeaturedSet != newSelectedFeaturedSet) {
|
||||||
_selectedFeaturedSet = selectedFeaturedSet;
|
_selectedFeaturedSet = newSelectedFeaturedSet;
|
||||||
}
|
}
|
||||||
if (selectedFeaturedSetAdd != _selectedFeaturedSetAdd) {
|
if (_selectedFeaturedSetAdd != newSelectedFeaturedSetAdd) {
|
||||||
_selectedFeaturedSetAdd = selectedFeaturedSetAdd;
|
_selectedFeaturedSetAdd = newSelectedFeaturedSetAdd;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
if (xNewSel != xOldSel) {
|
|
||||||
if (xOldSel >= 0) {
|
|
||||||
_animations.remove(xOldSel + 1);
|
|
||||||
if (_animations.find(-xOldSel - 1) == _animations.end()) {
|
|
||||||
if (_animations.isEmpty()) startanim = true;
|
|
||||||
_animations.insert(-xOldSel - 1, getms());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (xNewSel >= 0) {
|
|
||||||
_animations.remove(-xNewSel - 1);
|
|
||||||
if (_animations.find(xNewSel + 1) == _animations.end()) {
|
|
||||||
if (_animations.isEmpty()) startanim = true;
|
|
||||||
_animations.insert(xNewSel + 1, getms());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_selected = selIndex;
|
|
||||||
if (_previewShown && _selected >= 0 && _pressed != _selected) {
|
|
||||||
_pressed = _selected;
|
|
||||||
if (newSel >= 0 && xNewSel < 0) {
|
|
||||||
Ui::showMediaPreview(sets.at(newSelTab).pack.at(newSel % MatrixRowShift));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (startanim && !_a_selected.animating()) _a_selected.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickerPanInner::onSettings() {
|
void StickerPanInner::onSettings() {
|
||||||
|
@ -2348,27 +2201,8 @@ void StickerPanInner::onSwitchPm() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickerPanInner::step_selected(uint64 ms, bool timer) {
|
|
||||||
QRegion toUpdate;
|
|
||||||
auto &sets = shownSets();
|
|
||||||
for (auto i = _animations.begin(); i != _animations.end();) {
|
|
||||||
int index = qAbs(i.key()) - 1, tab = (index / MatrixRowShift), sel = index % MatrixRowShift;
|
|
||||||
float64 dt = float64(ms - i.value()) / st::emojiPanDuration;
|
|
||||||
if (dt >= 1) {
|
|
||||||
sets[tab].hovers[sel] = (i.key() > 0) ? 1 : 0;
|
|
||||||
i = _animations.erase(i);
|
|
||||||
} else {
|
|
||||||
sets[tab].hovers[sel] = (i.key() > 0) ? dt : (1 - dt);
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
toUpdate += stickerRect(tab, sel);
|
|
||||||
}
|
|
||||||
if (timer) rtlupdate(toUpdate.boundingRect());
|
|
||||||
if (_animations.isEmpty()) _a_selected.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void StickerPanInner::showStickerSet(uint64 setId) {
|
void StickerPanInner::showStickerSet(uint64 setId) {
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
|
|
||||||
if (setId == Stickers::NoneSetId) {
|
if (setId == Stickers::NoneSetId) {
|
||||||
if (!showingInlineItems()) {
|
if (!showingInlineItems()) {
|
||||||
|
@ -2436,12 +2270,12 @@ void StickerPanInner::showStickerSet(uint64 setId) {
|
||||||
void StickerPanInner::updateShowingSavedGifs() {
|
void StickerPanInner::updateShowingSavedGifs() {
|
||||||
if (cShowingSavedGifs()) {
|
if (cShowingSavedGifs()) {
|
||||||
if (!showingInlineItems()) {
|
if (!showingInlineItems()) {
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
_section = Section::Gifs;
|
_section = Section::Gifs;
|
||||||
if (_inlineRows.isEmpty()) refreshSavedGifs();
|
if (_inlineRows.isEmpty()) refreshSavedGifs();
|
||||||
}
|
}
|
||||||
} else if (!showingInlineItems()) {
|
} else if (!showingInlineItems()) {
|
||||||
clearSelection(true);
|
clearSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3637,8 +3471,8 @@ void EmojiPan::hideAll() {
|
||||||
_symbols->hide();
|
_symbols->hide();
|
||||||
e_scroll->hide();
|
e_scroll->hide();
|
||||||
s_scroll->hide();
|
s_scroll->hide();
|
||||||
e_inner->clearSelection(true);
|
e_inner->clearSelection();
|
||||||
s_inner->clearSelection(true);
|
s_inner->clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiPan::setActiveTab(DBIEmojiTab tab) {
|
void EmojiPan::setActiveTab(DBIEmojiTab tab) {
|
||||||
|
|
|
@ -67,17 +67,9 @@ public:
|
||||||
|
|
||||||
void showEmoji(uint32 code);
|
void showEmoji(uint32 code);
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *e);
|
void clearSelection();
|
||||||
void enterEvent(QEvent *e);
|
void handleMouseMove(QPoint globalPos);
|
||||||
void leaveEvent(QEvent *e);
|
void handleMouseRelease(QPoint globalPos);
|
||||||
void mousePressEvent(QMouseEvent *e);
|
|
||||||
void mouseReleaseEvent(QMouseEvent *e);
|
|
||||||
void mouseMoveEvent(QMouseEvent *e);
|
|
||||||
|
|
||||||
void step_appearance(float64 ms, bool timer);
|
|
||||||
void step_selected(uint64 ms, bool timer);
|
|
||||||
|
|
||||||
void clearSelection(bool fast = false);
|
|
||||||
|
|
||||||
void hideFast();
|
void hideFast();
|
||||||
|
|
||||||
|
@ -89,21 +81,26 @@ signals:
|
||||||
void emojiSelected(EmojiPtr emoji);
|
void emojiSelected(EmojiPtr emoji);
|
||||||
void hidden();
|
void hidden();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
void enterEvent(QEvent *e) override;
|
||||||
|
void leaveEvent(QEvent *e) override;
|
||||||
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void step_appearance(float64 ms, bool timer);
|
||||||
|
|
||||||
void drawVariant(Painter &p, int variant);
|
void drawVariant(Painter &p, int variant);
|
||||||
|
|
||||||
void updateSelected();
|
void updateSelected();
|
||||||
|
void setSelected(int newSelected);
|
||||||
|
|
||||||
bool _ignoreShow = false;
|
bool _ignoreShow = false;
|
||||||
|
|
||||||
EmojiPtr _variants[EmojiColorsCount + 1];
|
EmojiPtr _variants[EmojiColorsCount + 1];
|
||||||
|
|
||||||
typedef QMap<int32, uint64> EmojiAnimations; // index - showing, -index - hiding
|
|
||||||
EmojiAnimations _emojiAnimations;
|
|
||||||
Animation _a_selected;
|
|
||||||
|
|
||||||
float64 _hovers[EmojiColorsCount + 1];
|
|
||||||
|
|
||||||
int _selected = -1;
|
int _selected = -1;
|
||||||
int _pressedSel = -1;
|
int _pressedSel = -1;
|
||||||
QPoint _lastMousePos;
|
QPoint _lastMousePos;
|
||||||
|
@ -128,14 +125,12 @@ public:
|
||||||
EmojiPanInner(QWidget *parent);
|
EmojiPanInner(QWidget *parent);
|
||||||
|
|
||||||
void setMaxHeight(int32 h);
|
void setMaxHeight(int32 h);
|
||||||
void paintEvent(QPaintEvent *e) override;
|
|
||||||
|
|
||||||
void step_selected(uint64 ms, bool timer);
|
|
||||||
void hideFinish();
|
void hideFinish();
|
||||||
|
|
||||||
void showEmojiPack(DBIEmojiTab packIndex);
|
void showEmojiPack(DBIEmojiTab packIndex);
|
||||||
|
|
||||||
void clearSelection(bool fast = false);
|
void clearSelection();
|
||||||
|
|
||||||
DBIEmojiTab currentTab(int yOffset) const;
|
DBIEmojiTab currentTab(int yOffset) const;
|
||||||
|
|
||||||
|
@ -150,13 +145,12 @@ protected:
|
||||||
void mousePressEvent(QMouseEvent *e) override;
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||||
void mouseMoveEvent(QMouseEvent *e) override;
|
void mouseMoveEvent(QMouseEvent *e) override;
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
void leaveEvent(QEvent *e) override;
|
void leaveEvent(QEvent *e) override;
|
||||||
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
||||||
void enterFromChildEvent(QEvent *e, QWidget *child) override;
|
void enterFromChildEvent(QEvent *e, QWidget *child) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateSelected();
|
|
||||||
|
|
||||||
void onShowPicker();
|
void onShowPicker();
|
||||||
void onPickerHidden();
|
void onPickerHidden();
|
||||||
void onColorSelected(EmojiPtr emoji);
|
void onColorSelected(EmojiPtr emoji);
|
||||||
|
@ -175,6 +169,9 @@ signals:
|
||||||
void saveConfigDelayed(int32 delay);
|
void saveConfigDelayed(int32 delay);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateSelected();
|
||||||
|
void setSelected(int newSelected);
|
||||||
|
|
||||||
int32 _maxHeight;
|
int32 _maxHeight;
|
||||||
|
|
||||||
int countHeight();
|
int countHeight();
|
||||||
|
@ -182,16 +179,11 @@ private:
|
||||||
|
|
||||||
QRect emojiRect(int tab, int sel);
|
QRect emojiRect(int tab, int sel);
|
||||||
|
|
||||||
typedef QMap<int32, uint64> Animations; // index - showing, -index - hiding
|
|
||||||
Animations _animations;
|
|
||||||
Animation _a_selected;
|
|
||||||
|
|
||||||
int _visibleTop = 0;
|
int _visibleTop = 0;
|
||||||
int _visibleBottom = 0;
|
int _visibleBottom = 0;
|
||||||
int _counts[emojiTabCount];
|
int _counts[emojiTabCount];
|
||||||
|
|
||||||
QVector<EmojiPtr> _emojis[emojiTabCount];
|
QVector<EmojiPtr> _emojis[emojiTabCount];
|
||||||
QVector<float64> _hovers[emojiTabCount];
|
|
||||||
|
|
||||||
int32 _esize;
|
int32 _esize;
|
||||||
|
|
||||||
|
@ -222,9 +214,6 @@ public:
|
||||||
StickerPanInner(QWidget *parent);
|
StickerPanInner(QWidget *parent);
|
||||||
|
|
||||||
void setMaxHeight(int32 h);
|
void setMaxHeight(int32 h);
|
||||||
void paintEvent(QPaintEvent *e) override;
|
|
||||||
|
|
||||||
void step_selected(uint64 ms, bool timer);
|
|
||||||
|
|
||||||
void hideFinish(bool completely);
|
void hideFinish(bool completely);
|
||||||
void showFinish();
|
void showFinish();
|
||||||
|
@ -232,7 +221,7 @@ public:
|
||||||
void updateShowingSavedGifs();
|
void updateShowingSavedGifs();
|
||||||
|
|
||||||
bool showSectionIcons() const;
|
bool showSectionIcons() const;
|
||||||
void clearSelection(bool fast = false);
|
void clearSelection();
|
||||||
|
|
||||||
void refreshStickers();
|
void refreshStickers();
|
||||||
void refreshRecentStickers(bool resize = true);
|
void refreshRecentStickers(bool resize = true);
|
||||||
|
@ -272,12 +261,12 @@ protected:
|
||||||
void mousePressEvent(QMouseEvent *e) override;
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||||
void mouseMoveEvent(QMouseEvent *e) override;
|
void mouseMoveEvent(QMouseEvent *e) override;
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
void leaveEvent(QEvent *e) override;
|
void leaveEvent(QEvent *e) override;
|
||||||
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
||||||
void enterFromChildEvent(QEvent *e, QWidget *child) override;
|
void enterFromChildEvent(QEvent *e, QWidget *child) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateSelected();
|
|
||||||
void onSettings();
|
void onSettings();
|
||||||
void onPreview();
|
void onPreview();
|
||||||
void onUpdateInlineItems();
|
void onUpdateInlineItems();
|
||||||
|
@ -308,15 +297,17 @@ private:
|
||||||
static constexpr bool kRefreshIconsScrollAnimation = true;
|
static constexpr bool kRefreshIconsScrollAnimation = true;
|
||||||
static constexpr bool kRefreshIconsNoAnimation = false;
|
static constexpr bool kRefreshIconsNoAnimation = false;
|
||||||
|
|
||||||
|
void updateSelected();
|
||||||
|
void setSelected(int newSelected, int newSelectedFeaturedSet, int newSelectedFeaturedSetAdd);
|
||||||
|
|
||||||
void setPressedFeaturedSetAdd(int newPressedFeaturedSetAdd);
|
void setPressedFeaturedSetAdd(int newPressedFeaturedSetAdd);
|
||||||
|
|
||||||
struct Set {
|
struct Set {
|
||||||
Set(uint64 id, MTPDstickerSet::Flags flags, const QString &title, int32 hoversSize, const StickerPack &pack = StickerPack()) : id(id), flags(flags), title(title), hovers(hoversSize, 0), pack(pack) {
|
Set(uint64 id, MTPDstickerSet::Flags flags, const QString &title, int32 hoversSize, const StickerPack &pack = StickerPack()) : id(id), flags(flags), title(title), pack(pack) {
|
||||||
}
|
}
|
||||||
uint64 id;
|
uint64 id;
|
||||||
MTPDstickerSet::Flags flags;
|
MTPDstickerSet::Flags flags;
|
||||||
QString title;
|
QString title;
|
||||||
QVector<float64> hovers;
|
|
||||||
StickerPack pack;
|
StickerPack pack;
|
||||||
QSharedPointer<Ui::RippleAnimation> ripple;
|
QSharedPointer<Ui::RippleAnimation> ripple;
|
||||||
};
|
};
|
||||||
|
@ -336,7 +327,7 @@ private:
|
||||||
|
|
||||||
void paintInlineItems(Painter &p, const QRect &r);
|
void paintInlineItems(Painter &p, const QRect &r);
|
||||||
void paintStickers(Painter &p, const QRect &r);
|
void paintStickers(Painter &p, const QRect &r);
|
||||||
void paintSticker(Painter &p, Set &set, int y, int index);
|
void paintSticker(Painter &p, Set &set, int y, int index, bool selected, bool deleteSelected);
|
||||||
bool featuredHasAddButton(int index) const;
|
bool featuredHasAddButton(int index) const;
|
||||||
int featuredContentWidth() const;
|
int featuredContentWidth() const;
|
||||||
QRect featuredAddRect(int y) const;
|
QRect featuredAddRect(int y) const;
|
||||||
|
@ -355,10 +346,6 @@ private:
|
||||||
|
|
||||||
int32 _maxHeight;
|
int32 _maxHeight;
|
||||||
|
|
||||||
typedef QMap<int32, uint64> Animations; // index - showing, -index - hiding
|
|
||||||
Animations _animations;
|
|
||||||
Animation _a_selected;
|
|
||||||
|
|
||||||
int _visibleTop = 0;
|
int _visibleTop = 0;
|
||||||
int _visibleBottom = 0;
|
int _visibleBottom = 0;
|
||||||
|
|
||||||
|
@ -436,15 +423,11 @@ class EmojiPanel : public TWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EmojiPanel(QWidget *parent, const QString &text, uint64 setId, bool special, int32 wantedY); // Stickers::NoneSetId if in emoji
|
EmojiPanel(QWidget *parent, const QString &text, uint64 setId, bool special, int32 wantedY); // Stickers::NoneSetId if in emoji
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
void setDeleteVisible(bool isVisible);
|
void setDeleteVisible(bool isVisible);
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *e);
|
int wantedY() const {
|
||||||
void mousePressEvent(QMouseEvent *e);
|
|
||||||
|
|
||||||
int32 wantedY() const {
|
|
||||||
return _wantedY;
|
return _wantedY;
|
||||||
}
|
}
|
||||||
void setWantedY(int32 y) {
|
void setWantedY(int32 y) {
|
||||||
|
@ -452,38 +435,39 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void deleteClicked(quint64 setId);
|
void deleteClicked(quint64 setId);
|
||||||
void mousePressed();
|
void mousePressed();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void onDelete();
|
void onDelete();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
|
|
||||||
|
private:
|
||||||
void updateText();
|
void updateText();
|
||||||
|
|
||||||
int32 _wantedY;
|
int32 _wantedY;
|
||||||
QString _text, _fullText;
|
QString _text, _fullText;
|
||||||
uint64 _setId;
|
uint64 _setId;
|
||||||
bool _special, _deleteVisible;
|
bool _special, _deleteVisible;
|
||||||
Ui::IconButton *_delete;
|
Ui::IconButton *_delete = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class EmojiSwitchButton : public Ui::AbstractButton {
|
class EmojiSwitchButton : public Ui::AbstractButton {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EmojiSwitchButton(QWidget *parent, bool toStickers); // otherwise toEmoji
|
EmojiSwitchButton(QWidget *parent, bool toStickers); // otherwise toEmoji
|
||||||
void paintEvent(QPaintEvent *e);
|
|
||||||
void updateText(const QString &inlineBotUsername = QString());
|
void updateText(const QString &inlineBotUsername = QString());
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
bool _toStickers;
|
private:
|
||||||
|
bool _toStickers = false;
|
||||||
QString _text;
|
QString _text;
|
||||||
int32 _textWidth;
|
int _textWidth = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -496,21 +480,9 @@ public:
|
||||||
EmojiPan(QWidget *parent);
|
EmojiPan(QWidget *parent);
|
||||||
|
|
||||||
void setMaxHeight(int32 h);
|
void setMaxHeight(int32 h);
|
||||||
void paintEvent(QPaintEvent *e);
|
|
||||||
|
|
||||||
void moveBottom(int32 bottom, bool force = false);
|
void moveBottom(int32 bottom, bool force = false);
|
||||||
|
|
||||||
void enterEvent(QEvent *e);
|
|
||||||
void leaveEvent(QEvent *e);
|
|
||||||
void otherEnter();
|
|
||||||
void otherLeave();
|
|
||||||
|
|
||||||
void mousePressEvent(QMouseEvent *e);
|
|
||||||
void mouseMoveEvent(QMouseEvent *e);
|
|
||||||
void mouseReleaseEvent(QMouseEvent *e);
|
|
||||||
|
|
||||||
bool event(QEvent *e);
|
|
||||||
|
|
||||||
void hideFast();
|
void hideFast();
|
||||||
bool hiding() const {
|
bool hiding() const {
|
||||||
return _hiding || _hideTimer.isActive();
|
return _hiding || _hideTimer.isActive();
|
||||||
|
@ -518,7 +490,6 @@ public:
|
||||||
|
|
||||||
void step_icons(uint64 ms, bool timer);
|
void step_icons(uint64 ms, bool timer);
|
||||||
|
|
||||||
bool eventFilter(QObject *obj, QEvent *e);
|
|
||||||
void stickersInstalled(uint64 setId);
|
void stickersInstalled(uint64 setId);
|
||||||
|
|
||||||
void queryInlineBot(UserData *bot, PeerData *peer, QString query);
|
void queryInlineBot(UserData *bot, PeerData *peer, QString query);
|
||||||
|
@ -545,6 +516,20 @@ public:
|
||||||
|
|
||||||
~EmojiPan();
|
~EmojiPan();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void enterEvent(QEvent *e) override;
|
||||||
|
void leaveEvent(QEvent *e) override;
|
||||||
|
void otherEnter();
|
||||||
|
void otherLeave();
|
||||||
|
|
||||||
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent *e) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
|
bool event(QEvent *e) override;
|
||||||
|
bool eventFilter(QObject *obj, QEvent *e) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void refreshStickers();
|
void refreshStickers();
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,6 @@ stickersMaxHeight: 440px;
|
||||||
stickersPadding: margins(19px, 17px, 19px, 17px);
|
stickersPadding: margins(19px, 17px, 19px, 17px);
|
||||||
stickersSize: size(64px, 64px);
|
stickersSize: size(64px, 64px);
|
||||||
stickersScroll: FlatScroll(boxScroll) {
|
stickersScroll: FlatScroll(boxScroll) {
|
||||||
round: 2px;
|
|
||||||
deltax: 7px;
|
|
||||||
deltat: 23px;
|
deltat: 23px;
|
||||||
deltab: 9px;
|
deltab: 9px;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +128,7 @@ emojiPanWidth: 345px;
|
||||||
emojiPanMaxHeight: 366px;
|
emojiPanMaxHeight: 366px;
|
||||||
emojiPanShowDuration: 200;
|
emojiPanShowDuration: 200;
|
||||||
emojiPanDuration: 200;
|
emojiPanDuration: 200;
|
||||||
emojiPanHover: #f0f4f7;
|
emojiPanHover: windowBgOver;
|
||||||
emojiPanSlideDuration: 200;
|
emojiPanSlideDuration: 200;
|
||||||
emojiPanSlideDelta: 0; // between hide start and show start
|
emojiPanSlideDelta: 0; // between hide start and show start
|
||||||
|
|
||||||
|
|
|
@ -527,15 +527,7 @@ defaultFlatScroll: FlatScroll {
|
||||||
hiding: 1000;
|
hiding: 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultSolidScroll: FlatScroll {
|
defaultSolidScroll: FlatScroll(defaultFlatScroll) {
|
||||||
barColor: #3f729734;
|
|
||||||
bgColor: #214f751a;
|
|
||||||
barOverColor: #3f729734;
|
|
||||||
bgOverColor: #214f751a;
|
|
||||||
|
|
||||||
minHeight: 20px;
|
|
||||||
|
|
||||||
round: 2px;
|
|
||||||
deltax: 5px;
|
deltax: 5px;
|
||||||
width: 14px;
|
width: 14px;
|
||||||
deltat: 6px;
|
deltat: 6px;
|
||||||
|
@ -543,9 +535,7 @@ defaultSolidScroll: FlatScroll {
|
||||||
|
|
||||||
topsh: 0px;
|
topsh: 0px;
|
||||||
bottomsh: 0px;
|
bottomsh: 0px;
|
||||||
shColor: #00000012;
|
|
||||||
|
|
||||||
duration: 150;
|
|
||||||
hiding: 0;
|
hiding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
|
||||||
TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w)
|
TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w)
|
||||||
, _a_appearance(animation(this, &TopBarWidget::step_appearance))
|
|
||||||
, _clearSelection(this, lang(lng_selected_clear), st::topBarClearButton)
|
, _clearSelection(this, lang(lng_selected_clear), st::topBarClearButton)
|
||||||
, _forward(this, lang(lng_selected_forward), st::defaultActiveButton)
|
, _forward(this, lang(lng_selected_forward), st::defaultActiveButton)
|
||||||
, _delete(this, lang(lng_selected_delete), st::defaultActiveButton)
|
, _delete(this, lang(lng_selected_delete), st::defaultActiveButton)
|
||||||
|
@ -44,8 +43,6 @@ TopBarWidget::TopBarWidget(MainWidget *w) : TWidget(w)
|
||||||
, _mediaType(this, lang(lng_media_type), st::topBarButton)
|
, _mediaType(this, lang(lng_media_type), st::topBarButton)
|
||||||
, _search(this, st::topBarSearch)
|
, _search(this, st::topBarSearch)
|
||||||
, _menuToggle(this, st::topBarMenuToggle) {
|
, _menuToggle(this, st::topBarMenuToggle) {
|
||||||
_mediaType->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
|
|
||||||
|
|
||||||
_forward->setClickedCallback([this] { onForwardSelection(); });
|
_forward->setClickedCallback([this] { onForwardSelection(); });
|
||||||
_delete->setClickedCallback([this] { onDeleteSelection(); });
|
_delete->setClickedCallback([this] { onDeleteSelection(); });
|
||||||
_clearSelection->setClickedCallback([this] { onClearSelection(); });
|
_clearSelection->setClickedCallback([this] { onClearSelection(); });
|
||||||
|
@ -139,41 +136,6 @@ void TopBarWidget::showMenu() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopBarWidget::enterEvent(QEvent *e) {
|
|
||||||
a_over.start(1);
|
|
||||||
_a_appearance.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TopBarWidget::enterFromChildEvent(QEvent *e, QWidget *child) {
|
|
||||||
if (child != _membersShowArea) {
|
|
||||||
a_over.start(1);
|
|
||||||
_a_appearance.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TopBarWidget::leaveEvent(QEvent *e) {
|
|
||||||
a_over.start(0);
|
|
||||||
_a_appearance.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TopBarWidget::leaveToChildEvent(QEvent *e, QWidget *child) {
|
|
||||||
if (child != _membersShowArea) {
|
|
||||||
a_over.start(0);
|
|
||||||
_a_appearance.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TopBarWidget::step_appearance(float64 ms, bool timer) {
|
|
||||||
float64 dt = ms / st::topBarDuration;
|
|
||||||
if (dt >= 1) {
|
|
||||||
_a_appearance.stop();
|
|
||||||
a_over.finish();
|
|
||||||
} else {
|
|
||||||
a_over.update(dt, anim::linear);
|
|
||||||
}
|
|
||||||
if (timer) update();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TopBarWidget::eventFilter(QObject *obj, QEvent *e) {
|
bool TopBarWidget::eventFilter(QObject *obj, QEvent *e) {
|
||||||
if (obj == _membersShowArea) {
|
if (obj == _membersShowArea) {
|
||||||
switch (e->type()) {
|
switch (e->type()) {
|
||||||
|
@ -207,7 +169,7 @@ void TopBarWidget::paintEvent(QPaintEvent *e) {
|
||||||
if (!_search->isHidden()) {
|
if (!_search->isHidden()) {
|
||||||
decreaseWidth += _search->width();
|
decreaseWidth += _search->width();
|
||||||
}
|
}
|
||||||
auto paintCounter = main()->paintTopBar(p, a_over.current(), decreaseWidth);
|
auto paintCounter = main()->paintTopBar(p, decreaseWidth);
|
||||||
p.restore();
|
p.restore();
|
||||||
|
|
||||||
if (paintCounter) {
|
if (paintCounter) {
|
||||||
|
|
|
@ -37,16 +37,6 @@ class TopBarWidget : public TWidget, private base::Subscriber {
|
||||||
public:
|
public:
|
||||||
TopBarWidget(MainWidget *w);
|
TopBarWidget(MainWidget *w);
|
||||||
|
|
||||||
void enterEvent(QEvent *e) override;
|
|
||||||
void enterFromChildEvent(QEvent *e, QWidget *child) override;
|
|
||||||
void leaveEvent(QEvent *e) override;
|
|
||||||
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
|
||||||
void paintEvent(QPaintEvent *e) override;
|
|
||||||
void mousePressEvent(QMouseEvent *e) override;
|
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
|
||||||
|
|
||||||
void step_appearance(float64 ms, bool timer);
|
|
||||||
|
|
||||||
void startAnim();
|
void startAnim();
|
||||||
void stopAnim();
|
void stopAnim();
|
||||||
void showAll();
|
void showAll();
|
||||||
|
@ -59,6 +49,9 @@ public:
|
||||||
static void paintUnreadCounter(Painter &p, int outerWidth);
|
static void paintUnreadCounter(Painter &p, int outerWidth);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
bool eventFilter(QObject *obj, QEvent *e) override;
|
bool eventFilter(QObject *obj, QEvent *e) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -75,8 +68,6 @@ private:
|
||||||
void updateAdaptiveLayout();
|
void updateAdaptiveLayout();
|
||||||
|
|
||||||
MainWidget *main();
|
MainWidget *main();
|
||||||
anim::fvalue a_over = { 0. };
|
|
||||||
Animation _a_appearance;
|
|
||||||
|
|
||||||
PeerData *_searchInPeer = nullptr;
|
PeerData *_searchInPeer = nullptr;
|
||||||
PeerData *_selPeer = nullptr;
|
PeerData *_selPeer = nullptr;
|
||||||
|
|
|
@ -174,31 +174,12 @@ topBarMenuPosition: point(-2px, 35px);
|
||||||
topBarDuration: 200;
|
topBarDuration: 200;
|
||||||
topBarBackward: icon {{ "title_back", #a3a3a3 }};
|
topBarBackward: icon {{ "title_back", #a3a3a3 }};
|
||||||
topBarForwardAlpha: 0.6;
|
topBarForwardAlpha: 0.6;
|
||||||
topBarBack: icon {{ "title_back", #259fd8 }};
|
topBarBack: icon {{ "title_back", lightButtonFg }};
|
||||||
topBarBackAlpha: 0.8;
|
|
||||||
topBarBackColor: #005faf;
|
|
||||||
topBarBackFont: font(16px);
|
|
||||||
topBarArrowPadding: margins(39px, 8px, 17px, 8px);
|
topBarArrowPadding: margins(39px, 8px, 17px, 8px);
|
||||||
topBarMinPadding: 5px;
|
topBarMinPadding: 5px;
|
||||||
topBarButton: RoundButton {
|
topBarButton: RoundButton(defaultLightButton) {
|
||||||
textFg: btnYesColor;
|
width: -18px;
|
||||||
textFgOver: btnYesColor;
|
padding: margins(0px, 10px, 12px, 10px);
|
||||||
secondaryTextFg: btnYesColor;
|
|
||||||
secondaryTextFgOver: btnYesColor;
|
|
||||||
textBg: windowBg;
|
|
||||||
textBgOver: #edf4f7;
|
|
||||||
|
|
||||||
width: -22px;
|
|
||||||
height: 28px;
|
|
||||||
padding: margins(0px, 14px, 12px, 12px);
|
|
||||||
|
|
||||||
textTop: 6px;
|
|
||||||
|
|
||||||
font: font(fsize);
|
|
||||||
|
|
||||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
|
||||||
color: lightButtonBgRipple;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
topBarClearButton: RoundButton(defaultLightButton) {
|
topBarClearButton: RoundButton(defaultLightButton) {
|
||||||
width: -18px;
|
width: -18px;
|
||||||
|
|
Loading…
Add table
Reference in a new issue