| 
									
										
										
										
											2014-07-04 15:12:54 +04:00
										 |  |  | /*
 | 
					
						
							|  |  |  | This file is part of Telegram Desktop, | 
					
						
							| 
									
										
										
										
											2014-12-01 13:47:38 +03:00
										 |  |  | the official desktop version of Telegram messaging app, see https://telegram.org
 | 
					
						
							| 
									
										
										
										
											2014-07-04 15:12:54 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-03 16:16:42 +03:00
										 |  |  | In addition, as a special exception, the copyright holders give permission | 
					
						
							|  |  |  | to link the code of portions of this program with the OpenSSL library. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-04 15:12:54 +04:00
										 |  |  | Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
 | 
					
						
							| 
									
										
										
										
											2015-10-03 16:16:42 +03:00
										 |  |  | Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
 | 
					
						
							| 
									
										
										
										
											2014-07-04 15:12:54 +04:00
										 |  |  | */ | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QtWidgets/QWidget>
 | 
					
						
							|  |  |  | #include "gui/twidget.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Switcher : public TWidget, public Animated { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	Switcher(QWidget *parent, const style::switcher &st); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void mousePressEvent(QMouseEvent *e); | 
					
						
							|  |  |  | 	void mouseMoveEvent(QMouseEvent *e); | 
					
						
							|  |  |  | 	void mouseReleaseEvent(QMouseEvent *e); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void paintEvent(QPaintEvent *e); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void enterEvent(QEvent *e); | 
					
						
							|  |  |  | 	void leaveEvent(QEvent *e); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void addButton(const QString &btn); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool animStep(float64 ms); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int selected() const; | 
					
						
							|  |  |  | 	void setSelected(int selected); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | signals: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void changed(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void setOver(int over); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int _selected; | 
					
						
							|  |  |  | 	int _over, _wasOver, _pressed; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	typedef QVector<QString> Buttons; | 
					
						
							|  |  |  | 	Buttons _buttons; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	style::switcher _st; | 
					
						
							|  |  |  | 	anim::cvalue a_bgOver, a_bgWasOver; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }; |