Hide 'Tile' option in generated backgrounds.

This commit is contained in:
John Preston 2021-08-20 15:14:28 +03:00
parent 44f52ca6cd
commit f3f741e1eb

View file

@ -954,13 +954,16 @@ void SetupChatBackground(
AddSkip(container, st::settingsTileSkip); AddSkip(container, st::settingsTileSkip);
const auto background = Window::Theme::Background();
const auto tile = inner->add( const auto tile = inner->add(
object_ptr<Ui::Checkbox>( object_ptr<Ui::SlideWrap<Ui::Checkbox>>(
inner, inner,
tr::lng_settings_bg_tile(tr::now), object_ptr<Ui::Checkbox>(
Window::Theme::Background()->tile(), inner,
st::settingsCheckbox), tr::lng_settings_bg_tile(tr::now),
st::settingsSendTypePadding); background->tile(),
st::settingsCheckbox),
st::settingsSendTypePadding));
const auto adaptive = inner->add( const auto adaptive = inner->add(
object_ptr<Ui::SlideWrap<Ui::Checkbox>>( object_ptr<Ui::SlideWrap<Ui::Checkbox>>(
inner, inner,
@ -971,19 +974,26 @@ void SetupChatBackground(
st::settingsCheckbox), st::settingsCheckbox),
st::settingsSendTypePadding)); st::settingsSendTypePadding));
tile->checkedChanges( tile->entity()->checkedChanges(
) | rpl::start_with_next([](bool checked) { ) | rpl::start_with_next([=](bool checked) {
Window::Theme::Background()->setTile(checked); background->setTile(checked);
}, tile->lifetime()); }, tile->lifetime());
const auto shown = [=] {
return !background->prepared().isNull()
&& !background->colorForFill()
&& background->gradientForFill().isNull();
};
tile->toggle(shown(), anim::type::instant);
using Update = const Window::Theme::BackgroundUpdate; using Update = const Window::Theme::BackgroundUpdate;
Window::Theme::Background()->updates( background->updates(
) | rpl::filter([](const Update &update) { ) | rpl::filter([](const Update &update) {
return (update.type == Update::Type::Changed); return (update.type == Update::Type::Changed)
}) | rpl::map([] { || (update.type == Update::Type::New);
return Window::Theme::Background()->tile(); }) | rpl::start_with_next([=] {
}) | rpl::start_with_next([=](bool tiled) { tile->entity()->setChecked(background->tile());
tile->setChecked(tiled); tile->toggle(shown(), anim::type::instant);
}, tile->lifetime()); }, tile->lifetime());
adaptive->toggleOn(controller->adaptive().chatLayoutValue( adaptive->toggleOn(controller->adaptive().chatLayoutValue(