2017-09-13 16:57:44 +00:00
|
|
|
/*
|
|
|
|
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/wrap/padding_wrap.h"
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
template <typename Widget = RpWidget>
|
|
|
|
class SlideWrap;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
class SlideWrap<RpWidget> : public Wrap<PaddingWrap<RpWidget>> {
|
|
|
|
using Parent = Wrap<PaddingWrap<RpWidget>>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SlideWrap(QWidget *parent, object_ptr<RpWidget> child);
|
|
|
|
SlideWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
object_ptr<RpWidget> child,
|
|
|
|
const style::margins &padding);
|
|
|
|
SlideWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
object_ptr<RpWidget> child,
|
|
|
|
int duration);
|
2017-09-21 10:28:34 +00:00
|
|
|
SlideWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
const style::margins &padding);
|
|
|
|
SlideWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
const style::margins &padding,
|
|
|
|
int duration);
|
2017-09-13 16:57:44 +00:00
|
|
|
SlideWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
object_ptr<RpWidget> child,
|
|
|
|
const style::margins &padding,
|
|
|
|
int duration);
|
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
void toggleAnimated(bool shown);
|
|
|
|
void toggleFast(bool shown);
|
2017-09-13 16:57:44 +00:00
|
|
|
|
|
|
|
void showAnimated() {
|
|
|
|
toggleAnimated(true);
|
|
|
|
}
|
|
|
|
void hideAnimated() {
|
|
|
|
toggleAnimated(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void showFast() {
|
|
|
|
toggleFast(true);
|
|
|
|
}
|
|
|
|
void hideFast() {
|
|
|
|
toggleFast(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool animating() const {
|
|
|
|
return _slideAnimation.animating();
|
|
|
|
}
|
|
|
|
void finishAnimations();
|
|
|
|
|
|
|
|
QMargins getMargins() const override;
|
|
|
|
|
|
|
|
bool isHiddenOrHiding() const {
|
2017-09-13 17:01:23 +00:00
|
|
|
return !_shown;
|
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<bool> shownValue() const {
|
|
|
|
return _shownUpdated.events_starting_with_copy(_shown);
|
2017-09-13 16:57:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int resizeGetHeight(int newWidth) override;
|
|
|
|
void wrappedSizeUpdated(QSize size) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void animationStep();
|
2017-09-13 17:01:23 +00:00
|
|
|
void setShown(bool shown);
|
2017-09-13 16:57:44 +00:00
|
|
|
|
2017-09-13 17:01:23 +00:00
|
|
|
bool _shown = true;
|
|
|
|
rpl::event_stream<bool> _shownUpdated;
|
2017-09-13 16:57:44 +00:00
|
|
|
Animation _slideAnimation;
|
|
|
|
int _duration = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename Widget>
|
|
|
|
class SlideWrap : public Wrap<PaddingWrap<Widget>, SlideWrap<RpWidget>> {
|
|
|
|
using Parent = Wrap<PaddingWrap<Widget>, SlideWrap<RpWidget>>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SlideWrap(QWidget *parent, object_ptr<Widget> child)
|
|
|
|
: Parent(parent, std::move(child)) {
|
|
|
|
}
|
|
|
|
SlideWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
object_ptr<Widget> child,
|
|
|
|
const style::margins &padding)
|
|
|
|
: Parent(parent, std::move(child), padding) {
|
|
|
|
}
|
|
|
|
SlideWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
object_ptr<Widget> child,
|
|
|
|
int duration)
|
|
|
|
: Parent(parent, std::move(child), duration) {
|
|
|
|
}
|
2017-09-21 10:28:34 +00:00
|
|
|
SlideWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
const style::margins &padding)
|
|
|
|
: Parent(parent, padding) {
|
|
|
|
}
|
|
|
|
SlideWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
const style::margins &padding,
|
|
|
|
int duration)
|
|
|
|
: Parent(parent, nullptr, padding, duration) {
|
|
|
|
}
|
2017-09-13 16:57:44 +00:00
|
|
|
SlideWrap(
|
|
|
|
QWidget *parent,
|
|
|
|
object_ptr<Widget> child,
|
|
|
|
const style::margins &padding,
|
|
|
|
int duration)
|
|
|
|
: Parent(parent, std::move(child), padding, duration) {
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-09-21 10:28:34 +00:00
|
|
|
inline object_ptr<SlideWrap<>> CreateSlideSkipWidget(
|
|
|
|
QWidget *parent,
|
|
|
|
int skip) {
|
|
|
|
return object_ptr<SlideWrap<>>(
|
|
|
|
parent,
|
|
|
|
QMargins(0, 0, 0, skip));
|
|
|
|
}
|
|
|
|
|
2017-09-13 16:57:44 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|