5.2  Anchors

The anchor of a display element is the point of the element which is used for positioning. If you place an element at the coordinates (10, 10), then the element will be positioned with its anchor lying on that point.

The default anchor is the top-left corner, which is called nw in gDesklets, because it is in the north-west, if you assume north pointing upwards.

By changing the anchor property to another value, you can easily achieve some fancy layouts. For instance, by setting the anchor to se, and placing the element at (100%, 100%), you can align the element with the bottom-right corner of its container.

The valid anchor positions are:

  • nw - north-west, the top-left corner
  • n - north, the middle of the top edge
  • ne - north-east, the top-right corner
  • e - east, the middle of the right edge
  • se - south-east, the bottom-right corner
  • s - south, the middle of the bottom edge
  • sw - south-west, the bottom-left corner
  • w - west, the middle of the left edge
  • center - the center of the element