mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed animation for grouped userpics in who read context menu item.
This commit is contained in:
parent
21c562fcb7
commit
a5be9d78d8
1 changed files with 21 additions and 5 deletions
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "ui/controls/who_read_context_action.h"
|
#include "ui/controls/who_read_context_action.h"
|
||||||
|
|
||||||
|
#include "base/call_delayed.h";
|
||||||
#include "ui/widgets/menu/menu_action.h"
|
#include "ui/widgets/menu/menu_action.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
|
@ -89,6 +90,7 @@ private:
|
||||||
int _textWidth = 0;
|
int _textWidth = 0;
|
||||||
const int _height = 0;
|
const int _height = 0;
|
||||||
int _userpicsWidth = 0;
|
int _userpicsWidth = 0;
|
||||||
|
bool _appeared = false;
|
||||||
|
|
||||||
WhoReadContent _content;
|
WhoReadContent _content;
|
||||||
|
|
||||||
|
@ -193,6 +195,9 @@ Action::Action(
|
||||||
+ _st.itemStyle.font->height
|
+ _st.itemStyle.font->height
|
||||||
+ st::defaultWhoRead.itemPadding.bottom()) {
|
+ st::defaultWhoRead.itemPadding.bottom()) {
|
||||||
const auto parent = parentMenu->menu();
|
const auto parent = parentMenu->menu();
|
||||||
|
const auto checkAppeared = [=, now = crl::now()] {
|
||||||
|
_appeared = (crl::now() - now) >= parentMenu->st().duration;
|
||||||
|
};
|
||||||
|
|
||||||
setAcceptBoth(true);
|
setAcceptBoth(true);
|
||||||
initResizeHook(parent->sizeValue());
|
initResizeHook(parent->sizeValue());
|
||||||
|
@ -208,6 +213,7 @@ Action::Action(
|
||||||
std::move(
|
std::move(
|
||||||
content
|
content
|
||||||
) | rpl::start_with_next([=](WhoReadContent &&content) {
|
) | rpl::start_with_next([=](WhoReadContent &&content) {
|
||||||
|
checkAppeared();
|
||||||
const auto changed = (_content.participants != content.participants);
|
const auto changed = (_content.participants != content.participants);
|
||||||
_content = content;
|
_content = content;
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
@ -240,6 +246,11 @@ Action::Action(
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
enableMouseSelecting();
|
enableMouseSelecting();
|
||||||
|
|
||||||
|
base::call_delayed(parentMenu->st().duration, this, [=] {
|
||||||
|
checkAppeared();
|
||||||
|
updateUserpicsFromContent();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::resolveMinWidth() {
|
void Action::resolveMinWidth() {
|
||||||
|
@ -260,6 +271,9 @@ void Action::resolveMinWidth() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::updateUserpicsFromContent() {
|
void Action::updateUserpicsFromContent() {
|
||||||
|
if (!_appeared) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto users = std::vector<GroupCallUser>();
|
auto users = std::vector<GroupCallUser>();
|
||||||
if (!_content.participants.empty()) {
|
if (!_content.participants.empty()) {
|
||||||
const auto count = std::min(
|
const auto count = std::min(
|
||||||
|
@ -353,11 +367,13 @@ void Action::paint(Painter &p) {
|
||||||
st::defaultWhoRead.itemPadding.top(),
|
st::defaultWhoRead.itemPadding.top(),
|
||||||
_textWidth,
|
_textWidth,
|
||||||
width());
|
width());
|
||||||
_userpics->paint(
|
if (_appeared) {
|
||||||
p,
|
_userpics->paint(
|
||||||
width() - st::defaultWhoRead.itemPadding.right(),
|
p,
|
||||||
(height() - st::defaultWhoRead.userpics.size) / 2,
|
width() - st::defaultWhoRead.itemPadding.right(),
|
||||||
st::defaultWhoRead.userpics.size);
|
(height() - st::defaultWhoRead.userpics.size) / 2,
|
||||||
|
st::defaultWhoRead.userpics.size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Action::refreshText() {
|
void Action::refreshText() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue