mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-05-11 18:33:59 +02:00
Added ability to mirror icon from widget for swipe-to-back.
This commit is contained in:
parent
f0c8e48403
commit
f57eff4195
2 changed files with 16 additions and 9 deletions
|
@ -332,7 +332,8 @@ 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) {
|
bool mirrored,
|
||||||
|
bool iconMirrored) {
|
||||||
struct State {
|
struct State {
|
||||||
base::unique_qptr<Ui::RpWidget> back;
|
base::unique_qptr<Ui::RpWidget> back;
|
||||||
SwipeContextData data;
|
SwipeContextData data;
|
||||||
|
@ -398,17 +399,22 @@ SwipeBackResult SetupSwipeBack(
|
||||||
const auto arrowHalf = arrowSize / 2;
|
const auto arrowHalf = arrowSize / 2;
|
||||||
const auto arrowX = st::swipeBackSize / 8
|
const auto arrowX = st::swipeBackSize / 8
|
||||||
+ rect.x()
|
+ rect.x()
|
||||||
+ halfSize
|
+ halfSize;
|
||||||
- arrowHalf;
|
|
||||||
const auto arrowY = rect.y() + halfSize;
|
const auto arrowY = rect.y() + halfSize;
|
||||||
|
|
||||||
auto arrowPath = QPainterPath();
|
auto arrowPath = QPainterPath();
|
||||||
arrowPath.moveTo(arrowX + arrowSize, arrowY);
|
const auto direction = iconMirrored ? -1 : 1;
|
||||||
arrowPath.lineTo(arrowX, arrowY);
|
|
||||||
arrowPath.lineTo(arrowX + arrowHalf, arrowY - arrowHalf);
|
|
||||||
arrowPath.moveTo(arrowX, arrowY);
|
|
||||||
arrowPath.lineTo(arrowX + arrowHalf, arrowY + arrowHalf);
|
|
||||||
|
|
||||||
|
arrowPath.moveTo(arrowX + direction * arrowSize, arrowY);
|
||||||
|
arrowPath.lineTo(arrowX, arrowY);
|
||||||
|
arrowPath.lineTo(
|
||||||
|
arrowX + direction * arrowHalf,
|
||||||
|
arrowY - arrowHalf);
|
||||||
|
arrowPath.moveTo(arrowX, arrowY);
|
||||||
|
arrowPath.lineTo(
|
||||||
|
arrowX + direction * arrowHalf,
|
||||||
|
arrowY + arrowHalf);
|
||||||
|
arrowPath.translate(-direction * arrowHalf, 0);
|
||||||
p.drawPath(arrowPath);
|
p.drawPath(arrowPath);
|
||||||
}
|
}
|
||||||
if (reachRatio) {
|
if (reachRatio) {
|
||||||
|
|
|
@ -40,7 +40,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);
|
bool mirrored = false,
|
||||||
|
bool iconMirrored = false);
|
||||||
|
|
||||||
[[nodiscard]] SwipeHandlerFinishData DefaultSwipeBackHandlerFinishData(
|
[[nodiscard]] SwipeHandlerFinishData DefaultSwipeBackHandlerFinishData(
|
||||||
Fn<void(void)> callback);
|
Fn<void(void)> callback);
|
||||||
|
|
Loading…
Add table
Reference in a new issue