From c48709d6e472b547ea1691af202e12d9686150e7 Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Thu, 15 Sep 2022 23:35:57 +0300 Subject: [PATCH] [Visual] Allow hiding shadow of modal window header This was needed for custom changelog box, which is currently not in main branch. --- ui/layers/box_content.cpp | 12 ++++++++---- ui/layers/box_content.h | 9 +++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ui/layers/box_content.cpp b/ui/layers/box_content.cpp index e1a0423..07eb8fc 100644 --- a/ui/layers/box_content.cpp +++ b/ui/layers/box_content.cpp @@ -204,10 +204,12 @@ void BoxContent::updateShadowsVisibility() { const auto top = _scroll->scrollTop(); _topShadow->toggle( - (top > 0 || _innerTopSkip > 0), + (top > 0 + || (_innerTopSkip > 0 && !_topShadowWithSkip)), anim::type::normal); _bottomShadow->toggle( - (top < _scroll->scrollTopMax() || _innerBottomSkip > 0), + (top < _scroll->scrollTopMax() + || (_innerBottomSkip > 0 && !_bottomShadowWithSkip)), anim::type::normal); } @@ -298,10 +300,12 @@ void BoxContent::updateScrollAreaGeometry() { const auto top = _scroll->scrollTop(); _topShadow->toggle( - (top > 0 || _innerTopSkip > 0), + (top > 0 + || (_innerTopSkip > 0 && !_topShadowWithSkip)), anim::type::instant); _bottomShadow->toggle( - (top < _scroll->scrollTopMax() || _innerBottomSkip > 0), + (top < _scroll->scrollTopMax() + || (_innerBottomSkip > 0 && !_bottomShadowWithSkip)), anim::type::instant); } } diff --git a/ui/layers/box_content.h b/ui/layers/box_content.h index fa275f5..63970c9 100644 --- a/ui/layers/box_content.h +++ b/ui/layers/box_content.h @@ -209,6 +209,13 @@ protected: getDelegate()->setLayerType(layerType); } + void setTopShadowWithSkip(bool enabled) { + _topShadowWithSkip = enabled; + } + void setBottomShadowWithSkip(bool enabled) { + _bottomShadowWithSkip = enabled; + } + void setDimensions( int newWidth, int maxHeight, @@ -277,6 +284,8 @@ private: bool _preparing = false; bool _noContentMargin = false; bool _closeByEscape = true; + bool _topShadowWithSkip = false; + bool _bottomShadowWithSkip = false; int _innerTopSkip = 0; int _innerBottomSkip = 0; object_ptr _scroll = { nullptr };