Added index for spoiler to AbstractBox.
This commit is contained in:
parent
0524252197
commit
e19a4c6544
3 changed files with 52 additions and 23 deletions
|
|
@ -450,13 +450,13 @@ void Parser::createBlock(int32 skipBack) {
|
|||
}
|
||||
_lastSkipped = false;
|
||||
if (_emoji) {
|
||||
_t->_blocks.push_back(Block::Emoji(_t->_st->font, _t->_text, _blockStart, len, _flags, _lnkIndex, _emoji));
|
||||
_t->_blocks.push_back(Block::Emoji(_t->_st->font, _t->_text, _blockStart, len, _flags, _lnkIndex, 0/*spoilerIndex*/, _emoji));
|
||||
_emoji = nullptr;
|
||||
_lastSkipped = true;
|
||||
} else if (newline) {
|
||||
_t->_blocks.push_back(Block::Newline(_t->_st->font, _t->_text, _blockStart, len, _flags, _lnkIndex));
|
||||
_t->_blocks.push_back(Block::Newline(_t->_st->font, _t->_text, _blockStart, len, _flags, _lnkIndex, 0/*spoilerIndex*/));
|
||||
} else {
|
||||
_t->_blocks.push_back(Block::Text(_t->_st->font, _t->_text, _t->_minResizeWidth, _blockStart, len, _flags, _lnkIndex));
|
||||
_t->_blocks.push_back(Block::Text(_t->_st->font, _t->_text, _t->_minResizeWidth, _blockStart, len, _flags, _lnkIndex, 0/*spoilerIndex*/));
|
||||
}
|
||||
_blockStart += len;
|
||||
blockCreated();
|
||||
|
|
@ -466,7 +466,7 @@ void Parser::createBlock(int32 skipBack) {
|
|||
void Parser::createSkipBlock(int32 w, int32 h) {
|
||||
createBlock();
|
||||
_t->_text.push_back('_');
|
||||
_t->_blocks.push_back(Block::Skip(_t->_st->font, _t->_text, _blockStart++, w, h, _lnkIndex));
|
||||
_t->_blocks.push_back(Block::Skip(_t->_st->font, _t->_text, _blockStart++, w, h, _lnkIndex, 0/*spoilerIndex*/));
|
||||
blockCreated();
|
||||
}
|
||||
|
||||
|
|
@ -1843,7 +1843,7 @@ private:
|
|||
_elideSavedIndex = blockIndex;
|
||||
auto mutableText = const_cast<String*>(_t);
|
||||
_elideSavedBlock = std::move(mutableText->_blocks[blockIndex]);
|
||||
mutableText->_blocks[blockIndex] = Block::Text(_t->_st->font, _t->_text, QFIXED_MAX, elideStart, 0, (*_elideSavedBlock)->flags(), (*_elideSavedBlock)->lnkIndex());
|
||||
mutableText->_blocks[blockIndex] = Block::Text(_t->_st->font, _t->_text, QFIXED_MAX, elideStart, 0, (*_elideSavedBlock)->flags(), (*_elideSavedBlock)->lnkIndex(), (*_elideSavedBlock)->spoilerIndex());
|
||||
_blocksSize = blockIndex + 1;
|
||||
_endBlock = (blockIndex + 1 < _t->_blocks.size() ? _t->_blocks[blockIndex + 1].get() : nullptr);
|
||||
}
|
||||
|
|
@ -2889,6 +2889,7 @@ bool String::updateSkipBlock(int width, int height) {
|
|||
_text.size() - 1,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
0));
|
||||
recountNaturalSize(false);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -346,9 +346,11 @@ AbstractBlock::AbstractBlock(
|
|||
uint16 from,
|
||||
uint16 length,
|
||||
uchar flags,
|
||||
uint16 lnkIndex)
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex)
|
||||
: _from(from)
|
||||
, _flags((flags & 0xFF) | ((lnkIndex & 0xFFFF) << 12)) {
|
||||
, _flags((flags & 0xFF) | ((lnkIndex & 0xFFFF) << 12))
|
||||
, _spoilerIndex(spoilerIndex) {
|
||||
}
|
||||
|
||||
uint16 AbstractBlock::from() const {
|
||||
|
|
@ -379,12 +381,20 @@ void AbstractBlock::setLnkIndex(uint16 lnkIndex) {
|
|||
_flags = (_flags & ~(0xFFFF << 12)) | (lnkIndex << 12);
|
||||
}
|
||||
|
||||
uint16 AbstractBlock::spoilerIndex() const {
|
||||
return _spoilerIndex;
|
||||
}
|
||||
|
||||
void AbstractBlock::setSpoilerIndex(uint16 spoilerIndex) {
|
||||
_spoilerIndex = spoilerIndex;
|
||||
}
|
||||
|
||||
TextBlockType AbstractBlock::type() const {
|
||||
return TextBlockType((_flags >> 8) & 0x0F);
|
||||
}
|
||||
|
||||
int32 AbstractBlock::flags() const {
|
||||
return (_flags & 0xFF);
|
||||
return (_flags & 0xFFF);
|
||||
}
|
||||
|
||||
QFixed AbstractBlock::f_rbearing() const {
|
||||
|
|
@ -400,8 +410,9 @@ TextBlock::TextBlock(
|
|||
uint16 from,
|
||||
uint16 length,
|
||||
uchar flags,
|
||||
uint16 lnkIndex)
|
||||
: AbstractBlock(font, str, from, length, flags, lnkIndex) {
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex)
|
||||
: AbstractBlock(font, str, from, length, flags, lnkIndex, spoilerIndex) {
|
||||
_flags |= ((TextBlockTText & 0x0F) << 8);
|
||||
if (length) {
|
||||
style::font blockFont = font;
|
||||
|
|
@ -442,8 +453,9 @@ EmojiBlock::EmojiBlock(
|
|||
uint16 length,
|
||||
uchar flags,
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex,
|
||||
EmojiPtr emoji)
|
||||
: AbstractBlock(font, str, from, length, flags, lnkIndex)
|
||||
: AbstractBlock(font, str, from, length, flags, lnkIndex, spoilerIndex)
|
||||
, _emoji(emoji) {
|
||||
_flags |= ((TextBlockTEmoji & 0x0F) << 8);
|
||||
_width = int(st::emojiSize + 2 * st::emojiPadding);
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@ public:
|
|||
uint16 lnkIndex() const;
|
||||
void setLnkIndex(uint16 lnkIndex);
|
||||
|
||||
uint16 spoilerIndex() const;
|
||||
void setSpoilerIndex(uint16 spoilerIndex);
|
||||
|
||||
TextBlockType type() const;
|
||||
int32 flags() const;
|
||||
|
||||
|
|
@ -56,12 +59,15 @@ protected:
|
|||
uint16 from,
|
||||
uint16 length,
|
||||
uchar flags,
|
||||
uint16 lnkIndex);
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex);
|
||||
|
||||
uint16 _from = 0;
|
||||
|
||||
uint32 _flags = 0; // 4 bits empty, 16 bits lnkIndex, 4 bits type, 8 bits flags
|
||||
|
||||
uint16 _spoilerIndex = 0;
|
||||
|
||||
QFixed _width = 0;
|
||||
|
||||
// Right padding: spaces after the last content of the block (like a word).
|
||||
|
|
@ -81,8 +87,9 @@ public:
|
|||
uint16 from,
|
||||
uint16 length,
|
||||
uchar flags,
|
||||
uint16 lnkIndex)
|
||||
: AbstractBlock(font, str, from, length, flags, lnkIndex) {
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex)
|
||||
: AbstractBlock(font, str, from, length, flags, lnkIndex, spoilerIndex) {
|
||||
_flags |= ((TextBlockTNewline & 0x0F) << 8);
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +149,8 @@ public:
|
|||
uint16 from,
|
||||
uint16 length,
|
||||
uchar flags,
|
||||
uint16 lnkIndex);
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex);
|
||||
|
||||
private:
|
||||
QFixed real_f_rbearing() const {
|
||||
|
|
@ -168,6 +176,7 @@ public:
|
|||
uint16 length,
|
||||
uchar flags,
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex,
|
||||
EmojiPtr emoji);
|
||||
|
||||
private:
|
||||
|
|
@ -187,8 +196,9 @@ public:
|
|||
uint16 from,
|
||||
int32 w,
|
||||
int32 h,
|
||||
uint16 lnkIndex)
|
||||
: AbstractBlock(font, str, from, 1, 0, lnkIndex)
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex)
|
||||
: AbstractBlock(font, str, from, 1, 0, lnkIndex, spoilerIndex)
|
||||
, _height(h) {
|
||||
_flags |= ((TextBlockTSkip & 0x0F) << 8);
|
||||
_width = w;
|
||||
|
|
@ -304,8 +314,9 @@ public:
|
|||
uint16 from,
|
||||
uint16 length,
|
||||
uchar flags,
|
||||
uint16 lnkIndex) {
|
||||
return New<NewlineBlock>(font, str, from, length, flags, lnkIndex);
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex) {
|
||||
return New<NewlineBlock>(font, str, from, length, flags, lnkIndex, spoilerIndex);
|
||||
}
|
||||
|
||||
[[nodiscard]] static Block Text(
|
||||
|
|
@ -315,7 +326,8 @@ public:
|
|||
uint16 from,
|
||||
uint16 length,
|
||||
uchar flags,
|
||||
uint16 lnkIndex) {
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex) {
|
||||
return New<TextBlock>(
|
||||
font,
|
||||
str,
|
||||
|
|
@ -323,7 +335,8 @@ public:
|
|||
from,
|
||||
length,
|
||||
flags,
|
||||
lnkIndex);
|
||||
lnkIndex,
|
||||
spoilerIndex);
|
||||
}
|
||||
|
||||
[[nodiscard]] static Block Emoji(
|
||||
|
|
@ -333,6 +346,7 @@ public:
|
|||
uint16 length,
|
||||
uchar flags,
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex,
|
||||
EmojiPtr emoji) {
|
||||
return New<EmojiBlock>(
|
||||
font,
|
||||
|
|
@ -341,6 +355,7 @@ public:
|
|||
length,
|
||||
flags,
|
||||
lnkIndex,
|
||||
spoilerIndex,
|
||||
emoji);
|
||||
}
|
||||
|
||||
|
|
@ -350,8 +365,9 @@ public:
|
|||
uint16 from,
|
||||
int32 w,
|
||||
int32 h,
|
||||
uint16 lnkIndex) {
|
||||
return New<SkipBlock>(font, str, from, w, h, lnkIndex);
|
||||
uint16 lnkIndex,
|
||||
uint16 spoilerIndex) {
|
||||
return New<SkipBlock>(font, str, from, w, h, lnkIndex, spoilerIndex);
|
||||
}
|
||||
|
||||
template <typename FinalBlock>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue