ModraUp Ruby API Documentation Ruby API Reference

Class: UI::Toolbar

Inherits:
Object
  • Object
show all
Includes:
Enumerable

Overview

Plugin Toolbar: A set of UI::Command objects, displayed as draggable cards in the studio top bar (not floating Qt toolbars).

Examples:

toolbar = UI::Toolbar.new "Test"
cmd = UI::Command.new("Beep") { UI.beep }
cmd.small_icon = File.join(__dir__, "icons", "beep.png")
toolbar.add_item(cmd)
toolbar.show

Class Method Summary # collapse

  • .new(name) ⇒ UI::Toolbar
    Creates a toolbar by name. The optional category argument is a ModraUp extension. Reusing a name shares the existing toolbar. Passing category explicitly updates its category. Omitting it preserves the existing category. On first creation, the default is the Modeling tab (Ruby string "\u5efa\u6a21"). An empty category also selects that tab. Pass "Layout" or "\u51fa\u56fe" for the drawing workspace tab. Other names create a tab after it, or reuse a tab of the same name.

Instance Method Summary # collapse

Class Method Details

Toolbar.new(name) ⇒ toolbarToolbar.new(name, category) ⇒ toolbar

Creates a toolbar by name. The optional category argument is a ModraUp extension. Reusing a name shares the existing toolbar. Passing category explicitly updates its category. Omitting it preserves the existing category. On first creation, the default is the Modeling tab (Ruby string "\u5efa\u6a21"). An empty category also selects that tab. Pass "Layout" or "\u51fa\u56fe" for the drawing workspace tab. Other names create a tab after it, or reuse a tab of the same name.

Parameters:

  • name (String)
  • category (String) Tab name. Defaults to "\u5efa\u6a21" (Modeling).

Returns:

  • (UI::Toolbar)
Note: ModraUp extension. SketchUp only supports name.

Examples:

Default Modeling

toolbar = UI::Toolbar.new "Test"

Customize tab title

toolbar = UI::Toolbar.new "Test", "My category"

Instance Method Details

toolbar.name ⇒ String

Toolbar name.

Returns:

  • (String)

Examples:

UI::Toolbar.new("Test").name  #=> "Test"

toolbar.category ⇒ String

Returns the current category name. The default is "\u5efa\u6a21" (Modeling). Toolbars with the same name share their category.

Returns:

  • (String)
Note: ModraUp extension.

Examples:

UI::Toolbar.new("Test").category  #=> "\u5efa\u6a21"

toolbar.add_item(command) ⇒ self

Add the UI::Command to the toolbar. The icon should be set before this.

Parameters:

  • command (UI::Command)

Returns:

  • (UI::Toolbar)

Examples:

tb = UI::Toolbar.new("Test")
tb.add_item(UI::Command.new("Beep") { UI.beep })

toolbar.add_separator ⇒ self

Add a separator.

Returns:

  • (UI::Toolbar)

Examples:

UI::Toolbar.new("Test").add_separator

toolbar.show ⇒ nil

Display the toolbar (studio card, not a floating Qt toolbar).

Returns:

  • (nil)

Examples:

UI::Toolbar.new("Test").show

toolbar.hide ⇒ nil

Hide the toolbar.

Returns:

  • (nil)

Examples:

UI::Toolbar.new("Test").hide

toolbar.visible? ⇒ Boolean

Visibility.

Returns:

  • (Boolean)

Examples:

UI::Toolbar.new("Test").visible?

toolbar.restore ⇒ nil

Same as #show.

Returns:

  • (nil)

Examples:

UI::Toolbar.new("Test").restore

toolbar.each {|command| } ⇒ selftoolbar.each ⇒ Enumerator

Iterate through the added UI::Command instances.

Returns:

  • (self, Enumerator)

Yields:

  • @yieldparam command [UI::Command]

Examples:

UI::Toolbar.new("Test").each { |cmd| puts cmd.menu_text }

toolbar.length ⇒ Integer

Number of commands.

Returns:

  • (Integer)

Examples:

UI::Toolbar.new("Test").length

toolbar.size ⇒ Integer

Alias for #length.

Returns:

  • (Integer)

Examples:

UI::Toolbar.new("Test").size

toolbar.get_last_state ⇒ Integer

Last Displayed State: TB_HIDDEN / TB_VISIBLE / TB_NEVER_SHOWN.

Returns:

  • (Integer)

Examples:

UI::Toolbar.new("Test").get_last_state