mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add arrows to move in premium previews box.
This commit is contained in:
parent
2583ddea2e
commit
01bcdf10ee
3 changed files with 67 additions and 33 deletions
|
@ -1088,6 +1088,24 @@ void ReactionPreview::paintEffect(QPainter &p) {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
const auto select = [=](int index) {
|
||||||
|
const auto wasInside = (state->selected >= 0);
|
||||||
|
const auto nowInside = (index >= 0);
|
||||||
|
if (state->selected != index) {
|
||||||
|
if (wasInside) {
|
||||||
|
state->entries[state->selected]->setOver(false);
|
||||||
|
}
|
||||||
|
if (nowInside) {
|
||||||
|
state->entries[index]->setOver(true);
|
||||||
|
}
|
||||||
|
state->selected = index;
|
||||||
|
}
|
||||||
|
if (wasInside != nowInside) {
|
||||||
|
result->setCursor(nowInside
|
||||||
|
? style::cur_pointer
|
||||||
|
: style::cur_default);
|
||||||
|
}
|
||||||
|
};
|
||||||
result->events(
|
result->events(
|
||||||
) | rpl::start_with_next([=](not_null<QEvent*> event) {
|
) | rpl::start_with_next([=](not_null<QEvent*> event) {
|
||||||
if (event->type() == QEvent::MouseButtonPress) {
|
if (event->type() == QEvent::MouseButtonPress) {
|
||||||
|
@ -1101,22 +1119,9 @@ void ReactionPreview::paintEffect(QPainter &p) {
|
||||||
} else if (event->type() == QEvent::MouseMove) {
|
} else if (event->type() == QEvent::MouseMove) {
|
||||||
const auto point = static_cast<QMouseEvent*>(event.get())->pos();
|
const auto point = static_cast<QMouseEvent*>(event.get())->pos();
|
||||||
const auto index = lookup(point);
|
const auto index = lookup(point);
|
||||||
const auto wasInside = (state->selected >= 0);
|
select(lookup(point));
|
||||||
const auto nowInside = (index >= 0);
|
} else if (event->type() == QEvent::Leave) {
|
||||||
if (state->selected != index) {
|
select(-1);
|
||||||
if (wasInside) {
|
|
||||||
state->entries[state->selected]->setOver(false);
|
|
||||||
}
|
|
||||||
if (nowInside) {
|
|
||||||
state->entries[index]->setOver(true);
|
|
||||||
}
|
|
||||||
state->selected = index;
|
|
||||||
}
|
|
||||||
if (wasInside != nowInside) {
|
|
||||||
result->setCursor(nowInside
|
|
||||||
? style::cur_pointer
|
|
||||||
: style::cur_default);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, lifetime);
|
}, lifetime);
|
||||||
|
|
||||||
|
@ -1230,14 +1235,6 @@ void PreviewBox(
|
||||||
const auto outer = box->addRow(
|
const auto outer = box->addRow(
|
||||||
ChatBackPreview(box, size.height(), back),
|
ChatBackPreview(box, size.height(), back),
|
||||||
{});
|
{});
|
||||||
const auto close = Ui::CreateChild<Ui::IconButton>(
|
|
||||||
box->verticalLayout().get(),
|
|
||||||
st::settingsPremiumTopBarClose);
|
|
||||||
box->verticalLayout()->widthValue(
|
|
||||||
) | rpl::start_with_next([=](int width) {
|
|
||||||
close->moveToRight(0, 0, width);
|
|
||||||
}, close->lifetime());
|
|
||||||
close->setClickedCallback([=] { box->closeBox(); });
|
|
||||||
|
|
||||||
struct Hiding {
|
struct Hiding {
|
||||||
not_null<Ui::RpWidget*> widget;
|
not_null<Ui::RpWidget*> widget;
|
||||||
|
@ -1261,6 +1258,37 @@ void PreviewBox(
|
||||||
const auto state = outer->lifetime().make_state<State>();
|
const auto state = outer->lifetime().make_state<State>();
|
||||||
state->selected = descriptor.section;
|
state->selected = descriptor.section;
|
||||||
|
|
||||||
|
const auto move = [=](int delta) {
|
||||||
|
using Type = PremiumPreview;
|
||||||
|
const auto count = int(Type::kCount);
|
||||||
|
const auto now = state->selected.current();
|
||||||
|
state->selected = Type((int(now) + count + delta) % count);
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto buttonsParent = box->verticalLayout().get();
|
||||||
|
const auto close = Ui::CreateChild<Ui::IconButton>(
|
||||||
|
buttonsParent,
|
||||||
|
st::settingsPremiumTopBarClose);
|
||||||
|
close->setClickedCallback([=] { box->closeBox(); });
|
||||||
|
|
||||||
|
const auto left = Ui::CreateChild<Ui::IconButton>(
|
||||||
|
buttonsParent,
|
||||||
|
st::settingsPremiumMoveLeft);
|
||||||
|
left->setClickedCallback([=] { move(-1); });
|
||||||
|
|
||||||
|
const auto right = Ui::CreateChild<Ui::IconButton>(
|
||||||
|
buttonsParent,
|
||||||
|
st::settingsPremiumMoveRight);
|
||||||
|
right->setClickedCallback([=] { move(1); });
|
||||||
|
|
||||||
|
buttonsParent->widthValue(
|
||||||
|
) | rpl::start_with_next([=](int width) {
|
||||||
|
const auto outerHeight = st::premiumPreviewHeight;
|
||||||
|
close->moveToRight(0, 0, width);
|
||||||
|
left->moveToLeft(0, (outerHeight - left->height()) / 2, width);
|
||||||
|
right->moveToRight(0, (outerHeight - right->height()) / 2, width);
|
||||||
|
}, close->lifetime());
|
||||||
|
|
||||||
state->preload = [=] {
|
state->preload = [=] {
|
||||||
if (!state->showFinished) {
|
if (!state->showFinished) {
|
||||||
state->preloadScheduled = true;
|
state->preloadScheduled = true;
|
||||||
|
@ -1480,15 +1508,10 @@ void PreviewBox(
|
||||||
) | rpl::start_with_next([=](not_null<QEvent*> e) {
|
) | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||||
if (e->type() == QEvent::KeyPress) {
|
if (e->type() == QEvent::KeyPress) {
|
||||||
const auto key = static_cast<QKeyEvent*>(e.get())->key();
|
const auto key = static_cast<QKeyEvent*>(e.get())->key();
|
||||||
using Type = PremiumPreview;
|
|
||||||
if (key == Qt::Key_Left) {
|
if (key == Qt::Key_Left) {
|
||||||
const auto count = int(Type::kCount);
|
move(-1);
|
||||||
const auto now = state->selected.current();
|
|
||||||
state->selected = Type((int(now) + count - 1) % count);
|
|
||||||
} else if (key == Qt::Key_Right) {
|
} else if (key == Qt::Key_Right) {
|
||||||
const auto count = int(Type::kCount);
|
move(1);
|
||||||
const auto now = state->selected.current();
|
|
||||||
state->selected = Type((int(now) + 1) % count);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, box->lifetime());
|
}, box->lifetime());
|
||||||
|
|
|
@ -299,7 +299,7 @@ infoProfileNameLabel: FlatLabel(infoProfileStatusLabel) {
|
||||||
linkFontOver: font(16px semibold underline);
|
linkFontOver: font(16px semibold underline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
infoVerifiedCheckPosition: point(10px, 2px);
|
infoVerifiedCheckPosition: point(2px, 2px);
|
||||||
infoVerifiedCheck: icon {
|
infoVerifiedCheck: icon {
|
||||||
{ "profile_verified_star", profileVerifiedCheckBg },
|
{ "profile_verified_star", profileVerifiedCheckBg },
|
||||||
{ "profile_verified_check", profileVerifiedCheckFg }
|
{ "profile_verified_check", profileVerifiedCheckFg }
|
||||||
|
|
|
@ -435,7 +435,7 @@ settingsPremiumTopBarBack: IconButton(infoTopBarBack) {
|
||||||
}
|
}
|
||||||
settingsPremiumLayerTopBarBack: IconButton(infoLayerTopBarBack) {
|
settingsPremiumLayerTopBarBack: IconButton(infoLayerTopBarBack) {
|
||||||
icon: settingsPremiumTopBarBackIcon;
|
icon: settingsPremiumTopBarBackIcon;
|
||||||
iconOver: settingsPremiumTopBarBackIcon;
|
iconOver: settingsPremiumTopBarBackIconOver;
|
||||||
ripple: RippleAnimation(defaultRippleAnimation) {
|
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||||
color: shadowFg;
|
color: shadowFg;
|
||||||
}
|
}
|
||||||
|
@ -447,6 +447,17 @@ settingsPremiumTopBarClose: IconButton(infoTopBarClose) {
|
||||||
color: shadowFg;
|
color: shadowFg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
settingsPremiumMoveLeft: IconButton(settingsPremiumLayerTopBarBack) {
|
||||||
|
width: 52px;
|
||||||
|
height: 56px;
|
||||||
|
iconPosition: point(-1px, -1px);
|
||||||
|
}
|
||||||
|
settingsPremiumMoveRightIcon: icon {{ "info/info_back-flip_horizontal", premiumButtonFg }};
|
||||||
|
settingsPremiumMoveRightIconOver: icon {{ "info/info_back-flip_horizontal", premiumButtonFg }};
|
||||||
|
settingsPremiumMoveRight: IconButton(settingsPremiumMoveLeft) {
|
||||||
|
icon: settingsPremiumMoveRightIcon;
|
||||||
|
iconOver: settingsPremiumMoveRightIconOver;
|
||||||
|
}
|
||||||
settingsPremiumRowTitlePadding: margins(60px, 5px, 46px, 3px);
|
settingsPremiumRowTitlePadding: margins(60px, 5px, 46px, 3px);
|
||||||
settingsPremiumRowAboutPadding: margins(60px, 0px, 46px, 6px);
|
settingsPremiumRowAboutPadding: margins(60px, 0px, 46px, 6px);
|
||||||
settingsPremiumPreviewTitlePadding: margins(24px, 13px, 24px, 3px);
|
settingsPremiumPreviewTitlePadding: margins(24px, 13px, 24px, 3px);
|
||||||
|
|
Loading…
Add table
Reference in a new issue