cromo La guida di Cromo
Scarica PDF EN

std.gui

Windows and their components, drawn by the program itself: labels, buttons, text boxes, check boxes, switches, sliders, combo boxes, images and icons, groups and panels that scroll, lists, the bars of an app, dialogs and snackbars. A window looks the same on Windows and on Linux, flat and quiet, with an ochre accent, light or dark, compact on the desktop; the same program compiled with --target android is an app for Android, with the sizes for the fingers.

Window makes a window, its add puts a component in it and gives it back, and start shows it; when main returns, the program waits until its windows are closed. A window and a component are handles: small values that name them, which can be copied freely and captured by copy in a lambda.

  • Positions and sizes are in logical pixels, which the library scales with the density of the screen, from the top left corner of the content of the window, under its title bar, or of the group, the panel or the dialog that holds the component.
  • The anchors, set with setAnchor, say which edges of the window, or of its group, a component follows when they move: a window is written for one size, and the anchors adapt it to the others, also to the screen of a phone.
  • The handlers of the events, as onClick, run on the thread of the windows, one at a time, and can change any component. A handler that takes long freezes the windows: long work goes to a task. An exception that leaves a handler stops the program.
  • The methods of the windows and of the components can be called from any thread. When the program changes a component, as with setText or setChecked, the handlers are not called: they are for what the user does.
  • A window is drawn when something in it changes: an event, a change of the program, or what moves by itself, as the caret that blinks. A still window does not use the processor.
cromo
import std.gui

[[window]]
i32 main() {
    gui.Window w = gui.Window("Greetings", 420, 230)
    w.add(gui.Label("Your name", 24, 24, 200, 20))
    gui.TextBox name = w.add(gui.TextBox("", 24, 48, 372, 32))
    gui.Button greet = w.add(gui.Button("Greet", 24, 96, 100, 32))
    gui.Label answer = w.add(gui.Label("", 24, 148, 372, 20))
    greet.onClick([name, answer]() { answer.setText(format("Hello, {}!", name.text())) })
    w.start()
    ret 0
}

The guide: Windows and apps.

Generata dalla documentazione nei sorgenti della libreria, che è in inglese.

#Tipi

#Theme

cromo
enum Theme

The colors of a window and of its components, light or dark, set with Window.setTheme. On a phone the bars of the system take the same colors.

  • System: that of the system, the default, which changes when the user changes it
  • Light: dark text on light grays
  • Dark: light text on dark grays

#Palette

cromo
struct Palette

The colors of a theme, each for a role, as 0xRRGGBB: a program that wants its own colors takes those of the library, changes some, and gives them to its window with Window.setPalette, for the light theme and for the dark one. The shapes, the borders and the shadows stay those of the library.

cromo
gui.Palette light = gui.lightPalette()
light.accent = 0x2F6E8F          // the main buttons, the checked boxes, the sliders
light.accentStrong = 0x245873
gui.Palette dark = gui.palette(0x101418, 0x181E24, 0xE6EAEE, 0x6FB2D2, 0x6FB2D2, 0xE0786D)
w.setPalette(light, dark)
  • u32 background: under the components
  • u32 surface: cards, dialogs, fields, buttons and bars
  • u32 surfaceHover: the bands of the groups and of the dialogs, and under the mouse
  • u32 surfacePressed: pressed, and the tracks of the sliders and of the bars
  • u32 text: the text
  • u32 textSecondary: the text that matters less, the labels and the icons
  • u32 textFaint: muted text, the titles of the bands, the placeholders
  • u32 line: lines, and the borders of the cards
  • u32 border: the borders of the controls
  • u32 accent: main buttons, checked boxes, switches and sliders
  • u32 accentStrong: the accent under the mouse, and the text on the soft accent
  • u32 accentSoft: the item pointed at in a list, the item chosen of a bar
  • u32 selection: the focus, the links, and the bar of the selected row
  • u32 selectionSoft: the selected row and the selected text
  • u32 onAccent: the text on the accent
  • u32 danger: errors, and the buttons that destroy

#ButtonStyle

cromo
enum ButtonStyle

The style of a button, set with Button.setStyle.

  • Normal: light, with a thin border: the default
  • Primary: filled with the accent, for the main action of a window or of a group
  • Danger: in the color of danger, for an action that destroys, as Delete

#FileType

cromo
struct FileType

A kind of file for the dialogs of the files: its name, as "Images", and its extensions without the dot, between ;, as "png;jpg", or "*" for every file.

cromo
w.openFile([gui.FileType("Images", "png;jpg"), gui.FileType("All the files", "*")], [](list<string> files) {
    println("{}", files)
})
cromo
FileType(string kind, string patterns)

A kind of file with its name and its extensions.

  • string name: shown in the dialog, as "Images"
  • string extensions: without the dot, between ;, as "png;jpg", or "*"

#Ink

cromo
enum Ink

The color of a piece of rich text: a role of the theme, which follows the light or the dark one by itself.

  • Normal: the text
  • Secondary: the text that matters less
  • Faint: muted, as numbers and remarks on the side
  • Accent: the accent, darker for the text: what must stand out
  • Selection: the blue of the selection, as notes and links
  • Danger: errors and warnings

#BlockLine

cromo
enum BlockLine

The line along the left edge of a block of rich text, set with RichText.startBlock.

  • None: no line: only the margin
  • Plain: gray, as the borders of the components
  • Selection: the soft blue of the selection
  • Accent: the accent

#Horizontal

cromo
enum Horizontal

How a component follows the left and the right edges of its parent, the window or the group, the panel or the dialog that holds it, when the parent changes width. The component keeps the distances that it has when its anchors, its position or its size are set: so a window is written for one size, and the anchors adapt it to the others.

cromo
gui.TextBox title = w.add(gui.TextBox("", 16, 16, 448, 32))
title.setAnchor(gui.Horizontal.Stretch, gui.Vertical.Top)   // as wide as the window
  • Left: keeps its distance from the left edge, and its width: the default
  • Right: keeps its distance from the right edge, and its width
  • Stretch: keeps its distances from both edges, and so changes its width
  • Center: keeps its center at the same distance from the center, and its width

#Vertical

cromo
enum Vertical

How a component follows the top and the bottom edges of its parent when the parent changes height, as Horizontal does for the left and the right ones. In a panel that scrolls, the components anchored to the top scroll with its content, and the others stay where they are on the part that is seen, as a button over a list.

cromo
gui.Button save = w.add(gui.Button("Save", 364, 217, 100, 32))
save.setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom)   // in the bottom right corner
  • Top: keeps its distance from the top edge, and its height: the default
  • Bottom: keeps its distance from the bottom edge, and its height
  • Stretch: keeps its distances from both edges, and so changes its height
  • Center: keeps its center at the same distance from the center, and its height

#Direction

cromo
enum Direction

How a Split puts its two panels.

  • Across: side by side, the first on the left
  • Down: one over the other, the first on top

#Scale

cromo
enum Scale

How an image box fits its image, set with ImageBox.setScale. The image is at the center of the box, and what goes beyond its edges is cut.

  • Fit: the whole image, as large as the box allows, with its proportions: the default
  • Fill: the whole box, covered by the image with its proportions, cut at the edges
  • Stretch: the size of the box, without the proportions of the image
  • Center: the size of the image, a pixel of it for each logical pixel

#Color

cromo
struct Color

A color with its opacity, for the drawings of a canvas: rgb(0x2F6E8F) is opaque, and rgba(0x2F6E8F, 115) lets what is under it show through.

  • u8 red: from 0 to 255
  • u8 green: from 0 to 255
  • u8 blue: from 0 to 255
  • u8 alpha: 255 opaque, 0 transparent

#Role

cromo
enum Role

A color of the theme by its role, the ones of a Palette: gui.role gives a Color that follows the theme of the window, light or dark, and its palette.

  • Background: under the components
  • Surface: cards, dialogs, fields, buttons and bars
  • SurfaceHover: under the mouse, and the bands
  • SurfacePressed: pressed, and the tracks
  • Text: the text
  • TextSecondary: the text that matters less
  • TextFaint: muted text
  • Line: lines, and the borders of the cards
  • Border: the borders of the controls
  • Accent: the accent
  • AccentStrong: the accent under the mouse
  • AccentSoft: the soft accent
  • Selection: the selection and the focus
  • SelectionSoft: the selected row
  • OnAccent: the text on the accent
  • Danger: errors, and what destroys

#TextStyle

cromo
struct TextStyle

How a piece of rich text looks: its color, a role of the theme; semibold, italic and monospaced; and its size, from that of the text of the view.

cromo
gui.TextStyle note = gui.TextStyle(gui.Ink.Faint)
note.italic = true
note.scale = 0.9   // 90% of the text of the view
gui.TextStyle label = gui.TextStyle(gui.Ink.Faint)
label.strong = true
label.spacing = 0.06   // small capitals, spaced: 6% of the size after each letter
cromo
TextStyle(Ink color)

A style in a color, regular, of the size of the text of the view.

  • Ink ink: the color, a role of the theme
  • bool strong: semibold
  • bool italic: slanted
  • bool mono: JetBrains Mono, whose letters are all equally wide
  • f32 scale: the size, from that of the text of the view: more than 0
  • f32 spacing: added after each letter, as a part of its size, from -0.5 to 1

#Image

cromo
struct Image

An image for the drawings of a canvas: PNG, JPEG, BMP, GIF or SVG, read once from its bytes and kept for the whole program. It is a handle, as a component: its copies name the same image, and a lambda captures it by copy. An SVG image is drawn again at the size where it is shown, sharp at every size and density.

cromo
gui.Image logo = gui.Image(embed("images/logo.svg"))
gui.Drawing d
d.image(logo, 16, 16, 64, 64)
cromo
Image(list<u8> bytes)

Reads the image from its bytes, as embed and fs.readBytes give them. Bytes that are not an image that can be read throw an Error with the reason.

#Image.width

cromo
f32 width() const

The width of the image in pixels: that of its file, or the one written in the SVG.

#Image.height

cromo
f32 height() const

The height of the image in pixels: that of its file, or the one written in the SVG.

#Icon

cromo
enum Icon

An icon of Lucide 1.68.0, drawn with lines in the colors of the component that shows it, and sharp at every size. A button shows one with setIcon, an icon box alone, and the app bar, the navigation bar and the items of a list have theirs. The names are those of Lucide with capitals and no hyphens: message-circle is MessageCircle, trash-2 is Trash2. None, the default, is no icon.

  • None: no icon: the default
  • Activity: a pulse line, as that of a heart monitor
  • AlarmClock: an alarm clock
  • Archive: a box for archives, with its lid
  • ArrowDown: an arrow that points down
  • ArrowLeft: an arrow that points left, to go back
  • ArrowRight: an arrow that points right
  • ArrowUp: an arrow that points up
  • AtSign: the sign @
  • Award: a rosette with ribbons, for a prize
  • Ban: a circle crossed by a line, for something forbidden
  • Battery: a battery
  • Bell: a bell, for the notifications
  • BellOff: a bell crossed out, for the notifications off
  • Bike: a bicycle
  • Bluetooth: the sign of Bluetooth
  • Book: a closed book
  • BookOpen: an open book
  • Bookmark: a bookmark
  • Briefcase: a briefcase, for work
  • Building2: an office building
  • Calendar: a calendar
  • Camera: a camera
  • Car: a car
  • ChartColumn: a chart with columns
  • ChartLine: a chart with a line
  • ChartPie: a pie chart
  • Check: a check mark
  • ChevronDown: a chevron that points down, to open
  • ChevronLeft: a chevron that points left, to go back
  • ChevronRight: a chevron that points right, to go on
  • ChevronUp: a chevron that points up, to close
  • CircleAlert: an exclamation mark in a circle, for an error
  • CircleCheck: a check mark in a circle, for a success
  • CircleQuestionMark: a question mark in a circle, for help
  • CircleX: an X in a circle, for a failure
  • Clipboard: a clipboard
  • Clock: a clock, for a time
  • Cloud: a cloud
  • Code: two angle brackets, for code
  • Coffee: a cup of coffee
  • Contact: a card with a person, for a contact
  • Copy: two sheets one over the other, to copy
  • Cpu: a processor
  • CreditCard: a credit card
  • Database: a cylinder, for a database
  • Download: an arrow down into a tray, to download
  • Droplet: a drop of water
  • Ellipsis: three dots in a row, for more
  • EllipsisVertical: three dots in a column, for a menu of more actions
  • ExternalLink: a box with an arrow out of it, for a link that opens elsewhere
  • Eye: an eye, to show
  • EyeOff: an eye crossed out, to hide
  • File: a sheet of paper, for a file
  • FileText: a sheet with lines of text
  • Flag: a flag
  • Flame: a flame
  • Folder: a folder
  • FolderOpen: an open folder
  • Funnel: a funnel, for a filter
  • Gift: a gift
  • Globe: a globe, for the web or the languages
  • GraduationCap: a graduation cap, for a school
  • Heart: a heart, for what is liked
  • History: a clock with an arrow around it, for the history
  • House: a house, for the home page
  • Image: a picture of mountains, for an image
  • Inbox: a tray, for the messages received
  • Info: an i in a circle, for information
  • Key: a key
  • Laptop: a laptop
  • Layers: sheets one over the other, for layers
  • LayoutGrid: four squares, for a grid
  • Lightbulb: a light bulb, for an idea or a tip
  • Link: two links of a chain, for a link
  • List: lines with dots, for a list
  • Loader: rays in a circle, for something that is loading
  • Lock: a closed padlock
  • LockOpen: an open padlock
  • LogIn: an arrow into a door, to sign in
  • LogOut: an arrow out of a door, to sign out
  • Mail: an envelope, for the mail
  • Map: a folded map
  • MapPin: a pin, for a place on a map
  • Menu: three lines, for a menu
  • MessageCircle: a round speech bubble, for a message
  • MessageSquare: a square speech bubble, for a message
  • Mic: a microphone
  • Minus: a minus sign
  • Monitor: the screen of a computer
  • Moon: a crescent moon, for the night or the dark theme
  • Music: a musical note
  • Package: a parcel
  • Paperclip: a paper clip, for an attachment
  • Pause: two bars, to pause
  • Pencil: a pencil, to write or to edit
  • Phone: the handset of a phone, for a call
  • Plane: an airplane
  • Play: a triangle that points right, to play
  • Plus: a plus sign, to add
  • Power: a circle broken by a line, to switch on or off
  • Printer: a printer
  • QrCode: a QR code
  • RefreshCw: two arrows in a circle, to refresh
  • RotateCcw: an arrow that turns back, to undo
  • Save: a floppy disk, to save
  • Scan: the corners of a frame, to scan
  • Search: a magnifying glass, to search
  • Send: a paper plane, to send
  • Server: a server
  • Settings: a gear, for the settings
  • Share2: three dots joined by lines, to share
  • Shield: a shield, for security
  • ShoppingBag: a shopping bag
  • ShoppingCart: a shopping cart
  • SkipBack: a triangle to the left against a bar, for the track before
  • SkipForward: a triangle to the right against a bar, for the track after
  • SlidersHorizontal: horizontal sliders, for options
  • Smartphone: a smartphone
  • Smile: a smiling face
  • Square: a square, to stop
  • Star: a star, for the favorites
  • Sun: a sun, for the day or the light theme
  • Table: a table with rows and columns
  • Tag: a tag, for a label or a price
  • Terminal: a prompt, for a terminal
  • Thermometer: a thermometer
  • ThumbsDown: a thumb down
  • ThumbsUp: a thumb up
  • Trash2: a bin, to delete
  • TriangleAlert: an exclamation mark in a triangle, for a warning
  • Trophy: a trophy
  • Truck: a truck, for a delivery
  • Umbrella: an umbrella
  • Upload: an arrow up out of a tray, to upload
  • User: a person, for a user or an account
  • UserCheck: a person with a check mark
  • UserPlus: a person with a plus sign, to add someone
  • Users: two people, for a group
  • Utensils: a fork and a knife, for food
  • Video: a video camera
  • Volume2: a speaker with waves, for the sound on
  • VolumeX: a speaker with an X, for the sound off
  • Wallet: a wallet
  • Wifi: the waves of Wi-Fi
  • WifiOff: the waves of Wi-Fi crossed out
  • X: an X, to close or to cancel
  • Zap: a lightning bolt

#Mouse

cromo
struct Mouse

Where the mouse is, and which button changed, for the handlers of onMouseMove, onMouseDown and onMouseUp of a window or of a canvas. A finger on a phone is the left button.

  • f32 x: in logical pixels from the left edge of the content, or of the canvas
  • f32 y: in logical pixels from the top of the content, or of the canvas
  • i32 button: 1 left, 2 middle, 3 right, 0 when the mouse moves
  • bool shift: a Shift key is held
  • bool control: a Ctrl key is held
  • bool alt: an Alt key is held

#CameraSide

cromo
enum CameraSide

Which camera of the device, for Camera.

  • Any: the first one that the system has
  • Front: the one on the side of the screen, toward the user
  • Back: the one behind the screen

#CameraState

cromo
enum CameraState

How a camera is, from Camera.state().

  • Opening: not open yet, or waiting for the user to allow it
  • Ready: it gives its frames
  • Denied: the user did not allow it
  • Missing: the device has no camera, or it could not be opened
  • Closed: closed by close()

#Frame

cromo
struct Frame

A frame of a camera: its pixels, row after row from the top, each of four bytes, red, green, blue and 255.

  • i32 width: in pixels
  • i32 height
  • list<u8> pixels: width * height * 4 bytes
  • i64 time: when it was taken, in nanoseconds: for the time between two frames

#Frame.png

cromo
list<u8> png() const

The frame as the bytes of a PNG file, for fs.writeBytes or to send: a photo. Without pixels, an empty list.

#Camera

cromo
struct Camera

A camera of the computer or of the phone: it gives its frames to the handlers of onFrame, and a CameraView shows what it sees. It is a handle: its copies are the same camera. The camera opens when the windows run; on a phone the system asks the user to allow it, the first time. It stays open, with its light on, until close() or the end of the program.

cromo
gui.Camera camera = gui.Camera(gui.CameraSide.Back)
gui.CameraView view = w.add(gui.CameraView(camera, 0, 0, 390, 520))
shoot.onClick([view]() { fs.writeBytes("photo.png", view.takePhoto().png()) })
cromo
Camera(CameraSide side)

The camera on a side of the device, or the first one there is. A computer does not say where its cameras are: there every side is the first camera.

#Camera.onFrame

cromo
void onFrame(move func(Frame) handler) const

Adds a handler, called on the thread of the windows with each frame of the camera, some tens a second: to read a code, to find a face, to send the video.

#Camera.frame

cromo
Frame frame() const

The last frame of the camera: without pixels, and 0 wide, before the first one.

#Camera.state

cromo
CameraState state() const

How the camera is: opening, ready, denied by the user, missing, or closed.

#Camera.close

cromo
void close() const

Closes the camera, which turns its light off: its views keep its last frame.

#CameraView

cromo
struct CameraView : Component

Shows what a camera sees, filling its box as an image with Scale.Fill: the frame keeps its proportions, and is cut at the edges of the box.

cromo
gui.CameraView view = w.add(gui.CameraView(camera, 0, 0, 390, 520))
cromo
CameraView(Camera camera, i32 x, i32 y, i32 width, i32 height)

A view of a camera. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#CameraView.takePhoto

cromo
Frame takePhoto() const

The frame that the view shows, to keep: takePhoto().png() is a photo as the bytes of a file. Without pixels before the first frame of the camera.

#CameraView.setScale

cromo
void setScale(Scale value) const

How the frame fits the box: Scale.Fill by default.

#CameraView.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the camera view, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#CameraView.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the camera view, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#CameraView.x

cromo
i32 x() const

The distance of the camera view from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#CameraView.y

cromo
i32 y() const

The distance of the camera view from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#CameraView.width

cromo
i32 width() const

The width of the camera view now, in logical pixels: a Stretch anchor changes it with its parent.

#CameraView.height

cromo
i32 height() const

The height of the camera view now, in logical pixels: a Stretch anchor changes it with its parent.

#CameraView.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the camera view for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#CameraView.tooltip

cromo
string tooltip() const

The text of the tooltip of the camera view, "" for none.

#CameraView.setVisible

cromo
void setVisible(bool value) const

Shows or hides the camera view.

#CameraView.visible

cromo
bool visible() const

Whether the camera view is visible, as setVisible set it: true by default.

#CameraView.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the camera view: disabled, it is drawn at half its opacity.

#CameraView.enabled

cromo
bool enabled() const

Whether the camera view is enabled, as setEnabled set it: true by default.

#CameraView.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the camera view follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#CameraView.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the camera view follows the left and the right edges of its parent: Horizontal.Left by default.

#CameraView.verticalAnchor

cromo
Vertical verticalAnchor() const

How the camera view follows the top and the bottom edges of its parent: Vertical.Top by default.

#CameraView.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#CameraView.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#CameraView.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#CameraView.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#CameraView.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#CameraView.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#Motion

cromo
struct Motion

The motion of the device, for the handlers of onMotion of a window: what its accelerometer and its gyroscope measure, along its axes. With the device in front of the user as it is held by default, x goes to the right, y up and z out of the screen toward the user. A sensor that the device does not have leaves its three numbers at 0.

  • f32 accelerationX: the acceleration, in meters per second squared, with the one of
  • f32 accelerationY: gravity: a phone at rest on a table has about 9.8 on z
  • f32 accelerationZ
  • f32 rotationX: how fast the device turns around each axis, in radians per second
  • f32 rotationY
  • f32 rotationZ
  • i64 time: when the sensor measured, in nanoseconds: for the time between two events

#Point

cromo
struct Point

A point, or a size or a step, in logical pixels: two numbers that go together, as the place of a shape of a drawing or the speed of what moves. It is a simple value: a program keeps a list of points in place of a list of x and one of y.

cromo
gui.Point ball = gui.Point(40, 100)
ball.x += 120 * seconds
cromo
Point(f32 across, f32 down)
  • f32 x
  • f32 y

#Touch

cromo
struct Touch

A finger on the screen, for the handlers of onTouchDown, onTouchMove and onTouchUp of a window. Each finger that touches has a number of its own, the same from when it comes down to when it goes up: two fingers are two numbers.

  • i64 finger: the number of the finger, the same for as long as it touches
  • f32 x: in logical pixels from the left edge of the content
  • f32 y: in logical pixels from the top of the content
  • f32 pressure: from 0 to 1, or 1 on a screen that does not measure it

#Orientation

cromo
enum Orientation

How a phone holds the window, for Window.setOrientation.

  • Any: as the phone is held: the window turns with it
  • Portrait: upright, taller than wide
  • Landscape: on its side, wider than tall

#Key

cromo
struct Key

A key pressed or released, for the handlers of onKeyDown and onKeyUp of a window.

  • i64 code: The keycode of SDL. For the letters, the digits and the signs it is the character of the key without Shift: 97 for A, with Shift too, and 49 for 1. Then 13 is Enter, 27 Esc, 32 Space, 8 Backspace and 127 Delete, and the arrows are 0x40000050 left, 0x4000004F right, 0x40000052 up and 0x40000051 down.
  • bool shift: a Shift key is held
  • bool control: a Ctrl key is held
  • bool alt: an Alt key is held
  • bool repeated: the key is held down, and this is not its first event

#Component

cromo
interface Component

A component that a window, a group, a panel or a dialog can hold, with their add: the components of this module, as Label and Button, are its implementations.

#Component.componentId

cromo
i64 componentId() const

The number that names the component inside the module, for add.

#Label

cromo
struct Label : Component

A line of text, on the left of its box and in the middle of its height. It takes neither the mouse nor the keys.

cromo
gui.Label status = w.add(gui.Label("Ready", 16, 223, 300, 20))
status.setText("Saved")
cromo
Label(string text, i32 x, i32 y, i32 width, i32 height)

A label with its text. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#Label.setText

cromo
void setText(string value) const

Changes the text of the label.

#Label.text

cromo
string text() const

The text of the label.

#Label.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the label, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#Label.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the label, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#Label.x

cromo
i32 x() const

The distance of the label from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#Label.y

cromo
i32 y() const

The distance of the label from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#Label.width

cromo
i32 width() const

The width of the label now, in logical pixels: a Stretch anchor changes it with its parent.

#Label.height

cromo
i32 height() const

The height of the label now, in logical pixels: a Stretch anchor changes it with its parent.

#Label.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the label for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#Label.tooltip

cromo
string tooltip() const

The text of the tooltip of the label, "" for none.

#Label.setVisible

cromo
void setVisible(bool value) const

Shows or hides the label.

#Label.visible

cromo
bool visible() const

Whether the label is visible, as setVisible set it: true by default.

#Label.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the label: disabled, it is drawn at half its opacity.

#Label.enabled

cromo
bool enabled() const

Whether the label is enabled, as setEnabled set it: true by default.

#Label.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the label follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#Label.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the label follows the left and the right edges of its parent: Horizontal.Left by default.

#Label.verticalAnchor

cromo
Vertical verticalAnchor() const

How the label follows the top and the bottom edges of its parent: Vertical.Top by default.

#Label.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#Label.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#Label.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#Label.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#Label.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#Label.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#Button

cromo
struct Button : Component

A button, with a text, an icon or both. A click, a touch, or Space and Enter while it has the keyboard, call its handlers of onClick.

cromo
gui.Button save = w.add(gui.Button("Save", 364, 217, 100, 32))
save.setIcon(gui.Icon.Save)
save.onClick([w]() { w.showSnackbar("Saved") })
cromo
Button(string text, i32 x, i32 y, i32 width, i32 height)

A button with its text. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#Button.onClick

cromo
void onClick(move func() handler) const

Adds a handler, called on the thread of the windows when the user presses the button: with a click, a touch, or Space or Enter while it has the keyboard. The handlers are called in the order they were added.

#Button.setIcon

cromo
void setIcon(Icon value) const

Puts an icon of 16 pixels before the text, 18 on a phone, or alone in the middle when the button has no text; Icon.None removes it.

#Button.setStyle

cromo
void setStyle(ButtonStyle value) const

Changes the style of the button: ButtonStyle.Primary fills it with the accent, for the main action, and ButtonStyle.Danger is for an action that destroys.

cromo
gui.Button save = w.add(gui.Button("Save", 364, 217, 100, 28))
save.setStyle(gui.ButtonStyle.Primary)

#Button.style

cromo
ButtonStyle style() const

The style of the button: ButtonStyle.Normal unless it was changed.

#Button.icon

cromo
Icon icon() const

The icon of the button, Icon.None without one.

#Button.setText

cromo
void setText(string value) const

Changes the text of the button; without text, its icon is alone in the middle.

#Button.text

cromo
string text() const

The text of the button.

#Button.setToggle

cromo
void setToggle(bool value) const

Makes the button one with two states, pressed and released, which a click changes : pressed it is in the soft accent. A button is normal by default.

#Button.toggle

cromo
bool toggle() const

Whether the button has two states.

#Button.setChecked

cromo
void setChecked(bool value) const

Presses or releases a button with two states, without calling the handlers of onChange.

#Button.checked

cromo
bool checked() const

Whether a button with two states is pressed.

#Button.onChange

cromo
void onChange(move func(bool) handler) const

Adds a handler, called on the thread of the windows when the user presses or releases a button with two states, with its new state; setChecked does not call it. The handlers of onClick are called too.

#Button.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the button, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#Button.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the button, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#Button.x

cromo
i32 x() const

The distance of the button from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#Button.y

cromo
i32 y() const

The distance of the button from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#Button.width

cromo
i32 width() const

The width of the button now, in logical pixels: a Stretch anchor changes it with its parent.

#Button.height

cromo
i32 height() const

The height of the button now, in logical pixels: a Stretch anchor changes it with its parent.

#Button.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the button: hidden for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#Button.tooltip

cromo
string tooltip() const

The text of the tooltip of the button: hidden, "" for none.

#Button.setVisible

cromo
void setVisible(bool value) const

Shows or hides the button: hidden, it takes neither the mouse nor the keys.

#Button.visible

cromo
bool visible() const

Whether the button is visible, as setVisible set it: true by default.

#Button.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the button: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.

#Button.enabled

cromo
bool enabled() const

Whether the button is enabled, as setEnabled set it: true by default.

#Button.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the button follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#Button.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the button follows the left and the right edges of its parent: Horizontal.Left by default.

#Button.verticalAnchor

cromo
Vertical verticalAnchor() const

How the button follows the top and the bottom edges of its parent: Vertical.Top by default.

#Button.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#Button.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#Button.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#Button.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#Button.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#Button.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#TextBox

cromo
struct TextBox : Component

A line of text that the user writes, with the input method of the system and, on a phone, the keyboard on the screen. The arrows, Home and End move in it, with Ctrl a word, with Shift they select, as the mouse does, and Backspace, Delete, Ctrl+A, Ctrl+C, Ctrl+X and Ctrl+V do what they do in every program; a text pasted becomes one line. Ctrl+Z and Ctrl+Y undo and redo. Its handlers of onChange receive the text at each change, those of onEnter when Enter is pressed.

cromo
gui.TextBox name = w.add(gui.TextBox("", 24, 48, 372, 32))
name.setPlaceholder("Write your name")
name.onEnter([](string text) { println("Hello, {}!", text) })
cromo
TextBox(string text, i32 x, i32 y, i32 width, i32 height)

A text box with its first text, maybe "". x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#TextBox.onChange

cromo
void onChange(move func(string) handler) const

Adds a handler, called on the thread of the windows with the new text at each change that the user makes: a character written or deleted, a text cut or pasted. setText does not call it.

#TextBox.onEnter

cromo
void onEnter(move func(string) handler) const

Adds a handler, called on the thread of the windows with the text when the user presses Enter in the box.

#TextBox.setPlaceholder

cromo
void setPlaceholder(string value) const

Sets the text shown in gray while the box is empty, as a hint of what to write.

#TextBox.placeholder

cromo
string placeholder() const

The text shown while the box is empty, "" by default.

#TextBox.setText

cromo
void setText(string value) const

Replaces the text, with the cursor at its end, without calling the handlers of onChange; what Ctrl+Z could undo is forgotten.

#TextBox.text

cromo
string text() const

The text written in the box.

#TextBox.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the text box, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#TextBox.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the text box, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#TextBox.x

cromo
i32 x() const

The distance of the text box from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#TextBox.y

cromo
i32 y() const

The distance of the text box from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#TextBox.width

cromo
i32 width() const

The width of the text box now, in logical pixels: a Stretch anchor changes it with its parent.

#TextBox.height

cromo
i32 height() const

The height of the text box now, in logical pixels: a Stretch anchor changes it with its parent.

#TextBox.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the text box: hidden for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#TextBox.tooltip

cromo
string tooltip() const

The text of the tooltip of the text box: hidden, "" for none.

#TextBox.setVisible

cromo
void setVisible(bool value) const

Shows or hides the text box: hidden, it takes neither the mouse nor the keys.

#TextBox.visible

cromo
bool visible() const

Whether the text box is visible, as setVisible set it: true by default.

#TextBox.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the text box: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.

#TextBox.enabled

cromo
bool enabled() const

Whether the text box is enabled, as setEnabled set it: true by default.

#TextBox.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the text box follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#TextBox.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the text box follows the left and the right edges of its parent: Horizontal.Left by default.

#TextBox.verticalAnchor

cromo
Vertical verticalAnchor() const

How the text box follows the top and the bottom edges of its parent: Vertical.Top by default.

#TextBox.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#TextBox.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#TextBox.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#TextBox.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#TextBox.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#TextBox.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#CheckBox

cromo
struct CheckBox : Component

A box to check, with its text on its right. A click on the box or on its text, or Space while it has the keyboard, checks or unchecks it, and calls its handlers of onChange with the new state.

cromo
gui.CheckBox news = w.add(gui.CheckBox("Send me the news", 12, 154, 260, 22))
news.onChange([](bool checked) { println("news: {}", checked) })
cromo
CheckBox(string text, i32 x, i32 y, i32 width, i32 height)

A check box with its text, not checked. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size, with the text.

#CheckBox.onChange

cromo
void onChange(move func(bool) handler) const

Adds a handler, called on the thread of the windows with the new state when the user checks or unchecks the box. setChecked does not call it.

#CheckBox.setChecked

cromo
void setChecked(bool value) const

Checks or unchecks the box, without calling the handlers of onChange.

#CheckBox.checked

cromo
bool checked() const

Whether the box is checked: false at the start.

#CheckBox.setText

cromo
void setText(string value) const

Changes the text on the right of the box.

#CheckBox.text

cromo
string text() const

The text on the right of the box.

#CheckBox.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the check box, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#CheckBox.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the check box, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#CheckBox.x

cromo
i32 x() const

The distance of the check box from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#CheckBox.y

cromo
i32 y() const

The distance of the check box from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#CheckBox.width

cromo
i32 width() const

The width of the check box now, in logical pixels: a Stretch anchor changes it with its parent.

#CheckBox.height

cromo
i32 height() const

The height of the check box now, in logical pixels: a Stretch anchor changes it with its parent.

#CheckBox.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the check box: hidden for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#CheckBox.tooltip

cromo
string tooltip() const

The text of the tooltip of the check box: hidden, "" for none.

#CheckBox.setVisible

cromo
void setVisible(bool value) const

Shows or hides the check box: hidden, it takes neither the mouse nor the keys.

#CheckBox.visible

cromo
bool visible() const

Whether the check box is visible, as setVisible set it: true by default.

#CheckBox.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the check box: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.

#CheckBox.enabled

cromo
bool enabled() const

Whether the check box is enabled, as setEnabled set it: true by default.

#CheckBox.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the check box follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#CheckBox.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the check box follows the left and the right edges of its parent: Horizontal.Left by default.

#CheckBox.verticalAnchor

cromo
Vertical verticalAnchor() const

How the check box follows the top and the bottom edges of its parent: Vertical.Top by default.

#CheckBox.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#CheckBox.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#CheckBox.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#CheckBox.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#CheckBox.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#CheckBox.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#GroupBox

cromo
struct GroupBox : Component

A card with its title in a band at its top, 32 pixels high, 40 on a phone, which holds other components: their positions are from its top left corner, so the first ones go under the band, at about 42 pixels. Without a title the card has no band. They move, hide and are disabled with the group, follow its edges with their anchors, and are drawn only inside it. A group can hold groups; unlike a panel, it does not scroll.

cromo
gui.GroupBox account = w.add(gui.GroupBox("Account", 12, 12, 300, 200))
account.add(gui.Label("Name", 12, 42, 200, 18))
gui.TextBox name = account.add(gui.TextBox("", 12, 62, 276, 28))
account.setEnabled(false)   // name too
cromo
GroupBox(string text, i32 x, i32 y, i32 width, i32 height)

A group with its title. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#GroupBox.add

cromo
T add<T : Component>(T component) const

Puts a component in the group, with its position from the top left corner of the group, and gives it back. The group can be put in its window before or after. A component that is already in a window or in a group is a panic, and so are an app bar and a group put in itself or in a group that it holds.

#GroupBox.setText

cromo
void setText(string value) const

Changes the title of the group.

#GroupBox.text

cromo
string text() const

The title of the group.

#GroupBox.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the group, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#GroupBox.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the group, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#GroupBox.x

cromo
i32 x() const

The distance of the group from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#GroupBox.y

cromo
i32 y() const

The distance of the group from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#GroupBox.width

cromo
i32 width() const

The width of the group now, in logical pixels: a Stretch anchor changes it with its parent.

#GroupBox.height

cromo
i32 height() const

The height of the group now, in logical pixels: a Stretch anchor changes it with its parent.

#GroupBox.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the group for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#GroupBox.tooltip

cromo
string tooltip() const

The text of the tooltip of the group, "" for none.

#GroupBox.setVisible

cromo
void setVisible(bool value) const

Shows or hides the group, and its components with it.

#GroupBox.visible

cromo
bool visible() const

Whether the group is visible, as setVisible set it: true by default.

#GroupBox.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the group, and its components with it: disabled, they are drawn at half their opacity and take neither the mouse nor the keys.

#GroupBox.enabled

cromo
bool enabled() const

Whether the group is enabled, as setEnabled set it: true by default.

#GroupBox.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the group follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#GroupBox.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the group follows the left and the right edges of its parent: Horizontal.Left by default.

#GroupBox.verticalAnchor

cromo
Vertical verticalAnchor() const

How the group follows the top and the bottom edges of its parent: Vertical.Top by default.

#GroupBox.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#GroupBox.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#GroupBox.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#GroupBox.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#GroupBox.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#GroupBox.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#TextArea

cromo
struct TextArea : Component

A text on more lines that the user writes, as a note or a description: Enter starts a new line, and a line longer than the box goes on the next one at its spaces . The text scrolls up and down, with the wheel, its bar and a finger. The arrows, Home, End, Page Up and Page Down move in it, with Ctrl a word or the whole text, with Shift they select, as the mouse does; Backspace, Delete, Ctrl+A, Ctrl+C, Ctrl+X and Ctrl+V do what they do in every program, and Ctrl+Z and Ctrl+Y undo and redo. Tab gives the keyboard to the next component.

cromo
gui.TextArea note = w.add(gui.TextArea("", 16, 16, 400, 160))
note.setPlaceholder("A note")
note.onChange([](string text) { println("{} characters", text.len()) })
cromo
TextArea(string text, i32 x, i32 y, i32 width, i32 height)

A text area with its first text, maybe "", in which "\n" starts a new line. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#TextArea.onChange

cromo
void onChange(move func(string) handler) const

Adds a handler, called on the thread of the windows with the new text at each change that the user makes: a character written or deleted, a text cut or pasted, an undo. setText does not call it.

#TextArea.setPlaceholder

cromo
void setPlaceholder(string value) const

Sets the text shown in gray while the area is empty, as a hint of what to write.

#TextArea.placeholder

cromo
string placeholder() const

The text shown while the area is empty, "" by default.

#TextArea.setText

cromo
void setText(string value) const

Replaces the text, with the cursor at its end, without calling the handlers of onChange; what Ctrl+Z could undo is forgotten.

#TextArea.text

cromo
string text() const

The text written in the area, with "\n" between its lines.

#TextArea.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the text area, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#TextArea.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the text area, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#TextArea.x

cromo
i32 x() const

The distance of the text area from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#TextArea.y

cromo
i32 y() const

The distance of the text area from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#TextArea.width

cromo
i32 width() const

The width of the text area now, in logical pixels: a Stretch anchor changes it with its parent.

#TextArea.height

cromo
i32 height() const

The height of the text area now, in logical pixels: a Stretch anchor changes it with its parent.

#TextArea.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the text area for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#TextArea.tooltip

cromo
string tooltip() const

The text of the tooltip of the text area, "" for none.

#TextArea.setVisible

cromo
void setVisible(bool value) const

Shows or hides the text area.

#TextArea.visible

cromo
bool visible() const

Whether the text area is visible, as setVisible set it: true by default.

#TextArea.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the text area: disabled, it is drawn at half its opacity.

#TextArea.enabled

cromo
bool enabled() const

Whether the text area is enabled, as setEnabled set it: true by default.

#TextArea.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the text area follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#TextArea.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the text area follows the left and the right edges of its parent: Horizontal.Left by default.

#TextArea.verticalAnchor

cromo
Vertical verticalAnchor() const

How the text area follows the top and the bottom edges of its parent: Vertical.Top by default.

#TextArea.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#TextArea.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#TextArea.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#TextArea.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#TextArea.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#TextArea.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#ComboBox

cromo
struct ComboBox : Component

A choice among a list of items, which the user chooses and cannot write. A click, or Space, Enter or Alt+Down while it has the keyboard, opens the list over the other components, below the box or above it when there is no room below, with up to 8 items and the others with the wheel of the mouse. In the list Up, Down, Home, End and the first letter of an item move, Enter, Space or a click choose, and Esc or a click out of the list close it. With the list closed, the same keys choose an item at once. Without a choice the box shows its placeholder.

cromo
gui.ComboBox role = w.add(gui.ComboBox(["Developer", "Designer", "Viewer"], 12, 110, 276, 28))
role.setPlaceholder("Choose a role")
role.onChange([role](i64 index) { println("{}: {}", index, role.text()) })
cromo
ComboBox(list<string> items, i32 x, i32 y, i32 width, i32 height)

A combo box with a copy of its items, none chosen. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#ComboBox.onChange

cromo
void onChange(move func(i64) handler) const

Adds a handler, called on the thread of the windows with the index of the item that the user chooses, when it is not the one chosen before. setSelected and setItems do not call it.

#ComboBox.setItems

cromo
void setItems(list<string> items) const

Replaces the items with a copy of items, and leaves none chosen.

#ComboBox.items

cromo
list<string> items() const

A copy of the items.

#ComboBox.addItem

cromo
void addItem(string item) const

Adds an item at the end of the list; the item chosen stays the same.

#ComboBox.setSelected

cromo
void setSelected(i64 index) const

Chooses the item at index, from 0, or none with -1, without calling the handlers of onChange. Another index out of the items is a panic.

#ComboBox.selected

cromo
i64 selected() const

The index of the item chosen, from 0, or -1 when none is: the default.

#ComboBox.text

cromo
string text() const

The item chosen, or "" when none is.

#ComboBox.setPlaceholder

cromo
void setPlaceholder(string value) const

Sets the text shown in gray while no item is chosen, as "Choose a role".

#ComboBox.placeholder

cromo
string placeholder() const

The text shown while no item is chosen, "" by default.

#ComboBox.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the combo box, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#ComboBox.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the combo box, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#ComboBox.x

cromo
i32 x() const

The distance of the combo box from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#ComboBox.y

cromo
i32 y() const

The distance of the combo box from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#ComboBox.width

cromo
i32 width() const

The width of the combo box now, in logical pixels: a Stretch anchor changes it with its parent.

#ComboBox.height

cromo
i32 height() const

The height of the combo box now, in logical pixels: a Stretch anchor changes it with its parent.

#ComboBox.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the combo box: hidden for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#ComboBox.tooltip

cromo
string tooltip() const

The text of the tooltip of the combo box: hidden, "" for none.

#ComboBox.setVisible

cromo
void setVisible(bool value) const

Shows or hides the combo box: hidden, it takes neither the mouse nor the keys.

#ComboBox.visible

cromo
bool visible() const

Whether the combo box is visible, as setVisible set it: true by default.

#ComboBox.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the combo box: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.

#ComboBox.enabled

cromo
bool enabled() const

Whether the combo box is enabled, as setEnabled set it: true by default.

#ComboBox.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the combo box follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#ComboBox.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the combo box follows the left and the right edges of its parent: Horizontal.Left by default.

#ComboBox.verticalAnchor

cromo
Vertical verticalAnchor() const

How the combo box follows the top and the bottom edges of its parent: Vertical.Top by default.

#ComboBox.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#ComboBox.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#ComboBox.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#ComboBox.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#ComboBox.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#ComboBox.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#ImageBox

cromo
struct ImageBox : Component

An image in PNG, JPEG, BMP, GIF or SVG, of which a GIF shows its first frame, from a file or from bytes in memory, placed in its box as setScale says: by default the whole image, as large as the box allows. An SVG image is drawn at the size where it is shown, sharp at every size. The image is read and decoded by the thread that sets it, which receives the errors as exceptions. An app on a phone has no files next to it: there the images come from embed.

cromo
gui.ImageBox logo = w.add(gui.ImageBox("", 16, 16, 64, 64))
logo.setBytes(embed("images/logo.png"))
cromo
ImageBox(string file, i32 x, i32 y, i32 width, i32 height)

An image box with the image of file, or none with "". x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size. Throws an Error when the file cannot be read, is empty or is not an image.

#ImageBox.setFile

cromo
void setFile(string path) const

Shows the image of a file, read and decoded by this thread, or none with "". Throws an Error when the file cannot be read, is empty or is not an image, and then the image shown stays.

#ImageBox.file

cromo
string file() const

The path of the image shown, "" when there is none or it came from bytes.

#ImageBox.setBytes

cromo
void setBytes(list<u8> bytes) const

Shows an image in memory, as embed or fs.readBytes give it, or none with an empty list. The bytes are decoded by this thread and not kept. Throws an Error when they are not an image, and then the image shown stays.

#ImageBox.imageWidth

cromo
i32 imageWidth() const

The width of the image, in its own pixels, or 0 without an image.

#ImageBox.imageHeight

cromo
i32 imageHeight() const

The height of the image, in its own pixels, or 0 without an image.

#ImageBox.setScale

cromo
void setScale(Scale value) const

Sets how the image fits the box: Scale.Fit by default.

#ImageBox.scale

cromo
Scale scale() const

How the image fits the box: Scale.Fit by default.

#ImageBox.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the image box, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#ImageBox.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the image box, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#ImageBox.x

cromo
i32 x() const

The distance of the image box from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#ImageBox.y

cromo
i32 y() const

The distance of the image box from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#ImageBox.width

cromo
i32 width() const

The width of the image box now, in logical pixels: a Stretch anchor changes it with its parent.

#ImageBox.height

cromo
i32 height() const

The height of the image box now, in logical pixels: a Stretch anchor changes it with its parent.

#ImageBox.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the image box for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#ImageBox.tooltip

cromo
string tooltip() const

The text of the tooltip of the image box, "" for none.

#ImageBox.setVisible

cromo
void setVisible(bool value) const

Shows or hides the image box.

#ImageBox.visible

cromo
bool visible() const

Whether the image box is visible, as setVisible set it: true by default.

#ImageBox.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the image box: disabled, it is drawn at half its opacity.

#ImageBox.enabled

cromo
bool enabled() const

Whether the image box is enabled, as setEnabled set it: true by default.

#ImageBox.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the image box follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#ImageBox.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the image box follows the left and the right edges of its parent: Horizontal.Left by default.

#ImageBox.verticalAnchor

cromo
Vertical verticalAnchor() const

How the image box follows the top and the bottom edges of its parent: Vertical.Top by default.

#ImageBox.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#ImageBox.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#ImageBox.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#ImageBox.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#ImageBox.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#ImageBox.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#IconBox

cromo
struct IconBox : Component

An icon alone, at the center of its box, as large as the smaller side of the box, in the color of the labels. It takes neither the mouse nor the keys.

cromo
w.add(gui.IconBox(gui.Icon.CircleCheck, 16, 16, 48, 48))
cromo
IconBox(Icon icon, i32 x, i32 y, i32 width, i32 height)

An icon box with its icon; Icon.None shows nothing. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#IconBox.setIcon

cromo
void setIcon(Icon value) const

Changes the icon; Icon.None shows nothing.

#IconBox.icon

cromo
Icon icon() const

The icon shown, Icon.None for none.

#IconBox.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the icon box, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#IconBox.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the icon box, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#IconBox.x

cromo
i32 x() const

The distance of the icon box from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#IconBox.y

cromo
i32 y() const

The distance of the icon box from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#IconBox.width

cromo
i32 width() const

The width of the icon box now, in logical pixels: a Stretch anchor changes it with its parent.

#IconBox.height

cromo
i32 height() const

The height of the icon box now, in logical pixels: a Stretch anchor changes it with its parent.

#IconBox.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the icon box for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#IconBox.tooltip

cromo
string tooltip() const

The text of the tooltip of the icon box, "" for none.

#IconBox.setVisible

cromo
void setVisible(bool value) const

Shows or hides the icon box.

#IconBox.visible

cromo
bool visible() const

Whether the icon box is visible, as setVisible set it: true by default.

#IconBox.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the icon box: disabled, it is drawn at half its opacity.

#IconBox.enabled

cromo
bool enabled() const

Whether the icon box is enabled, as setEnabled set it: true by default.

#IconBox.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the icon box follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#IconBox.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the icon box follows the left and the right edges of its parent: Horizontal.Left by default.

#IconBox.verticalAnchor

cromo
Vertical verticalAnchor() const

How the icon box follows the top and the bottom edges of its parent: Vertical.Top by default.

#IconBox.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#IconBox.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#IconBox.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#IconBox.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#IconBox.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#IconBox.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#Panel

cromo
struct Panel : Component

A container with no look of its own: its components take their positions from its top left corner, as in a group, and are drawn only inside it. A panel scrolls up and down when its components anchored to the top go below its bottom edge: with a finger, with the wheel of the mouse, or with the thin bar that shows on its right. There is nothing to write for it. Its components anchored otherwise stay where they are on the part that is seen, as a button over a list. A page of a navigation bar is a panel.

cromo
gui.Panel form = w.add(gui.Panel(0, 0, 420, 300))
form.setAnchor(gui.Horizontal.Stretch, gui.Vertical.Stretch)
for (i64 i = 0; i < 20; i++) {
    form.add(gui.CheckBox(format("Option {}", i + 1), 16, 16 + 32 * i32(i), 300, 22))
}
cromo
Panel(i32 x, i32 y, i32 width, i32 height)

A panel, empty. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#Panel.add

cromo
T add<T : Component>(T component) const

Puts a component in the panel, with its position from the top left corner of the panel, and gives it back. A component that is already in a window or in a group is a panic, and so are an app bar and a panel put in itself or in a panel that it holds.

#Panel.scrollY

cromo
i32 scrollY() const

How far the panel is scrolled, in logical pixels from the top: 0 when it is not.

#Panel.scrollTo

cromo
void scrollTo(i32 y) const

Scrolls the panel so that y, in logical pixels from the top of its content, is at its top edge: 0 goes back to the top. At the next frame the value is kept between 0 and the most that the components of the panel allow.

#Panel.setPalette

cromo
void setPalette(Palette light, Palette dark) const

Gives what the panel holds its own colors, for the light theme and for the dark one, in place of those of the window: a side bar in dark colors, a card in those of a brand. The theme of the window says which of the two is shown. The panel draws no background by itself: setBackground(gui.role(gui.Role.Background)) gives it the one of its palette.

#Panel.resetPalette

cromo
void resetPalette() const

Gives what the panel holds the colors of the window again.

#Panel.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the panel, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#Panel.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the panel, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#Panel.x

cromo
i32 x() const

The distance of the panel from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#Panel.y

cromo
i32 y() const

The distance of the panel from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#Panel.width

cromo
i32 width() const

The width of the panel now, in logical pixels: a Stretch anchor changes it with its parent.

#Panel.height

cromo
i32 height() const

The height of the panel now, in logical pixels: a Stretch anchor changes it with its parent.

#Panel.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the panel for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#Panel.tooltip

cromo
string tooltip() const

The text of the tooltip of the panel, "" for none.

#Panel.setVisible

cromo
void setVisible(bool value) const

Shows or hides the panel, and its components with it.

#Panel.visible

cromo
bool visible() const

Whether the panel is visible, as setVisible set it: true by default.

#Panel.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the panel, and its components with it: disabled, they are drawn at half their opacity and take neither the mouse nor the keys.

#Panel.enabled

cromo
bool enabled() const

Whether the panel is enabled, as setEnabled set it: true by default.

#Panel.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the panel follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#Panel.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the panel follows the left and the right edges of its parent: Horizontal.Left by default.

#Panel.verticalAnchor

cromo
Vertical verticalAnchor() const

How the panel follows the top and the bottom edges of its parent: Vertical.Top by default.

#Panel.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#Panel.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#Panel.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#Panel.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#Panel.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#Panel.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#Split

cromo
struct Split : Component

Two panels side by side, or one over the other, that share its room: the first takes a part of it, half by default, or a fixed size, and the second the rest, with a gap of 8 pixels between them. When the split changes size, as with a Stretch anchor, its panels follow it, and splits in the panels of other splits make the grid of a page. With setDraggable(true) the user moves the line between them.

cromo
gui.Split split = w.add(gui.Split(gui.Direction.Across, 0, 0, 800, 600))
split.setAnchor(gui.Horizontal.Stretch, gui.Vertical.Stretch)
split.setFirstSize(240)   // a side bar of 240 pixels, the rest to the content
split.setDraggable(true)
split.first().add(gui.Label("Folders", 12, 8, 200, 24))
cromo
Split(Direction direction, i32 x, i32 y, i32 width, i32 height)

A split with its two panels, empty. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size, with the gap.

#Split.first

cromo
Panel first() const

The first panel: on the left, or on top. Its components take their positions from its top left corner; its own position and size are those that the split gives it, whatever is set. It scrolls as the other panels when its components go beyond it.

#Split.second

cromo
Panel second() const

The second panel: on the right, or under the first, as first says.

#Split.direction

cromo
Direction direction() const

How the split puts its panels, as it was made.

#Split.setRatio

cromo
void setRatio(f32 value) const

Gives the first panel the part value of the room, the size of the split less the gap, and the second the rest: 0.5 by default. A value out of 0 to 1 is a panic. It ends a fixed size set with setFirstSize or setSecondSize.

#Split.ratio

cromo
f32 ratio() const

The part of the room of the first panel: as set, or as the user left it moving the line; with a fixed size, the part that it is of the room now.

#Split.setFirstSize

cromo
void setFirstSize(i32 pixels) const

Keeps the first panel pixels wide, or high, whatever the size of the split, and the second takes the rest, as a side bar and its content. A negative size is a panic.

#Split.setSecondSize

cromo
void setSecondSize(i32 pixels) const

Keeps the second panel pixels wide, or high, and the first takes the rest. A negative size is a panic.

#Split.setMinimums

cromo
void setMinimums(i32 first, i32 second) const

The least sizes of the panels in logical pixels, 0 by default: the first has at least its own, and then the second, as far as the room allows. A negative size is a panic.

#Split.setGap

cromo
void setGap(i32 pixels) const

The room between the panels, in logical pixels: 8 by default. A negative gap is a panic.

#Split.gap

cromo
i32 gap() const

The room between the panels, in logical pixels.

#Split.setDraggable

cromo
void setDraggable(bool value) const

Lets the user move the line between the panels with the mouse or a finger, or not: not by default. The line moves within the least sizes, and changes the part of the first panel, or the fixed size.

#Split.draggable

cromo
bool draggable() const

Whether the user can move the line, as setDraggable set it: false by default.

#Split.onChange

cromo
void onChange(move func(f32) handler) const

Adds a handler called each time the user moves the line, with the part of the room of the first panel now, as ratio gives it.

#Split.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the split, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#Split.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the split, in logical pixels, and so those of its panels. Its anchors keep the distances from the edges that it has with the new size.

#Split.x

cromo
i32 x() const

The distance of the split from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#Split.y

cromo
i32 y() const

The distance of the split from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#Split.width

cromo
i32 width() const

The width of the split now, in logical pixels: a Stretch anchor changes it with its parent.

#Split.height

cromo
i32 height() const

The height of the split now, in logical pixels: a Stretch anchor changes it with its parent.

#Split.setVisible

cromo
void setVisible(bool value) const

Shows or hides the split, and its panels with it.

#Split.visible

cromo
bool visible() const

Whether the split is visible, as setVisible set it: true by default.

#Split.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the split, and its panels with it: disabled, their components are drawn at half their opacity and take neither the mouse nor the keys, and the line does not move.

#Split.enabled

cromo
bool enabled() const

Whether the split is enabled, as setEnabled set it: true by default.

#Split.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the split follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now; with Stretch its panels share the new size. By default it is anchored to the left and to the top, and does not move.

#Split.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the split follows the left and the right edges of its parent: Horizontal.Left by default.

#Split.verticalAnchor

cromo
Vertical verticalAnchor() const

How the split follows the top and the bottom edges of its parent: Vertical.Top by default.

#Split.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#Split.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#Split.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#Split.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#Split.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#Split.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#AppBar

cromo
struct AppBar : Component

The bar at the top of an app: its title, an icon on its left, as a menu or an arrow back, and the icons of its actions on its right. Put in a window with add, it takes the top of the content, the whole width and 44 pixels, 56 on a phone: the other components of the window go under it, and the pages of a navigation bar start there by themselves. On the desktop it is under the title bar of the window.

cromo
gui.AppBar top = w.add(gui.AppBar("Inbox"))
top.setNavigation(gui.Icon.Menu)
top.onNavigation([]() { println("the menu") })
top.addAction(gui.Icon.Search, [w]() { w.showSnackbar("Search") })
cromo
AppBar(string title)

An app bar with its title, to put in a window with add. A window has one at most: a second one, or an app bar put in a group, a panel or a dialog, is a panic of add.

#AppBar.setTitle

cromo
void setTitle(string value) const

Changes the title of the bar.

#AppBar.title

cromo
string title() const

The title of the bar.

#AppBar.setNavigation

cromo
void setNavigation(Icon value) const

Puts an icon on the left of the bar, as Icon.Menu or Icon.ArrowLeft, which calls the handlers of onNavigation when it is clicked; Icon.None removes it.

#AppBar.navigation

cromo
Icon navigation() const

The icon on the left of the bar, Icon.None without one.

#AppBar.onNavigation

cromo
void onNavigation(move func() handler) const

Adds a handler, called on the thread of the windows when the user clicks or touches the icon on the left of the bar.

#AppBar.addAction

cromo
void addAction(Icon icon, move func() handler) const

Adds an icon on the right of the bar, with the handler that a click or a touch on it calls on the thread of the windows. The first action added is at the right edge, and each next one on the left of the one before.

#AppBar.setActionTooltip

cromo
void setActionTooltip(i64 index, string text) const

Gives the action at index, from 0 in the order they were added, a tooltip, shown when the mouse stays on it. An index out of the actions is a panic.

#AppBar.x

cromo
i32 x() const

The distance of the app bar from the left edge of the content: 0.

#AppBar.y

cromo
i32 y() const

The distance of the app bar from the top of the content: 0.

#AppBar.width

cromo
i32 width() const

The width of the app bar, in logical pixels: that of the content of its window, once it is in one.

#AppBar.height

cromo
i32 height() const

The height of the app bar: 56 logical pixels.

#AppBar.setVisible

cromo
void setVisible(bool value) const

Shows or hides the app bar: the room that it takes at the top stays empty.

#AppBar.visible

cromo
bool visible() const

Whether the app bar is visible, as setVisible set it: true by default.

#AppBar.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the app bar: disabled, it is drawn at half its opacity and its icons do not respond.

#AppBar.enabled

cromo
bool enabled() const

Whether the app bar is enabled, as setEnabled set it: true by default.

#AppBar.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#AppBar.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#AppBar.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#AppBar.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#AppBar.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#AppBar.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

cromo
struct NavigationBar : Component

The bar at the bottom of an app, whose items, an icon and a text each, choose the page that is shown. A window has one, made the first time that Window.navigationBar is called: it takes the bottom of the content, the whole width and 56 pixels, 64 on a phone. Each page is a panel that fills the room between it and the app bar, and scrolls when its components go below its bottom. On a phone the keyboard on the screen covers the bar, and the pages go down to the keyboard.

cromo
gui.NavigationBar bar = w.navigationBar()
gui.Panel home = bar.addPage("Home", gui.Icon.House)
home.add(gui.Label("Welcome", 16, 16, 200, 20))
gui.Panel settings = bar.addPage("Settings", gui.Icon.Settings)
bar.onChange([top](i64 index) { top.setTitle(index == 0 ? "Home" : "Settings") })
cromo
Panel addPage(string text, Icon icon) const

Adds an item with its text and its icon, and gives back its page: a panel that fills the room between the bars, follows the size of the window, and is shown while its item is chosen. Its components take their positions from its top left corner; its own position and size are those of the room, whatever is set.

cromo
void setSelected(i64 index) const

Chooses the item at index, from 0, and shows its page, without calling the handlers of onChange. An index out of the items is a panic.

cromo
i64 selected() const

The index of the item chosen, whose page is shown: 0 at the start.

cromo
void onChange(move func(i64) handler) const

Adds a handler, called on the thread of the windows with the index of the item that the user chooses, when it is not the one chosen before. setSelected does not call it.

cromo
i32 x() const

The distance of the navigation bar from the left edge of the content: 0.

cromo
i32 y() const

The distance of the navigation bar from the top of the content, in logical pixels: the height of the content less the 64 of the bar.

cromo
i32 width() const

The width of the navigation bar, in logical pixels: that of the content of its window.

cromo
i32 height() const

The height of the navigation bar: 64 logical pixels.

cromo
void setVisible(bool value) const

Shows or hides the navigation bar, and its pages with it.

cromo
bool visible() const

Whether the navigation bar is visible, as setVisible set it: true by default.

cromo
void setEnabled(bool value) const

Enables or disables the navigation bar: disabled, it is drawn at half its opacity and its items do not respond; its pages stay as they are.

cromo
bool enabled() const

Whether the navigation bar is enabled, as setEnabled set it: true by default.

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#ListView

cromo
struct ListView : Component

A list of items in rows of 44 pixels, 56 on a phone, as those of an app of mail: each has an icon or a round image, a title, a line under it and a text on its right, as a time, all optional. Only the rows that are seen are drawn, so a list can have thousands of items, and it scrolls as a panel, with a finger, the wheel or its bar. The item chosen stays lit: a click, a touch, or Up, Down, Home, End, Page Up and Page Down while the list has the keyboard, choose an item and call the handlers of onChoose with its index.

cromo
gui.ListView inbox = page.add(gui.ListView(0, 0, 390, 605))
inbox.setAnchor(gui.Horizontal.Stretch, gui.Vertical.Stretch)
inbox.addItem(gui.Icon.User, "Ada Lovelace", "The notes on the engine", "10:42")
inbox.addItem(gui.Icon.Mail, "The workshop", "The report of the day", "Mon")
inbox.setItemImageBytes(0, embed("images/ada.png"))
inbox.onChoose([inbox](i64 index) { println("open {}", inbox.itemTitle(index)) })
cromo
ListView(i32 x, i32 y, i32 width, i32 height)

An empty list. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#ListView.addItem

cromo
void addItem(Icon icon, string title, string subtitle, string detail) const

Adds an item at the end: its icon, its title, the line under the title and the text on the right, with Icon.None and "" for what the item does not have.

#ListView.insertItem

cromo
void insertItem(i64 index, Icon icon, string title, string subtitle, string detail) const

Inserts an item before the one at index, or at the end with count(), with the same parts as addItem. The item chosen stays the same, at its new index. An index below 0 or above count() is a panic.

#ListView.setItem

cromo
void setItem(i64 index, Icon icon, string title, string subtitle, string detail) const

Replaces the icon and the texts of the item at index, which keeps its image and stays chosen if it is. An index out of the items is a panic.

#ListView.removeItem

cromo
void removeItem(i64 index) const

Removes the item at index, with its image; if it was the item chosen, none is. The items after it go back by one, and so does the index of the item chosen. An index out of the items is a panic.

#ListView.clear

cromo
void clear() const

Removes all the items, with their images, leaves none chosen, and scrolls back to the top.

#ListView.count

cromo
i64 count() const

How many items the list has.

#ListView.itemTitle

cromo
string itemTitle(i64 index) const

The title of the item at index. An index out of the items is a panic.

#ListView.itemSubtitle

cromo
string itemSubtitle(i64 index) const

The line under the title of the item at index, "" if it has none. An index out of the items is a panic.

#ListView.itemDetail

cromo
string itemDetail(i64 index) const

The text on the right of the item at index, "" if it has none. An index out of the items is a panic.

#ListView.itemIcon

cromo
Icon itemIcon(i64 index) const

The icon of the item at index, Icon.None if it has none. An index out of the items is a panic.

#ListView.setSelected

cromo
void setSelected(i64 index) const

Chooses the item at index, which stays lit, or none with -1, without calling the handlers of onChoose and without scrolling to it, which scrollTo does. Another index out of the items is a panic.

#ListView.selected

cromo
i64 selected() const

The index of the item chosen, from 0, or -1 when none is: the default.

#ListView.onChoose

cromo
void onChoose(move func(i64) handler) const

Adds a handler, called on the thread of the windows with the index of the item that the user chooses, with a click, a touch or the keys, also when it was the item chosen already. setSelected does not call it.

#ListView.setItemImage

cromo
void setItemImage(i64 index, string file) const

Shows a round image of 40 pixels in place of the icon of the item at index, as the photo of a contact: the square at the center of the image of file, in PNG, JPEG, BMP or GIF, read and decoded by this thread. "" removes it. Throws an Error when the file cannot be read, is empty or is not an image; an index out of the items is a panic.

#ListView.setItemImageBytes

cromo
void setItemImageBytes(i64 index, list<u8> bytes) const

Shows a round image in place of the icon of the item at index, as setItemImage does, from an image in memory, as embed gives it; an empty list removes it. Throws an Error when the bytes are not an image; an index out of the items is a panic.

#ListView.scrollTo

cromo
void scrollTo(i64 index) const

Scrolls the list as little as it takes to show the item at index. An index out of the items is a panic.

#ListView.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the list, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#ListView.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the list, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#ListView.x

cromo
i32 x() const

The distance of the list from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#ListView.y

cromo
i32 y() const

The distance of the list from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#ListView.width

cromo
i32 width() const

The width of the list now, in logical pixels: a Stretch anchor changes it with its parent.

#ListView.height

cromo
i32 height() const

The height of the list now, in logical pixels: a Stretch anchor changes it with its parent.

#ListView.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the list: hidden for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#ListView.tooltip

cromo
string tooltip() const

The text of the tooltip of the list: hidden, "" for none.

#ListView.setVisible

cromo
void setVisible(bool value) const

Shows or hides the list: hidden, it takes neither the mouse nor the keys.

#ListView.visible

cromo
bool visible() const

Whether the list is visible, as setVisible set it: true by default.

#ListView.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the list: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.

#ListView.enabled

cromo
bool enabled() const

Whether the list is enabled, as setEnabled set it: true by default.

#ListView.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the list follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#ListView.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the list follows the left and the right edges of its parent: Horizontal.Left by default.

#ListView.verticalAnchor

cromo
Vertical verticalAnchor() const

How the list follows the top and the bottom edges of its parent: Vertical.Top by default.

#ListView.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#ListView.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#ListView.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#ListView.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#ListView.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#ListView.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#Switch

cromo
struct Switch : Component

A switch, on or off, as those in the settings of a phone: its text on the left and the switch at the right edge of its box. A click, a touch, or Space while it has the keyboard, turns it, and calls its handlers of onChange with the new state.

cromo
gui.Switch notify = w.add(gui.Switch("Notifications", 16, 16, 358, 32))
notify.setChecked(true)
notify.onChange([](bool on) { println("notifications: {}", on) })
cromo
Switch(string text, i32 x, i32 y, i32 width, i32 height)

A switch with its text, off. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size, with the text.

#Switch.onChange

cromo
void onChange(move func(bool) handler) const

Adds a handler, called on the thread of the windows with the new state when the user turns the switch on or off. setChecked does not call it.

#Switch.setChecked

cromo
void setChecked(bool value) const

Turns the switch on, with true, or off, without calling the handlers of onChange.

#Switch.checked

cromo
bool checked() const

Whether the switch is on: false at the start.

#Switch.setText

cromo
void setText(string value) const

Changes the text on the left of the switch.

#Switch.text

cromo
string text() const

The text on the left of the switch.

#Switch.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the switch, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#Switch.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the switch, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#Switch.x

cromo
i32 x() const

The distance of the switch from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#Switch.y

cromo
i32 y() const

The distance of the switch from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#Switch.width

cromo
i32 width() const

The width of the switch now, in logical pixels: a Stretch anchor changes it with its parent.

#Switch.height

cromo
i32 height() const

The height of the switch now, in logical pixels: a Stretch anchor changes it with its parent.

#Switch.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the switch: hidden for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#Switch.tooltip

cromo
string tooltip() const

The text of the tooltip of the switch: hidden, "" for none.

#Switch.setVisible

cromo
void setVisible(bool value) const

Shows or hides the switch: hidden, it takes neither the mouse nor the keys.

#Switch.visible

cromo
bool visible() const

Whether the switch is visible, as setVisible set it: true by default.

#Switch.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the switch: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.

#Switch.enabled

cromo
bool enabled() const

Whether the switch is enabled, as setEnabled set it: true by default.

#Switch.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the switch follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#Switch.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the switch follows the left and the right edges of its parent: Horizontal.Left by default.

#Switch.verticalAnchor

cromo
Vertical verticalAnchor() const

How the switch follows the top and the bottom edges of its parent: Vertical.Top by default.

#Switch.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#Switch.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#Switch.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#Switch.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#Switch.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#Switch.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#Slider

cromo
struct Slider : Component

An integer between a minimum and a maximum, as a volume or a quantity, chosen by dragging the knob, with a click on the track, or with the keys while the slider has the keyboard: Left and Down take 1, Right and Up add 1, Page Down and Page Up move by a tenth of the range, Home and End go to the minimum and to the maximum. A value with decimals comes from dividing it. Its handlers of onChange receive the new value, also while the knob is dragged.

cromo
gui.Label size = w.add(gui.Label("Text size: 100%", 16, 64, 358, 20))
gui.Slider zoom = w.add(gui.Slider(80, 150, 16, 88, 358, 32))
zoom.setValue(100)
zoom.onChange([size](i64 value) { size.setText(format("Text size: {}%", value)) })
cromo
Slider(i64 minimum, i64 maximum, i32 x, i32 y, i32 width, i32 height)

A slider from minimum to maximum, both included, at the minimum. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size. A minimum above the maximum is a panic.

#Slider.onChange

cromo
void onChange(move func(i64) handler) const

Adds a handler, called on the thread of the windows with the new value whenever the user changes it, also while the knob is dragged. setValue does not call it.

#Slider.setValue

cromo
void setValue(i64 value) const

Sets the value, kept between the minimum and the maximum, without calling the handlers of onChange.

#Slider.value

cromo
i64 value() const

The value now, between the minimum and the maximum.

#Slider.minimum

cromo
i64 minimum() const

The smallest value, at the left end of the track.

#Slider.maximum

cromo
i64 maximum() const

The largest value, at the right end of the track.

#Slider.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the slider, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#Slider.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the slider, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#Slider.x

cromo
i32 x() const

The distance of the slider from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#Slider.y

cromo
i32 y() const

The distance of the slider from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#Slider.width

cromo
i32 width() const

The width of the slider now, in logical pixels: a Stretch anchor changes it with its parent.

#Slider.height

cromo
i32 height() const

The height of the slider now, in logical pixels: a Stretch anchor changes it with its parent.

#Slider.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the slider: hidden for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#Slider.tooltip

cromo
string tooltip() const

The text of the tooltip of the slider: hidden, "" for none.

#Slider.setVisible

cromo
void setVisible(bool value) const

Shows or hides the slider: hidden, it takes neither the mouse nor the keys.

#Slider.visible

cromo
bool visible() const

Whether the slider is visible, as setVisible set it: true by default.

#Slider.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the slider: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.

#Slider.enabled

cromo
bool enabled() const

Whether the slider is enabled, as setEnabled set it: true by default.

#Slider.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the slider follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#Slider.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the slider follows the left and the right edges of its parent: Horizontal.Left by default.

#Slider.verticalAnchor

cromo
Vertical verticalAnchor() const

How the slider follows the top and the bottom edges of its parent: Vertical.Top by default.

#Slider.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#Slider.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#Slider.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#Slider.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#Slider.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#Slider.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#Table

cromo
struct Table : Component

Rows of cells in columns, with their titles at the top: also millions of rows, since the table keeps only those near the ones shown. It knows how many rows it has, and asks for those it must show and does not have with onNeedRows; the program gives them with setRows, also later and from another thread, and a row not given yet is empty. A small table gives all its rows at once.

A click on the title of a column calls onSort, and the program sorts its rows and gives them again. A click chooses a row, Ctrl and a click add or remove one, Shift and a click choose those between; the arrows, Page Up, Page Down, Home and End move the row chosen, and a double click or Enter opens it, with onChoose.

cromo
gui.Table orders = w.add(gui.Table(16, 16, 600, 400))
orders.addColumn("Customer", 0, gui.Horizontal.Left)    // the room left
orders.addColumn("Total", 96, gui.Horizontal.Right)
orders.setRowCount(1000000)
orders.onNeedRows([orders](i64 first, i64 count) {
    list<list<string>> rows
    for (i64 i = first; i < first + count; i++) {
        rows.add([format("Customer {}", i), format("{}.00", i % 1000)])
    }
    orders.setRows(first, rows)
})
cromo
Table(i32 x, i32 y, i32 width, i32 height)

A table without columns and without rows. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#Table.addColumn

cromo
void addColumn(string title, i32 width, Horizontal align) const

Adds a column at the right of the others, with its title and its width in logical pixels; a width of 0 takes the room that the others leave, shared among the columns of width 0. align places the title and the cells: Horizontal.Left, Center or Right.

#Table.columnCount

cromo
i64 columnCount() const

The number of the columns, also those hidden.

#Table.setColumnVisible

cromo
void setColumnVisible(i64 index, bool visible) const

Shows or hides the column at index, from 0; the others take its place. An index out of the columns is a panic.

#Table.setRowCount

cromo
void setRowCount(i64 count) const

Changes the number of the rows. The rows already given stay, those beyond the number are forgotten, and so are the chosen ones beyond it.

#Table.rowCount

cromo
i64 rowCount() const

The number of the rows.

#Table.setRows

cromo
void setRows(i64 first, list<list<string>> rows) const

Gives the cells of the rows from first, a list of strings for each row, in the order of the columns. It can be called from any thread, as the answer to onNeedRows or before; the rows beyond the number of the rows are ignored.

#Table.clearRows

cromo
void clearRows() const

Forgets all the rows given, as after the rows were sorted or filtered: the table asks again for those it shows. The rows chosen stay.

#Table.cell

cromo
string cell(i64 row, i64 column) const

The cell of a row and a column, from 0, or "" when the row has not been given.

#Table.onNeedRows

cromo
void onNeedRows(move func(i64, i64) handler) const

Adds a handler, called on the thread of the windows when the table shows rows that it does not have: first and count, the rows to give with setRows. It asks for each row once, in blocks of 100, until clearRows.

#Table.onSort

cromo
void onSort(move func(i64, bool) handler) const

Adds a handler, called on the thread of the windows when the user clicks the title of a column: the column, from 0, and whether the order is descending, true at the second click on the same column. The table shows the order with an arrow; the program sorts its rows and gives them again.

#Table.setSort

cromo
void setSort(i64 column, bool descending) const

Shows the order of a column, -1 for none, without calling the handlers of onSort.

#Table.sortColumn

cromo
i64 sortColumn() const

The column of the order, or -1.

#Table.sortDescending

cromo
bool sortDescending() const

Whether the order is descending.

#Table.onChange

cromo
void onChange(move func(i64) handler) const

Adds a handler, called on the thread of the windows when the row chosen changes, with a click or with the keys: the row, from 0. With Ctrl and Shift the rows chosen can be more: selectedRows gives them all.

#Table.onChoose

cromo
void onChoose(move func(i64) handler) const

Adds a handler, called on the thread of the windows when the user opens a row: a double click on it, or Enter while the table has the keyboard.

#Table.setSelected

cromo
void setSelected(i64 index) const

Chooses only the row at index, or none with -1, and scrolls to show it, without calling the handlers of onChange. An index out of the rows is a panic.

#Table.selected

cromo
i64 selected() const

The row chosen last, from 0, or -1 for none.

#Table.selectedRows

cromo
list<i64> selectedRows() const

All the rows chosen, in order. Shift and a click on a table of millions of rows can choose millions of them.

#Table.scrollTo

cromo
void scrollTo(i64 index) const

Scrolls the table to show the row at index, from 0.

#Table.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the table, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#Table.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the table, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#Table.x

cromo
i32 x() const

The distance of the table from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#Table.y

cromo
i32 y() const

The distance of the table from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#Table.width

cromo
i32 width() const

The width of the table now, in logical pixels: a Stretch anchor changes it with its parent.

#Table.height

cromo
i32 height() const

The height of the table now, in logical pixels: a Stretch anchor changes it with its parent.

#Table.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the table for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#Table.tooltip

cromo
string tooltip() const

The text of the tooltip of the table, "" for none.

#Table.setVisible

cromo
void setVisible(bool value) const

Shows or hides the table.

#Table.visible

cromo
bool visible() const

Whether the table is visible, as setVisible set it: true by default.

#Table.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the table: disabled, it is drawn at half its opacity.

#Table.enabled

cromo
bool enabled() const

Whether the table is enabled, as setEnabled set it: true by default.

#Table.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the table follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#Table.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the table follows the left and the right edges of its parent: Horizontal.Left by default.

#Table.verticalAnchor

cromo
Vertical verticalAnchor() const

How the table follows the top and the bottom edges of its parent: Vertical.Top by default.

#Table.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#Table.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#Table.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#Table.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#Table.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#Table.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#RichText

cromo
struct RichText

Rich text, which a TextView shows: pieces of text in their styles, which go to the next line by themselves, at the spaces and at the gaps; small images among them; new lines; and blocks, with a margin on their left and a line along it. A piece made with link has a number, and the view says when the user clicks it. A rich text is a value: the program builds it, on any thread, and hands it to the view with TextView.setText, which keeps it until the next one.

cromo
gui.TextStyle plain = gui.TextStyle(gui.Ink.Normal)
gui.TextStyle code = gui.TextStyle(gui.Ink.Accent)
code.mono = true
gui.RichText t
t.text("Call ", plain)
t.link(1, "connect()", code)
t.text(" before you send.", plain)
t.startBlock(14, gui.BlockLine.Selection)
t.text("It waits at most 5 seconds.", plain)
t.endBlock()
view.setText(move t)

#RichText.text

cromo
void text(string value, TextStyle style)

Adds a text in a style. It breaks into lines at its spaces, and "\n" starts a new line.

cromo
void link(i64 piece, string value, TextStyle style)

Adds a text that the user can click, with the number of its piece, from 0: the texts and the images that follow one another with the same number are one piece, which does not break into lines, is lit under the mouse and is marked as a whole. A number less than 0 is a panic.

#RichText.image

cromo
void image(Image picture, f32 width, f32 height)

Adds an image among the words, as large as width by height logical pixels allow with its proportions, in the middle of the line.

#RichText.linkImage

cromo
void linkImage(i64 piece, Image picture, f32 width, f32 height)

Adds an image that the user can click, as a part of the piece with that number, as link does with a text.

#RichText.gap

cromo
void gap(f32 width)

Adds an empty space width logical pixels wide, where the line can break, as a space can.

#RichText.newLine

cromo
void newLine()

Ends the line: what follows starts on the next one. Two new lines leave an empty line between.

#RichText.startBlock

cromo
void startBlock(f32 indent, BlockLine line)

Starts a block on a new line, indent logical pixels from the left of the text around it, with a line along its left edge, as line says; its text starts 10 pixels after the line. Blocks can be inside blocks.

#RichText.endBlock

cromo
void endBlock()

Ends the last block started: what follows goes on under it, at the left of the text around it. Without a block started it is a panic.

#RichText.tooltip

cromo
void tooltip(i64 piece, string text)

Gives the piece with that number a tooltip, shown when the mouse stays on it.

#RichText.clear

cromo
void clear()

Removes everything.

#RichText.len

cromo
i64 len() const

The number of the parts added: texts, images, gaps, new lines, starts and ends of blocks.

#TextView

cromo
struct TextView : Component

A view of rich text, as an article, a log, a discussion or a list of links: it shows the RichText given to setText on the surface, goes to the next line by itself at its width, and scrolls when the text is longer than its height. It says which piece the user clicks, with any button, and marks one piece, as the current one, in the accent.

cromo
gui.TextView notes = w.add(gui.TextView(16, 16, 360, 240))
notes.setText(move t)
notes.onClick([notes](i64 piece, gui.Mouse m) { notes.setMarked(piece) })
cromo
TextView(i32 x, i32 y, i32 width, i32 height)

A text view, empty. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#TextView.setText

cromo
void setText(move RichText text) const

Shows the rich text, in place of the one shown before, and stays where it was scrolled. It can be called from any thread; the blocks not ended end with the text.

#TextView.onClick

cromo
void onClick(move func(i64, Mouse) handler) const

Adds a handler, called on the thread of the windows when the user clicks a piece made with link or linkImage, with any button of the mouse: the number of the piece, and where the mouse is, from the top left corner of the view, with its button, 1 left, 2 middle, 3 right. A click is a press and a release on the same piece.

#TextView.setMarked

cromo
void setMarked(i64 piece) const

Marks the piece with that number in the accent, semibold, as the current one, and scrolls as little as it takes to show it; -1 marks none. A number that the text does not have marks nothing.

#TextView.marked

cromo
i64 marked() const

The number of the piece marked, or -1.

#TextView.scrollTo

cromo
void scrollTo(i64 piece) const

Scrolls the view as little as it takes to show the piece with that number.

#TextView.scrollY

cromo
i32 scrollY() const

How far the view is scrolled, in logical pixels from the top: 0 when it is not.

#TextView.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text, in logical pixels, from 6 to 72, to which the scale of the styles applies: by default that of the text of the components, 13 on the desktop and 14 on a phone. A size out of the range is a panic.

#TextView.textSize

cromo
f32 textSize() const

The size of the text, in logical pixels.

#TextView.setLineSpacing

cromo
void setLineSpacing(f32 value) const

Sets the height of the lines, from the size of their text: from 1 to 3, 1.5 by default. A value out of the range is a panic.

#TextView.lineSpacing

cromo
f32 lineSpacing() const

The height of the lines, from the size of their text.

#TextView.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the view, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#TextView.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the view, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#TextView.x

cromo
i32 x() const

The distance of the view from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#TextView.y

cromo
i32 y() const

The distance of the view from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#TextView.width

cromo
i32 width() const

The width of the view now, in logical pixels: a Stretch anchor changes it with its parent.

#TextView.height

cromo
i32 height() const

The height of the view now, in logical pixels: a Stretch anchor changes it with its parent.

#TextView.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the view for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#TextView.tooltip

cromo
string tooltip() const

The text of the tooltip of the view, "" for none.

#TextView.setVisible

cromo
void setVisible(bool value) const

Shows or hides the view.

#TextView.visible

cromo
bool visible() const

Whether the view is visible, as setVisible set it: true by default.

#TextView.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the view: disabled, it is drawn at half its opacity.

#TextView.enabled

cromo
bool enabled() const

Whether the view is enabled, as setEnabled set it: true by default.

#TextView.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the view follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#TextView.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the view follows the left and the right edges of its parent: Horizontal.Left by default.

#TextView.verticalAnchor

cromo
Vertical verticalAnchor() const

How the view follows the top and the bottom edges of its parent: Vertical.Top by default.

#TextView.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#TextView.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#TextView.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#TextView.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#TextView.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors and its corners.

#TabView

cromo
struct TabView : Component

Pages one over the other in a card, with their tabs in the band at its top: a click on a tab shows its page, and while the tabs have the keyboard Left, Right, Home and End choose one. Each page is a panel that fills the card under the band, with its components; the first tab is chosen at the start.

cromo
gui.TabView views = w.add(gui.TabView(16, 16, 520, 300))
gui.Panel files = views.addPage("Files")
files.add(gui.ListView(0, 0, 518, 267))
gui.Panel notes = views.addPage("Notes")
views.onChange([](i64 index) { println("tab {}", index) })
cromo
TabView(i32 x, i32 y, i32 width, i32 height)

A card without tabs. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size, with the band of the tabs.

#TabView.addPage

cromo
Panel addPage(string title) const

Adds a tab with its title, on the right of the others, and gives back its page: a panel that fills the card under the band and follows its size, shown while its tab is chosen. Its components take their positions from its top left corner; its own position and size are those of the card, whatever is set.

#TabView.pageCount

cromo
i64 pageCount() const

The number of the tabs.

#TabView.setPageTitle

cromo
void setPageTitle(i64 index, string title) const

Changes the title of the tab at index, from 0. An index out of the tabs is a panic.

#TabView.pageTitle

cromo
string pageTitle(i64 index) const

The title of the tab at index, from 0. An index out of the tabs is a panic.

#TabView.setSelected

cromo
void setSelected(i64 index) const

Chooses the tab at index, from 0, and shows its page, without calling the handlers of onChange. An index out of the tabs is a panic.

#TabView.selected

cromo
i64 selected() const

The index of the tab chosen, whose page is shown: 0 at the start.

#TabView.onChange

cromo
void onChange(move func(i64) handler) const

Adds a handler, called on the thread of the windows with the index of the tab that the user chooses, when it is not the one chosen before. setSelected does not call it.

#TabView.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the tab view, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#TabView.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the tab view, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#TabView.x

cromo
i32 x() const

The distance of the tab view from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#TabView.y

cromo
i32 y() const

The distance of the tab view from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#TabView.width

cromo
i32 width() const

The width of the tab view now, in logical pixels: a Stretch anchor changes it with its parent.

#TabView.height

cromo
i32 height() const

The height of the tab view now, in logical pixels: a Stretch anchor changes it with its parent.

#TabView.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the tab view for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#TabView.tooltip

cromo
string tooltip() const

The text of the tooltip of the tab view, "" for none.

#TabView.setVisible

cromo
void setVisible(bool value) const

Shows or hides the tab view.

#TabView.visible

cromo
bool visible() const

Whether the tab view is visible, as setVisible set it: true by default.

#TabView.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the tab view: disabled, it is drawn at half its opacity.

#TabView.enabled

cromo
bool enabled() const

Whether the tab view is enabled, as setEnabled set it: true by default.

#TabView.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the tab view follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#TabView.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the tab view follows the left and the right edges of its parent: Horizontal.Left by default.

#TabView.verticalAnchor

cromo
Vertical verticalAnchor() const

How the tab view follows the top and the bottom edges of its parent: Vertical.Top by default.

#TabView.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#TabView.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#TabView.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#TabView.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#TabView.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#TabView.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#Segmented

cromo
struct Segmented : Component

A row of buttons joined together, one of them chosen and filled with the accent : a choice among a few values that are all seen, as a view by day, by week or by month. The segments share the width in equal parts. A click chooses one, and while it has the keyboard Left, Right, Home and End do.

cromo
gui.Segmented period = w.add(gui.Segmented(["Day", "Week", "Month"], 16, 16, 240, 28))
period.onChange([](i64 index) { println("period {}", index) })
cromo
Segmented(list<string> segments, i32 x, i32 y, i32 width, i32 height)

A segmented control with a copy of its segments, the first one chosen. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#Segmented.setItems

cromo
void setItems(list<string> segments) const

Replaces the segments with a copy of segments, and chooses the first one.

#Segmented.items

cromo
list<string> items() const

A copy of the segments.

#Segmented.setSelected

cromo
void setSelected(i64 index) const

Chooses the segment at index, from 0, without calling the handlers of onChange. An index out of the segments is a panic.

#Segmented.selected

cromo
i64 selected() const

The index of the segment chosen, from 0: -1 only without segments.

#Segmented.text

cromo
string text() const

The text of the segment chosen, or "" without segments.

#Segmented.onChange

cromo
void onChange(move func(i64) handler) const

Adds a handler, called on the thread of the windows with the index of the segment that the user chooses, when it is not the one chosen before. setSelected and setItems do not call it.

#Segmented.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the segmented control, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#Segmented.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the segmented control, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#Segmented.x

cromo
i32 x() const

The distance of the segmented control from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#Segmented.y

cromo
i32 y() const

The distance of the segmented control from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#Segmented.width

cromo
i32 width() const

The width of the segmented control now, in logical pixels: a Stretch anchor changes it with its parent.

#Segmented.height

cromo
i32 height() const

The height of the segmented control now, in logical pixels: a Stretch anchor changes it with its parent.

#Segmented.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the segmented control for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#Segmented.tooltip

cromo
string tooltip() const

The text of the tooltip of the segmented control, "" for none.

#Segmented.setVisible

cromo
void setVisible(bool value) const

Shows or hides the segmented control.

#Segmented.visible

cromo
bool visible() const

Whether the segmented control is visible, as setVisible set it: true by default.

#Segmented.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the segmented control: disabled, it is drawn at half its opacity.

#Segmented.enabled

cromo
bool enabled() const

Whether the segmented control is enabled, as setEnabled set it: true by default.

#Segmented.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the segmented control follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#Segmented.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the segmented control follows the left and the right edges of its parent: Horizontal.Left by default.

#Segmented.verticalAnchor

cromo
Vertical verticalAnchor() const

How the segmented control follows the top and the bottom edges of its parent: Vertical.Top by default.

#Segmented.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#Segmented.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#Segmented.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#Segmented.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#Segmented.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#Segmented.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

cromo
struct Menu

A menu of items, as the one that the right button opens: a value that the program builds when it needs it, with a handler for each item, which captures what the menu is about, and opens with Window.showMenu where the mouse is. It goes away when an item is chosen, with Esc, or with a click out of it; Up, Down and Enter choose with the keys. An item can open a submenu. On a phone a long press on a piece of rich text is the right button.

cromo
view.onClick([w](i64 piece, gui.Mouse m) {
    if (m.button == 3) {
        gui.Menu menu
        menu.addItem("Copy", [piece]() { println("copy {}", piece) })
        menu.addSeparator()
        menu.addItem("Delete", [piece]() { println("delete {}", piece) })
        w.showMenu(move menu)
    }
})
cromo
void addItem(string text, move func() handler)

Adds an item with its text under the others, and its handler, called on the thread of the windows when the user chooses it, after the menu has gone away.

cromo
void addIconItem(Icon icon, string text, move func() handler)

Adds an item with an icon on the left of its text, as addItem does.

cromo
void addSeparator()

Adds a line between the items above and those below.

cromo
void addSubmenu(string text, move Menu submenu)

Adds an item that opens a submenu, with its text: the entries of submenu show on its right when the mouse is on it, or with the Right arrow, and Left closes it. A submenu can have submenus of its own.

cromo
void setEnabled(i64 index, bool enabled)

Enables or disables the entry at index, from 0, counting the separators and the items with a submenu too: a disabled item is gray and cannot be chosen. An index out of the entries, or that of a separator, is a panic.

cromo
i64 len() const

The number of the entries: the items, the separators and the items with a submenu.

cromo
void clear()

Removes all the entries.

#RadioGroup

cromo
struct RadioGroup : Component

A choice among a few values, one under the other, one of them chosen: a click chooses one, and while it has the keyboard the arrows do. The first one is chosen at the start.

cromo
gui.RadioGroup size = w.add(gui.RadioGroup(["Small", "Medium", "Large"], 16, 16, 200, 84))
size.onChange([size](i64 index) { println("size {}", size.text()) })
cromo
RadioGroup(list<string> choices, i32 x, i32 y, i32 width, i32 height)

A radio group with a copy of its choices, the first one chosen. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size: a choice takes 28 pixels of the height on the desktop and 44 on a phone.

#RadioGroup.setItems

cromo
void setItems(list<string> choices) const

Replaces the choices with a copy of choices, and chooses the first one.

#RadioGroup.items

cromo
list<string> items() const

A copy of the choices.

#RadioGroup.setSelected

cromo
void setSelected(i64 index) const

Chooses the choice at index, from 0, without calling the handlers of onChange. An index out of the choices is a panic.

#RadioGroup.selected

cromo
i64 selected() const

The index of the choice chosen, from 0: -1 only without choices.

#RadioGroup.text

cromo
string text() const

The text of the choice chosen, or "" without choices.

#RadioGroup.onChange

cromo
void onChange(move func(i64) handler) const

Adds a handler, called on the thread of the windows with the index of the choice that the user makes, when it is not the one chosen before. setSelected and setItems do not call it.

#RadioGroup.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the radio group, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#RadioGroup.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the radio group, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#RadioGroup.x

cromo
i32 x() const

The distance of the radio group from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#RadioGroup.y

cromo
i32 y() const

The distance of the radio group from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#RadioGroup.width

cromo
i32 width() const

The width of the radio group now, in logical pixels: a Stretch anchor changes it with its parent.

#RadioGroup.height

cromo
i32 height() const

The height of the radio group now, in logical pixels: a Stretch anchor changes it with its parent.

#RadioGroup.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the radio group for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#RadioGroup.tooltip

cromo
string tooltip() const

The text of the tooltip of the radio group, "" for none.

#RadioGroup.setVisible

cromo
void setVisible(bool value) const

Shows or hides the radio group.

#RadioGroup.visible

cromo
bool visible() const

Whether the radio group is visible, as setVisible set it: true by default.

#RadioGroup.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the radio group: disabled, it is drawn at half its opacity.

#RadioGroup.enabled

cromo
bool enabled() const

Whether the radio group is enabled, as setEnabled set it: true by default.

#RadioGroup.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the radio group follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#RadioGroup.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the radio group follows the left and the right edges of its parent: Horizontal.Left by default.

#RadioGroup.verticalAnchor

cromo
Vertical verticalAnchor() const

How the radio group follows the top and the bottom edges of its parent: Vertical.Top by default.

#RadioGroup.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#RadioGroup.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#RadioGroup.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#RadioGroup.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#RadioGroup.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#RadioGroup.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#ProgressBar

cromo
struct ProgressBar : Component

A bar that shows how much of a work is done, from 0 to 1, or with setBusy a segment that runs, for a wait without a measure.

cromo
gui.ProgressBar progress = w.add(gui.ProgressBar(16, 16, 300, 8))
progress.setValue(0.25)
cromo
ProgressBar(i32 x, i32 y, i32 width, i32 height)

A progress bar at 0. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size: the bar is at most 6 pixels high, in the middle of the height.

#ProgressBar.setValue

cromo
void setValue(f64 value) const

Sets the part done, from 0 to 1: a value out of the range is taken to its nearest end. It can be called from any thread.

#ProgressBar.value

cromo
f64 value() const

The part done, from 0 to 1.

#ProgressBar.setBusy

cromo
void setBusy(bool busy) const

Shows a segment that runs instead of the part done, while busy is true.

#ProgressBar.busy

cromo
bool busy() const

Whether the bar shows a wait without a measure.

#ProgressBar.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the progress bar, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#ProgressBar.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the progress bar, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#ProgressBar.x

cromo
i32 x() const

The distance of the progress bar from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#ProgressBar.y

cromo
i32 y() const

The distance of the progress bar from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#ProgressBar.width

cromo
i32 width() const

The width of the progress bar now, in logical pixels: a Stretch anchor changes it with its parent.

#ProgressBar.height

cromo
i32 height() const

The height of the progress bar now, in logical pixels: a Stretch anchor changes it with its parent.

#ProgressBar.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the progress bar for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#ProgressBar.tooltip

cromo
string tooltip() const

The text of the tooltip of the progress bar, "" for none.

#ProgressBar.setVisible

cromo
void setVisible(bool value) const

Shows or hides the progress bar.

#ProgressBar.visible

cromo
bool visible() const

Whether the progress bar is visible, as setVisible set it: true by default.

#ProgressBar.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the progress bar: disabled, it is drawn at half its opacity.

#ProgressBar.enabled

cromo
bool enabled() const

Whether the progress bar is enabled, as setEnabled set it: true by default.

#ProgressBar.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the progress bar follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#ProgressBar.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the progress bar follows the left and the right edges of its parent: Horizontal.Left by default.

#ProgressBar.verticalAnchor

cromo
Vertical verticalAnchor() const

How the progress bar follows the top and the bottom edges of its parent: Vertical.Top by default.

#ProgressBar.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#ProgressBar.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#ProgressBar.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#ProgressBar.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#ProgressBar.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#ProgressBar.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#Drawing

cromo
struct Drawing

What a canvas shows: its shapes, each drawn over the ones before it. The positions are in logical pixels from the top left corner of the canvas. A drawing is a value: the program builds it, on any thread, and hands it to the canvas with Canvas.setDrawing, which keeps it until the next one.

cromo
gui.Drawing d
d.rect(0, 0, 320, 200, gui.rgb(0xFFFFFF))
d.polyline([20.0, 180.0, 120.0, 90.0, 300.0, 40.0], 3, gui.rgb(0xB4761C))
d.circle(300, 40, 6, gui.rgb(0x2F6E8F))
d.text("Sales", 20, 20, 13, gui.rgb(0x18212A), gui.Horizontal.Left)
chart.setDrawing(move d)

#Drawing.rect

cromo
void rect(f32 x, f32 y, f32 width, f32 height, Color color)

A rectangle filled with a color.

#Drawing.roundRect

cromo
void roundRect(f32 x, f32 y, f32 width, f32 height, f32 radius, Color color)

A rectangle with round corners of radius pixels, filled with a color.

#Drawing.frame

cromo
void frame(f32 x, f32 y, f32 width, f32 height, f32 thickness, Color color)

The outline of a rectangle: a line thickness pixels wide inside its edges.

#Drawing.circle

cromo
void circle(f32 x, f32 y, f32 radius, Color color)

A circle with its center at x, y, filled with a color.

#Drawing.ring

cromo
void ring(f32 x, f32 y, f32 radius, f32 thickness, Color color)

The outline of a circle with its center at x, y: a line thickness pixels wide inside its radius.

#Drawing.line

cromo
void line(f32 x1, f32 y1, f32 x2, f32 y2, f32 thickness, Color color)

A segment from x1, y1 to x2, y2, thickness pixels wide, with round ends.

#Drawing.polygon

cromo
void polygon(list<f32> points, Color color)

A polygon filled with a color: points are its corners, the x and the y of each one after the other. Fewer than three corners, or an odd number of values, is a panic.

#Drawing.polyline

cromo
void polyline(list<f32> points, f32 thickness, Color color)

A line through points, the x and the y of each one after the other, thickness pixels wide, with round joins and ends. Fewer than two points, or an odd number of values, is a panic.

#Drawing.image

cromo
void image(Image picture, f32 x, f32 y, f32 width, f32 height)

An image in the rectangle, as large as the rectangle allows with its proportions, at its center.

#Drawing.text

cromo
void text(string value, f32 x, f32 y, f32 size, Color color, Horizontal align)

A line of text in Inter, size pixels high. y is the middle of the line, and x its left edge, its center or its right edge, as align says: Horizontal.Left, Center or Right.

#Drawing.clear

cromo
void clear()

Removes all the shapes.

#Drawing.len

cromo
i64 len() const

The number of shapes.

#Canvas

cromo
struct Canvas : Component

A surface on which the program draws: a chart, a map, a diagram, a game. It shows the Drawing given to setDrawing, and draws it again by itself whenever it must; it tells where the mouse is pressed, moves and is released, so that the program can drag what it draws, and a new drawing takes the place of the old one. A canvas draws nothing else: under its shapes its parent shows.

cromo
gui.Canvas chart = w.add(gui.Canvas(16, 16, 480, 320))
gui.Drawing d
d.rect(0, 0, 480, 320, gui.rgb(0xFFFFFF))
d.circle(240, 160, 40, gui.rgba(0x2F6E8F, 115))
chart.setDrawing(move d)
chart.onMouseDown([](gui.Mouse m) { println("pressed at {}, {}", m.x, m.y) })
cromo
Canvas(i32 x, i32 y, i32 width, i32 height)

A canvas. x and y are in logical pixels from the top left corner of its parent, the window, the group, the panel or the dialog whose add puts it there, and width and height its size.

#Canvas.setDrawing

cromo
void setDrawing(move Drawing drawing) const

Shows the drawing, in place of the one shown before. It can be called from any thread, as often as the drawing changes: while the mouse drags a shape, at each of its moves.

#Canvas.onMouseDown

cromo
void onMouseDown(move func(Mouse) handler) const

Adds a handler, called on the thread of the windows when a button of the mouse, or a finger, is pressed on the canvas. The position of gui.Mouse is from the top left corner of the canvas, and its button 1 left, 2 middle, 3 right. Until the button is released, the canvas has the mouse: its moves and its release come to it, also outside it.

#Canvas.onMouseMove

cromo
void onMouseMove(move func(Mouse) handler) const

Adds a handler, called on the thread of the windows when the mouse moves over the canvas, or anywhere while a button pressed on it is held. The position is from the top left corner of the canvas, and the button 0.

#Canvas.onMouseUp

cromo
void onMouseUp(move func(Mouse) handler) const

Adds a handler, called on the thread of the windows when the button pressed on the canvas is released, wherever the mouse is. The position is from the top left corner of the canvas.

#Canvas.onWheel

cromo
void onWheel(move func(Mouse, f32) handler) const

Adds a handler, called on the thread of the windows when the wheel of the mouse turns over the canvas: where the mouse is, with the keys held, and the steps, more than 0 away from the user, as to zoom in, less than 0 toward. Without handlers the wheel scrolls the panel that holds the canvas.

#Canvas.setPosition

cromo
void setPosition(i32 x, i32 y) const

Moves the canvas, in logical pixels from the top left corner of its parent: the content of the window, or the group, the panel or the dialog that holds it. Its anchors keep the distances from the edges that it has at the new place.

#Canvas.setSize

cromo
void setSize(i32 width, i32 height) const

Changes the width and the height of the canvas, in logical pixels. Its anchors keep the distances from the edges that it has with the new size.

#Canvas.x

cromo
i32 x() const

The distance of the canvas from the left edge of its parent, in logical pixels, where its anchors have placed it now.

#Canvas.y

cromo
i32 y() const

The distance of the canvas from the top edge of its parent, in logical pixels, where its anchors have placed it now.

#Canvas.width

cromo
i32 width() const

The width of the canvas now, in logical pixels: a Stretch anchor changes it with its parent.

#Canvas.height

cromo
i32 height() const

The height of the canvas now, in logical pixels: a Stretch anchor changes it with its parent.

#Canvas.setTooltip

cromo
void setTooltip(string text) const

Sets the text that a small card shows when the mouse stays on the canvas for a moment, or after a long press on a phone: "" for none, the default; "\n" starts a new line.

#Canvas.tooltip

cromo
string tooltip() const

The text of the tooltip of the canvas, "" for none.

#Canvas.setVisible

cromo
void setVisible(bool value) const

Shows or hides the canvas.

#Canvas.visible

cromo
bool visible() const

Whether the canvas is visible, as setVisible set it: true by default.

#Canvas.setEnabled

cromo
void setEnabled(bool value) const

Enables or disables the canvas: disabled, it is drawn at half its opacity.

#Canvas.enabled

cromo
bool enabled() const

Whether the canvas is enabled, as setEnabled set it: true by default.

#Canvas.setAnchor

cromo
void setAnchor(Horizontal horizontal, Vertical vertical) const

Sets which edges of its parent the canvas follows when the parent changes size: the window, or the group, the panel or the dialog that holds it. It keeps the distances from those edges that it has now, as setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) in the bottom right corner. By default it is anchored to the left and to the top, and does not move.

#Canvas.horizontalAnchor

cromo
Horizontal horizontalAnchor() const

How the canvas follows the left and the right edges of its parent: Horizontal.Left by default.

#Canvas.verticalAnchor

cromo
Vertical verticalAnchor() const

How the canvas follows the top and the bottom edges of its parent: Vertical.Top by default.

#Canvas.setBackground

cromo
void setBackground(Color color) const

Sets the background of the component, in place of the one of the theme: a color that stays, as gui.rgb(0xFBEFD9), or one of the theme, as gui.role(gui.Role.AccentSoft).

#Canvas.setTextColor

cromo
void setTextColor(Color color) const

Sets the color of the text of the component, in place of the one of the theme.

#Canvas.setBorderColor

cromo
void setBorderColor(Color color) const

Sets the color of the border and of the lines of the component, in place of the one of the theme.

#Canvas.setCornerRadius

cromo
void setCornerRadius(f32 radius) const

Sets the radius of the corners of the component, in logical pixels, from 0, sharp corners, to 64, and at most half its shorter side: for the buttons, the boxes of text, the groups, the cards with tabs, the segmented controls, and the background of the others. Out of the range it is a panic.

#Canvas.setTextSize

cromo
void setTextSize(f32 size) const

Sets the size of the text of the component, in logical pixels, from 6 to 96, in place of the one of the window: for the labels, the buttons, the boxes of text and the others that write their own text. The component keeps its size: the program gives it the room for a larger text. Out of the range it is a panic.

#Canvas.resetLook

cromo
void resetLook() const

Gives the component the look of the theme again: its colors, its corners and the size of its text.

#Dialog

cromo
struct Dialog

A dialog: a card with a title, its components and its buttons at the bottom, which Window.showDialog opens at the center of the window, over the rest darkened, which the mouse and the keys do not reach until it closes. It is drawn inside the window, the same on the desktop and on a phone. Its buttons do not close it by themselves: their handlers call close. Esc, or the back key of a phone, closes it too. A dialog is made once and can be shown again after it closes.

cromo
gui.Dialog ask = gui.Dialog("Delete the message?", 320, 156)
ask.add(gui.Label("It cannot be undone.", 0, 0, 272, 20))
ask.addButton("Cancel", [ask]() { ask.close() })
ask.addButton("Delete", [w, ask]() {
    ask.close()
    w.showSnackbar("Message deleted")
})
trash.onClick([w, ask]() { w.showDialog(ask) })
cromo
Dialog(string title, i32 width, i32 height)

A dialog with its title and the size of its card, in logical pixels. The title is in a band at the top of the card, 32 pixels high, and the buttons in a band at the bottom, 44 pixels high. The body, where add puts the components, starts 14 pixels from the left edge of the card and 14 under the band of the title, and ends 14 pixels above the band of the buttons: Dialog("...", 320, 156) has a body of 292 by 52. On a phone the bands are 40 and 60 pixels high and the margins 16. The card is at most as large as the content of the window less 32 pixels: in a smaller window it shrinks, and the components of its body follow their anchors.

#Dialog.add

cromo
T add<T : Component>(T component) const

Puts a component in the body of the dialog, with its position from the top left corner of the body, under the title, and gives it back. A component that is already in a window or in a group is a panic, and so is an app bar.

#Dialog.addButton

cromo
void addButton(string text, move func() handler) const

Adds a button in the band at the bottom of the card, on the right of those added before, as wide as its text: the last one is the main one, filled with the accent, the others are normal buttons. A click, or Space and Enter while it has the keyboard, call the handler on the thread of the windows; the dialog stays open until it calls close.

#Dialog.close

cromo
void close() const

Closes the dialog, if a window shows it, and then calls its handlers of onClose on the thread of the windows; the keyboard goes back to the component that had it before. A dialog that is not shown stays as it is.

#Dialog.onClose

cromo
void onClose(move func() handler) const

Adds a handler, called on the thread of the windows whenever the dialog closes: by close, with Esc, or with the back key of a phone.

#Dialog.shown

cromo
bool shown() const

Whether a window shows the dialog now.

#Dialog.setTitle

cromo
void setTitle(string value) const

Changes the title of the dialog.

#Dialog.title

cromo
string title() const

The title of the dialog.

#Window

cromo
struct Window

A window, with its title bar, drawn by the library in the colors of its theme, and its components. It is a handle: its copies name the same window, and a lambda captures it by copy, so that a button can close its own window. start shows it, and when main returns the program waits until its windows are closed. The handlers of its events and of its components run on the thread of the windows, one at a time.

On Android an app has one window, which fills the screen between the bars of the system, without a title bar: its components, placed for the size given to the constructor, follow the screen with their anchors, also when the phone turns. Its size and its state do not change there.

cromo
gui.Window w = gui.Window("Notes", 480, 300)
gui.TextBox title = w.add(gui.TextBox("", 16, 16, 448, 32))
title.setAnchor(gui.Horizontal.Stretch, gui.Vertical.Top)
gui.Button quit = w.add(gui.Button("Quit", 364, 217, 100, 32))
quit.setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom)
quit.onClick([w]() { w.close() })
w.start()
cromo
Window(string text, i32 w, i32 h)

A window with its title and the size of the whole window, in logical pixels, its title bar of 35 pixels included: the content, where the components go, is w wide and h less 35 high. The window is shown by start.

#Window.add

cromo
T add<T : Component>(T component) const

Puts a component in the window, with its position from the top left corner of the content, and gives it back, so that its handle can be kept: gui.Button ok = w.add(gui.Button("OK", 20, 20, 100, 32)). A component that is already in a window or in a group is a panic, and so is a second app bar.

#Window.navigationBar

cromo
NavigationBar navigationBar() const

The navigation bar at the bottom of the window, made the first time that it is called: a window has one at most, and each call gives the same bar.

#Window.setTitle

cromo
void setTitle(string text) const

Changes the title, shown at the center of the title bar and by the system, as in the taskbar; on a phone it is not shown.

#Window.title

cromo
string title() const

The title of the window.

#Window.setSize

cromo
void setSize(i32 w, i32 h) const

Changes the size of the whole window, its title bar included, in logical pixels; before start, the size it starts with. The anchors move the components. On Android it does nothing.

#Window.width

cromo
i32 width() const

The width of the whole window in logical pixels, which follows the user who resizes it; on a phone, once the window is shown, that of the screen.

#Window.height

cromo
i32 height() const

The height of the whole window in logical pixels, its title bar included, which follows the user who resizes it; on a phone, once the window is shown, that of the screen.

#Window.setResizable

cromo
void setResizable(bool value) const

Sets whether the user can resize the window with its edges and maximize it with its button: true by default. On Android it does nothing.

#Window.setIcon

cromo
void setIcon(Icon value) const

Puts an icon of Lucide at the left of the title bar, in the color of the title, in place of the icon or the image there was; Icon.None, the default, removes it. The panel of titleBar starts after the icon.

cromo
w.setIcon(gui.Icon.Mail)
w.setIcon(gui.Icon.None)  // no icon

#Window.icon

cromo
Icon icon() const

The icon of Lucide at the left of the title bar: Icon.None without one, and with an image.

#Window.setIconImage

cromo
void setIconImage(Image picture) const

Puts an image at the left of the title bar, as the logo of the program, in its own colors and as large as an icon, in place of the icon or the image there was; setIcon(Icon.None) removes it.

cromo
w.setIconImage(gui.Image(embed("logo.svg")))

#Window.setTitleBarVisible

cromo
void setTitleBarVisible(bool value) const

Shows or hides the title bar of the window, with its title, its buttons and the panel of titleBar: shown by default. Without it the content takes the whole window, whose edges still resize it, and the program gives its own way to close it, with close. On Android, where a window has no title bar, it does nothing.

cromo
gui.Window w = gui.Window("Splash", 420, 260)
w.setTitleBarVisible(false)
w.setCornerRadius(12)

#Window.setTitleBarHeight

cromo
void setTitleBarHeight(i32 height) const

Sets the height of the title bar in logical pixels, from 24 to 96: 35 by default. The panel of titleBar is as high, and the content starts under it. A height out of the range is a panic.

#Window.titleBarHeight

cromo
i32 titleBarHeight() const

The height of the title bar: 35 by default.

#Window.titleBarVisible

cromo
bool titleBarVisible() const

Whether the title bar is shown: true by default.

#Window.setButtons

cromo
void setButtons(bool minimize, bool maximize, bool close) const

Chooses the buttons of the title bar: to minimize, to maximize or restore, and to close; all three by default. A window without the button to close is closed by the program, with close.

cromo
w.setButtons(false, false, true)  // only the button to close, as a dialog

#Window.setCornerRadius

cromo
void setCornerRadius(i32 radius) const

Rounds the corners of the window by a radius in logical pixels, from 0, the sharp corners of the default, to 64: what is outside them shows what is behind the window. It is set before start: after it, and out of the range, it is a panic. A maximized window has sharp corners, and on Android it does nothing.

#Window.cornerRadius

cromo
i32 cornerRadius() const

The radius of the corners of the window: 0 by default.

#Window.resizable

cromo
bool resizable() const

Whether the user can resize the window: true by default.

#Window.minimize

cromo
void minimize() const

Minimizes the window; called before start, the window starts minimized. On Android it does nothing.

#Window.maximize

cromo
void maximize() const

Maximizes the window; called before start, the window starts maximized. On Android it does nothing.

#Window.restore

cromo
void restore() const

Brings the window back from minimized or maximized to its size; called before start, the window starts so, as it does by default. On Android it does nothing.

#Window.minimized

cromo
bool minimized() const

Whether the window is minimized now; before start, whether it starts so.

#Window.maximized

cromo
bool maximized() const

Whether the window is maximized now; before start, whether it starts so.

#Window.setTheme

cromo
void setTheme(Theme value) const

Sets the colors of the window and of its components, light or dark, at once: Theme.System, the default, follows those of the system and changes with them.

#Window.setPalette

cromo
void setPalette(Palette light, Palette dark) const

Gives the window its own colors, for the light theme and for the dark one, in place of those of the library: setTheme still says which of the two is shown. From lightPalette() and darkPalette() with some colors changed, or from palette().

#Window.resetPalette

cromo
void resetPalette() const

Gives the window the colors of the library again.

#Window.theme

cromo
Theme theme() const

The theme of the window, Theme.System by default.

#Window.setFps

cromo
void setFps(i32 value) const

Sets the most frames drawn each second, from 1 to 240: 60 by default. A window is drawn only when something in it changes, at the most frames among the windows open. A value out of the range is a panic.

#Window.setVsync

cromo
void setVsync(bool value) const

Draws the window in step with the display, each frame at one of its refreshes : what moves is smooth, without the frames that an own clock skips or shows twice. While the window is drawn so, the display gives the pace and setFps does not count; it counts again when nothing in the window changes, and where the display cannot give its pace. False by default.

#Window.vsync

cromo
bool vsync() const

Whether the window is asked to be drawn in step with the display.

#Window.fps

cromo
i32 fps() const

The most frames of the window drawn each second: 60 by default.

#Window.start

cromo
void start() const

Shows the window and returns at once: the window is drawn, and the handlers are called, by the thread of the windows, which the first start starts. Starting a window twice is a panic, and so is starting a second window on Android, where an app has one.

#Window.close

cromo
void close() const

Closes the window, as its button does, and then calls its handlers of onClose on the thread of the windows. A window closed before start is never shown.

#Window.closed

cromo
bool closed() const

Whether the window is closed, by the user or by close, once its handlers of onClose have run.

#Window.wait

cromo
void wait() const

Waits until the window is closed, for a program that has more to do after it: at the end of main the program waits for its windows anyway. It waits forever for a window never started, and for an open one when it is called from a handler, which holds the thread that would close it.

#Window.onMouseMove

cromo
void onMouseMove(move func(Mouse) handler) const

Adds a handler, called on the thread of the windows when the mouse moves over the content of the window, also over the components, with its position and button 0.

#Window.onMouseDown

cromo
void onMouseDown(move func(Mouse) handler) const

Adds a handler, called on the thread of the windows when a button of the mouse, or a finger, is pressed on the content of the window, with its position and the button. The presses on the components come here too, after the components.

#Window.onMouseUp

cromo
void onMouseUp(move func(Mouse) handler) const

Adds a handler, called on the thread of the windows when a button of the mouse, or a finger, is released on the content of the window, with its position and the button. The releases on the components come here too, after the components.

#Window.onKeyDown

cromo
void onKeyDown(move func(Key) handler) const

Adds a handler, called on the thread of the windows with each key pressed that the component with the keyboard does not use, as F5 in a text box; a key held down comes again as it repeats. Tab, which moves the keyboard to the next component, the back key of a phone, and the keys pressed while a dialog is shown, do not come here.

#Window.onKeyUp

cromo
void onKeyUp(move func(Key) handler) const

Adds a handler, called on the thread of the windows with each key released, as onKeyDown is with each key pressed: with both a program knows the keys that are held, as a game does for its arrows.

#Window.onUpdate

cromo
void onUpdate(move func(f32) handler) const

Adds a handler, called on the thread of the windows at each frame of the window, 60 times a second or as setFps says, with the seconds since its call before, and 0 the first time: where a game, or what else moves by itself, takes its step. The window is drawn again when the handler changes something in it, as the drawing of a canvas. The handler is not called while the window is minimized.

cromo
w.onUpdate([ball, canvas](f32 seconds) {
    ball.lock([seconds](ref f32 x) { x += 120 * seconds })  // 120 pixels a second
    ...
})

#Window.onTouchDown

cromo
void onTouchDown(move func(Touch) handler) const

Adds a handler, called on the thread of the windows when a finger comes down on the content of the window, with its number and its place. The fingers are the mouse too, as before: the first one presses the left button, and the components under it answer. On a computer without a screen that feels the fingers the handler is never called.

#Window.onTouchMove

cromo
void onTouchMove(move func(Touch) handler) const

Adds a handler, called on the thread of the windows when a finger that touches the window moves.

#Window.onTouchUp

cromo
void onTouchUp(move func(Touch) handler) const

Adds a handler, called on the thread of the windows when a finger goes up from the window, or the system takes it away, as for a gesture of its own.

#Window.setFullscreen

cromo
void setFullscreen(bool value) const

Gives the window the whole screen, or takes it back. On a computer the window covers the screen, without its title bar, and comes back as it was; on a phone the bars of the system go away, and come back for a moment when the user pulls them. The program gives its own way out, as Esc.

#Window.fullscreen

cromo
bool fullscreen() const

Whether the window has the whole screen: false by default.

#Window.setOrientation

cromo
void setOrientation(Orientation value) const

Says how a phone holds the window: upright, on its side, or as the phone is held, which is the default. Called before start the window opens so; after it, the window turns. On a computer it does nothing.

#Window.orientation

cromo
Orientation orientation() const

How a phone holds the window: Orientation.Any by default.

#Window.onMotion

cromo
void onMotion(move func(Motion) handler) const

Adds a handler, called on the thread of the windows each time the accelerometer or the gyroscope of the device measures, many times a second, with the last measures of both: to follow how a phone is held, tilted and shaken. The sensors measure from the first handler on. On a device without them, as most computers, the handler is never called: gui.hasMotion() tells.

cromo
w.onMotion([level](gui.Motion m) {
    level.setText(format("tilted {:.1f} to the right", m.accelerationX))
})

#Window.onResize

cromo
void onResize(move func(i32, i32) handler) const

Adds a handler, called on the thread of the windows with the new width and height of the whole window, in logical pixels, when its size changes. The anchors move the components by themselves.

#Window.titleBar

cromo
Panel titleBar() const

The panel in the title bar of the window, made the first time that it is called : it takes the bar from its left edge to the buttons of the window, and is as high as the bar; its components are drawn over the bar, and where there is none the bar still moves the window. The title stays at the center of the bar, under them. On a phone, without a title bar, the panel is not shown.

#Window.showDialog

cromo
void showDialog(Dialog dialog) const

Opens a dialog at the center of the content, over the rest darkened, which the mouse and the keys do not reach until it closes; the keyboard goes to the first of its components that takes it. A window shows one dialog at a time: opening one while another is shown is a panic, and so is a dialog shown by another window.

#Window.openFile

cromo
void openFile(list<FileType> types, move func(list<string>) handler) const

Shows the dialog of the system to open a file, with the kinds of file that it lets the user choose, the first one at the start, or every file with an empty list. It returns at once; the handler is called later on the thread of the windows with the path chosen in a list, or with an empty list when the user cancels. On Android the path is the name of a document, "content://...", which std.fs reads.

#Window.openFiles

cromo
void openFiles(list<FileType> types, move func(list<string>) handler) const

Shows the dialog of the system to open one file or more, as openFile does: the handler receives all the paths chosen.

#Window.saveFile

cromo
void saveFile(list<FileType> types, string name, move func(string) handler) const

Shows the dialog of the system to save a file, with the kinds of file and the name proposed, as "notes.txt", or a path. It returns at once; the handler is called later on the thread of the windows with the path chosen, or "" when the user cancels. The program writes the file, with std.fs.

#Window.openFolder

cromo
void openFolder(move func(string) handler) const

Shows the dialog of the system to choose a folder. It returns at once; the handler is called later on the thread of the windows with the path of the folder, or "" when the user cancels.

#Window.showMenu

cromo
void showMenu(move Menu menu) const

Opens a menu where the mouse is, or where the finger is on a phone, over everything, and on the left of the mouse or above it when there is no room. It takes the place of the menu open, and a menu without entries closes it. It can be called from any thread, as from the handler of a right click.

#Window.showMenuUnder

cromo
void showMenuUnder<T : Component>(move Menu menu, T anchor) const

Opens a menu under a component of the window, from its left edge, as the list of a button: above it when there is no room below.

#Window.closeMenu

cromo
void closeMenu() const

Closes the menu open, if there is one, without calling its handlers.

#Window.showSnackbar

cromo
void showSnackbar(string text) const

Shows a short message at the bottom of the content for 4 seconds, above the navigation bar and above the components anchored to the bottom that it would cover, which stay visible and can be pressed. It takes the place of the one shown, and "" hides it.

#Window.showSnackbarAction

cromo
void showSnackbarAction(string text, string action, move func() handler) const

Shows a snackbar as showSnackbar does, with an action on its right, as "Undo": a click or a touch on it calls the handler on the thread of the windows and hides the snackbar. The handler is dropped when another snackbar takes the place of this one, so it must own what it captures.

cromo
string title = messages.itemTitle(index)
messages.removeItem(index)
w.showSnackbarAction("Message deleted", "Undo", [messages, index, move title]() {
    messages.insertItem(index, gui.Icon.Mail, title, "", "")
})

#Window.onBack

cromo
void onBack(move func() handler) const

Adds a handler, called on the thread of the windows when the user presses the back key of Android, or makes its gesture, in place of what the key does without handlers: closing the window, and so the app. While a dialog is shown, the key closes the dialog instead. On the desktop the handlers are never called.

cromo
w.onBack([w, pages]() {
    if (pages.selected() == 0) {
        w.close()
    } else {
        pages.setSelected(0)
    }
})

#Window.onClose

cromo
void onClose(move func() handler) const

Adds a handler, called on the thread of the windows after the window is closed: by its button, by the keys of the system, by the back key of a phone or by close. The window is closed once its handlers have run.

#Funzioni

#lightPalette

cromo
Palette lightPalette()

The colors of the light theme of the library, to change some of them.

#darkPalette

cromo
Palette darkPalette()

The colors of the dark theme of the library, to change some of them.

#palette

cromo
Palette palette(u32 background, u32 surface, u32 text, u32 accent, u32 selection, u32 danger)

A whole palette from six colors, as 0xRRGGBB: what is under the components, their surface, the text, the accent, the selection and the color of the errors. The others are made from these: the ones under the mouse and pressed, the lighter texts, the lines, and the text on the accent, white or dark as the accent wants.

#role

cromo
Color role(Role which)

The color of a role of the theme, for the look of a component: it changes with the theme of the window, where rgb gives a color that stays.

cromo
warning.setTextColor(gui.role(gui.Role.Danger))

#rgb

cromo
Color rgb(u32 value)

An opaque color from its value 0xRRGGBB, as in CSS: gui.rgb(0xB4761C).

#rgba

cromo
Color rgba(u32 value, u8 alpha)

A color from its value 0xRRGGBB and its opacity, from 0, transparent, to 255, opaque: gui.rgba(0x2F6E8F, 115) is about 45% opaque.

#hasMotion

cromo
bool hasMotion()

Whether the device has an accelerometer or a gyroscope, for Window.onMotion . The windows look for them when the first one starts: before that, false.