From 395100584f485b075987def492b299dd86381436 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 18 Nov 2021 21:02:39 +0400 Subject: [PATCH] Add a second dropdown with playback mode controls. --- Telegram/CMakeLists.txt | 2 + .../icons/player/player_repeat_one.png | Bin 0 -> 262 bytes .../icons/player/player_repeat_one@2x.png | Bin 0 -> 304 bytes .../icons/player/player_repeat_one@3x.png | Bin 0 -> 377 bytes .../icons/player/player_repeat_reverse.png | Bin 0 -> 246 bytes .../icons/player/player_repeat_reverse@2x.png | Bin 0 -> 301 bytes .../icons/player/player_repeat_reverse@3x.png | Bin 0 -> 371 bytes .../icons/player/player_repeat_shuffle.png | Bin 0 -> 269 bytes .../icons/player/player_repeat_shuffle@2x.png | Bin 0 -> 290 bytes .../icons/player/player_repeat_shuffle@3x.png | Bin 0 -> 387 bytes .../Resources/icons/player/player_reverse.png | Bin 0 -> 198 bytes .../icons/player/player_reverse@2x.png | Bin 0 -> 212 bytes .../icons/player/player_reverse@3x.png | Bin 0 -> 298 bytes .../Resources/icons/player/player_shuffle.png | Bin 0 -> 346 bytes .../icons/player/player_shuffle@2x.png | Bin 0 -> 537 bytes .../icons/player/player_shuffle@3x.png | Bin 0 -> 761 bytes Telegram/SourceFiles/mainwidget.cpp | 40 ++++++++++++- Telegram/SourceFiles/mainwidget.h | 1 + .../media/player/media_player.style | 36 +++++++++++- .../player/media_player_repeat_controls.cpp | 53 ++++++++++++++++++ .../player/media_player_repeat_controls.h | 22 ++++++++ .../media/player/media_player_widget.cpp | 11 ++++ .../media/player/media_player_widget.h | 3 + 23 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 Telegram/Resources/icons/player/player_repeat_one.png create mode 100644 Telegram/Resources/icons/player/player_repeat_one@2x.png create mode 100644 Telegram/Resources/icons/player/player_repeat_one@3x.png create mode 100644 Telegram/Resources/icons/player/player_repeat_reverse.png create mode 100644 Telegram/Resources/icons/player/player_repeat_reverse@2x.png create mode 100644 Telegram/Resources/icons/player/player_repeat_reverse@3x.png create mode 100644 Telegram/Resources/icons/player/player_repeat_shuffle.png create mode 100644 Telegram/Resources/icons/player/player_repeat_shuffle@2x.png create mode 100644 Telegram/Resources/icons/player/player_repeat_shuffle@3x.png create mode 100644 Telegram/Resources/icons/player/player_reverse.png create mode 100644 Telegram/Resources/icons/player/player_reverse@2x.png create mode 100644 Telegram/Resources/icons/player/player_reverse@3x.png create mode 100644 Telegram/Resources/icons/player/player_shuffle.png create mode 100644 Telegram/Resources/icons/player/player_shuffle@2x.png create mode 100644 Telegram/Resources/icons/player/player_shuffle@3x.png create mode 100644 Telegram/SourceFiles/media/player/media_player_repeat_controls.cpp create mode 100644 Telegram/SourceFiles/media/player/media_player_repeat_controls.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index bfd931857..d0605f9c9 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -813,6 +813,8 @@ PRIVATE media/player/media_player_instance.h media/player/media_player_panel.cpp media/player/media_player_panel.h + media/player/media_player_repeat_controls.cpp + media/player/media_player_repeat_controls.h media/player/media_player_volume_controller.cpp media/player/media_player_volume_controller.h media/player/media_player_widget.cpp diff --git a/Telegram/Resources/icons/player/player_repeat_one.png b/Telegram/Resources/icons/player/player_repeat_one.png new file mode 100644 index 0000000000000000000000000000000000000000..8020d6df31cf78f3e45515d2ca74246ec4b55ba7 GIT binary patch literal 262 zcmeAS@N?(olHy`uVBq!ia0vp@K+MO%1|+}KPrC%9I14-?iy0WWg+Z8+Vb&Z8px_Qq z7sn8diM^A2xmpZ(+~VED(=Jp-uv$%V`!?ay+qqXk2n0Yqb{4ItA?r`^XMrIKlPC@VjAmnnRAvdEsHc> z{FW2EDSf=qrr+E*_*zHwk|{bZ6Y_s?zTf+BZ+)#|OM<5AGvxc6#Y+ zubsMu(J#_|3x|d>DwM_kk7R7i=vmB9^zFbqXs5MnTxI2*_D zlGpybVaizu!JO}IT@0%N^5_xB)4JAL9Jk2>flNnU2td&2swqb~5O6xmgOoT36ax1JHF{aagex6zc`cm@~3ytAuL+0000&}f!M1Jq&DTBh%>jsj-h0FtQOZ!96j;k}oCLV8 zD`Je8=UE@u3-sO>_ff-*XmPeyZT^Y$0x!k&0x!q)0Bg7hDaJW>ZUe2a#>_U`+5;2e zdN-BAF2hM+m*AwZW{tq9z((NIU}tfvuo_PNrT?f9!VzZ$1|Y{-f@L^supMU+1^{Fg z_H$zV{h&6kmL_hW8f&<0YAoRnQ)2~JoEi(b#?;)4tHJIJS%m=rS%m?>O?O)kc@hz)l*lS@A8BST_MViFl1AkhNR1v00000NkvXXu0mjf7TulJ literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/player/player_repeat_reverse.png b/Telegram/Resources/icons/player/player_repeat_reverse.png new file mode 100644 index 0000000000000000000000000000000000000000..6928cf64deca42f1e897d08150df566ff38ef675 GIT binary patch literal 246 zcmeAS@N?(olHy`uVBq!ia0vp@K+MO%1|+}KPrC%9I14-?iy0WWg+Z8+Vb&Z8px_Em z7sn8diM^8!ave6{ah~ta_ji87|NqHVXP2@R8QogAfrFwoD!7Be`oH!2%&fTX0P4KS6u3Sy~g9x zw%o&u+_zmj$0vNovU|?wlE&Sux0dz&+0?F>y>`+P@dLZoZD0BK(8lE*4wnkv$e!NB tkRX-&oxjJHU(nGj^PF5k&CJL>j7PeTX7~BW$^hNW;OXk;vd$@?2>>rDWs(2@ literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/player/player_repeat_reverse@2x.png b/Telegram/Resources/icons/player/player_repeat_reverse@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..6aa3d20bfdedcec0b26fdfa3904c4faf45f37047 GIT binary patch literal 301 zcmeAS@N?(olHy`uVBq!ia0vp^Qa~)j!3HGjh1XvOQk(@Ik;M!Q+`=Ht$S`Y;1W@q4 zr;B5VN9WNgu|mxX0?o~rKTeU;pJ!YfutvxGuV%LK;bw&zsZFyPILuvy7z})a4fS=8 zFP*Z=c9)fhR(HzAX;0tm=Kq)w>mYaJP}G7YIj9m zmmJ!7TeRnS**^^x(Gzkvr0)H`pY;D#V(hhj6}gJxD?e-PYX3KRSLHls1r_`4S^Dd* zpI|&FEU=bUlyBmaEqWr8z7+q;;a(e5zUg>e7-LtH$N~=zh9#|n+>8wmIXOP0aCc=b x3X7JFg_T2*`X#$7fR@fR1*d6x`vw&T38cYLr!?j>F;1OK-EM7_op*o*m z@|Qi2tFRvV;{ZTJKyn*-@_7*{7A^i^&wlZd(Ynsjr^pao4m1x4 zqi`$GT34H}));%{-{-ETid&YYw_}$W(y1#()`u Rp*sKo002ovPDHLkV1h45oEZQB literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/player/player_repeat_shuffle.png b/Telegram/Resources/icons/player/player_repeat_shuffle.png new file mode 100644 index 0000000000000000000000000000000000000000..dcb08429b7f807be4ae6cae2a9462eb3d23264fc GIT binary patch literal 269 zcmeAS@N?(olHy`uVBq!ia0vp@K+MO%1|+}KPrC%9I14-?iy0WWg+Z8+Vb&Z8px}N_ z7sn8diBl&X*<|Z3m8(&a(^wl4B@B%3)QZd8 zP3lqbw0yqZM|xY1yMpKIUH8l$pPCXBJw3=T_SZ3iCJx0vItArZgN_&;HV-@(Iq3_7 zhvwbhSIWC`^|pqo7@q%p{B-So<}H?gQ<)`n`L~AcTKD^H<%NA`?A!c}FP~=naU-q( P=oJP}S3j3^P6D2MG9CjZrg-I%%L0k;cVk(Ci zxF$>PTzp#jUn(=V(JOUX$G*o5u_Eu!%uY<3q+%?bxT@m)_3aLP(vFXIt1d9^u#abZ zrFe1M$GM$0R_>NZ_TMzPuzSJ2808r=&o-yI345r$D7pGIHG->#DM;Me%wO~xzl7HDEtsZf my_q-R{`ZoIDDGEZnKqt1b#?LlXFGuYWAJqKb6Mw<&;$U@>1<#C literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/player/player_repeat_shuffle@3x.png b/Telegram/Resources/icons/player/player_repeat_shuffle@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..5fe95448e4d3c76d4feeec8eb1e8fcaad3eca04b GIT binary patch literal 387 zcmV-}0et?6P)L~~8m}t>@sF&9s%F=#YR{bUxGS&| zhW4tJ=s^caxZxRg23uppaRF3=1zh&}XW&|}^8-xBwP0cArsGO5>$PTUj>O$L{N}p9 z>`HGdxzk3H`;W$b(}3f=k+{;~ZvmT4_%80(G#`iw*WH9? literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/player/player_reverse.png b/Telegram/Resources/icons/player/player_reverse.png new file mode 100644 index 0000000000000000000000000000000000000000..dea0be2df5352d1acdf63a3f443e6232ff7f30d5 GIT binary patch literal 198 zcmeAS@N?(olHy`uVBq!ia0vp@K+MO%1|+}KPrC%9I14-?iy0WWg+Z8+Vb&Z8pkRfk zi(`n!#HW)C`Hm>?upBR}b2$0Go^9?=#%b$2EDoxAUApffqMcpvkd;G$P5J!!Gt+J! zOEl0}`r(L};0|kscYfz8e?IAob&pHI!_y!456!xnnpl7O596-o(R{ZrDYOCIz~JfX=d#Wzp$Py;D@-f^ literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/player/player_reverse@2x.png b/Telegram/Resources/icons/player/player_reverse@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d3af5baf60257095948951257bb026701502a5cf GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^Qa~)j!3HGjh1XvOQk(@Ik;M!Q+`=Ht$S`Y;1W>Te z)5S5wqx0>wgIo-X94_f9zy90j@p}sdtxlcJ`g}$ozpepOMnKkETcwrG-lhK2zi}~K ziCWH<+t(ps6(#zuM8}Oic;!3HD^Y@J>MDb50q$YKTtZeb8+WSBKa0w{RL z)5S3)qV?^~-F(c7JT8I4Pxt5UyQ8Tj)pAfyZt8lMsdwL86w_2|?U_mYWvbU~C& z|BL8dm-_5~`eNaEd<|PqZB)2(aN&WxTRYmjnb>Eaj-4Z((c}2NQ2Rm3(yHdo4c$NA q$gX2wSGHH**3YG*Bc^`OABL-p=F#^%U)KZu$>8bg=d#Wzp$P!J{dKqi literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/player/player_shuffle.png b/Telegram/Resources/icons/player/player_shuffle.png new file mode 100644 index 0000000000000000000000000000000000000000..662958889faad7045dd8bb1f87b9dd59887c0573 GIT binary patch literal 346 zcmV-g0j2(lP)+QZbH$Fc6#tiH?dNxHA%bfV?GN;Vl#hrSVg6$pce!IEOS5awtafApK%4+chzI~6IU@i7RR#I-7j6vLosRCmAqgQMgn$?$ zy!SB1z!-yZ91&wg2w|V}W(a`JIg(`4H0-*LB$*}^ zSyk1WXyZ5#UM?5*eNU3S-EPN6-_KW3mL*k{s!D6^N6}m4ZQCMA5)8wDqA31Ma^Fc+ zxvnd%wVbBu$4*-ivMdV$AkTATS%$9bAR@S4uejguh%url3aBd5G~LJU@ZQrHLt_lb sapWh+md1a0JRV5X6e5DtqT`2s0vXNm;~r$=IRF3v07*qoM6N<$f?ec_)&Kwi literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/player/player_shuffle@2x.png b/Telegram/Resources/icons/player/player_shuffle@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..54d44448fa27691cb47ba88316ef7f598f20cf47 GIT binary patch literal 537 zcmV+!0_OdRP))e&?K?QWz0|CKLc-j6KZ%ObO}3z5x)RDp6h#1lG)-G96NV29JL`3j?ABv*DFbot$ zA%Ma#lzN^({s*b53L=8%c><)WDwwAE)b}=sh_F~JP?n_tI-k$)LSBP{AP^vBSz@_d zP75+k6IE3SpwsCjlywqN7={9*C<+*c0Yy>Z`~Eb|(6)D9hr$ zx~@ahG^A+?V1ff{Sr+QL7EIgi7DR;IZr9D#bq&k1o`M9}!yAbv`KZzed7ejko>QLZ zbUYr%SOj6reRR28z&Ym_TL}WBm5Uq9Xy!v+&ih|A2WG4F-c$*kCXy1Q!GIEbx6F zwOWk{tJP}oeZMf=cs$OB1Aygn$;7Qzt72h!A1eSvQG{l*nSeE$O+-;tEG+FPX*3!L z!;qO^v)LqKZQEwXg<*(Bqaj>4KVa$S++wj{Cb29lj?pxYy9@LAT)3(kuykCtT7~C% zi6qzS6^f#Oh)^n(;5ZHw=6N2f)v6GV153vd5&HdpB9UPj@wMS_$lbMGuP1aKroggs zvMl3pH~;`#*F~jL0TH2Iuj6vLFk$=s9*JhbjrDpR$LYEbKI1b9?GPhXr ze3hgC`MCLf&fPUl)8aVGvY0VnUthvFCXjpglwsR;A_?zH_?hu^-wN=1h}-Q}JTULV z)oR6jOhtBIF)+`9)9IAjx1P`E!f?6!)^~OMPxY-?XCki(pMr@T!mpYFu)l-L-M79A r_jKR-YTU2-)>q;R>04hhMf%o%wds9inqk}V00000NkvXXu0mjfT}ocF literal 0 HcmV?d00001 diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index feeece08c..846dd8a58 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -81,6 +81,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "media/player/media_player_panel.h" #include "media/player/media_player_widget.h" #include "media/player/media_player_dropdown.h" +#include "media/player/media_player_repeat_controls.h" #include "media/player/media_player_volume_controller.h" #include "media/player/media_player_instance.h" #include "media/player/media_player_float.h" @@ -813,6 +814,7 @@ void MainWidget::closeBothPlayers() { _player->hide(anim::type::normal); } _playerVolume.destroyDelayed(); + _playerRepeat.destroyDelayed(); _playerPlaylist->hideIgnoringEnterEvents(); Media::Player::instance()->stop(AudioMsgId::Type::Voice); @@ -849,6 +851,11 @@ void MainWidget::createPlayer() { _playerVolume.data(), _controller); _player->entity()->volumeWidgetCreated(_playerVolume); + _playerRepeat.create(this); + Media::Player::PrepareRepeatDropdown( + _playerRepeat.data(), + _controller); + _player->entity()->repeatWidgetCreated(_playerRepeat); orderWidgets(); if (_a_show.animating()) { _player->show(anim::type::instant); @@ -883,6 +890,7 @@ void MainWidget::playerHeightUpdated() { const auto state = Media::Player::instance()->getState(Media::Player::instance()->getActiveType()); if (!state.id || Media::Player::IsStoppedOrStopping(state.state)) { _playerVolume.destroyDelayed(); + _playerRepeat.destroyDelayed(); _player.destroyDelayed(); } } @@ -1536,6 +1544,10 @@ Window::SectionSlideParams MainWidget::prepareShowAnimation( if (playerVolumeVisible) { _playerVolume->hide(); } + auto playerRepeatVisible = _playerRepeat && !_playerRepeat->isHidden(); + if (playerRepeatVisible) { + _playerRepeat->hide(); + } auto playerPlaylistVisible = !_playerPlaylist->isHidden(); if (playerPlaylistVisible) { _playerPlaylist->hide(); @@ -1563,6 +1575,9 @@ Window::SectionSlideParams MainWidget::prepareShowAnimation( if (playerVolumeVisible) { _playerVolume->show(); } + if (playerRepeatVisible) { + _playerRepeat->show(); + } if (playerPlaylistVisible) { _playerPlaylist->show(); } @@ -1822,6 +1837,9 @@ void MainWidget::orderWidgets() { if (_playerVolume) { _playerVolume->raise(); } + if (_playerRepeat) { + _playerRepeat->raise(); + } _sideShadow->raise(); if (_thirdShadow) { _thirdShadow->raise(); @@ -1855,6 +1873,10 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams ¶m if (playerVolumeVisible) { _playerVolume->hide(); } + auto playerRepeatVisible = _playerRepeat && !_playerRepeat->isHidden(); + if (playerRepeatVisible) { + _playerRepeat->hide(); + } auto playerPlaylistVisible = !_playerPlaylist->isHidden(); if (playerPlaylistVisible) { _playerPlaylist->hide(); @@ -1885,6 +1907,9 @@ QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams ¶m if (playerVolumeVisible) { _playerVolume->show(); } + if (playerRepeatVisible) { + _playerRepeat->show(); + } if (playerPlaylistVisible) { _playerPlaylist->show(); } @@ -2374,11 +2399,19 @@ void MainWidget::updateThirdColumnToCurrentChat( } void MainWidget::updateMediaPlayerPosition() { - if (_player && _playerVolume) { + if (!_player) { + return; + } + if (_playerVolume) { auto relativePosition = _player->entity()->getPositionForVolumeWidget(); auto playerMargins = _playerVolume->getMargin(); _playerVolume->moveToLeft(_player->x() + relativePosition.x() - playerMargins.left(), _player->y() + relativePosition.y() - playerMargins.top()); } + if (_playerRepeat) { + auto relativePosition = _player->entity()->getPositionForRepeatWidget(); + auto playerMargins = _playerRepeat->getMargin(); + _playerRepeat->moveToLeft(_player->x() + relativePosition.x() - playerMargins.left(), _player->y() + relativePosition.y() - playerMargins.top()); + } } void MainWidget::updateMediaPlaylistPosition(int x) { @@ -2529,8 +2562,9 @@ void MainWidget::searchInChat(Dialogs::Key chat) { bool MainWidget::contentOverlapped(const QRect &globalRect) { return (_history->contentOverlapped(globalRect) - || _playerPlaylist->overlaps(globalRect) - || (_playerVolume && _playerVolume->overlaps(globalRect))); + || _playerPlaylist->overlaps(globalRect) + || (_playerVolume && _playerVolume->overlaps(globalRect))) + || (_playerRepeat && _playerRepeat->overlaps(globalRect)); } void MainWidget::activate() { diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index beb97010d..91402ca22 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -368,6 +368,7 @@ private: object_ptr> _player = { nullptr }; object_ptr _playerVolume = { nullptr }; + object_ptr _playerRepeat = { nullptr }; object_ptr _playerPlaylist; bool _playerUsingPanel = false; diff --git a/Telegram/SourceFiles/media/player/media_player.style b/Telegram/SourceFiles/media/player/media_player.style index ab91473f1..22a726790 100644 --- a/Telegram/SourceFiles/media/player/media_player.style +++ b/Telegram/SourceFiles/media/player/media_player.style @@ -67,10 +67,40 @@ mediaPlayerRepeatDisabledIcon: icon { mediaPlayerRepeatDisabledIconOver: icon { { "player/player_repeat", menuIconFgOver, point(9px, 11px)} }; -mediaPlayerRepeatDisabledRippleBg: windowBgOver; -mediaPlayerRepeatInactiveIcon: icon { - { "player/player_repeat", mediaPlayerInactiveFg, point(9px, 11px)} +mediaPlayerRepeatOneIcon: icon { + { "player/player_repeat_one", mediaPlayerActiveFg, point(9px, 11px)} }; +mediaPlayerRepeatOneDisabledIcon: icon { + { "player/player_repeat_one", menuIconFg, point(9px, 11px)} +}; +mediaPlayerRepeatOneDisabledIconOver: icon { + { "player/player_repeat_one", menuIconFgOver, point(9px, 11px)} +}; +mediaPlayerReverseIcon: icon { + { "player/player_reverse", mediaPlayerActiveFg, point(9px, 11px)} +}; +mediaPlayerReverseDisabledIcon: icon { + { "player/player_reverse", menuIconFg, point(9px, 11px)} +}; +mediaPlayerReverseDisabledIconOver: icon { + { "player/player_reverse", menuIconFgOver, point(9px, 11px)} +}; +mediaPlayerShuffleIcon: icon { + { "player/player_shuffle", mediaPlayerActiveFg, point(9px, 11px)} +}; +mediaPlayerShuffleDisabledIcon: icon { + { "player/player_shuffle", menuIconFg, point(9px, 11px)} +}; +mediaPlayerShuffleDisabledIconOver: icon { + { "player/player_shuffle", menuIconFgOver, point(9px, 11px)} +}; +mediaPlayerRepeatReverseIcon: icon { + { "player/player_repeat_reverse", mediaPlayerActiveFg, point(9px, 11px)} +}; +mediaPlayerRepeatShuffleIcon: icon { + { "player/player_repeat_shuffle", mediaPlayerActiveFg, point(9px, 11px)} +}; +mediaPlayerRepeatDisabledRippleBg: windowBgOver; mediaPlayerSpeedButton: IconButton { width: 31px; diff --git a/Telegram/SourceFiles/media/player/media_player_repeat_controls.cpp b/Telegram/SourceFiles/media/player/media_player_repeat_controls.cpp new file mode 100644 index 000000000..fe8bfc882 --- /dev/null +++ b/Telegram/SourceFiles/media/player/media_player_repeat_controls.cpp @@ -0,0 +1,53 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "media/player/media_player_repeat_controls.h" + +#include "media/player/media_player_dropdown.h" +#include "ui/widgets/buttons.h" +#include "styles/style_media_player.h" + +namespace Media::Player { + +void PrepareRepeatDropdown( + not_null dropdown, + not_null controller) { + const auto makeButton = [&] { + const auto result = Ui::CreateChild( + dropdown.get(), + st::mediaPlayerRepeatButton); + result->show(); + return result; + }; + + const auto repeatOne = makeButton(); + const auto repeat = makeButton(); + const auto shuffle = makeButton(); + const auto reverse = makeButton(); + + repeatOne->setIconOverride(&st::mediaPlayerRepeatOneIcon); + shuffle->setIconOverride(&st::mediaPlayerShuffleIcon); + reverse->setIconOverride(&st::mediaPlayerReverseIcon); + + dropdown->sizeValue( + ) | rpl::start_with_next([=](QSize size) { + const auto rect = QRect(QPoint(), size); + const auto inner = rect.marginsRemoved(dropdown->getMargin()); + const auto skip = (inner.height() - repeatOne->height() * 4) / 3; + auto top = 0; + const auto move = [&](auto &widget) { + widget->move((size.width() - widget->width()) / 2, top); + top += widget->height() + skip; + }; + move(repeatOne); + move(repeat); + move(shuffle); + move(reverse); + }, dropdown->lifetime()); +} + +} // namespace Media::Player diff --git a/Telegram/SourceFiles/media/player/media_player_repeat_controls.h b/Telegram/SourceFiles/media/player/media_player_repeat_controls.h new file mode 100644 index 000000000..ae3f31de9 --- /dev/null +++ b/Telegram/SourceFiles/media/player/media_player_repeat_controls.h @@ -0,0 +1,22 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#pragma once + +namespace Window { +class SessionController; +} // namespace Window + +namespace Media::Player { + +class Dropdown; + +void PrepareRepeatDropdown( + not_null dropdown, + not_null controller); + +} // namespace Media::Player diff --git a/Telegram/SourceFiles/media/player/media_player_widget.cpp b/Telegram/SourceFiles/media/player/media_player_widget.cpp index dee206a2b..a28481de8 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.cpp +++ b/Telegram/SourceFiles/media/player/media_player_widget.cpp @@ -398,6 +398,17 @@ void Widget::volumeWidgetCreated(Dropdown *widget) { _volumeToggle->installEventFilter(widget); } +QPoint Widget::getPositionForRepeatWidget() const { + auto x = _repeatToggle->x(); + x += (_repeatToggle->width() - st::mediaPlayerVolumeSize.width()) / 2; + if (rtl()) x = width() - x - st::mediaPlayerVolumeSize.width(); + return QPoint(x, height()); +} + +void Widget::repeatWidgetCreated(Dropdown *widget) { + _repeatToggle->installEventFilter(widget); +} + Widget::~Widget() = default; void Widget::handleSeekProgress(float64 progress) { diff --git a/Telegram/SourceFiles/media/player/media_player_widget.h b/Telegram/SourceFiles/media/player/media_player_widget.h index 0373bec7b..e918835e9 100644 --- a/Telegram/SourceFiles/media/player/media_player_widget.h +++ b/Telegram/SourceFiles/media/player/media_player_widget.h @@ -53,6 +53,9 @@ public: QPoint getPositionForVolumeWidget() const; void volumeWidgetCreated(Dropdown *widget); + QPoint getPositionForRepeatWidget() const; + void repeatWidgetCreated(Dropdown *widget); + ~Widget(); protected: