From b7fc3f67d7dd203586758e7d77db92e7ef1be4b1 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 27 Apr 2021 16:03:36 +0400 Subject: [PATCH] Add toggle video and screen sharing buttons. --- .../Resources/icons/calls/calls_present.png | Bin 0 -> 553 bytes .../icons/calls/calls_present@2x.png | Bin 0 -> 991 bytes .../icons/calls/calls_present@3x.png | Bin 0 -> 1529 bytes Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/calls/calls.style | 109 ++++++++---------- .../calls/group/calls_group_call.cpp | 15 ++- .../calls/group/calls_group_call.h | 2 +- .../calls/group/calls_group_panel.cpp | 99 ++++++++++------ .../calls/group/calls_group_panel.h | 6 +- .../ui/controls/call_mute_button.cpp | 32 ++--- Telegram/lib_ui | 2 +- 11 files changed, 151 insertions(+), 115 deletions(-) create mode 100644 Telegram/Resources/icons/calls/calls_present.png create mode 100644 Telegram/Resources/icons/calls/calls_present@2x.png create mode 100644 Telegram/Resources/icons/calls/calls_present@3x.png diff --git a/Telegram/Resources/icons/calls/calls_present.png b/Telegram/Resources/icons/calls/calls_present.png new file mode 100644 index 0000000000000000000000000000000000000000..5e0ba09504b4b3ad54acb2133b7cc0c134cabedc GIT binary patch literal 553 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjjKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(-uv49!D1}S`GTDlgfY_g||V~7Xu z)ezrRhYSSzMDJw1T-4q5;GXgg=87ec&b6{@9_{76{^*!8hn|ao`L;)*TMm6Us?;|# z^St<}<^!A4rJq0dojha0dracTuNfBd&i@$yNjJrW~0zrQW>`qfIM`$iHxubM)Rin6>di?;Ave);%Xm7lAv zr*?mLQN6;Max#up_xDO$!@kVbS69v9nzij|QRdf|WxM^ixif8Y;ctC9Ayrc5xTDN* zF@C$(M?+q!ZgMMhp7%ULM~rE~&735&*^+nftL?a(C((cWMTu2bnZl%>HR~qsadmi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#5c*=wyn5hJ;TKra-W zec>242JltnwzO}fFE1}#$Fo|7L7TuT{3lXjP{uvFdh$-p6Iuc5;Gl)SRm@;jZF8P* z5Zm0TC?`>FBHJ=t+M5`aS5mb1z)GS=P#XeXugqozHY>2C2i87>egUNB#ecI)t^@!8 N002ovPDHLkV1gy$uE78R literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/calls/calls_present@3x.png b/Telegram/Resources/icons/calls/calls_present@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..ae36d18bda8215391a89748b6d850e1d0df9d7e0 GIT binary patch literal 1529 zcmVPx#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91NT34%1ONa40RR91NB{r;0FW_8?*IS=V@X6oRCodHo7*crK^(y6AeV?x zilU?x;?09cm-47QNb*2<=S5Op{Sk^h;K370q(nk;DaxhfevKrzNMU~8*?zlc_neuX zz0A4HX{Sy*=lh-c?)UpS-I;T^-KM z%+&fhnD}Js>z{*QDQ5!u{QSi2?d>uJCdyYoASNA9ba!`)I-zWK_<+{e*F`U#(m*my z(yW66^8Eaa;8qLT-`@{q!We8z0Z8xh)6)~Gt*s5)aFY%Yfdvm06iCO%$9i@lsY?ln zkhs6UN8}>!^z<|&U{s^h0wMw2-rg#ZE-o(Ac!VDlgj*C~@a5$NEi5dc)zwwyb9i{j zw0d=Qg{rHo(aOpS%FoYdwsWJfZ*2FR-Bxitoa0iS*jNm72%tk8&(Kh zxygC_4zR3*8qnF<8E$NBv;@K=5L{ebjA3qKg<&c;u^U-H6B83SB_+i*95uj_k`nyz z@L&pqrd0b=j*$b@-`_6`j6Sfcswx@-Q<=WMz81FXGGB*OySE+ONn$ zEP4(a85z;e36Th`7ZeoW%gakvC``GDAASenhBnoJNI=)u*El^rT__YaxV*ePd~$L^ zje#drZ3G?-Lo6JRcY1ny(A(P^_#w9BnH7i$=-X}>0UuZC7cWe{BPV)7(J ze@ap)s@VHZEbCMYHG?>KRbsetState(Webrtc::VideoState::Inactive); + } return; } + const auto changing = isScreenSharing(); _videoDeviceId = _videoInputId; if (_videoOutgoing->state() != Webrtc::VideoState::Active) { _videoOutgoing->setState(Webrtc::VideoState::Active); } - _videoCapture->switchToDevice(_videoDeviceId.toStdString()); + if (!_videoCapture) { + return; + } + if (changing) { + _videoCapture->switchToDevice(_videoDeviceId.toStdString()); + } } void GroupCall::switchToScreenSharing(const QString &uniqueId) { diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.h b/Telegram/SourceFiles/calls/group/calls_group_call.h index a6773aa61c..fb5e6cd174 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.h +++ b/Telegram/SourceFiles/calls/group/calls_group_call.h @@ -244,7 +244,7 @@ public: void setCurrentAudioDevice(bool input, const QString &deviceId); void setCurrentVideoDevice(const QString &deviceId); bool isScreenSharing() const; - void switchToCamera(); + void toggleVideo(bool active); void switchToScreenSharing(const QString &uniqueId); void toggleMute(const Group::MuteRequest &data); diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index cb0e2de1dc..09821cce85 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -685,30 +685,47 @@ void Panel::refreshLeftButton() { const auto share = _call->scheduleDate() && _peer->isBroadcast() && _peer->asChannel()->hasUsername(); - if ((share && _share) || (!share && _settings)) { + if ((share && _callShare) || (!share && _settings)) { return; } if (share) { _settings.destroy(); - _share.create(widget(), st::groupCallShare); - _share->setClickedCallback(_shareLinkCallback); - _share->setText(tr::lng_group_call_share_button()); + _callShare.create(widget(), st::groupCallShare); + _callShare->setClickedCallback(_callShareLinkCallback); + _callShare->setText(tr::lng_group_call_share_button()); } else { - _share.destroy(); + _callShare.destroy(); _settings.create(widget(), st::groupCallSettings); _settings->setClickedCallback([=] { - if (_call->isScreenSharing()) { - _call->switchToCamera(); - } else { - Ui::DesktopCapture::ChooseSource(this); - } - //_layerBg->showBox(Box(SettingsBox, _call)); + _layerBg->showBox(Box(SettingsBox, _call)); }); _settings->setText(tr::lng_group_call_settings()); } - const auto raw = _share ? _share.data() : _settings.data(); + const auto raw = _callShare ? _callShare.data() : _settings.data(); raw->show(); raw->setColorOverrides(_mute->colorOverrides()); + + if (!_video) { + _video.create(widget(), st::groupCallVideoSmall); + _video->show(); + _video->setClickedCallback([=] { + const auto sharing = _call->isScreenSharing(); + const auto active = (_call->outgoingVideoTrack()->state() + == Webrtc::VideoState::Active); + _call->toggleVideo(sharing || !active); + }); + _video->setText(tr::lng_group_call_video()); + _video->setColorOverrides(_mute->colorOverrides()); + } + if (!_screenShare) { + _screenShare.create(widget(), st::groupCallScreenShareSmall); + _screenShare->show(); + _screenShare->setClickedCallback([=] { + Ui::DesktopCapture::ChooseSource(this); + }); + _screenShare->setText(tr::lng_group_call_screen_share()); + _screenShare->setColorOverrides(_mute->colorOverrides()); + } } void Panel::initShareAction() { @@ -725,7 +742,7 @@ void Panel::initShareAction() { _peer, showBox, showToast); - _shareLinkCallback = [=, callback = std::move(shareLinkCallback)] { + _callShareLinkCallback = [=, callback = std::move(shareLinkCallback)] { if (_call->lookupReal()) { callback(); } @@ -911,7 +928,7 @@ void Panel::setupMembers() { _members->addMembersRequests( ) | rpl::start_with_next([=] { if (_peer->isBroadcast() && _peer->asChannel()->hasUsername()) { - _shareLinkCallback(); + _callShareLinkCallback(); } else { addMembers(); } @@ -1505,31 +1522,44 @@ bool Panel::updateMode() { } void Panel::updateControlsGeometry() { - if (widget()->size().isEmpty() || (!_settings && !_share)) { + if (widget()->size().isEmpty() || (!_settings && !_callShare)) { return; } if (_videoMode.current()) { _mute->setStyle(st::callMuteButtonSmall); const auto buttonsTop = widget()->height() - - st::groupCallButtonBottomSkip; - const auto muteSize = _mute->innerSize().width(); - const auto fullWidth = muteSize - + 2 * (_settings ? _settings : _share)->width() - + 2 * st::groupCallButtonSkip; - const auto leftButtonLeft = (widget()->width() - fullWidth) / 2; + - st::groupCallButtonBottomSkipSmall; const auto addSkip = st::callMuteButtonSmall.active.outerRadius; - _mute->moveInner({ leftButtonLeft + addSkip, buttonsTop + addSkip }); + const auto muteSize = _mute->innerSize().width() + 2 * addSkip; + const auto skip = (_video ? 1 : 2) * st::groupCallButtonSkipSmall; + const auto fullWidth = muteSize + + (_video ? _video->width() + skip : 0) + + (_screenShare ? _screenShare->width() + skip : 0) + + (_settings ? _settings : _callShare)->width() + skip + + _hangup->width() + skip; + auto left = (widget()->width() - fullWidth) / 2; + _mute->moveInner({ left + addSkip, buttonsTop + addSkip }); + left += muteSize + skip; + if (_video) { + _video->moveToLeft(left, buttonsTop); + left += _video->width() + skip; + } + if (_screenShare) { + _screenShare->moveToLeft(left, buttonsTop); + left += _video->width() + skip; + } if (_settings) { - _settings->moveToLeft( - (widget()->width() - _settings->width()) / 2, - buttonsTop); + _settings->setStyle(st::groupCallSettingsSmall); + _settings->moveToLeft(left, buttonsTop); + left += _settings->width() + skip; } - if (_share) { - _share->moveToLeft( - (widget()->width() - _share->width()) / 2, - buttonsTop); + if (_callShare) { + _callShare->setStyle(st::groupCallShareSmall); + _callShare->moveToLeft(left, buttonsTop); + left += _callShare->width() + skip; } - _hangup->moveToRight(leftButtonLeft, buttonsTop); + _hangup->setStyle(st::groupCallHangupSmall); + _hangup->moveToLeft(left, buttonsTop); } else { _mute->setStyle(st::callMuteButton); const auto muteTop = widget()->height() @@ -1538,16 +1568,19 @@ void Panel::updateControlsGeometry() { - st::groupCallButtonBottomSkip; const auto muteSize = _mute->innerSize().width(); const auto fullWidth = muteSize - + 2 * (_settings ? _settings : _share)->width() + + 2 * (_settings ? _settings : _callShare)->width() + 2 * st::groupCallButtonSkip; _mute->moveInner({ (widget()->width() - muteSize) / 2, muteTop }); const auto leftButtonLeft = (widget()->width() - fullWidth) / 2; if (_settings) { + _settings->setStyle(st::groupCallSettings); _settings->moveToLeft(leftButtonLeft, buttonsTop); } - if (_share) { - _share->moveToLeft(leftButtonLeft, buttonsTop); + if (_callShare) { + _callShare->setStyle(st::groupCallShare); + _callShare->moveToLeft(leftButtonLeft, buttonsTop); } + _hangup->setStyle(st::groupCallHangup); _hangup->moveToRight(leftButtonLeft, buttonsTop); } updateMembersGeometry(); diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.h b/Telegram/SourceFiles/calls/group/calls_group_panel.h index a963fbf62d..c9b5354244 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.h +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.h @@ -147,12 +147,12 @@ private: rpl::variable _videoMode; object_ptr _settings = { nullptr }; - object_ptr _share = { nullptr }; + object_ptr _callShare = { nullptr }; object_ptr _video = { nullptr }; - object_ptr _shareScreen = { nullptr }; + object_ptr _screenShare = { nullptr }; std::unique_ptr _mute; object_ptr _hangup; - Fn _shareLinkCallback; + Fn _callShareLinkCallback; rpl::lifetime _peerLifetime; diff --git a/Telegram/SourceFiles/ui/controls/call_mute_button.cpp b/Telegram/SourceFiles/ui/controls/call_mute_button.cpp index 8a5b6ad0ae..76b1d6b959 100644 --- a/Telegram/SourceFiles/ui/controls/call_mute_button.cpp +++ b/Telegram/SourceFiles/ui/controls/call_mute_button.cpp @@ -175,11 +175,9 @@ public: int additionalHeight, const style::FlatLabel &st = st::defaultFlatLabel); - int height() const; + int contentHeight() const; private: - int realHeight() const; - void setText(const QString &text); const style::FlatLabel &_st; @@ -220,9 +218,9 @@ AnimatedLabel::AnimatedLabel( p.setPen(_st.textFg); p.setTextPalette(_st.palette); - const auto textHeight = height(); - const auto diffHeight = realHeight() - textHeight; - const auto center = (diffHeight) / 2; + const auto textHeight = contentHeight(); + const auto diffHeight = height() - textHeight; + const auto center = diffHeight / 2; p.setOpacity(1. - progress); if (p.opacity()) { @@ -246,14 +244,10 @@ AnimatedLabel::AnimatedLabel( }, lifetime()); } -int AnimatedLabel::height() const { +int AnimatedLabel::contentHeight() const { return _st.style.font->height; } -int AnimatedLabel::realHeight() const { - return RpWidget::height(); -} - void AnimatedLabel::setText(const QString &text) { if (_text.toString() == text) { return; @@ -264,7 +258,9 @@ void AnimatedLabel::setText(const QString &text) { const auto width = std::max( _st.style.font->width(_text.toString()), _st.style.font->width(_previousText.toString())); - resize(width + _additionalHeight, height() + _additionalHeight * 2); + resize( + width + _additionalHeight, + contentHeight() + _additionalHeight * 2); _animation.stop(); _animation.start([=] { update(); }, 0., 1., _duration); @@ -933,25 +929,31 @@ void CallMuteButton::updateLabelsGeometry() { void CallMuteButton::updateLabelGeometry(QRect my, QSize size) { const auto skip = _st->sublabelSkip + _st->labelsSkip; + const auto contentHeight = _label->contentHeight(); + const auto contentTop = my.y() + my.height() - contentHeight - skip; _label->moveToLeft( my.x() + (my.width() - size.width()) / 2 + _labelShakeShift, - my.y() + my.height() - size.height() - skip, + contentTop - (size.height() - contentHeight) / 2, my.width()); } void CallMuteButton::updateCenterLabelGeometry(QRect my, QSize size) { const auto skip = (_st->sublabelSkip / 2) + _st->labelsSkip; + const auto contentHeight = _centerLabel->contentHeight(); + const auto contentTop = my.y() + my.height() - contentHeight - skip; _centerLabel->moveToLeft( my.x() + (my.width() - size.width()) / 2 + _labelShakeShift, - my.y() + my.height() - size.height() - skip, + contentTop - (size.height() - contentHeight) / 2, my.width()); } void CallMuteButton::updateSublabelGeometry(QRect my, QSize size) { const auto skip = _st->labelsSkip; + const auto contentHeight = _sublabel->contentHeight(); + const auto contentTop = my.y() + my.height() - contentHeight - skip; _sublabel->moveToLeft( my.x() + (my.width() - size.width()) / 2 + _labelShakeShift, - my.y() + my.height() - size.height() - skip, + contentTop - (size.height() - contentHeight) / 2, my.width()); } diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 14c67cf724..3c1866f52d 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 14c67cf724a572186455a8c0639f037ae26cc762 +Subproject commit 3c1866f52d88f9430341f9a9f1ed3dbbb3b794ea