mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Fix call bar appearance in a new MainWidget.
This commit is contained in:
parent
dcb1315d53
commit
5154fe0044
2 changed files with 20 additions and 5 deletions
|
@ -275,6 +275,14 @@ TopBar::TopBar(
|
|||
, _updateDurationTimer([=] { updateDurationText(); }) {
|
||||
initControls();
|
||||
resize(width(), st::callBarHeight);
|
||||
setupInitialBrush();
|
||||
}
|
||||
|
||||
void TopBar::setupInitialBrush() {
|
||||
Expects(_switchStateCallback != nullptr);
|
||||
|
||||
_switchStateAnimation.stop();
|
||||
_switchStateCallback(1.);
|
||||
}
|
||||
|
||||
void TopBar::initControls() {
|
||||
|
@ -316,14 +324,16 @@ void TopBar::initControls() {
|
|||
| MapPushToTalkToActive()
|
||||
| rpl::distinct_until_changed()
|
||||
| rpl::type_erased()),
|
||||
_groupCall->instanceStateValue(),
|
||||
rpl::single(
|
||||
_groupCall->instanceState()
|
||||
) | rpl::then(_groupCall->instanceStateValue() | rpl::filter(
|
||||
_1 != GroupCall::InstanceState::TransitionToRtc)),
|
||||
rpl::single(
|
||||
_groupCall->scheduleDate()
|
||||
) | rpl::then(_groupCall->real(
|
||||
) | rpl::map([](not_null<Data::GroupCall*> call) {
|
||||
return call->scheduleDateValue();
|
||||
}) | rpl::flatten_latest())
|
||||
) | rpl::filter(_2 != GroupCall::InstanceState::TransitionToRtc);
|
||||
}) | rpl::flatten_latest()));
|
||||
std::move(
|
||||
muted
|
||||
) | rpl::map(
|
||||
|
@ -350,7 +360,7 @@ void TopBar::initControls() {
|
|||
const auto crossFrom = (fromMuted != BarState::Active) ? 1. : 0.;
|
||||
const auto crossTo = (toMuted != BarState::Active) ? 1. : 0.;
|
||||
|
||||
auto animationCallback = [=](float64 value) {
|
||||
_switchStateCallback = [=](float64 value) {
|
||||
if (_groupCall) {
|
||||
_groupBrush = QBrush(
|
||||
_gradients.gradient(fromMuted, toMuted, value));
|
||||
|
@ -366,7 +376,7 @@ void TopBar::initControls() {
|
|||
_switchStateAnimation.stop();
|
||||
const auto duration = (to - from) * kSwitchStateDuration;
|
||||
_switchStateAnimation.start(
|
||||
std::move(animationCallback),
|
||||
_switchStateCallback,
|
||||
from,
|
||||
to,
|
||||
duration);
|
||||
|
@ -748,6 +758,9 @@ void TopBar::updateControlsGeometry() {
|
|||
_gradients.set_points(
|
||||
QPointF(0, st::callBarHeight / 2),
|
||||
QPointF(width(), st::callBarHeight / 2));
|
||||
if (!_switchStateAnimation.animating()) {
|
||||
_switchStateCallback(1.);
|
||||
}
|
||||
}
|
||||
|
||||
void TopBar::paintEvent(QPaintEvent *e) {
|
||||
|
|
|
@ -68,6 +68,7 @@ private:
|
|||
const base::weak_ptr<GroupCall> &groupCall);
|
||||
|
||||
void initControls();
|
||||
void setupInitialBrush();
|
||||
void updateInfoLabels();
|
||||
void setInfoLabels();
|
||||
void updateDurationText();
|
||||
|
@ -101,6 +102,7 @@ private:
|
|||
QBrush _groupBrush;
|
||||
anim::linear_gradients<BarState> _gradients;
|
||||
Ui::Animations::Simple _switchStateAnimation;
|
||||
Fn<void(float64)> _switchStateCallback;
|
||||
|
||||
base::Timer _updateDurationTimer;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue