Make a nice selector for only-recent set.

This commit is contained in:
John Preston 2022-08-23 21:34:51 +03:00
parent 96805b62b2
commit 610c46e26f
7 changed files with 30 additions and 13 deletions

View file

@ -24,6 +24,7 @@ EmojiPan {
iconSkip: pixels;
iconWidth: pixels;
iconArea: pixels;
bg: color;
overBg: color;
fadeLeft: icon;
fadeRight: icon;
@ -198,6 +199,7 @@ defaultEmojiPan: EmojiPan {
iconSkip: 4px;
iconWidth: 35px;
iconArea: 32px;
bg: emojiPanBg;
overBg: emojiPanHover;
fadeLeft: icon {{ "fade_horizontal-flip_horizontal", emojiPanCategories }};
fadeRight: icon {{ "fade_horizontal", emojiPanCategories }};

View file

@ -395,7 +395,9 @@ EmojiListWidget::EmojiListWidget(
, _picker(this)
, _showPickerTimer([=] { showPicker(); }) {
setMouseTracking(true);
setAttribute(Qt::WA_OpaquePaintEvent);
if (st().bg->c.alpha() > 0) {
setAttribute(Qt::WA_OpaquePaintEvent);
}
_customSingleSize = Data::FrameSizeFromTag(
Data::CustomEmojiManager::SizeTag::Large
@ -778,7 +780,9 @@ void EmojiListWidget::paintEvent(QPaintEvent *e) {
_repaintsScheduled.clear();
const auto clip = e ? e->rect() : rect();
p.fillRect(clip, st::emojiPanBg);
if (st().bg->c.alpha() > 0) {
p.fillRect(clip, st().bg);
}
paint(p, {}, clip);
}

View file

@ -181,7 +181,9 @@ int Selector::countWidth(int desiredWidth, int maxWidth) {
(maxWidth - 2 * _skipx) / _size);
_columns = std::min(possibleColumns, max);
_small = (possibleColumns - _columns > 1);
_recentRows = (_strip.count() + _columns - 1) / _columns;
_recentRows = (_reactions.recent.size()
+ (_reactions.morePremiumAvailable ? 1 : 0)
+ _columns - 1) / _columns;
const auto added = (_columns < max || _reactions.customAllowed)
? Strip::AddedButton::Expand
: _reactions.morePremiumAvailable
@ -207,10 +209,11 @@ int Selector::extendTopForCategories() const {
return _reactions.customAllowed ? st::reactPanelEmojiPan.footer : 0;
}
int Selector::desiredHeight() const {
return _reactions.customAllowed
? st::emojiPanMaxHeight
: (_skipy + _recentRows * _size + _skipBottom);
int Selector::minimalHeight() const {
return _skipy
+ (_recentRows * _size)
+ st::roundRadiusSmall
+ st::reactPanelEmojiPan.padding.bottom();
}
void Selector::setSpecialExpandTopSkip(int skip) {
@ -363,7 +366,9 @@ auto Selector::paintExpandingBg(QPainter &p, float64 progress)
const auto frame = int(base::SafeRound(progress * (kFramesCount - 1)));
const auto radiusStart = st::reactStripHeight / 2.;
const auto radiusEnd = st::roundRadiusSmall;
const auto radius = radiusStart + progress * (radiusEnd - radiusStart);
const auto radius = _reactions.customAllowed
? (radiusStart + progress * (radiusEnd - radiusStart))
: radiusStart;
const auto extents = extentsForShadow();
const auto expanding = anim::easeOutCirc(1., progress);
const auto expandUp = anim::interpolate(0, _collapsedTopSkip, expanding);
@ -624,6 +629,9 @@ void Selector::createList(not_null<Window::SessionController*> controller) {
const auto st = lifetime().make_state<style::EmojiPan>(
st::reactPanelEmojiPan);
st->padding.setTop(_skipy);
if (!_reactions.customAllowed) {
st->bg = st::transparent;
}
_list = _scroll->setOwnedWidget(
object_ptr<EmojiListWidget>(_scroll, EmojiListDescriptor{
.session = &controller->session(),
@ -722,9 +730,7 @@ bool AdjustMenuGeometryForSelector(
const auto height = menu->height();
const auto fullTop = extents.top() + categoriesTop + extend.top();
const auto minimalHeight = extents.top()
+ std::min(
selector->desiredHeight(),
categoriesTop + st::emojiPanMinHeight / 2)
+ selector->minimalHeight()
+ extents.bottom();
const auto willBeHeightWithoutBottomPadding = fullTop
+ height

View file

@ -46,7 +46,7 @@ public:
int countWidth(int desiredWidth, int maxWidth);
[[nodiscard]] QMargins extentsForShadow() const;
[[nodiscard]] int extendTopForCategories() const;
[[nodiscard]] int desiredHeight() const;
[[nodiscard]] int minimalHeight() const;
void setSpecialExpandTopSkip(int skip);
void initGeometry(int innerTop);

View file

@ -38,6 +38,7 @@ constexpr auto kHoverScale = 1.24;
.json = media->bytes(),
.sizeOverride = QSize(size, size),
.frame = frame,
.limitFps = true,
});
}

View file

@ -268,6 +268,10 @@ LottieIcon CreateLottieIcon(
not_null<QWidget*> parent,
Lottie::IconDescriptor &&descriptor,
style::margins padding) {
Expects(!descriptor.frame); // I'm not sure it considers limitFps.
descriptor.limitFps = true;
auto object = object_ptr<Ui::RpWidget>(parent);
const auto raw = object.data();

@ -1 +1 @@
Subproject commit f3563bc6b0e042095d4d667d013f62cb8ae62b65
Subproject commit d4764ed8bf0ba2309847bca99f7f8b3d58db25b4