mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-05-09 17:33:58 +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(
|
||||
not_null<Ui::RpWidget*> widget,
|
||||
Fn<std::pair<QColor, QColor>()> colors,
|
||||
bool mirrored) {
|
||||
bool mirrored,
|
||||
bool iconMirrored) {
|
||||
struct State {
|
||||
base::unique_qptr<Ui::RpWidget> back;
|
||||
SwipeContextData data;
|
||||
|
@ -398,17 +399,22 @@ SwipeBackResult SetupSwipeBack(
|
|||
const auto arrowHalf = arrowSize / 2;
|
||||
const auto arrowX = st::swipeBackSize / 8
|
||||
+ rect.x()
|
||||
+ halfSize
|
||||
- arrowHalf;
|
||||
+ halfSize;
|
||||
const auto arrowY = rect.y() + halfSize;
|
||||
|
||||
auto arrowPath = QPainterPath();
|
||||
arrowPath.moveTo(arrowX + arrowSize, arrowY);
|
||||
arrowPath.lineTo(arrowX, arrowY);
|
||||
arrowPath.lineTo(arrowX + arrowHalf, arrowY - arrowHalf);
|
||||
arrowPath.moveTo(arrowX, arrowY);
|
||||
arrowPath.lineTo(arrowX + arrowHalf, arrowY + arrowHalf);
|
||||
const auto direction = iconMirrored ? -1 : 1;
|
||||
|
||||
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);
|
||||
}
|
||||
if (reachRatio) {
|
||||
|
|
|
@ -40,7 +40,8 @@ void SetupSwipeHandler(
|
|||
[[nodiscard]] SwipeBackResult SetupSwipeBack(
|
||||
not_null<Ui::RpWidget*> widget,
|
||||
Fn<std::pair<QColor, QColor>()> colors,
|
||||
bool mirrored = false);
|
||||
bool mirrored = false,
|
||||
bool iconMirrored = false);
|
||||
|
||||
[[nodiscard]] SwipeHandlerFinishData DefaultSwipeBackHandlerFinishData(
|
||||
Fn<void(void)> callback);
|
||||
|
|
Loading…
Add table
Reference in a new issue