"""Bookmarks — labeled fit-to-screen markers for the viewer.

A bookmark is a named bbox attached to a cell. In the Lumicron viewer it
appears in the Bookmarks panel, and tapping it fits-to-screen on the
component. Two flavors:

    1. Free-floating: `c.add(lm.Bookmark("name", at=(x, y)))`
    2. Attached to a placement chain: `.add_bookmark(name="...")`
"""
import lumicron as lm
import lumicron.pdks.elyon_demo.all as pdk


@lm.pcell
def BookmarkDemo():
    c = lm.CELL("BookmarkDemo")

    pad = lm.Rectangle(x_dim=80, y_dim=80, layer=pdk.LAYER.MTL1)

    # Bookmark attached to a placement — auto-fits the placed pad in the viewer.
    c.add(pad)
    c.Place(pad).at((0, 0)).add_bookmark(name="pad_1")

    c.add(pad)
    c.Place(pad).at((300, 0)).add_bookmark(name="pad_2", group="pads")

    # Free-floating bookmark — bookmarks an arbitrary location with notes.
    c.add(lm.Bookmark(
        "alignment_mark",
        at=(150, 150),
        notes="Coarse-align target — visible at 5× under microscope.",
    ))
    return c


if __name__ == "__main__":
    BookmarkDemo().to_gds("bookmark_demo.gds")
