mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-05-10 18:04:01 +02:00
Added ability to set swipe back widget on opposite side.
This commit is contained in:
parent
ad64e068db
commit
4c74cbbbe9
2 changed files with 24 additions and 13 deletions
|
@ -298,16 +298,17 @@ void SetupSwipeHandler(
|
||||||
|
|
||||||
SwipeBackResult SetupSwipeBack(
|
SwipeBackResult SetupSwipeBack(
|
||||||
not_null<Ui::RpWidget*> widget,
|
not_null<Ui::RpWidget*> widget,
|
||||||
Fn<std::pair<QColor, QColor>()> colors) {
|
Fn<std::pair<QColor, QColor>()> colors,
|
||||||
|
bool mirrored) {
|
||||||
struct State {
|
struct State {
|
||||||
base::unique_qptr<Ui::RpWidget> back;
|
base::unique_qptr<Ui::RpWidget> back;
|
||||||
ChatPaintGestureHorizontalData data;
|
ChatPaintGestureHorizontalData data;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr auto kMaxRightOffset = 0.5;
|
constexpr auto kMaxInnerOffset = 0.5;
|
||||||
constexpr auto kMaxLeftOffset = 0.8;
|
constexpr auto kMaxOuterOffset = 0.8;
|
||||||
constexpr auto kIdealSize = 100;
|
constexpr auto kIdealSize = 100;
|
||||||
const auto maxOffset = st::swipeBackSize * kMaxRightOffset;
|
const auto maxOffset = st::swipeBackSize * kMaxInnerOffset;
|
||||||
const auto sizeRatio = st::swipeBackSize
|
const auto sizeRatio = st::swipeBackSize
|
||||||
/ style::ConvertFloatScale(kIdealSize);
|
/ style::ConvertFloatScale(kIdealSize);
|
||||||
|
|
||||||
|
@ -346,10 +347,10 @@ SwipeBackResult SetupSwipeBack(
|
||||||
const auto arcRect = rect - Margins(strokeWidth);
|
const auto arcRect = rect - Margins(strokeWidth);
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.setOpacity(ratio);
|
p.setOpacity(ratio);
|
||||||
if (reachScale) {
|
if (reachScale || mirrored) {
|
||||||
const auto scale = (1. + 1. * reachScale);
|
const auto scale = (1. + 1. * reachScale);
|
||||||
p.translate(center);
|
p.translate(center);
|
||||||
p.scale(scale, scale);
|
p.scale(scale * (mirrored ? -1 : 1), scale);
|
||||||
p.translate(-center);
|
p.translate(-center);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -405,12 +406,21 @@ SwipeBackResult SetupSwipeBack(
|
||||||
raw->show();
|
raw->show();
|
||||||
raw->raise();
|
raw->raise();
|
||||||
}
|
}
|
||||||
|
if (!mirrored) {
|
||||||
state->back->moveToLeft(
|
state->back->moveToLeft(
|
||||||
anim::interpolate(
|
anim::interpolate(
|
||||||
-st::swipeBackSize * kMaxLeftOffset,
|
-st::swipeBackSize * kMaxOuterOffset,
|
||||||
maxOffset - st::swipeBackSize,
|
maxOffset - st::swipeBackSize,
|
||||||
ratio),
|
ratio),
|
||||||
(widget->height() - state->back->height()) / 2);
|
(widget->height() - state->back->height()) / 2);
|
||||||
|
} else {
|
||||||
|
state->back->moveToLeft(
|
||||||
|
anim::interpolate(
|
||||||
|
widget->width() + st::swipeBackSize * kMaxOuterOffset,
|
||||||
|
widget->width() - maxOffset,
|
||||||
|
ratio),
|
||||||
|
(widget->height() - state->back->height()) / 2);
|
||||||
|
}
|
||||||
state->back->update();
|
state->back->update();
|
||||||
} else if (state->back) {
|
} else if (state->back) {
|
||||||
state->back = nullptr;
|
state->back = nullptr;
|
||||||
|
|
|
@ -38,7 +38,8 @@ void SetupSwipeHandler(
|
||||||
|
|
||||||
[[nodiscard]] SwipeBackResult SetupSwipeBack(
|
[[nodiscard]] SwipeBackResult SetupSwipeBack(
|
||||||
not_null<Ui::RpWidget*> widget,
|
not_null<Ui::RpWidget*> widget,
|
||||||
Fn<std::pair<QColor, QColor>()> colors);
|
Fn<std::pair<QColor, QColor>()> colors,
|
||||||
|
bool mirrored = false);
|
||||||
|
|
||||||
[[nodiscard]] SwipeHandlerFinishData DefaultSwipeBackHandlerFinishData(
|
[[nodiscard]] SwipeHandlerFinishData DefaultSwipeBackHandlerFinishData(
|
||||||
Fn<void(void)> callback);
|
Fn<void(void)> callback);
|
||||||
|
|
Loading…
Add table
Reference in a new issue