Constructor

Bubble

new Bubble(workspace, content, shape, anchorXY, bubbleWidth, bubbleHeight)

Class for UI bubble.

Parameter

workspace

Blockly.WorkspaceSvg

The workspace on which to draw the bubble.

Value must not be null.

content

Element

SVG content for the bubble.

Value must not be null.

shape

Element

SVG element to avoid eclipsing.

anchorXY

goog.math.Coordinate

Absolute position of bubble's anchor point.

Value must not be null.

bubbleWidth

number

Width of bubble, or null if not resizable.

Value may be null.

bubbleHeight

number

Height of bubble, or null if not resizable.

Value may be null.

Properties

ANCHOR_RADIUS

static

Distance between arrow point and anchor point.

ARROW_ANGLE

static

The number of degrees that the arrow bends counter-clockwise.

ARROW_BEND

static

The sharpness of the arrow's bend. Higher numbers result in smoother arrows.

ARROW_THICKNESS

static

Determines the thickness of the base of the arrow in relation to the size of the bubble. Higher numbers result in thinner arrows.

BORDER_WIDTH

static

Width of the border around the bubble.

resizeCallback_

function()

Function to call on resize of bubble.

Methods

dispose

dispose()

Dispose of this bubble.

getBubbleSize

getBubbleSize() returns Object

Get the dimensions of this bubble.

Returns

non-null Object Object with width and height properties.

getRelativeToSurfaceXY

getRelativeToSurfaceXY() returns goog.math.Coordinate

Return the coordinates of the top-left corner of this bubble's body relative to the drawing surface's origin (0,0), in workspace units.

Returns

non-null goog.math.Coordinate Object with .x and .y properties.

getSvgRoot

getSvgRoot() returns Element

Return the root node of the bubble's SVG group.

Returns

Element The root SVG node of the bubble's group.

isDeletable

isDeletable() returns boolean

Get whether this bubble is deletable or not.

Returns

boolean True if deletable.

moveDuringDrag

moveDuringDrag(dragSurface, newLoc)

Move this bubble during a drag, taking into account whether or not there is a drag surface.

Parameter

dragSurface

Blockly.BlockDragSurfaceSvg

The surface that carries rendered items during a drag, or null if no drag surface is in use.

Value may be null.

newLoc

goog.math.Coordinate

The location to translate to, in workspace coordinates.

Value must not be null.

moveTo

moveTo(x, y)

Move the bubble group to the specified location in workspace coordinates.

Parameter

x

number

The x position to move to.

y

number

The y position to move to.

registerResizeEvent

registerResizeEvent(callback)

Register a function as a callback event for when the bubble is resized.

Parameter

callback

function()

The function to call on resize.

Value must not be null.

setAnchorLocation

setAnchorLocation(xy)

Notification that the anchor has moved. Update the arrow and bubble accordingly.

Parameter

xy

goog.math.Coordinate

Absolute location.

Value must not be null.

setAutoLayout

setAutoLayout(enable)

Set whether auto-layout of this bubble is enabled. The first time a bubble is shown it positions itself to not cover any blocks. Once a user has dragged it to reposition, it renders where the user put it.

Parameter

enable

boolean

True if auto-layout should be enabled, false otherwise.

setBubbleSize

setBubbleSize(width, height)

Size this bubble.

Parameter

width

number

Width of the bubble.

height

number

Height of the bubble.

setColour

setColour(hexColour)

Change the colour of a bubble.

Parameter

hexColour

string

Hex code of colour.

setSvgId

setSvgId(id)

Expose the block's ID on the bubble's top-level SVG group.

Parameter

id

string

ID of block.