mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix animated toggle in tabbed panel.
This commit is contained in:
parent
21f3a7b07f
commit
4129664637
2 changed files with 22 additions and 9 deletions
|
@ -276,15 +276,15 @@ SearchWithGroups::SearchWithGroups(
|
||||||
SearchDescriptor descriptor)
|
SearchDescriptor descriptor)
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _st(descriptor.st)
|
, _st(descriptor.st)
|
||||||
, _search(CreateChild<FadeWrap<IconButton>>(
|
, _search(CreateChild<FadeWrapScaled<IconButton>>(
|
||||||
this,
|
this,
|
||||||
object_ptr<IconButton>(this, _st.search)))
|
object_ptr<IconButton>(this, _st.search)))
|
||||||
, _back(CreateChild<FadeWrap<IconButton>>(
|
, _back(CreateChild<FadeWrapScaled<IconButton>>(
|
||||||
this,
|
this,
|
||||||
object_ptr<IconButton>(this, _st.back)))
|
object_ptr<IconButton>(this, _st.back)))
|
||||||
, _cancel(CreateChild<CrossButton>(this, _st.cancel))
|
, _cancel(CreateChild<CrossButton>(this, _st.cancel))
|
||||||
, _field(CreateChild<InputField>(this, _st.field, tr::lng_dlg_filter()))
|
, _field(CreateChild<InputField>(this, _st.field, tr::lng_dlg_filter()))
|
||||||
, _groups(CreateChild<FadeWrap<RpWidget>>(
|
, _groups(CreateChild<FadeWrapScaled<RpWidget>>(
|
||||||
this,
|
this,
|
||||||
object_ptr<GroupsStrip>(
|
object_ptr<GroupsStrip>(
|
||||||
this,
|
this,
|
||||||
|
@ -297,6 +297,7 @@ SearchWithGroups::SearchWithGroups(
|
||||||
initGroups();
|
initGroups();
|
||||||
initButtons();
|
initButtons();
|
||||||
initEdges();
|
initEdges();
|
||||||
|
_inited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
anim::type SearchWithGroups::animated() const {
|
anim::type SearchWithGroups::animated() const {
|
||||||
|
@ -308,8 +309,7 @@ void SearchWithGroups::initField() {
|
||||||
const auto last = FieldQuery(_field);
|
const auto last = FieldQuery(_field);
|
||||||
_query = last;
|
_query = last;
|
||||||
const auto empty = last.empty();
|
const auto empty = last.empty();
|
||||||
_cancel->toggle(!empty, animated());
|
_fieldEmpty = empty;
|
||||||
_groups->toggle(empty, animated());
|
|
||||||
if (empty) {
|
if (empty) {
|
||||||
_debounceTimer.cancel();
|
_debounceTimer.cancel();
|
||||||
_debouncedQuery = last;
|
_debouncedQuery = last;
|
||||||
|
@ -330,6 +330,13 @@ void SearchWithGroups::initField() {
|
||||||
const auto last = FieldQuery(_field);
|
const auto last = FieldQuery(_field);
|
||||||
_query = last;
|
_query = last;
|
||||||
_debouncedQuery = last;
|
_debouncedQuery = last;
|
||||||
|
_fieldEmpty = last.empty();
|
||||||
|
_fieldEmpty.value(
|
||||||
|
) | rpl::start_with_next([=](bool empty) {
|
||||||
|
_cancel->toggle(!empty, animated());
|
||||||
|
_groups->toggle(empty, animated());
|
||||||
|
resizeToWidth(width());
|
||||||
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchWithGroups::initGroups() {
|
void SearchWithGroups::initGroups() {
|
||||||
|
@ -544,6 +551,9 @@ int SearchWithGroups::IconSizeOverride() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int SearchWithGroups::resizeGetHeight(int newWidth) {
|
int SearchWithGroups::resizeGetHeight(int newWidth) {
|
||||||
|
if (!newWidth) {
|
||||||
|
return _st.height;
|
||||||
|
}
|
||||||
_back->moveToLeft(0, 0, newWidth);
|
_back->moveToLeft(0, 0, newWidth);
|
||||||
_search->moveToLeft(0, 0, newWidth);
|
_search->moveToLeft(0, 0, newWidth);
|
||||||
_cancel->moveToRight(0, 0, newWidth);
|
_cancel->moveToRight(0, 0, newWidth);
|
||||||
|
@ -582,11 +592,13 @@ void SearchWithGroups::moveGroupsTo(int width, int to) {
|
||||||
const auto fieldWidthMin = std::min(
|
const auto fieldWidthMin = std::min(
|
||||||
rect::m::sum::h(placeholderMargins) + placeholderWidth,
|
rect::m::sum::h(placeholderMargins) + placeholderWidth,
|
||||||
_st.defaultFieldWidth);
|
_st.defaultFieldWidth);
|
||||||
const auto fieldWidth = std::max(
|
const auto fieldWidth = _fieldEmpty.current()
|
||||||
groupsLeft - _st.search.width,
|
? std::max(groupsLeft - _st.search.width, fieldWidthMin)
|
||||||
fieldWidthMin);
|
: (width - _fadeLeftStart - _st.cancel.width);
|
||||||
_field->resizeToWidth(fieldWidth);
|
_field->resizeToWidth(fieldWidth);
|
||||||
const auto fieldLeft = groupsLeft - fieldWidth;
|
const auto fieldLeft = _fieldEmpty.current()
|
||||||
|
? (groupsLeft - fieldWidth)
|
||||||
|
: _fadeLeftStart;
|
||||||
_field->moveToLeft(fieldLeft, 0);
|
_field->moveToLeft(fieldLeft, 0);
|
||||||
|
|
||||||
if (fieldLeft >= _fadeLeftStart) {
|
if (fieldLeft >= _fadeLeftStart) {
|
||||||
|
|
|
@ -90,6 +90,7 @@ private:
|
||||||
int _fadeLeftStart = 0;
|
int _fadeLeftStart = 0;
|
||||||
|
|
||||||
rpl::variable<int> _fieldPlaceholderWidth;
|
rpl::variable<int> _fieldPlaceholderWidth;
|
||||||
|
rpl::variable<bool> _fieldEmpty = true;
|
||||||
Ui::Animations::Simple _groupsLeftAnimation;
|
Ui::Animations::Simple _groupsLeftAnimation;
|
||||||
int _groupsLeftTo = 0;
|
int _groupsLeftTo = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue