Added ability to show or hide spoilers from outside.
This commit is contained in:
parent
db871a87f5
commit
44853e9334
4 changed files with 26 additions and 2 deletions
|
|
@ -30,3 +30,7 @@ crl::time SpoilerClickHandler::startMs() const {
|
|||
void SpoilerClickHandler::setStartMs(crl::time value) {
|
||||
_startMs = value;
|
||||
}
|
||||
|
||||
void SpoilerClickHandler::setShown(bool value) {
|
||||
_shown = value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public:
|
|||
void onClick(ClickContext context) const override;
|
||||
|
||||
[[nodiscard]] bool shown() const;
|
||||
void setShown(bool value);
|
||||
[[nodiscard]] crl::time startMs() const;
|
||||
void setStartMs(crl::time value);
|
||||
|
||||
|
|
|
|||
|
|
@ -3156,14 +3156,29 @@ void String::setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk) {
|
|||
void String::setSpoiler(
|
||||
uint16 lnkIndex,
|
||||
const std::shared_ptr<SpoilerClickHandler> &lnk) {
|
||||
if (!lnkIndex || lnkIndex > _spoilers.size()) return;
|
||||
if (!lnkIndex || lnkIndex > _spoilers.size()) {
|
||||
return;
|
||||
}
|
||||
_spoilers[lnkIndex - 1] = lnk;
|
||||
}
|
||||
|
||||
void String::setSpoilerShown(uint16 lnkIndex, bool shown) {
|
||||
if (!lnkIndex
|
||||
|| (lnkIndex > _spoilers.size())
|
||||
|| !_spoilers[lnkIndex - 1]) {
|
||||
return;
|
||||
}
|
||||
_spoilers[lnkIndex - 1]->setShown(shown);
|
||||
}
|
||||
|
||||
bool String::hasLinks() const {
|
||||
return !_links.isEmpty();
|
||||
}
|
||||
|
||||
int String::spoilersCount() const {
|
||||
return _spoilers.size();
|
||||
}
|
||||
|
||||
bool String::hasSkipBlock() const {
|
||||
return _blocks.empty() ? false : _blocks.back()->type() == TextBlockTSkip;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,11 @@ public:
|
|||
|
||||
void setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk);
|
||||
bool hasLinks() const;
|
||||
void setSpoiler(uint16 lnkIndex, const std::shared_ptr<SpoilerClickHandler> &lnk);
|
||||
void setSpoiler(
|
||||
uint16 lnkIndex,
|
||||
const std::shared_ptr<SpoilerClickHandler> &lnk);
|
||||
void setSpoilerShown(uint16 lnkIndex, bool shown);
|
||||
int spoilersCount() const;
|
||||
|
||||
bool hasSkipBlock() const;
|
||||
bool updateSkipBlock(int width, int height);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue