diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index f23619866..d4eb5242b 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -28,6 +28,9 @@ "ktg_mac_menu_show": "Show Kotatogram", "ktg_settings_kotato": "Kotatogram Settings", "ktg_settings_chats": "Chats", + "ktg_settings_sticker_height": "Sticker height: {pixels}px", + "ktg_settings_sticker_scale_both": "Apply to sticker width", + "ktg_settings_sticker_scale_both_about": "When enabled, sticker maximum width will be changed along with sticker height.", "ktg_settings_emoji_outline": "Big emoji outline", "ktg_fonts_title": "Fonts", "ktg_settings_fonts": "Change application fonts", diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index d4ed7f6d7..5ce869414 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -643,6 +643,22 @@ HistoryWidget::HistoryWidget( }); }, lifetime()); + ::Kotato::JsonSettings::Events( + "sticker_height" + ) | rpl::start_with_next([=] { + crl::on_main(this, [=] { + updateHistoryGeometry(); + }); + }, lifetime()); + + ::Kotato::JsonSettings::Events( + "sticker_scale_both" + ) | rpl::start_with_next([=] { + crl::on_main(this, [=] { + updateHistoryGeometry(); + }); + }, lifetime()); + session().data().channelDifferenceTooLong( ) | rpl::filter([=](not_null channel) { return _peer == channel.get(); diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp index beee98df1..a0709f0cb 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "history/view/media/history_view_media_unwrapped.h" +#include "kotato/kotato_settings.h" #include "data/data_session.h" #include "history/history.h" #include "history/view/media/history_view_media_common.h" @@ -14,9 +15,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/view/history_view_element.h" #include "history/view/history_view_cursor_state.h" #include "history/view/history_view_reply.h" +#include "history/history.h" #include "history/history_item.h" #include "history/history_item_components.h" #include "lottie/lottie_single_player.h" +#include "data/data_session.h" #include "ui/cached_round_corners.h" #include "ui/chat/chat_style.h" #include "ui/painter.h" @@ -44,6 +47,17 @@ UnwrappedMedia::UnwrappedMedia( std::unique_ptr content) : Media(parent) , _content(std::move(content)) { + ::Kotato::JsonSettings::Events( + "sticker_height" + ) | rpl::start_with_next([=] { + history()->owner().requestItemViewRefresh(_parent->data()); + }, _lifetime); + + ::Kotato::JsonSettings::Events( + "sticker_scale_both" + ) | rpl::start_with_next([=] { + history()->owner().requestItemViewRefresh(_parent->data()); + }, _lifetime); } QSize UnwrappedMedia::countOptimalSize() { @@ -605,7 +619,7 @@ int UnwrappedMedia::calculateFullRight(const QRect &inner) const { const auto rightActionWidth = rightActionSize ? (st::historyFastShareLeft * 2 + rightActionSize->width()) - : 0; + : st::msgMargin.left() + st::msgMargin.right(); auto fullRight = inner.x() + inner.width() + (rightAligned ? 0 : infoWidth); diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h index 0259392d6..f247ed27b 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h +++ b/Telegram/SourceFiles/history/view/media/history_view_media_unwrapped.h @@ -162,6 +162,8 @@ private: int _topAdded = 0; bool _additionalOnTop = false; + rpl::lifetime _lifetime; + }; } // namespace HistoryView diff --git a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp index c8527d999..8ebdb4358 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_sticker.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "history/view/media/history_view_sticker.h" +#include "kotato/kotato_settings.h" #include "boxes/sticker_set_box.h" #include "history/history.h" #include "history/history_item_components.h" @@ -187,8 +188,11 @@ bool Sticker::readyToDrawAnimationFrame() { } QSize Sticker::Size() { - const auto side = std::min(st::maxStickerSize, kMaxSizeFixed); - return { side, side }; + const auto currentStickerHeight = ::Kotato::JsonSettings::GetInt("sticker_height"); + const auto currentScaleBoth = ::Kotato::JsonSettings::GetBool("sticker_scale_both"); + const auto maxHeight = int(st::maxStickerSize / 256.0 * currentStickerHeight); + const auto maxWidth = currentScaleBoth ? maxHeight : st::maxStickerSize; + return { maxWidth, maxHeight }; } QSize Sticker::Size(not_null document) { @@ -209,7 +213,9 @@ QSize Sticker::EmojiEffectSize() { } QSize Sticker::EmojiSize() { - const auto side = std::min(st::maxAnimatedEmojiSize, kMaxEmojiSizeFixed); + const auto currentStickerHeight = ::Kotato::JsonSettings::GetInt("sticker_height"); + const auto maxHeight = int(st::maxStickerSize / 256.0 * currentStickerHeight / 2); + const auto side = std::min(maxHeight, kMaxEmojiSizeFixed); return { side, side }; } diff --git a/Telegram/SourceFiles/kotato/kotato_settings.cpp b/Telegram/SourceFiles/kotato/kotato_settings.cpp index cf239b9f2..1e40a7cd8 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -229,6 +229,13 @@ const std::map> DefinitionMap { { "big_emoji_outline", { .type = SettingType::BoolSetting, .defaultValue = true, }}, + { "sticker_height", { + .type = SettingType::IntSetting, + .defaultValue = 170, + .limitHandler = IntLimit(64, 256, 170), }}, + { "sticker_scale_both", { + .type = SettingType::BoolSetting, + .defaultValue = true, }}, }; using OldOptionKey = QString; diff --git a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp index 7f4ef3ba1..ac6f9be98 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -88,6 +88,53 @@ void SetupKotatoChats( void SetupKotatoMessages(not_null container) { Ui::AddSubsectionTitle(container, rktr("ktg_settings_messages")); + const auto stickerHeightLabel = container->add( + object_ptr( + container, + st::ktgSettingsSliderLabel), + st::groupCallDelayLabelMargin); + const auto stickerHeightSlider = container->add( + object_ptr( + container, + st::defaultContinuousSlider), + st::localStorageLimitMargin); + const auto updateStickerHeightLabel = [=](int value) { + const auto pixels = QString::number(value); + stickerHeightLabel->setText( + ktr("ktg_settings_sticker_height", { "pixels", pixels })); + }; + const auto updateStickerHeight = [=](int value) { + updateStickerHeightLabel(value); + ::Kotato::JsonSettings::Set("sticker_height", value); + ::Kotato::JsonSettings::Write(); + }; + stickerHeightSlider->resize(st::defaultContinuousSlider.seekSize); + stickerHeightSlider->setPseudoDiscrete( + 193, + [](int val) { return val + 64; }, + ::Kotato::JsonSettings::GetInt("sticker_height"), + updateStickerHeight); + updateStickerHeightLabel(::Kotato::JsonSettings::GetInt("sticker_height")); + + container->add( + object_ptr( + container, + ktr("ktg_settings_sticker_scale_both"), + ::Kotato::JsonSettings::GetBool("sticker_scale_both"), + st::settingsCheckbox), + st::settingsCheckboxPadding + )->checkedChanges( + ) | rpl::filter([](bool checked) { + return (checked != ::Kotato::JsonSettings::GetBool("sticker_scale_both")); + }) | rpl::start_with_next([](bool checked) { + ::Kotato::JsonSettings::Set("sticker_scale_both", checked); + ::Kotato::JsonSettings::Write(); + }, container->lifetime()); + + Ui::AddSkip(container); + Ui::AddDividerText(container, rktr("ktg_settings_sticker_scale_both_about")); + Ui::AddSkip(container); + SettingsMenuJsonSwitch(ktg_settings_emoji_outline, big_emoji_outline); Ui::AddSkip(container); diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index 91ba60a37..a6d86de9c 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -183,7 +183,7 @@ mediaInPaletteSelected: TextPalette(defaultTextPalette) { minPhotoSize: 100px; maxMediaSize: 430px; -maxStickerSize: 224px; +maxStickerSize: 256px; maxAnimatedEmojiSize: 112px; maxGifSize: 320px; maxVideoMessageSize: 240px;