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

Use drawOnState() for buttons precessing and cache buttons' position for event handler loop #9223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Districh-ru
Copy link
Collaborator

@Districh-ru Districh-ru commented Oct 21, 2024

This PR affects most of the dialogs in the engine including the main menu.

It replaces le.isMouseLeftButtonPressedInArea( button.area() ) ? button.drawOnPress() : button.drawOnRelease(); with button.drawOnState( le.isMouseLeftButtonPressedInArea( buttonArea ) ); and do buttonArea cache not to call .area() with all its calculations on every loop.

It also modifies some dialogs that can be also called by the mouse right click to have its own event handler loop to reduce some checks (e.g. unit dialog, build dialog). And in some dialogs it skips the possibly unused buttons initialization making them unique_ptr, in example in Hero dialog: DISMISS and PATROL buttons.

While testing this PR you should check rendering of the buttons (press/release) and their interaction with the mouse cursor (right press, left click).

This PR does not fix rendering issues that are present in the master build.

@Districh-ru Districh-ru added the improvement New feature, request or improvement label Oct 21, 2024
@Districh-ru Districh-ru added this to the 1.1.4 milestone Oct 21, 2024
@Districh-ru Districh-ru self-assigned this Oct 21, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

src/fheroes2/game/game_mainmenu.cpp Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement New feature, request or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant