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