From 9ecb0c12a0b4ff87202ec977ca1be8e077a07697 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Mon, 9 Mar 2020 00:31:01 +0300 Subject: [PATCH] Userpic corners option --- Telegram/Resources/icons/bubble_tail1.png | Bin 0 -> 1816 bytes Telegram/Resources/icons/bubble_tail1@2x.png | Bin 0 -> 1844 bytes Telegram/Resources/icons/bubble_tail1@3x.png | Bin 0 -> 1856 bytes Telegram/Resources/icons/bubble_tail2.png | Bin 0 -> 1837 bytes Telegram/Resources/icons/bubble_tail2@2x.png | Bin 0 -> 1875 bytes Telegram/Resources/icons/bubble_tail2@3x.png | Bin 0 -> 1910 bytes Telegram/SourceFiles/boxes/peer_list_box.cpp | 23 +++- Telegram/SourceFiles/core/kotato_settings.cpp | 8 ++ Telegram/SourceFiles/data/data_folder.cpp | 24 +++- Telegram/SourceFiles/data/data_peer.cpp | 27 ++++ Telegram/SourceFiles/data/data_peer.h | 10 ++ .../dialogs/dialogs_inner_widget.cpp | 13 +- Telegram/SourceFiles/dialogs/dialogs_row.cpp | 13 +- Telegram/SourceFiles/history/history.style | 18 +++ .../history/view/history_view_message.cpp | 28 ++++- .../history/view/media/history_view_poll.cpp | 23 +++- Telegram/SourceFiles/settings.cpp | 2 + Telegram/SourceFiles/settings.h | 2 + .../SourceFiles/ui/effects/round_checkbox.cpp | 23 +++- Telegram/SourceFiles/ui/empty_userpic.cpp | 115 +++++++++++++++++- Telegram/SourceFiles/ui/empty_userpic.h | 34 ++++++ Telegram/SourceFiles/ui/special_buttons.cpp | 62 ++++++++-- .../SourceFiles/ui/widgets/multi_select.cpp | 37 +++++- 23 files changed, 434 insertions(+), 28 deletions(-) create mode 100644 Telegram/Resources/icons/bubble_tail1.png create mode 100644 Telegram/Resources/icons/bubble_tail1@2x.png create mode 100644 Telegram/Resources/icons/bubble_tail1@3x.png create mode 100644 Telegram/Resources/icons/bubble_tail2.png create mode 100644 Telegram/Resources/icons/bubble_tail2@2x.png create mode 100644 Telegram/Resources/icons/bubble_tail2@3x.png diff --git a/Telegram/Resources/icons/bubble_tail1.png b/Telegram/Resources/icons/bubble_tail1.png new file mode 100644 index 0000000000000000000000000000000000000000..65d577e9541a61caa442c0a16f800b73df524dcb GIT binary patch literal 1816 zcmb_dO>f*p7&cUjLQy4DE(ocTnRY0b z6VX|wIiNM|&ek%g>_}AlL`;(`GXDPcH$zW&WIXUjc$D|VEE${?;{Mt0n4KN5kQ-Z{ z>UWj|2vSi|eVNX)k}M;m<|QyzuT4X*A=Oc2Y%4+iaI~lQWFd5~<0EFdp56^RmhZS> z_=#>~D==|jS`M;&;$mXkdh;_tt>7`)?|=hxYSFUwi0Eva{^&B3Aq$q zj!$!8?u$|$7fkG&fX&+~nw<0sK`U8|rJSz|wYRpc_j;-@q5k26B;#^Xesp1u=+jC> zhK+5EFjUPN<1TS5V!Iz>hhV&djwDaw(`TUe7+b^%iQ_y4g|6YWqOSyVMq*i{6k<+N zIu&M~O%1)xB(j~&s|rn z+3pnyEHyg6$f{g%U<|vAyCDB-C8V=usQ$S24ZPJm+S+K4)gBB+Yv__heT6sozh^}PFlxGwBD>wbJq_YFOp(QGPU z2Q`h?kLPOLd1*Y)udn|#9#id|t5!3g?ZW!og?$#vS-*nKTMgS&10LFQM`Vzy0#215 z?*5^Uv|Gde_IUFa`$juBIM~=cKRg*cs?Dl{8 I?BTcn0)ziB%m4rY literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/bubble_tail1@2x.png b/Telegram/Resources/icons/bubble_tail1@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..ebeca1511c8b6e018059ae7ea40a8baf2b9dba14 GIT binary patch literal 1844 zcmb_dO>f*p7~UdLl|@w#p;E=AmLnmmGVAfTXXw(VyMe6K4N=td zwacBg_9nb9R?nrk;9nh%ufyw|Z0(DpR(p4;dM?zy`~DgLeu#V9<#zWTqFfHh~sZV$*jH_is*Cvp1r>U=02DR<(hSpNK)ZB)Lxaqi>Pa39YJA{0s zS=bB=92lmJOpiL4T9!8Z>0m7v5#4NmI5IhU(@Aal9$CZnxfvQp(erH1oFZOkQWtyYy7qJ6j(r$UX28z=V2HY;UQ zx3Gl~hOC)A>{HvMmU9!^6yqtht3({_pMqLFY*L3%$9xV7RU=r*{ueAbjZ~g6@HtLc zUm983*R@3?X-f@N4u(OUJyFr^(oR~GEakG(ZtCE6BaQ|2ZQmC`$Ptgs06C!}QGlh3 zEG#TP5HNSl`Tn-zyH#?l{nI)ZiUY?ptHflH=>S{k`vhU`1Skw6f|%BXVDU zH5(0MZBiDL@v7XLI<#MGDu{%$F886dc zu)SBS$8LZlB0}UyJ3tY0EW~WikmtL$?O8JL8JT6|P<^R9-ATLUJGdq<`asvK^W z!)rG^xRFSwz0$k%Eq{3D?R$5={@}-_PoFg2TUvVj`__X8M@RpD{K!~dE{^{B>-hNi maZs<dUXFQAm literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/bubble_tail1@3x.png b/Telegram/Resources/icons/bubble_tail1@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..e11ccb08b4c48a9856959adfc7c18f3630853477 GIT binary patch literal 1856 zcmb_d&2QX96n9ZowP_=S;6RZgxvoGU@Xq*icSdzfSf|ZOb%>I!8o0oCJl?f-?Qv~y zb~i`Ffx-dtacRYYORpdfJ#iqYQpH~Y9H@kZIHL#&u8jA?>PK3ls4ICrGyctczxUp6 z-dtZ_yR^9Q(t;#Oi>+06L%dIv&+%u(KmYr)OXVb8eJ7Wslh2pW5$WbvFG|v}FQWEV zvE^OHl*cs^aG%viaVpS~bne0^CA7y1*=L<7ag@Kl|3Q(Xz)`MR9`w>C>qe_P8Qa`h zYtx+`MS*hRynJqig@KqAL>|TcB*!C1nb^f*TrLAeo+lMdI^8;V6RXG=w;<%qICPO(J1n zL{gyDU>VW`7|;rr4zm8lc|ZZ{vzR4CF0fjKO}o6{d6z%NboKcG2O_neSNYhNOB`1& z@?vFMgfUCVzUaI?P8rx>IUi({t!xXLXUk|(+{_p$c-H2;KQGk!oU+_(mW4s`t5>5W z;KTg2`}Q!G6wFa{s6!Qss%dRl$A*S=^L1!o2&Yhw2T?eF2&%WChAoJ-`U6m*nt&AK zf58F8AeB|&k#5@cfX?^3oDRz3&i4mmKdRHfM3ku}L7{5fW~ib7G8IB% zLCx@4XjT5-&LVNRNdM4w$|F~*0+f?+fQZ>tp*HH;HxGx8fr*PT_px3 zs$I7X!`4}&PS8C1N7*;9X^Jj0SKuMp&yq{KBfU;Xo zr3M~W;pE$WomG@`vLxDdIjrspF{y4EmWWhk;vV_)pP!x;chF|bU2Y#=8vOX(;;ww^ z=IGkzIbKtlNbSq( w`qB@t-MN0_mv{GeZ~c4z?)sJCr+1FMdD>jNee;M1& literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/bubble_tail2.png b/Telegram/Resources/icons/bubble_tail2.png new file mode 100644 index 0000000000000000000000000000000000000000..3b661456056c1abdea4bfc9be167dddb6439b60d GIT binary patch literal 1837 zcmb_dL2ukd6m|hsB~>IOB!oCwE{7KIdS>jkcSbc;x|=jBu^~zpC8$#Acs$;IB?|5U*LJyyQFE_Mir~IJsyAa-uK@7X5MGp zTX$AhUR%*LZMD1E*@5Q^a9zIg9NZ7?erv$v#ccEaLes9kTwRy6ufBd20N=#@{c^we z4ihSA@K6P^F-bB&Yue3QlZ=Z4S?Ylt#Hnxm^UJS>9*4fM*X*HQ)|SI~^Ej8g$6I}I zd?09O+msTD~mi(hox@-(|HI= zZk$>pJG_*>K@dSEf~w&@@|aEF|0c2-LUU+Og>f`J10{WgnS)sqJp={SguLWW1&4w~ zDo;4X94CArtt=fF`ZANOtwt&b$H2~>vFPYK|`nk?SCBVjiUWssc!~IlwRQr0IH|?Ye}}D0C}9&osg| z;{vKTt+&Xo{IDL4VtpnH#ziG}-w;)uWoXpX@j3apkmq{+cqqZ>6N*3gUZ|)X^IWbC zAa@thm-RUQ1wVQ+doQrL<5Jg*Z0?z!1Ign-RSqddhyv0gE?q?bDEk(3T!!dEkI%@y zPL3GzbRgjbwTx$v=VI!d6Fn2pqx;CXE7et7@z*ZOzROvkl1Qb~IBsr8F_A66B40Lj+N%6v{JuQrzCib%Lz zEZB(ZR#A4`f^M6Z>%Jr#nqE@1lB%0Xx3Q&R!;nXp0&EHM@pAQ*5f^-wm3EfJSXH~- zZlP-yMAA}q*L79RPz?hC0;T;ZBRv$QhsGAFJf%qxXMu?1+#>PBMpjlp>ClBRo|ui& zQJ5fLYLCRKUeI!v20%t9xOgM!49FQ(d54EQ%2L4U6KvcTnMm8>E~Y2H?;wECHX0L- zUA2Vagd)urHo=WiKz2o^&3??)WuA(Sgz|+=ka;NgCdQS7lT0K{Av)tkEsZ71l}er% zSAJn7h?wZ6hquk)Rg&?tVrYhjG{~CX)EsOYaKEUTSks2khG2o;-vKq6nvRS59XKc% zMl!NDl2Po7BqZQ%5Rw*GmS;#M1W|0s^HActttAcLiY0c*kE1U@mHvVNbiR-{b9r?_&ki#qw zdAesH(}V#|Jd5bY*xGAJ0E>)twp-0rF|cTvF4Z*8My6{~q-&OrJkR0Cb{x~T4a4=B zotN^UI&dvWA#eTB;yB6Q8udDXJSYfEXkO@Lh2|ONOc@OayToH(%%l0;HV317qfk$Kl`iBq0k-v>{waecz??7_2FE>2&TpML1_BlhO0Pt2*?XKs|f z|Ml6&Z_Hfy-HA^>KQ~wV;@ju`e*MJFZ`}9JfAHj)6Ni5~NUINCI%n43?%n!&cJAVj yYk&OGzjAHu=e6G+_;U9A`|-O^9Q*w2$J6QcV;!(p85wkrc#9f literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/bubble_tail2@3x.png b/Telegram/Resources/icons/bubble_tail2@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..aa368174bdb98b8a259854bcfc66bed194caef02 GIT binary patch literal 1910 zcmb_dO>Epm6n0yFvZX~4aEK5G$GIec*W;hH*P|?Hx*NJ%aEOwXk_c27k7w6b)*jb( zvbzyNr~;`KNQjmbM2G`LfS?jcQHuakQ7M;7s3%nQfZ%{Q0XH}xRgCvf{Ygs{v0B^X z@i*^%?|pCPotm3Ha&Z5n`#Fv~SSgq0+4BIq9va%q?mu7t_<8oogyrR!;~sc8z4mbL zZj5l;eP_JtQnF+{3o-Sx$e}jLw)~KxIc{>Q6(YPs65b|tFDM9qe*K-mdrm=E%vrz+ zi^TQH>k(O4pRMBc6>K`f)KmOq3o-*fNf6)i8$k?P1)*aXvT-^s348~VtQ3Ul)FHoQ z&GAJV5k8mIMJ#JM-Y~PWu4<w!4M0WVdq07Bi<}yqFFoD!#oh{n znA`vBxYE7fDK)m(AcGSFg^Hu zlLMAo%NqFDmW%HXT*S%D8VjSBkZsX%wH*>^p2T!D!enNR(Hu*o31KlJD4|i6(nepX zxjtpSSWJa6`SC?BaA-50xM2+`p@b9!1t>rSOf|U*45%vX{{&DW09~j>9k15D1*%km z40AG6!A($BH4aM9e}WwhYc%o^i`ny0ok(F&7x+OYVUady#2hnrYKMho!AcM(D8Qsr zDhMp>tmiop=W;ouszl6b1{QTiQ^h=X6w$P0HgB6qk+uH%62+^jxc&7GTd%1m2Ef)u z)zq*k15Flf+aRKD7^%cWHT%U;a%YWFt90y*9rH9Wpk z2oT}4zzYISl_ieQoA$QJz|JD*nr*s-8NG|#U06(ONfSk6y3Vq-lZuk=#6L!BcV}MH zXZ5(P8n^GL|1};dJuSPXCf!oUe`r5^l@q=Udz?4bz{$moA1Ya$G3*~t*ayZ4o#f3ULIZfJ$vl! zcfQ>G>-F)on?DvOwan3`2>9t4F P&RCh5EuB03(uscokegZ_ literal 0 HcmV?d00001 diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 2ecddf4bc..6434c8c8e 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -546,7 +546,28 @@ void PeerListRow::paintDisabledCheckUserpic( p.setPen(userpicBorderPen); p.setBrush(Qt::NoBrush); - p.drawEllipse(userpicEllipse); + switch (cUserpicCornersType()) { + case 0: + p.drawRoundedRect( + userpicEllipse, + 0, 0); + break; + + case 1: + p.drawRoundedRect( + userpicEllipse, + st::buttonRadius, st::buttonRadius); + break; + + case 2: + p.drawRoundedRect( + userpicEllipse, + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse(userpicEllipse); + } p.setPen(iconBorderPen); p.setBrush(st::contactsPhotoDisabledCheckFg); diff --git a/Telegram/SourceFiles/core/kotato_settings.cpp b/Telegram/SourceFiles/core/kotato_settings.cpp index a750cabcc..292f70f21 100644 --- a/Telegram/SourceFiles/core/kotato_settings.cpp +++ b/Telegram/SourceFiles/core/kotato_settings.cpp @@ -317,6 +317,12 @@ bool Manager::readCustomFile() { SetRecentStickersLimit(v); } }); + + ReadIntOption(settings, "userpic_corner_type", [&](auto v) { + if (v >= 0 || v <= 3) { + cSetUserpicCornersType(v); + } + }); return true; } @@ -358,6 +364,7 @@ void Manager::writeDefaultFile() { settings.insert(qsl("confirm_before_calls"), cConfirmBeforeCall()); settings.insert(qsl("no_taskbar_flash"), cNoTaskbarFlashing()); settings.insert(qsl("recent_stickers_limit"), RecentStickersLimit()); + settings.insert(qsl("userpic_corner_type"), cUserpicCornersType()); auto settingsScales = QJsonArray(); settings.insert(qsl("scales"), settingsScales); @@ -420,6 +427,7 @@ void Manager::writeCurrentSettings() { settings.insert(qsl("confirm_before_calls"), cConfirmBeforeCall()); settings.insert(qsl("no_taskbar_flash"), cNoTaskbarFlashing()); settings.insert(qsl("recent_stickers_limit"), RecentStickersLimit()); + settings.insert(qsl("userpic_corner_type"), cUserpicCornersType()); auto settingsScales = QJsonArray(); auto currentScales = cInterfaceScales(); diff --git a/Telegram/SourceFiles/data/data_folder.cpp b/Telegram/SourceFiles/data/data_folder.cpp index 5229de94b..99175a4c2 100644 --- a/Telegram/SourceFiles/data/data_folder.cpp +++ b/Telegram/SourceFiles/data/data_folder.cpp @@ -248,7 +248,29 @@ void Folder::paintUserpic( p.setBrush(overrideBg ? *overrideBg : st::historyPeerArchiveUserpicBg); { PainterHighQualityEnabler hq(p); - p.drawEllipse(x, y, size, size); + switch (cUserpicCornersType()) { + case 0: + p.drawRoundedRect( + QRect{ x, y, size, size }, + 0, 0); + break; + + case 1: + p.drawRoundedRect( + QRect{ x, y, size, size }, + st::buttonRadius, st::buttonRadius); + break; + + case 2: + p.drawRoundedRect( + QRect{ x, y, size, size }, + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse(x, y, size, size); + } + } if (size == st::dialogsPhotoSize) { const auto rect = QRect{ x, y, size, size }; diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index 1044fcc3c..b0a9c6b4d 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -230,6 +230,25 @@ ImagePtr PeerData::currentUserpic() const { } void PeerData::paintUserpic(Painter &p, int x, int y, int size) const { + switch (cUserpicCornersType()) { + case 0: + paintUserpicSquare(p, x, y, size); + break; + + case 1: + paintUserpicRounded(p, x, y, size); + break; + + case 2: + paintUserpicRoundedLarge(p, x, y, size); + break; + + default: + paintUserpicCircled(p, x, y, size); + } +} + +void PeerData::paintUserpicCircled(Painter &p, int x, int y, int size) const { if (auto userpic = currentUserpic()) { p.drawPixmap(x, y, userpic->pixCircled(userpicOrigin(), size, size)); } else { @@ -237,6 +256,14 @@ void PeerData::paintUserpic(Painter &p, int x, int y, int size) const { } } +void PeerData::paintUserpicRoundedLarge(Painter &p, int x, int y, int size) const { + if (auto userpic = currentUserpic()) { + p.drawPixmap(x, y, userpic->pixRounded(userpicOrigin(), size, size, ImageRoundRadius::Large)); + } else { + _userpicEmpty->paintRoundedLarge(p, x, y, x + size + x, size); + } +} + void PeerData::paintUserpicRounded(Painter &p, int x, int y, int size) const { if (auto userpic = currentUserpic()) { p.drawPixmap(x, y, userpic->pixRounded(userpicOrigin(), size, size, ImageRoundRadius::Small)); diff --git a/Telegram/SourceFiles/data/data_peer.h b/Telegram/SourceFiles/data/data_peer.h index 94328faaf..6ab17e0fb 100644 --- a/Telegram/SourceFiles/data/data_peer.h +++ b/Telegram/SourceFiles/data/data_peer.h @@ -252,6 +252,16 @@ public: int size) const { paintUserpic(p, rtl() ? (w - x - size) : x, y, size); } + void paintUserpicCircled( + Painter &p, + int x, + int y, + int size) const; + void paintUserpicRoundedLarge( + Painter &p, + int x, + int y, + int size) const; void paintUserpicRounded( Painter &p, int x, diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 5175955be..bdafcd740 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -2892,9 +2892,18 @@ void InnerWidget::userOnlineUpdated(const Notify::PeerUpdate &update) { const auto stroke = st::dialogsOnlineBadgeStroke; const auto skip = st::dialogsOnlineBadgeSkip; const auto edge = st::dialogsPadding.x() + DialogsPhotoSize(); + auto onlineTop = edge - size; + auto onlineLeft = edge - size; + if (cUserpicCornersType() == 3) { + onlineTop = onlineTop - skip.x(); + onlineLeft = onlineLeft - skip.y(); + } else { + onlineTop = onlineTop - size; + onlineLeft = onlineLeft - size; + } const auto updateRect = QRect( - edge - skip.x() - size, - edge - skip.y() - size, + onlineTop, + onlineLeft, size, size ).marginsAdded( diff --git a/Telegram/SourceFiles/dialogs/dialogs_row.cpp b/Telegram/SourceFiles/dialogs/dialogs_row.cpp index 6f152b9e2..2abd24270 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_row.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_row.cpp @@ -163,9 +163,18 @@ void BasicRow::PaintOnlineFrame( q.setBrush(data->active ? st::dialogsOnlineBadgeFgActive : st::dialogsOnlineBadgeFg); + auto onlineTop = edge - size; + auto onlineLeft = edge - size; + if (cUserpicCornersType() == 3) { + onlineTop = onlineTop - skip.x(); + onlineLeft = onlineLeft - skip.y(); + } else { + onlineTop = onlineTop - size; + onlineLeft = onlineLeft - size; + } q.drawEllipse(QRectF( - edge - skip.x() - size, - edge - skip.y() - size, + onlineTop, + onlineLeft, size, size ).marginsRemoved({ shrink, shrink, shrink, shrink })); diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index 61657eb39..b0c3140af 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -397,6 +397,24 @@ historyBubbleTailInRightSelected: icon {{ "bubble_tail-flip_horizontal", msgInBg historyBubbleTailOutRight: icon {{ "bubble_tail-flip_horizontal", msgOutBg }}; historyBubbleTailOutRightSelected: icon {{ "bubble_tail-flip_horizontal", msgOutBgSelected }}; +historyBubbleTail1InLeft: icon {{ "bubble_tail1", msgInBg }}; +historyBubbleTail1InLeftSelected: icon {{ "bubble_tail1", msgInBgSelected }}; +historyBubbleTail1OutLeft: icon {{ "bubble_tail1", msgOutBg }}; +historyBubbleTail1OutLeftSelected: icon {{ "bubble_tail1", msgOutBgSelected }}; +historyBubbleTail1InRight: icon {{ "bubble_tail1-flip_horizontal", msgInBg }}; +historyBubbleTail1InRightSelected: icon {{ "bubble_tail1-flip_horizontal", msgInBgSelected }}; +historyBubbleTail1OutRight: icon {{ "bubble_tail1-flip_horizontal", msgOutBg }}; +historyBubbleTail1OutRightSelected: icon {{ "bubble_tail1-flip_horizontal", msgOutBgSelected }}; + +historyBubbleTail2InLeft: icon {{ "bubble_tail2", msgInBg }}; +historyBubbleTail2InLeftSelected: icon {{ "bubble_tail2", msgInBgSelected }}; +historyBubbleTail2OutLeft: icon {{ "bubble_tail2", msgOutBg }}; +historyBubbleTail2OutLeftSelected: icon {{ "bubble_tail2", msgOutBgSelected }}; +historyBubbleTail2InRight: icon {{ "bubble_tail2-flip_horizontal", msgInBg }}; +historyBubbleTail2InRightSelected: icon {{ "bubble_tail2-flip_horizontal", msgInBgSelected }}; +historyBubbleTail2OutRight: icon {{ "bubble_tail2-flip_horizontal", msgOutBg }}; +historyBubbleTail2OutRightSelected: icon {{ "bubble_tail2-flip_horizontal", msgOutBgSelected }}; + historyPeerUserpicFont: semiboldFont; historyStatusFg: windowSubTextFg; diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 65f46b1ce..9a990a2a2 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -137,15 +137,31 @@ void PaintBubble(Painter &p, QRect rect, int outerWidth, bool selected, bool out if (tailSide == RectPart::Right) { parts |= RectPart::BottomLeft; p.fillRect(rect.x() + rect.width() - st::historyMessageRadius, rect.y() + rect.height() - st::historyMessageRadius, st::historyMessageRadius, st::historyMessageRadius, bg); - auto &tail = selected ? st::historyBubbleTailOutRightSelected : st::historyBubbleTailOutRight; - tail.paint(p, rect.x() + rect.width(), rect.y() + rect.height() - tail.height(), outerWidth); - p.fillRect(rect.x() + rect.width() - st::historyMessageRadius, rect.y() + rect.height(), st::historyMessageRadius + tail.width(), st::msgShadow, sh); + if (cUserpicCornersType() != 0) { + auto &tail = (cUserpicCornersType() == 1) + ? (selected ? st::historyBubbleTail1OutRightSelected : st::historyBubbleTail1OutRight) + : (cUserpicCornersType() == 2) + ? (selected ? st::historyBubbleTail2OutRightSelected : st::historyBubbleTail2OutRight) + : (selected ? st::historyBubbleTailOutRightSelected : st::historyBubbleTailOutRight); + tail.paint(p, rect.x() + rect.width(), rect.y() + rect.height() - tail.height(), outerWidth); + p.fillRect(rect.x() + rect.width() - st::historyMessageRadius, rect.y() + rect.height(), st::historyMessageRadius + tail.width(), st::msgShadow, sh); + } else { + p.fillRect(rect.x() + rect.width() - st::historyMessageRadius, rect.y() + rect.height(), st::historyMessageRadius, st::msgShadow, sh); + } } else if (tailSide == RectPart::Left) { parts |= RectPart::BottomRight; p.fillRect(rect.x(), rect.y() + rect.height() - st::historyMessageRadius, st::historyMessageRadius, st::historyMessageRadius, bg); - auto &tail = selected ? (outbg ? st::historyBubbleTailOutLeftSelected : st::historyBubbleTailInLeftSelected) : (outbg ? st::historyBubbleTailOutLeft : st::historyBubbleTailInLeft); - tail.paint(p, rect.x() - tail.width(), rect.y() + rect.height() - tail.height(), outerWidth); - p.fillRect(rect.x() - tail.width(), rect.y() + rect.height(), st::historyMessageRadius + tail.width(), st::msgShadow, sh); + if (cUserpicCornersType() != 0) { + auto &tail = (cUserpicCornersType() == 1) + ? (selected ? (outbg ? st::historyBubbleTail1OutLeftSelected : st::historyBubbleTail1InLeftSelected) : (outbg ? st::historyBubbleTail1OutLeft : st::historyBubbleTail1InLeft)) + : (cUserpicCornersType() == 2) + ? (selected ? (outbg ? st::historyBubbleTail2OutLeftSelected : st::historyBubbleTail2InLeftSelected) : (outbg ? st::historyBubbleTail2OutLeft : st::historyBubbleTail2InLeft)) + : (selected ? (outbg ? st::historyBubbleTailOutLeftSelected : st::historyBubbleTailInLeftSelected) : (outbg ? st::historyBubbleTailOutLeft : st::historyBubbleTailInLeft)); + tail.paint(p, rect.x() - tail.width(), rect.y() + rect.height() - tail.height(), outerWidth); + p.fillRect(rect.x() - tail.width(), rect.y() + rect.height(), st::historyMessageRadius + tail.width(), st::msgShadow, sh); + } else { + p.fillRect(rect.x(), rect.y() + rect.height(), st::historyMessageRadius, st::msgShadow, sh); + } } else { parts |= RectPart::FullBottom; } diff --git a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp index 9bfc98ae5..9a5d63c16 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_poll.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_poll.cpp @@ -794,7 +794,28 @@ void Poll::paintRecentVoters( p.setPen(pen); p.setBrush(Qt::NoBrush); PainterHighQualityEnabler hq(p); - p.drawEllipse(x, y, size, size); + switch (cUserpicCornersType()) { + case 0: + p.drawRoundedRect( + QRect{ x, y, size, size }, + 0, 0); + break; + + case 1: + p.drawRoundedRect( + QRect{ x, y, size, size }, + st::buttonRadius, st::buttonRadius); + break; + + case 2: + p.drawRoundedRect( + QRect{ x, y, size, size }, + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse(x, y, size, size); + } x -= st::historyPollRecentVoterSkip; } } diff --git a/Telegram/SourceFiles/settings.cpp b/Telegram/SourceFiles/settings.cpp index d0efa04e4..6a043a002 100644 --- a/Telegram/SourceFiles/settings.cpp +++ b/Telegram/SourceFiles/settings.cpp @@ -315,3 +315,5 @@ int RecentStickersLimit() { rpl::producer RecentStickersLimitChanges() { return gRecentStickersLimit.changes(); } + +int gUserpicCornersType = 3; diff --git a/Telegram/SourceFiles/settings.h b/Telegram/SourceFiles/settings.h index c47cdc7eb..73a0d3b26 100644 --- a/Telegram/SourceFiles/settings.h +++ b/Telegram/SourceFiles/settings.h @@ -245,3 +245,5 @@ DeclareSetting(bool, NoTaskbarFlashing); void SetRecentStickersLimit(int limit); [[nodiscard]] int RecentStickersLimit(); [[nodiscard]] rpl::producer RecentStickersLimitChanges(); + +DeclareSetting(int, UserpicCornersType); diff --git a/Telegram/SourceFiles/ui/effects/round_checkbox.cpp b/Telegram/SourceFiles/ui/effects/round_checkbox.cpp index fb2b5f6d7..623442fad 100644 --- a/Telegram/SourceFiles/ui/effects/round_checkbox.cpp +++ b/Telegram/SourceFiles/ui/effects/round_checkbox.cpp @@ -428,7 +428,28 @@ void RoundImageCheckbox::paint(Painter &p, int x, int y, int outerWidth) { auto pen = _st.selectFg->p; pen.setWidth(_st.selectWidth); p.setPen(pen); - p.drawEllipse(style::rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth)); + switch (cUserpicCornersType()) { + case 0: + p.drawRoundedRect( + style::rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth), + 0, 0); + break; + + case 1: + p.drawRoundedRect( + style::rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth), + st::buttonRadius, st::buttonRadius); + break; + + case 2: + p.drawRoundedRect( + style::rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth), + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse(style::rtlrect(x, y, _st.imageRadius * 2, _st.imageRadius * 2, outerWidth)); + } p.setOpacity(1.); } diff --git a/Telegram/SourceFiles/ui/empty_userpic.cpp b/Telegram/SourceFiles/ui/empty_userpic.cpp index 634643e66..2bce5892b 100644 --- a/Telegram/SourceFiles/ui/empty_userpic.cpp +++ b/Telegram/SourceFiles/ui/empty_userpic.cpp @@ -142,8 +142,29 @@ void EmptyUserpic::paint( int y, int outerWidth, int size) const { + switch (cUserpicCornersType()) { + case 0: + paintSquare(p, x, y, outerWidth, size); + break; + + case 1: + paintRounded(p, x, y, outerWidth, size); + break; + + case 2: + paintRoundedLarge(p, x, y, outerWidth, size); + break; + + default: + paint(p, x, y, outerWidth, size, [&p, x, y, size] { + p.drawEllipse(x, y, size, size); + }); + } +} + +void EmptyUserpic::paintRoundedLarge(Painter &p, int x, int y, int outerWidth, int size) const { paint(p, x, y, outerWidth, size, [&p, x, y, size] { - p.drawEllipse(x, y, size, size); + p.drawRoundedRect(x, y, size, size, st::dateRadius, st::dateRadius); }); } @@ -165,9 +186,35 @@ void EmptyUserpic::PaintSavedMessages( int y, int outerWidth, int size) { + switch (cUserpicCornersType()) { + case 0: + PaintSavedMessagesSquared(p, x, y, outerWidth, size); + break; + + case 1: + PaintSavedMessagesRounded(p, x, y, outerWidth, size); + break; + + case 2: + PaintSavedMessagesRoundedLarge(p, x, y, outerWidth, size); + break; + + default: + const auto &bg = st::historyPeerSavedMessagesBg; + const auto &fg = st::historyPeerUserpicFg; + PaintSavedMessages(p, x, y, outerWidth, size, bg, fg); + } +} + +void EmptyUserpic::PaintSavedMessagesRoundedLarge( + Painter &p, + int x, + int y, + int outerWidth, + int size) { const auto &bg = st::historyPeerSavedMessagesBg; const auto &fg = st::historyPeerUserpicFg; - PaintSavedMessages(p, x, y, outerWidth, size, bg, fg); + PaintSavedMessagesRoundedLarge(p, x, y, outerWidth, size, bg, fg); } void EmptyUserpic::PaintSavedMessagesRounded( @@ -181,6 +228,17 @@ void EmptyUserpic::PaintSavedMessagesRounded( PaintSavedMessagesRounded(p, x, y, outerWidth, size, bg, fg); } +void EmptyUserpic::PaintSavedMessagesSquared( + Painter &p, + int x, + int y, + int outerWidth, + int size) { + const auto &bg = st::historyPeerSavedMessagesBg; + const auto &fg = st::historyPeerUserpicFg; + PaintSavedMessagesSquared(p, x, y, outerWidth, size, bg, fg); +} + void EmptyUserpic::PaintSavedMessages( Painter &p, int x, @@ -189,12 +247,45 @@ void EmptyUserpic::PaintSavedMessages( int size, const style::color &bg, const style::color &fg) { + switch (cUserpicCornersType()) { + case 0: + PaintSavedMessagesSquared(p, x, y, outerWidth, size, bg, fg); + break; + + case 1: + PaintSavedMessagesRounded(p, x, y, outerWidth, size, bg, fg); + break; + + case 2: + PaintSavedMessagesRoundedLarge(p, x, y, outerWidth, size, bg, fg); + break; + + default: + x = rtl() ? (outerWidth - x - size) : x; + + PainterHighQualityEnabler hq(p); + p.setBrush(bg); + p.setPen(Qt::NoPen); + p.drawEllipse(x, y, size, size); + + PaintSavedMessagesInner(p, x, y, size, bg, fg); + } +} + +void EmptyUserpic::PaintSavedMessagesRoundedLarge( + Painter &p, + int x, + int y, + int outerWidth, + int size, + const style::color &bg, + const style::color &fg) { x = rtl() ? (outerWidth - x - size) : x; PainterHighQualityEnabler hq(p); p.setBrush(bg); p.setPen(Qt::NoPen); - p.drawEllipse(x, y, size, size); + p.drawRoundedRect(x, y, size, size, st::dateRadius, st::dateRadius); PaintSavedMessagesInner(p, x, y, size, bg, fg); } @@ -217,6 +308,24 @@ void EmptyUserpic::PaintSavedMessagesRounded( PaintSavedMessagesInner(p, x, y, size, bg, fg); } +void EmptyUserpic::PaintSavedMessagesSquared( + Painter &p, + int x, + int y, + int outerWidth, + int size, + const style::color &bg, + const style::color &fg) { + x = rtl() ? (outerWidth - x - size) : x; + + PainterHighQualityEnabler hq(p); + p.setBrush(bg); + p.setPen(Qt::NoPen); + p.drawRoundedRect(x, y, size, size, 0, 0); + + PaintSavedMessagesInner(p, x, y, size, bg, fg); +} + QPixmap EmptyUserpic::GenerateSavedMessages(int size) { return Generate(size, [&](Painter &p) { PaintSavedMessages(p, 0, 0, size, size); diff --git a/Telegram/SourceFiles/ui/empty_userpic.h b/Telegram/SourceFiles/ui/empty_userpic.h index e177baf4e..43a89a5b8 100644 --- a/Telegram/SourceFiles/ui/empty_userpic.h +++ b/Telegram/SourceFiles/ui/empty_userpic.h @@ -19,6 +19,12 @@ public: int y, int outerWidth, int size) const; + void paintRoundedLarge( + Painter &p, + int x, + int y, + int outerWidth, + int size) const; void paintRounded( Painter &p, int x, @@ -40,12 +46,24 @@ public: int y, int outerWidth, int size); + static void PaintSavedMessagesRoundedLarge( + Painter &p, + int x, + int y, + int outerWidth, + int size); static void PaintSavedMessagesRounded( Painter &p, int x, int y, int outerWidth, int size); + static void PaintSavedMessagesSquared( + Painter &p, + int x, + int y, + int outerWidth, + int size); static void PaintSavedMessages( Painter &p, int x, @@ -54,6 +72,14 @@ public: int size, const style::color &bg, const style::color &fg); + static void PaintSavedMessagesRoundedLarge( + Painter &p, + int x, + int y, + int outerWidth, + int size, + const style::color &bg, + const style::color &fg); static void PaintSavedMessagesRounded( Painter &p, int x, @@ -62,6 +88,14 @@ public: int size, const style::color &bg, const style::color &fg); + static void PaintSavedMessagesSquared( + Painter &p, + int x, + int y, + int outerWidth, + int size, + const style::color &bg, + const style::color &fg); static QPixmap GenerateSavedMessages(int size); static QPixmap GenerateSavedMessagesRounded(int size); diff --git a/Telegram/SourceFiles/ui/special_buttons.cpp b/Telegram/SourceFiles/ui/special_buttons.cpp index 1b6e84b17..61c8efe53 100644 --- a/Telegram/SourceFiles/ui/special_buttons.cpp +++ b/Telegram/SourceFiles/ui/special_buttons.cpp @@ -682,11 +682,32 @@ void UserpicButton::paintEvent(QPaintEvent *e) { p.setBrush(_userpicHasImage ? st::msgDateImgBg : _st.changeButton.textBgOver); - p.drawEllipse( - photoLeft, - photoTop, - _st.photoSize, - _st.photoSize); + switch (cUserpicCornersType()) { + case 0: + p.drawRoundedRect( + QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize }, + 0, 0); + break; + + case 1: + p.drawRoundedRect( + QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize }, + st::buttonRadius, st::buttonRadius); + break; + + case 2: + p.drawRoundedRect( + QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize }, + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse( + photoLeft, + photoTop, + _st.photoSize, + _st.photoSize); + } } paintRipple( p, @@ -728,11 +749,32 @@ void UserpicButton::paintEvent(QPaintEvent *e) { PainterHighQualityEnabler hq(p); p.setPen(Qt::NoPen); p.setBrush(_st.uploadBg); - p.drawEllipse( - photoLeft, - photoTop, - _st.photoSize, - _st.photoSize); + switch (cUserpicCornersType()) { + case 0: + p.drawRoundedRect( + QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize }, + 0, 0); + break; + + case 1: + p.drawRoundedRect( + QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize }, + st::buttonRadius, st::buttonRadius); + break; + + case 2: + p.drawRoundedRect( + QRect{ photoLeft, photoTop, _st.photoSize, _st.photoSize }, + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse( + photoLeft, + photoTop, + _st.photoSize, + _st.photoSize); + } } auto iconLeft = (_st.uploadIconPosition.x() < 0) ? (_st.photoSize - _st.uploadIcon.width()) / 2 diff --git a/Telegram/SourceFiles/ui/widgets/multi_select.cpp b/Telegram/SourceFiles/ui/widgets/multi_select.cpp index 17ceb2f7c..f85c6b6c4 100644 --- a/Telegram/SourceFiles/ui/widgets/multi_select.cpp +++ b/Telegram/SourceFiles/ui/widgets/multi_select.cpp @@ -72,6 +72,20 @@ void MultiSelect::Item::paintOnce(Painter &p, int x, int y, int outerWidth) { } auto radius = _st.height / 2; + switch (cUserpicCornersType()) { + case 0: + radius = 0; + break; + + case 1: + radius = st::buttonRadius; + break; + + case 2: + radius = st::dateRadius; + break; + } + auto inner = style::rtlrect(x + radius, y, _width - radius, _st.height, outerWidth); auto clipEnabled = p.hasClipping(); @@ -112,7 +126,28 @@ void MultiSelect::Item::paintDeleteButton(Painter &p, int x, int y, int outerWid p.setBrush(_color); { PainterHighQualityEnabler hq(p); - p.drawEllipse(style::rtlrect(x, y, _st.height, _st.height, outerWidth)); + switch (cUserpicCornersType()) { + case 0: + p.drawRoundedRect( + style::rtlrect(x, y, _st.height, _st.height, outerWidth), + 0, 0); + break; + + case 1: + p.drawRoundedRect( + style::rtlrect(x, y, _st.height, _st.height, outerWidth), + st::buttonRadius, st::buttonRadius); + break; + + case 2: + p.drawRoundedRect( + style::rtlrect(x, y, _st.height, _st.height, outerWidth), + st::dateRadius, st::dateRadius); + break; + + default: + p.drawEllipse(style::rtlrect(x, y, _st.height, _st.height, outerWidth)); + } } CrossAnimation::paint(p, _st.deleteCross, _st.deleteFg, x, y, outerWidth, overOpacity);