2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Info shared media and common groups counters.

This commit is contained in:
John Preston
2017-09-21 22:21:33 +03:00
parent 812dcb5e8d
commit b9fb9af74f
26 changed files with 1048 additions and 435 deletions

View File

@@ -37,12 +37,6 @@ public:
object_ptr<RpWidget> child,
const style::margins &padding);
PaddingWrap(
QWidget *parent,
const style::margins &padding)
: PaddingWrap(parent, nullptr, padding) {
}
int naturalWidth() const override;
protected:
@@ -66,18 +60,23 @@ public:
: Parent(parent, std::move(child), padding) {
}
PaddingWrap(QWidget *parent, const style::margins &padding)
: Parent(parent, padding) {
};
class FixedHeightWidget : public RpWidget {
public:
FixedHeightWidget(QWidget *parent, int height)
: RpWidget(parent) {
resize(width(), height);
}
};
inline object_ptr<PaddingWrap<>> CreateSkipWidget(
inline object_ptr<FixedHeightWidget> CreateSkipWidget(
QWidget *parent,
int skip) {
return object_ptr<PaddingWrap<>>(
return object_ptr<FixedHeightWidget>(
parent,
QMargins(0, 0, 0, skip));
skip);
}
} // namespace Ui

View File

@@ -28,53 +28,69 @@ SlideWrap<RpWidget>::SlideWrap(
: SlideWrap(
parent,
std::move(child),
style::margins(),
st::slideWrapDuration) {
style::margins()) {
}
SlideWrap<RpWidget>::SlideWrap(
QWidget *parent,
const style::margins &padding)
: SlideWrap(parent, nullptr, padding) {
}
SlideWrap<RpWidget>::SlideWrap(
QWidget *parent,
object_ptr<RpWidget> child,
const style::margins &padding)
: SlideWrap(
parent,
std::move(child),
padding,
st::slideWrapDuration) {
}
SlideWrap<RpWidget>::SlideWrap(
QWidget *parent,
object_ptr<RpWidget> child,
int duration)
: SlideWrap(parent, std::move(child), style::margins(), duration) {
}
SlideWrap<RpWidget>::SlideWrap(
QWidget *parent,
const style::margins &padding)
: SlideWrap(parent, nullptr, padding, st::slideWrapDuration) {
}
SlideWrap<RpWidget>::SlideWrap(
QWidget *parent,
const style::margins &padding,
int duration)
: SlideWrap(parent, nullptr, padding, duration) {
}
SlideWrap<RpWidget>::SlideWrap(
QWidget *parent,
object_ptr<RpWidget> child,
const style::margins &padding,
int duration)
: Parent(
parent,
object_ptr<PaddingWrap<RpWidget>>(
parent,
std::move(child),
padding))
, _duration(duration) {
, _duration(st::slideWrapDuration) {
}
SlideWrap<RpWidget> *SlideWrap<RpWidget>::setDuration(int duration) {
_duration = duration;
return this;
}
SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleAnimated(
bool shown) {
if (_shown != shown) {
setShown(shown);
_slideAnimation.start(
[this] { animationStep(); },
_shown ? 0. : 1.,
_shown ? 1. : 0.,
_duration,
anim::linear);
}
animationStep();
return this;
}
SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleFast(bool shown) {
setShown(shown);
finishAnimations();
return this;
}
SlideWrap<RpWidget> *SlideWrap<RpWidget>::finishAnimations() {
_slideAnimation.finish();
animationStep();
return this;
}
SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleOn(
rpl::producer<bool> &&shown) {
_toggleOnLifetime.destroy();
std::move(shown)
| rpl::start([this](bool shown) {
toggleAnimated(shown);
}, _toggleOnLifetime);
finishAnimations();
return this;
}
void SlideWrap<RpWidget>::animationStep() {
@@ -107,31 +123,6 @@ void SlideWrap<RpWidget>::setShown(bool shown) {
_shownUpdated.fire_copy(_shown);
}
void SlideWrap<RpWidget>::toggleAnimated(bool shown) {
if (_shown == shown) {
animationStep();
return;
}
setShown(shown);
_slideAnimation.start(
[this] { animationStep(); },
_shown ? 0. : 1.,
_shown ? 1. : 0.,
_duration,
anim::linear);
animationStep();
}
void SlideWrap<RpWidget>::toggleFast(bool shown) {
setShown(shown);
finishAnimations();
}
void SlideWrap<RpWidget>::finishAnimations() {
_slideAnimation.finish();
animationStep();
}
QMargins SlideWrap<RpWidget>::getMargins() const {
auto result = wrapped()->getMargins();
return (animating() || !_shown)

View File

@@ -32,49 +32,30 @@ 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);
object_ptr<RpWidget> child);
SlideWrap(
QWidget *parent,
const style::margins &padding);
SlideWrap(
QWidget *parent,
const style::margins &padding,
int duration);
SlideWrap(
QWidget *parent,
object_ptr<RpWidget> child,
const style::margins &padding,
int duration);
const style::margins &padding);
void toggleAnimated(bool shown);
void toggleFast(bool shown);
void showAnimated() {
toggleAnimated(true);
}
void hideAnimated() {
toggleAnimated(false);
}
void showFast() {
toggleFast(true);
}
void hideFast() {
toggleFast(false);
}
SlideWrap *setDuration(int duration);
SlideWrap *toggleAnimated(bool shown);
SlideWrap *toggleFast(bool shown);
SlideWrap *showAnimated() { return toggleAnimated(true); }
SlideWrap *hideAnimated() { return toggleAnimated(false); }
SlideWrap *showFast() { return toggleFast(true); }
SlideWrap *hideFast() { return toggleFast(false); }
SlideWrap *finishAnimations();
SlideWrap *toggleOn(rpl::producer<bool> &&shown);
bool animating() const {
return _slideAnimation.animating();
}
void finishAnimations();
QMargins getMargins() const override;
@@ -96,6 +77,7 @@ private:
bool _shown = true;
rpl::event_stream<bool> _shownUpdated;
rpl::lifetime _toggleOnLifetime;
Animation _slideAnimation;
int _duration = 0;
@@ -106,38 +88,54 @@ class SlideWrap : public Wrap<PaddingWrap<Widget>, SlideWrap<RpWidget>> {
using Parent = Wrap<PaddingWrap<Widget>, SlideWrap<RpWidget>>;
public:
SlideWrap(QWidget *parent, object_ptr<Widget> child)
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) {
}
SlideWrap(
QWidget *parent,
const style::margins &padding)
: Parent(parent, padding) {
}
SlideWrap(
QWidget *parent,
const style::margins &padding,
int duration)
: Parent(parent, nullptr, padding, duration) {
}
SlideWrap(
QWidget *parent,
object_ptr<Widget> child,
const style::margins &padding,
int duration)
: Parent(parent, std::move(child), padding, duration) {
const style::margins &padding)
: Parent(parent, std::move(child), padding) {
}
SlideWrap *setDuration(int duration) {
return chain(Parent::setDuration(duration));
}
SlideWrap *toggleAnimated(bool shown) {
return chain(Parent::toggleAnimated(shown));
}
SlideWrap *toggleFast(bool shown) {
return chain(Parent::toggleFast(shown));
}
SlideWrap *showAnimated() {
return chain(Parent::showAnimated());
}
SlideWrap *hideAnimated() {
return chain(Parent::hideAnimated());
}
SlideWrap *showFast() {
return chain(Parent::showFast());
}
SlideWrap *hideFast() {
return chain(Parent::hideFast());
}
SlideWrap *finishAnimations() {
return chain(Parent::finishAnimations());
}
SlideWrap *toggleOn(rpl::producer<bool> &&shown) {
return chain(Parent::toggleOn(std::move(shown)));
}
private:
SlideWrap *chain(SlideWrap<RpWidget> *result) {
return static_cast<SlideWrap*>(result);
}
};