TabbedView2:
Filter:
TabbedView2/Classes (extension) | GUI > Views

TabbedView2
ExtensionExtension

A Tabbed View which holds TabbedViewTabs

Description

There are extensive explanations in the Examples section on how to use TabbedView2 with its many configuration options .

Version and Author

version: 1.05 , Oct 28, 2016

author: Jost Muxfeldt

New Features

TabbedView2 has a number of new features compared with TabbedView.

NOTE: Try the DEMO Code to test all the features, and go through the EXAMPLES.

Differences to older TabbedView

The new TabbedView2 now holds an Array of TabbedViewTab instances. The creation syntax is just like other Views:

You then add defaults, followed by the individual tabs, setting their individual instance variables.

NOTE: You never dierectly create TabbedViewTab instances, but rather use TabbedView2.add to add tabs. Many instance variables for TabbedView, are now (arrays of) default values for TabbedViewTab instances. TabbedViewTab instances can in turn override those defaults. This way you can customize individual tabs.

See TabbedViewTab .

Example:

Old Syntax

New Syntax

Class Methods

.new

create a Tabbed View

Arguments:

parent

a parent view. if nil, then a new window is created

bounds

Rect . if nil then the parent Rect is used

Returns:

returns a TabbedView2

Convenience Creation Methods

Instance Methods

Views and Windows

.view

Returns:

the container for all the views

.alwaysOnTop

Arguments:

boolean

If a window was created automatically, then this sets whether it is always on top.

.window

If a window was created automatically, then this returns the window.

NOTE: If the last tab of this window is closed or dragged (under QT only), then the window closes as well.

.tabAt

get the TabbedViewTab instance at index.

Returns:

a TabbedViewTab instance. A TabbedViewTab instance responds to .asView, so it can be used to fill a parent argument, just like any other view can.

.tabViews

Returns:

an array of TabbedViewTab instances.

.resize

sets the resize flag (1-9 ) of the enclosing view. see Resize behaviour

.clone

Creates a new TabbedView2, copying all of the settings of the current on, other that the tabs. This method is also used internally when detaching tabs under QT.

Arguments:

parent

a parent view. if none, a new window is created.

x

If a new window is created, it will be created offset from this x position by 20px (mainly for internal use)

y

If a new window is created, it will be created offset from this y position by 20px (mainly for internal use)

Returns:

The new TabbedView2 instance.

Adding, Removing, Dragging, and Detaching Tabs

NOTE: Double-Clicking and Dragging.Double-clicking or dragging a tab widget within its view will change the tab followEdges or position (\left, \top, \right, or \bottom), as well as changing the order of the tabs; You can use methods tabPosition and followEdges to do the same programmatically. To prevent dragging or double clicking, use lockPosition and followEdges=false, or dragTabs=false.

NOTE: DraggingTabs between Views and Windows.Under QT, you can cmd-drag (or ctrl-drag) a tab between different TabbedView2 instances, even if they are in different window.

NOTE: DetachingTabs.Under QT, you can right click to detach a tab. In reality, this clones the parent TabbedView2, places the clone in its own window, and then migrates the tab into the new view, using Qt's set Parent. If the last Tab of this window is closed or dragged, then the window closes as well.

.add

adds a TabbedViewTab instance

Arguments:

label

string, the label

index

int, (optional) the index at which the tab is inserted (if nil, add to the end)

scroll

Boolean, default false. Must be set before creation of tab.

Returns:

the new TabbedViewTab

.insert

inserts a TabbedViewTab instance at index

Arguments:

index

the index at which the tab is inserted

label

(describe argument here)

scroll

Boolean, default false. Must be set before creation of tab.

Returns:

the new TabbedViewTab

.dragTabs

Boolean or Function: {arg thisView; return boolean}. default: true; Set to false to disable regular tab dragging (position or order changing by drag);

.detachedClosable

if tabs are detached, you can lose a tab if you close its window. so this allows you to prevent that by setting it to false. The window will still close when the last tab has been dragged out of it.

.demo

quickly creates a bunch of tabs. for texting TabbedView2 settings Tab labels will be i++string

Arguments:

i
string

.removeAt

remove tab at Index

Arguments:

index

the index of the tab to be removed

.focus

selects one of the tabs

Arguments:

index

int, the index to focus

.activeTab

Returns:

returns the focused tab

Set tabPosition and followEdges

NOTE: Double-clicking or dragging a tab widget will change the tab followEdges or position (\left, \top, \right, or \bottom), or the order of the tabs. You can use methods tabPosition and followEdges to do the same programmatically.

.tabPosition

Arguments:

symbol

\left, \top, \right, or \bottom.

.lockPosition

Lockes the \left, \top, \right, or \bottom position of the tabs. You still can change the order of the tabs themselves by dragging.

Arguments:

bool

default false.

.followEdges

Boolean or Function: {arg thisView; return boolean}. Set tabs parallel or perpendicular to container edges. default true. (Set tabs parallel);

.lockEdges

Prevents Double-Click changing of followEdges.

Arguments:

bool

default false.

Examples: Set tabPosition and followEdges

Setting the position or followEdges instance variables

Auto-Archiving a TabbedView2 State

NOTE: In order to archive tab positions, their labels must be unique.

NOTE: Does not support detached Tabs

.autoArchive

Automatically saves the state of the TabbedView2 to given path in the Archive.

NOTE: If the number of saved \indexes is different than the number of tabs, the saved \indexes array will be ignored and reset.

Arguments:

symbols

symbol1, symbol2, symbol3, ...

.archiveKeys

Array: Determines which keys will be archived when autoArchive is enabled.

default=[\indexes, \followEdges, \tabPosition, \tabFocus]

Arguments:

array

Array of Symbols, may include only [\indexes, \followEdges, \tabPosition, \tabFocus]

.saveStateToArchive

Saves the state of the TabbedView2 to given path in the Archive.

Arguments:

symbols

symbol1, symbol2, symbol3, ...

.restoreStateFromArchive

Restores the state of the TabbedView2 from given path in the Archive.

NOTE: If the number of saved \indexes is different than the number of tabs, the saved \indexes array will be ignored and reset.

Arguments:

symbols

symbol1, symbol2, symbol3, ...

Setting Colors

NOTE: Many of these methods take arrays of Color instances. These colors are used as the defaults for new tabs. If the array is shorter than the amount of tabs, then the color choice will cycle through the array. However, TabbedViewTab instances will retain their color when their positions change, and they can also have individual color definitions, which override the defaults. These defaults are only there in order to prevent repeating code when creating new tabs.

.resetColors

reset the tab colors, cycling through default color arrays.

WARNING: This will reset individual colors that were overriden in the tab instances!

.labelColors

Arguments:

colorArray

Array of Colors sets the default colors of the tab widgets. New tabs will cycle through these colors, though these can be overridden in the TabbedViewTab instance.

.unfocusedColors

Arguments:

colorArray

Array of Colors sets the default unfocusedColors colors of the tab widgets. New tabs will cycle through these colors, though these can be overridden in the TabbedViewTab instance.

.backgrounds

Arguments:

colorArray

Array of Colors sets the default background colors of the Composite/Scroll Views. New tabs will cycle through these colors, though these can be overridden in the TabbedViewTab instance.

.stringColors

Arguments:

colorArray

Array of Colors sets the default label string colors. New tabs will cycle through these colors, though these can be overridden in the TabbedViewTab instance.

.stringFocusedColors

Arguments:

colorArray

Array of Colors sets the default focused label string colors. New tabs will cycle through these colors, though these can be overridden in the TabbedViewTab instance.

Setting Geometry and Fonts

NOTE: tabWidth and labelPadding are defaults which can be overridden in individual tabs

.refresh

recalculate all geometry values and redraw tabs

.tabWidth

Arguments:

int

int or \auto ; a fixed tab width, or "auto" for automatic tab width (default "auto", unless using themes). Can be overridden in in the TabbedViewTab instance.

.labelPadding

Arguments:

int

if autosizing is on, then this determines left and right padding from the label text. Can be overridden in in the TabbedViewTab instance.

.tabHeight

Arguments:

int

int or \auto . a fixed tab height, or "auto" for automatic tab height (default "auto", unless using themes)

.tabCurve

Arguments:

int

the radius in pixels of the rounded tab corners

.clickbox

Arguments:

int

set the size of the clickbox and detach icons in pixels. default is 15

.swingFactor

Arguments:

point

Point ; a multiplication factor for a string/tab width for GUI.swing only. default Point(0.52146,1.25)

.font

set the font

Examples

Usage:

use CompositeView style GUI

use FlowView style GUI

Quick styling with variations on *new:

(There are some color differences for swing)

Drag objects from one tab to another (under cocoa and qt only at the moment):

Add, removeAt, insert tabs

defaults on *new, but other themes use fixed widths:

Auto-Archiving Tabs

NOTE: Does not support detached Tabs

resize

Nest TabbedView2 & use scrolling

uses scroll:true in the inner tab

User functions: focus and unfocus

turn on/off scopes , e.g.

Swing Special: focusFrameColor_(color) and unfocusTabs_(bool)

The tabs are drawn with user view which have a clear focus frame on Cocoa. On Swing, the frame cannot be made clear, so by default the tabs are unfocused after clicking. You can change this if it interferes with your tabbing scheme.

Fixed tab widths and \auto tab widths

tabWidth defaults to \auto on *new, but other themes use fixed widths:

Set Font

Swing fonts only work within certain limits for now. use swingFactor_ to adjust the conversion.

Set colors very specifically to your own taste using set methods

Adjust padding and curves

labelPadding only has an effect on auto width

Adjust tab height and curves

Demo

Execute the code below to test all the features and parameters.

All Features and Parameters