mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-30 22:16:14 +00:00
Closed beta 10019008: Some more ripple animations added.
This commit is contained in:
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
|
||||
namespace Ui {
|
||||
class Radiobutton;
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
#include "core/lambda_wrap.h"
|
||||
|
||||
class BackgroundBox : public ItemListBox {
|
||||
|
@@ -37,7 +37,6 @@ defaultBoxButton: RoundButton {
|
||||
padding: margins(0px, 0px, 0px, 0px);
|
||||
|
||||
textTop: 8px;
|
||||
downTextTop: 8px;
|
||||
|
||||
font: boxButtonFont;
|
||||
|
||||
@@ -51,12 +50,12 @@ cancelBoxButton: RoundButton(defaultBoxButton) {
|
||||
}
|
||||
|
||||
attentionBoxButton: RoundButton(defaultBoxButton) {
|
||||
textFg: attentionBoxButtonFg;
|
||||
textFgOver: attentionBoxButtonFgOver;
|
||||
textBgOver: attentionBoxButtonBgOver;
|
||||
textFg: attentionButtonFg;
|
||||
textFgOver: attentionButtonFgOver;
|
||||
textBgOver: attentionButtonBgOver;
|
||||
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: attentionBoxButtonBgRipple;
|
||||
color: attentionButtonBgRipple;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,12 +197,21 @@ contactUserIcon: icon {{ "add_contact_user", #999999 }};
|
||||
contactPhoneIcon: icon {{ "add_contact_phone", #999999 }};
|
||||
contactIconTop: 10px;
|
||||
|
||||
contactsAdd: IconButton {
|
||||
contactsAddIconAbove: icon {{ "contacts_add", activeButtonFg, point(18px, 18px) }};
|
||||
contactsAdd: TwoIconButton {
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
|
||||
icon: contactsAddIcon;
|
||||
iconOver: contactsAddIconOver;
|
||||
iconBelow: contactsAddIconBelow;
|
||||
iconBelowOver: contactsAddIconBelowOver;
|
||||
iconAbove: contactsAddIconAbove;
|
||||
iconAboveOver: contactsAddIconAbove;
|
||||
|
||||
rippleAreaPosition: point(5px, 5px);
|
||||
rippleAreaSize: 42px;
|
||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||
color: activeButtonBgRipple;
|
||||
}
|
||||
}
|
||||
contactsAddPosition: point(14px, 8px);
|
||||
|
||||
@@ -289,9 +297,7 @@ contactsMultiSelect: MultiSelect {
|
||||
|
||||
icon: boxSearchCancelIcon;
|
||||
iconOver: boxSearchCancelIconOver;
|
||||
|
||||
iconPosition: point(8px, 18px);
|
||||
iconPositionDown: point(8px, 18px);
|
||||
}
|
||||
fieldCancelSkip: 34px;
|
||||
}
|
||||
@@ -370,9 +376,7 @@ sessionTerminate: IconButton {
|
||||
|
||||
icon: simpleCloseIcon;
|
||||
iconOver: simpleCloseIconOver;
|
||||
|
||||
iconPosition: point(3px, 3px);
|
||||
iconPositionDown: point(3px, 4px);
|
||||
}
|
||||
sessionTerminateAllButton: LinkButton(boxLinkButton) {
|
||||
color: #d15948;
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
|
||||
namespace Ui {
|
||||
class InputField;
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
#include "core/single_timer.h"
|
||||
#include "ui/effects/round_image_checkbox.h"
|
||||
#include "boxes/members_box.h"
|
||||
@@ -93,7 +93,7 @@ private:
|
||||
class Inner;
|
||||
ChildWidget<Inner> _inner;
|
||||
ChildWidget<Ui::WidgetSlideWrap<Ui::MultiSelect>> _select;
|
||||
ChildWidget<Ui::IconButton> _add = { nullptr };
|
||||
ChildWidget<MembersAddButton> _add = { nullptr };
|
||||
|
||||
ChildWidget<Ui::RoundButton> _next;
|
||||
ChildWidget<Ui::RoundButton> _cancel;
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
#include "core/observer.h"
|
||||
|
||||
namespace Ui {
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
|
||||
class EmojiBox : public AbstractBox {
|
||||
Q_OBJECT
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
|
||||
namespace Ui {
|
||||
class Radiobutton;
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
|
||||
namespace Ui {
|
||||
class RoundButton;
|
||||
|
@@ -30,8 +30,36 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
#include "boxes/confirmbox.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/effects/ripple_animation.h"
|
||||
#include "observer_peer.h"
|
||||
|
||||
|
||||
MembersAddButton::MembersAddButton(QWidget *parent, const style::TwoIconButton &st) : RippleButton(parent, st.ripple)
|
||||
, _st(st) {
|
||||
resize(_st.width, _st.height);
|
||||
setCursor(style::cur_pointer);
|
||||
}
|
||||
|
||||
void MembersAddButton::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
|
||||
auto ms = getms();
|
||||
auto over = (_state & StateOver);
|
||||
auto down = (_state & StateDown);
|
||||
|
||||
((over || down) ? _st.iconBelowOver : _st.iconBelow).paint(p, _st.iconPosition, width());
|
||||
paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y(), ms);
|
||||
((over || down) ? _st.iconAboveOver : _st.iconAbove).paint(p, _st.iconPosition, width());
|
||||
}
|
||||
|
||||
QImage MembersAddButton::prepareRippleMask() const {
|
||||
return Ui::RippleAnimation::ellipseMask(QSize(_st.rippleAreaSize, _st.rippleAreaSize));
|
||||
}
|
||||
|
||||
QPoint MembersAddButton::prepareRippleStartPosition() const {
|
||||
return mapFromGlobal(QCursor::pos()) - _st.rippleAreaPosition;
|
||||
}
|
||||
|
||||
MembersBox::MembersBox(ChannelData *channel, MembersFilter filter) : ItemListBox(st::boxScroll)
|
||||
, _inner(this, channel, filter) {
|
||||
ItemListBox::init(_inner);
|
||||
|
@@ -20,9 +20,10 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
#include "core/single_timer.h"
|
||||
#include "ui/effects/round_image_checkbox.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
|
||||
class ContactsBox;
|
||||
class ConfirmBox;
|
||||
@@ -33,6 +34,21 @@ enum class MembersFilter {
|
||||
};
|
||||
using MembersAlreadyIn = OrderedSet<UserData*>;
|
||||
|
||||
class MembersAddButton : public Ui::RippleButton {
|
||||
public:
|
||||
MembersAddButton(QWidget *parent, const style::TwoIconButton &st);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
QImage prepareRippleMask() const override;
|
||||
QPoint prepareRippleStartPosition() const override;
|
||||
|
||||
private:
|
||||
const style::TwoIconButton &_st;
|
||||
|
||||
};
|
||||
|
||||
class MembersBox : public ItemListBox {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -54,7 +70,7 @@ private:
|
||||
|
||||
class Inner;
|
||||
ChildWidget<Inner> _inner;
|
||||
ChildWidget<Ui::IconButton> _add = { nullptr };
|
||||
ChildWidget<MembersAddButton> _add = { nullptr };
|
||||
|
||||
ContactsBox *_addBox = nullptr;
|
||||
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
|
||||
namespace Ui {
|
||||
class RoundButton;
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
|
||||
namespace Ui {
|
||||
class InputField;
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
|
||||
namespace Ui {
|
||||
class RoundButton;
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
#include "localimageloader.h"
|
||||
|
||||
namespace Ui {
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
|
||||
namespace Ui {
|
||||
class Radiobutton;
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
#include "core/single_timer.h"
|
||||
|
||||
class ConfirmBox;
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
#include "core/lambda_wrap.h"
|
||||
#include "core/observer.h"
|
||||
#include "core/vector_of_moveable.h"
|
||||
|
@@ -33,6 +33,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
#include "styles/style_stickers.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/effects/ripple_animation.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -563,6 +564,7 @@ void StickersBox::Inner::paintEvent(QPaintEvent *e) {
|
||||
|
||||
_a_shifting.step();
|
||||
|
||||
auto ms = getms();
|
||||
p.fillRect(r, st::boxBg);
|
||||
p.setClipRect(r);
|
||||
|
||||
@@ -591,19 +593,26 @@ void StickersBox::Inner::paintEvent(QPaintEvent *e) {
|
||||
p.translate(0, from * _rowHeight);
|
||||
for (int32 i = from; i < to; ++i) {
|
||||
if (i != _above) {
|
||||
paintRow(p, i);
|
||||
paintRow(p, i, ms);
|
||||
}
|
||||
p.translate(0, _rowHeight);
|
||||
}
|
||||
if (from <= _above && _above < to) {
|
||||
p.translate(0, (_above - to) * _rowHeight);
|
||||
paintRow(p, _above);
|
||||
paintRow(p, _above, ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StickersBox::Inner::paintRow(Painter &p, int32 index) {
|
||||
const StickerSetRow *s(_rows.at(index));
|
||||
QRect StickersBox::Inner::relativeAddButtonRect() const {
|
||||
int addw = st::stickersAddSize.width();
|
||||
int addx = width() - st::contactsPadding.right() - st::contactsCheckPosition.x() - addw;
|
||||
int addy = st::contactsPadding.top() + (st::contactsPhotoSize - st::stickersAddSize.height()) / 2;
|
||||
return QRect(addx, addy, addw, st::stickersAddSize.height());
|
||||
}
|
||||
|
||||
void StickersBox::Inner::paintRow(Painter &p, int32 index, uint64 ms) {
|
||||
auto s = _rows.at(index);
|
||||
|
||||
int32 xadd = 0, yadd = s->yadd.current();
|
||||
if (xadd || yadd) p.translate(xadd, yadd);
|
||||
@@ -639,17 +648,23 @@ void StickersBox::Inner::paintRow(Painter &p, int32 index) {
|
||||
int checkx = width() - (st::contactsPadding.right() + st::contactsCheckPosition.x() + (addw + st::stickersFeaturedInstalled.width()) / 2);
|
||||
int checky = st::contactsPadding.top() + (st::contactsPhotoSize - st::stickersFeaturedInstalled.height()) / 2;
|
||||
st::stickersFeaturedInstalled.paint(p, QPoint(checkx, checky), width());
|
||||
if (s->ripple) {
|
||||
s->ripple.reset();
|
||||
}
|
||||
} else {
|
||||
int addw = st::stickersAddSize.width();
|
||||
int addx = width() - st::contactsPadding.right() - st::contactsCheckPosition.x() - addw;
|
||||
int addy = st::contactsPadding.top() + (st::contactsPhotoSize - st::stickersAddSize.height()) / 2;
|
||||
QRect add(myrtlrect(addx, addy, addw, st::stickersAddSize.height()));
|
||||
auto relativeAdd = relativeAddButtonRect();
|
||||
auto add = myrtlrect(relativeAdd);
|
||||
|
||||
auto &textBg = (_actionSel == index) ? st::defaultActiveButton.textBgOver : st::defaultActiveButton.textBg;
|
||||
auto &textBg = (_actionSel == index || _actionDown == index) ? st::defaultActiveButton.textBgOver : st::defaultActiveButton.textBg;
|
||||
App::roundRect(p, add, textBg, ImageRoundRadius::Small);
|
||||
int iconx = addx + (st::stickersAddSize.width() - st::stickersAddIcon.width()) / 2;
|
||||
int icony = addy + (st::stickersAddSize.height() - st::stickersAddIcon.height()) / 2;
|
||||
icony += (_actionSel == index && _actionDown == index) ? (st::defaultActiveButton.downTextTop - st::defaultActiveButton.textTop) : 0;
|
||||
if (s->ripple) {
|
||||
s->ripple->paint(p, relativeAdd.x(), relativeAdd.y(), width(), ms);
|
||||
if (s->ripple->empty()) {
|
||||
s->ripple.reset();
|
||||
}
|
||||
}
|
||||
int iconx = relativeAdd.x() + (st::stickersAddSize.width() - st::stickersAddIcon.width()) / 2;
|
||||
int icony = relativeAdd.y() + (st::stickersAddSize.height() - st::stickersAddIcon.height()) / 2;
|
||||
st::stickersAddIcon.paint(p, QPoint(iconx, icony), width());
|
||||
}
|
||||
|
||||
@@ -696,7 +711,7 @@ void StickersBox::Inner::mousePressEvent(QMouseEvent *e) {
|
||||
|
||||
_pressed = _selected;
|
||||
if (_actionSel >= 0) {
|
||||
_actionDown = _actionSel;
|
||||
setActionDown(_actionSel);
|
||||
update(0, _itemsTop + _actionSel * _rowHeight, width(), _rowHeight);
|
||||
} else if (_selected >= 0 && _section == Section::Installed && !_rows.at(_selected)->recent) {
|
||||
_above = _dragging = _started = _selected;
|
||||
@@ -704,6 +719,33 @@ void StickersBox::Inner::mousePressEvent(QMouseEvent *e) {
|
||||
}
|
||||
}
|
||||
|
||||
void StickersBox::Inner::setActionDown(int newActionDown) {
|
||||
if (_actionDown == newActionDown) {
|
||||
return;
|
||||
}
|
||||
if (_actionDown >= 0 && _actionDown < _rows.size()) {
|
||||
update(0, _itemsTop + _actionDown * _rowHeight, width(), _rowHeight);
|
||||
auto set = _rows[_actionDown];
|
||||
if (set->ripple) {
|
||||
set->ripple->lastStop();
|
||||
}
|
||||
}
|
||||
_actionDown = newActionDown;
|
||||
if (_actionDown >= 0 && _actionDown < _rows.size()) {
|
||||
update(0, _itemsTop + _actionDown * _rowHeight, width(), _rowHeight);
|
||||
auto set = _rows[_actionDown];
|
||||
if (!set->ripple) {
|
||||
auto mask = Ui::RippleAnimation::roundRectMask(st::stickersAddSize, st::buttonRadius);
|
||||
set->ripple = MakeShared<Ui::RippleAnimation>(st::defaultActiveButton.ripple, std_::move(mask), [this, index = _actionDown] {
|
||||
update(0, _itemsTop + index * _rowHeight, width(), _rowHeight);
|
||||
});
|
||||
}
|
||||
auto relativeAdd = relativeAddButtonRect();
|
||||
auto add = myrtlrect(relativeAdd);
|
||||
set->ripple->add(mapFromGlobal(QCursor::pos()) - QPoint(add.x(), _itemsTop + _actionDown * _rowHeight + add.y()));
|
||||
}
|
||||
}
|
||||
|
||||
void StickersBox::Inner::mouseMoveEvent(QMouseEvent *e) {
|
||||
if (_saving) return;
|
||||
_mouse = e->globalPos();
|
||||
@@ -762,10 +804,8 @@ void StickersBox::Inner::onUpdateSelected() {
|
||||
} else if (_rows.at(selected)->installed && !_rows.at(selected)->disabled) {
|
||||
actionSel = -1;
|
||||
} else {
|
||||
int addw = st::stickersAddSize.width();
|
||||
int addx = width() - st::contactsPadding.right() - st::contactsCheckPosition.x() - addw;
|
||||
int addy = st::contactsPadding.top() + (st::contactsPhotoSize - st::stickersAddSize.height()) / 2;
|
||||
QRect add(myrtlrect(addx, addy, addw, st::stickersAddSize.height()));
|
||||
auto relativeAdd = relativeAddButtonRect();
|
||||
auto add = myrtlrect(relativeAdd);
|
||||
actionSel = add.contains(local.x(), local.y() - _itemsTop - selected * _rowHeight) ? selected : -1;
|
||||
}
|
||||
} else if (_hasFeaturedButton && QRect(0, st::membersPadding.top(), width(), _buttonHeight).contains(local)) {
|
||||
@@ -878,10 +918,7 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_actionDown >= 0) {
|
||||
update(0, _itemsTop + _actionDown * _rowHeight, width(), _rowHeight);
|
||||
_actionDown = -1;
|
||||
}
|
||||
setActionDown(-1);
|
||||
}
|
||||
|
||||
void StickersBox::Inner::leaveEvent(QEvent *e) {
|
||||
|
@@ -20,13 +20,14 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
|
||||
class ConfirmBox;
|
||||
|
||||
namespace Ui {
|
||||
class PlainShadow;
|
||||
class RoundButton;
|
||||
class RippleAnimation;
|
||||
} // namespace Ui
|
||||
|
||||
class StickersBox : public ItemListBox, public RPCSender {
|
||||
@@ -150,11 +151,13 @@ private slots:
|
||||
void onImageLoaded();
|
||||
|
||||
private:
|
||||
void setActionDown(int newActionDown);
|
||||
void setup();
|
||||
QRect relativeAddButtonRect() const;
|
||||
void paintButton(Painter &p, int y, bool selected, const QString &text, int badgeCounter) const;
|
||||
|
||||
void step_shifting(uint64 ms, bool timer);
|
||||
void paintRow(Painter &p, int32 index);
|
||||
void paintRow(Painter &p, int32 index, uint64 ms);
|
||||
void clear();
|
||||
void setActionSel(int32 actionSel);
|
||||
float64 aboveShadowOpacity() const;
|
||||
@@ -192,6 +195,7 @@ private:
|
||||
bool installed, official, unread, disabled, recent;
|
||||
int32 pixw, pixh;
|
||||
anim::ivalue yadd;
|
||||
QSharedPointer<Ui::RippleAnimation> ripple;
|
||||
};
|
||||
using StickerSetRows = QList<StickerSetRow*>;
|
||||
|
||||
@@ -236,5 +240,6 @@ private:
|
||||
|
||||
Ui::RectShadow _aboveShadow;
|
||||
|
||||
int32 _scrollbar = 0;
|
||||
int _scrollbar = 0;
|
||||
|
||||
};
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
#include "core/vector_of_moveable.h"
|
||||
|
||||
class ConfirmBox;
|
||||
|
@@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "abstractbox.h"
|
||||
#include "boxes/abstractbox.h"
|
||||
|
||||
namespace Ui {
|
||||
class UsernameInput;
|
||||
|
Reference in New Issue
Block a user