2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Intro redesign done.

This commit is contained in:
John Preston
2016-11-24 22:28:23 +03:00
parent 6e0394dd42
commit 3da0533339
71 changed files with 2150 additions and 1776 deletions

View File

@@ -252,7 +252,7 @@ void AddContactBox::onRetry() {
GroupInfoBox::GroupInfoBox(CreatingGroupType creating, bool fromTypeChoose) : AbstractBox()
, _creating(creating)
, _photo(this, st::newGroupPhotoSize)
, _photo(this, st::newGroupPhotoSize, st::newGroupPhotoIconPosition)
, _title(this, st::defaultInputField, lang(_creating == CreatingGroupChannel ? lng_dlg_new_channel_name : lng_dlg_new_group_name))
, _description(this, st::newGroupDescription, lang(lng_create_group_description))
, _next(this, lang(_creating == CreatingGroupChannel ? lng_create_group_create : lng_create_group_next), st::defaultBoxButton)
@@ -276,15 +276,14 @@ GroupInfoBox::GroupInfoBox(CreatingGroupType creating, bool fromTypeChoose) : Ab
connect(_next, SIGNAL(clicked()), this, SLOT(onNext()));
connect(_cancel, SIGNAL(clicked()), this, SLOT(onClose()));
subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) {
notifyFileQueryUpdated(update);
});
_photo->setClickedCallback([this] {
auto imgExtensions = cImgExtensions();
auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter();
_setPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_images), filter);
});
subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) {
notifyFileQueryUpdated(update);
});
prepare();
}
@@ -418,7 +417,7 @@ void GroupInfoBox::notifyFileQueryUpdated(const FileDialog::QueryUpdate &update)
if (img.isNull() || img.width() > 10 * img.height() || img.height() > 10 * img.width()) {
return;
}
PhotoCropBox *box = new PhotoCropBox(img, (_creating == CreatingGroupChannel) ? peerFromChannel(0) : peerFromChat(0));
auto box = new PhotoCropBox(img, (_creating == CreatingGroupChannel) ? peerFromChannel(0) : peerFromChat(0));
connect(box, SIGNAL(ready(const QImage&)), this, SLOT(onPhotoReady(const QImage&)));
Ui::showLayer(box, KeepOtherLayers);
}

View File

@@ -401,8 +401,7 @@ sessionTerminateAllButton: LinkButton(boxLinkButton) {
passcodeHeaderFont: font(19px);
passcodeHeaderHeight: 80px;
passcodeInput: FlatInput(introPhone) {
}
passcodeInput: introPhone;
passcodeSubmit: RoundButton(introNextButton) {
width: 225px;
}
@@ -420,8 +419,6 @@ newGroupLinkTop: 3px;
newGroupLinkFont: font(16px);
newGroupPhotoSize: 76px;
newGroupPhotoBg: #4eb5f0;
newGroupPhotoBgOver: #3fa9e7;
newGroupPhotoIcon: icon {{ "new_chat_photo", #ffffff }};
newGroupPhotoIconPosition: point(23px, 25px);
newGroupPhotoDuration: 150;

View File

@@ -65,6 +65,10 @@ void PhotoCropBox::init(const QImage &img, PeerData *peer) {
int32 s = st::boxWideWidth - st::boxPhotoPadding.left() - st::boxPhotoPadding.right();
_thumb = App::pixmapFromImageInPlace(img.scaled(s * cIntRetinaFactor(), s * cIntRetinaFactor(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
_thumb.setDevicePixelRatio(cRetinaFactor());
_mask = QImage(_thumb.size(), QImage::Format_ARGB32_Premultiplied);
_mask.setDevicePixelRatio(cRetinaFactor());
_fade = QImage(_thumb.size(), QImage::Format_ARGB32_Premultiplied);
_fade.setDevicePixelRatio(cRetinaFactor());
_thumbw = _thumb.width() / cIntRetinaFactor();
_thumbh = _thumb.height() / cIntRetinaFactor();
if (_thumbw > _thumbh) {
@@ -238,18 +242,16 @@ void PhotoCropBox::paintEvent(QPaintEvent *e) {
p.translate(_thumbx, _thumby);
p.drawPixmap(0, 0, _thumb);
if (_cropy > 0) {
p.fillRect(QRect(0, 0, _cropx + _cropw, _cropy), st::photoCropFadeBg);
}
if (_cropx + _cropw < _thumbw) {
p.fillRect(QRect(_cropx + _cropw, 0, _thumbw - _cropx - _cropw, _cropy + _cropw), st::photoCropFadeBg);
}
if (_cropy + _cropw < _thumbh) {
p.fillRect(QRect(_cropx, _cropy + _cropw, _thumbw - _cropx, _thumbh - _cropy - _cropw), st::photoCropFadeBg);
}
if (_cropx > 0) {
p.fillRect(QRect(0, _cropy, _cropx, _thumbh - _cropy), st::photoCropFadeBg);
_mask.fill(Qt::white);
{
Painter p(&_mask);
p.setRenderHint(QPainter::HighQualityAntialiasing);
p.setPen(Qt::NoPen);
p.setBrush(Qt::black);
p.drawEllipse(_cropx, _cropy, _cropw, _cropw);
}
style::colorizeImage(_mask, st::photoCropFadeBg->c, &_fade);
p.drawImage(0, 0, _fade);
int delta = st::cropPointSize;
int mdelta = -delta / 2;

View File

@@ -62,6 +62,7 @@ private:
ChildWidget<Ui::RoundButton> _cancel;
QImage _img;
QPixmap _thumb;
QImage _mask, _fade;
PeerId _peerId;
};

View File

@@ -34,6 +34,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "ui/widgets/buttons.h"
#include "ui/widgets/scroll_area.h"
#include "ui/effects/ripple_animation.h"
#include "ui/effects/slide_animation.h"
#include "ui/widgets/discrete_sliders.h"
namespace {
@@ -338,37 +339,12 @@ void StickersBox::paintEvent(QPaintEvent *e) {
_about.draw(p, st::stickersReorderPadding.top(), st::stickersReorderPadding.top(), _aboutWidth, style::al_center);
}
if (!_leftCache.isNull()) {
auto slide = _a_slide.current(getms(), _slideLeft ? 0. : 1.);
if (!_a_slide.animating()) {
_leftCache = _rightCache = QPixmap();
if (_slideAnimation) {
_slideAnimation->paintFrame(p, scrollArea()->x(), scrollArea()->y() - titleHeight(), width(), getms());
if (!_slideAnimation->animating()) {
_slideAnimation.reset();
scrollArea()->show();
update();
} else {
auto easeOut = anim::easeOutCirc(1., slide);
auto easeIn = anim::easeInCirc(1., slide);
auto cacheWidth = (_leftCache.width() / cIntRetinaFactor());
auto arrivingCoord = anim::interpolate(cacheWidth, 0, easeOut);
auto departingCoord = anim::interpolate(0, cacheWidth, easeIn);
auto arrivingAlpha = easeIn;
auto departingAlpha = 1. - easeOut;
auto leftCoord = (_slideLeft ? arrivingCoord : departingCoord) * -1;
auto leftAlpha = (_slideLeft ? arrivingAlpha : departingAlpha);
auto rightCoord = (_slideLeft ? departingCoord : arrivingCoord);
auto rightAlpha = (_slideLeft ? departingAlpha : arrivingAlpha);
auto x = scrollArea()->x();
auto y = scrollArea()->y() - titleHeight();
auto leftWidth = (cacheWidth + leftCoord);
if (leftWidth > 0) {
p.setOpacity(leftAlpha);
p.drawPixmap(x, y, leftWidth, _leftCache.height() / cIntRetinaFactor(), _leftCache, (_leftCache.width() - leftWidth * cIntRetinaFactor()), 0, leftWidth * cIntRetinaFactor(), _leftCache.height());
}
auto rightWidth = cacheWidth - rightCoord;
if (rightWidth > 0) {
p.setOpacity(rightAlpha);
p.drawPixmap(x + rightCoord, y, _rightCache, 0, 0, rightWidth * cIntRetinaFactor(), _rightCache.height());
}
}
}
}
@@ -430,14 +406,11 @@ void StickersBox::switchTab() {
auto nowCache = grabContentCache();
auto nowIndex = _tab->index;
_leftCache = std_::move(wasCache);
_rightCache = std_::move(nowCache);
_slideLeft = (wasIndex > nowIndex);
if (_slideLeft) {
std_::swap_moveable(_leftCache, _rightCache);
}
_slideAnimation = std_::make_unique<Ui::SlideAnimation>();
_slideAnimation->setSnapshots(std_::move(wasCache), std_::move(nowCache));
auto slideLeft = wasIndex > nowIndex;
_slideAnimation->start(slideLeft, [this] { update(); }, st::slideDuration);
scrollArea()->hide();
_a_slide.start([this] { update(); }, 0., 1., st::slideDuration);
update();
}
}
@@ -602,6 +575,8 @@ void StickersBox::closePressed() {
}
}
StickersBox::~StickersBox() = default;
StickersBox::Inner::Inner(QWidget *parent, StickersBox::Section section) : TWidget(parent)
, _section(section)
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())

View File

@@ -33,6 +33,7 @@ class PlainShadow;
class RoundButton;
class RippleAnimation;
class SettingsSlider;
class SlideAnimation;
} // namespace Ui
class StickersBox : public ItemListBox, public RPCSender {
@@ -48,6 +49,8 @@ public:
StickersBox(Section section = Section::Installed);
StickersBox(const Stickers::Order &archivedIds);
~StickersBox();
public slots:
void onStickersUpdated();
@@ -111,9 +114,7 @@ private:
ChildWidget<Ui::RoundButton> _done = { nullptr };
ChildWidget<ScrollableBoxShadow> _bottomShadow = { nullptr };
FloatAnimation _a_slide;
bool _slideLeft = false;
QPixmap _leftCache, _rightCache;
std_::unique_ptr<Ui::SlideAnimation> _slideAnimation;
QTimer _scrollTimer;
int32 _scrollDelta = 0;