2016-09-09 15:52:46 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-09-09 15:52:46 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-09-09 15:52:46 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2017-09-16 16:53:41 +00:00
|
|
|
#include "ui/rp_widget.h"
|
2017-04-08 15:20:12 +00:00
|
|
|
#include "base/timer.h"
|
2016-09-09 15:52:46 +00:00
|
|
|
|
2017-04-07 18:10:49 +00:00
|
|
|
namespace Window {
|
|
|
|
class Controller;
|
|
|
|
} // namespace Window
|
|
|
|
|
2017-04-09 18:06:06 +00:00
|
|
|
namespace Ui {
|
|
|
|
class PanelAnimation;
|
|
|
|
} // namespace Ui
|
|
|
|
|
2017-03-29 14:04:00 +00:00
|
|
|
namespace ChatHelpers {
|
2016-09-09 15:52:46 +00:00
|
|
|
|
2017-04-08 15:20:12 +00:00
|
|
|
class TabbedSelector;
|
2016-09-09 15:52:46 +00:00
|
|
|
|
2018-11-21 18:14:48 +00:00
|
|
|
class TabbedPanel : public Ui::RpWidget {
|
2016-09-09 15:52:46 +00:00
|
|
|
public:
|
2017-08-17 08:31:24 +00:00
|
|
|
TabbedPanel(QWidget *parent, not_null<Window::Controller*> controller);
|
2018-11-22 12:48:50 +00:00
|
|
|
TabbedPanel(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Window::Controller*> controller,
|
|
|
|
object_ptr<TabbedSelector> selector);
|
2016-09-09 15:52:46 +00:00
|
|
|
|
2017-04-09 18:06:06 +00:00
|
|
|
object_ptr<TabbedSelector> takeSelector();
|
|
|
|
QPointer<TabbedSelector> getSelector() const;
|
2018-11-22 12:48:50 +00:00
|
|
|
void moveBottomRight(int bottom, int right);
|
|
|
|
void setDesiredHeightValues(
|
|
|
|
float64 ratio,
|
|
|
|
int minHeight,
|
|
|
|
int maxHeight);
|
2016-09-09 15:52:46 +00:00
|
|
|
|
2016-10-26 16:43:13 +00:00
|
|
|
void hideFast();
|
2016-09-09 15:52:46 +00:00
|
|
|
bool hiding() const {
|
|
|
|
return _hiding || _hideTimer.isActive();
|
|
|
|
}
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
bool overlaps(const QRect &globalRect) const;
|
2016-09-09 15:52:46 +00:00
|
|
|
|
2017-03-27 18:11:51 +00:00
|
|
|
void showAnimated();
|
2016-10-26 16:43:13 +00:00
|
|
|
void hideAnimated();
|
2017-04-09 18:06:06 +00:00
|
|
|
void toggleAnimated();
|
2016-11-12 15:02:19 +00:00
|
|
|
|
2017-04-08 15:20:12 +00:00
|
|
|
~TabbedPanel();
|
2017-03-29 14:04:00 +00:00
|
|
|
|
2016-11-19 09:22:53 +00:00
|
|
|
protected:
|
2017-02-11 11:24:37 +00:00
|
|
|
void enterEventHook(QEvent *e) override;
|
|
|
|
void leaveEventHook(QEvent *e) override;
|
2016-11-19 09:22:53 +00:00
|
|
|
void otherEnter();
|
|
|
|
void otherLeave();
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
bool eventFilter(QObject *obj, QEvent *e) override;
|
|
|
|
|
2016-09-09 15:52:46 +00:00
|
|
|
private:
|
2017-04-08 15:20:12 +00:00
|
|
|
void hideByTimerOrLeave();
|
2017-01-07 11:55:05 +00:00
|
|
|
void moveByBottom();
|
2017-04-09 18:06:06 +00:00
|
|
|
bool isDestroying() const {
|
|
|
|
return !_selector;
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
void showFromSelector();
|
2016-11-12 15:02:19 +00:00
|
|
|
|
|
|
|
style::margins innerPadding() const;
|
|
|
|
|
|
|
|
// Rounded rect which has shadow around it.
|
|
|
|
QRect innerRect() const;
|
|
|
|
|
2017-04-08 15:20:12 +00:00
|
|
|
QImage grabForAnimation();
|
2016-11-12 15:02:19 +00:00
|
|
|
void startShowAnimation();
|
|
|
|
void startOpacityAnimation(bool hiding);
|
2019-04-30 08:56:21 +00:00
|
|
|
void prepareCacheFor(bool hiding);
|
2016-11-12 15:02:19 +00:00
|
|
|
|
|
|
|
void opacityAnimationCallback();
|
|
|
|
|
|
|
|
void hideFinished();
|
|
|
|
void showStarted();
|
|
|
|
|
2016-09-09 15:52:46 +00:00
|
|
|
bool preventAutoHide() const;
|
|
|
|
void updateContentHeight();
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<Window::Controller*> _controller;
|
2017-04-08 15:20:12 +00:00
|
|
|
object_ptr<TabbedSelector> _selector;
|
2016-09-09 15:52:46 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
int _contentMaxHeight = 0;
|
|
|
|
int _contentHeight = 0;
|
|
|
|
int _bottom = 0;
|
2018-11-22 12:48:50 +00:00
|
|
|
int _right = 0;
|
|
|
|
float64 _heightRatio = 1.;
|
|
|
|
int _minContentHeight = 0;
|
|
|
|
int _maxContentHeight = 0;
|
2016-09-09 15:52:46 +00:00
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<Ui::PanelAnimation> _showAnimation;
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _a_show;
|
2016-09-09 15:52:46 +00:00
|
|
|
|
2016-11-12 15:02:19 +00:00
|
|
|
bool _hiding = false;
|
2017-03-28 12:30:38 +00:00
|
|
|
bool _hideAfterSlide = false;
|
2016-11-12 15:02:19 +00:00
|
|
|
QPixmap _cache;
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _a_opacity;
|
2017-04-08 15:20:12 +00:00
|
|
|
base::Timer _hideTimer;
|
2017-03-29 15:09:16 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-03-29 14:04:00 +00:00
|
|
|
} // namespace ChatHelpers
|