Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added notification history #3368

Merged
merged 12 commits into from
Sep 23, 2024
Merged

added notification history #3368

merged 12 commits into from
Sep 23, 2024

Conversation

ABSitf
Copy link
Contributor

@ABSitf ABSitf commented Sep 16, 2024

No description provided.

@@ -35,6 +35,7 @@ class RibbonNotifier
public:
// adds new notification for drawing
void pushNotification( const RibbonNotification& notification );
void drawNotificationHistoryButton( float scaling );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 111 to 112
notifier_.drawNotificationHistoryButton( menu_scaling() );
notifier_.drawNotifications( menu_scaling() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calc scaling once, and pass to both functions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 95 to 101
if ( ImGui::IsWindowAppearing() )
{
if ( !activeModal )
ImGui::BringWindowToDisplayFront( ImGui::GetCurrentWindow() ); // bring to front to be over modal background
if ( !ProgressBar::isOrdered() && !activeModal ) // do not focus window, not to close modal on appearing
ImGui::SetWindowFocus();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not needed for "Notification History" it is simple button that should not appear over other windows

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 122 to 131
if ( activeModal )
{
// workaround to be able to hover notification even if modal is present
auto mousePos = ImGui::GetMousePos();
isHovered = window->Rect().Contains( mousePos ) && !activeModal->Rect().Contains( mousePos );
}
else
{
if ( notifications_.size() == cNotificationNumberLimit )
notifications_.erase( notifications_.end() - 1 );
notifications_.insert( notifications_.begin(), NotificationWithTimer{ notification } );
isHovered = ImGui::IsWindowHovered();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


void RibbonNotifier::drawNotificationHistoryButton( float scaling )
{
if ( !notifications_.empty() || notificationsHistory_.empty() )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why check both, should check only notificationsHistory_

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think it's necessary to show history button if we are already showing notifications
(notificationsHistory_ is empty only until first notification)

}
requestClosestRedraw_();
const float size = ImGui::GetTextLineHeight() + 10.f * scaling * 2.f;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is 10&scaling*2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reworked


ImGui::Begin( name.c_str(), nullptr, flags );

iconsFont = RibbonFontManager::getFontByTypeStatic( RibbonFontManager::FontType::Icons );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why take it second time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 111 to 112
bool isHovered = false;
isHovered = ImGui::IsWindowHovered();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool isHovered = ImGui::IsWindowHovered();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 116 to 125
if ( ImGui::IsMouseClicked( ImGuiMouseButton_Left ) )
{
for ( int i = int( notificationsHistory_.size() ) - 1; i >= 0; --i )
{
const auto& nwt = notificationsHistory_[i];
for ( int j = 0; j < nwt.sameCounter; ++j )
addNotification_( notifications_, nwt.notification );
}
requestClosestRedraw_();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if click several times? will notifications_ timer work and close them automatical?

@@ -35,8 +35,8 @@ class RibbonNotifier
public:
// adds new notification for drawing
void pushNotification( const RibbonNotification& notification );
// draws all present notifications
void drawNotifications( float scaling );
// main draw function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please write more detailed comment, what does it draw

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 28 to 29
const float cWindowRounding = 4.f;
const float cWIndowSpacing = 20.f;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have MRRibbonConstants.h mb use constants form there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 68 to 69
if ( auto menu = getViewerInstance().getMenuPluginAs<RibbonMenu>() )
notificationsPosX += float( menu->getSceneSize().x );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of dynamic casting RibbonMenu mb take it as argument from draw? or set as class field? or better sceneSize

@@ -209,7 +407,23 @@ void RibbonNotifier::drawNotifications( float scaling )
ImGui::PopStyleVar( 4 );
currentPos.y -= window->Size.y;
}
filterInvalid_( numInvalid );

historyBtnPosY_ = currentPos.y - cWIndowSpacing * scaling;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we update it each frame? should be always in the same position?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, button is located above upper-left corner of notifications

…o #4657_notifiaction_history

# Conflicts:
#	source/MRViewer/MRRibbonMenu.cpp
#	source/MRViewer/MRRibbonNotification.h
@ABSitf ABSitf merged commit ab5728e into master Sep 23, 2024
28 checks passed
@ABSitf ABSitf deleted the #4657_notifiaction_history branch September 23, 2024 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants