diff --git a/Telegram/SourceFiles/info/userpic/info_userpic_builder.style b/Telegram/SourceFiles/info/userpic/info_userpic_builder.style index 0dee1aefeb..c83dbb8293 100644 --- a/Telegram/SourceFiles/info/userpic/info_userpic_builder.style +++ b/Telegram/SourceFiles/info/userpic/info_userpic_builder.style @@ -9,3 +9,5 @@ using "ui/basic.style"; userpicBuilderEmojiAccentColorSize: 30px; userpicBuilderEmojiBubblePadding: margins(5px, 5px, 5px, 5px); + +userpicBuilderEmojiLayerMinHeight: 496px; diff --git a/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.cpp b/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.cpp new file mode 100644 index 0000000000..c251c7b66f --- /dev/null +++ b/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.cpp @@ -0,0 +1,51 @@ +/* +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 "info/userpic/info_userpic_emoji_builder_layer.h" + +#include "styles/style_info.h" +#include "styles/style_info_userpic_builder.h" +#include "styles/style_layers.h" + +namespace UserpicBuilder { + +LayerWidget::LayerWidget() +: _corners(Ui::PrepareCornerPixmaps(st::boxRadius, st::boxDividerBg)) { +} + +void LayerWidget::setContent(not_null content) { + _content = content; +} + +void LayerWidget::parentResized() { + Expects(_content != nullptr); + const auto parentSize = parentWidget()->size(); + const auto currentHeight = resizeGetHeight(0); + const auto currentWidth = _content->width(); + resizeToWidth(currentWidth); + moveToLeft( + (parentSize.width() - currentWidth) / 2, + (parentSize.height() - currentHeight) / 2); +} + +bool LayerWidget::closeByOutsideClick() const { + return false; +} + +int LayerWidget::resizeGetHeight(int newWidth) { + Expects(_content != nullptr); + _content->resizeToWidth(st::infoDesiredWidth); + return st::userpicBuilderEmojiLayerMinHeight; +} + +void LayerWidget::paintEvent(QPaintEvent *e) { + auto p = QPainter(this); + + Ui::FillRoundRect(p, rect(), st::boxDividerBg, _corners); +} + +} // namespace UserpicBuilder diff --git a/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.h b/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.h new file mode 100644 index 0000000000..8889982517 --- /dev/null +++ b/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_layer.h @@ -0,0 +1,39 @@ +/* +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 + +#include "ui/layers/layer_widget.h" + +#include "ui/cached_round_corners.h" + +namespace Ui { +class RpWidget; +} // namespace Ui + +namespace UserpicBuilder { + +class LayerWidget : public Ui::LayerWidget { +public: + LayerWidget(); + + void setContent(not_null content); + + void parentResized() override; + bool closeByOutsideClick() const override; + +protected: + int resizeGetHeight(int newWidth) override; + void paintEvent(QPaintEvent *e) override; + +private: + const Ui::CornersPixmaps _corners; + Ui::RpWidget *_content; + +}; + +} // namespace UserpicBuilder diff --git a/Telegram/cmake/td_ui.cmake b/Telegram/cmake/td_ui.cmake index d216583544..80a716fe7a 100644 --- a/Telegram/cmake/td_ui.cmake +++ b/Telegram/cmake/td_ui.cmake @@ -99,6 +99,8 @@ PRIVATE info/userpic/info_userpic_bubble_wrap.h info/userpic/info_userpic_colors_palette_chooser.cpp info/userpic/info_userpic_colors_palette_chooser.h + info/userpic/info_userpic_emoji_builder_layer.cpp + info/userpic/info_userpic_emoji_builder_layer.h layout/abstract_layout_item.cpp layout/abstract_layout_item.h