mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-09-23 12:15:17 +02:00
Add fireworks on ending a task list.
This commit is contained in:
parent
5666e84d92
commit
e5de8e22b7
2 changed files with 33 additions and 0 deletions
|
@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/effects/radial_animation.h"
|
#include "ui/effects/radial_animation.h"
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
|
#include "ui/effects/fireworks_animation.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "data/data_media_types.h"
|
#include "data/data_media_types.h"
|
||||||
|
@ -276,14 +277,19 @@ void TodoList::updateTasks(bool skipAnimations) {
|
||||||
&Task::id,
|
&Task::id,
|
||||||
&TodoListItem::id);
|
&TodoListItem::id);
|
||||||
if (!changed) {
|
if (!changed) {
|
||||||
|
auto animated = false;
|
||||||
auto &&tasks = ranges::views::zip(_tasks, _todolist->items);
|
auto &&tasks = ranges::views::zip(_tasks, _todolist->items);
|
||||||
for (auto &&[task, original] : tasks) {
|
for (auto &&[task, original] : tasks) {
|
||||||
const auto wasDate = task.completionDate;
|
const auto wasDate = task.completionDate;
|
||||||
task.fillData(_todolist, original, context);
|
task.fillData(_todolist, original, context);
|
||||||
if (!skipAnimations && (!wasDate != !task.completionDate)) {
|
if (!skipAnimations && (!wasDate != !task.completionDate)) {
|
||||||
startToggleAnimation(task);
|
startToggleAnimation(task);
|
||||||
|
animated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (animated) {
|
||||||
|
maybeStartFireworks();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_tasks = ranges::views::all(
|
_tasks = ranges::views::all(
|
||||||
|
@ -337,6 +343,15 @@ void TodoList::toggleCompletion(int id) {
|
||||||
_parent->data()->fullId(),
|
_parent->data()->fullId(),
|
||||||
id,
|
id,
|
||||||
!selected);
|
!selected);
|
||||||
|
|
||||||
|
maybeStartFireworks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TodoList::maybeStartFireworks() {
|
||||||
|
if (!ranges::contains(_tasks, TimeId(), &Task::completionDate)) {
|
||||||
|
_fireworksAnimation = std::make_unique<Ui::FireworksAnimation>(
|
||||||
|
[=] { repaint(); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TodoList::updateCompletionStatus() {
|
void TodoList::updateCompletionStatus() {
|
||||||
|
@ -625,6 +640,16 @@ TextState TodoList::textState(QPoint point, StateRequest request) const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TodoList::paintBubbleFireworks(
|
||||||
|
Painter &p,
|
||||||
|
const QRect &bubble,
|
||||||
|
crl::time ms) const {
|
||||||
|
if (!_fireworksAnimation || _fireworksAnimation->paint(p, bubble)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_fireworksAnimation = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void TodoList::clickHandlerPressedChanged(
|
void TodoList::clickHandlerPressedChanged(
|
||||||
const ClickHandlerPtr &handler,
|
const ClickHandlerPtr &handler,
|
||||||
bool pressed) {
|
bool pressed) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class RippleAnimation;
|
class RippleAnimation;
|
||||||
|
class FireworksAnimation;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace HistoryView {
|
namespace HistoryView {
|
||||||
|
@ -51,6 +52,11 @@ public:
|
||||||
uint16 fullSelectionLength() const override;
|
uint16 fullSelectionLength() const override;
|
||||||
TextForMimeData selectedText(TextSelection selection) const override;
|
TextForMimeData selectedText(TextSelection selection) const override;
|
||||||
|
|
||||||
|
void paintBubbleFireworks(
|
||||||
|
Painter &p,
|
||||||
|
const QRect &bubble,
|
||||||
|
crl::time ms) const override;
|
||||||
|
|
||||||
void clickHandlerPressedChanged(
|
void clickHandlerPressedChanged(
|
||||||
const ClickHandlerPtr &handler,
|
const ClickHandlerPtr &handler,
|
||||||
bool pressed) override;
|
bool pressed) override;
|
||||||
|
@ -80,6 +86,7 @@ private:
|
||||||
void updateTasks(bool skipAnimations);
|
void updateTasks(bool skipAnimations);
|
||||||
void startToggleAnimation(Task &task);
|
void startToggleAnimation(Task &task);
|
||||||
void updateCompletionStatus();
|
void updateCompletionStatus();
|
||||||
|
void maybeStartFireworks();
|
||||||
void setupPreviousState(const std::vector<TodoTaskInfo> &info);
|
void setupPreviousState(const std::vector<TodoTaskInfo> &info);
|
||||||
|
|
||||||
int paintTask(
|
int paintTask(
|
||||||
|
@ -122,6 +129,7 @@ private:
|
||||||
std::vector<Task> _tasks;
|
std::vector<Task> _tasks;
|
||||||
Ui::Text::String _completionStatusLabel;
|
Ui::Text::String _completionStatusLabel;
|
||||||
|
|
||||||
|
mutable std::unique_ptr<Ui::FireworksAnimation> _fireworksAnimation;
|
||||||
mutable QPoint _lastLinkPoint;
|
mutable QPoint _lastLinkPoint;
|
||||||
mutable QImage _userpicCircleCache;
|
mutable QImage _userpicCircleCache;
|
||||||
mutable QImage _fillingIconCache;
|
mutable QImage _fillingIconCache;
|
||||||
|
|
Loading…
Add table
Reference in a new issue