-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
🚧Create ShapeButton control #213
Comments
This issue has been automatically marked as stale due to the lack of activity for 60 days. The issue will be closed after 7 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale due to the lack of activity for 60 days. The issue will be closed after 7 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale due to the lack of activity for 60 days. The issue will be closed after 7 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale due to the lack of activity for 60 days. The issue will be closed after 7 days if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale due to the lack of activity for 60 days. The issue will be closed after 7 days if no further activity occurs. Thank you for your contributions. |
This stale issue has been closed due to a lack of activity. |
I have done the items below . . .
Description
Create a button control that contains all of the mouse functionality of the regular
Button
control. This will basically be aButton
without theLabel
.Eventually, this button can hold different shapes. But for right now, only implement a rectangle shape.
Also, refactor the
Button
class to inherit all of the newShapeButton
functionality with the extra label functionality added. This will simplify testing and implementation.Also, improve mouse over calculations with the
ShapeButton
by making sure that the mouse is not considered to be over the button if it is on the outside of the radius of one of the corners but inside the rectangle bounds of the button. This can easily be done by maintaining circle data for each corner and checking if the mouse is inside of the corner circle relative to if its contained by the entire control bounds vs the rectangle formed by the corner circle centers.Rounded Corner Rectangle Point Containment
This GIF demonstrates how to figure out if a point in space, (mouse location) is contained in a rounded corner rectangle.
This is how it's calculated in the rectangle shader.
Containment Concept
The idea here is to use the information in the GIF above to figure out if a point (mouse location) is contained inside and ONLY inside the Rounded Corner Rectangle. What this means is that if the point is located outer bounds and not in the invalid inner zones, then the point MUST be inside the shape.
The issue is trying to figure out if the mouse is a corner of the rectangle but not outside of the radius for that corner.
To figure out if the point is inside of a corner but not inside the invalid zone, check if the point is contained by the circle, and in the quadrant of that circle, and if the distance is less than the radius of the corner. If all of those conditions are true, then the point is inside of the shape.
If used for mouse location containment, (which is for this scenario), most of the time the mouse will not be inside of the outer bounds of the control. Also, most of the time, the mouse will pass into the outer bounds area via the longer horizontal or vertical sections of the button rather than by the corners themselves. This means the order of checks can be optimized based on the majority of mouse entries over the control.
Optimization 1:
If the point is outside of the outer bounds, then there is no point in checking anything else. The point cannot be contained.
Optimization 2:
If the point is inside of the inner bounds, then it HAS to be in the shape and it is impossible that the mouse could be in the invalid inner zones. This means you do not have to do further calculations of any of the corners.
Optimization 3:
If the point is in any of the corner circles, then it cannot be in any other corner circle so other corner circle calculations do not need to be performed.
Use the following order of checks to best take advantage of the optimizations above:
💡TIP💡
Create an exact copy of the
Button
code and refactor it appropriately by removing the label functionality and cleaning things up. This goes for theButton
unit tests as well. Once this is cleaned up, refactoring theButton
class to inherit from theShapeButton
will be much easier.Acceptance Criteria
This issue is finished when:
ShapeButton
created and workingShapeButton
contains no text or label optionsButton
class refactor to use the newShapeButton
ToDo Items
Issue Dependencies
No response
Related Work
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: