mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Added slight nice effect to time picker.
This commit is contained in:
parent
18b9bba21c
commit
8591fae031
1 changed files with 16 additions and 1 deletions
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/event_filter.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/effects/animation_value.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "ui/widgets/vertical_drum_picker.h"
|
||||
#include "styles/style_chat.h"
|
||||
|
@ -17,6 +18,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace Ui {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr auto kMinYScale = 0.2;
|
||||
|
||||
} // namespace
|
||||
|
||||
Fn<TimeId()> TimePickerBox(
|
||||
not_null<GenericBox*> box,
|
||||
std::vector<TimeId> values,
|
||||
|
@ -53,10 +60,18 @@ Fn<TimeId()> TimePickerBox(
|
|||
int outerWidth) {
|
||||
const auto r = QRectF(0, y, outerWidth, itemHeight);
|
||||
const auto progress = std::abs(distanceFromCenter);
|
||||
p.setOpacity(1. - progress);
|
||||
const auto revProgress = 1. - progress;
|
||||
p.save();
|
||||
p.translate(r.center());
|
||||
const auto yScale = kMinYScale
|
||||
+ (1. - kMinYScale) * anim::easeOutCubic(1., revProgress);
|
||||
p.scale(1., yScale);
|
||||
p.translate(-r.center());
|
||||
p.setOpacity(revProgress);
|
||||
p.setFont(font);
|
||||
p.setPen(st::defaultFlatLabel.textFg);
|
||||
p.drawText(r, phrases[index], style::al_center);
|
||||
p.restore();
|
||||
};
|
||||
|
||||
const auto picker = Ui::CreateChild<Ui::VerticalDrumPicker>(
|
||||
|
|
Loading…
Add table
Reference in a new issue