mirror of https://github.com/procxx/kepka.git
Fix visual glitches in bubble shaking.
This commit is contained in:
parent
04cfd598e2
commit
66e3b529b7
|
@ -1707,7 +1707,9 @@ void InnerWidget::repaintItem(const Element *view) {
|
||||||
if (!view) {
|
if (!view) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
update(0, itemTop(view), width(), view->height());
|
const auto top = itemTop(view);
|
||||||
|
const auto range = view->verticalRepaintRange();
|
||||||
|
update(0, top + range.top, width(), range.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::resizeItem(not_null<Element*> view) {
|
void InnerWidget::resizeItem(not_null<Element*> view) {
|
||||||
|
|
|
@ -242,7 +242,8 @@ void HistoryInner::repaintItem(const Element *view) {
|
||||||
}
|
}
|
||||||
const auto top = itemTop(view);
|
const auto top = itemTop(view);
|
||||||
if (top >= 0) {
|
if (top >= 0) {
|
||||||
update(0, top, width(), view->height());
|
const auto range = view->verticalRepaintRange();
|
||||||
|
update(0, top + range.top, width(), range.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -601,6 +601,13 @@ bool Element::hasVisibleText() const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto Element::verticalRepaintRange() const -> VerticalRepaintRange {
|
||||||
|
return {
|
||||||
|
.top = 0,
|
||||||
|
.height = height()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void Element::unloadHeavyPart() {
|
void Element::unloadHeavyPart() {
|
||||||
if (_media) {
|
if (_media) {
|
||||||
_media->unloadHeavyPart();
|
_media->unloadHeavyPart();
|
||||||
|
|
|
@ -263,6 +263,12 @@ public:
|
||||||
virtual TimeId displayedEditDate() const;
|
virtual TimeId displayedEditDate() const;
|
||||||
virtual bool hasVisibleText() const;
|
virtual bool hasVisibleText() const;
|
||||||
|
|
||||||
|
struct VerticalRepaintRange {
|
||||||
|
int top = 0;
|
||||||
|
int height = 0;
|
||||||
|
};
|
||||||
|
[[nodiscard]] virtual VerticalRepaintRange verticalRepaintRange() const;
|
||||||
|
|
||||||
virtual void unloadHeavyPart();
|
virtual void unloadHeavyPart();
|
||||||
|
|
||||||
// Legacy blocks structure.
|
// Legacy blocks structure.
|
||||||
|
|
|
@ -2398,7 +2398,9 @@ void ListWidget::repaintItem(const Element *view) {
|
||||||
if (!view) {
|
if (!view) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
update(0, itemTop(view), width(), view->height());
|
const auto top = itemTop(view);
|
||||||
|
const auto range = view->verticalRepaintRange();
|
||||||
|
update(0, top + range.top, width(), range.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListWidget::repaintItem(FullMsgId itemId) {
|
void ListWidget::repaintItem(FullMsgId itemId) {
|
||||||
|
|
|
@ -409,7 +409,7 @@ void Message::draw(
|
||||||
|
|
||||||
paintHighlight(p, g.height());
|
paintHighlight(p, g.height());
|
||||||
|
|
||||||
const auto roll = media ? media->getBubbleRoll() : Media::BubbleRoll();
|
const auto roll = media ? media->bubbleRoll() : Media::BubbleRoll();
|
||||||
if (roll) {
|
if (roll) {
|
||||||
p.save();
|
p.save();
|
||||||
p.translate(g.center());
|
p.translate(g.center());
|
||||||
|
@ -1293,6 +1293,15 @@ int Message::infoWidth() const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto Message::verticalRepaintRange() const -> VerticalRepaintRange {
|
||||||
|
const auto media = this->media();
|
||||||
|
const auto add = media ? media->bubbleRollRepaintMargins() : QMargins();
|
||||||
|
return {
|
||||||
|
.top = -add.top(),
|
||||||
|
.height = height() + add.top() + add.bottom()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
void Message::refreshDataIdHook() {
|
void Message::refreshDataIdHook() {
|
||||||
if (base::take(_rightActionLink)) {
|
if (base::take(_rightActionLink)) {
|
||||||
_rightActionLink = rightActionLink();
|
_rightActionLink = rightActionLink();
|
||||||
|
|
|
@ -86,6 +86,8 @@ public:
|
||||||
TimeId displayedEditDate() const override;
|
TimeId displayedEditDate() const override;
|
||||||
int infoWidth() const override;
|
int infoWidth() const override;
|
||||||
|
|
||||||
|
VerticalRepaintRange verticalRepaintRange() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void refreshDataIdHook() override;
|
void refreshDataIdHook() override;
|
||||||
|
|
||||||
|
|
|
@ -241,9 +241,12 @@ public:
|
||||||
return (rotate != 0.) || (scale != 1.);
|
return (rotate != 0.) || (scale != 1.);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
[[nodiscard]] virtual BubbleRoll getBubbleRoll() const {
|
[[nodiscard]] virtual BubbleRoll bubbleRoll() const {
|
||||||
return BubbleRoll();
|
return BubbleRoll();
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] virtual QMargins bubbleRollRepaintMargins() const {
|
||||||
|
return QMargins();
|
||||||
|
}
|
||||||
|
|
||||||
virtual void unloadHeavyPart() {
|
virtual void unloadHeavyPart() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,10 @@ namespace HistoryView {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kShowRecentVotersCount = 3;
|
constexpr auto kShowRecentVotersCount = 3;
|
||||||
|
constexpr auto kRotateSegments = 8;
|
||||||
|
constexpr auto kRotateAmplitude = 3.;
|
||||||
|
constexpr auto kScaleSegments = 2;
|
||||||
|
constexpr auto kScaleAmplitude = 0.03;
|
||||||
|
|
||||||
struct PercentCounterItem {
|
struct PercentCounterItem {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -1142,14 +1146,10 @@ TextState Poll::textState(QPoint point, StateRequest request) const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Poll::getBubbleRoll() const -> BubbleRoll {
|
auto Poll::bubbleRoll() const -> BubbleRoll {
|
||||||
constexpr auto kRotateSegments = 8;
|
|
||||||
constexpr auto kRotateAmplitude = 2.5;
|
|
||||||
constexpr auto kScaleSegments = 2;
|
|
||||||
constexpr auto kScaleAmplitude = 0.025;
|
|
||||||
|
|
||||||
const auto value = _wrongAnswerAnimation.value(1.);
|
const auto value = _wrongAnswerAnimation.value(1.);
|
||||||
if (value == 1.) {
|
_wrongAnswerAnimated = (value < 1.);
|
||||||
|
if (!_wrongAnswerAnimated) {
|
||||||
return BubbleRoll();
|
return BubbleRoll();
|
||||||
}
|
}
|
||||||
const auto rotateFull = value * kRotateSegments;
|
const auto rotateFull = value * kRotateSegments;
|
||||||
|
@ -1164,13 +1164,21 @@ auto Poll::getBubbleRoll() const -> BubbleRoll {
|
||||||
}
|
}
|
||||||
Unexpected("Value in Poll::getBubbleRollDegrees.");
|
Unexpected("Value in Poll::getBubbleRollDegrees.");
|
||||||
};
|
};
|
||||||
const auto scaleFull = value * kScaleSegments;
|
|
||||||
return {
|
return {
|
||||||
.rotate = progress(value * kRotateSegments) * kRotateAmplitude,
|
.rotate = progress(value * kRotateSegments) * kRotateAmplitude,
|
||||||
.scale = 1. + progress(value * kScaleSegments) * kScaleAmplitude
|
.scale = 1. + progress(value * kScaleSegments) * kScaleAmplitude
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMargins Poll::bubbleRollRepaintMargins() const {
|
||||||
|
if (!_wrongAnswerAnimated) {
|
||||||
|
return QMargins();
|
||||||
|
}
|
||||||
|
static const auto kAdd = int(std::ceil(
|
||||||
|
st::msgMaxWidth * std::sin(kRotateAmplitude * M_PI / 180.)));
|
||||||
|
return QMargins(kAdd, kAdd, kAdd, kAdd);
|
||||||
|
}
|
||||||
|
|
||||||
void Poll::clickHandlerPressedChanged(
|
void Poll::clickHandlerPressedChanged(
|
||||||
const ClickHandlerPtr &handler,
|
const ClickHandlerPtr &handler,
|
||||||
bool pressed) {
|
bool pressed) {
|
||||||
|
|
|
@ -41,7 +41,8 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BubbleRoll getBubbleRoll() const override;
|
BubbleRoll bubbleRoll() const override;
|
||||||
|
QMargins bubbleRollRepaintMargins() const override;
|
||||||
|
|
||||||
void clickHandlerPressedChanged(
|
void clickHandlerPressedChanged(
|
||||||
const ClickHandlerPtr &handler,
|
const ClickHandlerPtr &handler,
|
||||||
|
@ -168,13 +169,15 @@ private:
|
||||||
ClickHandlerPtr _showResultsLink;
|
ClickHandlerPtr _showResultsLink;
|
||||||
ClickHandlerPtr _sendVotesLink;
|
ClickHandlerPtr _sendVotesLink;
|
||||||
mutable std::unique_ptr<Ui::RippleAnimation> _linkRipple;
|
mutable std::unique_ptr<Ui::RippleAnimation> _linkRipple;
|
||||||
bool _hasSelected = false;
|
|
||||||
|
|
||||||
mutable std::unique_ptr<AnswersAnimation> _answersAnimation;
|
mutable std::unique_ptr<AnswersAnimation> _answersAnimation;
|
||||||
mutable std::unique_ptr<SendingAnimation> _sendingAnimation;
|
mutable std::unique_ptr<SendingAnimation> _sendingAnimation;
|
||||||
mutable Ui::Animations::Simple _wrongAnswerAnimation;
|
Ui::Animations::Simple _wrongAnswerAnimation;
|
||||||
mutable QPoint _lastLinkPoint;
|
mutable QPoint _lastLinkPoint;
|
||||||
|
|
||||||
|
bool _hasSelected = false;
|
||||||
|
mutable bool _wrongAnswerAnimated = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace HistoryView
|
} // namespace HistoryView
|
||||||
|
|
Loading…
Reference in New Issue