Added initial implementation of layer for userpic emoji builder.

This commit is contained in:
23rd 2023-01-24 01:29:42 +03:00 committed by John Preston
parent 177b9140d5
commit 607e79fca0
4 changed files with 94 additions and 0 deletions

View File

@ -9,3 +9,5 @@ using "ui/basic.style";
userpicBuilderEmojiAccentColorSize: 30px;
userpicBuilderEmojiBubblePadding: margins(5px, 5px, 5px, 5px);
userpicBuilderEmojiLayerMinHeight: 496px;

View File

@ -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<Ui::RpWidget*> 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

View File

@ -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<Ui::RpWidget*> 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

View File

@ -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