Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/nuklear|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. == nuklear [[toc:]] === Introduction This egg provides an incomplete set of bindings to the [[https://github.com/vurtun/nuklear|nuklear]] immediate mode GUI library. === Author Vasilij Schneidermann === Repository [[https://depp.brause.cc/nuklear]] === Current state of the bindings ==== Backends * {{glfw-opengl2}} ==== API Support Everything required for [[https://github.com/vurtun/nuklear/tree/master/demo/glfw_opengl2|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: * GLFW3 * GL * GLU 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> <parameter>(anti-alias? FLAG)</parameter> Controls whether anti-aliasing is enabled, defaulting to {{#t}}. ====== max-vertex-buffer <parameter>(max-vertex-buffer)</parameter> <parameter>(max-vertex-buffer N)</parameter> Controls the maximum amount of vertices, defaulting to 512*1024. ====== max-element-buffer <parameter>(max-element-buffer)</parameter> <parameter>(max-element-buffer N)</parameter> Controls the maximum amount of elements, defaulting to 128*1024. ====== init! <procedure>(init! window install-callbacks?)</procedure> 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])</procedure> 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)</procedure> Starts a new frame to operate on. ====== render! <procedure>(render!)</procedure> Commits all changes done to the current frame. ====== shutdown! <procedure>(shutdown!)</procedure> 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)</procedure> Creates and returns a panel. ====== panel-bounds <procedure>(panel-bounds PANEL)</procedure> Returns a rectangle describing the panel's bounds. ===== Rects ====== make-rect <procedure>(make-rect X Y W H)</procedure> 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> <procedure>(rect-x-set! RECT X)</procedure> <setter>(set! (rect-x RECT) X)</setter> Retrieves or sets the x coordinate of {{RECT}}. ====== rect-y / rect-y-set! <procedure>(rect-y RECT)</procedure> <procedure>(rect-y-set! RECT Y)</procedure> <setter>(set! (rect-y RECT) Y)</setter> Retrieves or sets the y coordinate of {{RECT}}. ====== rect-w / rect-w-set! <procedure>(rect-w RECT)</procedure> <procedure>(rect-w-set! RECT W)</procedure> <setter>(set! (rect-w RECT) W)</setter> Retrieves or sets the w coordinate of {{RECT}}. ====== rect-h / rect-h-set! <procedure>(rect-h RECT)</procedure> <procedure>(rect-h-set! RECT H)</procedure> <setter>(set! (rect-h RECT) H)</setter> Retrieves or sets the h coordinate of {{RECT}}. ===== Vectors ====== make-vec2 <procedure>(make-vec2 X Y)</procedure> 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> <procedure>(vec2-x-set! VECTOR X)</procedure> <setter>(set! (vec2-x VECTOR) X)</setter> Retrieves or sets the x component of {{VECTOR}}. ====== vec2-y / vec2-y-set! <procedure>(vec2-y VECTOR)</procedure> <procedure>(vec2-y-set! VECTOR Y)</procedure> <setter>(set! (vec2-y VECTOR) Y)</setter> Retrieves or sets the y component of {{VECTOR}}. ===== Colors ====== make-color <procedure>(make-color R G B A)</procedure> 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> <procedure>(color-r-set! COLOR R)</procedure> <setter>(set! (color-r COLOR) R)</setter> Retrieves or sets the red component of {{COLOR}}. ====== color-g / color-g-set! <procedure>(color-g COLOR)</procedure> <procedure>(color-g-set! COLOR G)</procedure> <setter>(set! (color-g COLOR) G)</setter> Retrieves or sets the green component of {{COLOR}}. ====== color-b / color-b-set! <procedure>(color-b COLOR)</procedure> <procedure>(color-b-set! COLOR B)</procedure> <setter>(set! (color-b COLOR) B)</setter> Retrieves or sets the blue component of {{COLOR}}. ====== color-a / color-a-set! <procedure>(color-a COLOR)</procedure> <procedure>(color-a-set! COLOR A)</procedure> <setter>(set! (color-a COLOR) A)</setter> Retrieves or sets the alpha component of {{COLOR}}. ===== Color helpers ====== rgb->color <procedure>(rgb->color R G B)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> Returns a list of hue, saturation, value and alpha components as integers between 0 and 255. ==== Window helpers ===== window-bounds <procedure>(window-bounds CONTEXT)</procedure> Returns a rectangle describing the boundaries of the currently active window. ===== window-content-region <procedure>(window-content-region CONTEXT)</procedure> Returns a rectangle describing the content region of the currently active window. ===== window-canvas <procedure>(window-canvas CONTEXT)</procedure> Returns a canvas suitable for drawing on the currently active window. ===== window-closed? <procedure>(window-closed? CONTEXT TITLE)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> Terminates a layouted row. ====== layout-row <procedure>(layout-row CONTEXT DYNAMIC? HEIGHT RATIOS-OR-WIDTHS)</procedure> 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)</procedure> 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)</procedure> Adds a freely positioned widget at {{RECT}}. ====== layout-space-end <procedure>(layout-space-end CONTEXT)</procedure> Terminates free positioning. ===== Layout space helpers ====== layout-space-bounds <procedure>(layout-space-bounds CONTEXT)</procedure> Returns a rectangle describing the inner bounds of the current widget. ====== layout-space-to-screen <procedure>(layout-space-to-screen CONTEXT VECTOR)</procedure> Returns a copy of {{VECTOR}} with absolute coordinates. ====== layout-space-rect-to-screen <procedure>(layout-space-rect-to-screen CONTEXT RECT)</procedure> Returns a copy of {{RECT}} with absolute coordinates. ====== layout-space-rect-to-local <procedure>(layout-space-rect-to-local CONTEXT RECT)</procedure> Returns a copy of {{RECT}} with relative coordinates. ===== Misc ====== spacing <procedure>(spacing CONTEXT COLUMNS)</procedure> Adds {{COLUMNS}} of spacing. ==== Blocks ===== Window block ====== window-begin <procedure>(window-begin CONTEXT PANEL TITLE RECT FLAG-OR-FLAGS)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> Terminates the group block. May only be used when the group is visible. ===== Tree block ====== tree-push <procedure>(tree-push CONTEXT TAB? TEXT MAXIMIZED?)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> Terminates a chart block. ===== Popup block ====== popup-begin <procedure>(popup-begin CONTEXT PANEL DYNAMIC? FLAG-OR-FLAGS RECT)</procedure> 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. ====== popup-close <procedure>(popup-close CONTEXT)</procedure> Closes the popup. Must be used inside a popup block. ====== popup-end <procedure>(popup-end CONTEXT)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> Closes the combo block. Must be used inside a combo block. ====== combo-end <procedure>(combo-end CONTEXT)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> Terminates the context block. May only be used if the context block is visible. ===== Menubar block ====== menubar-begin <procedure>(menubar-begin CONTEXT)</procedure> Starts a menubar block. ====== menubar-end <procedure>(menubar-end CONTEXT)</procedure> Terminates a menubar block. ===== Menu block ====== menu-begin-label <procedure>(menu-begin-label CONTEXT PANEL TEXT ALIGNMENT WIDTH)</procedure> 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. ====== menu-item-label <procedure>(menu-item-label CONTEXT TEXT ALIGNMENT)</procedure> 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. ====== menu-end <procedure>(menu-end CONTEXT)</procedure> Terminates a menu block. May only be used if the menu block is visible. ==== Widgets ===== Label widget ====== label <procedure>(label CONTEXT TEXT ALIGNMENT)</procedure> 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)</procedure> 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)</procedure> Creates a label widget with wrapped {{TEXT}} as label. ===== Button widget ====== button-label <procedure>(button-label CONTEXT TEXT [REPEATER?])</procedure> 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?])</procedure> 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?])</procedure> 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?])</procedure> 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?)</procedure> 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?)</procedure> 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?)</procedure> 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)</procedure> 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)</procedure> 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?)</procedure> 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?])</procedure> 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)</procedure> 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)</procedure> 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])</procedure> 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)</procedure> Creates a tooltip with {{TEXT}} as content. ==== Context ===== context-input <procedure>(context-input CONTEXT)</procedure> Returns the current input state associated with {{CONTEXT}}. ===== context-style <procedure>(context-style CONTEXT)</procedure> Returns the current style associated with {{CONTEXT}}. ==== Canvas ===== stroke-line <procedure>(stroke-line CANVAS X0 Y0 X1 Y1 LINE-THICKNESS COLOR)</procedure> 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)</procedure> 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)</procedure> Draw a filled circle in {{RECT}} with {{COLOR}} on {{CANVAS}}. ==== Styling ===== style-window-border <procedure>(style-window-border STYLE)</procedure> Returns the window border width associated with {{STYLE}}. ===== style-window-header-align-set! <procedure>(style-window-header-align-set! STYLE RIGHT?)</procedure> 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)</procedure> Returns the mouse state for {{INPUT}}. ===== mouse-delta <procedure>(mouse-delta MOUSE)</procedure> Returns a vector describing the relative change in pixels between the current and last mouse position for {{MOUSE}}. ===== mouse-position <procedure>(mouse-position MOUSE)</procedure> 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?)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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)</procedure> 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. <enscript highlight="scheme"> (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) </enscript> Further examples can be found [[https://depp.brause.cc/nuklear/examples|in the repository]]. Additionally to the previously mentioned eggs, [[format]] is required to run the calculator, overview and node editor demos. === Notes * If you wish to use a different font than the default, set it at init time. Loading multiple fonts and switching the active one is currently unsupported. * You will need to write your own main loop using eggs that match the chosen backend and the backend API. As only the {{glfw-opengl2}} backend is supported for now, that would be the [[glfw3]] and [[opengl-glew]] eggs. Each example contains a full implementation you can reuse. * As backends can be platform-specific and are built at installation time, their modules aren't automatically loaded by the egg. Therefore you'll need to use {{require-library}} and {{import}} to load one. * Widgets typically take an input value and return an output value. Therefore you will need to use global variables, parameters or named-let initializers in the main loop for managing them. Some widgets return multiple values with the output value first, use {{receive}} to access the other values. * Block starters (for windows, groups, combo boxes, etc.) typically return a boolean to indicate whether they're active. If this is the case, then one can draw widgets inside them and finally terminate the block with the matching procedure. * Layouts must be used inside blocks, otherwise no widgets will be drawn. * Bind the context and panels to top-level identifiers, otherwise they'll be gone by the next GC and make your application segfault. === 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 * Initial release
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 2 to 24?