3.3.3 Panels
3.3.3.1 HPanel
3.3.3.2 VPanel
3.3.3.3 Group  Panel
3.3.3.4 Tabs  Panel
On this page:
Tabs  Panel
Tabs  Panel.at_  selection
Tabs  Panel.Style
Tabs  Panel.Style.no_  border
Tabs  Panel.Style.can_  reorder
Tabs  Panel.Style.can_  close
Tabs  Panel.Style.new_  button
Tabs  Panel.Style.flat_  portable
Tabs  Panel.Action
Tabs  Panel.Action.select
Tabs  Panel.Action.new
Tabs  Panel.Action.close
Tabs  Panel.Action.reorder

image   image

class

class gui.TabsPanel():

  implements WindowChildView

  constructor (

    choices :: ObsOrValue.of(List),

    ~selection: selection :: ObsOrValue.of(Any),

    ~action: action :: (TabsPanel.Action, List, maybe(Any)) -> ~any = values,

    ~choice_to_label: choice_to_label :: Any -> Any = values,

    ~choice_equal: choice_equal :: Function.of_arity(2) = (_ == _),

    ~align: align :: ObsOrValue.of(View.Alignment) = [#'center, #'center],

    ~styles: styles :: ObsOrValue.of(List.of(TabsPanel.Style)) = [],

    ~enable: enable :: ObsOrValue.of(Boolean) = #true,

    ~spacing: spacing :: ObsOrValue.of(View.SpacingInt) = 0,

    ~margin: margin :: ObsOrValue.of(View.Margin) = [0, 0],

    ~min_size: min_size :: ObsOrValue.of(View.Size) = [#false, #false],

    ~stretch: stretch :: ObsOrValue.of(View.Stretch) = [#true, #true],

    ~window_callbacks: window_callbacks :: maybe(WindowCallbacks) = #false,

    child :: ObsOrValue.of(WindowChildView && !WindowView),

    ...

  )

 

property

property (tabs :: gui.TabsPanel).at_selection :: Obs

Creates a tab panel where choices provides the number and identity of choices, and selection determines which of the tabs is selected.

The TabsPanel.at_selection property returns an observable that is updated whenever the panel changes through an action (as also reported via action) or via selection as an observable.

The choice_to_label function converts an item in choices to a label to be shown for the tab, and choice_equal defines equality for choice identities. By default, choices is expected to be a list of View.LabelString, since choice_to_label is the identity function.

When the tab selection changes, action is called as

action(what, choices, selected)

where what describes the action, choices is the list of choices at the time of the action, and selected is the tab (if any) selected after the action.

To change the content of a TabsPanel based on its selection, supply a child that is an observable derived from one supplied as selection.

A tab panel style option.

  • #'no_border: No border is drawn around the panel content. A borderless tab panel typically has a different look for its tabs, too.

  • #'can_reorder: Allows the user to reorder tabs by dragging them.

  • #'can_close: Allows the user to close tabs by clicking a close icon on a tab.

  • #'new_button: Include a button to create a new tab, if supported. A tab-creation button is always available with #'flat_portable.

  • #'flat_portable: Use a platform-independent implementation of the tab control, which provides more consistent functionality and style across platforms.

enumeration

enum gui.TabsPanel.Action

| select

| new

| close

| reorder

A tab panel action provided to the ~action callback function of a Panel.