nuklear

  1. nuklear
    1. Introduction
    2. Author
    3. Repository
    4. Current state of the bindings
      1. Backends
      2. API Support
      3. Vendored headers
    5. Requirements
    6. API
      1. Backends
        1. glfw-opengl2 Backend
          1. anti-alias?
          2. max-vertex-buffer
          3. max-element-buffer
          4. init!
          5. init-font!
          6. new-frame
          7. render!
          8. shutdown!
      2. Basic types
        1. Panels
          1. make-panel
          2. panel-bounds
        2. Rects
          1. make-rect
          2. rect-x / rect-x-set!
          3. rect-y / rect-y-set!
          4. rect-w / rect-w-set!
          5. rect-h / rect-h-set!
        3. Vectors
          1. make-vec2
          2. vec2-x / vec2-x-set!
          3. vec2-y / vec2-y-set!
        4. Colors
          1. make-color
          2. color-r / color-r-set!
          3. color-g / color-g-set!
          4. color-b / color-b-set!
          5. color-a / color-a-set!
        5. Color helpers
          1. rgb->color
          2. color->rgba-floats
          3. hsva->color
          4. color->hsva-ints
      3. Window helpers
        1. window-bounds
        2. window-content-region
        3. window-canvas
        4. window-closed?
      4. Layouts
        1. Constrained positioning
          1. layout-row-dynamic
          2. layout-row-static
          3. layout-row-begin
          4. layout-row-push
          5. layout-row-end
          6. layout-row
        2. Free positioning
          1. layout-space-begin
          2. layout-space-push
          3. layout-space-end
        3. Layout space helpers
          1. layout-space-bounds
          2. layout-space-to-screen
          3. layout-space-rect-to-screen
          4. layout-space-rect-to-local
        4. Misc
          1. spacing
      5. Blocks
        1. Window block
          1. window-begin
          2. window-end
        2. Group block
          1. group-begin
          2. group-end
        3. Tree block
          1. tree-push
          2. tree-pop
        4. Chart block
          1. chart-begin
          2. chart-begin-colored
          3. chart-push
          4. chart-push-slot
          5. chart-add-slot
          6. chart-add-slot-colored
          7. chart-end
        5. Popup block
          1. popup-begin
          2. popup-close
          3. popup-end
        6. Combo block
          1. combo-begin-label
          2. combo-begin-color
          3. combo-items-height
          4. combo-item-label
          5. combo-close
          6. combo-end
        7. Contextual block
          1. contextual-begin
          2. contextual-item-label
          3. contextual-end
        8. Menubar block
          1. menubar-begin
          2. menubar-end
        9. Menu block
          1. menu-begin-label
          2. menu-item-label
          3. menu-end
      6. Widgets
        1. Label widget
          1. label
          2. label-colored
          3. label-wrap
        2. Button widget
          1. button-label
          2. button-color
          3. button-symbol
          4. button-symbol-label
        3. Checkbox widget
          1. checkbox-label
        4. Option widget
          1. option-label
        5. Selectable widget
          1. selectable-label
        6. Slider widget
          1. slider-float
          2. slider-int
        7. Progressbar widget
          1. progressbar
        8. Color picker widget
          1. color-picker
        9. Property widget
          1. property-float
          2. property-int
        10. Editor widget
          1. edit-string
      7. Tooltip
        1. tooltip
      8. Context
        1. context-input
        2. context-style
      9. Canvas
        1. stroke-line
        2. stroke-curve
        3. fill-circle
      10. Styling
        1. style-window-border
        2. style-window-header-align-set!
      11. Input
        1. input-mouse
        2. mouse-delta
        3. mouse-position
        4. input-mouse-click-down-in-rect?
        5. input-mouse-hovering-in-rect?
        6. input-mouse-previously-hovering-in-rect?
        7. input-mouse-clicked?
        8. input-mouse-down?
        9. input-mouse-released?
    7. Examples
    8. Notes
    9. License
    10. Version history
      1. 0.1

Introduction

This egg provides an incomplete set of bindings to the nuklear immediate mode GUI library.

Author

Vasilij Schneidermann

Repository

https://github.com/wasamasa/nuklear

Current state of the bindings

Backends

API Support

Everything required for the GLFW3 OpenGL2 demos is supported.

Vendored headers

Last synced: 07-06-2016

Requirements

To compile the egg successfully, all foreign dependencies for the glfw-opengl2 backend must be met:

Additionally to this, you will need a GPU supporting OpenGL2. The setup script has only been tested on Linux and will most certainly need adjustments to work on OS X and Windows.

API

Backends

glfw-opengl2 Backend
anti-alias?
[parameter] (anti-alias?)
[parameter] (anti-alias? FLAG)

Controls whether anti-aliasing is enabled, defaulting to #t.

max-vertex-buffer
[parameter] (max-vertex-buffer)
[parameter] (max-vertex-buffer N)

Controls the maximum amount of vertices, defaulting to 512*1024.

max-element-buffer
[parameter] (max-element-buffer)
[parameter] (max-element-buffer N)

Controls the maximum amount of elements, defaulting to 128*1024.

init!
[procedure] (init! window install-callbacks?)

Initializes the backend and returns a context to be used in all GUI procedures. WINDOW must be a GLFW3 window and can be obtained with its (window) parameter after successful setup. If INSTALL-CALLBACKS? is #t, input and scrolling callbacks are set up, otherwise the created context can only be used for visualizing data.

init-font!
[procedure] (init-font! [context path size])

Initializes either the default font or a custom one if CONTEXT, PATH and SIZE are provided. The optional arguments need to be a previously obtained context, a string specifying the path to the font and a number for the font size.

new-frame
[procedure] (new-frame)

Starts a new frame to operate on.

render!
[procedure] (render!)

Commits all changes done to the current frame.

shutdown!
[procedure] (shutdown!)

Shuts down the backend. This must be called after exiting the main loop and before terminating GLFW3.

Basic types

Panels
make-panel
[procedure] (make-panel)

Creates and returns a panel.

panel-bounds
[procedure] (panel-bounds PANEL)

Returns a rectangle describing the panel's bounds.

Rects
make-rect
[procedure] (make-rect X Y W H)

Creates and returns a rectangle at the coordinates X and Y with the dimensions W and H. Note that all arguments can be floats.

rect-x / rect-x-set!
[procedure] (rect-x RECT)
[procedure] (rect-x-set! RECT X)
[setter] (set! (rect-x RECT) X)

Retrieves or sets the x coordinate of RECT.

rect-y / rect-y-set!
[procedure] (rect-y RECT)
[procedure] (rect-y-set! RECT Y)
[setter] (set! (rect-y RECT) Y)

Retrieves or sets the y coordinate of RECT.

rect-w / rect-w-set!
[procedure] (rect-w RECT)
[procedure] (rect-w-set! RECT W)
[setter] (set! (rect-w RECT) W)

Retrieves or sets the w coordinate of RECT.

rect-h / rect-h-set!
[procedure] (rect-h RECT)
[procedure] (rect-h-set! RECT H)
[setter] (set! (rect-h RECT) H)

Retrieves or sets the h coordinate of RECT.

Vectors
make-vec2
[procedure] (make-vec2 X Y)

Creates and returns a vector with the components X and Y. Note that all arguments can be floats.

vec2-x / vec2-x-set!
[procedure] (vec2-x VECTOR)
[procedure] (vec2-x-set! VECTOR X)
[setter] (set! (vec2-x VECTOR) X)

Retrieves or sets the x component of VECTOR.

vec2-y / vec2-y-set!
[procedure] (vec2-y VECTOR)
[procedure] (vec2-y-set! VECTOR Y)
[setter] (set! (vec2-y VECTOR) Y)

Retrieves or sets the y component of VECTOR.

Colors
make-color
[procedure] (make-color R G B A)

Creates and returns a color with the components R, G, B and A. All arguments must be integers between 0 and 255.

color-r / color-r-set!
[procedure] (color-r COLOR)
[procedure] (color-r-set! COLOR R)
[setter] (set! (color-r COLOR) R)

Retrieves or sets the red component of COLOR.

color-g / color-g-set!
[procedure] (color-g COLOR)
[procedure] (color-g-set! COLOR G)
[setter] (set! (color-g COLOR) G)

Retrieves or sets the green component of COLOR.

color-b / color-b-set!
[procedure] (color-b COLOR)
[procedure] (color-b-set! COLOR B)
[setter] (set! (color-b COLOR) B)

Retrieves or sets the blue component of COLOR.

color-a / color-a-set!
[procedure] (color-a COLOR)
[procedure] (color-a-set! COLOR A)
[setter] (set! (color-a COLOR) A)

Retrieves or sets the alpha component of COLOR.

Color helpers
rgb->color
[procedure] (rgb->color R G B)

Returns a color with the components R, G and B. All arguments must be integers between 0 and 255.

color->rgba-floats
[procedure] (color->rgba-floats COLOR)

Returns a list of red, green, blue and alpha components as floats between 0 and 1.

hsva->color
[procedure] (hsva->color H S V A)

Returns a color with the components H, S, V and A. All arguments must be integers between 0 and 255.

color->hsva-ints
[procedure] (color->hsva-ints COLOR)

Returns a list of hue, saturation, value and alpha components as integers between 0 and 255.

Window helpers

window-bounds
[procedure] (window-bounds CONTEXT)

Returns a rectangle describing the boundaries of the currently active window.

window-content-region
[procedure] (window-content-region CONTEXT)

Returns a rectangle describing the content region of the currently active window.

window-canvas
[procedure] (window-canvas CONTEXT)

Returns a canvas suitable for drawing on the currently active window.

window-closed?
[procedure] (window-closed? CONTEXT TITLE)

Returns #t if a window as identified by TITLE is no longer open, otherwise #f.

Layouts

Constrained positioning
layout-row-dynamic
[procedure] (layout-row-dynamic CONTEXT HEIGHT COLUMNS)

Sets up the following widgets to be positioned dynamically into rows. HEIGHT is the height of the row, COLUMNS the amount of widgets per row.

layout-row-static
[procedure] (layout-row-static CONTEXT HEIGHT ITEM-WIDTH COLUMNS)

Sets up the following widgets to be positioned statically into rows. HEIGHT is the height of the row, ITEM-WIDTH the width of each widget and COLUMNS the amount of widgets per row.

layout-row-begin
[procedure] (layout-row-begin CONTEXT DYNAMIC? HEIGHT COLUMNS)

Sets up the following widgets to be positioned dynamically or statically into a row, depending on DYNAMIC?. COLUMNS is the amount of widgets to be positioned.

layout-row-push
[procedure] (layout-row-push CONTEXT RATIO-OR-WIDTH)

Adds a widget to a row. If the positioning is dynamic, RATIO-OR-WIDTH is interpreted as ratio, otherwise as width in pixels.

layout-row-end
[procedure] (layout-row-end CONTEXT)

Terminates a layouted row.

layout-row
[procedure] (layout-row CONTEXT DYNAMIC? HEIGHT RATIOS-OR-WIDTHS)

Sets up the following widgets to be positioned dynamically or statically into a row, depending on DYNAMIC?. HEIGHT is the height of the row. RATIONS-OR-WIDTHS is a list of ratios or widths, depending on DYNAMIC?. This is equivalent to using layout-row-begin, layout-row-push and layout-row-end.

Free positioning
layout-space-begin
[procedure] (layout-space-begin CONTEXT DYNAMIC? HEIGHT WIDGET-COUNT)

Sets up the following widgets to be positioned freely. If DYNAMIC? is #t, widgets are scaled. HEIGHT is the total height of all widgets, WIDGET-COUNT the number of widgets.

layout-space-push
[procedure] (layout-space-push CONTEXT RECT)

Adds a freely positioned widget at RECT.

layout-space-end
[procedure] (layout-space-end CONTEXT)

Terminates free positioning.

Layout space helpers
layout-space-bounds
[procedure] (layout-space-bounds CONTEXT)

Returns a rectangle describing the inner bounds of the current widget.

layout-space-to-screen
[procedure] (layout-space-to-screen CONTEXT VECTOR)

Returns a copy of VECTOR with absolute coordinates.

layout-space-rect-to-screen
[procedure] (layout-space-rect-to-screen CONTEXT RECT)

Returns a copy of RECT with absolute coordinates.

layout-space-rect-to-local
[procedure] (layout-space-rect-to-local CONTEXT RECT)

Returns a copy of RECT with relative coordinates.

Misc
spacing
[procedure] (spacing CONTEXT COLUMNS)

Adds COLUMNS of spacing.

Blocks

Window block
window-begin
[procedure] (window-begin CONTEXT PANEL TITLE RECT FLAG-OR-FLAGS)

Starts a window block with TITLE as window title. RECT specifies the window boundaries. FLAG-OR-FLAGS is a symbol or a list of symbols, each of which must be one of (border border-header movable scalable closable minimizable dynamic no-scrollbar title). Returns #t if the window is visible.

window-end
[procedure] (window-end CONTEXT)

Terminates the window block. Must be used after starting a window block, regardless of whether the window is visible or not.

Group block
group-begin
[procedure] (group-begin CONTEXT PANEL TITLE FLAG-OR-FLAGS)

Starts a group block with TEXT as title. FLAG-OR-FLAGS is a symbol or list of symbols, each of which must be one of (border border-header movable scalable closable minimizable dynamic no-scrollbar title). Returns #t if the group is visible.

group-end
[procedure] (group-end CONTEXT)

Terminates the group block. May only be used when the group is visible.

Tree block
tree-push
[procedure] (tree-push CONTEXT TAB? TEXT MAXIMIZED?)

Starts a tree block with TEXT as label. If TAB? is #t, the tree header is highlighted specially. If MAXIMIZED? is #t, the tree starts expanded, otherwise minimized. Returns #t if the tree is expanded.

tree-pop
[procedure] (tree-pop CONTEXT)

Terminates the tree block. May only be used when the tree is expanded.

Chart block
chart-begin
[procedure] (chart-begin CONTEXT LINES? COUNT MIN-VALUE MAX-VALUE)

Starts a chart block. If LINES? is #t, draw lines, otherwise columns. COUNT is the number of data points, MIN-VALUE and MAX-VALUE the extremes. Returns #t if the chart is visible.

chart-begin-colored
[procedure] (chart-begin-colored CONTEXT LINES? COLOR HIGHLIGHT COUNT MIN-VALUE MAX-VALUE)

Starts a colored chart block. If LINES? if #t, draw lines, otherwise columns. COLOR is used for the chart itself and HIGHLIGHT for values hovered over. COUNT is the number of data points, MIN-VALUE and MAX-VALUE the extremes. Returns #t if the chart is visible.

chart-push
[procedure] (chart-push CONTEXT VALUE)

Adds VALUE to the data points in the chart. Returns either #f or a list of events for the data point, each of which is one of (hovering clicked).

chart-push-slot
[procedure] (chart-push-slot CONTEXT VALUE SLOT)

Adds VALUE to the data points in the chart SLOT. Returns either #f or a list of events for the data point, each of which is one of (hovering clicked).

chart-add-slot
[procedure] (chart-add-slot CONTEXT LINES? COUNT MIN-VALUE MAX-VALUE)

Adds an extra slot to the chart. Slots are integer values starting from 0. If LINES? is #t, draw lines, otherwise columns. COUNT is the number of data points, MIN-VALUE and MAX-VALUE the extremes.

chart-add-slot-colored
[procedure] (chart-add-slot-colored CONTEXT LINES? COLOR HIGHLIGHT COUNT MIN-VALUE MAX-VALUE)

Adds an extra colored slot to the chart. If LINES? is #t, draw lines, otherwise columns. COLOR is used for the chart itself and HIGHLIGHT for values hovered over. COUNT is the number of data points, MIN-VALUE and MAX-VALUE the extremes.

chart-end
[procedure] (chart-end CONTEXT)

Terminates a chart block.

[procedure] (popup-begin CONTEXT PANEL DYNAMIC? FLAG-OR-FLAGS RECT)

Starts a popup block. If DYNAMIC? is #t, the popup uses the dynamic flag. FLAG-OR-FLAGS is a symbol or list of symbols, each of which must be one of (border border-header movable scalable closable minimizable dynamic no-scrollbar title). RECT specifies the boundaries of the popup. Returns #t if the popup is visible.

[procedure] (popup-close CONTEXT)

Closes the popup. Must be used inside a popup block.

[procedure] (popup-end CONTEXT)

Terminates a popup block. May only be used if the popup is visible.

Combo block
combo-begin-label
[procedure] (combo-begin-label CONTEXT PANEL TEXT MAX-HEIGHT)

Starts a combo block with TEXT as displayed item. MAX-HEIGHT specifies the maximum height the opened combo block may occupy. Returns #t if the combo block is opened.

combo-begin-color
[procedure] (combo-begin-color CONTEXT PANEL COLOR MAX-HEIGHT)

Starts a combo block with COLOR as displayed item. MAX-HEIGHT specifies the maximum height the opened combo block may occupy. Returns #t if the combo block is opened.

combo-items-height
[procedure] (combo-items-height CONTEXT COUNT ITEM-HEIGHT)

Returns the height COUNT labels each of which is ITEM-HEIGHT tall would occupy. This includes padding and borders.

combo-item-label
[procedure] (combo-item-label CONTEXT TEXT ALIGNMENT)

Adds a combo item with TEXT as label. ALIGNMENT is a symbol and must be one of (left centered right).

combo-close
[procedure] (combo-close CONTEXT)

Closes the combo block. Must be used inside a combo block.

combo-end
[procedure] (combo-end CONTEXT)

Terminates a combo block. May only be used if the combo block is visible.

Contextual block
contextual-begin
[procedure] (contextual-begin CONTEXT PANEL FLAG-OR-FLAGS SIZE TRIGGER-BOUNDS)

Starts a context block. SIZE is a vector describing its size. TRIGGER-BOUNDS is a rectangle specifying where it can be triggered with a right mouse click. FLAG-OR-FLAGS is a symbol or list of symbols, each of which must be one of (border border-header movable scalable closable minimizable dynamic no-scrollbar title). Returns #t if the context block is visible.

contextual-item-label
[procedure] (contextual-item-label CONTEXT TEXT ALIGNMENT)

Adds a context item to the current context block with TEXT as label. ALIGNMENT is a symbol and must be one of (left centered right). Returns #t when clicked, otherwise #f.

contextual-end
[procedure] (contextual-end CONTEXT)

Terminates the context block. May only be used if the context block is visible.

[procedure] (menubar-begin CONTEXT)

Starts a menubar block.

[procedure] (menubar-end CONTEXT)

Terminates a menubar block.

[procedure] (menu-begin-label CONTEXT PANEL TEXT ALIGNMENT WIDTH)

Starts a menu block with TEXT as label. ALIGNMENT is a symbol and must be one of (left centered right). WIDTH specifies the menu width. Returns #t if the menu block is visible.

[procedure] (menu-item-label CONTEXT TEXT ALIGNMENT)

Adds a menu item to the current menu block with TEXT as label. ALIGNMENT is a symbol and must be one of (left centered right). Returns #t when clicked.

[procedure] (menu-end CONTEXT)

Terminates a menu block. May only be used if the menu block is visible.

Widgets

Label widget
label
[procedure] (label CONTEXT TEXT ALIGNMENT)

Creates a label widget with TEXT as label. ALIGNMENT controls how the text is aligned and must be one of (left centered right).

label-colored
[procedure] (label-colored CONTEXT TEXT ALIGNMENT COLOR)

Creates a colored label widget with TEXT as label painted with COLOR. ALIGNMENT controls how the text is aligned and must be one of (left centered right).

label-wrap
[procedure] (label-wrap CONTEXT TEXT)

Creates a label widget with wrapped TEXT as label.

Button widget
button-label
[procedure] (button-label CONTEXT TEXT [REPEATER?])

Creates a button widget with TEXT as label. If REPEATER? is #t, the button fires as long as it's clicked, otherwise only once. Returns #t if the button has been clicked.

button-color
[procedure] (button-color CONTEXT COLOR [REPEATER?])

Creates a color button widget with COLOR as value. If REPEATER? is #t, the button fires as long as it's clicked, otherwise only once. Returns #t if the button has been clicked.

button-symbol
[procedure] (button-symbol CONTEXT SYMBOL [REPEATER?])

Creates a button with SYMBOL on it. SYMBOL must be one of (none x underscore circle circle-filled rect rect-filled triangle-up triangle-down triangle-left triangle-right plus minus). If REPEATER? is #t, the button fires as long as it's clicked, otherwise only once. Returns #t if the button has been clicked.

button-symbol-label
[procedure] (button-symbol-label CONTEXT SYMBOL TEXT ALIGNMENT [REPEATER?])

Creates a button with SYMBOL and TEXT as label on it. SYMBOL must be one of (none x underscore circle circle-filled rect rect-filled triangle-up triangle-down triangle-left triangle-right plus minus). ALIGNMENT controls how the text is aligned and must be one of (left centered right). If REPEATER? is #t, the button fires as long as it's clicked, otherwise only once. Returns #t if the button has been clicked.

Checkbox widget
checkbox-label
[procedure] (checkbox-label CONTEXT TEXT ACTIVE?)

Creates a checkbox widget with TEXT as label and ACTIVE? as value. Returns the new value.

Option widget
option-label
[procedure] (option-label CONTEXT TEXT ACTIVE?)

Creates an option widget with TEXT as label and ACTIVE? as value. Returns the new value.

Selectable widget
selectable-label
[procedure] (selectable-label CONTEXT TEXT ALIGNMENT ACTIVE?)

Creates a selectable widget with TEXT as label and ACTIVE? as value. ALIGNMENT must be one of (left centered right). Returns two values, the new value and whether it is different from the old one.

Slider widget
slider-float
[procedure] (slider-float CONTEXT MIN VALUE MAX STEP)

Creates a slider widget with VALUE as initial float value and MIN and MAX as boundaries. STEP determines how much the value changes per step. Returns two values, the new float value and whether it is different from the old one.

slider-int
[procedure] (slider-int CONTEXT MIN VALUE MAX STEP)

Creates a slider widget with VALUE as initial integer value and MIN and MAX as boundaries. STEP determines how much the value changes per step. Returns two values, the new integer value and whether it is different from the old one.

Progressbar widget
progressbar
[procedure] (progressbar CONTEXT VALUE MAX MODIFIABLE?)

Creates a progressbar widget with VALUE as initial value. MAX specifies the maximum value that can be displayed. If MODIFIABLE? is #t, the value of the widget can be changed interactively. Returns two values, the new value and whether it is different from the old one.

Color picker widget
color-picker
[procedure] (color-picker CONTEXT COLOR [RGB?])

Creates a color picker widget with COLOR as initially picked color. If the optional RGB? argument is #t, use a RGB instead of a RGBA picker. Returns the new color.

Property widget
property-float
[procedure] (property-float CONTEXT TEXT MIN VALUE MAX STEP PIXEL-STEP)

Creates a property widget with VALUE as initial float value and MIN and MAX as boundaries. TEXT specifies the widget label, STEP controls the change in value for each step, PIXEL-STEP the travel in pixels necessary to change the widget value when dragging. Returns the new float value.

property-int
[procedure] (property-int CONTEXT TEXT MIN VALUE MAX STEP PIXEL-STEP)

Creates a property widget with VALUE as initial integer value and MIN and MAX as boundaries. TEXT specifies the widget label, STEP controls the change in value for each step, PIXEL-STEP the travel in pixels necessary to change the widget value when dragging. Returns the new integer value.

Editor widget
edit-string
[procedure] (edit-string CONTEXT EDIT-FLAG-OR-FLAGS TEXT MAX [FILTER-FLAG])

Creates an text editing widget with TEXT for its initial contents and a maximum length of MAX. EDIT-FLAG-OR-FLAGS must be a symbol or list of symbols specifying the general widget behaviour, with the permitted symbols being (simple field box editor) for predefined behavior and (default read-only auto-select sig-enter allow-tab no-cursor selectable clipboard ctrl-enter-newline no-horizontal-scroll always-insert-mode multiline) for finer-grained control over it. FILTER-FLAG restricts chars that can be entered and must be one of (default ascii float decimal hex oct binary). Returns two values, the new text and a list of edit events, each of which are one of (active inactive activated deactivated committed).

Tooltip

tooltip
[procedure] (tooltip CONTEXT TEXT)

Creates a tooltip with TEXT as content.

Context

context-input
[procedure] (context-input CONTEXT)

Returns the current input state associated with CONTEXT.

context-style
[procedure] (context-style CONTEXT)

Returns the current style associated with CONTEXT.

Canvas

stroke-line
[procedure] (stroke-line CANVAS X0 Y0 X1 Y1 LINE-THICKNESS COLOR)

Draw a line between the coordinates X0, Y0, X1, Y1 with the width LINE-THICKNESS and COLOR on CANVAS.

stroke-curve
[procedure] (stroke-curve CANVAS AX AY CTRL0X CTRL0Y CTRL1X CTRL1Y BX BY LINE-THICKNESS COLOR)

Draw a curve between the coordinates AX, AY, BX, BY with control points CTRL0X, CTRL0Y, CTRL1X, CTRL1Y, the width LINE-THICKNESS and COLOR on CANVAS.

fill-circle
[procedure] (fill-circle CANVAS RECT COLOR)

Draw a filled circle in RECT with COLOR on CANVAS.

Styling

style-window-border
[procedure] (style-window-border STYLE)

Returns the window border width associated with STYLE.

style-window-header-align-set!
[procedure] (style-window-header-align-set! STYLE RIGHT?)

Sets the window header alignment for STYLE. If RIGHT? is #t, it is set to right-aligned, otherwise left-aligned.

Input

input-mouse
[procedure] (input-mouse INPUT)

Returns the mouse state for INPUT.

mouse-delta
[procedure] (mouse-delta MOUSE)

Returns a vector describing the relative change in pixels between the current and last mouse position for MOUSE.

mouse-position
[procedure] (mouse-position MOUSE)

Returns a vector describing the current mouse position in pixels for MOUSE.

input-mouse-click-down-in-rect?
[procedure] (input-mouse-click-down-in-rect? INPUT BUTTON RECT DOWN?)

Returns #t if the BUTTON has been clicked in RECT for INPUT and its clicked state is equal to the DOWN? argument. BUTTON must be one of (left middle right).

input-mouse-hovering-in-rect?
[procedure] (input-mouse-hovering-in-rect? INPUT RECT)

Returns #t if the mouse has been hovering in RECT for INPUT, otherwise #f.

input-mouse-previously-hovering-in-rect?
[procedure] (input-mouse-previously-hovering-in-rect? INPUT RECT)

Returns #t if the mouse has been hovering in the previous frame in RECT for INPUT, otherwise #f.

input-mouse-clicked?
[procedure] (input-mouse-clicked? INPUT BUTTON RECT)

Returns #t if the BUTTON has been clicked in RECT for INPUT, otherwise #f. BUTTON must be one of (left middle right).

input-mouse-down?
[procedure] (input-mouse-down? INPUT BUTTON)

Returns #t if the BUTTON is pressed down for INPUT, otherwise #f. BUTTON must be one of (left middle right).

input-mouse-released?
[procedure] (input-mouse-released? INPUT BUTTON)

Returns #t if the BUTTON is released for INPUT, otherwise #f. BUTTON must be one of (left middle right).

Examples

The following example requires the glfw3 and opengl-glew eggs.

(use (prefix glfw3 glfw:)
     (prefix opengl-glew gl:)
     (prefix nuklear nk:))

(require-library nuklear-glfw-opengl2)
(import (prefix nuklear-glfw-opengl2 backend:))

(define width 250)
(define height 150)

(glfw:init)
(glfw:make-window width height "Hello World")
(glfw:make-context-current (glfw:window))
(set!-values (width height) (glfw:get-window-size (glfw:window)))

(define context (backend:init! (glfw:window) #t))
(backend:init-font!)

(define quit? #f)
(define show-greeting? #f)

(define layout (nk:make-panel))
(define popup-layout (nk:make-panel))

(let loop ()
  (when (and (not (glfw:window-should-close (glfw:window))) (not quit?))
    (glfw:poll-events)
    (backend:new-frame)

    (when (nk:window-begin context layout "Hello World!"
                           (nk:make-rect 10 10 192 100)
                           '(border no-scrollbar movable))
      (nk:layout-row-dynamic context 30 2)
      (when (nk:button-label context "Click Me!")
        (printf "Yay\n")
        (set! show-greeting? #t))
      (when (nk:button-label context "Quit")
        (set! quit? #t))

      (when show-greeting?
        (if (nk:popup-begin context popup-layout #f "Greeting" '(dynamic)
                            (nk:make-rect 15 50 200 150))
            (begin
              (nk:layout-row-dynamic context 25 1)
              (nk:label context "Hello World!" 'centered)
              (nk:layout-row-dynamic context 25 1)
              (when (nk:button-label context "OK")
                (set! show-greeting? #f)
                (nk:popup-close context))
              (nk:popup-end context))
            (set! show-greeting? #f))))
    (nk:window-end context)

    (let-values (((width height) (glfw:get-window-size (glfw:window))))
      (gl:viewport 0 0 width height))
    (gl:clear gl:+color-buffer-bit+)
    (gl:clear-color (/ 28 255) (/ 48 255) (/ 62 255) 0)
    (backend:render!)
    (glfw:swap-buffers (glfw:window))
    (loop)))

(backend:shutdown!)
(glfw:terminate)

Further examples can be found in the repository. Additionally to the previously mentioned eggs, format is required to run the calculator, overview and node editor demos.

Notes

License

This software is dual-licensed to the public domain and under the following license: you are granted a perpetual, irrevocable license to copy, modify, publish and distribute its files as you see fit.

Version history

0.1