From 82ccac3200ed86f34b6d76137bbf09cab75c3beb Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 20 Sep 2019 14:10:25 +0300 Subject: [PATCH] Add menuToggle style. --- icons/title_menu_dots.png | Bin 0 -> 130 bytes icons/title_menu_dots@2x.png | Bin 0 -> 212 bytes icons/title_menu_dots@3x.png | Bin 0 -> 311 bytes ui/widgets/dropdown_menu.cpp | 4 ++-- ui/widgets/inner_dropdown.cpp | 27 +++++++++++++++++++-------- ui/widgets/widgets.style | 17 +++++++++++++++++ 6 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 icons/title_menu_dots.png create mode 100644 icons/title_menu_dots@2x.png create mode 100644 icons/title_menu_dots@3x.png diff --git a/icons/title_menu_dots.png b/icons/title_menu_dots.png new file mode 100644 index 0000000000000000000000000000000000000000..228a2a3bc94874a0a14043e8cd58a36c70508ebd GIT binary patch literal 130 zcmeAS@N?(olHy`uVBq!ia0vp^96&6>!3HEZNY`WoDNj!q#}JK)Z~G5&9xxDb@_qhW z;m==of$1BTvlMy0Unuu=p#=jAyY2D<=3Ua;5~WqlH5ihtgC`mNJ>PlN!Dy0_X6RO_ eWB(s564!UGXcGMu@Te4MD1)b~pUXO@geCx6A}XT* literal 0 HcmV?d00001 diff --git a/icons/title_menu_dots@2x.png b/icons/title_menu_dots@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..0020d07f11493d55e521effaba2075a58de38e3e GIT binary patch literal 212 zcmV;_04x8AP)MxB;LObS>nZhhI%8{WgOcIzg><_}JY)-oN#vs>30c zQoawdNdSbqhr0)WQE^<&@-LgN^0MG$VUCl9ZC80&aI!GR$-=g)Ji`;3%+|&vp`VTb O0000Q<@% literal 0 HcmV?d00001 diff --git a/icons/title_menu_dots@3x.png b/icons/title_menu_dots@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..029087a43b10280f2845ef46f0e4adeaef16295b GIT binary patch literal 311 zcmV-70m%M|P){cxTp$G^uj~5Wn!>=L<(%I?v>u4aAq0*wa;=qXtsGS$f+XhXH?XzFMRcp9LNCIZyay42BzYSq!y(G+mAz5!&7gvdt3C`$kU002ov JPDHLkV1gvBhgARo literal 0 HcmV?d00001 diff --git a/ui/widgets/dropdown_menu.cpp b/ui/widgets/dropdown_menu.cpp index 54aecb0..9e69974 100644 --- a/ui/widgets/dropdown_menu.cpp +++ b/ui/widgets/dropdown_menu.cpp @@ -222,8 +222,8 @@ void DropdownMenu::childHiding(DropdownMenu *child) { void DropdownMenu::hideFinish() { _menu->clearSelection(); - if (_hiddenCallback) { - _hiddenCallback(); + if (const auto onstack = _hiddenCallback) { + onstack(); } } diff --git a/ui/widgets/inner_dropdown.cpp b/ui/widgets/inner_dropdown.cpp index 9cc4e3f..0c793c8 100644 --- a/ui/widgets/inner_dropdown.cpp +++ b/ui/widgets/inner_dropdown.cpp @@ -234,10 +234,13 @@ void InnerDropdown::hideFinished() { _cache = QPixmap(); _ignoreShowEvents = false; if (!isHidden()) { - if (_hiddenCallback) { - _hiddenCallback(); + const auto weak = Ui::MakeWeak(this); + if (const auto onstack = _hiddenCallback) { + onstack(); + } + if (weak) { + hide(); } - hide(); } } @@ -256,19 +259,27 @@ void InnerDropdown::prepareCache() { } void InnerDropdown::startOpacityAnimation(bool hiding) { + const auto weak = Ui::MakeWeak(this); if (hiding) { - if (_hideStartCallback) { - _hideStartCallback(); + if (const auto onstack = _hideStartCallback) { + onstack(); } - } else if (_showStartCallback) { - _showStartCallback(); + } else if (const auto onstack = _showStartCallback) { + onstack(); + } + if (!weak) { + return; } _hiding = false; prepareCache(); _hiding = hiding; hideChildren(); - _a_opacity.start([this] { opacityAnimationCallback(); }, _hiding ? 1. : 0., _hiding ? 0. : 1., _st.duration); + _a_opacity.start( + [=] { opacityAnimationCallback(); }, + _hiding ? 1. : 0., + _hiding ? 0. : 1., + _st.duration); } void InnerDropdown::showStarted() { diff --git a/ui/widgets/widgets.style b/ui/widgets/widgets.style index 59f6f7d..42b4186 100644 --- a/ui/widgets/widgets.style +++ b/ui/widgets/widgets.style @@ -1128,3 +1128,20 @@ defaultLevelMeter: LevelMeter { activeFg: mediaPlayerActiveFg; inactiveFg: mediaPlayerInactiveFg; } + +menuToggleIcon: icon {{ "title_menu_dots", menuIconFg }}; +menuToggleIconOver: icon {{ "title_menu_dots", menuIconFgOver }}; +menuToggle: IconButton { + width: 40px; + height: 40px; + + icon: menuToggleIcon; + iconOver: menuToggleIconOver; + iconPosition: point(16px, 10px); + + rippleAreaPosition: point(0px, 0px); + rippleAreaSize: 40px; + ripple: RippleAnimation(defaultRippleAnimation) { + color: windowBgOver; + } +}