Table of Contents

Class ViewSwitcher

Namespace
PluginUI
Assembly
PluginUI.dll

Shows one of its children at a time, over the whole content area, chosen by SelectedIndex or by a bound Parameter: for example the settings panel of the oscillator type selected in a menu. Unlike TabView it draws no tabs. Equivalent of VSTGUI's UIViewSwitchContainer.

public class ViewSwitcher : Panel
Inheritance
ViewSwitcher
Inherited Members

Examples

var panels = new ViewSwitcher { Parameter = Parameters[model.OscillatorType] };
panels.Add(sinePanel, sawPanel, wavetablePanel);

Remarks

With a parameter, the view index follows the parameter value: the step index for a discrete parameter (StepCount > 0), otherwise the value spread over the children. Indexes beyond the last child show the last child. Setting SelectedIndex edits the parameter (one complete gesture).

Hidden views stay attached and keep their state (scroll position, text being typed); they are neither drawn nor hit-tested. In PluginUIEditor, change SelectedIndex (or the bound preview parameter) to edit each view.

Constructors

ViewSwitcher()

Creates an empty switcher.

public ViewSwitcher()

Properties

Parameter

Parameter choosing the view (null: SelectedIndex alone decides).

public IParameter? Parameter { get; set; }

Property Value

IParameter

SelectedIndex

Index of the visible child (-1 when there is no child).

public int SelectedIndex { get; set; }

Property Value

int

SelectedView

Visible child, or null.

public UIElement? SelectedView { get; }

Property Value

UIElement

Methods

IndexForValue(double, int)

View index for a normalized value of Parameter.

public int IndexForValue(double normalized, int viewCount)

Parameters

normalized double

Normalized value in [0, 1].

viewCount int

Number of views.

Returns

int

The index, in [0, viewCount − 1], or -1 when there is no view.

MeasureOverride(Size)

Natural size of the content for the available size (margins excluded).

protected override Size MeasureOverride(Size available)

Parameters

available Size

Returns

Size

OnAttached()

Called when the element joins a host (subscribe to external events here).

protected override void OnAttached()

OnDetached()

Called when the element leaves its host (unsubscribe here).

protected override void OnDetached()

Events

SelectionChanged

Raised when the visible child changes (argument: its index).

public event Action<ViewSwitcher, int>? SelectionChanged

Event Type

Action<ViewSwitcher, int>