@@ -38,6 +38,7 @@ void RibbonNotifier::pushNotification( const RibbonNotification& notification )
3838 addNotification_ ( notifications_, notification );
3939 addNotification_ ( notificationsHistory_, notification );
4040
41+ currentHistoryBtnTimer_ = showHistoryBtnMaxTime_;
4142 scrollDownNeeded_ = true ;
4243 requestClosestRedraw_ ();
4344}
@@ -52,12 +53,40 @@ void RibbonNotifier::draw( float scaling, const Box2i& limitFramebuffer )
5253 filterInvalid_ ( -1 );
5354}
5455
56+ void RibbonNotifier::setHitoryButtonMaxLifeTime ( float histBtnMaxLifeTime )
57+ {
58+ if ( showHistoryBtnMaxTime_ == histBtnMaxLifeTime )
59+ return ; // do nothing
60+ if ( showHistoryBtnMaxTime_ <= 0 && histBtnMaxLifeTime <= 0 )
61+ return ; // do nothing
62+
63+ if ( showHistoryBtnMaxTime_ <= 0 )
64+ {
65+ currentHistoryBtnTimer_ = histBtnMaxLifeTime;
66+ }
67+ else
68+ {
69+ if ( currentHistoryBtnTimer_ > 0 )
70+ currentHistoryBtnTimer_ += ( histBtnMaxLifeTime - showHistoryBtnMaxTime_ ); // decrease current timer
71+ }
72+ showHistoryBtnMaxTime_ = histBtnMaxLifeTime;
73+ requestClosestRedraw_ ();
74+ }
75+
5576void RibbonNotifier::drawHistoryButton_ ( float scaling, const Box2i& limitFramebuffer )
5677{
5778 using namespace StyleConsts ::Notification;
5879 if ( notificationsHistory_.empty () )
5980 return ;
6081
82+ if ( showHistoryBtnMaxTime_ > 0 )
83+ {
84+ if ( currentHistoryBtnTimer_ >= 0 && !historyMode_ )
85+ currentHistoryBtnTimer_ -= ImGui::GetIO ().DeltaTime ;
86+ if ( currentHistoryBtnTimer_ < 0 )
87+ return ;
88+ }
89+
6190 const auto windowSzie = ImVec2 ( 36 , cHistoryButtonSizeY ) * scaling;
6291 Vector2f windowPos = Vector2f ( float ( limitFramebuffer.min .x ), float ( getViewerInstance ().framebufferSize .y - limitFramebuffer.min .y ) - windowSzie.y );
6392 if ( cornerPosition == RibbonNotificationCorner::LowerRight )
@@ -113,6 +142,12 @@ void RibbonNotifier::drawHistoryButton_( float scaling, const Box2i& limitFrameb
113142 notifications_.clear ();
114143 scrollDownNeeded_ = true ;
115144 }
145+ else
146+ {
147+ currentHistoryBtnTimer_ = showHistoryBtnMaxTime_;
148+ if ( currentHistoryBtnTimer_ > 0 )
149+ requestClosestRedraw_ ();
150+ }
116151 }
117152
118153 auto drawList = window->DrawList ;
@@ -187,6 +222,9 @@ void RibbonNotifier::drawHistory_( float scaling, const Box2i& limitFramebuffer
187222 if ( lostFoucsClickCheck () )
188223 {
189224 historyMode_ = false ;
225+ currentHistoryBtnTimer_ = showHistoryBtnMaxTime_;
226+ if ( currentHistoryBtnTimer_ > 0 )
227+ requestClosestRedraw_ ();
190228 }
191229
192230 ImGui::End ();
@@ -499,6 +537,13 @@ void RibbonNotifier::requestClosestRedraw_()
499537 if ( neededTime < minTimeReq )
500538 minTimeReq = neededTime;
501539 }
540+
541+ if ( showHistoryBtnMaxTime_ > 0 && currentHistoryBtnTimer_ > 0 )
542+ {
543+ if ( currentHistoryBtnTimer_ < minTimeReq )
544+ minTimeReq = currentHistoryBtnTimer_;
545+ }
546+
502547 if ( minTimeReq == FLT_MAX )
503548 return ;
504549 requestRedraw_ = true ;
0 commit comments