| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | /*
 | 
					
						
							|  |  |  | This file is part of Telegram Desktop, | 
					
						
							|  |  |  | the official desktop application for the Telegram messaging service. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | For license and copyright information please follow this link: | 
					
						
							|  |  |  | https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "ui/rp_widget.h"
 | 
					
						
							| 
									
										
										
										
											2019-04-02 13:13:30 +04:00
										 |  |  | #include "ui/effects/animations.h"
 | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | #include "boxes/abstract_box.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Ui { | 
					
						
							|  |  |  | class IconButton; | 
					
						
							|  |  |  | class FlatLabel; | 
					
						
							|  |  |  | template <typename Widget> | 
					
						
							|  |  |  | class FadeWrapScaled; | 
					
						
							|  |  |  | } // namespace Ui
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Window { | 
					
						
							|  |  |  | class LayerStackWidget; | 
					
						
							|  |  |  | } // namespace Window
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Ui { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-26 22:33:30 +01:00
										 |  |  | class SeparatePanel : public Ui::RpWidget, private base::Subscriber { | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | public: | 
					
						
							|  |  |  | 	SeparatePanel(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void setTitle(rpl::producer<QString> title); | 
					
						
							|  |  |  | 	void setInnerSize(QSize size); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-20 01:02:36 +01:00
										 |  |  | 	void setHideOnDeactivate(bool hideOnDeactivate); | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | 	void showAndActivate(); | 
					
						
							| 
									
										
										
										
											2018-06-02 17:29:21 +03:00
										 |  |  | 	int hideGetDuration(); | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void showInner(base::unique_qptr<Ui::RpWidget> inner); | 
					
						
							|  |  |  | 	void showBox( | 
					
						
							|  |  |  | 		object_ptr<BoxContent> box, | 
					
						
							|  |  |  | 		LayerOptions options, | 
					
						
							|  |  |  | 		anim::type animated); | 
					
						
							|  |  |  | 	void showToast(const QString &text); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	rpl::producer<> backRequests() const; | 
					
						
							|  |  |  | 	rpl::producer<> closeRequests() const; | 
					
						
							| 
									
										
										
										
											2018-06-02 17:29:21 +03:00
										 |  |  | 	rpl::producer<> closeEvents() const; | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | 	void setBackAllowed(bool allowed); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  | 	void paintEvent(QPaintEvent *e) override; | 
					
						
							|  |  |  | 	void closeEvent(QCloseEvent *e) override; | 
					
						
							|  |  |  | 	void resizeEvent(QResizeEvent *e) override; | 
					
						
							|  |  |  | 	void focusInEvent(QFocusEvent *e) override; | 
					
						
							|  |  |  | 	void mousePressEvent(QMouseEvent *e) override; | 
					
						
							|  |  |  | 	void mouseReleaseEvent(QMouseEvent *e) override; | 
					
						
							|  |  |  | 	void mouseMoveEvent(QMouseEvent *e) override; | 
					
						
							|  |  |  | 	void leaveEventHook(QEvent *e) override; | 
					
						
							|  |  |  | 	void leaveToChildEvent(QEvent *e, QWidget *child) override; | 
					
						
							|  |  |  | 	void keyPressEvent(QKeyEvent *e) override; | 
					
						
							| 
									
										
										
										
											2018-06-20 01:02:36 +01:00
										 |  |  | 	bool eventHook(QEvent *e) override; | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	void initControls(); | 
					
						
							|  |  |  | 	void initLayout(); | 
					
						
							|  |  |  | 	void initGeometry(QSize size); | 
					
						
							|  |  |  | 	void updateGeometry(QSize size); | 
					
						
							|  |  |  | 	void showControls(); | 
					
						
							|  |  |  | 	void updateControlsGeometry(); | 
					
						
							|  |  |  | 	void createBorderImage(); | 
					
						
							|  |  |  | 	void opacityCallback(); | 
					
						
							|  |  |  | 	void ensureLayerCreated(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-20 01:02:36 +01:00
										 |  |  | 	void updateTitleGeometry(int newWidth); | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | 	void updateTitlePosition(); | 
					
						
							|  |  |  | 	void paintShadowBorder(Painter &p) const; | 
					
						
							|  |  |  | 	void paintOpaqueBorder(Painter &p) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void toggleOpacityAnimation(bool visible); | 
					
						
							|  |  |  | 	void finishAnimating(); | 
					
						
							| 
									
										
										
										
											2018-06-02 17:29:21 +03:00
										 |  |  | 	void finishClose(); | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	object_ptr<Ui::IconButton> _close; | 
					
						
							|  |  |  | 	object_ptr<Ui::FlatLabel> _title = { nullptr }; | 
					
						
							|  |  |  | 	object_ptr<Ui::FadeWrapScaled<Ui::IconButton>> _back; | 
					
						
							|  |  |  | 	object_ptr<Ui::RpWidget> _body; | 
					
						
							|  |  |  | 	base::unique_qptr<Ui::RpWidget> _inner; | 
					
						
							| 
									
										
										
										
											2018-11-23 15:05:06 +04:00
										 |  |  | 	base::unique_qptr<Window::LayerStackWidget> _layer = { nullptr }; | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | 	rpl::event_stream<> _synteticBackRequests; | 
					
						
							| 
									
										
										
										
											2018-06-02 17:29:21 +03:00
										 |  |  | 	rpl::event_stream<> _userCloseRequests; | 
					
						
							|  |  |  | 	rpl::event_stream<> _closeEvents; | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-20 01:02:36 +01:00
										 |  |  | 	bool _hideOnDeactivate = false; | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | 	bool _useTransparency = true; | 
					
						
							|  |  |  | 	style::margins _padding; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool _dragging = false; | 
					
						
							|  |  |  | 	QPoint _dragStartMousePosition; | 
					
						
							|  |  |  | 	QPoint _dragStartMyPosition; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-02 13:13:30 +04:00
										 |  |  | 	Ui::Animations::Simple _titleLeft; | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | 	bool _visible = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-02 13:13:30 +04:00
										 |  |  | 	Ui::Animations::Simple _opacityAnimation; | 
					
						
							| 
									
										
										
										
											2018-06-02 12:59:19 +03:00
										 |  |  | 	QPixmap _animationCache; | 
					
						
							|  |  |  | 	QPixmap _borderParts; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace Ui
 |