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
setTextorsetChecked, 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.
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.
Made from the documentation in the sources of the library.
#Types
#Theme
enum ThemeThe 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 itLight: dark text on light graysDark: light text on dark grays
#Palette
struct PaletteThe 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.
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 componentsu32 surface: cards, dialogs, fields, buttons and barsu32 surfaceHover: the bands of the groups and of the dialogs, and under the mouseu32 surfacePressed: pressed, and the tracks of the sliders and of the barsu32 text: the textu32 textSecondary: the text that matters less, the labels and the iconsu32 textFaint: muted text, the titles of the bands, the placeholdersu32 line: lines, and the borders of the cardsu32 border: the borders of the controlsu32 accent: main buttons, checked boxes, switches and slidersu32 accentStrong: the accent under the mouse, and the text on the soft accentu32 accentSoft: the item pointed at in a list, the item chosen of a baru32 selection: the focus, the links, and the bar of the selected rowu32 selectionSoft: the selected row and the selected textu32 onAccent: the text on the accentu32 danger: errors, and the buttons that destroy
#ButtonStyle
enum ButtonStyleThe style of a button, set with Button.setStyle.
Normal: light, with a thin border: the defaultPrimary: filled with the accent, for the main action of a window or of a groupDanger: in the color of danger, for an action that destroys, as Delete
#FileType
struct FileTypeA 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.
w.openFile([gui.FileType("Images", "png;jpg"), gui.FileType("All the files", "*")], [](list<string> files) {
println("{}", files)
})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
enum InkThe color of a piece of rich text: a role of the theme, which follows the light or the dark one by itself.
Normal: the textSecondary: the text that matters lessFaint: muted, as numbers and remarks on the sideAccent: the accent, darker for the text: what must stand outSelection: the blue of the selection, as notes and linksDanger: errors and warnings
#BlockLine
enum BlockLineThe line along the left edge of a block of rich text, set with RichText.startBlock.
None: no line: only the marginPlain: gray, as the borders of the componentsSelection: the soft blue of the selectionAccent: the accent
#Horizontal
enum HorizontalHow 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.
gui.TextBox title = w.add(gui.TextBox("", 16, 16, 448, 32))
title.setAnchor(gui.Horizontal.Stretch, gui.Vertical.Top) // as wide as the windowLeft: keeps its distance from the left edge, and its width: the defaultRight: keeps its distance from the right edge, and its widthStretch: keeps its distances from both edges, and so changes its widthCenter: keeps its center at the same distance from the center, and its width
#Vertical
enum VerticalHow 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.
gui.Button save = w.add(gui.Button("Save", 364, 217, 100, 32))
save.setAnchor(gui.Horizontal.Right, gui.Vertical.Bottom) // in the bottom right cornerTop: keeps its distance from the top edge, and its height: the defaultBottom: keeps its distance from the bottom edge, and its heightStretch: keeps its distances from both edges, and so changes its heightCenter: keeps its center at the same distance from the center, and its height
#Direction
enum DirectionHow a Split puts its two panels.
Across: side by side, the first on the leftDown: one over the other, the first on top
#Scale
enum ScaleHow 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 defaultFill: the whole box, covered by the image with its proportions, cut at the edgesStretch: the size of the box, without the proportions of the imageCenter: the size of the image, a pixel of it for each logical pixel
#Color
struct ColorA 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 255u8 green: from 0 to 255u8 blue: from 0 to 255u8 alpha: 255 opaque, 0 transparent
#Role
enum RoleA 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 componentsSurface: cards, dialogs, fields, buttons and barsSurfaceHover: under the mouse, and the bandsSurfacePressed: pressed, and the tracksText: the textTextSecondary: the text that matters lessTextFaint: muted textLine: lines, and the borders of the cardsBorder: the borders of the controlsAccent: the accentAccentStrong: the accent under the mouseAccentSoft: the soft accentSelection: the selection and the focusSelectionSoft: the selected rowOnAccent: the text on the accentDanger: errors, and what destroys
#TextStyle
struct TextStyleHow 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.
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 letterTextStyle(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 themebool strong: semiboldbool italic: slantedbool mono: JetBrains Mono, whose letters are all equally widef32 scale: the size, from that of the text of the view: more than 0f32 spacing: added after each letter, as a part of its size, from -0.5 to 1
#Image
struct ImageAn 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.
gui.Image logo = gui.Image(embed("images/logo.svg"))
gui.Drawing d
d.image(logo, 16, 16, 64, 64)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
f32 width() constThe width of the image in pixels: that of its file, or the one written in the SVG.
#Image.height
f32 height() constThe height of the image in pixels: that of its file, or the one written in the SVG.
#Icon
enum IconAn 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 defaultActivity: a pulse line, as that of a heart monitorAlarmClock: an alarm clockArchive: a box for archives, with its lidArrowDown: an arrow that points downArrowLeft: an arrow that points left, to go backArrowRight: an arrow that points rightArrowUp: an arrow that points upAtSign: the sign @Award: a rosette with ribbons, for a prizeBan: a circle crossed by a line, for something forbiddenBattery: a batteryBell: a bell, for the notificationsBellOff: a bell crossed out, for the notifications offBike: a bicycleBluetooth: the sign of BluetoothBook: a closed bookBookOpen: an open bookBookmark: a bookmarkBriefcase: a briefcase, for workBuilding2: an office buildingCalendar: a calendarCamera: a cameraCar: a carChartColumn: a chart with columnsChartLine: a chart with a lineChartPie: a pie chartCheck: a check markChevronDown: a chevron that points down, to openChevronLeft: a chevron that points left, to go backChevronRight: a chevron that points right, to go onChevronUp: a chevron that points up, to closeCircleAlert: an exclamation mark in a circle, for an errorCircleCheck: a check mark in a circle, for a successCircleQuestionMark: a question mark in a circle, for helpCircleX: an X in a circle, for a failureClipboard: a clipboardClock: a clock, for a timeCloud: a cloudCode: two angle brackets, for codeCoffee: a cup of coffeeContact: a card with a person, for a contactCopy: two sheets one over the other, to copyCpu: a processorCreditCard: a credit cardDatabase: a cylinder, for a databaseDownload: an arrow down into a tray, to downloadDroplet: a drop of waterEllipsis: three dots in a row, for moreEllipsisVertical: three dots in a column, for a menu of more actionsExternalLink: a box with an arrow out of it, for a link that opens elsewhereEye: an eye, to showEyeOff: an eye crossed out, to hideFile: a sheet of paper, for a fileFileText: a sheet with lines of textFlag: a flagFlame: a flameFolder: a folderFolderOpen: an open folderFunnel: a funnel, for a filterGift: a giftGlobe: a globe, for the web or the languagesGraduationCap: a graduation cap, for a schoolHeart: a heart, for what is likedHistory: a clock with an arrow around it, for the historyHouse: a house, for the home pageImage: a picture of mountains, for an imageInbox: a tray, for the messages receivedInfo: an i in a circle, for informationKey: a keyLaptop: a laptopLayers: sheets one over the other, for layersLayoutGrid: four squares, for a gridLightbulb: a light bulb, for an idea or a tipLink: two links of a chain, for a linkList: lines with dots, for a listLoader: rays in a circle, for something that is loadingLock: a closed padlockLockOpen: an open padlockLogIn: an arrow into a door, to sign inLogOut: an arrow out of a door, to sign outMail: an envelope, for the mailMap: a folded mapMapPin: a pin, for a place on a mapMenu: three lines, for a menuMessageCircle: a round speech bubble, for a messageMessageSquare: a square speech bubble, for a messageMic: a microphoneMinus: a minus signMonitor: the screen of a computerMoon: a crescent moon, for the night or the dark themeMusic: a musical notePackage: a parcelPaperclip: a paper clip, for an attachmentPause: two bars, to pausePencil: a pencil, to write or to editPhone: the handset of a phone, for a callPlane: an airplanePlay: a triangle that points right, to playPlus: a plus sign, to addPower: a circle broken by a line, to switch on or offPrinter: a printerQrCode: a QR codeRefreshCw: two arrows in a circle, to refreshRotateCcw: an arrow that turns back, to undoSave: a floppy disk, to saveScan: the corners of a frame, to scanSearch: a magnifying glass, to searchSend: a paper plane, to sendServer: a serverSettings: a gear, for the settingsShare2: three dots joined by lines, to shareShield: a shield, for securityShoppingBag: a shopping bagShoppingCart: a shopping cartSkipBack: a triangle to the left against a bar, for the track beforeSkipForward: a triangle to the right against a bar, for the track afterSlidersHorizontal: horizontal sliders, for optionsSmartphone: a smartphoneSmile: a smiling faceSquare: a square, to stopStar: a star, for the favoritesSun: a sun, for the day or the light themeTable: a table with rows and columnsTag: a tag, for a label or a priceTerminal: a prompt, for a terminalThermometer: a thermometerThumbsDown: a thumb downThumbsUp: a thumb upTrash2: a bin, to deleteTriangleAlert: an exclamation mark in a triangle, for a warningTrophy: a trophyTruck: a truck, for a deliveryUmbrella: an umbrellaUpload: an arrow up out of a tray, to uploadUser: a person, for a user or an accountUserCheck: a person with a check markUserPlus: a person with a plus sign, to add someoneUsers: two people, for a groupUtensils: a fork and a knife, for foodVideo: a video cameraVolume2: a speaker with waves, for the sound onVolumeX: a speaker with an X, for the sound offWallet: a walletWifi: the waves of Wi-FiWifiOff: the waves of Wi-Fi crossed outX: an X, to close or to cancelZap: a lightning bolt
#Mouse
struct MouseWhere 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 canvasf32 y: in logical pixels from the top of the content, or of the canvasi32 button: 1 left, 2 middle, 3 right, 0 when the mouse movesbool shift: a Shift key is heldbool control: a Ctrl key is heldbool alt: an Alt key is held
#CameraSide
enum CameraSideWhich camera of the device, for Camera.
Any: the first one that the system hasFront: the one on the side of the screen, toward the userBack: the one behind the screen
#CameraState
enum CameraStateHow a camera is, from Camera.state().
Opening: not open yet, or waiting for the user to allow itReady: it gives its framesDenied: the user did not allow itMissing: the device has no camera, or it could not be openedClosed: closed byclose()
#Frame
struct FrameA frame of a camera: its pixels, row after row from the top, each of four bytes, red, green, blue and 255.
i32 width: in pixelsi32 heightlist<u8> pixels: width * height * 4 bytesi64 time: when it was taken, in nanoseconds: for the time between two frames
#Frame.png
list<u8> png() constThe frame as the bytes of a PNG file, for fs.writeBytes or to send: a photo. Without pixels, an empty list.
#Camera
struct CameraA 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.
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()) })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
void onFrame(move func(Frame) handler) constAdds 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
Frame frame() constThe last frame of the camera: without pixels, and 0 wide, before the first one.
#Camera.state
CameraState state() constHow the camera is: opening, ready, denied by the user, missing, or closed.
#Camera.close
void close() constCloses the camera, which turns its light off: its views keep its last frame.
#CameraView
struct CameraView : ComponentShows 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.
gui.CameraView view = w.add(gui.CameraView(camera, 0, 0, 390, 520))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
Frame takePhoto() constThe 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
void setScale(Scale value) constHow the frame fits the box: Scale.Fill by default.
#CameraView.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the camera view from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#CameraView.y
i32 y() constThe distance of the camera view from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#CameraView.width
i32 width() constThe width of the camera view now, in logical pixels: a Stretch anchor changes it with its parent.
#CameraView.height
i32 height() constThe height of the camera view now, in logical pixels: a Stretch anchor changes it with its parent.
#CameraView.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the camera view, "" for none.
#CameraView.setVisible
void setVisible(bool value) constShows or hides the camera view.
#CameraView.visible
bool visible() constWhether the camera view is visible, as setVisible set it: true by default.
#CameraView.setEnabled
void setEnabled(bool value) constEnables or disables the camera view: disabled, it is drawn at half its opacity.
#CameraView.enabled
bool enabled() constWhether the camera view is enabled, as setEnabled set it: true by default.
#CameraView.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the camera view follows the left and the right edges of its parent: Horizontal.Left by default.
#CameraView.verticalAnchor
Vertical verticalAnchor() constHow the camera view follows the top and the bottom edges of its parent: Vertical.Top by default.
#CameraView.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#CameraView.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#CameraView.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#Motion
struct MotionThe 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 off32 accelerationY: gravity: a phone at rest on a table has about 9.8 on zf32 accelerationZf32 rotationX: how fast the device turns around each axis, in radians per secondf32 rotationYf32 rotationZi64 time: when the sensor measured, in nanoseconds: for the time between two events
#Point
struct PointA 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.
gui.Point ball = gui.Point(40, 100)
ball.x += 120 * secondsPoint(f32 across, f32 down)f32 xf32 y
#Touch
struct TouchA 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 touchesf32 x: in logical pixels from the left edge of the contentf32 y: in logical pixels from the top of the contentf32 pressure: from 0 to 1, or 1 on a screen that does not measure it
#Orientation
enum OrientationHow a phone holds the window, for Window.setOrientation.
Any: as the phone is held: the window turns with itPortrait: upright, taller than wideLandscape: on its side, wider than tall
#Key
struct KeyA 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 heldbool control: a Ctrl key is heldbool alt: an Alt key is heldbool repeated: the key is held down, and this is not its first event
#Component
interface ComponentA 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
i64 componentId() constThe number that names the component inside the module, for add.
#Label
struct Label : ComponentA line of text, on the left of its box and in the middle of its height. It takes neither the mouse nor the keys.
gui.Label status = w.add(gui.Label("Ready", 16, 223, 300, 20))
status.setText("Saved")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
void setText(string value) constChanges the text of the label.
#Label.text
string text() constThe text of the label.
#Label.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the label from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#Label.y
i32 y() constThe distance of the label from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#Label.width
i32 width() constThe width of the label now, in logical pixels: a Stretch anchor changes it with its parent.
#Label.height
i32 height() constThe height of the label now, in logical pixels: a Stretch anchor changes it with its parent.
#Label.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the label, "" for none.
#Label.setVisible
void setVisible(bool value) constShows or hides the label.
#Label.visible
bool visible() constWhether the label is visible, as setVisible set it: true by default.
#Label.setEnabled
void setEnabled(bool value) constEnables or disables the label: disabled, it is drawn at half its opacity.
#Label.enabled
bool enabled() constWhether the label is enabled, as setEnabled set it: true by default.
#Label.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the label follows the left and the right edges of its parent: Horizontal.Left by default.
#Label.verticalAnchor
Vertical verticalAnchor() constHow the label follows the top and the bottom edges of its parent: Vertical.Top by default.
#Label.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#Label.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#Label.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#Button
struct Button : ComponentA 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.
gui.Button save = w.add(gui.Button("Save", 364, 217, 100, 32))
save.setIcon(gui.Icon.Save)
save.onClick([w]() { w.showSnackbar("Saved") })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
void onClick(move func() handler) constAdds 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
void setIcon(Icon value) constPuts 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
void setStyle(ButtonStyle value) constChanges 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.
gui.Button save = w.add(gui.Button("Save", 364, 217, 100, 28))
save.setStyle(gui.ButtonStyle.Primary)#Button.style
ButtonStyle style() constThe style of the button: ButtonStyle.Normal unless it was changed.
#Button.icon
Icon icon() constThe icon of the button, Icon.None without one.
#Button.setText
void setText(string value) constChanges the text of the button; without text, its icon is alone in the middle.
#Button.text
string text() constThe text of the button.
#Button.setToggle
void setToggle(bool value) constMakes 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
bool toggle() constWhether the button has two states.
#Button.setChecked
void setChecked(bool value) constPresses or releases a button with two states, without calling the handlers of onChange.
#Button.checked
bool checked() constWhether a button with two states is pressed.
#Button.onChange
void onChange(move func(bool) handler) constAdds 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
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the button from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#Button.y
i32 y() constThe distance of the button from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#Button.width
i32 width() constThe width of the button now, in logical pixels: a Stretch anchor changes it with its parent.
#Button.height
i32 height() constThe height of the button now, in logical pixels: a Stretch anchor changes it with its parent.
#Button.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the button: hidden, "" for none.
#Button.setVisible
void setVisible(bool value) constShows or hides the button: hidden, it takes neither the mouse nor the keys.
#Button.visible
bool visible() constWhether the button is visible, as setVisible set it: true by default.
#Button.setEnabled
void setEnabled(bool value) constEnables or disables the button: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.
#Button.enabled
bool enabled() constWhether the button is enabled, as setEnabled set it: true by default.
#Button.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the button follows the left and the right edges of its parent: Horizontal.Left by default.
#Button.verticalAnchor
Vertical verticalAnchor() constHow the button follows the top and the bottom edges of its parent: Vertical.Top by default.
#Button.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#Button.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#Button.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#TextBox
struct TextBox : ComponentA 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.
gui.TextBox name = w.add(gui.TextBox("", 24, 48, 372, 32))
name.setPlaceholder("Write your name")
name.onEnter([](string text) { println("Hello, {}!", text) })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
void onChange(move func(string) handler) constAdds 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
void onEnter(move func(string) handler) constAdds a handler, called on the thread of the windows with the text when the user presses Enter in the box.
#TextBox.setPlaceholder
void setPlaceholder(string value) constSets the text shown in gray while the box is empty, as a hint of what to write.
#TextBox.placeholder
string placeholder() constThe text shown while the box is empty, "" by default.
#TextBox.setText
void setText(string value) constReplaces the text, with the cursor at its end, without calling the handlers of onChange; what Ctrl+Z could undo is forgotten.
#TextBox.text
string text() constThe text written in the box.
#TextBox.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the text box from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#TextBox.y
i32 y() constThe distance of the text box from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#TextBox.width
i32 width() constThe width of the text box now, in logical pixels: a Stretch anchor changes it with its parent.
#TextBox.height
i32 height() constThe height of the text box now, in logical pixels: a Stretch anchor changes it with its parent.
#TextBox.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the text box: hidden, "" for none.
#TextBox.setVisible
void setVisible(bool value) constShows or hides the text box: hidden, it takes neither the mouse nor the keys.
#TextBox.visible
bool visible() constWhether the text box is visible, as setVisible set it: true by default.
#TextBox.setEnabled
void setEnabled(bool value) constEnables or disables the text box: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.
#TextBox.enabled
bool enabled() constWhether the text box is enabled, as setEnabled set it: true by default.
#TextBox.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the text box follows the left and the right edges of its parent: Horizontal.Left by default.
#TextBox.verticalAnchor
Vertical verticalAnchor() constHow the text box follows the top and the bottom edges of its parent: Vertical.Top by default.
#TextBox.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#TextBox.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#TextBox.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#CheckBox
struct CheckBox : ComponentA 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.
gui.CheckBox news = w.add(gui.CheckBox("Send me the news", 12, 154, 260, 22))
news.onChange([](bool checked) { println("news: {}", checked) })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
void onChange(move func(bool) handler) constAdds 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
void setChecked(bool value) constChecks or unchecks the box, without calling the handlers of onChange.
#CheckBox.checked
bool checked() constWhether the box is checked: false at the start.
#CheckBox.setText
void setText(string value) constChanges the text on the right of the box.
#CheckBox.text
string text() constThe text on the right of the box.
#CheckBox.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the check box from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#CheckBox.y
i32 y() constThe distance of the check box from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#CheckBox.width
i32 width() constThe width of the check box now, in logical pixels: a Stretch anchor changes it with its parent.
#CheckBox.height
i32 height() constThe height of the check box now, in logical pixels: a Stretch anchor changes it with its parent.
#CheckBox.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the check box: hidden, "" for none.
#CheckBox.setVisible
void setVisible(bool value) constShows or hides the check box: hidden, it takes neither the mouse nor the keys.
#CheckBox.visible
bool visible() constWhether the check box is visible, as setVisible set it: true by default.
#CheckBox.setEnabled
void setEnabled(bool value) constEnables or disables the check box: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.
#CheckBox.enabled
bool enabled() constWhether the check box is enabled, as setEnabled set it: true by default.
#CheckBox.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the check box follows the left and the right edges of its parent: Horizontal.Left by default.
#CheckBox.verticalAnchor
Vertical verticalAnchor() constHow the check box follows the top and the bottom edges of its parent: Vertical.Top by default.
#CheckBox.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#CheckBox.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#CheckBox.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#GroupBox
struct GroupBox : ComponentA 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.
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 tooGroupBox(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
T add<T : Component>(T component) constPuts 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
void setText(string value) constChanges the title of the group.
#GroupBox.text
string text() constThe title of the group.
#GroupBox.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the group from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#GroupBox.y
i32 y() constThe distance of the group from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#GroupBox.width
i32 width() constThe width of the group now, in logical pixels: a Stretch anchor changes it with its parent.
#GroupBox.height
i32 height() constThe height of the group now, in logical pixels: a Stretch anchor changes it with its parent.
#GroupBox.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the group, "" for none.
#GroupBox.setVisible
void setVisible(bool value) constShows or hides the group, and its components with it.
#GroupBox.visible
bool visible() constWhether the group is visible, as setVisible set it: true by default.
#GroupBox.setEnabled
void setEnabled(bool value) constEnables 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
bool enabled() constWhether the group is enabled, as setEnabled set it: true by default.
#GroupBox.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the group follows the left and the right edges of its parent: Horizontal.Left by default.
#GroupBox.verticalAnchor
Vertical verticalAnchor() constHow the group follows the top and the bottom edges of its parent: Vertical.Top by default.
#GroupBox.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#GroupBox.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#GroupBox.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#TextArea
struct TextArea : ComponentA 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.
gui.TextArea note = w.add(gui.TextArea("", 16, 16, 400, 160))
note.setPlaceholder("A note")
note.onChange([](string text) { println("{} characters", text.len()) })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
void onChange(move func(string) handler) constAdds 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
void setPlaceholder(string value) constSets the text shown in gray while the area is empty, as a hint of what to write.
#TextArea.placeholder
string placeholder() constThe text shown while the area is empty, "" by default.
#TextArea.setText
void setText(string value) constReplaces the text, with the cursor at its end, without calling the handlers of onChange; what Ctrl+Z could undo is forgotten.
#TextArea.text
string text() constThe text written in the area, with "\n" between its lines.
#TextArea.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the text area from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#TextArea.y
i32 y() constThe distance of the text area from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#TextArea.width
i32 width() constThe width of the text area now, in logical pixels: a Stretch anchor changes it with its parent.
#TextArea.height
i32 height() constThe height of the text area now, in logical pixels: a Stretch anchor changes it with its parent.
#TextArea.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the text area, "" for none.
#TextArea.setVisible
void setVisible(bool value) constShows or hides the text area.
#TextArea.visible
bool visible() constWhether the text area is visible, as setVisible set it: true by default.
#TextArea.setEnabled
void setEnabled(bool value) constEnables or disables the text area: disabled, it is drawn at half its opacity.
#TextArea.enabled
bool enabled() constWhether the text area is enabled, as setEnabled set it: true by default.
#TextArea.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the text area follows the left and the right edges of its parent: Horizontal.Left by default.
#TextArea.verticalAnchor
Vertical verticalAnchor() constHow the text area follows the top and the bottom edges of its parent: Vertical.Top by default.
#TextArea.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#TextArea.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#TextArea.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#ComboBox
struct ComboBox : ComponentA 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.
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()) })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
void onChange(move func(i64) handler) constAdds 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
void setItems(list<string> items) constReplaces the items with a copy of items, and leaves none chosen.
#ComboBox.items
list<string> items() constA copy of the items.
#ComboBox.addItem
void addItem(string item) constAdds an item at the end of the list; the item chosen stays the same.
#ComboBox.setSelected
void setSelected(i64 index) constChooses 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
i64 selected() constThe index of the item chosen, from 0, or -1 when none is: the default.
#ComboBox.text
string text() constThe item chosen, or "" when none is.
#ComboBox.setPlaceholder
void setPlaceholder(string value) constSets the text shown in gray while no item is chosen, as "Choose a role".
#ComboBox.placeholder
string placeholder() constThe text shown while no item is chosen, "" by default.
#ComboBox.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the combo box from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#ComboBox.y
i32 y() constThe distance of the combo box from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#ComboBox.width
i32 width() constThe width of the combo box now, in logical pixels: a Stretch anchor changes it with its parent.
#ComboBox.height
i32 height() constThe height of the combo box now, in logical pixels: a Stretch anchor changes it with its parent.
#ComboBox.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the combo box: hidden, "" for none.
#ComboBox.setVisible
void setVisible(bool value) constShows or hides the combo box: hidden, it takes neither the mouse nor the keys.
#ComboBox.visible
bool visible() constWhether the combo box is visible, as setVisible set it: true by default.
#ComboBox.setEnabled
void setEnabled(bool value) constEnables or disables the combo box: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.
#ComboBox.enabled
bool enabled() constWhether the combo box is enabled, as setEnabled set it: true by default.
#ComboBox.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the combo box follows the left and the right edges of its parent: Horizontal.Left by default.
#ComboBox.verticalAnchor
Vertical verticalAnchor() constHow the combo box follows the top and the bottom edges of its parent: Vertical.Top by default.
#ComboBox.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#ComboBox.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#ComboBox.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#ImageBox
struct ImageBox : ComponentAn 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.
gui.ImageBox logo = w.add(gui.ImageBox("", 16, 16, 64, 64))
logo.setBytes(embed("images/logo.png"))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
void setFile(string path) constShows 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
string file() constThe path of the image shown, "" when there is none or it came from bytes.
#ImageBox.setBytes
void setBytes(list<u8> bytes) constShows 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
i32 imageWidth() constThe width of the image, in its own pixels, or 0 without an image.
#ImageBox.imageHeight
i32 imageHeight() constThe height of the image, in its own pixels, or 0 without an image.
#ImageBox.setScale
void setScale(Scale value) constSets how the image fits the box: Scale.Fit by default.
#ImageBox.scale
Scale scale() constHow the image fits the box: Scale.Fit by default.
#ImageBox.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the image box from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#ImageBox.y
i32 y() constThe distance of the image box from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#ImageBox.width
i32 width() constThe width of the image box now, in logical pixels: a Stretch anchor changes it with its parent.
#ImageBox.height
i32 height() constThe height of the image box now, in logical pixels: a Stretch anchor changes it with its parent.
#ImageBox.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the image box, "" for none.
#ImageBox.setVisible
void setVisible(bool value) constShows or hides the image box.
#ImageBox.visible
bool visible() constWhether the image box is visible, as setVisible set it: true by default.
#ImageBox.setEnabled
void setEnabled(bool value) constEnables or disables the image box: disabled, it is drawn at half its opacity.
#ImageBox.enabled
bool enabled() constWhether the image box is enabled, as setEnabled set it: true by default.
#ImageBox.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the image box follows the left and the right edges of its parent: Horizontal.Left by default.
#ImageBox.verticalAnchor
Vertical verticalAnchor() constHow the image box follows the top and the bottom edges of its parent: Vertical.Top by default.
#ImageBox.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#ImageBox.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#ImageBox.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#IconBox
struct IconBox : ComponentAn 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.
w.add(gui.IconBox(gui.Icon.CircleCheck, 16, 16, 48, 48))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
void setIcon(Icon value) constChanges the icon; Icon.None shows nothing.
#IconBox.icon
Icon icon() constThe icon shown, Icon.None for none.
#IconBox.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the icon box from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#IconBox.y
i32 y() constThe distance of the icon box from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#IconBox.width
i32 width() constThe width of the icon box now, in logical pixels: a Stretch anchor changes it with its parent.
#IconBox.height
i32 height() constThe height of the icon box now, in logical pixels: a Stretch anchor changes it with its parent.
#IconBox.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the icon box, "" for none.
#IconBox.setVisible
void setVisible(bool value) constShows or hides the icon box.
#IconBox.visible
bool visible() constWhether the icon box is visible, as setVisible set it: true by default.
#IconBox.setEnabled
void setEnabled(bool value) constEnables or disables the icon box: disabled, it is drawn at half its opacity.
#IconBox.enabled
bool enabled() constWhether the icon box is enabled, as setEnabled set it: true by default.
#IconBox.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the icon box follows the left and the right edges of its parent: Horizontal.Left by default.
#IconBox.verticalAnchor
Vertical verticalAnchor() constHow the icon box follows the top and the bottom edges of its parent: Vertical.Top by default.
#IconBox.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#IconBox.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#IconBox.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#Panel
struct Panel : ComponentA 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.
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))
}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
T add<T : Component>(T component) constPuts 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
i32 scrollY() constHow far the panel is scrolled, in logical pixels from the top: 0 when it is not.
#Panel.scrollTo
void scrollTo(i32 y) constScrolls 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
void setPalette(Palette light, Palette dark) constGives 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
void resetPalette() constGives what the panel holds the colors of the window again.
#Panel.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the panel from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#Panel.y
i32 y() constThe distance of the panel from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#Panel.width
i32 width() constThe width of the panel now, in logical pixels: a Stretch anchor changes it with its parent.
#Panel.height
i32 height() constThe height of the panel now, in logical pixels: a Stretch anchor changes it with its parent.
#Panel.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the panel, "" for none.
#Panel.setVisible
void setVisible(bool value) constShows or hides the panel, and its components with it.
#Panel.visible
bool visible() constWhether the panel is visible, as setVisible set it: true by default.
#Panel.setEnabled
void setEnabled(bool value) constEnables 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
bool enabled() constWhether the panel is enabled, as setEnabled set it: true by default.
#Panel.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the panel follows the left and the right edges of its parent: Horizontal.Left by default.
#Panel.verticalAnchor
Vertical verticalAnchor() constHow the panel follows the top and the bottom edges of its parent: Vertical.Top by default.
#Panel.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#Panel.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#Panel.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#Split
struct Split : ComponentTwo 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.
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))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
Panel first() constThe 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
Panel second() constThe second panel: on the right, or under the first, as first says.
#Split.direction
Direction direction() constHow the split puts its panels, as it was made.
#Split.setRatio
void setRatio(f32 value) constGives 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
f32 ratio() constThe 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
void setFirstSize(i32 pixels) constKeeps 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
void setSecondSize(i32 pixels) constKeeps the second panel pixels wide, or high, and the first takes the rest. A negative size is a panic.
#Split.setMinimums
void setMinimums(i32 first, i32 second) constThe 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
void setGap(i32 pixels) constThe room between the panels, in logical pixels: 8 by default. A negative gap is a panic.
#Split.gap
i32 gap() constThe room between the panels, in logical pixels.
#Split.setDraggable
void setDraggable(bool value) constLets 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
bool draggable() constWhether the user can move the line, as setDraggable set it: false by default.
#Split.onChange
void onChange(move func(f32) handler) constAdds 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
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the split from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#Split.y
i32 y() constThe distance of the split from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#Split.width
i32 width() constThe width of the split now, in logical pixels: a Stretch anchor changes it with its parent.
#Split.height
i32 height() constThe height of the split now, in logical pixels: a Stretch anchor changes it with its parent.
#Split.setVisible
void setVisible(bool value) constShows or hides the split, and its panels with it.
#Split.visible
bool visible() constWhether the split is visible, as setVisible set it: true by default.
#Split.setEnabled
void setEnabled(bool value) constEnables 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
bool enabled() constWhether the split is enabled, as setEnabled set it: true by default.
#Split.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the split follows the left and the right edges of its parent: Horizontal.Left by default.
#Split.verticalAnchor
Vertical verticalAnchor() constHow the split follows the top and the bottom edges of its parent: Vertical.Top by default.
#Split.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#Split.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#Split.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#AppBar
struct AppBar : ComponentThe 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.
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") })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
void setTitle(string value) constChanges the title of the bar.
#AppBar.title
string title() constThe title of the bar.
#AppBar.setNavigation
void setNavigation(Icon value) constPuts 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
Icon navigation() constThe icon on the left of the bar, Icon.None without one.
#AppBar.onNavigation
void onNavigation(move func() handler) constAdds 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
void addAction(Icon icon, move func() handler) constAdds 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
void setActionTooltip(i64 index, string text) constGives 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
i32 x() constThe distance of the app bar from the left edge of the content: 0.
#AppBar.y
i32 y() constThe distance of the app bar from the top of the content: 0.
#AppBar.width
i32 width() constThe width of the app bar, in logical pixels: that of the content of its window, once it is in one.
#AppBar.height
i32 height() constThe height of the app bar: 56 logical pixels.
#AppBar.setVisible
void setVisible(bool value) constShows or hides the app bar: the room that it takes at the top stays empty.
#AppBar.visible
bool visible() constWhether the app bar is visible, as setVisible set it: true by default.
#AppBar.setEnabled
void setEnabled(bool value) constEnables or disables the app bar: disabled, it is drawn at half its opacity and its icons do not respond.
#AppBar.enabled
bool enabled() constWhether the app bar is enabled, as setEnabled set it: true by default.
#AppBar.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#AppBar.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#AppBar.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#NavigationBar
struct NavigationBar : ComponentThe 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.
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") })#NavigationBar.addPage
Panel addPage(string text, Icon icon) constAdds 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.
#NavigationBar.setSelected
void setSelected(i64 index) constChooses 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.
#NavigationBar.selected
i64 selected() constThe index of the item chosen, whose page is shown: 0 at the start.
#NavigationBar.onChange
void onChange(move func(i64) handler) constAdds 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.
#NavigationBar.x
i32 x() constThe distance of the navigation bar from the left edge of the content: 0.
#NavigationBar.y
i32 y() constThe 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.
#NavigationBar.width
i32 width() constThe width of the navigation bar, in logical pixels: that of the content of its window.
#NavigationBar.height
i32 height() constThe height of the navigation bar: 64 logical pixels.
#NavigationBar.setVisible
void setVisible(bool value) constShows or hides the navigation bar, and its pages with it.
#NavigationBar.visible
bool visible() constWhether the navigation bar is visible, as setVisible set it: true by default.
#NavigationBar.setEnabled
void setEnabled(bool value) constEnables 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.
#NavigationBar.enabled
bool enabled() constWhether the navigation bar is enabled, as setEnabled set it: true by default.
#NavigationBar.setBackground
void setBackground(Color color) constSets 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).
#NavigationBar.setTextColor
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#NavigationBar.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#NavigationBar.setCornerRadius
void setCornerRadius(f32 radius) constSets 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.
#NavigationBar.setTextSize
void setTextSize(f32 size) constSets 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.
#NavigationBar.resetLook
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#ListView
struct ListView : ComponentA 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.
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)) })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
void addItem(Icon icon, string title, string subtitle, string detail) constAdds 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
void insertItem(i64 index, Icon icon, string title, string subtitle, string detail) constInserts 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
void setItem(i64 index, Icon icon, string title, string subtitle, string detail) constReplaces 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
void removeItem(i64 index) constRemoves 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
void clear() constRemoves all the items, with their images, leaves none chosen, and scrolls back to the top.
#ListView.count
i64 count() constHow many items the list has.
#ListView.itemTitle
string itemTitle(i64 index) constThe title of the item at index. An index out of the items is a panic.
#ListView.itemSubtitle
string itemSubtitle(i64 index) constThe line under the title of the item at index, "" if it has none. An index out of the items is a panic.
#ListView.itemDetail
string itemDetail(i64 index) constThe text on the right of the item at index, "" if it has none. An index out of the items is a panic.
#ListView.itemIcon
Icon itemIcon(i64 index) constThe icon of the item at index, Icon.None if it has none. An index out of the items is a panic.
#ListView.setSelected
void setSelected(i64 index) constChooses 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
i64 selected() constThe index of the item chosen, from 0, or -1 when none is: the default.
#ListView.onChoose
void onChoose(move func(i64) handler) constAdds 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
void setItemImage(i64 index, string file) constShows 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
void setItemImageBytes(i64 index, list<u8> bytes) constShows 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
void scrollTo(i64 index) constScrolls the list as little as it takes to show the item at index. An index out of the items is a panic.
#ListView.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the list from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#ListView.y
i32 y() constThe distance of the list from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#ListView.width
i32 width() constThe width of the list now, in logical pixels: a Stretch anchor changes it with its parent.
#ListView.height
i32 height() constThe height of the list now, in logical pixels: a Stretch anchor changes it with its parent.
#ListView.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the list: hidden, "" for none.
#ListView.setVisible
void setVisible(bool value) constShows or hides the list: hidden, it takes neither the mouse nor the keys.
#ListView.visible
bool visible() constWhether the list is visible, as setVisible set it: true by default.
#ListView.setEnabled
void setEnabled(bool value) constEnables or disables the list: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.
#ListView.enabled
bool enabled() constWhether the list is enabled, as setEnabled set it: true by default.
#ListView.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the list follows the left and the right edges of its parent: Horizontal.Left by default.
#ListView.verticalAnchor
Vertical verticalAnchor() constHow the list follows the top and the bottom edges of its parent: Vertical.Top by default.
#ListView.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#ListView.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#ListView.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#Switch
struct Switch : ComponentA 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.
gui.Switch notify = w.add(gui.Switch("Notifications", 16, 16, 358, 32))
notify.setChecked(true)
notify.onChange([](bool on) { println("notifications: {}", on) })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
void onChange(move func(bool) handler) constAdds 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
void setChecked(bool value) constTurns the switch on, with true, or off, without calling the handlers of onChange.
#Switch.checked
bool checked() constWhether the switch is on: false at the start.
#Switch.setText
void setText(string value) constChanges the text on the left of the switch.
#Switch.text
string text() constThe text on the left of the switch.
#Switch.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the switch from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#Switch.y
i32 y() constThe distance of the switch from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#Switch.width
i32 width() constThe width of the switch now, in logical pixels: a Stretch anchor changes it with its parent.
#Switch.height
i32 height() constThe height of the switch now, in logical pixels: a Stretch anchor changes it with its parent.
#Switch.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the switch: hidden, "" for none.
#Switch.setVisible
void setVisible(bool value) constShows or hides the switch: hidden, it takes neither the mouse nor the keys.
#Switch.visible
bool visible() constWhether the switch is visible, as setVisible set it: true by default.
#Switch.setEnabled
void setEnabled(bool value) constEnables or disables the switch: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.
#Switch.enabled
bool enabled() constWhether the switch is enabled, as setEnabled set it: true by default.
#Switch.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the switch follows the left and the right edges of its parent: Horizontal.Left by default.
#Switch.verticalAnchor
Vertical verticalAnchor() constHow the switch follows the top and the bottom edges of its parent: Vertical.Top by default.
#Switch.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#Switch.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#Switch.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#Slider
struct Slider : ComponentAn 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.
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)) })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
void onChange(move func(i64) handler) constAdds 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
void setValue(i64 value) constSets the value, kept between the minimum and the maximum, without calling the handlers of onChange.
#Slider.value
i64 value() constThe value now, between the minimum and the maximum.
#Slider.minimum
i64 minimum() constThe smallest value, at the left end of the track.
#Slider.maximum
i64 maximum() constThe largest value, at the right end of the track.
#Slider.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the slider from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#Slider.y
i32 y() constThe distance of the slider from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#Slider.width
i32 width() constThe width of the slider now, in logical pixels: a Stretch anchor changes it with its parent.
#Slider.height
i32 height() constThe height of the slider now, in logical pixels: a Stretch anchor changes it with its parent.
#Slider.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the slider: hidden, "" for none.
#Slider.setVisible
void setVisible(bool value) constShows or hides the slider: hidden, it takes neither the mouse nor the keys.
#Slider.visible
bool visible() constWhether the slider is visible, as setVisible set it: true by default.
#Slider.setEnabled
void setEnabled(bool value) constEnables or disables the slider: disabled, it is drawn at half its opacity and takes neither the mouse nor the keys.
#Slider.enabled
bool enabled() constWhether the slider is enabled, as setEnabled set it: true by default.
#Slider.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the slider follows the left and the right edges of its parent: Horizontal.Left by default.
#Slider.verticalAnchor
Vertical verticalAnchor() constHow the slider follows the top and the bottom edges of its parent: Vertical.Top by default.
#Slider.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#Slider.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#Slider.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#Table
struct Table : ComponentRows 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.
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)
})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
void addColumn(string title, i32 width, Horizontal align) constAdds 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
i64 columnCount() constThe number of the columns, also those hidden.
#Table.setColumnVisible
void setColumnVisible(i64 index, bool visible) constShows or hides the column at index, from 0; the others take its place. An index out of the columns is a panic.
#Table.setRowCount
void setRowCount(i64 count) constChanges 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
i64 rowCount() constThe number of the rows.
#Table.setRows
void setRows(i64 first, list<list<string>> rows) constGives 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
void clearRows() constForgets 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
string cell(i64 row, i64 column) constThe cell of a row and a column, from 0, or "" when the row has not been given.
#Table.onNeedRows
void onNeedRows(move func(i64, i64) handler) constAdds 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
void onSort(move func(i64, bool) handler) constAdds 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
void setSort(i64 column, bool descending) constShows the order of a column, -1 for none, without calling the handlers of onSort.
#Table.sortColumn
i64 sortColumn() constThe column of the order, or -1.
#Table.sortDescending
bool sortDescending() constWhether the order is descending.
#Table.onChange
void onChange(move func(i64) handler) constAdds 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
void onChoose(move func(i64) handler) constAdds 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
void setSelected(i64 index) constChooses 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
i64 selected() constThe row chosen last, from 0, or -1 for none.
#Table.selectedRows
list<i64> selectedRows() constAll the rows chosen, in order. Shift and a click on a table of millions of rows can choose millions of them.
#Table.scrollTo
void scrollTo(i64 index) constScrolls the table to show the row at index, from 0.
#Table.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the table from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#Table.y
i32 y() constThe distance of the table from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#Table.width
i32 width() constThe width of the table now, in logical pixels: a Stretch anchor changes it with its parent.
#Table.height
i32 height() constThe height of the table now, in logical pixels: a Stretch anchor changes it with its parent.
#Table.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the table, "" for none.
#Table.setVisible
void setVisible(bool value) constShows or hides the table.
#Table.visible
bool visible() constWhether the table is visible, as setVisible set it: true by default.
#Table.setEnabled
void setEnabled(bool value) constEnables or disables the table: disabled, it is drawn at half its opacity.
#Table.enabled
bool enabled() constWhether the table is enabled, as setEnabled set it: true by default.
#Table.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the table follows the left and the right edges of its parent: Horizontal.Left by default.
#Table.verticalAnchor
Vertical verticalAnchor() constHow the table follows the top and the bottom edges of its parent: Vertical.Top by default.
#Table.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#Table.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#Table.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#RichText
struct RichTextRich 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.
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
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.
#RichText.link
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
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
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
void gap(f32 width)Adds an empty space width logical pixels wide, where the line can break, as a space can.
#RichText.newLine
void newLine()Ends the line: what follows starts on the next one. Two new lines leave an empty line between.
#RichText.startBlock
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
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
void tooltip(i64 piece, string text)Gives the piece with that number a tooltip, shown when the mouse stays on it.
#RichText.clear
void clear()Removes everything.
#RichText.len
i64 len() constThe number of the parts added: texts, images, gaps, new lines, starts and ends of blocks.
#TextView
struct TextView : ComponentA 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.
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) })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
void setText(move RichText text) constShows 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
void onClick(move func(i64, Mouse) handler) constAdds 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
void setMarked(i64 piece) constMarks 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
i64 marked() constThe number of the piece marked, or -1.
#TextView.scrollTo
void scrollTo(i64 piece) constScrolls the view as little as it takes to show the piece with that number.
#TextView.scrollY
i32 scrollY() constHow far the view is scrolled, in logical pixels from the top: 0 when it is not.
#TextView.setTextSize
void setTextSize(f32 size) constSets 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
f32 textSize() constThe size of the text, in logical pixels.
#TextView.setLineSpacing
void setLineSpacing(f32 value) constSets 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
f32 lineSpacing() constThe height of the lines, from the size of their text.
#TextView.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the view from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#TextView.y
i32 y() constThe distance of the view from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#TextView.width
i32 width() constThe width of the view now, in logical pixels: a Stretch anchor changes it with its parent.
#TextView.height
i32 height() constThe height of the view now, in logical pixels: a Stretch anchor changes it with its parent.
#TextView.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the view, "" for none.
#TextView.setVisible
void setVisible(bool value) constShows or hides the view.
#TextView.visible
bool visible() constWhether the view is visible, as setVisible set it: true by default.
#TextView.setEnabled
void setEnabled(bool value) constEnables or disables the view: disabled, it is drawn at half its opacity.
#TextView.enabled
bool enabled() constWhether the view is enabled, as setEnabled set it: true by default.
#TextView.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the view follows the left and the right edges of its parent: Horizontal.Left by default.
#TextView.verticalAnchor
Vertical verticalAnchor() constHow the view follows the top and the bottom edges of its parent: Vertical.Top by default.
#TextView.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#TextView.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#TextView.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void resetLook() constGives the component the look of the theme again: its colors and its corners.
#TabView
struct TabView : ComponentPages 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.
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) })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
Panel addPage(string title) constAdds 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
i64 pageCount() constThe number of the tabs.
#TabView.setPageTitle
void setPageTitle(i64 index, string title) constChanges the title of the tab at index, from 0. An index out of the tabs is a panic.
#TabView.pageTitle
string pageTitle(i64 index) constThe title of the tab at index, from 0. An index out of the tabs is a panic.
#TabView.setSelected
void setSelected(i64 index) constChooses 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
i64 selected() constThe index of the tab chosen, whose page is shown: 0 at the start.
#TabView.onChange
void onChange(move func(i64) handler) constAdds 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
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the tab view from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#TabView.y
i32 y() constThe distance of the tab view from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#TabView.width
i32 width() constThe width of the tab view now, in logical pixels: a Stretch anchor changes it with its parent.
#TabView.height
i32 height() constThe height of the tab view now, in logical pixels: a Stretch anchor changes it with its parent.
#TabView.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the tab view, "" for none.
#TabView.setVisible
void setVisible(bool value) constShows or hides the tab view.
#TabView.visible
bool visible() constWhether the tab view is visible, as setVisible set it: true by default.
#TabView.setEnabled
void setEnabled(bool value) constEnables or disables the tab view: disabled, it is drawn at half its opacity.
#TabView.enabled
bool enabled() constWhether the tab view is enabled, as setEnabled set it: true by default.
#TabView.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the tab view follows the left and the right edges of its parent: Horizontal.Left by default.
#TabView.verticalAnchor
Vertical verticalAnchor() constHow the tab view follows the top and the bottom edges of its parent: Vertical.Top by default.
#TabView.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#TabView.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#TabView.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#Segmented
struct Segmented : ComponentA 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.
gui.Segmented period = w.add(gui.Segmented(["Day", "Week", "Month"], 16, 16, 240, 28))
period.onChange([](i64 index) { println("period {}", index) })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
void setItems(list<string> segments) constReplaces the segments with a copy of segments, and chooses the first one.
#Segmented.items
list<string> items() constA copy of the segments.
#Segmented.setSelected
void setSelected(i64 index) constChooses the segment at index, from 0, without calling the handlers of onChange. An index out of the segments is a panic.
#Segmented.selected
i64 selected() constThe index of the segment chosen, from 0: -1 only without segments.
#Segmented.text
string text() constThe text of the segment chosen, or "" without segments.
#Segmented.onChange
void onChange(move func(i64) handler) constAdds 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
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the segmented control from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#Segmented.y
i32 y() constThe distance of the segmented control from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#Segmented.width
i32 width() constThe width of the segmented control now, in logical pixels: a Stretch anchor changes it with its parent.
#Segmented.height
i32 height() constThe height of the segmented control now, in logical pixels: a Stretch anchor changes it with its parent.
#Segmented.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the segmented control, "" for none.
#Segmented.setVisible
void setVisible(bool value) constShows or hides the segmented control.
#Segmented.visible
bool visible() constWhether the segmented control is visible, as setVisible set it: true by default.
#Segmented.setEnabled
void setEnabled(bool value) constEnables or disables the segmented control: disabled, it is drawn at half its opacity.
#Segmented.enabled
bool enabled() constWhether the segmented control is enabled, as setEnabled set it: true by default.
#Segmented.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the segmented control follows the left and the right edges of its parent: Horizontal.Left by default.
#Segmented.verticalAnchor
Vertical verticalAnchor() constHow the segmented control follows the top and the bottom edges of its parent: Vertical.Top by default.
#Segmented.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#Segmented.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#Segmented.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#Menu
struct MenuA 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.
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)
}
})#Menu.addItem
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.
#Menu.addIconItem
void addIconItem(Icon icon, string text, move func() handler)Adds an item with an icon on the left of its text, as addItem does.
#Menu.addSeparator
void addSeparator()Adds a line between the items above and those below.
#Menu.addSubmenu
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.
#Menu.setEnabled
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.
#Menu.len
i64 len() constThe number of the entries: the items, the separators and the items with a submenu.
#Menu.clear
void clear()Removes all the entries.
#RadioGroup
struct RadioGroup : ComponentA 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.
gui.RadioGroup size = w.add(gui.RadioGroup(["Small", "Medium", "Large"], 16, 16, 200, 84))
size.onChange([size](i64 index) { println("size {}", size.text()) })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
void setItems(list<string> choices) constReplaces the choices with a copy of choices, and chooses the first one.
#RadioGroup.items
list<string> items() constA copy of the choices.
#RadioGroup.setSelected
void setSelected(i64 index) constChooses the choice at index, from 0, without calling the handlers of onChange. An index out of the choices is a panic.
#RadioGroup.selected
i64 selected() constThe index of the choice chosen, from 0: -1 only without choices.
#RadioGroup.text
string text() constThe text of the choice chosen, or "" without choices.
#RadioGroup.onChange
void onChange(move func(i64) handler) constAdds 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
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the radio group from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#RadioGroup.y
i32 y() constThe distance of the radio group from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#RadioGroup.width
i32 width() constThe width of the radio group now, in logical pixels: a Stretch anchor changes it with its parent.
#RadioGroup.height
i32 height() constThe height of the radio group now, in logical pixels: a Stretch anchor changes it with its parent.
#RadioGroup.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the radio group, "" for none.
#RadioGroup.setVisible
void setVisible(bool value) constShows or hides the radio group.
#RadioGroup.visible
bool visible() constWhether the radio group is visible, as setVisible set it: true by default.
#RadioGroup.setEnabled
void setEnabled(bool value) constEnables or disables the radio group: disabled, it is drawn at half its opacity.
#RadioGroup.enabled
bool enabled() constWhether the radio group is enabled, as setEnabled set it: true by default.
#RadioGroup.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the radio group follows the left and the right edges of its parent: Horizontal.Left by default.
#RadioGroup.verticalAnchor
Vertical verticalAnchor() constHow the radio group follows the top and the bottom edges of its parent: Vertical.Top by default.
#RadioGroup.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#RadioGroup.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#RadioGroup.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#ProgressBar
struct ProgressBar : ComponentA 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.
gui.ProgressBar progress = w.add(gui.ProgressBar(16, 16, 300, 8))
progress.setValue(0.25)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
void setValue(f64 value) constSets 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
f64 value() constThe part done, from 0 to 1.
#ProgressBar.setBusy
void setBusy(bool busy) constShows a segment that runs instead of the part done, while busy is true.
#ProgressBar.busy
bool busy() constWhether the bar shows a wait without a measure.
#ProgressBar.setPosition
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the progress bar from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#ProgressBar.y
i32 y() constThe distance of the progress bar from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#ProgressBar.width
i32 width() constThe width of the progress bar now, in logical pixels: a Stretch anchor changes it with its parent.
#ProgressBar.height
i32 height() constThe height of the progress bar now, in logical pixels: a Stretch anchor changes it with its parent.
#ProgressBar.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the progress bar, "" for none.
#ProgressBar.setVisible
void setVisible(bool value) constShows or hides the progress bar.
#ProgressBar.visible
bool visible() constWhether the progress bar is visible, as setVisible set it: true by default.
#ProgressBar.setEnabled
void setEnabled(bool value) constEnables or disables the progress bar: disabled, it is drawn at half its opacity.
#ProgressBar.enabled
bool enabled() constWhether the progress bar is enabled, as setEnabled set it: true by default.
#ProgressBar.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the progress bar follows the left and the right edges of its parent: Horizontal.Left by default.
#ProgressBar.verticalAnchor
Vertical verticalAnchor() constHow the progress bar follows the top and the bottom edges of its parent: Vertical.Top by default.
#ProgressBar.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#ProgressBar.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#ProgressBar.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#Drawing
struct DrawingWhat 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.
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
void rect(f32 x, f32 y, f32 width, f32 height, Color color)A rectangle filled with a color.
#Drawing.roundRect
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
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
void circle(f32 x, f32 y, f32 radius, Color color)A circle with its center at x, y, filled with a color.
#Drawing.ring
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
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
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
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
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
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
void clear()Removes all the shapes.
#Drawing.len
i64 len() constThe number of shapes.
#Canvas
struct Canvas : ComponentA 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.
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) })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
void setDrawing(move Drawing drawing) constShows 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
void onMouseDown(move func(Mouse) handler) constAdds 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
void onMouseMove(move func(Mouse) handler) constAdds 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
void onMouseUp(move func(Mouse) handler) constAdds 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
void onWheel(move func(Mouse, f32) handler) constAdds 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
void setPosition(i32 x, i32 y) constMoves 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
void setSize(i32 width, i32 height) constChanges 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
i32 x() constThe distance of the canvas from the left edge of its parent, in logical pixels, where its anchors have placed it now.
#Canvas.y
i32 y() constThe distance of the canvas from the top edge of its parent, in logical pixels, where its anchors have placed it now.
#Canvas.width
i32 width() constThe width of the canvas now, in logical pixels: a Stretch anchor changes it with its parent.
#Canvas.height
i32 height() constThe height of the canvas now, in logical pixels: a Stretch anchor changes it with its parent.
#Canvas.setTooltip
void setTooltip(string text) constSets 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
string tooltip() constThe text of the tooltip of the canvas, "" for none.
#Canvas.setVisible
void setVisible(bool value) constShows or hides the canvas.
#Canvas.visible
bool visible() constWhether the canvas is visible, as setVisible set it: true by default.
#Canvas.setEnabled
void setEnabled(bool value) constEnables or disables the canvas: disabled, it is drawn at half its opacity.
#Canvas.enabled
bool enabled() constWhether the canvas is enabled, as setEnabled set it: true by default.
#Canvas.setAnchor
void setAnchor(Horizontal horizontal, Vertical vertical) constSets 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
Horizontal horizontalAnchor() constHow the canvas follows the left and the right edges of its parent: Horizontal.Left by default.
#Canvas.verticalAnchor
Vertical verticalAnchor() constHow the canvas follows the top and the bottom edges of its parent: Vertical.Top by default.
#Canvas.setBackground
void setBackground(Color color) constSets 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
void setTextColor(Color color) constSets the color of the text of the component, in place of the one of the theme.
#Canvas.setBorderColor
void setBorderColor(Color color) constSets the color of the border and of the lines of the component, in place of the one of the theme.
#Canvas.setCornerRadius
void setCornerRadius(f32 radius) constSets 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
void setTextSize(f32 size) constSets 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
void resetLook() constGives the component the look of the theme again: its colors, its corners and the size of its text.
#Dialog
struct DialogA 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.
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) })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
T add<T : Component>(T component) constPuts 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
void addButton(string text, move func() handler) constAdds 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
void close() constCloses 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
void onClose(move func() handler) constAdds 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
bool shown() constWhether a window shows the dialog now.
#Dialog.setTitle
void setTitle(string value) constChanges the title of the dialog.
#Dialog.title
string title() constThe title of the dialog.
#Window
struct WindowA 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.
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()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
T add<T : Component>(T component) constPuts 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
NavigationBar navigationBar() constThe 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
void setTitle(string text) constChanges 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
string title() constThe title of the window.
#Window.setSize
void setSize(i32 w, i32 h) constChanges 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
i32 width() constThe 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
i32 height() constThe 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
void setResizable(bool value) constSets 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
void setIcon(Icon value) constPuts 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.
w.setIcon(gui.Icon.Mail)
w.setIcon(gui.Icon.None) // no icon#Window.icon
Icon icon() constThe icon of Lucide at the left of the title bar: Icon.None without one, and with an image.
#Window.setIconImage
void setIconImage(Image picture) constPuts 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.
w.setIconImage(gui.Image(embed("logo.svg")))#Window.setTitleBarVisible
void setTitleBarVisible(bool value) constShows 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.
gui.Window w = gui.Window("Splash", 420, 260)
w.setTitleBarVisible(false)
w.setCornerRadius(12)#Window.setTitleBarHeight
void setTitleBarHeight(i32 height) constSets 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
i32 titleBarHeight() constThe height of the title bar: 35 by default.
#Window.titleBarVisible
bool titleBarVisible() constWhether the title bar is shown: true by default.
#Window.setButtons
void setButtons(bool minimize, bool maximize, bool close) constChooses 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.
w.setButtons(false, false, true) // only the button to close, as a dialog#Window.setCornerRadius
void setCornerRadius(i32 radius) constRounds 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
i32 cornerRadius() constThe radius of the corners of the window: 0 by default.
#Window.resizable
bool resizable() constWhether the user can resize the window: true by default.
#Window.minimize
void minimize() constMinimizes the window; called before start, the window starts minimized. On Android it does nothing.
#Window.maximize
void maximize() constMaximizes the window; called before start, the window starts maximized. On Android it does nothing.
#Window.restore
void restore() constBrings 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
bool minimized() constWhether the window is minimized now; before start, whether it starts so.
#Window.maximized
bool maximized() constWhether the window is maximized now; before start, whether it starts so.
#Window.setTheme
void setTheme(Theme value) constSets 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
void setPalette(Palette light, Palette dark) constGives 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
void resetPalette() constGives the window the colors of the library again.
#Window.theme
Theme theme() constThe theme of the window, Theme.System by default.
#Window.setFps
void setFps(i32 value) constSets 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
void setVsync(bool value) constDraws 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
bool vsync() constWhether the window is asked to be drawn in step with the display.
#Window.fps
i32 fps() constThe most frames of the window drawn each second: 60 by default.
#Window.start
void start() constShows 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
void close() constCloses 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
bool closed() constWhether the window is closed, by the user or by close, once its handlers of onClose have run.
#Window.wait
void wait() constWaits 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
void onMouseMove(move func(Mouse) handler) constAdds 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
void onMouseDown(move func(Mouse) handler) constAdds 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
void onMouseUp(move func(Mouse) handler) constAdds 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
void onKeyDown(move func(Key) handler) constAdds 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
void onKeyUp(move func(Key) handler) constAdds 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
void onUpdate(move func(f32) handler) constAdds 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.
w.onUpdate([ball, canvas](f32 seconds) {
ball.lock([seconds](ref f32 x) { x += 120 * seconds }) // 120 pixels a second
...
})#Window.onTouchDown
void onTouchDown(move func(Touch) handler) constAdds 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
void onTouchMove(move func(Touch) handler) constAdds a handler, called on the thread of the windows when a finger that touches the window moves.
#Window.onTouchUp
void onTouchUp(move func(Touch) handler) constAdds 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
void setFullscreen(bool value) constGives 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
bool fullscreen() constWhether the window has the whole screen: false by default.
#Window.setOrientation
void setOrientation(Orientation value) constSays 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
Orientation orientation() constHow a phone holds the window: Orientation.Any by default.
#Window.onMotion
void onMotion(move func(Motion) handler) constAdds 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.
w.onMotion([level](gui.Motion m) {
level.setText(format("tilted {:.1f} to the right", m.accelerationX))
})#Window.onResize
void onResize(move func(i32, i32) handler) constAdds 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
Panel titleBar() constThe 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
void showDialog(Dialog dialog) constOpens 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
void openFile(list<FileType> types, move func(list<string>) handler) constShows 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
void openFiles(list<FileType> types, move func(list<string>) handler) constShows the dialog of the system to open one file or more, as openFile does: the handler receives all the paths chosen.
#Window.saveFile
void saveFile(list<FileType> types, string name, move func(string) handler) constShows 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
void openFolder(move func(string) handler) constShows 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
void showMenu(move Menu menu) constOpens 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
void showMenuUnder<T : Component>(move Menu menu, T anchor) constOpens 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
void closeMenu() constCloses the menu open, if there is one, without calling its handlers.
#Window.showSnackbar
void showSnackbar(string text) constShows 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
void showSnackbarAction(string text, string action, move func() handler) constShows 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.
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
void onBack(move func() handler) constAdds 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.
w.onBack([w, pages]() {
if (pages.selected() == 0) {
w.close()
} else {
pages.setSelected(0)
}
})#Window.onClose
void onClose(move func() handler) constAdds 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.
#Functions
#lightPalette
Palette lightPalette()The colors of the light theme of the library, to change some of them.
#darkPalette
Palette darkPalette()The colors of the dark theme of the library, to change some of them.
#palette
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
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.
warning.setTextColor(gui.role(gui.Role.Danger))#rgb
Color rgb(u32 value)An opaque color from its value 0xRRGGBB, as in CSS: gui.rgb(0xB4761C).
#rgba
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
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.