mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix layout with a single available reaction.
This commit is contained in:
parent
0277d765bb
commit
4762c7a4fd
5 changed files with 24 additions and 7 deletions
|
@ -327,6 +327,7 @@ stickersPremiumLock: icon{{ "emoji/premium_lock", premiumButtonFg }};
|
||||||
reactStripExtend: margins(21px, 49px, 39px, 0px);
|
reactStripExtend: margins(21px, 49px, 39px, 0px);
|
||||||
reactStripHeight: 40px;
|
reactStripHeight: 40px;
|
||||||
reactStripSize: 32px;
|
reactStripSize: 32px;
|
||||||
|
reactStripMinWidth: 60px;
|
||||||
reactStripImage: 26px;
|
reactStripImage: 26px;
|
||||||
reactStripSkip: 7px;
|
reactStripSkip: 7px;
|
||||||
reactStripBubble: icon{
|
reactStripBubble: icon{
|
||||||
|
|
|
@ -397,6 +397,10 @@ EmojiListWidget::EmojiListWidget(
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
|
|
||||||
|
_customSingleSize = Data::FrameSizeFromTag(
|
||||||
|
Data::CustomEmojiManager::SizeTag::Large
|
||||||
|
) / style::DevicePixelRatio();
|
||||||
|
|
||||||
_picker->hide();
|
_picker->hide();
|
||||||
|
|
||||||
for (auto i = 1; i != _staticCount; ++i) {
|
for (auto i = 1; i != _staticCount; ++i) {
|
||||||
|
@ -962,6 +966,7 @@ void EmojiListWidget::drawRecent(
|
||||||
position += _innerPosition + _customPosition;
|
position += _innerPosition + _customPosition;
|
||||||
_recent[index].custom->paint(p, {
|
_recent[index].custom->paint(p, {
|
||||||
.preview = st::windowBgRipple->c,
|
.preview = st::windowBgRipple->c,
|
||||||
|
.size = QSize(_customSingleSize, _customSingleSize),
|
||||||
.now = now,
|
.now = now,
|
||||||
.scale = context.progress,
|
.scale = context.progress,
|
||||||
.position = position,
|
.position = position,
|
||||||
|
@ -997,6 +1002,7 @@ void EmojiListWidget::drawCustom(
|
||||||
_custom[set].painted = true;
|
_custom[set].painted = true;
|
||||||
_custom[set].list[index].custom->paint(p, {
|
_custom[set].list[index].custom->paint(p, {
|
||||||
.preview = st::windowBgRipple->c,
|
.preview = st::windowBgRipple->c,
|
||||||
|
.size = QSize(_customSingleSize, _customSingleSize),
|
||||||
.now = now,
|
.now = now,
|
||||||
.scale = context.progress,
|
.scale = context.progress,
|
||||||
.position = position,
|
.position = position,
|
||||||
|
@ -1619,9 +1625,7 @@ std::vector<StickerIcon> EmojiListWidget::fillIcons() {
|
||||||
} else {
|
} else {
|
||||||
result.emplace_back(AllEmojiSectionSetId());
|
result.emplace_back(AllEmojiSectionSetId());
|
||||||
}
|
}
|
||||||
const auto esize = Data::FrameSizeFromTag(
|
const auto esize = _customSingleSize;
|
||||||
Data::CustomEmojiManager::SizeTag::Large
|
|
||||||
) / style::DevicePixelRatio();
|
|
||||||
for (const auto &custom : _custom) {
|
for (const auto &custom : _custom) {
|
||||||
const auto set = custom.set;
|
const auto set = custom.set;
|
||||||
result.emplace_back(set, custom.thumbnailDocument, esize, esize);
|
result.emplace_back(set, custom.thumbnailDocument, esize, esize);
|
||||||
|
|
|
@ -329,6 +329,7 @@ private:
|
||||||
QVector<EmojiPtr> _emoji[kEmojiSectionCount];
|
QVector<EmojiPtr> _emoji[kEmojiSectionCount];
|
||||||
std::vector<CustomSet> _custom;
|
std::vector<CustomSet> _custom;
|
||||||
base::flat_map<DocumentId, CustomEmojiInstance> _customEmoji;
|
base::flat_map<DocumentId, CustomEmojiInstance> _customEmoji;
|
||||||
|
int _customSingleSize = 0;
|
||||||
bool _allowWithoutPremium = false;
|
bool _allowWithoutPremium = false;
|
||||||
Ui::RoundRect _overBg;
|
Ui::RoundRect _overBg;
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ Selector::Selector(
|
||||||
, _parentController(parentController.get())
|
, _parentController(parentController.get())
|
||||||
, _reactions(std::move(reactions))
|
, _reactions(std::move(reactions))
|
||||||
, _cachedRound(
|
, _cachedRound(
|
||||||
QSize(st::reactStripSkip * 2 + st::reactStripSize, st::reactStripHeight),
|
QSize(2 * st::reactStripSkip + st::reactStripSize, st::reactStripHeight),
|
||||||
st::reactionCornerShadow,
|
st::reactionCornerShadow,
|
||||||
st::reactStripHeight)
|
st::reactStripHeight)
|
||||||
, _strip(
|
, _strip(
|
||||||
|
@ -94,12 +94,22 @@ Selector::Selector(
|
||||||
crl::guard(this, [=] { update(_inner); }),
|
crl::guard(this, [=] { update(_inner); }),
|
||||||
std::move(iconFactory))
|
std::move(iconFactory))
|
||||||
, _size(st::reactStripSize)
|
, _size(st::reactStripSize)
|
||||||
, _skipx(st::reactStripSkip)
|
, _skipx(countSkipLeft())
|
||||||
, _skipy((st::reactStripHeight - st::reactStripSize) / 2)
|
, _skipy((st::reactStripHeight - st::reactStripSize) / 2)
|
||||||
, _skipBottom(st::reactStripHeight - st::reactStripSize - _skipy) {
|
, _skipBottom(st::reactStripHeight - st::reactStripSize - _skipy) {
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Selector::countSkipLeft() const {
|
||||||
|
const auto addedToMax = _reactions.customAllowed
|
||||||
|
|| _reactions.morePremiumAvailable;
|
||||||
|
const auto max = int(_reactions.recent.size()) + (addedToMax ? 1 : 0);
|
||||||
|
const auto width = max * _size;
|
||||||
|
return std::max(
|
||||||
|
(st::reactStripMinWidth - (max * _size)) / 2,
|
||||||
|
st::reactStripSkip);
|
||||||
|
}
|
||||||
|
|
||||||
int Selector::countWidth(int desiredWidth, int maxWidth) {
|
int Selector::countWidth(int desiredWidth, int maxWidth) {
|
||||||
const auto addedToMax = _reactions.customAllowed
|
const auto addedToMax = _reactions.customAllowed
|
||||||
|| _reactions.morePremiumAvailable;
|
|| _reactions.morePremiumAvailable;
|
||||||
|
@ -267,7 +277,6 @@ void Selector::paintExpanding(Painter &p, float64 progress) {
|
||||||
const auto rects = paintExpandingBg(p, progress);
|
const auto rects = paintExpandingBg(p, progress);
|
||||||
//paintStripWithoutExpand(p);
|
//paintStripWithoutExpand(p);
|
||||||
progress /= kFullDuration;
|
progress /= kFullDuration;
|
||||||
paintFadingExpandIcon(p, progress);
|
|
||||||
if (_footer) {
|
if (_footer) {
|
||||||
_footer->paintExpanding(
|
_footer->paintExpanding(
|
||||||
p,
|
p,
|
||||||
|
@ -281,6 +290,7 @@ void Selector::paintExpanding(Painter &p, float64 progress) {
|
||||||
rects.finalBottom,
|
rects.finalBottom,
|
||||||
progress,
|
progress,
|
||||||
RectPart::TopRight);
|
RectPart::TopRight);
|
||||||
|
paintFadingExpandIcon(p, progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Selector::paintExpandingBg(QPainter &p, float64 progress)
|
auto Selector::paintExpandingBg(QPainter &p, float64 progress)
|
||||||
|
@ -409,7 +419,7 @@ void Selector::mouseMoveEvent(QMouseEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Selector::lookupSelectedIndex(QPoint position) const {
|
int Selector::lookupSelectedIndex(QPoint position) const {
|
||||||
const auto p = position - _inner.topLeft();
|
const auto p = position - _inner.topLeft() - QPoint(_skipx, _skipy);
|
||||||
const auto max = _strip.count();
|
const auto max = _strip.count();
|
||||||
const auto index = p.x() / _size;
|
const auto index = p.x() / _size;
|
||||||
if (p.x() >= 0 && p.y() >= 0 && p.y() < _inner.height() && index < max) {
|
if (p.x() >= 0 && p.y() >= 0 && p.y() < _inner.height() && index < max) {
|
||||||
|
|
|
@ -89,6 +89,7 @@ private:
|
||||||
void paintBubble(QPainter &p, int innerWidth);
|
void paintBubble(QPainter &p, int innerWidth);
|
||||||
void paintBackgroundToBuffer();
|
void paintBackgroundToBuffer();
|
||||||
|
|
||||||
|
[[nodiscard]] int countSkipLeft() const;
|
||||||
[[nodiscard]] int lookupSelectedIndex(QPoint position) const;
|
[[nodiscard]] int lookupSelectedIndex(QPoint position) const;
|
||||||
void setSelected(int index);
|
void setSelected(int index);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue