Thanks to visit codestin.com
Credit goes to github.com

Skip to content

adding color properties #26

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

Merged
merged 3 commits into from
Jan 31, 2021
Merged

Conversation

FoamyGuy
Copy link

This adds properties to be able to change fill_color, outline_color, label_color, and their "selected" counterparts.

Previously color changing did not take effect immediately, and many of relevant properties were private.

A new example examples/display_button_color_properties has been added to test and illustrate usage of the new properties

@FoamyGuy FoamyGuy requested a review from a team January 23, 2021 18:11
@FoamyGuy
Copy link
Author

Forgot to mention: this change resolves #25

Copy link

@jposada202020 jposada202020 left a comment

Choose a reason for hiding this comment

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

Tested using display_button_simpletest.py on:
WIO Terminal
and
M4 Express using a SSD1306 128x32 OLED Display

Works well on both

@kmatch98
Copy link

I read through the code and it looks like it solves the problem at hand.

There are a couple of situations below that could cause unexpected behavior but I’m not sure it’s worth added complexity to resolve them.

Here are three (probably low probability) situations to consider:

  • if the fill_color is changed while the button is selected, I think the color will be updated to fill color.
  • if selected_color is changed while the button is selected, the color will not be updated
  • when the button is first instanced, and selected_color is None, then the selected color is automatically selected. Do you want the same behavior if the the fill_color is updated and the selected_color was not defined?

Even with all these comments above, this PR resolves the key issue that it is trying to solve.

@FoamyGuy
Copy link
Author

Great feedback thanks for having a look @kmatch98. Thank you @jposada202020 for trying it out!

I think you are right the colors will not get updated properly while the button is selected. I will work on a fix for both of those today.

I intended to leave the selected_color alone when updating the fill_color. I thought it might make it confusing if user was trying to set a different specific selected_color and fill_color but did them "out of order" and wound up overwriting their own selected_color with the new inverse.

I think it would be great to expose an easy way for user code to set selected_color to the inverse in the same way it does if initialized as None. This way the user can easily specify that the want to do that with their new fill_color, but it won't happen "silently".

Or if it was a setter function instead of a property it could accept a default argument to control the automatic inverse -> selected_color behavior?

@kmatch98
Copy link

Read through changes but did not verify on hardware.

Good updates to the color setters to eliminate the unexpected behavior when selected or unselected. Looks good to me.

@FoamyGuy
Copy link
Author

Thank you both for looking into it. Going to merge this one to get ready for some other updates that will work with things in the new Layouts library better.

@FoamyGuy FoamyGuy merged commit 64c79a9 into adafruit:master Jan 31, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Feb 1, 2021
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.

3 participants