diff --git a/Telegram/SourceFiles/settings/settings.style b/Telegram/SourceFiles/settings/settings.style index 9bc7797fd..6d891ded8 100644 --- a/Telegram/SourceFiles/settings/settings.style +++ b/Telegram/SourceFiles/settings/settings.style @@ -174,7 +174,7 @@ settingsTheme: Checkbox(defaultCheckbox) { width: 80px; margin: margins(0px, 0px, 0px, 0px); - textPosition: point(0px, 86px); + textPosition: point(0px, 99px); checkPosition: point(0px, 0px); style: defaultTextStyle; @@ -182,12 +182,12 @@ settingsTheme: Checkbox(defaultCheckbox) { disabledOpacity: 0.5; } -settingsThemePreviewSize: size(80px, 80px); +settingsThemePreviewSize: size(80px, 92px); settingsThemeBubbleSize: size(40px, 14px); settingsThemeBubbleRadius: 2px; settingsThemeBubblePosition: point(6px, 8px); -settingsThemeBubbleSkip: 4px; -settingsThemeRadioBottom: 8px; +settingsThemeBubbleSkip: 6px; +settingsThemeRadioBottom: 12px; settingsThemeMinSkip: 4px; autoDownloadLimitButton: InfoProfileButton(settingsButton) { diff --git a/Telegram/SourceFiles/settings/settings_chat.cpp b/Telegram/SourceFiles/settings/settings_chat.cpp index 31a6c33a3..637e3be58 100644 --- a/Telegram/SourceFiles/settings/settings_chat.cpp +++ b/Telegram/SourceFiles/settings/settings_chat.cpp @@ -1102,37 +1102,29 @@ void SetupDefaultThemes(not_null container) { ) | rpl::start_with_next([buttons = std::move(buttons)](int width) { Expects(!buttons.empty()); - // |------| |---------| |-------| |-------| - // pad | blue | skip | classic | 3*skip | night | skip | night | pad - // |------| |---------| |-------| |-------| const auto padding = st::settingsButton.padding; width -= padding.left() + padding.right(); const auto desired = st::settingsThemePreviewSize.width(); const auto count = int(buttons.size()); - const auto smallSkips = (count / 2); - const auto bigSkips = ((count - 1) / 2); - const auto skipRatio = 3; - const auto skipSegments = smallSkips + bigSkips * skipRatio; + const auto skips = count - 1; const auto minSkip = st::settingsThemeMinSkip; const auto single = [&] { - if (width >= skipSegments * minSkip + count * desired) { + if (width >= skips * minSkip + count * desired) { return desired; } - return (width - skipSegments * minSkip) / count; + return (width - skips * minSkip) / count; }(); if (single <= 0) { return; } const auto fullSkips = width - count * single; - const auto segment = fullSkips / float64(skipSegments); - const auto smallSkip = segment; - const auto bigSkip = segment * skipRatio; + const auto skip = fullSkips / float64(skips); auto left = padding.left() + 0.; auto index = 0; for (const auto button : buttons) { button->resizeToWidth(single); button->moveToLeft(int(std::round(left)), 0); - left += button->width() + ((index++ % 2) ? bigSkip : smallSkip); + left += button->width() + skip; } }, block->lifetime()); @@ -1180,10 +1172,25 @@ void SetupThemeOptions( &controller->window())); }); + AddSkip(container); +} + +void SetupCloudThemes( + not_null controller, + not_null container) { const auto wrap = container->add( object_ptr>( container, object_ptr(container))); + const auto inner = wrap->entity(); + + AddDivider(inner); + AddSkip(inner, st::settingsPrivacySkip); + + AddSubsectionTitle(inner, tr::lng_settings_bg_cloud_themes()); + + AddSkip(inner, st::settingsThemesTopSkip); + const auto list = std::make_shared>(); AddButton( wrap->entity(), @@ -1197,6 +1204,9 @@ void SetupThemeOptions( controller, *list)); }); + + AddSkip(inner, st::settingsThemesTopSkip); + auto shown = rpl::single( rpl::empty_value() ) | rpl::then( @@ -1206,8 +1216,6 @@ void SetupThemeOptions( return !list->empty(); }); wrap->setDuration(0)->toggleOn(std::move(shown)); - - AddSkip(container); } void SetupSupportSwitchSettings( @@ -1331,6 +1339,7 @@ void Chat::setupContent(not_null controller) { const auto content = Ui::CreateChild(this); SetupThemeOptions(controller, content); + SetupCloudThemes(controller, content); SetupChatBackground(controller, content); SetupStickersEmoji(controller, content); SetupMessages(controller, content); diff --git a/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp b/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp index 3048e15ca..1175a8d67 100644 --- a/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp +++ b/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_file_origin.h" #include "data/data_document.h" #include "data/data_session.h" +#include "ui/image/image_prepare.h" #include "lang/lang_keys.h" #include "main/main_session.h" #include "styles/style_settings.h" @@ -121,6 +122,14 @@ void CloudListCheck::setColors(const Colors &colors) { _colors = colors; _radio.setToggledOverride(_colors.radiobuttonActive); _radio.setUntoggledOverride(_colors.radiobuttonInactive); + const auto size = st::settingsThemePreviewSize * cIntRetinaFactor(); + _backgroundFull = (_colors.background.size() == size) + ? _colors.background + : _colors.background.scaled( + size, + Qt::IgnoreAspectRatio, + Qt::SmoothTransformation); + _backgroundCacheWidth = -1; update(); } @@ -128,6 +137,22 @@ QSize CloudListCheck::getSize() const { return st::settingsThemePreviewSize; } +void CloudListCheck::validateBackgroundCache(int width) { + if (_backgroundCacheWidth == width || width <= 0) { + return; + } + _backgroundCacheWidth = width; + const auto imageWidth = width * cIntRetinaFactor(); + _backgroundCache = (width == st::settingsThemePreviewSize.width()) + ? _backgroundFull + : _backgroundFull.copy( + (_backgroundFull.width() - imageWidth) / 2, + 0, + imageWidth, + _backgroundFull.height()); + Images::prepareRound(_backgroundCache, ImageRoundRadius::Large); +} + void CloudListCheck::paint( Painter &p, int left, @@ -150,9 +175,10 @@ void CloudListCheck::paint( PainterHighQualityEnabler hq(p); p.setPen(Qt::NoPen); + validateBackgroundCache(outerWidth); p.drawImage( - QRect(QPoint(), st::settingsThemePreviewSize), - _colors.background); + QRect(0, 0, outerWidth, st::settingsThemePreviewSize.height()), + _backgroundCache); p.setBrush(_colors.received); p.drawRoundedRect(rtlrect(received, outerWidth), radius, radius); diff --git a/Telegram/SourceFiles/window/themes/window_themes_cloud_list.h b/Telegram/SourceFiles/window/themes/window_themes_cloud_list.h index b791e0455..25e33597f 100644 --- a/Telegram/SourceFiles/window/themes/window_themes_cloud_list.h +++ b/Telegram/SourceFiles/window/themes/window_themes_cloud_list.h @@ -55,9 +55,13 @@ public: private: void checkedChangedHook(anim::type animated) override; + void validateBackgroundCache(int width); Colors _colors; Ui::RadioView _radio; + QImage _backgroundFull; + QImage _backgroundCache; + int _backgroundCacheWidth = -1; }; diff --git a/Telegram/SourceFiles/window/themes/window_themes_embedded.cpp b/Telegram/SourceFiles/window/themes/window_themes_embedded.cpp index d4e1cc17c..06341eb2f 100644 --- a/Telegram/SourceFiles/window/themes/window_themes_embedded.cpp +++ b/Telegram/SourceFiles/window/themes/window_themes_embedded.cpp @@ -369,7 +369,7 @@ std::vector EmbeddedThemes() { return { EmbeddedScheme{ EmbeddedType::Default, - qColor("90ce89"), + qColor("9bd494"), qColor("eaffdc"), qColor("ffffff"), qColor("eaffdc"),