Strict alignment request for base::lambda. Various improvements.

This commit is contained in:
John Preston 2016-11-20 15:54:07 +03:00
parent 8a0c275658
commit e880c4876e
72 changed files with 278 additions and 265 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 424 B

After

Width:  |  Height:  |  Size: 632 B

View File

@ -110,7 +110,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_status_online" = "online"; "lng_status_online" = "online";
"lng_status_connecting" = "connecting..."; "lng_status_connecting" = "connecting...";
"lng_chat_status_unaccessible" = "group is unaccessible"; "lng_chat_status_unaccessible" = "group is inaccessible";
"lng_chat_status_members" = "{count:no members|# member|# members}"; "lng_chat_status_members" = "{count:no members|# member|# members}";
"lng_chat_status_members_online" = "{count:_not_used_|# member|# members}, {count_online:_not_used_|# online|# online}"; "lng_chat_status_members_online" = "{count:_not_used_|# member|# members}, {count_online:_not_used_|# online|# online}";
@ -422,7 +422,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_preview_loading" = "Getting Link Info..."; "lng_preview_loading" = "Getting Link Info...";
"lng_profile_chat_unaccessible" = "Group is unaccessible"; "lng_profile_chat_unaccessible" = "Group is inaccessible";
"lng_profile_about_section" = "About"; "lng_profile_about_section" = "About";
"lng_profile_description_section" = "Description"; "lng_profile_description_section" = "Description";
"lng_profile_settings_section" = "Settings"; "lng_profile_settings_section" = "Settings";

View File

@ -43,10 +43,10 @@ ApiWrap::ApiWrap(QObject *parent) : QObject(parent)
void ApiWrap::init() { void ApiWrap::init() {
} }
void ApiWrap::requestMessageData(ChannelData *channel, MsgId msgId, RequestMessageDataCallback &&callback) { void ApiWrap::requestMessageData(ChannelData *channel, MsgId msgId, const RequestMessageDataCallback &callback) {
MessageDataRequest &req(channel ? _channelMessageDataRequests[channel][msgId] : _messageDataRequests[msgId]); MessageDataRequest &req(channel ? _channelMessageDataRequests[channel][msgId] : _messageDataRequests[msgId]);
if (callback) { if (callback) {
req.callbacks.append(std_::move(callback)); req.callbacks.append(callback);
} }
if (!req.req) _messageDataResolveDelayed->call(); if (!req.req) _messageDataResolveDelayed->call();
} }

View File

@ -30,8 +30,8 @@ public:
ApiWrap(QObject *parent); ApiWrap(QObject *parent);
void init(); void init();
using RequestMessageDataCallback = base::lambda_wrap<void(ChannelData*, MsgId)>; using RequestMessageDataCallback = base::lambda_copy<void(ChannelData*, MsgId)>;
void requestMessageData(ChannelData *channel, MsgId msgId, RequestMessageDataCallback &&callback); void requestMessageData(ChannelData *channel, MsgId msgId, const RequestMessageDataCallback &callback);
void requestFullPeer(PeerData *peer); void requestFullPeer(PeerData *peer);
void requestPeer(PeerData *peer); void requestPeer(PeerData *peer);

View File

@ -1150,7 +1150,7 @@ void EditChannelBox::onSaveSignDone(const MTPUpdates &updates) {
onClose(); onClose();
} }
RevokePublicLinkBox::RevokePublicLinkBox(base::lambda_unique<void()> &&revokeCallback) : AbstractBox() RevokePublicLinkBox::RevokePublicLinkBox(base::lambda<void()> &&revokeCallback) : AbstractBox()
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom()) , _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
, _revokeWidth(st::normalFont->width(lang(lng_channels_too_much_public_revoke))) , _revokeWidth(st::normalFont->width(lang(lng_channels_too_much_public_revoke)))
, _aboutRevoke(this, lang(lng_channels_too_much_public_about), Ui::FlatLabel::InitType::Simple, st::aboutRevokePublicLabel) , _aboutRevoke(this, lang(lng_channels_too_much_public_about), Ui::FlatLabel::InitType::Simple, st::aboutRevokePublicLabel)

View File

@ -286,7 +286,7 @@ class RevokePublicLinkBox : public AbstractBox, public RPCSender {
Q_OBJECT Q_OBJECT
public: public:
RevokePublicLinkBox(base::lambda_unique<void()> &&revokeCallback); RevokePublicLinkBox(base::lambda<void()> &&revokeCallback);
protected: protected:
void mouseMoveEvent(QMouseEvent *e) override; void mouseMoveEvent(QMouseEvent *e) override;
@ -323,7 +323,7 @@ private:
ChildWidget<Ui::FlatLabel> _aboutRevoke; ChildWidget<Ui::FlatLabel> _aboutRevoke;
ChildWidget<Ui::RoundButton> _cancel; ChildWidget<Ui::RoundButton> _cancel;
base::lambda_unique<void()> _revokeCallback; base::lambda<void()> _revokeCallback;
mtpRequestId _revokeRequestId = 0; mtpRequestId _revokeRequestId = 0;
QPointer<ConfirmBox> weakRevokeConfirmBox; QPointer<ConfirmBox> weakRevokeConfirmBox;

View File

@ -21,7 +21,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#pragma once #pragma once
#include "boxes/abstractbox.h" #include "boxes/abstractbox.h"
#include "core/lambda_wrap.h"
class BackgroundBox : public ItemListBox { class BackgroundBox : public ItemListBox {
Q_OBJECT Q_OBJECT

View File

@ -43,7 +43,7 @@ public:
void updateLink(); void updateLink();
// You can use this instead of connecting to "confirmed()" signal. // You can use this instead of connecting to "confirmed()" signal.
void setConfirmedCallback(base::lambda_unique<void()> &&callback) { void setConfirmedCallback(base::lambda<void()> &&callback) {
_confirmedCallback = std_::move(callback); _confirmedCallback = std_::move(callback);
} }
@ -92,7 +92,7 @@ private:
ChildWidget<Ui::RoundButton> _confirm; ChildWidget<Ui::RoundButton> _confirm;
ChildWidget<Ui::RoundButton> _cancel; ChildWidget<Ui::RoundButton> _cancel;
base::lambda_unique<void()> _confirmedCallback; base::lambda<void()> _confirmedCallback;
}; };

View File

@ -545,8 +545,8 @@ bool ContactsBox::creationFail(const RPCError &error) {
return false; return false;
} }
ContactsBox::Inner::ContactData::ContactData(PeerData *peer, base::lambda_wrap<void()> updateCallback) ContactsBox::Inner::ContactData::ContactData(PeerData *peer, const base::lambda_copy<void()> &updateCallback)
: checkbox(std_::make_unique<Ui::RoundImageCheckbox>(st::contactsPhotoCheckbox, std_::move(updateCallback), PaintUserpicCallback(peer))) { : checkbox(std_::make_unique<Ui::RoundImageCheckbox>(st::contactsPhotoCheckbox, updateCallback, PaintUserpicCallback(peer))) {
} }
ContactsBox::Inner::Inner(QWidget *parent, CreatingGroupType creating) : TWidget(parent) ContactsBox::Inner::Inner(QWidget *parent, CreatingGroupType creating) : TWidget(parent)
@ -1371,7 +1371,7 @@ void ContactsBox::Inner::peerUnselected(PeerData *peer) {
changePeerCheckState(data, peer, false, ChangeStateWay::SkipCallback); changePeerCheckState(data, peer, false, ChangeStateWay::SkipCallback);
} }
void ContactsBox::Inner::setPeerSelectedChangedCallback(base::lambda_unique<void(PeerData *peer, bool selected)> callback) { void ContactsBox::Inner::setPeerSelectedChangedCallback(base::lambda<void(PeerData *peer, bool selected)> &&callback) {
_peerSelectedChangedCallback = std_::move(callback); _peerSelectedChangedCallback = std_::move(callback);
} }

View File

@ -145,7 +145,7 @@ public:
Inner(QWidget *parent, ChatData *chat, MembersFilter membersFilter); Inner(QWidget *parent, ChatData *chat, MembersFilter membersFilter);
Inner(QWidget *parent, UserData *bot); Inner(QWidget *parent, UserData *bot);
void setPeerSelectedChangedCallback(base::lambda_unique<void(PeerData *peer, bool selected)> callback); void setPeerSelectedChangedCallback(base::lambda<void(PeerData *peer, bool selected)> &&callback);
void peerUnselected(PeerData *peer); void peerUnselected(PeerData *peer);
void updateFilter(QString filter = QString()); void updateFilter(QString filter = QString());
@ -157,7 +157,7 @@ public:
QVector<UserData*> selected(); QVector<UserData*> selected();
QVector<MTPInputUser> selectedInputs(); QVector<MTPInputUser> selectedInputs();
bool allAdmins() const; bool allAdmins() const;
void setAllAdminsChangedCallback(base::lambda_unique<void()> allAdminsChangedCallback) { void setAllAdminsChangedCallback(base::lambda<void()> &&allAdminsChangedCallback) {
_allAdminsChangedCallback = std_::move(allAdminsChangedCallback); _allAdminsChangedCallback = std_::move(allAdminsChangedCallback);
} }
@ -213,7 +213,7 @@ protected:
private: private:
struct ContactData { struct ContactData {
ContactData() = default; ContactData() = default;
ContactData(PeerData *peer, base::lambda_wrap<void()> updateCallback); ContactData(PeerData *peer, const base::lambda_copy<void()> &updateCallback);
std_::unique_ptr<Ui::RoundImageCheckbox> checkbox; std_::unique_ptr<Ui::RoundImageCheckbox> checkbox;
Text name; Text name;
@ -251,7 +251,7 @@ private:
return (_chat != nullptr) || (_creating != CreatingGroupNone && (!_channel || _membersFilter != MembersFilter::Admins)); return (_chat != nullptr) || (_creating != CreatingGroupNone && (!_channel || _membersFilter != MembersFilter::Admins));
} }
base::lambda_unique<void(PeerData *peer, bool selected)> _peerSelectedChangedCallback; base::lambda<void(PeerData *peer, bool selected)> _peerSelectedChangedCallback;
int _rowHeight; int _rowHeight;
int _aboutHeight = 0; int _aboutHeight = 0;
@ -266,7 +266,7 @@ private:
ChildWidget<Ui::Checkbox> _allAdmins; ChildWidget<Ui::Checkbox> _allAdmins;
int32 _aboutWidth; int32 _aboutWidth;
Text _aboutAllAdmins, _aboutAdmins; Text _aboutAllAdmins, _aboutAdmins;
base::lambda_unique<void()> _allAdminsChangedCallback; base::lambda<void()> _allAdminsChangedCallback;
PeerData *_addToPeer = nullptr; PeerData *_addToPeer = nullptr;
UserData *_addAdmin = nullptr; UserData *_addAdmin = nullptr;

View File

@ -513,9 +513,9 @@ void ShareBox::Inner::paintChat(Painter &p, uint64 ms, Chat *chat, int index) {
chat->name.drawLeftElided(p, x + nameLeft, y + nameTop, nameWidth, outerWidth, 2, style::al_top, 0, -1, 0, true); chat->name.drawLeftElided(p, x + nameLeft, y + nameTop, nameWidth, outerWidth, 2, style::al_top, 0, -1, 0, true);
} }
ShareBox::Inner::Chat::Chat(PeerData *peer, base::lambda_wrap<void()> updateCallback) ShareBox::Inner::Chat::Chat(PeerData *peer, const base::lambda_copy<void()> &updateCallback)
: peer(peer) : peer(peer)
, checkbox(st::sharePhotoCheckbox, std_::move(updateCallback), PaintUserpicCallback(peer)) , checkbox(st::sharePhotoCheckbox, updateCallback, PaintUserpicCallback(peer))
, name(st::sharePhotoCheckbox.imageRadius * 2) { , name(st::sharePhotoCheckbox.imageRadius * 2) {
} }
@ -649,7 +649,7 @@ void ShareBox::Inner::peerUnselected(PeerData *peer) {
changePeerCheckState(chat, false, ChangeStateWay::SkipCallback); changePeerCheckState(chat, false, ChangeStateWay::SkipCallback);
} }
void ShareBox::Inner::setPeerSelectedChangedCallback(base::lambda_unique<void(PeerData *peer, bool selected)> callback) { void ShareBox::Inner::setPeerSelectedChangedCallback(base::lambda<void(PeerData *peer, bool selected)> &&callback) {
_peerSelectedChangedCallback = std_::move(callback); _peerSelectedChangedCallback = std_::move(callback);
} }

View File

@ -21,7 +21,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#pragma once #pragma once
#include "boxes/abstractbox.h" #include "boxes/abstractbox.h"
#include "core/lambda_wrap.h"
#include "core/observer.h" #include "core/observer.h"
#include "core/vector_of_moveable.h" #include "core/vector_of_moveable.h"
#include "ui/effects/round_image_checkbox.h" #include "ui/effects/round_image_checkbox.h"
@ -47,9 +46,9 @@ class ShareBox : public ItemListBox, public RPCSender {
Q_OBJECT Q_OBJECT
public: public:
using CopyCallback = base::lambda_unique<void()>; using CopyCallback = base::lambda<void()>;
using SubmitCallback = base::lambda_unique<void(const QVector<PeerData*> &)>; using SubmitCallback = base::lambda<void(const QVector<PeerData*> &)>;
using FilterCallback = base::lambda_unique<bool(PeerData*)>; using FilterCallback = base::lambda<bool(PeerData*)>;
ShareBox(CopyCallback &&copyCallback, SubmitCallback &&submitCallback, FilterCallback &&filterCallback); ShareBox(CopyCallback &&copyCallback, SubmitCallback &&submitCallback, FilterCallback &&filterCallback);
private slots: private slots:
@ -119,7 +118,7 @@ class ShareBox::Inner : public TWidget, public RPCSender, private base::Subscrib
public: public:
Inner(QWidget *parent, ShareBox::FilterCallback &&filterCallback); Inner(QWidget *parent, ShareBox::FilterCallback &&filterCallback);
void setPeerSelectedChangedCallback(base::lambda_unique<void(PeerData *peer, bool selected)> callback); void setPeerSelectedChangedCallback(base::lambda<void(PeerData *peer, bool selected)> &&callback);
void peerUnselected(PeerData *peer); void peerUnselected(PeerData *peer);
QVector<PeerData*> selected() const; QVector<PeerData*> selected() const;
@ -157,7 +156,7 @@ private:
int displayedChatsCount() const; int displayedChatsCount() const;
struct Chat { struct Chat {
Chat(PeerData *peer, base::lambda_wrap<void()> updateCallback); Chat(PeerData *peer, const base::lambda_copy<void()> &updateCallback);
PeerData *peer; PeerData *peer;
Ui::RoundImageCheckbox checkbox; Ui::RoundImageCheckbox checkbox;
@ -207,7 +206,7 @@ private:
using SelectedChats = OrderedSet<PeerData*>; using SelectedChats = OrderedSet<PeerData*>;
SelectedChats _selected; SelectedChats _selected;
base::lambda_unique<void(PeerData *peer, bool selected)> _peerSelectedChangedCallback; base::lambda<void(PeerData *peer, bool selected)> _peerSelectedChangedCallback;
ChatData *data(Dialogs::Row *row); ChatData *data(Dialogs::Row *row);

View File

@ -181,7 +181,7 @@ protected:
class LambdaClickHandler : public ClickHandler { class LambdaClickHandler : public ClickHandler {
public: public:
LambdaClickHandler(base::lambda_unique<void()> handler) : _handler(std_::move(handler)) { LambdaClickHandler(base::lambda<void()> &&handler) : _handler(std_::move(handler)) {
} }
void onClick(Qt::MouseButton button) const override final { void onClick(Qt::MouseButton button) const override final {
if (button == Qt::LeftButton && _handler) { if (button == Qt::LeftButton && _handler) {
@ -190,6 +190,6 @@ public:
} }
private: private:
base::lambda_unique<void()> _handler; base::lambda<void()> _handler;
}; };

View File

@ -40,8 +40,8 @@ QString tryConvertUrlToLocal(QString url) {
using namespace qthelp; using namespace qthelp;
auto matchOptions = RegExOption::CaseInsensitive; auto matchOptions = RegExOption::CaseInsensitive;
if (auto telegramMeMatch = regex_match(qsl("https?://telegram\\.me/(.+)$"), url, matchOptions)) { if (auto telegramMeMatch = regex_match(qsl("https?://(www\\.)?telegram\\.me/(.+)$"), url, matchOptions)) {
auto query = telegramMeMatch->capturedRef(1); auto query = telegramMeMatch->capturedRef(2);
if (auto joinChatMatch = regex_match(qsl("^joinchat/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) { if (auto joinChatMatch = regex_match(qsl("^joinchat/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), query, matchOptions)) {
return qsl("tg://join?invite=") + url_encode(joinChatMatch->captured(1)); return qsl("tg://join?invite=") + url_encode(joinChatMatch->captured(1));
} else if (auto stickerSetMatch = regex_match(qsl("^addstickers/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), query, matchOptions)) { } else if (auto stickerSetMatch = regex_match(qsl("^addstickers/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), query, matchOptions)) {

View File

@ -147,9 +147,8 @@ struct lambda_wrap_helper_move_impl<Lambda, std_::false_type, Return, Args...> :
static void construct_move_lambda_method(void *lambda, void *source) { static void construct_move_lambda_method(void *lambda, void *source) {
static_assert(alignof(JustLambda) <= alignof(typename Parent::alignment), "Bad lambda alignment."); static_assert(alignof(JustLambda) <= alignof(typename Parent::alignment), "Bad lambda alignment.");
auto space = sizeof(JustLambda); auto space = sizeof(JustLambda);
// We want to be able to pass lambda by value in 32bit Windows version. auto aligned = std_::align(alignof(JustLambda), space, lambda, space);
//auto aligned = std_::align(alignof(JustLambda), space, lambda, space); t_assert(aligned == lambda);
//t_assert(aligned == lambda);
auto source_lambda = static_cast<JustLambda*>(source); auto source_lambda = static_cast<JustLambda*>(source);
new (lambda) JustLambda(static_cast<JustLambda&&>(*source_lambda)); new (lambda) JustLambda(static_cast<JustLambda&&>(*source_lambda));
} }
@ -223,9 +222,8 @@ struct lambda_wrap_helper_copy_impl<Lambda, std_::false_type, Return, Args...> :
static void construct_copy_lambda_method(void *lambda, const void *source) { static void construct_copy_lambda_method(void *lambda, const void *source) {
static_assert(alignof(JustLambda) <= alignof(typename Parent::alignment), "Bad lambda alignment."); static_assert(alignof(JustLambda) <= alignof(typename Parent::alignment), "Bad lambda alignment.");
auto space = sizeof(JustLambda); auto space = sizeof(JustLambda);
// We want to be able to pass lambda by value in 32bit Windows version. auto aligned = std_::align(alignof(JustLambda), space, lambda, space);
//auto aligned = std_::align(alignof(JustLambda), space, lambda, space); t_assert(aligned == lambda);
//t_assert(aligned == lambda);
auto source_lambda = static_cast<const JustLambda*>(source); auto source_lambda = static_cast<const JustLambda*>(source);
new (lambda) JustLambda(static_cast<const JustLambda &>(*source_lambda)); new (lambda) JustLambda(static_cast<const JustLambda &>(*source_lambda));
} }
@ -246,34 +244,34 @@ const lambda_wrap_helper_copy<Lambda, Return, Args...> lambda_wrap_helper_copy<L
} // namespace internal } // namespace internal
template <typename Function> class lambda_unique; template <typename Function> class lambda;
template <typename Function> class lambda_wrap; template <typename Function> class lambda_copy;
template <typename Return, typename ...Args> template <typename Return, typename ...Args>
class lambda_unique<Return(Args...)> { class lambda<Return(Args...)> {
using BaseHelper = internal::lambda_wrap_helper_base<Return, Args...>; using BaseHelper = internal::lambda_wrap_helper_base<Return, Args...>;
using EmptyHelper = internal::lambda_wrap_empty<Return, Args...>; using EmptyHelper = internal::lambda_wrap_empty<Return, Args...>;
template <typename Lambda> template <typename Lambda>
using IsUnique = std_::is_same<lambda_unique, std_::decay_simple_t<Lambda>>; using IsUnique = std_::is_same<lambda, std_::decay_simple_t<Lambda>>;
template <typename Lambda> template <typename Lambda>
using IsWrap = std_::is_same<lambda_wrap<Return(Args...)>, std_::decay_simple_t<Lambda>>; using IsWrap = std_::is_same<lambda_copy<Return(Args...)>, std_::decay_simple_t<Lambda>>;
template <typename Lambda> template <typename Lambda>
using IsOther = std_::enable_if_t<!IsUnique<Lambda>::value && !IsWrap<Lambda>::value>; using IsOther = std_::enable_if_t<!IsUnique<Lambda>::value && !IsWrap<Lambda>::value>;
template <typename Lambda> template <typename Lambda>
using IsRvalue = std_::enable_if_t<std_::is_rvalue_reference<Lambda&&>::value>; using IsRvalue = std_::enable_if_t<std_::is_rvalue_reference<Lambda&&>::value>;
public: public:
lambda_unique() : helper_(&EmptyHelper::instance) { lambda() : helper_(&EmptyHelper::instance) {
} }
lambda_unique(const lambda_unique &other) = delete; lambda(const lambda &other) = delete;
lambda_unique &operator=(const lambda_unique &other) = delete; lambda &operator=(const lambda &other) = delete;
lambda_unique(lambda_unique &&other) : helper_(other.helper_) { lambda(lambda &&other) : helper_(other.helper_) {
helper_->construct_move_other(storage_, other.storage_); helper_->construct_move_other(storage_, other.storage_);
} }
lambda_unique &operator=(lambda_unique &&other) { lambda &operator=(lambda &&other) {
auto temp = std_::move(other); auto temp = std_::move(other);
helper_->destruct(storage_); helper_->destruct(storage_);
helper_ = temp.helper_; helper_ = temp.helper_;
@ -281,21 +279,17 @@ public:
return *this; return *this;
} }
void swap(lambda_unique &other) { void swap(lambda &other) {
if (this != &other) { if (this != &other) std_::swap_moveable(*this, other);
lambda_unique temp = std_::move(other);
other = std_::move(*this);
*this = std_::move(other);
}
} }
template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>> template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>>
lambda_unique(Lambda &&other) : helper_(&internal::lambda_wrap_helper_move<Lambda, Return, Args...>::instance) { lambda(Lambda &&other) : helper_(&internal::lambda_wrap_helper_move<Lambda, Return, Args...>::instance) {
internal::lambda_wrap_helper_move<Lambda, Return, Args...>::construct_move_lambda_method(storage_, &other); internal::lambda_wrap_helper_move<Lambda, Return, Args...>::construct_move_lambda_method(storage_, &other);
} }
template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>> template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>>
lambda_unique &operator=(Lambda &&other) { lambda &operator=(Lambda &&other) {
auto temp = std_::move(other); auto temp = std_::move(other);
helper_->destruct(storage_); helper_->destruct(storage_);
helper_ = &internal::lambda_wrap_helper_move<Lambda, Return, Args...>::instance; helper_ = &internal::lambda_wrap_helper_move<Lambda, Return, Args...>::instance;
@ -311,74 +305,70 @@ public:
return (helper_ != &EmptyHelper::instance); return (helper_ != &EmptyHelper::instance);
} }
~lambda_unique() { ~lambda() {
helper_->destruct(storage_); helper_->destruct(storage_);
} }
protected: protected:
struct Private { struct Private {
}; };
lambda_unique(const BaseHelper *helper, const Private &) : helper_(helper) { lambda(const BaseHelper *helper, const Private &) : helper_(helper) {
} }
using alignment = typename BaseHelper::alignment; using alignment = typename BaseHelper::alignment;
static_assert(BaseHelper::kStorageSize % sizeof(alignment) == 0, "Bad storage size."); static_assert(BaseHelper::kStorageSize % sizeof(alignment) == 0, "Bad storage size.");
alignment storage_[BaseHelper::kStorageSize / sizeof(alignment)]; alignas(typename BaseHelper::alignment) alignment storage_[BaseHelper::kStorageSize / sizeof(alignment)];
const BaseHelper *helper_; const BaseHelper *helper_;
}; };
template <typename Return, typename ...Args> template <typename Return, typename ...Args>
class lambda_wrap<Return(Args...)> : public lambda_unique<Return(Args...)> { class lambda_copy<Return(Args...)> : public lambda<Return(Args...)> {
using BaseHelper = internal::lambda_wrap_helper_base<Return, Args...>; using BaseHelper = internal::lambda_wrap_helper_base<Return, Args...>;
using Parent = lambda_unique<Return(Args...)>; using Parent = lambda<Return(Args...)>;
template <typename Lambda> template <typename Lambda>
using IsOther = std_::enable_if_t<!std_::is_same<lambda_wrap, std_::decay_simple_t<Lambda>>::value>; using IsOther = std_::enable_if_t<!std_::is_same<lambda_copy, std_::decay_simple_t<Lambda>>::value>;
template <typename Lambda> template <typename Lambda>
using IsRvalue = std_::enable_if_t<std_::is_rvalue_reference<Lambda&&>::value>; using IsRvalue = std_::enable_if_t<std_::is_rvalue_reference<Lambda&&>::value>;
template <typename Lambda> template <typename Lambda>
using IsNotRvalue = std_::enable_if_t<!std_::is_rvalue_reference<Lambda&&>::value>; using IsNotRvalue = std_::enable_if_t<!std_::is_rvalue_reference<Lambda&&>::value>;
public: public:
lambda_wrap() = default; lambda_copy() = default;
lambda_wrap(const lambda_wrap &other) : Parent(other.helper_, typename Parent::Private()) { lambda_copy(const lambda_copy &other) : Parent(other.helper_, typename Parent::Private()) {
this->helper_->construct_copy_other(this->storage_, other.storage_); this->helper_->construct_copy_other(this->storage_, other.storage_);
} }
lambda_wrap &operator=(const lambda_wrap &other) { lambda_copy &operator=(const lambda_copy &other) {
auto temp = other; auto temp = other;
temp.swap(*this); temp.swap(*this);
return *this; return *this;
} }
lambda_wrap(lambda_wrap &&other) = default; lambda_copy(lambda_copy &&other) = default;
lambda_wrap &operator=(lambda_wrap &&other) = default; lambda_copy &operator=(lambda_copy &&other) = default;
void swap(lambda_wrap &other) { void swap(lambda_copy &other) {
if (this != &other) { if (this != &other) std_::swap_moveable(*this, other);
lambda_wrap temp = std_::move(other);
other = std_::move(*this);
*this = std_::move(other);
}
} }
lambda_wrap clone() const { lambda_copy clone() const {
return *this; return *this;
} }
template <typename Lambda, typename = IsOther<Lambda>> template <typename Lambda, typename = IsOther<Lambda>>
lambda_wrap(const Lambda &other) : Parent(&internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::instance, typename Parent::Private()) { lambda_copy(const Lambda &other) : Parent(&internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::instance, typename Parent::Private()) {
internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::construct_copy_lambda_method(this->storage_, &other); internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::construct_copy_lambda_method(this->storage_, &other);
} }
template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>> template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>>
lambda_wrap(Lambda &&other) : Parent(&internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::instance, typename Parent::Private()) { lambda_copy(Lambda &&other) : Parent(&internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::instance, typename Parent::Private()) {
internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::construct_move_lambda_method(this->storage_, &other); internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::construct_move_lambda_method(this->storage_, &other);
} }
template <typename Lambda, typename = IsOther<Lambda>> template <typename Lambda, typename = IsOther<Lambda>>
lambda_wrap &operator=(const Lambda &other) { lambda_copy &operator=(const Lambda &other) {
auto temp = other; auto temp = other;
this->helper_->destruct(this->storage_); this->helper_->destruct(this->storage_);
this->helper_ = &internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::instance; this->helper_ = &internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::instance;
@ -387,7 +377,7 @@ public:
} }
template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>> template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>>
lambda_wrap &operator=(Lambda &&other) { lambda_copy &operator=(Lambda &&other) {
auto temp = std_::move(other); auto temp = std_::move(other);
this->helper_->destruct(this->storage_); this->helper_->destruct(this->storage_);
this->helper_ = &internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::instance; this->helper_ = &internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::instance;
@ -401,7 +391,7 @@ class lambda_slot_wrap : public QObject {
Q_OBJECT Q_OBJECT
public: public:
lambda_slot_wrap(QObject *parent, lambda_unique<void()> lambda) : QObject(parent), _lambda(std_::move(lambda)) { lambda_slot_wrap(QObject *parent, lambda<void()> &&lambda) : QObject(parent), _lambda(std_::move(lambda)) {
} }
public slots: public slots:
@ -410,11 +400,11 @@ public slots:
} }
private: private:
lambda_unique<void()> _lambda; lambda<void()> _lambda;
}; };
inline lambda_slot_wrap *lambda_slot(QObject *parent, lambda_unique<void()> lambda) { inline lambda_slot_wrap *lambda_slot(QObject *parent, lambda<void()> &&lambda) {
return new lambda_slot_wrap(parent, std_::move(lambda)); return new lambda_slot_wrap(parent, std_::move(lambda));
} }

View File

@ -26,7 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
namespace base { namespace base {
namespace internal { namespace internal {
using ObservableCallHandlers = base::lambda_unique<void()>; using ObservableCallHandlers = base::lambda<void()>;
void RegisterPendingObservable(ObservableCallHandlers *handlers); void RegisterPendingObservable(ObservableCallHandlers *handlers);
void UnregisterActiveObservable(ObservableCallHandlers *handlers); void UnregisterActiveObservable(ObservableCallHandlers *handlers);
void UnregisterObservable(ObservableCallHandlers *handlers); void UnregisterObservable(ObservableCallHandlers *handlers);
@ -36,12 +36,12 @@ using EventParamType = typename base::type_traits<EventType>::parameter_type;
template <typename EventType> template <typename EventType>
struct SubscriptionHandlerHelper { struct SubscriptionHandlerHelper {
using type = base::lambda_unique<void(EventParamType<EventType>)>; using type = base::lambda<void(EventParamType<EventType>)>;
}; };
template <> template <>
struct SubscriptionHandlerHelper<void> { struct SubscriptionHandlerHelper<void> {
using type = base::lambda_unique<void()>; using type = base::lambda<void()>;
}; };
template <typename EventType> template <typename EventType>

View File

@ -31,7 +31,7 @@ SingleTimer::SingleTimer() {
} }
} }
void SingleTimer::setTimeoutHandler(base::lambda_unique<void()> &&handler) { void SingleTimer::setTimeoutHandler(base::lambda<void()> &&handler) {
if (_handler && !handler) { if (_handler && !handler) {
disconnect(this, SIGNAL(timeout()), this, SLOT(onTimeout())); disconnect(this, SIGNAL(timeout()), this, SLOT(onTimeout()));
} else if (handler && !_handler) { } else if (handler && !_handler) {

View File

@ -21,7 +21,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#pragma once #pragma once
#include "core/basic_types.h" #include "core/basic_types.h"
#include "core/lambda_wrap.h"
class SingleTimer : public QTimer { // single shot timer with check class SingleTimer : public QTimer { // single shot timer with check
Q_OBJECT Q_OBJECT
@ -32,7 +31,7 @@ public:
void setSingleShot(bool); // is not available void setSingleShot(bool); // is not available
void start(); // is not available void start(); // is not available
void setTimeoutHandler(base::lambda_unique<void()> &&handler); void setTimeoutHandler(base::lambda<void()> &&handler);
public slots: public slots:
void start(int msec); void start(int msec);
@ -45,6 +44,6 @@ private slots:
private: private:
uint64 _finishing = 0; uint64 _finishing = 0;
bool _inited = false; bool _inited = false;
base::lambda_unique<void()> _handler; base::lambda<void()> _handler;
}; };

View File

@ -644,7 +644,7 @@ void DialogsInner::contextMenuEvent(QContextMenuEvent *e) {
_menuPeer = history->peer; _menuPeer = history->peer;
_menu = new Ui::PopupMenu(); _menu = new Ui::PopupMenu();
App::main()->fillPeerMenu(_menuPeer, [this](const QString &text, base::lambda_unique<void()> callback) { App::main()->fillPeerMenu(_menuPeer, [this](const QString &text, base::lambda<void()> &&callback) {
return _menu->addAction(text, std_::move(callback)); return _menu->addAction(text, std_::move(callback));
}); });
connect(_menu, SIGNAL(destroyed(QObject*)), this, SLOT(onMenuDestroyed(QObject*))); connect(_menu, SIGNAL(destroyed(QObject*)), this, SLOT(onMenuDestroyed(QObject*)));

View File

@ -44,6 +44,12 @@ void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId rep
} }
} }
void hideSingleUseKeyboard(const HistoryItem *msg) {
if (auto m = main()) {
m->hideSingleUseKeyboard(msg->history()->peer, msg->id);
}
}
bool insertBotCommand(const QString &cmd, bool specialGif) { bool insertBotCommand(const QString &cmd, bool specialGif) {
if (auto m = main()) { if (auto m = main()) {
return m->insertBotCommand(cmd, specialGif); return m->insertBotCommand(cmd, specialGif);
@ -85,11 +91,13 @@ void activateBotCommand(const HistoryItem *msg, int row, int col) {
} break; } break;
case ButtonType::RequestLocation: { case ButtonType::RequestLocation: {
hideSingleUseKeyboard(msg);
Ui::showLayer(new InformBox(lang(lng_bot_share_location_unavailable))); Ui::showLayer(new InformBox(lang(lng_bot_share_location_unavailable)));
} break; } break;
case ButtonType::RequestPhone: { case ButtonType::RequestPhone: {
SharePhoneConfirmBox *box = new SharePhoneConfirmBox(msg->history()->peer); hideSingleUseKeyboard(msg);
auto box = new SharePhoneConfirmBox(msg->history()->peer);
box->connect(box, SIGNAL(confirmed(PeerData*)), App::main(), SLOT(onSharePhoneWithBot(PeerData*))); box->connect(box, SIGNAL(confirmed(PeerData*)), App::main(), SLOT(onSharePhoneWithBot(PeerData*)));
Ui::showLayer(box); Ui::showLayer(box);
} break; } break;

View File

@ -538,7 +538,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
if (mtop >= 0 || htop >= 0) { if (mtop >= 0 || htop >= 0) {
enumerateUserpics([&p, &r](HistoryMessage *message, int userpicTop) { enumerateUserpics([&p, &r](HistoryMessage *message, int userpicTop) {
// stop the enumeration if the userpic is above the painted rect // stop the enumeration if the userpic is below the painted rect
if (userpicTop >= r.top() + r.height()) { if (userpicTop >= r.top() + r.height()) {
return false; return false;
} }
@ -2024,8 +2024,8 @@ void HistoryInner::onUpdateSelected() {
if (auto msg = item->toHistoryMessage()) { if (auto msg = item->toHistoryMessage()) {
if (msg->hasFromPhoto()) { if (msg->hasFromPhoto()) {
enumerateUserpics([&dragState, &lnkhost, &point](HistoryMessage *message, int userpicTop) -> bool { enumerateUserpics([&dragState, &lnkhost, &point](HistoryMessage *message, int userpicTop) -> bool {
// stop enumeration if the userpic is above our point // stop enumeration if the userpic is below our point
if (userpicTop + st::msgPhotoSize <= point.y()) { if (userpicTop > point.y()) {
return false; return false;
} }
@ -5823,6 +5823,22 @@ void HistoryWidget::sendBotCommand(PeerData *peer, UserData *bot, const QString
_field->setFocus(); _field->setFocus();
} }
void HistoryWidget::hideSingleUseKeyboard(PeerData *peer, MsgId replyTo) {
if (!_peer || _peer != peer) return;
bool lastKeyboardUsed = (_keyboard->forMsgId() == FullMsgId(_channel, _history->lastKeyboardId)) && (_keyboard->forMsgId() == FullMsgId(_channel, replyTo));
if (replyTo) {
if (_replyToId == replyTo) {
cancelReply();
onCloudDraftSave();
}
if (_keyboard->singleUse() && _keyboard->hasMarkup() && lastKeyboardUsed) {
if (_kbShown) onKbToggle(false);
_history->lastKeyboardUsed = true;
}
}
}
void HistoryWidget::app_sendBotCallback(const HistoryMessageReplyMarkup::Button *button, const HistoryItem *msg, int row, int col) { void HistoryWidget::app_sendBotCallback(const HistoryMessageReplyMarkup::Button *button, const HistoryItem *msg, int row, int col) {
if (msg->id < 0 || _peer != msg->history()->peer) { if (msg->id < 0 || _peer != msg->history()->peer) {
return; return;

View File

@ -657,6 +657,7 @@ public:
void onListEnterPressed(); void onListEnterPressed();
void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo); void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo);
void hideSingleUseKeyboard(PeerData *peer, MsgId replyTo);
bool insertBotCommand(const QString &cmd, bool specialGif); bool insertBotCommand(const QString &cmd, bool specialGif);
bool eventFilter(QObject *obj, QEvent *e) override; bool eventFilter(QObject *obj, QEvent *e) override;

View File

@ -134,18 +134,17 @@ introErrorLabel: FlatLabel(defaultFlatLabel) {
font: introErrorFont; font: introErrorFont;
align: align(center); align: align(center);
} }
introBackButton: IconButton { introBackButton: IconButton(defaultIconButton) {
width: 40px; width: 56px;
height: 40px; height: 56px;
icon: icon { icon: icon {{ "box_button_back", menuIconFg }};
{ size(40px, 40px), #f2f2f2 }, iconOver: icon {{ "box_button_back", menuIconFgOver }};
{ "title_back", #adadad, point(12px, 12px) },
}; rippleAreaPosition: point(8px, 8px);
iconOver: icon { rippleAreaSize: 40px;
{ size(40px, 40px), #eeeeee }, ripple: RippleAnimation(defaultRippleAnimation) {
{ "title_back", #969696, point(12px, 12px) }, color: windowBgOver;
}; }
iconPosition: point(0px, 0px);
} }
introBackPosition: point(32px, 32px);

View File

@ -42,7 +42,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
IntroWidget::IntroWidget(QWidget *parent) : TWidget(parent) IntroWidget::IntroWidget(QWidget *parent) : TWidget(parent)
, _a_stage(animation(this, &IntroWidget::step_stage)) , _a_stage(animation(this, &IntroWidget::step_stage))
, _a_show(animation(this, &IntroWidget::step_show)) , _a_show(animation(this, &IntroWidget::step_show))
, _back(this, new Ui::IconButton(this, st::introBackButton), base::lambda_unique<void()>(), st::introSlideDuration) , _back(this, new Ui::IconButton(this, st::introBackButton), base::lambda<void()>(), st::introSlideDuration)
, _settings(this, lang(lng_menu_settings), st::defaultBoxButton) { , _settings(this, lang(lng_menu_settings), st::defaultBoxButton) {
_back->entity()->setClickedCallback([this] { onBack(); }); _back->entity()->setClickedCallback([this] { onBack(); });
_back->hideFast(); _back->hideFast();
@ -62,7 +62,7 @@ IntroWidget::IntroWidget(QWidget *parent) : TWidget(parent)
cSetPasswordRecovered(false); cSetPasswordRecovered(false);
_back->moveToLeft(st::introBackPosition.x(), st::introBackPosition.y()); _back->moveToLeft(0, 0);
#ifndef TDESKTOP_DISABLE_AUTOUPDATE #ifndef TDESKTOP_DISABLE_AUTOUPDATE
Sandbox::connect(SIGNAL(updateLatest()), this, SLOT(onCheckUpdateStatus())); Sandbox::connect(SIGNAL(updateLatest()), this, SLOT(onCheckUpdateStatus()));
@ -378,9 +378,9 @@ void IntroWidget::resizeEvent(QResizeEvent *e) {
} }
void IntroWidget::updateControlsGeometry() { void IntroWidget::updateControlsGeometry() {
_settings->moveToLeft(st::boxButtonPadding.right(), height() - st::boxButtonPadding.bottom() - _settings->height()); _settings->moveToRight(st::boxButtonPadding.right(), st::boxButtonPadding.top());
if (_update) { if (_update) {
_update->moveToLeft(st::boxButtonPadding.right() + _settings->width() + st::boxButtonPadding.left(), _settings->y()); _update->moveToRight(st::boxButtonPadding.right() + _settings->width() + st::boxButtonPadding.left(), _settings->y());
} }
} }

View File

@ -20,8 +20,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/ */
#pragma once #pragma once
#include "mtproto/rpc_sender.h"
namespace Ui { namespace Ui {
class IconButton; class IconButton;
class RoundButton; class RoundButton;

View File

@ -43,7 +43,7 @@ public:
, _shadow(st::boxShadow) { , _shadow(st::boxShadow) {
} }
void setDoneCallback(base::lambda_unique<void()> callback) { void setDoneCallback(base::lambda<void()> &&callback) {
_doneCallback = std_::move(callback); _doneCallback = std_::move(callback);
} }
@ -75,7 +75,7 @@ private:
QPixmap _specialLayerCache; QPixmap _specialLayerCache;
QPixmap _layerCache; QPixmap _layerCache;
base::lambda_unique<void()> _doneCallback; base::lambda<void()> _doneCallback;
bool _wasAnimating = false; bool _wasAnimating = false;
bool _inPaintEvent = false; bool _inPaintEvent = false;

View File

@ -1303,6 +1303,10 @@ void MainWidget::sendBotCommand(PeerData *peer, UserData *bot, const QString &cm
_history->sendBotCommand(peer, bot, cmd, replyTo); _history->sendBotCommand(peer, bot, cmd, replyTo);
} }
void MainWidget::hideSingleUseKeyboard(PeerData *peer, MsgId replyTo) {
_history->hideSingleUseKeyboard(peer, replyTo);
}
void MainWidget::app_sendBotCallback(const HistoryMessageReplyMarkup::Button *button, const HistoryItem *msg, int row, int col) { void MainWidget::app_sendBotCallback(const HistoryMessageReplyMarkup::Button *button, const HistoryItem *msg, int row, int col) {
_history->app_sendBotCallback(button, msg, row, col); _history->app_sendBotCallback(button, msg, row, col);
} }
@ -1997,7 +2001,7 @@ void MainWidget::scheduleViewIncrement(HistoryItem *item) {
j.value().insert(item->id, true); j.value().insert(item->id, true);
} }
void MainWidget::fillPeerMenu(PeerData *peer, base::lambda_unique<QAction*(const QString &text, base::lambda_unique<void()> handler)> callback) { void MainWidget::fillPeerMenu(PeerData *peer, base::lambda<QAction*(const QString &text, base::lambda<void()> &&handler)> &&callback) {
callback(lang((peer->isChat() || peer->isMegagroup()) ? lng_context_view_group : (peer->isUser() ? lng_context_view_profile : lng_context_view_channel)), [peer] { callback(lang((peer->isChat() || peer->isMegagroup()) ? lng_context_view_group : (peer->isUser() ? lng_context_view_profile : lng_context_view_channel)), [peer] {
Ui::showPeerProfile(peer); Ui::showPeerProfile(peer);
}); });
@ -2051,8 +2055,8 @@ void MainWidget::fillPeerMenu(PeerData *peer, base::lambda_unique<QAction*(const
Ui::showLayer(box); Ui::showLayer(box);
}; };
if (auto user = peer->asUser()) { if (auto user = peer->asUser()) {
callback(lang(lng_profile_clear_history), std_::move(clearHistoryHandler));
callback(lang(lng_profile_delete_conversation), std_::move(deleteAndLeaveHandler)); callback(lang(lng_profile_delete_conversation), std_::move(deleteAndLeaveHandler));
callback(lang(lng_profile_clear_history), std_::move(clearHistoryHandler));
if (user->access != UserNoAccess && user != App::self()) { if (user->access != UserNoAccess && user != App::self()) {
auto blockSubscription = MakeShared<base::Subscription>(); auto blockSubscription = MakeShared<base::Subscription>();
auto blockAction = callback(lang(user->isBlocked() ? (user->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (user->botInfo ? lng_profile_block_bot : lng_profile_block_user)), [user, blockSubscription] { auto blockAction = callback(lang(user->isBlocked() ? (user->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (user->botInfo ? lng_profile_block_bot : lng_profile_block_user)), [user, blockSubscription] {

View File

@ -300,6 +300,7 @@ public:
void stopAnimActive(); void stopAnimActive();
void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo); void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo);
void hideSingleUseKeyboard(PeerData *peer, MsgId replyTo);
bool insertBotCommand(const QString &cmd, bool specialGif); bool insertBotCommand(const QString &cmd, bool specialGif);
void searchMessages(const QString &query, PeerData *inPeer); void searchMessages(const QString &query, PeerData *inPeer);
@ -364,7 +365,7 @@ public:
void scheduleViewIncrement(HistoryItem *item); void scheduleViewIncrement(HistoryItem *item);
void fillPeerMenu(PeerData *peer, base::lambda_unique<QAction*(const QString &text, base::lambda_unique<void()> handler)> callback); void fillPeerMenu(PeerData *peer, base::lambda<QAction*(const QString &text, base::lambda<void()> &&handler)> &&callback);
void gotRangeDifference(ChannelData *channel, const MTPupdates_ChannelDifference &diff); void gotRangeDifference(ChannelData *channel, const MTPupdates_ChannelDifference &diff);
void onSelfParticipantUpdated(ChannelData *channel); void onSelfParticipantUpdated(ChannelData *channel);

View File

@ -52,7 +52,7 @@ enum ReaderSteps {
class ReaderPrivate; class ReaderPrivate;
class Reader { class Reader {
public: public:
using Callback = base::lambda_unique<void(Notification)>; using Callback = base::lambda<void(Notification)>;
enum class Mode { enum class Mode {
Gif, Gif,
Video, Video,

View File

@ -43,7 +43,7 @@ class CoverWidget : public TWidget, private base::Subscriber {
public: public:
CoverWidget(QWidget *parent); CoverWidget(QWidget *parent);
using ButtonCallback = base::lambda_unique<void()>; using ButtonCallback = base::lambda<void()>;
void setPinCallback(ButtonCallback &&callback); void setPinCallback(ButtonCallback &&callback);
void setCloseCallback(ButtonCallback &&callback); void setCloseCallback(ButtonCallback &&callback);

View File

@ -50,7 +50,7 @@ public:
void showFromOther(); void showFromOther();
void hideFromOther(); void hideFromOther();
using ButtonCallback = base::lambda_wrap<void()>; using ButtonCallback = base::lambda_copy<void()>;
void setPinCallback(ButtonCallback &&callback); void setPinCallback(ButtonCallback &&callback);
void setCloseCallback(ButtonCallback &&callback); void setCloseCallback(ButtonCallback &&callback);

View File

@ -45,7 +45,7 @@ class Widget : public TWidget, private base::Subscriber {
public: public:
Widget(QWidget *parent); Widget(QWidget *parent);
using CloseCallback = base::lambda_unique<void()>; using CloseCallback = base::lambda<void()>;
void setCloseCallback(CloseCallback &&callback); void setCloseCallback(CloseCallback &&callback);
void setShadowGeometryToLeft(int x, int y, int w, int h); void setShadowGeometryToLeft(int x, int y, int w, int h);

View File

@ -20,8 +20,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/ */
#pragma once #pragma once
#include "core/lambda_wrap.h"
class RPCError { class RPCError {
public: public:
RPCError(const MTPrpcError &error) : _code(error.c_rpc_error().verror_code.v) { RPCError(const MTPrpcError &error) : _code(error.c_rpc_error().verror_code.v) {
@ -834,7 +832,7 @@ struct LambdaUniqueHelper;
template <typename Lambda, typename R, typename ...Args> template <typename Lambda, typename R, typename ...Args>
struct LambdaUniqueHelper<R(Lambda::*)(Args...) const> { struct LambdaUniqueHelper<R(Lambda::*)(Args...) const> {
using UniqueType = base::lambda_unique<R(Args...)>; using UniqueType = base::lambda<R(Args...)>;
}; };
template <typename FunctionType> template <typename FunctionType>
@ -843,7 +841,7 @@ using LambdaGetUnique = typename LambdaUniqueHelper<FunctionType>::UniqueType;
template <typename Base, typename FunctionType> template <typename Base, typename FunctionType>
class RPCHandlerImplementation : public Base { class RPCHandlerImplementation : public Base {
protected: protected:
using Lambda = base::lambda_unique<FunctionType>; using Lambda = base::lambda<FunctionType>;
using Parent = RPCHandlerImplementation<Base, FunctionType>; using Parent = RPCHandlerImplementation<Base, FunctionType>;
public: public:
@ -919,32 +917,32 @@ public:
}; };
template <typename R> template <typename R>
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda_unique<R(const mtpPrime*, const mtpPrime*)> &&lambda) { inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const mtpPrime*, const mtpPrime*)> &&lambda) {
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationBare<R>(std_::move(lambda))); return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationBare<R>(std_::move(lambda)));
} }
template <typename R> template <typename R>
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda_unique<R(const mtpPrime*, const mtpPrime*, mtpRequestId)> &&lambda) { inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const mtpPrime*, const mtpPrime*, mtpRequestId)> &&lambda) {
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationBareReq<R>(std_::move(lambda))); return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationBareReq<R>(std_::move(lambda)));
} }
template <typename R, typename T> template <typename R, typename T>
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda_unique<R(const T&)> &&lambda) { inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const T&)> &&lambda) {
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationPlain<R, T>(std_::move(lambda))); return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationPlain<R, T>(std_::move(lambda)));
} }
template <typename R, typename T> template <typename R, typename T>
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda_unique<R(const T&, mtpRequestId)> &&lambda) { inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const T&, mtpRequestId)> &&lambda) {
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationReq<R, T>(std_::move(lambda))); return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationReq<R, T>(std_::move(lambda)));
} }
template <typename R> template <typename R>
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda_unique<R()> &&lambda) { inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R()> &&lambda) {
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationNo<R>(std_::move(lambda))); return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationNo<R>(std_::move(lambda)));
} }
template <typename R> template <typename R>
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda_unique<R(mtpRequestId)> &&lambda) { inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(mtpRequestId)> &&lambda) {
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationNoReq<R>(std_::move(lambda))); return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationNoReq<R>(std_::move(lambda)));
} }
@ -992,19 +990,19 @@ public:
}; };
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda_unique<bool(const RPCError&)> &&lambda) { inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool(const RPCError&)> &&lambda) {
return RPCFailHandlerPtr(new RPCFailHandlerImplementationPlain(std_::move(lambda))); return RPCFailHandlerPtr(new RPCFailHandlerImplementationPlain(std_::move(lambda)));
} }
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda_unique<bool(const RPCError&, mtpRequestId)> &&lambda) { inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool(const RPCError&, mtpRequestId)> &&lambda) {
return RPCFailHandlerPtr(new RPCFailHandlerImplementationReq(std_::move(lambda))); return RPCFailHandlerPtr(new RPCFailHandlerImplementationReq(std_::move(lambda)));
} }
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda_unique<bool()> &&lambda) { inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool()> &&lambda) {
return RPCFailHandlerPtr(new RPCFailHandlerImplementationNo(std_::move(lambda))); return RPCFailHandlerPtr(new RPCFailHandlerImplementationNo(std_::move(lambda)));
} }
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda_unique<bool(mtpRequestId)> &&lambda) { inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool(mtpRequestId)> &&lambda) {
return RPCFailHandlerPtr(new RPCFailHandlerImplementationNoReq(std_::move(lambda))); return RPCFailHandlerPtr(new RPCFailHandlerImplementationNoReq(std_::move(lambda)));
} }

View File

@ -102,7 +102,7 @@ public:
private: private:
PeerUpdate::Flags _events; PeerUpdate::Flags _events;
base::lambda_unique<void(const PeerUpdate&)> _handler; base::lambda<void(const PeerUpdate&)> _handler;
}; };
base::Observable<PeerUpdate, PeerUpdatedHandler> &PeerUpdated(); base::Observable<PeerUpdate, PeerUpdatedHandler> &PeerUpdated();

View File

@ -43,19 +43,19 @@ OverviewFileLayout {
fileDateTop: pixels; fileDateTop: pixels;
} }
overviewCheckBg: #00000066; overviewCheckBg: #00000042;
overviewCheckedBg: #2fa9e2; overviewCheckedBg: #2fa9e2;
overviewPhotoSkip: 10px; overviewPhotoSkip: 10px;
overviewPhotoBg: #F1F1F1; overviewPhotoBg: #F1F1F1;
overviewPhotoMinSize: minPhotoSize; overviewPhotoMinSize: minPhotoSize;
overviewPhotoCheck: icon { overviewPhotoCheck: icon {
{ size(32px, 32px), overviewCheckBg }, { size(31px, 31px), overviewCheckBg },
{ "overview_photo_check", #ffffff, point(8px, 10px) }, { "overview_photo_check", #ffffff, point(4px, 8px) },
}; };
overviewPhotoChecked: icon { overviewPhotoChecked: icon {
{ size(32px, 32px), overviewCheckedBg }, { size(31px, 31px), overviewCheckedBg },
{ "overview_photo_check", #ffffff, point(8px, 10px) }, { "overview_photo_check", #ffffff, point(4px, 8px) },
}; };
overviewPhotoSelectOverlay: #0a7bb03f; overviewPhotoSelectOverlay: #0a7bb03f;

View File

@ -28,7 +28,7 @@ public:
void showAnimated(); void showAnimated();
using HideFinishCallback = base::lambda_unique<void(CoverDropArea*)>; using HideFinishCallback = base::lambda<void(CoverDropArea*)>;
void hideAnimated(HideFinishCallback &&callback); void hideAnimated(HideFinishCallback &&callback);
bool hiding() const { bool hiding() const {

View File

@ -38,7 +38,7 @@ namespace Settings {
namespace { namespace {
QString SecretText; QString SecretText;
QMap<QString, base::lambda_wrap<void()>> Codes; QMap<QString, base::lambda_copy<void()>> Codes;
void fillCodes() { void fillCodes() {
Codes.insert(qsl("debugmode"), []() { Codes.insert(qsl("debugmode"), []() {

View File

@ -59,6 +59,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "core/basic_types.h" #include "core/basic_types.h"
#include "logs.h" #include "logs.h"
#include "core/utils.h" #include "core/utils.h"
#include "core/lambda.h"
#include "config.h" #include "config.h"
#include "mtproto/facade.h" #include "mtproto/facade.h"

View File

@ -2845,9 +2845,17 @@ void EmojiPan::paintEvent(QPaintEvent *e) {
Painter p(this); Painter p(this);
auto ms = getms(); auto ms = getms();
auto showAnimating = _a_show.animating(ms);
auto opacityAnimating = _a_opacity.animating(ms); auto opacityAnimating = _a_opacity.animating(ms);
auto switching = (_slideAnimation != nullptr); auto switching = (_slideAnimation != nullptr);
if (_a_show.animating(ms)) { if (_showAnimation && !showAnimating) {
_showAnimation.reset();
if (!switching && !opacityAnimating) {
showAll();
}
}
if (showAnimating) {
if (auto opacity = _a_opacity.current(_hiding ? 0. : 1.)) { if (auto opacity = _a_opacity.current(_hiding ? 0. : 1.)) {
_showAnimation->paintFrame(p, 0, 0, width(), _a_show.current(1.), opacity); _showAnimation->paintFrame(p, 0, 0, width(), _a_show.current(1.), opacity);
} }
@ -2856,10 +2864,6 @@ void EmojiPan::paintEvent(QPaintEvent *e) {
p.drawPixmap(0, 0, _cache); p.drawPixmap(0, 0, _cache);
} else if ((!switching && _hiding) || isHidden()) { } else if ((!switching && _hiding) || isHidden()) {
hideFinished(); hideFinished();
} else if (_showAnimation) {
_showAnimation->paintFrame(p, 0, 0, width(), 1., 1.);
_showAnimation.reset();
if (!switching && !opacityAnimating) showAll();
} else if (switching) { } else if (switching) {
auto slideDt = _a_slide.current(ms, 1.); auto slideDt = _a_slide.current(ms, 1.);
_slideAnimation->paintFrame(p, slideDt, _a_opacity.current(_hiding ? 0. : 1.)); _slideAnimation->paintFrame(p, slideDt, _a_opacity.current(_hiding ? 0. : 1.));

View File

@ -21,7 +21,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#pragma once #pragma once
#include "ui/twidget.h" #include "ui/twidget.h"
#include "core/lambda_wrap.h"
namespace Ui { namespace Ui {
@ -61,7 +60,7 @@ public:
void setAcceptBoth(bool acceptBoth = true); void setAcceptBoth(bool acceptBoth = true);
void setClickedCallback(base::lambda_unique<void()> &&callback) { void setClickedCallback(base::lambda<void()> &&callback) {
_clickedCallback = std_::move(callback); _clickedCallback = std_::move(callback);
} }
@ -83,7 +82,7 @@ protected:
int _state = StateNone; int _state = StateNone;
bool _acceptBoth = false; bool _acceptBoth = false;
base::lambda_unique<void()> _clickedCallback; base::lambda<void()> _clickedCallback;
}; };

View File

@ -21,7 +21,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#pragma once #pragma once
#include "core/basic_types.h" #include "core/basic_types.h"
#include "core/lambda_wrap.h"
#include <QtCore/QTimer> #include <QtCore/QTimer>
#include <QtGui/QColor> #include <QtGui/QColor>
@ -89,7 +88,7 @@ enum Notification {
namespace anim { namespace anim {
using transition = base::lambda_wrap<float64(float64 delta, float64 dt)>; using transition = base::lambda_copy<float64(float64 delta, float64 dt)>;
extern transition linear; extern transition linear;
extern transition sineInOut; extern transition sineInOut;
@ -584,7 +583,7 @@ template <typename AnimType>
class SimpleAnimation { class SimpleAnimation {
public: public:
using ValueType = typename AnimType::ValueType; using ValueType = typename AnimType::ValueType;
using Callback = base::lambda_unique<void()>; using Callback = base::lambda<void()>;
void step(uint64 ms) { void step(uint64 ms) {
if (_data) { if (_data) {
@ -621,7 +620,7 @@ public:
} }
template <typename Lambda> template <typename Lambda>
void start(Lambda &&updateCallback, const ValueType &from, const ValueType &to, float64 duration, anim::transition transition = anim::linear) { void start(Lambda &&updateCallback, const ValueType &from, const ValueType &to, float64 duration, const anim::transition &transition = anim::linear) {
if (!_data) { if (!_data) {
_data = std_::make_unique<Data>(from, std_::forward<Lambda>(updateCallback)); _data = std_::make_unique<Data>(from, std_::forward<Lambda>(updateCallback));
} }
@ -647,10 +646,10 @@ private:
, a_animation(animation(this, &Data::step)) , a_animation(animation(this, &Data::step))
, updateCallback(std_::move(updateCallback)) { , updateCallback(std_::move(updateCallback)) {
} }
Data(const ValueType &from, const base::lambda_wrap<void()> &updateCallback) Data(const ValueType &from, const base::lambda_copy<void()> &updateCallback)
: value(from, from) : value(from, from)
, a_animation(animation(this, &Data::step)) , a_animation(animation(this, &Data::step))
, updateCallback(base::lambda_wrap<void()>(updateCallback)) { , updateCallback(base::lambda_copy<void()>(updateCallback)) {
} }
void step(float64 ms, bool timer) { void step(float64 ms, bool timer) {
auto dt = (ms >= duration) ? 1. : (ms / duration); auto dt = (ms >= duration) ? 1. : (ms / duration);

View File

@ -25,8 +25,8 @@ namespace Ui {
class RippleAnimation::Ripple { class RippleAnimation::Ripple {
public: public:
Ripple(const style::RippleAnimation &st, QPoint origin, int startRadius, const QPixmap &mask, UpdateCallback update); Ripple(const style::RippleAnimation &st, QPoint origin, int startRadius, const QPixmap &mask, const UpdateCallback &update);
Ripple(const style::RippleAnimation &st, const QPixmap &mask, UpdateCallback update); Ripple(const style::RippleAnimation &st, const QPixmap &mask, const UpdateCallback &update);
void paint(QPainter &p, const QPixmap &mask, uint64 ms); void paint(QPainter &p, const QPixmap &mask, uint64 ms);
@ -53,7 +53,7 @@ private:
}; };
RippleAnimation::Ripple::Ripple(const style::RippleAnimation &st, QPoint origin, int startRadius, const QPixmap &mask, UpdateCallback update) RippleAnimation::Ripple::Ripple(const style::RippleAnimation &st, QPoint origin, int startRadius, const QPixmap &mask, const UpdateCallback &update)
: _st(st) : _st(st)
, _update(update) , _update(update)
, _origin(origin) , _origin(origin)
@ -75,7 +75,7 @@ RippleAnimation::Ripple::Ripple(const style::RippleAnimation &st, QPoint origin,
_show.start(UpdateCallback(_update), 0., 1., _st.showDuration); _show.start(UpdateCallback(_update), 0., 1., _st.showDuration);
} }
RippleAnimation::Ripple::Ripple(const style::RippleAnimation &st, const QPixmap &mask, UpdateCallback update) RippleAnimation::Ripple::Ripple(const style::RippleAnimation &st, const QPixmap &mask, const UpdateCallback &update)
: _st(st) : _st(st)
, _update(update) , _update(update)
, _origin(mask.width() / (2 * cIntRetinaFactor()), mask.height() / (2 * cIntRetinaFactor())) , _origin(mask.width() / (2 * cIntRetinaFactor()), mask.height() / (2 * cIntRetinaFactor()))
@ -141,10 +141,10 @@ void RippleAnimation::Ripple::finish() {
_hide.finish(); _hide.finish();
} }
RippleAnimation::RippleAnimation(const style::RippleAnimation &st, QImage mask, UpdateCallback callback) RippleAnimation::RippleAnimation(const style::RippleAnimation &st, QImage mask, const UpdateCallback &callback)
: _st(st) : _st(st)
, _mask(App::pixmapFromImageInPlace(std_::move(mask))) , _mask(App::pixmapFromImageInPlace(std_::move(mask)))
, _update(std_::move(callback)) { , _update(callback) {
} }
@ -190,7 +190,7 @@ void RippleAnimation::paint(QPainter &p, int x, int y, int outerWidth, uint64 ms
clearFinished(); clearFinished();
} }
QImage RippleAnimation::maskByDrawer(QSize size, bool filled, base::lambda_unique<void(QPainter &p)> drawer) { QImage RippleAnimation::maskByDrawer(QSize size, bool filled, base::lambda<void(QPainter &p)> &&drawer) {
auto result = QImage(size * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied); auto result = QImage(size * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
result.fill(filled ? QColor(255, 255, 255) : Qt::transparent); result.fill(filled ? QColor(255, 255, 255) : Qt::transparent);
if (drawer) { if (drawer) {
@ -204,7 +204,7 @@ QImage RippleAnimation::maskByDrawer(QSize size, bool filled, base::lambda_uniqu
} }
QImage RippleAnimation::rectMask(QSize size) { QImage RippleAnimation::rectMask(QSize size) {
return maskByDrawer(size, true, base::lambda_unique<void(QPainter&)>()); return maskByDrawer(size, true, base::lambda<void(QPainter&)>());
} }
QImage RippleAnimation::roundRectMask(QSize size, int radius) { QImage RippleAnimation::roundRectMask(QSize size, int radius) {

View File

@ -26,12 +26,10 @@ namespace Ui {
class RippleAnimation { class RippleAnimation {
public: public:
using UpdateCallback = base::lambda_wrap<void()>; using UpdateCallback = base::lambda_copy<void()>;
// White upon transparent mask, like colorizeImage(black-white-mask, white). // White upon transparent mask, like colorizeImage(black-white-mask, white).
RippleAnimation(const style::RippleAnimation &st, QImage mask, UpdateCallback update); RippleAnimation(const style::RippleAnimation &st, QImage mask, const UpdateCallback &update);
void setMask(QImage &&mask);
void add(QPoint origin, int startRadius = 0); void add(QPoint origin, int startRadius = 0);
void addFading(); void addFading();
@ -45,7 +43,7 @@ public:
return _ripples.isEmpty(); return _ripples.isEmpty();
} }
static QImage maskByDrawer(QSize size, bool filled, base::lambda_unique<void(QPainter &p)> drawer); static QImage maskByDrawer(QSize size, bool filled, base::lambda<void(QPainter &p)> &&drawer);
static QImage rectMask(QSize size); static QImage rectMask(QSize size);
static QImage roundRectMask(QSize size, int radius); static QImage roundRectMask(QSize size, int radius);
static QImage ellipseMask(QSize size); static QImage ellipseMask(QSize size);

View File

@ -58,9 +58,9 @@ void prepareCheckCaches(const style::RoundImageCheckbox *st, QPixmap &checkBgCac
} // namespace } // namespace
RoundImageCheckbox::RoundImageCheckbox(const style::RoundImageCheckbox &st, base::lambda_wrap<void()> updateCallback, PaintRoundImage paintRoundImage) RoundImageCheckbox::RoundImageCheckbox(const style::RoundImageCheckbox &st, const base::lambda_copy<void()> &updateCallback, PaintRoundImage &&paintRoundImage)
: _st(st) : _st(st)
, _updateCallback(std_::move(updateCallback)) , _updateCallback(updateCallback)
, _paintRoundImage(std_::move(paintRoundImage)) { , _paintRoundImage(std_::move(paintRoundImage)) {
prepareCheckCaches(&_st, _wideCheckBgCache, _wideCheckFullCache); prepareCheckCaches(&_st, _wideCheckBgCache, _wideCheckFullCache);
} }

View File

@ -26,8 +26,8 @@ namespace Ui {
class RoundImageCheckbox { class RoundImageCheckbox {
public: public:
using PaintRoundImage = base::lambda_unique<void(Painter &p, int x, int y, int outerWidth, int size)>; using PaintRoundImage = base::lambda<void(Painter &p, int x, int y, int outerWidth, int size)>;
RoundImageCheckbox(const style::RoundImageCheckbox &st, base::lambda_wrap<void()> updateCallback, PaintRoundImage paintRoundImage); RoundImageCheckbox(const style::RoundImageCheckbox &st, const base::lambda_copy<void()> &updateCallback, PaintRoundImage &&paintRoundImage);
void paint(Painter &p, uint64 ms, int x, int y, int outerWidth); void paint(Painter &p, uint64 ms, int x, int y, int outerWidth);
float64 checkedAnimationRatio() const; float64 checkedAnimationRatio() const;
@ -52,7 +52,7 @@ private:
void prepareWideCheckIconCache(Icon *icon); void prepareWideCheckIconCache(Icon *icon);
const style::RoundImageCheckbox &_st; const style::RoundImageCheckbox &_st;
base::lambda_wrap<void()> _updateCallback; base::lambda_copy<void()> _updateCallback;
PaintRoundImage _paintRoundImage; PaintRoundImage _paintRoundImage;
bool _checked = false; bool _checked = false;

View File

@ -115,7 +115,7 @@ void FadeAnimation::updateCallback() {
WidgetFadeWrap<TWidget>::WidgetFadeWrap(QWidget *parent WidgetFadeWrap<TWidget>::WidgetFadeWrap(QWidget *parent
, TWidget *entity , TWidget *entity
, base::lambda_unique<void()> updateCallback , base::lambda<void()> &&updateCallback
, int duration) : TWidget(parent) , int duration) : TWidget(parent)
, _entity(entity) , _entity(entity)
, _duration(duration) , _duration(duration)

View File

@ -33,10 +33,10 @@ public:
bool paint(Painter &p); bool paint(Painter &p);
void refreshCache(); void refreshCache();
using FinishedCallback = base::lambda_unique<void()>; using FinishedCallback = base::lambda<void()>;
void setFinishedCallback(FinishedCallback &&callback); void setFinishedCallback(FinishedCallback &&callback);
using UpdatedCallback = base::lambda_unique<void(float64)>; using UpdatedCallback = base::lambda<void(float64)>;
void setUpdatedCallback(UpdatedCallback &&callback); void setUpdatedCallback(UpdatedCallback &&callback);
void show(); void show();
@ -68,7 +68,7 @@ template <>
class WidgetFadeWrap<TWidget> : public TWidget { class WidgetFadeWrap<TWidget> : public TWidget {
public: public:
WidgetFadeWrap(QWidget *parent, TWidget *entity WidgetFadeWrap(QWidget *parent, TWidget *entity
, base::lambda_unique<void()> updateCallback , base::lambda<void()> &&updateCallback
, int duration = st::widgetFadeDuration); , int duration = st::widgetFadeDuration);
void fadeOut() { void fadeOut() {
@ -105,7 +105,7 @@ protected:
private: private:
TWidget *_entity; TWidget *_entity;
int _duration; int _duration;
base::lambda_unique<void()> _updateCallback; base::lambda<void()> _updateCallback;
FadeAnimation _animation; FadeAnimation _animation;
@ -115,7 +115,7 @@ template <typename Widget>
class WidgetFadeWrap : public WidgetFadeWrap<TWidget> { class WidgetFadeWrap : public WidgetFadeWrap<TWidget> {
public: public:
WidgetFadeWrap(QWidget *parent, Widget *entity WidgetFadeWrap(QWidget *parent, Widget *entity
, base::lambda_unique<void()> updateCallback , base::lambda<void()> &&updateCallback
, int duration = st::widgetFadeDuration) : WidgetFadeWrap<TWidget>(parent, entity, std_::move(updateCallback), duration) { , int duration = st::widgetFadeDuration) : WidgetFadeWrap<TWidget>(parent, entity, std_::move(updateCallback), duration) {
} }
Widget *entity() { Widget *entity() {

View File

@ -26,7 +26,7 @@ namespace Ui {
WidgetSlideWrap<TWidget>::WidgetSlideWrap(QWidget *parent WidgetSlideWrap<TWidget>::WidgetSlideWrap(QWidget *parent
, TWidget *entity , TWidget *entity
, style::margins entityPadding , style::margins entityPadding
, base::lambda_unique<void()> updateCallback , base::lambda<void()> &&updateCallback
, int duration) : TWidget(parent) , int duration) : TWidget(parent)
, _entity(entity) , _entity(entity)
, _padding(entityPadding) , _padding(entityPadding)

View File

@ -32,7 +32,7 @@ class WidgetSlideWrap<TWidget> : public TWidget {
public: public:
WidgetSlideWrap(QWidget *parent, TWidget *entity WidgetSlideWrap(QWidget *parent, TWidget *entity
, style::margins entityPadding , style::margins entityPadding
, base::lambda_unique<void()> updateCallback , base::lambda<void()> &&updateCallback
, int duration = st::widgetSlideDuration); , int duration = st::widgetSlideDuration);
void slideUp(); void slideUp();
@ -61,7 +61,7 @@ private:
bool _inResizeToWidth = false; bool _inResizeToWidth = false;
style::margins _padding; style::margins _padding;
int _duration; int _duration;
base::lambda_unique<void()> _updateCallback; base::lambda<void()> _updateCallback;
style::size _realSize; style::size _realSize;
int _forceHeight = -1; int _forceHeight = -1;
@ -76,7 +76,7 @@ class WidgetSlideWrap : public WidgetSlideWrap<TWidget> {
public: public:
WidgetSlideWrap(QWidget *parent, Widget *entity WidgetSlideWrap(QWidget *parent, Widget *entity
, style::margins entityPadding , style::margins entityPadding
, base::lambda_unique<void()> updateCallback , base::lambda<void()> &&updateCallback
, int duration = st::widgetSlideDuration) : WidgetSlideWrap<TWidget>(parent, entity, entityPadding, std_::move(updateCallback), duration) { , int duration = st::widgetSlideDuration) : WidgetSlideWrap<TWidget>(parent, entity, entityPadding, std_::move(updateCallback), duration) {
} }
Widget *entity() { Widget *entity() {

View File

@ -43,7 +43,7 @@ public:
return _disabled; return _disabled;
} }
using Callback = base::lambda_unique<void(float64)>; using Callback = base::lambda<void(float64)>;
void setChangeProgressCallback(Callback &&callback) { void setChangeProgressCallback(Callback &&callback) {
_changeProgressCallback = std_::move(callback); _changeProgressCallback = std_::move(callback);
} }

View File

@ -34,7 +34,7 @@ public:
void setActiveSection(int index); void setActiveSection(int index);
void setActiveSectionFast(int index); void setActiveSectionFast(int index);
using SectionActivatedCallback = base::lambda_unique<void()>; using SectionActivatedCallback = base::lambda<void()>;
void setSectionActivatedCallback(SectionActivatedCallback &&callback); void setSectionActivatedCallback(SectionActivatedCallback &&callback);
protected: protected:

View File

@ -69,7 +69,7 @@ QAction *DropdownMenu::addAction(const QString &text, const QObject *receiver, c
return _menu->addAction(text, receiver, member, icon, iconOver); return _menu->addAction(text, receiver, member, icon, iconOver);
} }
QAction *DropdownMenu::addAction(const QString &text, base::lambda_unique<void()> callback, const style::icon *icon, const style::icon *iconOver) { QAction *DropdownMenu::addAction(const QString &text, base::lambda<void()> &&callback, const style::icon *icon, const style::icon *iconOver) {
return _menu->addAction(text, std_::move(callback), icon, iconOver); return _menu->addAction(text, std_::move(callback), icon, iconOver);
} }

View File

@ -31,11 +31,11 @@ public:
DropdownMenu(QWidget *parent, const style::DropdownMenu &st = st::defaultDropdownMenu); DropdownMenu(QWidget *parent, const style::DropdownMenu &st = st::defaultDropdownMenu);
QAction *addAction(const QString &text, const QObject *receiver, const char* member, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr); QAction *addAction(const QString &text, const QObject *receiver, const char* member, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr);
QAction *addAction(const QString &text, base::lambda_unique<void()> callback, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr); QAction *addAction(const QString &text, base::lambda<void()> &&callback, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr);
QAction *addSeparator(); QAction *addSeparator();
void clearActions(); void clearActions();
void setHiddenCallback(base::lambda_unique<void()> callback) { void setHiddenCallback(base::lambda<void()> &&callback) {
_hiddenCallback = std_::move(callback); _hiddenCallback = std_::move(callback);
} }
@ -99,7 +99,7 @@ private:
void showMenu(const QPoint &p, DropdownMenu *parent, TriggeredSource source); void showMenu(const QPoint &p, DropdownMenu *parent, TriggeredSource source);
const style::DropdownMenu &_st; const style::DropdownMenu &_st;
base::lambda_unique<void()> _hiddenCallback; base::lambda<void()> _hiddenCallback;
ChildWidget<Ui::Menu> _menu; ChildWidget<Ui::Menu> _menu;

View File

@ -48,13 +48,13 @@ public:
void otherLeave(); void otherLeave();
void hideFast(); void hideFast();
void setShowStartCallback(base::lambda_unique<void()> callback) { void setShowStartCallback(base::lambda<void()> &&callback) {
_showStartCallback = std_::move(callback); _showStartCallback = std_::move(callback);
} }
void setHideStartCallback(base::lambda_unique<void()> callback) { void setHideStartCallback(base::lambda<void()> &&callback) {
_hideStartCallback = std_::move(callback); _hideStartCallback = std_::move(callback);
} }
void setHiddenCallback(base::lambda_unique<void()> callback) { void setHiddenCallback(base::lambda<void()> &&callback) {
_hiddenCallback = std_::move(callback); _hiddenCallback = std_::move(callback);
} }
@ -116,9 +116,9 @@ private:
QTimer _hideTimer; QTimer _hideTimer;
bool _ignoreShowEvents = false; bool _ignoreShowEvents = false;
base::lambda_unique<void()> _showStartCallback; base::lambda<void()> _showStartCallback;
base::lambda_unique<void()> _hideStartCallback; base::lambda<void()> _hideStartCallback;
base::lambda_unique<void()> _hiddenCallback; base::lambda<void()> _hiddenCallback;
ChildWidget<Ui::ScrollArea> _scroll; ChildWidget<Ui::ScrollArea> _scroll;

View File

@ -74,7 +74,7 @@ public:
void setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk); void setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk);
using ClickHandlerHook = base::lambda_unique<bool(const ClickHandlerPtr&, Qt::MouseButton)>; using ClickHandlerHook = base::lambda<bool(const ClickHandlerPtr&, Qt::MouseButton)>;
void setClickHandlerHook(ClickHandlerHook &&hook); void setClickHandlerHook(ClickHandlerHook &&hook);
// ClickHandlerHost interface // ClickHandlerHost interface

View File

@ -57,7 +57,7 @@ QAction *Menu::addAction(const QString &text, const QObject *receiver, const cha
return action; return action;
} }
QAction *Menu::addAction(const QString &text, base::lambda_unique<void()> callback, const style::icon *icon, const style::icon *iconOver) { QAction *Menu::addAction(const QString &text, base::lambda<void()> &&callback, const style::icon *icon, const style::icon *iconOver) {
auto action = addAction(new QAction(text, this), icon, iconOver); auto action = addAction(new QAction(text, this), icon, iconOver);
connect(action, SIGNAL(triggered(bool)), base::lambda_slot(action, std_::move(callback)), SLOT(action()), Qt::QueuedConnection); connect(action, SIGNAL(triggered(bool)), base::lambda_slot(action, std_::move(callback)), SLOT(action()), Qt::QueuedConnection);
return action; return action;

View File

@ -34,7 +34,7 @@ public:
Menu(QWidget *parent, QMenu *menu, const style::Menu &st = st::defaultMenu); Menu(QWidget *parent, QMenu *menu, const style::Menu &st = st::defaultMenu);
QAction *addAction(const QString &text, const QObject *receiver, const char* member, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr); QAction *addAction(const QString &text, const QObject *receiver, const char* member, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr);
QAction *addAction(const QString &text, base::lambda_unique<void()> callback, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr); QAction *addAction(const QString &text, base::lambda<void()> &&callback, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr);
QAction *addSeparator(); QAction *addSeparator();
void clearActions(); void clearActions();
@ -52,33 +52,33 @@ public:
using Actions = QList<QAction*>; using Actions = QList<QAction*>;
Actions &actions(); Actions &actions();
void setResizedCallback(base::lambda_unique<void()> callback) { void setResizedCallback(base::lambda<void()> &&callback) {
_resizedCallback = std_::move(callback); _resizedCallback = std_::move(callback);
} }
void setActivatedCallback(base::lambda_unique<void(QAction *action, int actionTop, TriggeredSource source)> callback) { void setActivatedCallback(base::lambda<void(QAction *action, int actionTop, TriggeredSource source)> &&callback) {
_activatedCallback = std_::move(callback); _activatedCallback = std_::move(callback);
} }
void setTriggeredCallback(base::lambda_unique<void(QAction *action, int actionTop, TriggeredSource source)> callback) { void setTriggeredCallback(base::lambda<void(QAction *action, int actionTop, TriggeredSource source)> &&callback) {
_triggeredCallback = std_::move(callback); _triggeredCallback = std_::move(callback);
} }
void setKeyPressDelegate(base::lambda_unique<bool(int key)> delegate) { void setKeyPressDelegate(base::lambda<bool(int key)> &&delegate) {
_keyPressDelegate = std_::move(delegate); _keyPressDelegate = std_::move(delegate);
} }
void handleKeyPress(int key); void handleKeyPress(int key);
void setMouseMoveDelegate(base::lambda_unique<void(QPoint globalPosition)> delegate) { void setMouseMoveDelegate(base::lambda<void(QPoint globalPosition)> &&delegate) {
_mouseMoveDelegate = std_::move(delegate); _mouseMoveDelegate = std_::move(delegate);
} }
void handleMouseMove(QPoint globalPosition); void handleMouseMove(QPoint globalPosition);
void setMousePressDelegate(base::lambda_unique<void(QPoint globalPosition)> delegate) { void setMousePressDelegate(base::lambda<void(QPoint globalPosition)> &&delegate) {
_mousePressDelegate = std_::move(delegate); _mousePressDelegate = std_::move(delegate);
} }
void handleMousePress(QPoint globalPosition); void handleMousePress(QPoint globalPosition);
void setMouseReleaseDelegate(base::lambda_unique<void(QPoint globalPosition)> delegate) { void setMouseReleaseDelegate(base::lambda<void(QPoint globalPosition)> &&delegate) {
_mouseReleaseDelegate = std_::move(delegate); _mouseReleaseDelegate = std_::move(delegate);
} }
void handleMouseRelease(QPoint globalPosition); void handleMouseRelease(QPoint globalPosition);
@ -114,13 +114,13 @@ private:
const style::Menu &_st; const style::Menu &_st;
base::lambda_unique<void()> _resizedCallback; base::lambda<void()> _resizedCallback;
base::lambda_unique<void(QAction *action, int actionTop, TriggeredSource source)> _activatedCallback; base::lambda<void(QAction *action, int actionTop, TriggeredSource source)> _activatedCallback;
base::lambda_unique<void(QAction *action, int actionTop, TriggeredSource source)> _triggeredCallback; base::lambda<void(QAction *action, int actionTop, TriggeredSource source)> _triggeredCallback;
base::lambda_unique<bool(int key)> _keyPressDelegate; base::lambda<bool(int key)> _keyPressDelegate;
base::lambda_unique<void(QPoint globalPosition)> _mouseMoveDelegate; base::lambda<void(QPoint globalPosition)> _mouseMoveDelegate;
base::lambda_unique<void(QPoint globalPosition)> _mousePressDelegate; base::lambda<void(QPoint globalPosition)> _mousePressDelegate;
base::lambda_unique<void(QPoint globalPosition)> _mouseReleaseDelegate; base::lambda<void(QPoint globalPosition)> _mouseReleaseDelegate;
struct ActionData { struct ActionData {
bool hasSubmenu = false; bool hasSubmenu = false;

View File

@ -36,7 +36,7 @@ constexpr int kWideScale = 3;
class MultiSelect::Inner::Item { class MultiSelect::Inner::Item {
public: public:
Item(const style::MultiSelectItem &st, uint64 id, const QString &text, const style::color &color, PaintRoundImage paintRoundImage); Item(const style::MultiSelectItem &st, uint64 id, const QString &text, const style::color &color, PaintRoundImage &&paintRoundImage);
uint64 id() const { uint64 id() const {
return _id; return _id;
@ -56,8 +56,8 @@ public:
void setPosition(int x, int y, int outerWidth, int maxVisiblePadding); void setPosition(int x, int y, int outerWidth, int maxVisiblePadding);
QRect paintArea(int outerWidth) const; QRect paintArea(int outerWidth) const;
void setUpdateCallback(base::lambda_wrap<void()> updateCallback) { void setUpdateCallback(const base::lambda_copy<void()> &updateCallback) {
_updateCallback = std_::move(updateCallback); _updateCallback = updateCallback;
} }
void setText(const QString &text); void setText(const QString &text);
void paint(Painter &p, int outerWidth, uint64 ms); void paint(Painter &p, int outerWidth, uint64 ms);
@ -88,11 +88,11 @@ private:
uint64 _id; uint64 _id;
struct SlideAnimation { struct SlideAnimation {
SlideAnimation(base::lambda_wrap<void()> updateCallback, int fromX, int toX, int y, float64 duration) SlideAnimation(const base::lambda_copy<void()> &updateCallback, int fromX, int toX, int y, float64 duration)
: fromX(fromX) : fromX(fromX)
, toX(toX) , toX(toX)
, y(y) { , y(y) {
x.start(std_::move(updateCallback), fromX, toX, duration); x.start(updateCallback, fromX, toX, duration);
} }
IntAnimation x; IntAnimation x;
int fromX, toX; int fromX, toX;
@ -111,12 +111,12 @@ private:
bool _overDelete = false; bool _overDelete = false;
bool _active = false; bool _active = false;
PaintRoundImage _paintRoundImage; PaintRoundImage _paintRoundImage;
base::lambda_wrap<void()> _updateCallback; base::lambda_copy<void()> _updateCallback;
bool _hiding = false; bool _hiding = false;
}; };
MultiSelect::Inner::Item::Item(const style::MultiSelectItem &st, uint64 id, const QString &text, const style::color &color, PaintRoundImage paintRoundImage) MultiSelect::Inner::Item::Item(const style::MultiSelectItem &st, uint64 id, const QString &text, const style::color &color, PaintRoundImage &&paintRoundImage)
: _st(st) : _st(st)
, _id(id) , _id(id)
, _color(color) , _color(color)
@ -409,15 +409,15 @@ void MultiSelect::scrollTo(int activeTop, int activeBottom) {
} }
} }
void MultiSelect::setQueryChangedCallback(base::lambda_unique<void(const QString &query)> callback) { void MultiSelect::setQueryChangedCallback(base::lambda<void(const QString &query)> &&callback) {
_queryChangedCallback = std_::move(callback); _queryChangedCallback = std_::move(callback);
} }
void MultiSelect::setSubmittedCallback(base::lambda_unique<void(bool ctrlShiftEnter)> callback) { void MultiSelect::setSubmittedCallback(base::lambda<void(bool ctrlShiftEnter)> &&callback) {
_inner->setSubmittedCallback(std_::move(callback)); _inner->setSubmittedCallback(std_::move(callback));
} }
void MultiSelect::setResizedCallback(base::lambda_unique<void()> callback) { void MultiSelect::setResizedCallback(base::lambda<void()> &&callback) {
_resizedCallback = std_::move(callback); _resizedCallback = std_::move(callback);
} }
@ -435,11 +435,11 @@ QString MultiSelect::getQuery() const {
return _inner->getQuery(); return _inner->getQuery();
} }
void MultiSelect::addItem(uint64 itemId, const QString &text, const style::color &color, PaintRoundImage paintRoundImage, AddItemWay way) { void MultiSelect::addItem(uint64 itemId, const QString &text, const style::color &color, PaintRoundImage &&paintRoundImage, AddItemWay way) {
_inner->addItem(std_::make_unique<Inner::Item>(_st.item, itemId, text, color, std_::move(paintRoundImage)), way); _inner->addItem(std_::make_unique<Inner::Item>(_st.item, itemId, text, color, std_::move(paintRoundImage)), way);
} }
void MultiSelect::setItemRemovedCallback(base::lambda_unique<void(uint64 itemId)> callback) { void MultiSelect::setItemRemovedCallback(base::lambda<void(uint64 itemId)> &&callback) {
_inner->setItemRemovedCallback(std_::move(callback)); _inner->setItemRemovedCallback(std_::move(callback));
} }
@ -456,7 +456,7 @@ int MultiSelect::resizeGetHeight(int newWidth) {
return newHeight; return newHeight;
} }
MultiSelect::Inner::Inner(QWidget *parent, const style::MultiSelect &st, const QString &placeholder, ScrollCallback callback) : TWidget(parent) MultiSelect::Inner::Inner(QWidget *parent, const style::MultiSelect &st, const QString &placeholder, ScrollCallback &&callback) : TWidget(parent)
, _st(st) , _st(st)
, _scrollCallback(std_::move(callback)) , _scrollCallback(std_::move(callback))
, _field(this, _st.field, placeholder) , _field(this, _st.field, placeholder)
@ -500,11 +500,11 @@ void MultiSelect::Inner::clearQuery() {
_field->setText(QString()); _field->setText(QString());
} }
void MultiSelect::Inner::setQueryChangedCallback(base::lambda_unique<void(const QString &query)> callback) { void MultiSelect::Inner::setQueryChangedCallback(base::lambda<void(const QString &query)> &&callback) {
_queryChangedCallback = std_::move(callback); _queryChangedCallback = std_::move(callback);
} }
void MultiSelect::Inner::setSubmittedCallback(base::lambda_unique<void(bool ctrlShiftEnter)> callback) { void MultiSelect::Inner::setSubmittedCallback(base::lambda<void(bool ctrlShiftEnter)> &&callback) {
_submittedCallback = std_::move(callback); _submittedCallback = std_::move(callback);
} }
@ -805,11 +805,11 @@ void MultiSelect::Inner::setItemText(uint64 itemId, const QString &text) {
} }
} }
void MultiSelect::Inner::setItemRemovedCallback(base::lambda_unique<void(uint64 itemId)> callback) { void MultiSelect::Inner::setItemRemovedCallback(base::lambda<void(uint64 itemId)> &&callback) {
_itemRemovedCallback = std_::move(callback); _itemRemovedCallback = std_::move(callback);
} }
void MultiSelect::Inner::setResizedCallback(base::lambda_unique<void(int heightDelta)> callback) { void MultiSelect::Inner::setResizedCallback(base::lambda<void(int heightDelta)> &&callback) {
_resizedCallback = std_::move(callback); _resizedCallback = std_::move(callback);
} }

View File

@ -36,19 +36,19 @@ public:
void setInnerFocus(); void setInnerFocus();
void clearQuery(); void clearQuery();
void setQueryChangedCallback(base::lambda_unique<void(const QString &query)> callback); void setQueryChangedCallback(base::lambda<void(const QString &query)> &&callback);
void setSubmittedCallback(base::lambda_unique<void(bool ctrlShiftEnter)> callback); void setSubmittedCallback(base::lambda<void(bool ctrlShiftEnter)> &&callback);
void setResizedCallback(base::lambda_unique<void()> callback); void setResizedCallback(base::lambda<void()> &&callback);
enum class AddItemWay { enum class AddItemWay {
Default, Default,
SkipAnimation, SkipAnimation,
}; };
using PaintRoundImage = base::lambda_unique<void(Painter &p, int x, int y, int outerWidth, int size)>; using PaintRoundImage = base::lambda<void(Painter &p, int x, int y, int outerWidth, int size)>;
void addItem(uint64 itemId, const QString &text, const style::color &color, PaintRoundImage paintRoundImage, AddItemWay way = AddItemWay::Default); void addItem(uint64 itemId, const QString &text, const style::color &color, PaintRoundImage &&paintRoundImage, AddItemWay way = AddItemWay::Default);
void setItemText(uint64 itemId, const QString &text); void setItemText(uint64 itemId, const QString &text);
void setItemRemovedCallback(base::lambda_unique<void(uint64 itemId)> callback); void setItemRemovedCallback(base::lambda<void(uint64 itemId)> &&callback);
void removeItem(uint64 itemId); void removeItem(uint64 itemId);
protected: protected:
@ -65,8 +65,8 @@ private:
class Inner; class Inner;
ChildWidget<Inner> _inner; ChildWidget<Inner> _inner;
base::lambda_unique<void()> _resizedCallback; base::lambda<void()> _resizedCallback;
base::lambda_unique<void(const QString &query)> _queryChangedCallback; base::lambda<void(const QString &query)> _queryChangedCallback;
}; };
@ -75,24 +75,24 @@ class MultiSelect::Inner : public TWidget {
Q_OBJECT Q_OBJECT
public: public:
using ScrollCallback = base::lambda_unique<void(int activeTop, int activeBottom)>; using ScrollCallback = base::lambda<void(int activeTop, int activeBottom)>;
Inner(QWidget *parent, const style::MultiSelect &st, const QString &placeholder, ScrollCallback callback); Inner(QWidget *parent, const style::MultiSelect &st, const QString &placeholder, ScrollCallback &&callback);
QString getQuery() const; QString getQuery() const;
bool setInnerFocus(); bool setInnerFocus();
void clearQuery(); void clearQuery();
void setQueryChangedCallback(base::lambda_unique<void(const QString &query)> callback); void setQueryChangedCallback(base::lambda<void(const QString &query)> &&callback);
void setSubmittedCallback(base::lambda_unique<void(bool ctrlShiftEnter)> callback); void setSubmittedCallback(base::lambda<void(bool ctrlShiftEnter)> &&callback);
class Item; class Item;
void addItem(std_::unique_ptr<Item> item, AddItemWay way); void addItem(std_::unique_ptr<Item> item, AddItemWay way);
void setItemText(uint64 itemId, const QString &text); void setItemText(uint64 itemId, const QString &text);
void setItemRemovedCallback(base::lambda_unique<void(uint64 itemId)> callback); void setItemRemovedCallback(base::lambda<void(uint64 itemId)> &&callback);
void removeItem(uint64 itemId); void removeItem(uint64 itemId);
void setResizedCallback(base::lambda_unique<void(int heightDelta)> callback); void setResizedCallback(base::lambda<void(int heightDelta)> &&callback);
~Inner(); ~Inner();
@ -159,10 +159,10 @@ private:
int _newHeight = 0; int _newHeight = 0;
IntAnimation _height; IntAnimation _height;
base::lambda_unique<void(const QString &query)> _queryChangedCallback; base::lambda<void(const QString &query)> _queryChangedCallback;
base::lambda_unique<void(bool ctrlShiftEnter)> _submittedCallback; base::lambda<void(bool ctrlShiftEnter)> _submittedCallback;
base::lambda_unique<void(uint64 itemId)> _itemRemovedCallback; base::lambda<void(uint64 itemId)> _itemRemovedCallback;
base::lambda_unique<void(int heightDelta)> _resizedCallback; base::lambda<void(int heightDelta)> _resizedCallback;
}; };

View File

@ -85,7 +85,7 @@ QAction *PopupMenu::addAction(const QString &text, const QObject *receiver, cons
return _menu->addAction(text, receiver, member, icon, iconOver); return _menu->addAction(text, receiver, member, icon, iconOver);
} }
QAction *PopupMenu::addAction(const QString &text, base::lambda_unique<void()> callback, const style::icon *icon, const style::icon *iconOver) { QAction *PopupMenu::addAction(const QString &text, base::lambda<void()> &&callback, const style::icon *icon, const style::icon *iconOver) {
return _menu->addAction(text, std_::move(callback), icon, iconOver); return _menu->addAction(text, std_::move(callback), icon, iconOver);
} }

View File

@ -29,7 +29,7 @@ public:
PopupMenu(QMenu *menu, const style::PopupMenu &st = st::defaultPopupMenu); PopupMenu(QMenu *menu, const style::PopupMenu &st = st::defaultPopupMenu);
QAction *addAction(const QString &text, const QObject *receiver, const char* member, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr); QAction *addAction(const QString &text, const QObject *receiver, const char* member, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr);
QAction *addAction(const QString &text, base::lambda_unique<void()> callback, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr); QAction *addAction(const QString &text, base::lambda<void()> &&callback, const style::icon *icon = nullptr, const style::icon *iconOver = nullptr);
QAction *addSeparator(); QAction *addSeparator();
void clearActions(); void clearActions();

View File

@ -140,7 +140,6 @@ void ScrollBar::paintEvent(QPaintEvent *e) {
if (a_fullOpacity.current() == 0.) return; if (a_fullOpacity.current() == 0.) return;
QPainter p(this); QPainter p(this);
auto deltal = _vertical ? _st->deltax : 0, deltar = _vertical ? _st->deltax : 0; auto deltal = _vertical ? _st->deltax : 0, deltar = _vertical ? _st->deltax : 0;
auto deltat = _vertical ? 0 : _st->deltax, deltab = _vertical ? 0 : _st->deltax; auto deltat = _vertical ? 0 : _st->deltax, deltab = _vertical ? 0 : _st->deltax;
p.setPen(Qt::NoPen); p.setPen(Qt::NoPen);

View File

@ -74,7 +74,8 @@ protected:
} }
void paintEvent(QPaintEvent *e) override { void paintEvent(QPaintEvent *e) override {
Painter p(this); Painter p(this);
_icon.fill(p, e->rect()); auto clip = e->rect();
_icon.fill(p, QRect(clip.x(), 0, clip.width(), height()));
} }
private: private:

View File

@ -419,7 +419,7 @@ void Widget::hideStop() {
} }
} }
void Widget::hideAnimated(float64 duration, anim::transition func) { void Widget::hideAnimated(float64 duration, const anim::transition &func) {
_opacityDuration = duration; _opacityDuration = duration;
a_func = func; a_func = func;
a_opacity.start(0); a_opacity.start(0);

View File

@ -152,7 +152,7 @@ protected:
private: private:
void destroyDelayed(); void destroyDelayed();
void moveByShift(); void moveByShift();
void hideAnimated(float64 duration, anim::transition func); void hideAnimated(float64 duration, const anim::transition &func);
void step_opacity(float64 ms, bool timer); void step_opacity(float64 ms, bool timer);
void step_shift(float64 ms, bool timer); void step_shift(float64 ms, bool timer);

View File

@ -25,7 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
namespace Window { namespace Window {
PlayerWrapWidget::PlayerWrapWidget(QWidget *parent, base::lambda_unique<void()> updateCallback) : Parent(parent PlayerWrapWidget::PlayerWrapWidget(QWidget *parent, base::lambda<void()> &&updateCallback) : Parent(parent
, new Media::Player::Widget(parent) , new Media::Player::Widget(parent)
, style::margins(0, 0, 0, 0) , style::margins(0, 0, 0, 0)
, std_::move(updateCallback)) { , std_::move(updateCallback)) {

View File

@ -13,7 +13,7 @@ class PlayerWrapWidget : public Ui::WidgetSlideWrap<Media::Player::Widget> {
using Parent = Ui::WidgetSlideWrap<Media::Player::Widget>; using Parent = Ui::WidgetSlideWrap<Media::Player::Widget>;
public: public:
PlayerWrapWidget(QWidget *parent, base::lambda_unique<void()> updateCallback); PlayerWrapWidget(QWidget *parent, base::lambda<void()> &&updateCallback);
void updateAdaptiveLayout() { void updateAdaptiveLayout() {
updateShadowGeometry(); updateShadowGeometry();

View File

@ -35,10 +35,10 @@ public:
void setPixmaps(const QPixmap &oldContentCache, const QPixmap &newContentCache); void setPixmaps(const QPixmap &oldContentCache, const QPixmap &newContentCache);
void setTopBarShadow(bool enabled); void setTopBarShadow(bool enabled);
using RepaintCallback = base::lambda_unique<void()>; using RepaintCallback = base::lambda<void()>;
void setRepaintCallback(RepaintCallback &&callback); void setRepaintCallback(RepaintCallback &&callback);
using FinishedCallback = base::lambda_unique<void()>; using FinishedCallback = base::lambda<void()>;
void setFinishedCallback(FinishedCallback &&callback); void setFinishedCallback(FinishedCallback &&callback);
void start(); void start();

View File

@ -126,7 +126,7 @@ void TopBarWidget::showMenu() {
} }
}); });
_menuToggle->installEventFilter(_menu); _menuToggle->installEventFilter(_menu);
App::main()->fillPeerMenu(peer, [this](const QString &text, base::lambda_unique<void()> callback) { App::main()->fillPeerMenu(peer, [this](const QString &text, base::lambda<void()> &&callback) {
return _menu->addAction(text, std_::move(callback)); return _menu->addAction(text, std_::move(callback));
}); });
_menu->moveToRight(st::topBarMenuPosition.x(), st::topBarMenuPosition.y()); _menu->moveToRight(st::topBarMenuPosition.x(), st::topBarMenuPosition.y());

View File

@ -33,7 +33,7 @@ class WarningWidget : public TWidget {
public: public:
WarningWidget(QWidget *parent); WarningWidget(QWidget *parent);
void setHiddenCallback(base::lambda_unique<void()> callback) { void setHiddenCallback(base::lambda<void()> &&callback) {
_hiddenCallback = std_::move(callback); _hiddenCallback = std_::move(callback);
} }
@ -65,7 +65,7 @@ private:
ChildWidget<Ui::RoundButton> _keepChanges; ChildWidget<Ui::RoundButton> _keepChanges;
ChildWidget<Ui::RoundButton> _revert; ChildWidget<Ui::RoundButton> _revert;
base::lambda_unique<void()> _hiddenCallback; base::lambda<void()> _hiddenCallback;
}; };

View File

@ -207,7 +207,7 @@
'<(src_loc)/core/click_handler.h', '<(src_loc)/core/click_handler.h',
'<(src_loc)/core/click_handler_types.cpp', '<(src_loc)/core/click_handler_types.cpp',
'<(src_loc)/core/click_handler_types.h', '<(src_loc)/core/click_handler_types.h',
'<(src_loc)/core/lambda_wrap.h', '<(src_loc)/core/lambda.h',
'<(src_loc)/core/observer.cpp', '<(src_loc)/core/observer.cpp',
'<(src_loc)/core/observer.h', '<(src_loc)/core/observer.h',
'<(src_loc)/core/ordered_set.h', '<(src_loc)/core/ordered_set.h',