Now base::lambda can be copied and can wrap any immutable lambda. For mutable lambdas there is base::lambda_once (which you're supposed to call only once to pass data through lambda captures, for example by using std::unique_ptr). Generally base::lambda is passed by value and base::lambda_once is passed by rvalue reference.
		
			
				
	
	
		
			96 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			96 lines
		
	
	
	
		
			2.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
This file is part of Telegram Desktop,
 | 
						|
the official desktop version of Telegram messaging app, see https://telegram.org
 | 
						|
 | 
						|
Telegram Desktop is free software: you can redistribute it and/or modify
 | 
						|
it under the terms of the GNU General Public License as published by
 | 
						|
the Free Software Foundation, either version 3 of the License, or
 | 
						|
(at your option) any later version.
 | 
						|
 | 
						|
It is distributed in the hope that it will be useful,
 | 
						|
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 | 
						|
GNU General Public License for more details.
 | 
						|
 | 
						|
In addition, as a special exception, the copyright holders give permission
 | 
						|
to link the code of portions of this program with the OpenSSL library.
 | 
						|
 | 
						|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
 | 
						|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
 | 
						|
*/
 | 
						|
#pragma once
 | 
						|
 | 
						|
#include "ui/text/text.h"
 | 
						|
 | 
						|
class History;
 | 
						|
class HistoryItem;
 | 
						|
 | 
						|
namespace Ui {
 | 
						|
class RippleAnimation;
 | 
						|
} // namespace Ui
 | 
						|
 | 
						|
namespace Dialogs {
 | 
						|
namespace Layout {
 | 
						|
class RowPainter;
 | 
						|
} // namespace Layout
 | 
						|
 | 
						|
class RippleRow {
 | 
						|
public:
 | 
						|
	RippleRow();
 | 
						|
	~RippleRow();
 | 
						|
 | 
						|
	void addRipple(QPoint origin, QSize size, base::lambda<void()> updateCallback);
 | 
						|
	void stopLastRipple();
 | 
						|
 | 
						|
	void paintRipple(Painter &p, int x, int y, int outerWidth, TimeMs ms, const QColor *colorOverride = nullptr) const;
 | 
						|
 | 
						|
private:
 | 
						|
	mutable std::unique_ptr<Ui::RippleAnimation> _ripple;
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
class List;
 | 
						|
class Row : public RippleRow {
 | 
						|
public:
 | 
						|
	Row(History *history, Row *prev, Row *next, int pos)
 | 
						|
		: _history(history)
 | 
						|
		, _prev(prev)
 | 
						|
		, _next(next)
 | 
						|
		, _pos(pos) {
 | 
						|
	}
 | 
						|
	void *attached = nullptr; // for any attached data, for example View in contacts list
 | 
						|
 | 
						|
	History *history() const {
 | 
						|
		return _history;
 | 
						|
	}
 | 
						|
	int pos() const {
 | 
						|
		return _pos;
 | 
						|
	}
 | 
						|
 | 
						|
private:
 | 
						|
	friend class List;
 | 
						|
 | 
						|
	History *_history;
 | 
						|
	Row *_prev, *_next;
 | 
						|
	int _pos;
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
class FakeRow : public RippleRow {
 | 
						|
public:
 | 
						|
	FakeRow(HistoryItem *item);
 | 
						|
 | 
						|
	HistoryItem *item() const {
 | 
						|
		return _item;
 | 
						|
	}
 | 
						|
 | 
						|
private:
 | 
						|
	friend class Layout::RowPainter;
 | 
						|
 | 
						|
	HistoryItem *_item;
 | 
						|
	mutable const HistoryItem *_cacheFor = nullptr;
 | 
						|
	mutable Text _cache;
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
} // namespace Dialogs
 |