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