Skip to content

Add Annotation widget #27

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 16 commits into from
Mar 25, 2021
Merged

Add Annotation widget #27

merged 16 commits into from
Mar 25, 2021

Conversation

kmatch98
Copy link
Contributor

@kmatch98 kmatch98 commented Mar 23, 2021

annotation_example

Add annotation widget, this allows annotations relative to a widget or freeform.

(I messed up the previous PR, so I am adding it back here.)

@kmatch98 kmatch98 changed the title Annotation pr Add Annotation widget Mar 23, 2021
@jposada202020
Copy link
Contributor

@kmatch98 Well :), I like very much this, makes me remember matplotlib. anyway, testing this with the Cartesian plane, make me rework all the local coordinates, now cartesian widgets respond as a widget. I will do some more testing if you want. Thanks

@jposada202020
Copy link
Contributor

Tested in

Adafruit CircuitPython 6.2.0-beta.4 on 2021-03-18; Seeeduino Wio Terminal with samd51p19

image

Testing Code

from adafruit_displayio_layout.widgets.cartesian import Cartesian
import board
import displayio
from adafruit_display_text import label
from adafruit_bitmap_font import bitmap_font
import terminalio
from adafruit_displayio_layout.widgets.annotation import Annotation


MEDIUM_FONT = bitmap_font.load_font("fonts/Helvetica-Bold-16.bdf")

display = board.DISPLAY
my_group = displayio.Group(max_size=10)

car = Cartesian(x=150,
                y=40,
                display_color=0x98fb98,
                width=100,
                height=100,
                xrange=(0, 50),
                yrange=(0, 50),
                subticks=True,
                tick_color=0x44FF99,
                axes_color=0x990099,
                axes_stroke=2,
                pointer_color=0xFF4400, )

my_group.append(car)

plane_annotation = Annotation(
    widget=car,  # positions are relative to the switch
    text="widget.bounding_box",
    anchor_point=(0.0, 0.0),
    # delta_x=2,
    text_color=0xFFA500,
)
my_group.append(plane_annotation)
plane_annotation1 = Annotation(
    widget=car,  # positions are relative to the switch
    text="[0,0,150,40]",
    anchor_point=(0.0, 0.0),
    text_under=True,
    text_color=0xFFA500,
)
my_group.append(plane_annotation1)

plane_annotation2 = Annotation(
    widget=car,  # positions are relative to the switch
    text="Origin [0,0]   ",
    anchor_point=(0.0, 1.0),
    delta_y=4,
    text_under=False,
    text_color=0xFFA500,
)
my_group.append(plane_annotation2)

plot_area = Annotation(
    font=MEDIUM_FONT,
    widget=car,  # positions are relative to the switch
    text="Plot Area",
    anchor_point=(0.5, 0.5),
    position_offset=(-35, 0),
    text_under=False,
    delta_x=0,
    delta_y=0,
    line_color=0x00A5FF,
    text_color=0x00A5FF,
)
my_group.append(plot_area)

text = "Axes Y"
text_area = label.Label(terminalio.FONT,
                        text=text,
                        label_direction="UPR",
                        x=270,
                        y=120,
                        background_color=0xA5CADD,
                        color=0x6E266E,

                        )
my_group.append(text_area)

text2 = "Axes X"
text_area2 = label.Label(terminalio.FONT,
                         text=text2,
                         x=180,
                         y=180,
                         background_color=0xA5CADD,
                         color=0x6E266E,

                         )
my_group.append(text_area2)
display.show(my_group)

# Conflicts:
#	docs/api.rst
#	docs/examples.rst
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

I tested this successfully with

Adafruit CircuitPython 6.2.0-beta.4 on 2021-03-18; Adafruit PyPortal with samd51j20

Code looks good to me.

These annotations are really great looking. I like how you allowed it to attach onto another widget. We can use this in future example scripts to highlight the features of new widgets.

Thank you @jposada202020 for testing this out as well.

@kmatch98
Copy link
Contributor Author

I’m thinking it will be useful for GUIs that might have a “Help” or “?” Button.

Thanks @jposada202020 and @FoamyGuy for reviewing and trying it out and merging!

@FoamyGuy FoamyGuy merged commit 168cbf6 into adafruit:main Mar 25, 2021
@kmatch98
Copy link
Contributor Author

And @jposada202020 i like how you did the over and under annotation. I never thought of that!

@jposada202020
Copy link
Contributor

@FoamyGuy @kmatch98 Team work! :)

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Mar 25, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes to 2.0.8 from 2.0.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_Display_Shapes#32 from Lukas1337/master
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout to 1.7.0 from 1.6.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#27 from kmatch98/annotation_PR
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_Layout#26 from kmatch98/dial_rotation

Updating https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing to 1.14.1 from 1.14.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_FeatherWing#69 from jfurcean/expose_cs_pins
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