Skip to content

Geometry

Carsten Eckelmann edited this page Mar 22, 2019 · 3 revisions

Fyne apps are based on 1 canvas per window. Each canvas has a root CanvasObject which can be a single widget or a Container for many sub-objects whose size and position are controlled by a Layout.

Each canvas has its origin at the top left (0, 0) every element of the UI may be scaled depending on the output device and so the API does not describe pixels or exact measurements. The Position(10, 10) may be 10 pixels right and down from the origin on, for example, a 96DPI monitor but on a HDPI (or "Retina") display this will probably be 15 pixels or more. As Fyne is based entirely on vector graphics this should never be an issue - but if you start loading bitmaps you should bear this in mind. To get "pixel perfect" rendering you need to multiply CanvasObject.Size by Canvas.Scale.

Every position referenced by a CanvasObject is relative to it's parent. This is important for layout algorithms but also for developers in situations such as the Button.OnClicked(MouseEvent) handlers. Here the the X/Y coordinates will be calculated from the top left of the button not the overall canvas. This is designed to allow code to be as self-contained as possible.