info_userpic_emoji_builder_layer.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "info/userpic/info_userpic_emoji_builder_layer.h"
  8. #include "styles/style_info.h"
  9. #include "styles/style_info_userpic_builder.h"
  10. #include "styles/style_layers.h"
  11. namespace UserpicBuilder {
  12. LayerWidget::LayerWidget()
  13. : _corners(Ui::PrepareCornerPixmaps(st::boxRadius, st::boxDividerBg)) {
  14. }
  15. void LayerWidget::setContent(not_null<Ui::RpWidget*> content) {
  16. _content = content;
  17. }
  18. void LayerWidget::parentResized() {
  19. Expects(_content != nullptr);
  20. const auto parentSize = parentWidget()->size();
  21. const auto currentHeight = resizeGetHeight(0);
  22. const auto currentWidth = _content->width();
  23. resizeToWidth(currentWidth);
  24. moveToLeft(
  25. (parentSize.width() - currentWidth) / 2,
  26. (parentSize.height() - currentHeight) / 2);
  27. }
  28. bool LayerWidget::closeByOutsideClick() const {
  29. return false;
  30. }
  31. int LayerWidget::resizeGetHeight(int newWidth) {
  32. Expects(_content != nullptr);
  33. _content->resizeToWidth(st::infoDesiredWidth);
  34. return st::userpicBuilderEmojiLayerMinHeight;
  35. }
  36. void LayerWidget::paintEvent(QPaintEvent *e) {
  37. auto p = QPainter(this);
  38. Ui::FillRoundRect(p, rect(), st::boxDividerBg, _corners);
  39. }
  40. } // namespace UserpicBuilder