Vixen
02b45cc4
csharp
public sealed class RadialMenu

A pie menu: wedges round a centre, aimed with the pointer.

Read the guide page for this →

Remarks

Blender's pie menu, which is the fastest menu anybody has shipped and is fast for one reason. A drop-down costs a read — the items are in an order you have to scan — and a pie costs a direction. After a week the direction is muscle memory and the menu is a flick; the items being in fixed positions is the whole mechanism, which is why nothing here sorts or filters what it was given.

⚠ Two gestures, and both have to work or neither is used. Press the key, then click a wedge is what somebody does the first fifty times, while they are still reading the labels. Hold the key, flick, release is what they do afterwards, and it is the one that makes the menu worth having. They are the same menu in the same place — see Hold.

⚠ The dead zone in the middle is what makes the release gesture safe. A release without having moved must do nothing: somebody who pressed the key and let go, or who opened the menu to look at it, has not chosen anything. Without a dead zone the wedge under the resting cursor is chosen by the tiniest tremor, which is a menu that runs commands nobody asked for.

⚠ Wedges are placed clockwise from the top and are never reordered. Blender's own order is west-first, which is better for four items and worse for six; what matters more than either is that a given menu puts a given item in the same place every time, so this is the simple rule rather than the clever one.

Fields and properties (6)

  • protected override string TagName

    The element name this type answers to when a caller does not choose one.

  • public IReadOnlyList<RadialItem> Items

    The wedges, clockwise from the top.

  • public int Highlighted

    Which wedge the pointer is aimed at, or -1 for none.

  • public float Radius

    How far the ring is from the centre, in pixels.

  • public float DeadZone

    How far the pointer must travel before it is aiming at anything.

  • public bool Hold

    Whether the menu was opened by a key that is still down.

Events (1)

Methods (8)

  • protected override void OnCreated()

    Builds whatever this element is made of, once, as it joins a document.

  • protected override void OnRemoved()
  • public void Clear()

    Empties it.

  • public RadialItem AddItem(string? label = null)

    Adds a wedge.

  • public void OpenAt(float x, float y, bool hold = false)

    Opens it centred on a point in document space.

  • public bool Accept()

    Runs the aimed wedge and closes.

  • public void Aim(int index)

    Aims at a wedge by index, as the keyboard does.

  • public int WedgeAt(Vector2 offset)

    Which wedge a direction from the centre points at.

Used by (2)

  • EditorApplicationVixen.Editor.App
  • SceneMenuTestsVixen.Editor.App.Tests