├── image ├── enums.v └── image.v ├── .gitignore ├── _docs ├── favicon.ico ├── mstile-70x70.png ├── favicon-16x16.png ├── favicon-32x32.png ├── mstile-144x144.png ├── mstile-150x150.png ├── mstile-310x150.png ├── mstile-310x310.png ├── apple-touch-icon.png ├── android-chrome-192x192.png ├── android-chrome-512x512.png ├── dark-mode.js ├── browserconfig.xml ├── site.webmanifest ├── safari-pinned-tab.svg ├── normalize.css ├── viup.browser.html ├── viup.image.html ├── viup.gl.html ├── doc.js ├── doc.css ├── search_index.js └── index.html ├── winmanifest ├── v-logo.ico ├── manifest.syso ├── resources.rc └── ui.manifest ├── examples ├── gl │ ├── manifest.syso │ └── gl.v └── gallery │ ├── v-logo.png │ ├── manifest.syso │ ├── gallery_linux.png │ ├── gallery_windows.png │ └── gallery.v ├── v.mod ├── headers ├── iupluagl.h ├── iupluaim.h ├── iuplua_plot.h ├── iupluaole.h ├── iupluatuio.h ├── iuplua_mglplot.h ├── iupluacontrols.h ├── iupluafiledlg.h ├── iuptuio.h ├── iuplua_scintilla.h ├── iupluaglcontrols.h ├── iupdraw_cd.h ├── iupfiledlg.h ├── iupluascripterdlg.h ├── iup_scintilla.h ├── iupcontrols.h ├── iupim.h ├── iupole.h ├── iupweb.h ├── iupluaweb.h ├── iupglcontrols.h ├── iuplua.h ├── iupdraw.h ├── iup_varg.h ├── iup_export.h ├── iupgl.h ├── iup_plot.h ├── iup_mglplot.h ├── iup_config.h └── iupcbs.h ├── browser └── browser.v ├── keys.v ├── CHANGELOG.md ├── LICENSE ├── gl └── gl.v ├── color.v ├── font.v ├── viup.v ├── dialog.v ├── enums.v ├── attributes.v ├── control.v ├── controls.v ├── containers.v ├── README.md └── callbacks.v /image/enums.v: -------------------------------------------------------------------------------- 1 | module image 2 | 3 | // 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | 3 | *.dll 4 | *.exe 5 | -------------------------------------------------------------------------------- /_docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/_docs/favicon.ico -------------------------------------------------------------------------------- /_docs/mstile-70x70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/_docs/mstile-70x70.png -------------------------------------------------------------------------------- /winmanifest/v-logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/winmanifest/v-logo.ico -------------------------------------------------------------------------------- /_docs/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/_docs/favicon-16x16.png -------------------------------------------------------------------------------- /_docs/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/_docs/favicon-32x32.png -------------------------------------------------------------------------------- /_docs/mstile-144x144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/_docs/mstile-144x144.png -------------------------------------------------------------------------------- /_docs/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/_docs/mstile-150x150.png -------------------------------------------------------------------------------- /_docs/mstile-310x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/_docs/mstile-310x150.png -------------------------------------------------------------------------------- /_docs/mstile-310x310.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/_docs/mstile-310x310.png -------------------------------------------------------------------------------- /examples/gl/manifest.syso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/examples/gl/manifest.syso -------------------------------------------------------------------------------- /winmanifest/manifest.syso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/winmanifest/manifest.syso -------------------------------------------------------------------------------- /_docs/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/_docs/apple-touch-icon.png -------------------------------------------------------------------------------- /examples/gallery/v-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/examples/gallery/v-logo.png -------------------------------------------------------------------------------- /examples/gallery/manifest.syso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/examples/gallery/manifest.syso -------------------------------------------------------------------------------- /_docs/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/_docs/android-chrome-192x192.png -------------------------------------------------------------------------------- /_docs/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/_docs/android-chrome-512x512.png -------------------------------------------------------------------------------- /examples/gallery/gallery_linux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/examples/gallery/gallery_linux.png -------------------------------------------------------------------------------- /examples/gallery/gallery_windows.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kjlaw89/viup/HEAD/examples/gallery/gallery_windows.png -------------------------------------------------------------------------------- /v.mod: -------------------------------------------------------------------------------- 1 | Module { 2 | name: 'vuip', 3 | description: 'A V wrapper library for IUP', 4 | version: '0.5.0', 5 | dependencies: [] 6 | } -------------------------------------------------------------------------------- /_docs/dark-mode.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var html = document.getElementsByTagName('html')[0]; 3 | if (localStorage.getItem('dark-mode') === 'true') { 4 | html.classList.add('dark'); 5 | } 6 | })(); 7 | -------------------------------------------------------------------------------- /_docs/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #da532c 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /headers/iupluagl.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Binding of iupglcanvas to Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUAGL_H 8 | #define __IUPLUAGL_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int iupgllua_open (lua_State * L); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /headers/iupluaim.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Bindig of iupim functions to Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUAIM_H 8 | #define __IUPLUAIM_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int iupimlua_open(lua_State * L); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /headers/iuplua_plot.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief iup_plot Binding for Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUA_PLOT_H 8 | #define __IUPLUA_PLOT_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int iup_plotlua_open (lua_State * L); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /headers/iupluaole.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Binding of iupolecontrol to Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUAOLE_H 8 | #define __IUPLUAOLE_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int iupolelua_open (lua_State * L); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /headers/iupluatuio.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Binding of iuptuio to Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUATUIO_H 8 | #define __IUPLUATUIO_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int iuptuiolua_open (lua_State * L); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /headers/iuplua_mglplot.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief IupMglPlot Binding for Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUA_MGLPLOT_H 8 | #define __IUPLUA_MGLPLOT_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int iup_mglplotlua_open (lua_State * L); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /headers/iupluacontrols.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief iupcontrols Binding for Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUACONTROLS_H 8 | #define __IUPLUACONTROLS_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int iupcontrolslua_open (lua_State * L); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /headers/iupluafiledlg.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Binding of new iupfiledlg to Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUAFILEDLG_H 8 | #define __IUPLUAFILEDLG_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int iupfiledlglua_open (lua_State * L); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /headers/iuptuio.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief IupTuioClient control 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPTUIO_H 8 | #define __IUPTUIO_H 9 | 10 | #if defined(__cplusplus) 11 | extern "C" { 12 | #endif 13 | 14 | int IupTuioOpen(void); 15 | Ihandle* IupTuioClient(int port); 16 | 17 | #if defined(__cplusplus) 18 | } 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /headers/iuplua_scintilla.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief IupScintilla Binding for Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUA_SCINTILLA_H 8 | #define __IUPLUA_SCINTILLA_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int iup_scintillalua_open (lua_State * L); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /headers/iupluaglcontrols.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief iupglcontrols Binding for Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUAGLCONTROLS_H 8 | #define __IUPLUAGLCONTROLS_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | int iupglcontrolslua_open (lua_State * L); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /browser/browser.v: -------------------------------------------------------------------------------- 1 | module browser 2 | 3 | import viup 4 | 5 | #flag -L . 6 | #flag windows -liupole 7 | #flag linux -lwebkit2gtk-4.0 8 | #flag linux -lgio-2.0 9 | #include "iupweb.h" 10 | 11 | fn C.IupWebBrowser() voidptr 12 | 13 | pub fn new(attrs ...string) &viup.Control { 14 | control := &viup.Control(C.IupWebBrowser()) 15 | control.set_attrs(...attrs) 16 | return control 17 | } 18 | -------------------------------------------------------------------------------- /headers/iupdraw_cd.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief IupDraw CD driver 3 | * 4 | * See Copyright Notice in iup.h 5 | */ 6 | 7 | #ifndef __CD_IUPDRAW_H 8 | #define __CD_IUPDRAW_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | cdContext* cdContextIupDraw(void); 15 | #define CD_IUPDRAW cdContextIupDraw() 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #endif /* ifndef __CD_IUPDRAW_ */ 22 | -------------------------------------------------------------------------------- /headers/iupfiledlg.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief New FileDlg (Windows Only). 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPFILEDLG_H 8 | #define __IUPFILEDLG_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* the only exported function, 15 | once called it will replace regular IupFileDlg */ 16 | 17 | int IupNewFileDlgOpen(void); 18 | 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /headers/iupluascripterdlg.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief IupLuaScripterDlg dialog and Lua binding 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUASCRIPTERDLG_H 8 | #define __IUPLUASCRIPTERDLG_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void IupLuaScripterDlgOpen(lua_State * L); 15 | 16 | Ihandle* IupLuaScripterDlg(void); 17 | 18 | /* Lua binding */ 19 | int iupluascripterdlglua_open(lua_State * L); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /keys.v: -------------------------------------------------------------------------------- 1 | module viup 2 | 3 | pub fn is_shift(key Key) bool { 4 | return int(key) & 0x10000000 > 0 || (int(key) >= 65 && int(key) <= 90) 5 | } 6 | 7 | pub fn is_ctrl(key Key) bool { 8 | return int(key) & 0x20000000 > 0 9 | } 10 | 11 | pub fn is_alt(key Key) bool { 12 | return int(key) & 0x40000000 > 0 13 | } 14 | 15 | pub fn is_sys(key Key) bool { 16 | return int(key) & 0x80000000 > 0 17 | } 18 | 19 | pub fn get_key(key Key) Key { 20 | return Key(int(key) & ~(0x10000000 | 0x20000000 | 0x40000000 | 0x80000000)) 21 | } 22 | -------------------------------------------------------------------------------- /_docs/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "short_name": "", 4 | "icons": [ 5 | { 6 | "src": "/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "theme_color": "#ffffff", 17 | "background_color": "#ffffff", 18 | "display": "standalone" 19 | } 20 | -------------------------------------------------------------------------------- /headers/iup_scintilla.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Scintilla control. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUP_SCINTILLA_H 8 | #define __IUP_SCINTILLA_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | 15 | void IupScintillaOpen(void); 16 | 17 | Ihandle *IupScintilla(void); 18 | Ihandle *IupScintillaDlg(void); 19 | 20 | #ifdef SCINTILLA_H 21 | sptr_t IupScintillaSendMessage(Ihandle* ih, unsigned int iMessage, uptr_t wParam, sptr_t lParam); 22 | #endif 23 | 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## VUIP 0.5.0 2 | *27 Feb 2021* 3 | 4 | - Updated to run on latest Vlang version 5 | - Updated callbacks to be individual methods 6 | - vfmt all files 7 | - Added Dialog struct with Dialog-specific methods 8 | - Generated `_docs` folder 9 | - Added basic support for `autofree`. Checkout notes in README for potential issues 10 | - Manifest automated-import currently broken. Review notes in README for how to add 11 | 12 | ## VIUP 0.4.0 13 | *27 Oct 2020* 14 | 15 | - Initial Release 16 | 17 | - Basic Windows & Linux support 18 | - All basic controls 19 | - Image support 20 | - Containers & Dialogs 21 | - GL Rendering (no controls) -------------------------------------------------------------------------------- /headers/iupcontrols.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief initializes dial, gauge, colorbrowser, colorbar controls. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPCONTROLS_H 8 | #define __IUPCONTROLS_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | 15 | int IupControlsOpen(void); 16 | 17 | Ihandle* IupCells(void); 18 | Ihandle* IupMatrix(const char *action); 19 | Ihandle* IupMatrixList(void); 20 | Ihandle* IupMatrixEx(void); 21 | 22 | /* available only when linking with "iupluamatrix" */ 23 | void IupMatrixSetFormula(Ihandle* ih, int col, const char* formula, const char* init); 24 | void IupMatrixSetDynamic(Ihandle* ih, const char* init); 25 | 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /headers/iupim.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Utilities using IM 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPIM_H 8 | #define __IUPIM_H 9 | 10 | #if defined(__cplusplus) 11 | extern "C" { 12 | #endif 13 | 14 | 15 | void IupImOpen(void); /* optional */ 16 | 17 | Ihandle* IupLoadImage(const char* filename); 18 | int IupSaveImage(Ihandle* ih, const char* filename, const char* format); 19 | 20 | Ihandle* IupLoadAnimation(const char* filename); 21 | Ihandle* IupLoadAnimationFrames(const char** filename_list, int file_count); 22 | 23 | #ifdef __IM_IMAGE_H 24 | imImage* IupGetNativeHandleImage(void* handle); 25 | void* IupGetImageNativeHandle(const imImage* image); 26 | 27 | Ihandle* IupImageFromImImage(const imImage* image); 28 | imImage* IupImageToImImage(Ihandle* iup_image); 29 | #endif 30 | 31 | 32 | #if defined(__cplusplus) 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /examples/gl/gl.v: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | import viup 4 | import viup.gl 5 | 6 | #flag linux -lGL 7 | #flag windows -lopengl32 8 | #include 9 | 10 | fn C.glClear(int) 11 | fn C.glBegin(int) 12 | fn C.glColor3f(f32, f32, f32) 13 | fn C.glVertex3f(f32, f32, f32) 14 | fn C.glEnd() 15 | fn C.glFlush() 16 | 17 | fn main() { 18 | canvas := gl.create_context().set_handle('context').on_draw(redraw) 19 | 20 | viup.dialog(viup.hbox([ 21 | viup.fill(), 22 | canvas, 23 | viup.fill(), 24 | ]), 'title=GL Example', 'rastersize=640x480').show() 25 | 26 | viup.main_loop() 27 | viup.close() 28 | } 29 | 30 | fn redraw(control &viup.Control, x f32, y f32) viup.FuncResult { 31 | gl.make_current(control) 32 | 33 | C.glClear(C.GL_COLOR_BUFFER_BIT) 34 | 35 | C.glBegin(C.GL_POLYGON) 36 | C.glColor3f(1, 0, 0) 37 | C.glVertex3f(-0.6, -0.75, 0.5) 38 | C.glColor3f(0, 1, 0) 39 | C.glVertex3f(0.6, -0.75, 0) 40 | C.glColor3f(0, 0, 1) 41 | C.glVertex3f(0, 0.75, 0) 42 | C.glEnd() 43 | 44 | gl.swap(control) 45 | 46 | return .cont 47 | } 48 | -------------------------------------------------------------------------------- /headers/iupole.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Ole control. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPOLE_H 8 | #define __IUPOLE_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #ifndef DOXYGEN_SHOULD_IGNORE_THIS 15 | /** @cond DOXYGEN_SHOULD_IGNORE_THIS */ 16 | #ifndef IUPOLE_API 17 | #ifdef IUPOLE_BUILD_LIBRARY 18 | #ifdef __EMSCRIPTEN__ 19 | #include 20 | #define IUPOLE_API EMSCRIPTEN_KEEPALIVE 21 | #elif WIN32 22 | #define IUPOLE_API __declspec(dllexport) 23 | #elif defined(__GNUC__) && __GNUC__ >= 4 24 | #define IUPOLE_API __attribute__ ((visibility("default"))) 25 | #else 26 | #define IUPOLE_API 27 | #endif 28 | #else 29 | #define IUPOLE_API 30 | #endif /* IUP_BUILD_LIBRARY */ 31 | #endif /* IUPOLE_API */ 32 | /** @endcond DOXYGEN_SHOULD_IGNORE_THIS */ 33 | #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ 34 | 35 | 36 | IUPOLE_API Ihandle *IupOleControl(const char* progid); 37 | 38 | IUPOLE_API int IupOleControlOpen(void); 39 | 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /headers/iupweb.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Web control. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPWEB_H 8 | #define __IUPWEB_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #ifndef DOXYGEN_SHOULD_IGNORE_THIS 15 | /** @cond DOXYGEN_SHOULD_IGNORE_THIS */ 16 | #ifndef IUPWEB_API 17 | #ifdef IUPWEB_BUILD_LIBRARY 18 | #ifdef __EMSCRIPTEN__ 19 | #include 20 | #define IUPWEB_API EMSCRIPTEN_KEEPALIVE 21 | #elif WIN32 22 | #define IUPWEB_API __declspec(dllexport) 23 | #elif defined(__GNUC__) && __GNUC__ >= 4 24 | #define IUPWEB_API __attribute__ ((visibility("default"))) 25 | #else 26 | #define IUPWEB_API 27 | #endif 28 | #else 29 | #define IUPWEB_API 30 | #endif /* IUP_BUILD_LIBRARY */ 31 | #endif /* IUPWEB_API */ 32 | /** @endcond DOXYGEN_SHOULD_IGNORE_THIS */ 33 | #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ 34 | 35 | 36 | IUPWEB_API int IupWebBrowserOpen(void); 37 | 38 | IUPWEB_API Ihandle *IupWebBrowser(void); 39 | 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /headers/iupluaweb.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Binding of iupwebbrowser to Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUAWEB_H 8 | #define __IUPLUAWEB_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #ifndef DOXYGEN_SHOULD_IGNORE_THIS 15 | /** @cond DOXYGEN_SHOULD_IGNORE_THIS */ 16 | #ifndef IUPLUAWEB_API 17 | #ifdef IUPLUAWEB_BUILD_LIBRARY 18 | #ifdef __EMSCRIPTEN__ 19 | #include 20 | #define IUPLUAWEB_API EMSCRIPTEN_KEEPALIVE 21 | #elif WIN32 22 | #define IUPLUAWEB_API __declspec(dllexport) 23 | #elif defined(__GNUC__) && __GNUC__ >= 4 24 | #define IUPLUAWEB_API __attribute__ ((visibility("default"))) 25 | #else 26 | #define IUPLUAWEB_API 27 | #endif 28 | #else 29 | #define IUPLUAWEB_API 30 | #endif /* IUPLUAWEB_BUILD_LIBRARY */ 31 | #endif /* IUPLUAWEB_API */ 32 | /** @endcond DOXYGEN_SHOULD_IGNORE_THIS */ 33 | #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ 34 | 35 | 36 | IUPLUAWEB_API int iupweblua_open (lua_State * L); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 KJ Lawrence 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /gl/gl.v: -------------------------------------------------------------------------------- 1 | module gl 2 | 3 | import viup 4 | 5 | #flag -I @VROOT/headers 6 | #flag -L . 7 | #flag -liupgl 8 | #include "iupgl.h" 9 | 10 | fn C.IupGLCanvasOpen() 11 | 12 | fn C.IupGLCanvas(charptr) voidptr 13 | 14 | fn C.IupGLIsCurrent(voidptr) int 15 | 16 | fn C.IupGLMakeCurrent(voidptr) 17 | 18 | fn C.IupGLPalette(voidptr, int, f32, f32, f32) 19 | 20 | fn C.IupGLSwapBuffers(voidptr) 21 | 22 | fn C.IupGLWait(int) 23 | 24 | fn init() { 25 | C.IupGLCanvasOpen() 26 | } 27 | 28 | pub fn create_context(attrs ...string) &viup.Control { 29 | canvas := &viup.Control(C.IupGLCanvas(0)) 30 | canvas.set_attr('buffer', 'double') 31 | canvas.set_attrs(...attrs) 32 | return canvas 33 | } 34 | 35 | pub fn is_current(control &viup.Control) bool { 36 | return C.IupGLIsCurrent(control) > 0 37 | } 38 | 39 | pub fn make_current(control &viup.Control) &viup.Control { 40 | C.IupGLMakeCurrent(control) 41 | return control 42 | } 43 | 44 | pub fn set_palette(control &viup.Control, index int, r f32, g f32, b f32) &viup.Control { 45 | C.IupGLPalette(control, index, r, g, b) 46 | return control 47 | } 48 | 49 | pub fn swap(control &viup.Control) &viup.Control { 50 | C.IupGLSwapBuffers(control) 51 | return control 52 | } 53 | 54 | pub fn wait(is_gl bool) { 55 | C.IupGLWait(is_gl) 56 | } 57 | -------------------------------------------------------------------------------- /headers/iupglcontrols.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief GL Controls. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPGLCONTROLS_H 8 | #define __IUPGLCONTROLS_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | 15 | int IupGLControlsOpen(void); 16 | 17 | Ihandle* IupGLCanvasBoxv(Ihandle** children); 18 | Ihandle* IupGLCanvasBox(Ihandle* child, ...); 19 | 20 | Ihandle* IupGLSubCanvas(void); 21 | 22 | Ihandle* IupGLLabel(const char* title); 23 | Ihandle* IupGLSeparator(void); 24 | Ihandle* IupGLButton(const char* title); 25 | Ihandle* IupGLToggle(const char* title); 26 | Ihandle* IupGLLink(const char *url, const char * title); 27 | Ihandle* IupGLProgressBar(void); 28 | Ihandle* IupGLVal(void); 29 | Ihandle* IupGLFrame(Ihandle* child); 30 | Ihandle* IupGLExpander(Ihandle* child); 31 | Ihandle* IupGLScrollBox(Ihandle* child); 32 | Ihandle* IupGLSizeBox(Ihandle* child); 33 | Ihandle* IupGLText(void); 34 | 35 | 36 | /* Utilities */ 37 | void IupGLDrawImage(Ihandle* ih, const char* name, int x, int y, int active); 38 | void IupGLDrawText(Ihandle* ih, const char* str, int len, int x, int y); 39 | void IupGLDrawGetTextSize(Ihandle* ih, const char* str, int *w, int *h); 40 | void IupGLDrawGetImageInfo(const char* name, int *w, int *h, int *bpp); 41 | 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /headers/iuplua.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief IUP Binding for Lua. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPLUA_H 8 | #define __IUPLUA_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | 15 | #ifndef DOXYGEN_SHOULD_IGNORE_THIS 16 | /** @cond DOXYGEN_SHOULD_IGNORE_THIS */ 17 | #ifndef IUPLUA_API 18 | #ifdef IUPLUA_BUILD_LIBRARY 19 | #ifdef __EMSCRIPTEN__ 20 | #include 21 | #define IUPLUA_API EMSCRIPTEN_KEEPALIVE 22 | #elif WIN32 23 | #define IUPLUA_API __declspec(dllexport) 24 | #elif defined(__GNUC__) && __GNUC__ >= 4 25 | #define IUPLUA_API __attribute__ ((visibility("default"))) 26 | #else 27 | #define IUPLUA_API 28 | #endif 29 | #else 30 | #define IUPLUA_API 31 | #endif /* IUPLUA_BUILD_LIBRARY */ 32 | #endif /* IUPLUA_API */ 33 | /** @endcond DOXYGEN_SHOULD_IGNORE_THIS */ 34 | #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ 35 | 36 | 37 | IUPLUA_API int iuplua_open(lua_State *L); 38 | IUPLUA_API int iupkey_open(lua_State *L); /* does nothing, kept for backward compatibility */ 39 | IUPLUA_API int iuplua_close(lua_State * L); 40 | 41 | /* utilities */ 42 | IUPLUA_API int iuplua_isihandle(lua_State *L, int pos); 43 | IUPLUA_API Ihandle* iuplua_checkihandle(lua_State *L, int pos); 44 | IUPLUA_API void iuplua_pushihandle(lua_State *L, Ihandle *n); 45 | IUPLUA_API int iuplua_dofile(lua_State *L, const char *filename); 46 | IUPLUA_API int iuplua_dostring(lua_State *L, const char *string, const char *chunk_name); 47 | IUPLUA_API int iuplua_dobuffer(lua_State *L, const char *buffer, int len, const char *chunk_name); 48 | IUPLUA_API void iuplua_show_error_message(const char *pname, const char* msg); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /winmanifest/resources.rc: -------------------------------------------------------------------------------- 1 | TECGRAF_ICON ICON "v-logo.ico" /* the first icon will also defines the executable icon in Explorer */ 2 | 3 | /****************************************************/ 4 | /* Applications can change or remove this */ 5 | 6 | 1 VERSIONINFO 7 | FILEVERSION 1,0,0,0 8 | PRODUCTVERSION 1,0,0,0 9 | BEGIN 10 | BLOCK "StringFileInfo" 11 | BEGIN 12 | BLOCK "040904b0" 13 | BEGIN 14 | VALUE "Comments", "Application built with VIUP and IUP\0" 15 | VALUE "CompanyName", "App\0" 16 | VALUE "FileDescription", "App\0" 17 | VALUE "FileVersion", "1.0.0\0" 18 | VALUE "LegalCopyright", "Copyright © 2021\0" 19 | VALUE "OriginalFilename", "iup.dll\0" 20 | VALUE "ProductName", "App\0" 21 | VALUE "ProductVersion", "1.0.0\0" 22 | END 23 | END 24 | END 25 | 26 | /****************************************************/ 27 | /* Used by IupFileDlg when SHOWPREVIEW=Yes */ 28 | 29 | /* To avoid the inclusion of */ 30 | #define WS_CHILD 0x40000000L 31 | #define WS_VISIBLE 0x10000000L 32 | #define WS_CLIPSIBLINGS 0x04000000L 33 | #define DS_3DLOOK 0x0004L 34 | #define DS_CONTROL 0x0400L 35 | #define SS_OWNERDRAW 0x0000000DL 36 | #define WS_EX_STATICEDGE 0x00020000L 37 | 38 | #define IUP_PREVIEWCANVAS 3000 /* 0x0BB8 */ 39 | 40 | iupPreviewDlg DIALOG DISCARDABLE 0, 0, 250, 95 41 | STYLE WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | DS_3DLOOK | DS_CONTROL 42 | FONT 8, "MS Shell Dlg" 43 | BEGIN 44 | /* ..., SS_OWNERDRAW, x, y, width, height, ... */ 45 | CONTROL "", IUP_PREVIEWCANVAS, "STATIC", SS_OWNERDRAW, 70, 0, 120, 90, WS_EX_STATICEDGE 46 | END 47 | 48 | 1 24 "ui.manifest" 49 | -------------------------------------------------------------------------------- /headers/iupdraw.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Canvas Draw API 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPDRAW_H 8 | #define __IUPDRAW_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* all functions can be used only in IUP canvas and inside the ACTION callback */ 15 | 16 | IUP_API void IupDrawBegin(Ihandle* ih); 17 | IUP_API void IupDrawEnd(Ihandle* ih); 18 | 19 | /* all functions can be called only between calls to Begin and End */ 20 | 21 | IUP_API void IupDrawSetClipRect(Ihandle* ih, int x1, int y1, int x2, int y2); 22 | IUP_API void IupDrawGetClipRect(Ihandle* ih, int *x1, int *y1, int *x2, int *y2); 23 | IUP_API void IupDrawResetClip(Ihandle* ih); 24 | 25 | /* color controlled by the attribute DRAWCOLOR */ 26 | /* line style or fill controlled by the attribute DRAWSTYLE */ 27 | 28 | IUP_API void IupDrawParentBackground(Ihandle* ih); 29 | IUP_API void IupDrawLine(Ihandle* ih, int x1, int y1, int x2, int y2); 30 | IUP_API void IupDrawRectangle(Ihandle* ih, int x1, int y1, int x2, int y2); 31 | IUP_API void IupDrawArc(Ihandle* ih, int x1, int y1, int x2, int y2, double a1, double a2); 32 | IUP_API void IupDrawPolygon(Ihandle* ih, int* points, int count); 33 | IUP_API void IupDrawText(Ihandle* ih, const char* text, int len, int x, int y, int w, int h); 34 | IUP_API void IupDrawImage(Ihandle* ih, const char* name, int x, int y, int w, int h); 35 | IUP_API void IupDrawSelectRect(Ihandle* ih, int x1, int y1, int x2, int y2); 36 | IUP_API void IupDrawFocusRect(Ihandle* ih, int x1, int y1, int x2, int y2); 37 | 38 | IUP_API void IupDrawGetSize(Ihandle* ih, int *w, int *h); 39 | IUP_API void IupDrawGetTextSize(Ihandle* ih, const char* text, int len, int *w, int *h); 40 | IUP_API void IupDrawGetImageInfo(const char* name, int *w, int *h, int *bpp); 41 | 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /image/image.v: -------------------------------------------------------------------------------- 1 | module image 2 | 3 | import viup 4 | 5 | #flag -I @VROOT/headers 6 | #flag -L . 7 | #flag -liupim 8 | #flag -liupimglib 9 | #include "iupim.h" 10 | 11 | fn C.IupGetImageNativeHandle(voidptr) voidptr 12 | 13 | fn C.IupImage(int, int, byteptr) voidptr 14 | 15 | fn C.IupImageFromImImage(voidptr) voidptr 16 | 17 | fn C.IupImageRGB(int, int, byteptr) voidptr 18 | 19 | fn C.IupImageRGBA(int, int, byteptr) voidptr 20 | 21 | fn C.IupLoadAnimation(charptr) voidptr 22 | 23 | fn C.IupLoadImage(charptr) voidptr 24 | 25 | pub fn load(path string, attrs ...string) ?&viup.Control { 26 | ptr := &viup.Control(C.IupLoadImage(path.str)) 27 | 28 | if ptr == 0 { 29 | err := viup.get_global_value('IUPIM_LASSERROR') 30 | return error('Unable to load image $path: $err') 31 | } 32 | 33 | ptr.set_attrs(...attrs) 34 | return ptr 35 | } 36 | 37 | pub fn load_animation(path string) ?&viup.Control { 38 | ptr := C.IupLoadAnimation(path.str) 39 | 40 | if ptr == 0 { 41 | err := viup.get_global_value('IUPIM_LASSERROR') 42 | return error('Unable to load image $path: $err') 43 | } 44 | 45 | return ptr 46 | } 47 | 48 | pub fn new_grayscale(width int, height int, pixels []byte) &viup.Control { 49 | return C.IupImage(width, height, pixels.data) 50 | } 51 | 52 | pub fn new_rgb(width int, height int, pixels []byte) &viup.Control { 53 | return C.IupImageRGB(width, height, pixels.data) 54 | } 55 | 56 | pub fn new_rgba(width int, height int, pixels []byte) &viup.Control { 57 | return C.IupImageRGBA(width, height, pixels.data) 58 | } 59 | 60 | // Need "im_image.h" from library 61 | //#include "im_image.h" 62 | // pub type NativeImage = voidptr 63 | /* 64 | pub fn get_control(native NativeImage) &viup.Control { 65 | return C.IupImageFromImImage(native) 66 | } 67 | 68 | pub fn get_to_native(control &viup.Control) NativeImage { 69 | return C.IupGetImageNativeHandle(control) 70 | } 71 | */ 72 | -------------------------------------------------------------------------------- /color.v: -------------------------------------------------------------------------------- 1 | module viup 2 | 3 | pub struct Color { 4 | pub mut: 5 | r byte 6 | g byte 7 | b byte 8 | a byte = 255 9 | } 10 | 11 | // parse_color parses the provided color string 12 | // and converts it to a valid `Color` 13 | pub fn parse_color(color string) Color { 14 | mut obj := Color{} 15 | if color == '' { 16 | return obj 17 | } 18 | 19 | split := color.split(' ') 20 | if split.len > 0 { 21 | val := split[0].int() 22 | obj.r = if val < 0 || val > 255 { 0 } else { byte(val) } 23 | } 24 | 25 | if split.len > 1 { 26 | val := split[1].int() 27 | obj.g = if val < 0 || val > 255 { 0 } else { byte(val) } 28 | } 29 | 30 | if split.len > 2 { 31 | val := split[2].int() 32 | obj.b = if val < 0 || val > 255 { 0 } else { byte(val) } 33 | } 34 | 35 | if split.len > 3 { 36 | val := split[3].int() 37 | obj.a = if val < 0 || val > 255 { 0 } else { byte(val) } 38 | } 39 | 40 | return obj 41 | } 42 | 43 | // show_picker is a helper function to show a color_dialog. It 44 | // will automatically show the color dialog with this `Color`s 45 | // values pre-selected and returns back the new Color on select 46 | // as well as all of the colors in the color table 47 | pub fn (color Color) show_picker() (Color, []Color) { 48 | dialog := color_dialog('value=$color.r $color.g $color.b', 'alpha=$color.a', 'showhex=yes', 49 | 'showcolortable=yes', 'title=Color Chooser') 50 | 51 | dialog.popup(pos_current, pos_current) 52 | 53 | if dialog.get_bool('status') { 54 | value := dialog.get_attr('value') 55 | colortable := dialog.get_attr('colortable') 56 | 57 | mut colors := []Color{} 58 | split := colortable.split(';') 59 | for c in split { 60 | colors << parse_color(c) 61 | } 62 | 63 | parsed := parse_color(value) 64 | return parsed, colors 65 | } 66 | 67 | return color, []Color{len: 0} 68 | } 69 | 70 | // str converts the color to a IUP valid string 71 | // Example format: 200 150 0 100 72 | pub fn (color Color) str() string { 73 | return '$color.r $color.g $color.b $color.a' 74 | } 75 | -------------------------------------------------------------------------------- /winmanifest/ui.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | Your application description here. 10 | 11 | 12 | 20 | 21 | 22 | 23 | 24 | true 25 | 26 | 27 | 28 | 29 | 30 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /headers/iup_varg.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief IUP API with explicit variable argument parameters. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUP_VARG_H 8 | #define __IUP_VARG_H 9 | 10 | #include 11 | #include "iup.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | IUP_API void IupLogV(const char* type, const char* format, va_list arglist); 18 | 19 | IUP_API Ihandle* IupSetAttV(const char* handle_name, Ihandle* ih, const char* name, va_list arglist); 20 | 21 | IUP_API void IupSetStrfV(Ihandle* ih, const char* name, const char* format, va_list arglist); 22 | IUP_API void IupSetStrfIdV(Ihandle* ih, const char* name, int id, const char* format, va_list arglist); 23 | IUP_API void IupSetStrfId2V(Ihandle* ih, const char* name, int lin, int col, const char* format, va_list arglist); 24 | 25 | IUP_API Ihandle* IupSetCallbacksV(Ihandle* ih, const char *name, Icallback func, va_list arglist); 26 | 27 | IUP_API Ihandle* IupCreateV(const char *classname, void* first, va_list arglist); 28 | IUP_API Ihandle* IupVboxV(Ihandle* child, va_list arglist); 29 | IUP_API Ihandle* IupZboxV(Ihandle* child, va_list arglist); 30 | IUP_API Ihandle* IupHboxV(Ihandle* child,va_list arglist); 31 | IUP_API Ihandle* IupNormalizerV(Ihandle* ih_first, va_list arglist); 32 | IUP_API Ihandle* IupCboxV(Ihandle* child, va_list arglist); 33 | IUP_API Ihandle* IupGridBoxV(Ihandle* child, va_list arglist); 34 | IUP_API Ihandle* IupMultiBoxV(Ihandle* child, va_list arglist); 35 | IUP_API Ihandle* IupMenuV(Ihandle* child,va_list arglist); 36 | IUP_API Ihandle* IupTabsV(Ihandle* child, va_list arglist); 37 | IUP_API Ihandle* IupFlatTabsV(Ihandle* child, va_list arglist); 38 | 39 | IUP_API void IupMessageV(const char *title, const char *format, va_list arglist); 40 | IUP_API Ihandle* IupParamBoxV(Ihandle* param, va_list arglist); 41 | IUP_API int IupGetParamV(const char* title, Iparamcb action, void* user_data, const char* format, va_list arglist); 42 | 43 | /* must include iupglcontrols before this file to enable this declaration */ 44 | #ifdef __IUPGLCONTROLS_H 45 | #ifndef IUP_GLCONTROLS_API 46 | #define IUP_GLCONTROLS_API 47 | #endif 48 | IUP_GLCONTROLS_API Ihandle* IupGLCanvasBoxV(Ihandle* child, va_list arglist); 49 | #endif 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /font.v: -------------------------------------------------------------------------------- 1 | module viup 2 | 3 | struct Font { 4 | pub mut: 5 | condensed string 6 | face string 7 | font string 8 | italic bool 9 | size int = 12 10 | strikeout bool 11 | underline bool 12 | weight string 13 | } 14 | 15 | // parse_font parses the provided font string and 16 | // converts it to a valid `Font` 17 | pub fn parse_font(font string) Font { 18 | if font == '' { 19 | return Font{ 20 | font: font 21 | } 22 | } 23 | 24 | mut obj := Font{ 25 | font: font 26 | } 27 | mut split := []string{} 28 | 29 | if font.contains(',') { 30 | split_1 := font.split(',') 31 | if split_1.len <= 1 { 32 | return Font{ 33 | face: split_1[0] 34 | font: font 35 | } 36 | } 37 | 38 | obj.face = split_1[0] 39 | 40 | split = split_1[1].trim_space().split(' ') 41 | } else { 42 | split = font.split(' ') 43 | if split.len <= 1 { 44 | return Font{ 45 | face: split[0] 46 | font: font 47 | } 48 | } 49 | 50 | obj.face = split[0] 51 | split.delete(0) 52 | } 53 | 54 | for val in split { 55 | match val.to_lower() { 56 | 'ultra-light', 'light', 'medium', 'semi-bold', 'bold', 'ultra-bold', 'heavy' { 57 | obj.weight = val 58 | } 59 | 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'semi-expanded', 60 | 'expanded', 'extra-expanded', 'ultra-expanded' { 61 | obj.condensed = val 62 | } 63 | 'italic' { 64 | obj.italic = true 65 | } 66 | 'strikeout' { 67 | obj.strikeout = true 68 | } 69 | 'underline' { 70 | obj.underline = true 71 | } 72 | else { 73 | obj.size = val.int() 74 | } 75 | } 76 | } 77 | 78 | return obj 79 | } 80 | 81 | // show_picker is a helper function to show a font_dialog. It 82 | // will automatically show the font dialog with this `Font`s 83 | // values pre-selected and returns back the new font on select 84 | pub fn (font Font) show_picker() Font { 85 | dialog := font_dialog('value=$font') 86 | dialog.popup(pos_current, pos_current) 87 | 88 | if dialog.get_bool('status') { 89 | value := dialog.get_attr('value') 90 | parsed := parse_font(value) 91 | 92 | return parsed 93 | } 94 | 95 | return font 96 | } 97 | 98 | // str returns back the original font that was provided in `parse_font` 99 | pub fn (font Font) str() string { 100 | return font.font 101 | } 102 | -------------------------------------------------------------------------------- /viup.v: -------------------------------------------------------------------------------- 1 | module viup 2 | 3 | import os 4 | 5 | #flag -I @VROOT/headers 6 | #flag -L . 7 | #flag -liup 8 | //#flag @VOUTPUT/manifest.syso // `@VOUTPUT` doesn't exist, compilers will compain about this file next existing 9 | #include "iup.h" 10 | 11 | fn C.IupClose() 12 | 13 | fn C.IupFlush() 14 | 15 | fn C.IupGetGlobal() voidptr 16 | 17 | fn C.IupGetHandle(charptr) voidptr 18 | 19 | fn C.IupHelp(charptr) int 20 | 21 | fn C.IupLog(charptr, charptr, voidptr) 22 | 23 | fn C.IupLoopStep() int 24 | 25 | fn C.IupMainLoop() int 26 | 27 | fn C.IupMessage(charptr, charptr) 28 | 29 | fn C.IupOpen(int, voidptr) 30 | 31 | fn C.IupSetGlobal(charptr, charptr) 32 | 33 | fn C.IupSetHandle(charptr, voidptr) 34 | 35 | fn C.IupSetStrGlobal(charptr, charptr) 36 | 37 | fn init() { 38 | C.IupOpen(&os.args.len, &os.args.data) 39 | } 40 | 41 | pub fn close() { 42 | C.IupClose() 43 | } 44 | 45 | pub fn flush() { 46 | C.IupFlush() 47 | } 48 | 49 | pub fn get_global_reference(name string) voidptr { 50 | return C.IupGetGlobal(name.to_upper().trim_space().str) 51 | } 52 | 53 | pub fn get_global_value(name string) string { 54 | return unsafe { tos3(C.IupGetGlobal(name.to_upper().trim_space().str)) } 55 | } 56 | 57 | // get_handle returns a component with the provided handle name 58 | // Note: This method can cause issues with autofree 59 | pub fn get_handle(handle string) &Control { 60 | return C.IupGetHandle(handle.str) 61 | } 62 | 63 | // help opens a browser to the provided `url` 64 | pub fn help(url string) int { 65 | return C.IupHelp(url.str) 66 | } 67 | 68 | pub fn log(log_type string, data string) { 69 | C.IupLog(log_type.to_upper().str, data.str) 70 | } 71 | 72 | pub fn loop_step() int { 73 | return C.IupLoopStep() 74 | } 75 | 76 | pub fn main_loop() int { 77 | return C.IupMainLoop() 78 | } 79 | 80 | pub fn message(title string, message string) { 81 | C.IupMessage(title.str, message.str) 82 | } 83 | 84 | pub fn set_global_reference(name string, data voidptr) { 85 | C.IupSetGlobal(name.to_upper().trim_space().str, charptr(data)) 86 | } 87 | 88 | pub fn set_global_value(name string, data string) { 89 | C.IupSetStrGlobal(name.to_upper().trim_space().str, data.str) 90 | } 91 | 92 | // set_handle adds a component to the global scope based on 93 | // the provided handle name. Note, currently accessing a component 94 | // on the global scope with autofree enabled can cause crashes 95 | pub fn set_handle(handle string, control &Control) &Control { 96 | C.IupSetHandle(handle.str, control) 97 | return control 98 | } 99 | -------------------------------------------------------------------------------- /_docs/safari-pinned-tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | Created by potrace 1.11, written by Peter Selinger 2001-2013 9 | 10 | 12 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /headers/iup_export.h: -------------------------------------------------------------------------------- 1 | #ifndef __IUP_EXPORT_H 2 | #define __IUP_EXPORT_H 3 | 4 | #ifndef DOXYGEN_SHOULD_IGNORE_THIS 5 | /** @cond DOXYGEN_SHOULD_IGNORE_THIS */ 6 | 7 | /* Mark the official functions */ 8 | #ifndef IUP_API 9 | #ifdef IUP_BUILD_LIBRARY 10 | #ifdef __EMSCRIPTEN__ 11 | #include 12 | #define IUP_API EMSCRIPTEN_KEEPALIVE 13 | #elif WIN32 14 | #define IUP_API __declspec(dllexport) 15 | #elif defined(__GNUC__) && __GNUC__ >= 4 16 | #define IUP_API __attribute__ ((visibility("default"))) 17 | #else 18 | #define IUP_API 19 | #endif 20 | #else 21 | #define IUP_API 22 | #endif /* IUP_BUILD_LIBRARY */ 23 | #endif /* IUP_API */ 24 | 25 | /* Mark the internal SDK functions (some not official but need to be exported) */ 26 | #ifndef IUP_SDK_API 27 | #ifdef IUP_BUILD_LIBRARY 28 | #ifdef __EMSCRIPTEN__ 29 | #include 30 | #define IUP_SDK_API EMSCRIPTEN_KEEPALIVE 31 | #elif WIN32 32 | #define IUP_SDK_API __declspec(dllexport) 33 | #elif defined(__GNUC__) && __GNUC__ >= 4 34 | #define IUP_SDK_API __attribute__ ((visibility("default"))) 35 | #else 36 | #define IUP_SDK_API 37 | #endif 38 | #else 39 | #define IUP_SDK_API 40 | #endif /* IUP_BUILD_LIBRARY */ 41 | #endif /* IUP_SDK_API */ 42 | 43 | /* Mark the driver functions that need to be exported */ 44 | #ifndef IUP_DRV_API 45 | #ifdef IUP_BUILD_LIBRARY 46 | #ifdef __EMSCRIPTEN__ 47 | #include 48 | #define IUP_DRV_API EMSCRIPTEN_KEEPALIVE 49 | #elif WIN32 50 | #define IUP_DRV_API __declspec(dllexport) 51 | #elif defined(__GNUC__) && __GNUC__ >= 4 52 | #define IUP_DRV_API __attribute__ ((visibility("default"))) 53 | #else 54 | #define IUP_DRV_API 55 | #endif 56 | #else 57 | #define IUP_DRV_API 58 | #endif /* IUP_BUILD_LIBRARY */ 59 | #endif /* IUP_DRV_API */ 60 | 61 | /* Mark the IupImageLib function, it does not have a header of its own */ 62 | #ifndef IUPIMGLIB_API 63 | #ifdef IUPIMGLIB_BUILD_LIBRARY 64 | #ifdef __EMSCRIPTEN__ 65 | #include 66 | #define IUPIMGLIB_API EMSCRIPTEN_KEEPALIVE 67 | #elif WIN32 68 | #define IUPIMGLIB_API __declspec(dllexport) 69 | #elif defined(__GNUC__) && __GNUC__ >= 4 70 | #define IUPIMGLIB_API __attribute__ ((visibility("default"))) 71 | #else 72 | #define IUPIMGLIB_API 73 | #endif 74 | #else 75 | #define IUPIMGLIB_API 76 | #endif /* IUPIMGLIB_BUILD_LIBRARY */ 77 | #endif /* IUPIMGLIB_API */ 78 | 79 | /** @endcond DOXYGEN_SHOULD_IGNORE_THIS */ 80 | #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ 81 | 82 | 83 | #endif /* __IUP_EXPORT_H */ 84 | -------------------------------------------------------------------------------- /headers/iupgl.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief OpenGL canvas for Iup. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPGL_H 8 | #define __IUPGL_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* Attributes 15 | ** To set the appropriate visual (pixel format) the following 16 | ** attributes may be specified. Their values should be set 17 | ** before the canvas is mapped to the scrren. 18 | ** After mapping, changing their values has no effect. 19 | */ 20 | #ifndef IUP_BUFFER /* IUP_SINGLE (defaut) or IUP_DOUBLE */ 21 | #define IUP_BUFFER "BUFFER" 22 | #endif 23 | #ifndef IUP_STEREO /* IUP_NO (defaut) or IUP_YES */ 24 | #define IUP_STEREO "STEREO" 25 | #endif 26 | #ifndef IUP_BUFFER_SIZE /* Number of bits if index mode */ 27 | #define IUP_BUFFER_SIZE "BUFFER_SIZE" 28 | #endif 29 | #ifndef IUP_RED_SIZE /* Number of red bits */ 30 | #define IUP_RED_SIZE "RED_SIZE" 31 | #endif 32 | #ifndef IUP_GREEN_SIZE /* Number of green bits */ 33 | #define IUP_GREEN_SIZE "GREEN_SIZE" 34 | #endif 35 | #ifndef IUP_BLUE_SIZE /* Number of blue bits */ 36 | #define IUP_BLUE_SIZE "BLUE_SIZE" 37 | #endif 38 | #ifndef IUP_ALPHA_SIZE /* Number of alpha bits */ 39 | #define IUP_ALPHA_SIZE "ALPHA_SIZE" 40 | #endif 41 | #ifndef IUP_DEPTH_SIZE /* Number of bits in depth buffer */ 42 | #define IUP_DEPTH_SIZE "DEPTH_SIZE" 43 | #endif 44 | #ifndef IUP_STENCIL_SIZE /* Number of bits in stencil buffer */ 45 | #define IUP_STENCIL_SIZE "STENCIL_SIZE" 46 | #endif 47 | #ifndef IUP_ACCUM_RED_SIZE /* Number of red bits in accum. buffer */ 48 | #define IUP_ACCUM_RED_SIZE "ACCUM_RED_SIZE" 49 | #endif 50 | #ifndef IUP_ACCUM_GREEN_SIZE /* Number of green bits in accum. buffer */ 51 | #define IUP_ACCUM_GREEN_SIZE "ACCUM_GREEN_SIZE" 52 | #endif 53 | #ifndef IUP_ACCUM_BLUE_SIZE /* Number of blue bits in accum. buffer */ 54 | #define IUP_ACCUM_BLUE_SIZE "ACCUM_BLUE_SIZE" 55 | #endif 56 | #ifndef IUP_ACCUM_ALPHA_SIZE /* Number of alpha bits in accum. buffer */ 57 | #define IUP_ACCUM_ALPHA_SIZE "ACCUM_ALPHA_SIZE" 58 | #endif 59 | 60 | 61 | /* Attribute values */ 62 | #ifndef IUP_DOUBLE 63 | #define IUP_DOUBLE "DOUBLE" 64 | #endif 65 | #ifndef IUP_SINGLE 66 | #define IUP_SINGLE "SINGLE" 67 | #endif 68 | #ifndef IUP_INDEX 69 | #define IUP_INDEX "INDEX" 70 | #endif 71 | #ifndef IUP_RGBA 72 | #define IUP_RGBA "RGBA" 73 | #endif 74 | #ifndef IUP_YES 75 | #define IUP_YES "YES" 76 | #endif 77 | #ifndef IUP_NO 78 | #define IUP_NO "NO" 79 | #endif 80 | 81 | void IupGLCanvasOpen(void); 82 | 83 | Ihandle *IupGLCanvas(const char *action); 84 | Ihandle* IupGLBackgroundBox(Ihandle* child); 85 | 86 | void IupGLMakeCurrent(Ihandle* ih); 87 | int IupGLIsCurrent(Ihandle* ih); 88 | void IupGLSwapBuffers(Ihandle* ih); 89 | void IupGLPalette(Ihandle* ih, int index, float r, float g, float b); 90 | void IupGLUseFont(Ihandle* ih, int first, int count, int list_base); 91 | void IupGLWait(int gl); 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /headers/iup_plot.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Plot component for Iup. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUP_PLOT_H 8 | #define __IUP_PLOT_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* Initialize IupPlot widget class */ 15 | void IupPlotOpen(void); 16 | 17 | /* Create an IupPlot widget instance */ 18 | Ihandle* IupPlot(void); 19 | 20 | /***********************************************/ 21 | /* Additional API */ 22 | 23 | void IupPlotBegin(Ihandle *ih, int strXdata); 24 | void IupPlotAdd(Ihandle *ih, double x, double y); 25 | void IupPlotAddStr(Ihandle *ih, const char* x, double y); 26 | void IupPlotAddSegment(Ihandle *ih, double x, double y); 27 | int IupPlotEnd(Ihandle *ih); 28 | 29 | int IupPlotLoadData(Ihandle* ih, const char* filename, int strXdata); 30 | 31 | /* available only when linking with "iupluaplot" */ 32 | int IupPlotSetFormula(Ihandle* ih, int sample_count, const char* formula, const char* init); 33 | 34 | void IupPlotInsert(Ihandle *ih, int ds_index, int sample_index, double x, double y); 35 | void IupPlotInsertStr(Ihandle *ih, int ds_index, int sample_index, const char* x, double y); 36 | void IupPlotInsertSegment(Ihandle *ih, int ds_index, int sample_index, double x, double y); 37 | 38 | void IupPlotInsertStrSamples(Ihandle* ih, int ds_index, int sample_index, const char** x, double* y, int count); 39 | void IupPlotInsertSamples(Ihandle* ih, int ds_index, int sample_index, double *x, double *y, int count); 40 | 41 | void IupPlotAddSamples(Ihandle* ih, int ds_index, double *x, double *y, int count); 42 | void IupPlotAddStrSamples(Ihandle* ih, int ds_index, const char** x, double* y, int count); 43 | 44 | void IupPlotGetSample(Ihandle* ih, int ds_index, int sample_index, double *x, double *y); 45 | void IupPlotGetSampleStr(Ihandle* ih, int ds_index, int sample_index, const char* *x, double *y); 46 | int IupPlotGetSampleSelection(Ihandle* ih, int ds_index, int sample_index); 47 | double IupPlotGetSampleExtra(Ihandle* ih, int ds_index, int sample_index); 48 | void IupPlotSetSample(Ihandle* ih, int ds_index, int sample_index, double x, double y); 49 | void IupPlotSetSampleStr(Ihandle* ih, int ds_index, int sample_index, const char* x, double y); 50 | void IupPlotSetSampleSelection(Ihandle* ih, int ds_index, int sample_index, int selected); 51 | void IupPlotSetSampleExtra(Ihandle* ih, int ds_index, int sample_index, double extra); 52 | 53 | void IupPlotTransform(Ihandle* ih, double x, double y, double *cnv_x, double *cnv_y); 54 | void IupPlotTransformTo(Ihandle* ih, double cnv_x, double cnv_y, double *x, double *y); 55 | 56 | int IupPlotFindSample(Ihandle* ih, double cnv_x, double cnv_y, int *ds_index, int *sample_index); 57 | int IupPlotFindSegment(Ihandle* ih, double cnv_x, double cnv_y, int *ds_index, int *sample_index1, int *sample_index2); 58 | 59 | struct _cdCanvas; 60 | 61 | void IupPlotPaintTo(Ihandle *ih, struct _cdCanvas* cnv); 62 | 63 | /***********************************************/ 64 | 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /headers/iup_mglplot.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Plot component for Iup. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUP_MGLPLOT_H 8 | #define __IUP_MGLPLOT_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | /* Initialize IupMglPlot widget class */ 15 | void IupMglPlotOpen(void); 16 | 17 | /* Create an IupMglPlot widget instance */ 18 | Ihandle* IupMglPlot(void); 19 | 20 | /***********************************************/ 21 | /* Additional API */ 22 | 23 | /* Linear Data Only */ 24 | void IupMglPlotBegin(Ihandle *ih, int dim); 25 | void IupMglPlotAdd1D(Ihandle *ih, const char* name, double y); 26 | void IupMglPlotAdd2D(Ihandle *ih, double x, double y); 27 | void IupMglPlotAdd3D(Ihandle *ih, double x, double y, double z); 28 | int IupMglPlotEnd(Ihandle *ih); 29 | 30 | /* Linear (dim=1,2,3), Planar (dim=1), Volumetric (dim=1) */ 31 | int IupMglPlotNewDataSet(Ihandle *ih, int dim); 32 | 33 | /* Linear Data Only */ 34 | void IupMglPlotInsert1D(Ihandle* ih, int ds_index, int sample_index, const char** names, const double* y, int count); 35 | void IupMglPlotInsert2D(Ihandle* ih, int ds_index, int sample_index, const double* x, const double* y, int count); 36 | void IupMglPlotInsert3D(Ihandle* ih, int ds_index, int sample_index, const double* x, const double* y, const double* z, int count); 37 | 38 | /* Linear Data Only */ 39 | void IupMglPlotSet1D(Ihandle* ih, int ds_index, const char** names, const double* y, int count); 40 | void IupMglPlotSet2D(Ihandle* ih, int ds_index, const double* x, const double* y, int count); 41 | void IupMglPlotSet3D(Ihandle* ih, int ds_index, const double* x, const double* y, const double* z, int count); 42 | void IupMglPlotSetFormula(Ihandle* ih, int ds_index, const char* formulaX, const char* formulaY, const char* formulaZ, int count); 43 | 44 | /* Linear (dim=1), Planar (dim=1), Volumetric (dim=1) */ 45 | void IupMglPlotSetData(Ihandle* ih, int ds_index, const double* data, int count_x, int count_y, int count_z); 46 | void IupMglPlotLoadData(Ihandle* ih, int ds_index, const char* filename, int count_x, int count_y, int count_z); 47 | void IupMglPlotSetFromFormula(Ihandle* ih, int ds_index, const char* formula, int count_x, int count_y, int count_z); 48 | 49 | /* Only inside callbacks */ 50 | void IupMglPlotTransform(Ihandle* ih, double x, double y, double z, int *ix, int *iy); 51 | void IupMglPlotTransformTo(Ihandle* ih, int ix, int iy, double *x, double *y, double *z); 52 | 53 | /* Only inside callbacks */ 54 | void IupMglPlotDrawMark(Ihandle* ih, double x, double y, double z); 55 | void IupMglPlotDrawLine(Ihandle* ih, double x1, double y1, double z1, double x2, double y2, double z2); 56 | void IupMglPlotDrawText(Ihandle* ih, const char* text, double x, double y, double z); 57 | 58 | void IupMglPlotPaintTo(Ihandle *ih, const char* format, int w, int h, double dpi, void *data); 59 | 60 | /***********************************************/ 61 | 62 | /* Utility label for showing TeX labels */ 63 | Ihandle* IupMglLabel(const char* title); 64 | 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /_docs/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */ 2 | html { 3 | line-height: 1.15; 4 | -webkit-text-size-adjust: 100%; 5 | } 6 | 7 | main { 8 | display: block; 9 | } 10 | 11 | h1 { 12 | font-size: 2em; 13 | margin: 0.67em 0; 14 | } 15 | 16 | hr { 17 | box-sizing: content-box; 18 | height: 0; 19 | overflow: visible; 20 | } 21 | 22 | pre { 23 | font-family: monospace, monospace; 24 | font-size: 1em; 25 | } 26 | 27 | a { 28 | background-color: transparent; 29 | } 30 | 31 | abbr[title] { 32 | border-bottom: none; 33 | text-decoration: underline; 34 | text-decoration: underline dotted; 35 | } 36 | 37 | b, 38 | strong { 39 | font-weight: bolder; 40 | } 41 | 42 | kbd, 43 | samp { 44 | font-family: monospace, monospace; 45 | font-size: 1em; 46 | } 47 | 48 | small { 49 | font-size: 80%; 50 | } 51 | 52 | sub, 53 | sup { 54 | font-size: 75%; 55 | line-height: 0; 56 | position: relative; 57 | vertical-align: baseline; 58 | } 59 | 60 | sub { 61 | bottom: -0.25em; 62 | } 63 | 64 | sup { 65 | top: -0.5em; 66 | } 67 | 68 | img { 69 | border-style: none; 70 | } 71 | 72 | button, 73 | input, 74 | optgroup, 75 | select, 76 | textarea { 77 | font-family: inherit; 78 | font-size: 100%; 79 | line-height: 1.15; 80 | margin: 0; 81 | } 82 | 83 | button, 84 | input { 85 | overflow: visible; 86 | } 87 | 88 | button, 89 | select { 90 | text-transform: none; 91 | } 92 | 93 | button, 94 | [type="button"], 95 | [type="reset"], 96 | [type="submit"] { 97 | -webkit-appearance: button; 98 | } 99 | 100 | button::-moz-focus-inner, 101 | [type="button"]::-moz-focus-inner, 102 | [type="reset"]::-moz-focus-inner, 103 | [type="submit"]::-moz-focus-inner { 104 | border-style: none; 105 | padding: 0; 106 | } 107 | 108 | button:-moz-focusring, 109 | [type="button"]:-moz-focusring, 110 | [type="reset"]:-moz-focusring, 111 | [type="submit"]:-moz-focusring { 112 | outline: 1px dotted ButtonText; 113 | } 114 | 115 | fieldset { 116 | padding: 0.35em 0.75em 0.625em; 117 | } 118 | 119 | legend { 120 | box-sizing: border-box; 121 | color: inherit; 122 | display: table; 123 | max-width: 100%; 124 | padding: 0; 125 | white-space: normal; 126 | } 127 | 128 | progress { 129 | vertical-align: baseline; 130 | } 131 | 132 | textarea { 133 | overflow: auto; 134 | } 135 | 136 | [type="checkbox"], 137 | [type="radio"] { 138 | box-sizing: border-box; 139 | padding: 0; 140 | } 141 | 142 | [type="number"]::-webkit-inner-spin-button, 143 | [type="number"]::-webkit-outer-spin-button { 144 | height: auto; 145 | } 146 | 147 | [type="search"] { 148 | -webkit-appearance: textfield; 149 | outline-offset: -2px; 150 | } 151 | 152 | [type="search"]::-webkit-search-decoration { 153 | -webkit-appearance: none; 154 | } 155 | 156 | ::-webkit-file-upload-button { 157 | -webkit-appearance: button; 158 | font: inherit; 159 | } 160 | 161 | summary { 162 | display: list-item; 163 | } 164 | 165 | template { 166 | display: none; 167 | } 168 | 169 | [hidden] { 170 | display: none; 171 | } 172 | -------------------------------------------------------------------------------- /headers/iup_config.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Configuration file Utilities 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef IUP_CONFIG_H 8 | #define IUP_CONFIG_H 9 | 10 | #if defined(__cplusplus) 11 | extern "C" { 12 | #endif 13 | 14 | 15 | IUP_API Ihandle* IupConfig(void); 16 | 17 | IUP_API int IupConfigLoad(Ihandle* ih); 18 | IUP_API int IupConfigSave(Ihandle* ih); 19 | 20 | /****************************************************************/ 21 | 22 | IUP_API void IupConfigSetVariableStr(Ihandle* ih, const char* group, const char* key, const char* value); 23 | IUP_API void IupConfigSetVariableStrId(Ihandle* ih, const char* group, const char* key, int id, const char* value); 24 | IUP_API void IupConfigSetVariableInt(Ihandle* ih, const char* group, const char* key, int value); 25 | IUP_API void IupConfigSetVariableIntId(Ihandle* ih, const char* group, const char* key, int id, int value); 26 | IUP_API void IupConfigSetVariableDouble(Ihandle* ih, const char* group, const char* key, double value); 27 | IUP_API void IupConfigSetVariableDoubleId(Ihandle* ih, const char* group, const char* key, int id, double value); 28 | 29 | IUP_API const char* IupConfigGetVariableStr(Ihandle* ih, const char* group, const char* key); 30 | IUP_API const char* IupConfigGetVariableStrId(Ihandle* ih, const char* group, const char* key, int id); 31 | IUP_API int IupConfigGetVariableInt(Ihandle* ih, const char* group, const char* key); 32 | IUP_API int IupConfigGetVariableIntId(Ihandle* ih, const char* group, const char* key, int id); 33 | IUP_API double IupConfigGetVariableDouble(Ihandle* ih, const char* group, const char* key); 34 | IUP_API double IupConfigGetVariableDoubleId(Ihandle* ih, const char* group, const char* key, int id); 35 | 36 | IUP_API const char* IupConfigGetVariableStrDef(Ihandle* ih, const char* group, const char* key, const char* def); 37 | IUP_API const char* IupConfigGetVariableStrIdDef(Ihandle* ih, const char* group, const char* key, int id, const char* def); 38 | IUP_API int IupConfigGetVariableIntDef(Ihandle* ih, const char* group, const char* key, int def); 39 | IUP_API int IupConfigGetVariableIntIdDef(Ihandle* ih, const char* group, const char* key, int id, int def); 40 | IUP_API double IupConfigGetVariableDoubleDef(Ihandle* ih, const char* group, const char* key, double def); 41 | IUP_API double IupConfigGetVariableDoubleIdDef(Ihandle* ih, const char* group, const char* key, int id, double def); 42 | 43 | IUP_API void IupConfigCopy(Ihandle* ih1, Ihandle* ih2, const char* exclude_prefix); 44 | 45 | /****************************************************************/ 46 | 47 | IUP_API void IupConfigSetListVariable(Ihandle* ih, const char *group, const char* key, const char* value, int add); 48 | 49 | IUP_API void IupConfigRecentInit(Ihandle* ih, Ihandle* menu, Icallback recent_cb, int max_recent); 50 | IUP_API void IupConfigRecentUpdate(Ihandle* ih, const char* filename); 51 | 52 | IUP_API void IupConfigDialogShow(Ihandle* ih, Ihandle* dialog, const char* name); 53 | IUP_API void IupConfigDialogClosed(Ihandle* ih, Ihandle* dialog, const char* name); 54 | 55 | 56 | #if defined(__cplusplus) 57 | } 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /dialog.v: -------------------------------------------------------------------------------- 1 | module viup 2 | 3 | fn C.IupElementPropertiesDialog(voidptr, voidptr) voidptr 4 | 5 | fn C.IupColorDlg() voidptr 6 | 7 | fn C.IupDialog(voidptr) voidptr 8 | 9 | fn C.IupFileDlg() voidptr 10 | 11 | fn C.IupFontDlg() voidptr 12 | 13 | fn C.IupMessageDlg() voidptr 14 | 15 | fn C.IupLayoutDialog(voidptr) voidptr 16 | 17 | fn C.IupPopup(voidptr) int 18 | 19 | fn C.IupShow(voidptr) int 20 | 21 | fn C.IupShowXY(voidptr, int, int) 22 | 23 | struct Dialog { 24 | Control 25 | } 26 | 27 | // color_dialog opens a color picker with optional palette 28 | pub fn color_dialog(handle string, attrs ...string) &Dialog { 29 | dialog := &Dialog(C.IupColorDlg()) 30 | dialog.set_handle(handle) 31 | dialog.set_attrs(...attrs) 32 | 33 | return dialog 34 | } 35 | 36 | // debug shows a layout dialog that can be used to 37 | // inspect the provided Dialog's layout 38 | // Note: This is intended for developers 39 | pub fn (control &Control) debug() &Dialog { 40 | dialog := &Dialog(C.IupLayoutDialog(control)) 41 | return dialog.show() 42 | } 43 | 44 | // debug_props shows a properites dialog that can be used to 45 | // inspect the provided control's various properties 46 | // Note: This is intended for developers 47 | pub fn (control &Control) debug_props() &Dialog { 48 | dialog := &Dialog(C.IupElementPropertiesDialog(C.NULL, control)) 49 | return dialog.show() 50 | } 51 | 52 | // dialog creates a standard Window or Modal dialog control 53 | pub fn dialog(child &Control, handle string, attrs ...string) &Dialog { 54 | dialog := &Dialog(C.IupDialog(child)) 55 | dialog.set_handle(handle) 56 | dialog.set_attrs(...attrs) 57 | return dialog 58 | } 59 | 60 | // file_dialog creates a file chooser dialog that can be used to 61 | // open or save files. If "dialogtype" is not provided, defaults to "open" 62 | pub fn file_dialog(handle string, attrs ...string) &Dialog { 63 | dialog := &Dialog(C.IupFileDlg()) 64 | dialog.set_handle(handle) 65 | dialog.set_attr('dialogtype', 'open') 66 | dialog.set_attrs(...attrs) 67 | return dialog 68 | } 69 | 70 | // font_dialog opens a font picker dialog 71 | pub fn font_dialog(handle string, attrs ...string) &Dialog { 72 | dialog := &Dialog(C.IupFontDlg()) 73 | dialog.set_handle(handle) 74 | dialog.set_attrs(...attrs) 75 | return dialog 76 | } 77 | 78 | // message_dialog opens customizable message modal box 79 | pub fn message_dialog(attrs ...string) &Dialog { 80 | dialog := &Dialog(C.IupMessageDlg()) 81 | dialog.set_attrs(...attrs) 82 | return dialog 83 | } 84 | 85 | // popup displays the dialog as a modal at `x`, `y` position 86 | pub fn (dialog &Dialog) popup(x int, y int) &Dialog { 87 | C.IupPopup(dialog, x, y) 88 | return dialog 89 | } 90 | 91 | // set_menu sets the provided menu to this control 92 | pub fn (dialog &Dialog) set_menu(name string, menu &Control) &Dialog { 93 | set_handle(name, menu) 94 | dialog.set_attr('menu', name) 95 | return dialog 96 | } 97 | 98 | // show shows the dialog (not as a modal), typically 99 | // centered on the opening dialog control 100 | pub fn (dialog &Dialog) show() &Dialog { 101 | C.IupShow(dialog) 102 | return dialog 103 | } 104 | 105 | // show_xy shows the dialog the the provided X/Y coordinates 106 | // Note: Only to be used with dialogs 107 | pub fn (dialog &Dialog) show_xy(x int, y int) &Dialog { 108 | C.IupShowXY(dialog, x, y) 109 | return dialog 110 | } 111 | -------------------------------------------------------------------------------- /enums.v: -------------------------------------------------------------------------------- 1 | module viup 2 | 3 | pub const ( 4 | pos_center = 0xFFFF 5 | pos_left = 0xFFFE 6 | pos_mouse = 0xFFFC 7 | pos_current = 0xFFFB 8 | pos_center_parent = 0xFFFA 9 | pos_left_parent = 0xFFF9 10 | pos_right_parent = 0xFFF8 11 | ) 12 | 13 | pub enum FuncResult { 14 | cont = -4 15 | close = -3 16 | default = -2 17 | ignore = -1 18 | } 19 | 20 | pub enum Key { 21 | k_tab = 9 22 | k_enter = 13 23 | key_sp = 32 24 | key_exclam = 33 25 | key_quotedbl = 34 26 | key_numbersign = 35 27 | key_dollar = 36 28 | key_percent = 37 29 | key_ampersand = 38 30 | key_apostrophe = 39 31 | key_parentleft = 40 32 | key_parentright = 41 33 | key_asterisk = 42 34 | key_plus = 43 35 | key_comma = 44 36 | key_minus = 45 37 | key_period = 46 38 | key_slash = 47 39 | key_0 = 48 40 | key_1 = 49 41 | key_2 = 50 42 | key_3 = 51 43 | key_4 = 52 44 | key_5 = 53 45 | key_6 = 54 46 | key_7 = 55 47 | key_8 = 56 48 | key_9 = 57 49 | key_colon = 58 50 | key_semicolon = 59 51 | key_less = 60 52 | key_equal = 61 53 | key_greater = 62 54 | key_question = 63 55 | key_at = 64 56 | key_shift_a = 65 57 | key_shift_b = 66 58 | key_shift_c = 67 59 | key_shift_d = 68 60 | key_shift_e = 69 61 | key_shift_f = 70 62 | key_shift_g = 71 63 | key_shift_h = 72 64 | key_shift_i = 73 65 | key_shift_j = 74 66 | key_shift_k = 75 67 | key_shift_l = 76 68 | key_shift_m = 77 69 | key_shift_n = 78 70 | key_shift_o = 79 71 | key_shift_p = 80 72 | key_shift_q = 81 73 | key_shift_r = 82 74 | key_shift_s = 83 75 | key_shift_t = 84 76 | key_shift_u = 85 77 | key_shift_v = 86 78 | key_shift_w = 87 79 | key_shift_x = 88 80 | key_shift_y = 89 81 | key_shift_z = 90 82 | key_bracketleft = 91 83 | key_backslash = 92 84 | key_bracketright = 93 85 | key_circum = 94 86 | key_underscore = 95 87 | key_grave = 96 88 | key_a = 97 89 | key_b = 98 90 | key_c = 99 91 | key_d = 100 92 | key_e = 101 93 | key_f = 102 94 | key_g = 103 95 | key_h = 104 96 | key_i = 105 97 | key_j = 106 98 | key_k = 107 99 | key_l = 108 100 | key_m = 109 101 | key_n = 110 102 | key_o = 111 103 | key_p = 112 104 | key_q = 113 105 | key_r = 114 106 | key_s = 115 107 | key_t = 116 108 | key_u = 117 109 | key_v = 118 110 | key_w = 119 111 | key_x = 120 112 | key_y = 121 113 | key_z = 122 114 | key_braceleft = 123 115 | key_bar = 124 116 | key_braceright = 125 117 | key_tilde = 126 118 | k_middle = 0xff0b 119 | k_pause = 0xff13 120 | k_scroll = 0xff14 121 | k_esc = 0xff1b 122 | k_home = 0xff50 123 | k_left = 0xff51 124 | k_up = 0xff52 125 | k_right = 0xff53 126 | k_down = 0xff54 127 | k_pgup = 0xff55 128 | k_pgdn = 0xff56 129 | k_end = 0xff57 130 | k_print = 0xff61 131 | k_ins = 0xff63 132 | k_menu = 0xff67 133 | k_num = 0xff7f 134 | k_f1 = 0xffbe 135 | k_f2 = 0xffbf 136 | k_f3 = 0xffc0 137 | k_f4 = 0xffc1 138 | k_f5 = 0xffc2 139 | k_f6 = 0xffc3 140 | k_f7 = 0xffc4 141 | k_f8 = 0xffc5 142 | k_f9 = 0xffc6 143 | k_f10 = 0xffc7 144 | k_f11 = 0xffc8 145 | k_f12 = 0xffc9 146 | k_lshift = 268500961 147 | k_rshift = 268500962 148 | k_lctrl = 536936419 149 | k_rctrl = 536936420 150 | k_caps = 0xffe5 151 | k_lalt = 1073807337 152 | k_ralt = 1073807338 153 | k_del = 0xffff 154 | k_sys = -2147483557 155 | } 156 | 157 | pub enum MouseButton { 158 | left = 49 159 | middle = 50 160 | right = 51 161 | button_4 = 52 162 | button_5 = 53 163 | } 164 | -------------------------------------------------------------------------------- /attributes.v: -------------------------------------------------------------------------------- 1 | module viup 2 | 3 | fn C.IupGetAttribute(voidptr, charptr) charptr 4 | 5 | fn C.IupGetDouble(voidptr, charptr) f64 6 | 7 | fn C.IupGetFloat(voidptr, charptr) f32 8 | 9 | fn C.IupGetInt(voidptr, charptr) int 10 | 11 | fn C.IupGetIntInt(voidptr, charptr, voidptr, voidptr) int 12 | 13 | fn C.IupGetRGB(voidptr, charptr, voidptr, voidptr, voidptr) 14 | 15 | fn C.IupGetRGBA(voidptr, charptr, voidptr, voidptr, voidptr, voidptr) 16 | 17 | fn C.IupSetAttribute(voidptr, charptr, charptr) 18 | 19 | fn C.IupSetStrAttribute(voidptr, charptr, charptr) 20 | 21 | pub fn (control &Control) get_attr(name string) string { 22 | ptr := C.IupGetAttribute(control, name.to_upper().trim_space().str) 23 | if ptr == 0 { 24 | return '' 25 | } 26 | 27 | return unsafe { tos_clone(ptr) } 28 | } 29 | 30 | // get_bool retrieves an bool attribute (technically int > 0) 31 | pub fn (control &Control) get_bool(name string) bool { 32 | return C.IupGetInt(control, name.to_upper().trim_space().str) > 0 33 | } 34 | 35 | // get_data gets some data that has been associated with this control based on `name` 36 | pub fn (control &Control) get_data(name string) voidptr { 37 | return C.IupGetAttribute(control, '${name}_data'.to_upper().trim_space().str) 38 | } 39 | 40 | // get_f32 retrieves a float attribute 41 | pub fn (control &Control) get_f32(name string) f32 { 42 | return C.IupGetFloat(control, name.to_upper().trim_space().str) 43 | } 44 | 45 | // get_f64 retrieves an f64 attribute 46 | pub fn (control &Control) get_f64(name string) f64 { 47 | return C.IupGetDouble(control, name.to_upper().trim_space().str) 48 | } 49 | 50 | // get_int retrieves an int attribute 51 | pub fn (control &Control) get_int(name string) int { 52 | return C.IupGetInt(control, name.to_upper().trim_space().str) 53 | } 54 | 55 | // get_int_int retrieves an attribute that has a divider (x, :, -) 56 | // It returns the amount of values (0, 1, 2) and each value 57 | pub fn (control &Control) get_int_int(name string) (int, int, int) { 58 | v1 := 0 59 | v2 := 0 60 | return C.IupGetIntInt(control, name.to_upper().trim_space().str, &v1, &v2), v1, v2 61 | } 62 | 63 | // get_rgb retrieves an attribute and returns it back in r, g, b form 64 | pub fn (control &Control) get_rgb(name string) (byte, byte, byte) { 65 | r := byte(0) 66 | g := byte(0) 67 | b := byte(0) 68 | 69 | C.IupGetRGB(control, name.to_upper().trim_space().str, &r, &g, &b) 70 | return r, g, b 71 | } 72 | 73 | // get_rgba retrieves an attribute and returns it back in r, g, b, a form 74 | pub fn (control &Control) get_rgba(name string) (byte, byte, byte, byte) { 75 | r := byte(0) 76 | g := byte(0) 77 | b := byte(0) 78 | a := byte(0) 79 | 80 | C.IupGetRGBA(control, name.to_upper().trim_space().str, &r, &g, &b, &a) 81 | return r, g, b, a 82 | } 83 | 84 | // set_attr sets an attribute on `Control` and 85 | // returns `Control` back for chaining 86 | pub fn (control &Control) set_attr(name string, value string) &Control { 87 | C.IupSetStrAttribute(control, name.to_upper().trim_space().str, value.trim_space().str) 88 | 89 | return control 90 | } 91 | 92 | // set_attrs takes all x=x values and applies them to `Control` and 93 | // returns `Control` back for chaining 94 | pub fn (control &Control) set_attrs(attrs ...string) &Control { 95 | for attr in attrs { 96 | split := attr.split_nth('=', 2) 97 | if split.len == 1 { 98 | continue 99 | } 100 | 101 | control.set_attr(split[0], split[1]) 102 | } 103 | 104 | return control 105 | } 106 | 107 | // set_data associates the provided `data` with `Control` and 108 | // returns `Control` back for chaining 109 | pub fn (control &Control) set_data(name string, data voidptr) &Control { 110 | C.IupSetAttribute(control, '${name}_data'.to_upper().trim_space().str, charptr(data)) 111 | 112 | return control 113 | } 114 | 115 | // unset_attr clears the provided attribute 116 | pub fn (control &Control) unset_attr(name string) &Control { 117 | C.IupSetAttribute(control, name.to_upper().trim_space().str, C.NULL) 118 | return control 119 | } 120 | -------------------------------------------------------------------------------- /_docs/viup.browser.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | viup.browser | vdoc 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 49 |
50 |
51 |
52 |
53 |

viup.browser #

54 | 55 |
56 | 57 |
58 |

fn new #

fn new(attrs ...string) &viup.Control
59 | 60 | 61 |
62 | 63 | 66 |
67 |
71 |
72 |
73 |
74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /headers/iupcbs.h: -------------------------------------------------------------------------------- 1 | /** \file 2 | * \brief Contains all function pointer typedefs. 3 | * 4 | * See Copyright Notice in "iup.h" 5 | */ 6 | 7 | #ifndef __IUPCBS_H 8 | #define __IUPCBS_H 9 | 10 | struct _cdCanvas; 11 | 12 | typedef int (*IFidle)(void); /* idle */ 13 | typedef void (*IFentry)(void); /* entry */ 14 | 15 | typedef void (*IFi)(int); /* globalentermodal_cb, globalleavemodal_cb, */ 16 | typedef void (*IFs)(char*); /* openurl_cb */ 17 | typedef void (*IFii)(int, int); /* globalkeypress_cb */ 18 | typedef void (*IFiis)(int, int, char*); /* globalmotion_cb, openfiles_cb */ 19 | typedef void (*IFiiiis)(int, int, int, int, char*); /* globalbutton_cb */ 20 | typedef void (*IFfiis)(float,int,int,char*); /* globalwheel_cb */ 21 | typedef void (*IFvs)(void*, char*); /* handleadd_cb, handleremove_cb, imagecreate_cb, imagedestroy_cb */ 22 | 23 | typedef int (*IFn)(Ihandle*); /* default definition, same as Icallback */ 24 | typedef int (*IFni)(Ihandle*, int); /* k_any, show_cb, toggle_action, spin_cb, branchopen_cb, branchclose_cb, executeleaf_cb, showrename_cb, rightclick_cb, extended_cb, height_cb, width_cb */ 25 | typedef int (*IFnii)(Ihandle*, int, int); /* resize_cb, caret_cb, matrix_mousemove_cb, enteritem_cb, leaveitem_cb, scrolltop_cb, dropcheck_cb, selection_cb, select_cb, switch_cb, scrolling_cb, vspan_cb, hspan_cb */ 26 | typedef int (*IFniii)(Ihandle*, int, int, int); /* trayclick_cb, edition_cb */ 27 | typedef int (*IFniiii)(Ihandle*, int, int, int, int); /* dragdrop_cb */ 28 | typedef int (*IFniiiiiiC)(Ihandle*, int, int, int, int, int, int, struct _cdCanvas*); /* draw_cb */ 29 | typedef int (*IFniiiiii)(Ihandle*, int, int, int, int, int, int); /* OLD draw_cb */ 30 | typedef int (*IFnsidv)(Ihandle*, char*, int, double, void*); /* postmessage_cb */ 31 | 32 | typedef int (*IFnff)(Ihandle*, float, float); /* canvas_action */ 33 | typedef int (*IFniff)(Ihandle*,int,float,float); /* scroll_cb */ 34 | typedef int (*IFnfiis)(Ihandle*,float,int,int,char*); /* wheel_cb */ 35 | 36 | typedef int (*IFnsVi)(Ihandle*, char*, void*, int); /* dragdata_cb */ 37 | typedef int (*IFnsViii)(Ihandle*, char*, void*, int, int, int); /* dropdata_cb */ 38 | typedef int (*IFnsiii)(Ihandle*, char*, int, int, int); /* dropfiles_cb */ 39 | typedef int (*IFnssi)(Ihandle*, char*, char*, int); /* dragfilecreatename_cb */ 40 | 41 | typedef int (*IFnnii)(Ihandle*, Ihandle*, int, int); /* drop_cb */ 42 | typedef int (*IFnn)(Ihandle*, Ihandle*); /* savemarkers_cb, restoremarkers_cb */ 43 | typedef int (*IFnnn)(Ihandle*, Ihandle*, Ihandle*); /* tabchange_cb */ 44 | typedef int (*IFnss)(Ihandle*, char *, char *); /* file_cb */ 45 | typedef int (*IFns)(Ihandle*, char *); /* multiselect_cb */ 46 | typedef int (*IFnsi)(Ihandle*, char *, int); /* copydata_cb */ 47 | typedef int (*IFnis)(Ihandle*, int, char *); /* text_action, multiline_action, edit_cb, rename_cb */ 48 | typedef int (*IFnsii)(Ihandle*, char*, int, int); /* list_action */ 49 | typedef int (*IFniis)(Ihandle*, int, int, char*); /* motion_cb, click_cb, value_edit_cb */ 50 | typedef int (*IFniiis)(Ihandle*, int, int, int, char*); /* touch_cb, dblclick_cb */ 51 | typedef int (*IFniiiis)(Ihandle*, int, int, int, int, char*); /* button_cb, matrix_action, mousemotion_cb */ 52 | typedef int (*IFniiiiiis)(Ihandle*, int, int, int, int, int, int, char*); /* mouseclick_cb */ 53 | 54 | typedef int (*IFnIi)(Ihandle*, int*, int); /* multiselection_cb, multiunselection_cb */ 55 | typedef int (*IFnd)(Ihandle*, double); /* mousemove_cb, button_press_cb, button_release_cb */ 56 | typedef int (*IFniiIII)(Ihandle*, int, int, int*, int*, int*); /* fgcolor_cb, bgcolor_cb */ 57 | typedef int (*IFniinsii)(Ihandle*, int, int, Ihandle*, char*, int, int); /* dropselect_cb */ 58 | typedef int (*IFnccc)(Ihandle*, unsigned char, unsigned char, unsigned char); /* drag_cb, change_cb */ 59 | typedef int (*IFniIIII)(Ihandle*, int, int*, int*, int*, int*); /* multitouch_cb */ 60 | 61 | typedef int (*IFnC)(Ihandle*, struct _cdCanvas*); /* postdraw_cb, predraw_cb */ 62 | typedef int (*IFniidd)(Ihandle*, int, int, double, double); /* delete_cb */ 63 | typedef int (*IFniiddi)(Ihandle*, int, int, double, double, int); /* select_cb */ 64 | typedef int (*IFniiddiddi)(Ihandle*, int, int, double, double, int, double, double, int); /* clicksegment_cb */ 65 | typedef int (*IFniidds)(Ihandle*, int, int, double, double, char*); /* plotbutton_cb */ 66 | typedef int (*IFndds)(Ihandle*, double, double, char*); /* plotmotion_cb */ 67 | typedef int (*IFnssds)(Ihandle*, char*, char*, double, char*); /* plottickformat_cb */ 68 | typedef int (*IFnni)(Ihandle*, Ihandle*, int); 69 | 70 | typedef char* (*sIFnii)(Ihandle*, int, int); /* value_cb, font_cb */ 71 | typedef char* (*sIFni)(Ihandle*, int); /* cell_cb */ 72 | typedef char* (*sIFniis)(Ihandle*, int, int, char*); /* translatevalue_cb */ 73 | 74 | typedef double (*dIFnii)(Ihandle*, int, int); /* numericgetvalue_cb */ 75 | typedef int (*IFniid)(Ihandle*, int, int, double); /* numericsetvalue_cb */ 76 | 77 | typedef void (*IFniiv)(Ihandle*, int, int, void*); /* android_onactivityresult_cb */ 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /control.v: -------------------------------------------------------------------------------- 1 | module viup 2 | 3 | fn C.IupAppend(voidptr, voidptr) voidptr 4 | 5 | fn C.IupDestroy(voidptr) 6 | 7 | fn C.IupDetach(voidptr) 8 | 9 | fn C.IupGetClassName(voidptr) charptr 10 | 11 | fn C.IupGetClassType(voidptr) charptr 12 | 13 | fn C.IupGetFocus() voidptr 14 | 15 | fn C.IupInsert(voidptr, voidptr, voidptr) voidptr 16 | 17 | fn C.IupNextField(voidptr) voidptr 18 | 19 | fn C.IupMap(voidptr) int 20 | 21 | fn C.IupPreviousField(voidptr) voidptr 22 | 23 | fn C.IupRefresh(voidptr) 24 | 25 | fn C.IupRefreshChildren(voidptr) 26 | 27 | fn C.IupSaveClassAttributes(voidptr) 28 | 29 | fn C.IupSetFocus(voidptr) voidptr 30 | 31 | fn C.IupUnmap(voidptr) 32 | 33 | pub struct Control { 34 | mut: 35 | sig [4]i8 36 | iclass voidptr 37 | attrib voidptr 38 | serial int 39 | handle voidptr 40 | expand int 41 | flags int 42 | pub: 43 | x int 44 | y int 45 | user_width int 46 | user_height int 47 | natural_width int 48 | natural_height int 49 | current_width int 50 | current_height int 51 | parent &Control 52 | first_child &Control 53 | sibling &Control 54 | data voidptr 55 | } 56 | 57 | pub fn (control &Control) append(new_control &Control) &Control { 58 | return C.IupAppend(control, new_control) 59 | } 60 | 61 | pub fn (control &Control) destroy() { 62 | C.IupDestroy(control) 63 | } 64 | 65 | pub fn (control &Control) detach() { 66 | C.IupDetach(control) 67 | } 68 | 69 | // focus sets focus on to the current control and 70 | // returns back the previously focused control 71 | pub fn (control &Control) focus() { 72 | return C.IupSetFocus(control) 73 | } 74 | 75 | // focus_next focuses on the next element that can have focus 76 | // Note: This may not produce the same results as tabbing 77 | pub fn (control &Control) focus_next() { 78 | return C.IupNextField(control) 79 | } 80 | 81 | // focus_prev focuses on the previous element that can have focus 82 | // Note: This may not produce the same results as tabbing 83 | pub fn (control &Control) focus_prev() { 84 | return C.IupPreviousField(control) 85 | } 86 | 87 | // free destroys this control and releases its memory (used by autofree) 88 | pub fn (mut control Control) free() { 89 | if control.handle == 0 { 90 | return 91 | } 92 | 93 | control.destroy() 94 | control.handle = voidptr(0) 95 | } 96 | 97 | // get_bgcolor gets the background color for the control 98 | pub fn (control &Control) get_bgcolor() Color { 99 | return parse_color(control.get_attr('bgcolor')) 100 | } 101 | 102 | pub fn (control &Control) get_class_name() string { 103 | return unsafe { tos3(C.IupGetClassName(control)) } 104 | } 105 | 106 | pub fn (control &Control) get_class_type() string { 107 | return unsafe { tos3(C.IupGetClassType(control)) } 108 | } 109 | 110 | // get_fgcolor gets the foreground color for the control 111 | pub fn (control &Control) get_fgcolor() Color { 112 | return parse_color(control.get_attr('fgcolor')) 113 | } 114 | 115 | // get_focused returns back the control that currently has focus 116 | // Note: This method can cause issues with autofree 117 | pub fn get_focused() &Control { 118 | return C.IupGetFocus() 119 | } 120 | 121 | // get_font returns back a formatted `Font` object for this control 122 | pub fn (control &Control) get_font() Font { 123 | return parse_font(control.get_attr('font')) 124 | } 125 | 126 | // insert inserts a `new_control` into this control after `ref_control` if provided 127 | pub fn (control &Control) insert(new_control &Control, ref_control &Control) &Control { 128 | return C.IupInsert(control, new_control, ref_control) 129 | } 130 | 131 | pub fn (control &Control) map_control() int { 132 | return C.IupMap(control) 133 | } 134 | 135 | pub fn (control &Control) refresh() { 136 | C.IupRefresh(control) 137 | } 138 | 139 | pub fn (control &Control) refresh_children() { 140 | C.IupRefreshChildren(control) 141 | } 142 | 143 | // set_bgcolor updates the background color for this control to the provided `Color` 144 | pub fn (control &Control) set_bgcolor(color Color) &Control { 145 | return control.set_attr('bgcolor', color.str()) 146 | } 147 | 148 | // set_fgcolor updates the foreground color for this control to the provided `Color` 149 | pub fn (control &Control) set_fgcolor(color Color) &Control { 150 | return control.set_attr('fgcolor', color.str()) 151 | } 152 | 153 | // set_font updates the font for this control to the provided `Font` 154 | pub fn (control &Control) set_font(font Font) &Control { 155 | return control.set_attr('font', font.str()) 156 | } 157 | 158 | // set_handle is a helper function for `Control` that calls the global 159 | // `set_handle` function. Returns back an instance of `Control` for chaining 160 | pub fn (control &Control) set_handle(name string) &Control { 161 | return set_handle(name, control) 162 | } 163 | 164 | pub fn (control &Control) set_image(handle string) &Control { 165 | return control.set_attr('image', handle) 166 | } 167 | 168 | pub fn (control &Control) unmap_control(save_attrs bool) { 169 | if save_attrs { 170 | C.IupSaveClassAttributes(control) 171 | } 172 | 173 | C.IupUnmap(control) 174 | } 175 | -------------------------------------------------------------------------------- /controls.v: -------------------------------------------------------------------------------- 1 | module viup 2 | 3 | fn C.IupAnimatedLabel(voidptr) voidptr 4 | 5 | fn C.IupButton(charptr) voidptr 6 | 7 | fn C.IupCalendar() voidptr 8 | 9 | fn C.IupCanvas(charptr) voidptr 10 | 11 | fn C.IupColorBrowser() voidptr 12 | 13 | fn C.IupDatePick() voidptr 14 | 15 | fn C.IupDropButton(voidptr) voidptr 16 | 17 | fn C.IupFlatButton(charptr) voidptr 18 | 19 | fn C.IupFlatTree() voidptr 20 | 21 | fn C.IupFlatToggle(charptr) voidptr 22 | 23 | fn C.IupFlatVal(charptr) voidptr 24 | 25 | fn C.IupItem(charptr, charptr) voidptr 26 | 27 | fn C.IupLabel(charptr) voidptr 28 | 29 | fn C.IupLink(charptr, charptr) voidptr 30 | 31 | fn C.IupList(charptr) voidptr 32 | 33 | fn C.IupMultiLine(charptr) voidptr 34 | 35 | fn C.IupProgressBar() voidptr 36 | 37 | fn C.IupSeparator() voidptr 38 | 39 | fn C.IupSpin() voidptr 40 | 41 | fn C.IupSpinbox(voidptr) voidptr 42 | 43 | fn C.IupSubmenu(charptr, voidptr) voidptr 44 | 45 | fn C.IupText(charptr) voidptr 46 | 47 | fn C.IupToggle(charptr, charptr) voidptr 48 | 49 | fn C.IupTree() voidptr 50 | 51 | fn C.IupVal(charptr) voidptr 52 | 53 | // animated_label creates an control that can display an animation 54 | pub fn animated_label(animation &Control, attrs ...string) &Control { 55 | animated_label := &Control(C.IupAnimatedLabel(animation)) 56 | animated_label.set_attrs(...attrs) 57 | return animated_label 58 | } 59 | 60 | // button creates a standard button control with `title` for text 61 | pub fn button(title string, attrs ...string) &Control { 62 | button := &Control(C.IupButton(title.str, 0)) 63 | button.set_attrs(...attrs) 64 | return button 65 | } 66 | 67 | pub fn calendar(attrs ...string) &Control { 68 | calendar := &Control(C.IupCalendar()) 69 | calendar.set_attrs(...attrs) 70 | return calendar 71 | } 72 | 73 | // canvas creates a control that can render custom content 74 | pub fn canvas(attrs ...string) &Control { 75 | canvas := &Control(C.IupCanvas(0)) 76 | canvas.set_attrs(...attrs) 77 | return canvas 78 | } 79 | 80 | pub fn color_browser(attrs ...string) &Control { 81 | color_browser := &Control(C.IupColorBrowser()) 82 | color_browser.set_attrs(...attrs) 83 | return color_browser 84 | } 85 | 86 | pub fn date_picker(attrs ...string) &Control { 87 | date_picker := &Control(C.IupDatePick()) 88 | date_picker.set_attrs(...attrs) 89 | return date_picker 90 | } 91 | 92 | // divider creates a simple line divider element (horizontal by default) 93 | pub fn divider(attrs ...string) &Control { 94 | divider := &Control(C.IupFlatSeparator()) 95 | divider.set_attr('orientation', 'horizontal') 96 | divider.set_attrs(...attrs) 97 | return divider 98 | } 99 | 100 | pub fn drop_button(child &Control, attrs ...string) &Control { 101 | drop_button := &Control(C.IupDropButton(child)) 102 | drop_button.set_attrs(...attrs) 103 | return drop_button 104 | } 105 | 106 | pub fn flat_button(title string, attrs ...string) &Control { 107 | flat_button := &Control(C.IupFlatButton(title.str)) 108 | flat_button.set_attrs(...attrs) 109 | return flat_button 110 | } 111 | 112 | pub fn flat_toggle(title string, attrs ...string) &Control { 113 | flat_toggle := &Control(C.IupFlatToggle(title.str)) 114 | flat_toggle.set_attrs(...attrs) 115 | return flat_toggle 116 | } 117 | 118 | pub fn flat_slider(orientation string, attrs ...string) &Control { 119 | flat_slider := &Control(C.IupFlatVal(orientation.str)) 120 | flat_slider.set_attrs(...attrs) 121 | return flat_slider 122 | } 123 | 124 | pub fn flat_tree(attrs ...string) &Control { 125 | flat_tree := &Control(C.IupFlatTree()) 126 | flat_tree.set_attrs(...attrs) 127 | return flat_tree 128 | } 129 | 130 | // label is used to draw simple text or images 131 | pub fn label(title string, attrs ...string) &Control { 132 | label := &Control(C.IupLabel(title.str)) 133 | label.set_attrs(...attrs) 134 | return label 135 | } 136 | 137 | // link creates a control similar to a `label` that can 138 | // link to external resources (files, URL, etc) 139 | pub fn link(url string, title string, attrs ...string) &Control { 140 | label := &Control(C.IupLink(url.str, title.str)) 141 | label.set_attrs(...attrs) 142 | return label 143 | } 144 | 145 | // list creates a component that can list multiple values 146 | pub fn list(attrs ...string) &Control { 147 | list := &Control(C.IupList(0)) 148 | list.set_attrs(...attrs) 149 | return list 150 | } 151 | 152 | // menu_item is a component that can be used in a `menu` to 153 | // that is tied to a specific action or event 154 | pub fn menu_item(title string, attrs ...string) &Control { 155 | menu_item := &Control(C.IupItem(title.str, 0)) 156 | menu_item.set_attrs(...attrs) 157 | return menu_item 158 | } 159 | 160 | // menu_sep creates a simple horizontal line in a `menu` 161 | pub fn menu_sep(attrs ...string) &Control { 162 | menu_sep := &Control(C.IupSeparator()) 163 | menu_sep.set_attrs(...attrs) 164 | return menu_sep 165 | } 166 | 167 | // multiline creates a multiline chooser component 168 | pub fn multiline(attrs ...string) &Control { 169 | multiline := &Control(C.IupMultiLine(0)) 170 | multiline.set_attrs(...attrs) 171 | return multiline 172 | } 173 | 174 | // progress is a basic progressbar component 175 | pub fn progress(attrs ...string) &Control { 176 | progress := &Control(C.IupProgressBar()) 177 | progress.set_attrs(...attrs) 178 | return progress 179 | } 180 | 181 | // slider is a number-line slider component 182 | pub fn slider(orientation string, attrs ...string) &Control { 183 | slider := &Control(C.IupVal(orientation.str)) 184 | slider.set_attrs(...attrs) 185 | return slider 186 | } 187 | 188 | pub fn spin(attrs ...string) &Control { 189 | spin := &Control(C.IupSpin()) 190 | spin.set_attrs(...attrs) 191 | return spin 192 | } 193 | 194 | pub fn spin_box(child &Control, attrs ...string) &Control { 195 | spin_box := &Control(C.IupSpinbox(child)) 196 | spin_box.set_attrs(...attrs) 197 | return spin_box 198 | } 199 | 200 | // sub_menu is a container control for `menu` controls 201 | pub fn sub_menu(title string, child &Control, attrs ...string) &Control { 202 | sub_menu := &Control(C.IupSubmenu(title.str, child)) 203 | sub_menu.set_attrs(...attrs) 204 | return sub_menu 205 | } 206 | 207 | // text is a standard text input component. Can be configured to 208 | // to be multi-line, number formatted, etc. 209 | pub fn text(attrs ...string) &Control { 210 | text := &Control(C.IupText(0)) 211 | text.set_attrs(...attrs) 212 | return text 213 | } 214 | 215 | pub fn tree(attrs ...string) &Control { 216 | tree := &Control(C.IupTree()) 217 | tree.set_attrs(...attrs) 218 | return tree 219 | } 220 | 221 | // toggle is a radio or checkbox component. Defaults to radio in a `radio_group` 222 | pub fn toggle(title string, attrs ...string) &Control { 223 | toggle := &Control(C.IupToggle(title.str, 0)) 224 | toggle.set_attrs(...attrs) 225 | return toggle 226 | } 227 | -------------------------------------------------------------------------------- /containers.v: -------------------------------------------------------------------------------- 1 | module viup 2 | 3 | fn C.IupBackgroundBox(voidptr) voidptr 4 | 5 | fn C.IupCboxv(voidptr) voidptr 6 | 7 | fn C.IupDetachBox(voidptr) voidptr 8 | 9 | fn C.IupExpander(voidptr) voidptr 10 | 11 | fn C.IupFill() voidptr 12 | 13 | fn C.IupFlatFrame(voidptr) voidptr 14 | 15 | fn C.IupFlatSeparator() voidptr 16 | 17 | fn C.IupFlatScrollBox(voidptr) voidptr 18 | 19 | fn C.IupFlatTabsv(voidptr) voidptr 20 | 21 | fn C.IupFrame(voidptr) voidptr 22 | 23 | fn C.IupGridBoxv(voidptr) voidptr 24 | 25 | fn C.IupHboxv(voidptr) voidptr 26 | 27 | fn C.IupMenuv(voidptr) voidptr 28 | 29 | fn C.IupMultiBoxv(voidptr) voidptr 30 | 31 | fn C.IupNormalizerv(voidptr) voidptr 32 | 33 | fn C.IupRadio(voidptr) voidptr 34 | 35 | fn C.IupSbox(voidptr) voidptr 36 | 37 | fn C.IupScrollBox(voidptr) voidptr 38 | 39 | fn C.IupSpace() voidptr 40 | 41 | fn C.IupTabsv(voidptr) voidptr 42 | 43 | fn C.IupVboxv(voidptr) voidptr 44 | 45 | fn C.IupZboxv(voidptr) voidptr 46 | 47 | // background is a simple container element that is 48 | // designed to have a background color or image 49 | pub fn background(child &Control, attrs ...string) &Control { 50 | background := &Control(C.IupBackgroundBox(child)) 51 | background.set_attr('title', '') 52 | background.set_attrs(...attrs) 53 | return background 54 | } 55 | 56 | pub fn cbox(children []&Control, attrs ...string) &Control { 57 | mut ptrs := []voidptr{} 58 | for child in children { 59 | ptrs << child 60 | } 61 | ptrs << 0 // Add null value 62 | cbox := &Control(C.IupCboxv(ptrs.data)) 63 | cbox.set_attrs(...attrs) 64 | return cbox 65 | } 66 | 67 | // detach_box is a container that can be detached as a dialog 68 | // and reattached back to the parent dialog when needed 69 | pub fn detach_box(child &Control, attrs ...string) &Control { 70 | detach_box := &Control(C.IupDetachBox(child)) 71 | detach_box.set_attrs(...attrs) 72 | return detach_box 73 | } 74 | 75 | pub fn expander(child &Control, attrs ...string) &Control { 76 | expander := &Control(C.IupExpander(child)) 77 | expander.set_attrs(...attrs) 78 | return expander 79 | } 80 | 81 | // fill fills up the remaining space for the parent container 82 | pub fn fill(attrs ...string) &Control { 83 | fill := &Control(C.IupFill()) 84 | fill.set_attrs(...attrs) 85 | return fill 86 | } 87 | 88 | // flat_frame is a standard frame that allows custom drawing 89 | pub fn flat_frame(child &Control, attrs ...string) &Control { 90 | flat_frame := &Control(C.IupFlatFrame(child)) 91 | flat_frame.set_attr('title', '') 92 | flat_frame.set_attrs(...attrs) 93 | return flat_frame 94 | } 95 | 96 | // flat_scroll is a standard scroll that allow custom drawing 97 | pub fn flat_scroll(child &Control, attrs ...string) &Control { 98 | flat_scroll := &Control(C.IupFlatScrollBox(child)) 99 | flat_scroll.set_attrs(...attrs) 100 | return flat_scroll 101 | } 102 | 103 | // flat_tabs is a standard tabs container that allows custom drawing 104 | pub fn flat_tabs(children []&Control, attrs ...string) &Control { 105 | mut ptrs := []voidptr{} 106 | for child in children { 107 | ptrs << child 108 | } 109 | ptrs << 0 // Add null value 110 | flat_tabs := &Control(C.IupFlatTabsv(ptrs.data)) 111 | flat_tabs.set_attrs(...attrs) 112 | return flat_tabs 113 | } 114 | 115 | // frame puts a border around its children with an optional title 116 | pub fn frame(child &Control, attrs ...string) &Control { 117 | frame := &Control(C.IupFrame(child)) 118 | frame.set_attr('title', '') 119 | frame.set_attrs(...attrs) 120 | return frame 121 | } 122 | 123 | // grid is a container that can layout its children in a table-like configuration 124 | pub fn grid(children []&Control, attrs ...string) &Control { 125 | mut ptrs := []voidptr{} 126 | for child in children { 127 | ptrs << child 128 | } 129 | ptrs << 0 // Add null value 130 | grid := &Control(C.IupGridBoxv(ptrs.data)) 131 | grid.set_attrs(...attrs) 132 | return grid 133 | } 134 | 135 | // hbox is a container that displays its children in a row 136 | pub fn hbox(children []&Control, attrs ...string) &Control { 137 | mut ptrs := []voidptr{} 138 | for child in children { 139 | ptrs << child 140 | } 141 | ptrs << 0 // Add null value 142 | hbox := &Control(C.IupHboxv(ptrs.data)) 143 | hbox.set_attrs(...attrs) 144 | return hbox 145 | } 146 | 147 | // menu is an application container for menu items 148 | pub fn menu(children []&Control, attrs ...string) &Control { 149 | mut ptrs := []voidptr{} 150 | for child in children { 151 | ptrs << child 152 | } 153 | ptrs << 0 // Add null value 154 | menu := &Control(C.IupMenuv(ptrs.data)) 155 | menu.set_attrs(...attrs) 156 | return menu 157 | } 158 | 159 | pub fn multi_box(children []&Control, attrs ...string) &Control { 160 | mut ptrs := []voidptr{} 161 | for child in children { 162 | ptrs << child 163 | } 164 | ptrs << 0 // Add null value 165 | multi_box := &Control(C.IupMultiBoxv(ptrs.data)) 166 | multi_box.set_attrs(...attrs) 167 | return multi_box 168 | } 169 | 170 | pub fn normalizer(children []&Control, attrs ...string) &Control { 171 | mut ptrs := []voidptr{} 172 | for child in children { 173 | ptrs << child 174 | } 175 | ptrs << 0 // Add null value 176 | normalizer := &Control(C.IupNormalizerv(ptrs.data)) 177 | normalizer.set_attrs(...attrs) 178 | return normalizer 179 | } 180 | 181 | // radio_group is designed to wrap around toggle controls to 182 | // turn them into a radio button group 183 | pub fn radio_group(child &Control, attrs ...string) &Control { 184 | radio_group := &Control(C.IupRadio(child)) 185 | radio_group.set_attrs(...attrs) 186 | return radio_group 187 | } 188 | 189 | pub fn resizer(child &Control, attrs ...string) &Control { 190 | resizer := &Control(C.IupSbox(child)) 191 | resizer.set_attrs(...attrs) 192 | return resizer 193 | } 194 | 195 | // scroll creates a scroll box that creates a virtual space that 196 | // can hold an unlimited amount of items with scrolling. 197 | pub fn scroll(child &Control, attrs ...string) &Control { 198 | scroll := &Control(C.IupScrollBox(child)) 199 | scroll.set_attrs(...attrs) 200 | return scroll 201 | } 202 | 203 | pub fn space(attrs ...string) &Control { 204 | space := &Control(C.IupSpace()) 205 | space.set_attrs(...attrs) 206 | return space 207 | } 208 | 209 | // tabs creates a tab group that can be switched 210 | // between to view different content 211 | pub fn tabs(children []&Control, attrs ...string) &Control { 212 | mut ptrs := []voidptr{} 213 | for child in children { 214 | ptrs << child 215 | } 216 | ptrs << 0 // Add null value 217 | tabs := &Control(C.IupTabsv(ptrs.data)) 218 | tabs.set_attrs(...attrs) 219 | return tabs 220 | } 221 | 222 | // vbox is a container that displays its children in a column 223 | pub fn vbox(children []&Control, attrs ...string) &Control { 224 | mut ptrs := []voidptr{} 225 | for child in children { 226 | ptrs << child 227 | } 228 | ptrs << 0 // Add null value 229 | vbox := &Control(C.IupVboxv(ptrs.data)) 230 | vbox.set_attrs(...attrs) 231 | return vbox 232 | } 233 | 234 | pub fn zbox(children []&Control, attrs ...string) &Control { 235 | mut ptrs := []voidptr{} 236 | for child in children { 237 | ptrs << child 238 | } 239 | ptrs << 0 // Add null value 240 | zbox := &Control(C.IupZboxv(ptrs.data)) 241 | zbox.set_attrs(...attrs) 242 | return zbox 243 | } 244 | -------------------------------------------------------------------------------- /examples/gallery/gallery.v: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | import os 4 | import viup 5 | import viup.image 6 | 7 | //#flag windows "path\\to\\manifest.syso" 8 | 9 | const ( 10 | version = '1.0.0' 11 | about = ' 12 | This is version $version of VIUP Control Gallery demo. 13 | 14 | It gives a simple overview of all of the available controls and some sample use cases. 15 | ' 16 | ) 17 | 18 | fn main() { 19 | vlogo := image.load(os.resource_abs_path('./v-logo.png'), 'resize=64x64') ? 20 | vlogo.set_handle('logo') 21 | 22 | // Create our menu with the typical "File | Edit | About" layout 23 | menu_event := viup.ActionFunc(menu_clicked) 24 | menu := viup.menu([ 25 | viup.sub_menu('&File', viup.menu([ 26 | viup.menu_item('&Open File...', 'name=MenuOpen').on_action(menu_event), 27 | viup.menu_item('&Save File...', 'name=MenuSave').on_action(menu_event), 28 | viup.menu_sep(), 29 | viup.menu_item('E&xit', 'name=MenuExit').on_action(menu_event), 30 | ])), 31 | viup.sub_menu('&Edit', viup.menu([ 32 | viup.menu_item('Debug &Window', 'name=MenuDebugWindow').on_action(menu_event), 33 | viup.menu_item('Debug &Control', 'name=MenuDebugControl').on_action(menu_event), 34 | ])), 35 | viup.sub_menu('&Help', viup.menu([ 36 | viup.menu_item('&Repository', 'name=MenuRepository').on_action(menu_event), 37 | viup.menu_sep(), 38 | viup.menu_item('&About', 'name=MenuAbout').on_action(menu_event), 39 | ])), 40 | ]) 41 | 42 | // Layout design 43 | // ----------------- hbox ------------------ 44 | // ------vbox------- ---------vbox---------- 45 | // |---frame "BC"--| |----frame "Numbers"--| "BC" - "Basic Controls" 46 | // | button | | spin | 47 | // | toggle | | slider ('value') | 48 | // | text | | progress | 49 | // | label | |---------------------| 50 | // | divider | |----frame "Lists"----| 51 | // | date_picker | | dropdown | 52 | // | button | | editable-dropdown | 53 | // | image | | radio-group | 54 | // | fill | |---------------------| 55 | // | | | tab-group | 56 | // |---------------| |---------------------| 57 | hbox := viup.hbox([ 58 | viup.vbox([ 59 | viup.frame(viup.vbox([ 60 | viup.button('Button', 'expand=horizontal').on_action(button_clicked), 61 | viup.toggle('Checkbox', 'action1'), 62 | viup.text('expand=horizontal', 'value=Text Field'), 63 | viup.label('Label'), 64 | viup.link('https://www.vlang.io', 'Link'), 65 | viup.divider(), 66 | viup.button('Set font...', 'expand=horizontal').set_handle('font_btn').on_action(font_button_clicked), 67 | viup.date_picker('expand=horizontal', 'order=MDY'), 68 | viup.button('', 'bgcolor=0 0 0', 'expand=horizontal', 'padding=10x0').unset_attr('title').set_handle('color_btn').on_action(color_button_clicked), 69 | viup.label('', 'size=64x64', 'alignment=acenter', 'expand=horizontal').set_image('logo'), 70 | viup.fill(), 71 | ]), 'title=Basic Controls', 'margin=10x10', 'expand=yes'), 72 | ], 'expand=vertical', 'gap=10', 'minsize=250x'), 73 | viup.vbox([ 74 | viup.frame(viup.vbox([ 75 | viup.text('expand=horizontal', 'spin=yes', 'spinmax=100', 'value=50').set_handle('spin1').on_value_changed(numbers_changed), 76 | viup.slider('horizontal', 'expand=horizontal', 'max=100', 'showticks=yes', 77 | 'step=5', 'tickspos=reverse', 'value=50').set_handle('slider1').on_value_changed(numbers_changed), 78 | viup.progress('expand=horizontal', 'max=100', 'value=50').set_handle('progress1'), 79 | viup.fill(), 80 | ]), 'title=Numbers', 'margin=10x10', 'minsize=500x'), 81 | viup.frame(viup.vbox([ 82 | viup.list('1=Combo Item 1', '2=Combo Item 2', '3=Combo Item 3', '4=Combo Item 4', 83 | 'dropdown=yes', 'expand=horizontal', 'value=1'), 84 | viup.list('1=Editable Item 1', '2=Editable Item 2', '3=Editable Item 3', 85 | '4=Editable Item 4', 'dropdown=yes', 'editbox=yes', 'expand=horizontal', 86 | 'value=1'), 87 | viup.radio_group(viup.vbox([ 88 | viup.toggle('Radio 1'), 89 | viup.toggle('Radio 2'), 90 | viup.toggle('Radio 3'), 91 | ])), 92 | ]), 'title=Lists', 'margin=10x10'), 93 | viup.tabs([ 94 | viup.hbox([ 95 | viup.label('In tab 1'), 96 | viup.fill(), 97 | ], 'tabtitle=Tab 1'), 98 | viup.hbox([ 99 | viup.label('In tab 2'), 100 | ], 'tabtitle=Tab 2'), 101 | viup.hbox([ 102 | viup.label('In tab 3'), 103 | ], 'tabtitle=Tab 3'), 104 | ]), 105 | ], 'gap=10'), 106 | ], 'margin=10x10') 107 | 108 | // Create our window to display - size will be 109 | // automatically calculated by components 110 | 111 | dialog := viup.dialog(viup.scroll(hbox), 'MainWindow', 'title=Control Gallery') 112 | dialog.set_menu('app_menu', menu) 113 | dialog.show_xy(viup.pos_center, viup.pos_center) 114 | 115 | viup.main_loop() 116 | viup.close() 117 | } 118 | 119 | // menu_clicked handles when different menu items are clicked 120 | fn menu_clicked(control &viup.Control) viup.FuncResult { 121 | name := control.get_attr('name') 122 | match name { 123 | 'MenuAbout' { 124 | viup.message_dialog('title=About', 'value=$about', 'dialogtype=information').popup(viup.pos_current, 125 | viup.pos_current) 126 | } 127 | 'MenuExit' { 128 | return .close 129 | } 130 | 'MenuOpen' { 131 | dialog := viup.file_dialog('title=Open file...') 132 | dialog.popup(viup.pos_current, viup.pos_current) 133 | 134 | if dialog.get_int('status') == 0 { 135 | value := dialog.get_attr('value') 136 | 137 | viup.message_dialog('title=File Opened', "value=The file '$value' was opened.", 138 | 'dialogtype=information').popup(viup.pos_current, viup.pos_current) 139 | } 140 | } 141 | 'MenuDebugControl' { 142 | focused := viup.get_focused() 143 | focused.debug_props() 144 | } 145 | 'MenuDebugWindow' { 146 | window := viup.get_handle('MainWindow') 147 | window.debug() // when autofree is enabled this will cause a crash as the mainwindow will go out of scope and be freed 148 | } 149 | 'MenuRepository' { 150 | viup.help('https://github.com/kjlaw89/viup') 151 | } 152 | 'MenuSave' { 153 | dialog := viup.file_dialog('title=Save file...', 'dialogtype=save') 154 | dialog.popup(viup.pos_current, viup.pos_current) 155 | 156 | if dialog.get_int('status') != -1 { 157 | value := dialog.get_attr('value') 158 | 159 | viup.message_dialog('buttons=OKCANCEL', 'dialogtype=warning', 'title=File Save', 160 | "value=The file '$value' was not actually saved, but this is where you would do it.").popup(viup.pos_current, 161 | viup.pos_current) 162 | } 163 | } 164 | else { 165 | println('Menu $name') 166 | } 167 | } 168 | 169 | return .cont 170 | } 171 | 172 | // numbers_changed handles when the spinner or slider are updated 173 | // and links all three controls together automatically 174 | fn numbers_changed(control &viup.Control) viup.FuncResult { 175 | value := control.get_attr('value') 176 | viup.get_handle('spin1').set_attr('value', value.int().str()) 177 | viup.get_handle('slider1').set_attr('value', value) 178 | viup.get_handle('progress1').set_attr('value', value) 179 | 180 | return .cont 181 | } 182 | 183 | // button_clicked shows a dialog when the test button is clicked 184 | fn button_clicked(control &viup.Control) viup.FuncResult { 185 | viup.message('Button Click', 'Button clicked!') 186 | return .cont 187 | } 188 | 189 | // font_button_clicked shows a font dialog when the font button is clicked 190 | fn font_button_clicked(control &viup.Control) viup.FuncResult { 191 | font := control.get_font().show_picker() 192 | control.set_font(font).set_attr('title', font.face) 193 | 194 | return .cont 195 | } 196 | 197 | // color_button_clicked shows a color dialog when the color button is clicked 198 | fn color_button_clicked(control &viup.Control) viup.FuncResult { 199 | color, table := control.get_bgcolor().show_picker() 200 | println(table) 201 | control.set_bgcolor(color) 202 | 203 | return .cont 204 | } 205 | -------------------------------------------------------------------------------- /_docs/viup.image.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | viup.image | vdoc 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 49 |
50 |
51 |
52 |
53 |

viup.image #

54 | 55 |
56 | 57 |
58 |

fn load_animation #

fn load_animation(path string) ?&viup.Control
59 | 60 | 61 |
62 |
63 |

fn new_grayscale #

fn new_grayscale(width int, height int, pixels []byte) &viup.Control
64 | 65 | 66 |
67 |
68 |

fn new_rgb #

fn new_rgb(width int, height int, pixels []byte) &viup.Control
69 | 70 | 71 |
72 |
73 |

fn new_rgba #

fn new_rgba(width int, height int, pixels []byte) &viup.Control
74 | 75 | 76 |
77 |
78 |

fn load #

fn load(path string, attrs ...string) ?&viup.Control
79 | 80 | 81 |
82 | 83 | 86 |
87 |
103 |
104 |
105 |
106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /_docs/viup.gl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | viup.gl | vdoc 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 49 |
50 |
51 |
52 |
53 |

viup.gl #

54 | 55 |
56 | 57 |
58 |

fn is_current #

fn is_current(control &viup.Control) bool
59 | 60 | 61 |
62 |
63 |

fn make_current #

fn make_current(control &viup.Control) &viup.Control
64 | 65 | 66 |
67 |
68 |

fn set_palette #

fn set_palette(control &viup.Control, index int, r f32, g f32, b f32) &viup.Control
69 | 70 | 71 |
72 |
73 |

fn swap #

fn swap(control &viup.Control) &viup.Control
74 | 75 | 76 |
77 |
78 |

fn wait #

fn wait(is_gl bool)
79 | 80 | 81 |
82 |
83 |

fn create_context #

fn create_context(attrs ...string) &viup.Control
84 | 85 | 86 |
87 | 88 | 91 |
92 |
111 |
112 |
113 |
114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /_docs/doc.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | if (document.body.scrollIntoView) { 3 | var docnav = document.querySelector('.doc-nav'); 4 | var active = docnav.querySelector('li.active'); 5 | if (active) { 6 | active.scrollIntoView({ block: 'center', inline: 'nearest' }); 7 | } 8 | } 9 | setupScrollSpy(); 10 | setupMobileToggle(); 11 | setupDarkMode(); 12 | setupSearch(); 13 | setupCollapse(); 14 | })(); 15 | 16 | function setupScrollSpy() { 17 | var sectionPositions = []; 18 | var sections = document.querySelectorAll('section'); 19 | sections.forEach(function(section) { 20 | sectionPositions.push(section.offsetTop); 21 | }); 22 | var scrollPos = 0; 23 | window.addEventListener('scroll', function(e) { 24 | // Reset classes 25 | document.querySelectorAll('.doc-toc a[class="active"]').forEach(function(link) { 26 | link.classList.remove('active'); 27 | }); 28 | // Set current menu link as active 29 | var scrollPosition = document.documentElement.scrollTop || document.body.scrollTop; 30 | for (var i = 0; i < sectionPositions.length; i++) { 31 | var section = sections[i]; 32 | var position = sectionPositions[i]; 33 | if (position >= scrollPosition) { 34 | var link = document.querySelector('.doc-toc a[href="#' + section.id + '"]'); 35 | if (link) { 36 | link.classList.add('active'); 37 | var docToc = document.querySelector('.doc-toc'); 38 | var tocHeight = docToc.clientHeight; 39 | var scrollTop = docToc.scrollTop; 40 | if ((document.body.getBoundingClientRect()).top < scrollPos && scrollTop < link.offsetTop - 10) { 41 | docToc.scrollTop = link.clientHeight + link.offsetTop - tocHeight + 10; 42 | } else if (scrollTop > link.offsetTop - 10) { 43 | docToc.scrollTop = link.offsetTop - 10; 44 | } 45 | } 46 | break; 47 | } 48 | } 49 | scrollPos = (document.body.getBoundingClientRect()).top; 50 | }); 51 | } 52 | 53 | function setupMobileToggle() { 54 | var toggle = document.getElementById('toggle-menu'); 55 | toggle.addEventListener('click', function(ev) { 56 | var docNav = document.querySelector('.doc-nav'); 57 | var isHidden = docNav.classList.contains('hidden'); 58 | docNav.classList.toggle('hidden'); 59 | var search = document.querySelector('.doc-nav > .search'); 60 | console.log(search); 61 | var searchHasResults = search.classList.contains('has-results'); 62 | if (isHidden && searchHasResults) { 63 | search.classList.remove('mobile-hidden'); 64 | } else { 65 | search.classList.add('mobile-hidden'); 66 | } 67 | var content = document.querySelector('.doc-nav .content'); 68 | content.classList.toggle('hidden'); 69 | content.classList.toggle('show'); 70 | }); 71 | } 72 | 73 | function setupDarkMode() { 74 | var html = document.getElementsByTagName('html')[0]; 75 | var darkModeToggle = document.getElementById('dark-mode-toggle'); 76 | darkModeToggle.addEventListener('click', function() { 77 | html.classList.toggle('dark'); 78 | var isDarkModeEnabled = html.classList.contains('dark'); 79 | localStorage.setItem('dark-mode', isDarkModeEnabled); 80 | darkModeToggle.setAttribute('aria-checked', isDarkModeEnabled) 81 | }); 82 | // Check if css var() is supported and enable dark mode toggle 83 | if (window.CSS && CSS.supports('color', 'var(--fake-var)')) { 84 | darkModeToggle.style.visibility = 'unset'; 85 | } 86 | } 87 | 88 | function setupSearch() { 89 | var searchInput = document.getElementById('search'); 90 | var onInputChange = debounce(function(e) { 91 | var searchValue = e.target.value.toLowerCase(); 92 | var menu = document.querySelector('.doc-nav > .content'); 93 | var search = document.querySelector('.doc-nav > .search'); 94 | if (searchValue === '') { 95 | // reset to default 96 | menu.style.display = ''; 97 | if (!search.classList.contains('hidden')) { 98 | search.classList.add('hidden'); 99 | search.classList.remove('has-results'); 100 | } 101 | } else if (searchValue.length > 2) { 102 | // search for less than 3 characters can display too much results 103 | search.innerHTML = ''; 104 | menu.style.display = 'none'; 105 | if (search.classList.contains('hidden')) { 106 | search.classList.remove('hidden'); 107 | search.classList.remove('mobile-hidden'); 108 | search.classList.add('has-results'); 109 | } 110 | // cache length for performance 111 | var foundModule = false; 112 | var searchModuleIndexLength = searchModuleIndex.length; 113 | var ul = document.createElement('ul'); 114 | search.appendChild(ul); 115 | for (var i = 0; i < searchModuleIndexLength; i++) { 116 | // no toLowerCase needed because modules are always lowercase 117 | var title = searchModuleIndex[i]; 118 | if (title.indexOf(searchValue) === -1) { 119 | continue 120 | } 121 | foundModule = true; 122 | // [description, link] 123 | var data = searchModuleData[i]; 124 | var description = data[0]; 125 | var link = data[1]; 126 | var el = createSearchResult({ 127 | link: link, 128 | title: title, 129 | description: description, 130 | badge: 'module', 131 | }); 132 | ul.appendChild(el); 133 | } 134 | if (foundModule) { 135 | var hr = document.createElement('hr'); 136 | hr.classList.add('separator'); 137 | search.appendChild(hr); 138 | } 139 | var searchIndexLength = searchIndex.length; 140 | var results = []; 141 | for (var i = 0; i < searchIndexLength; i++) { 142 | var title = searchIndex[i]; 143 | if (title.toLowerCase().indexOf(searchValue) === -1) { 144 | continue 145 | } 146 | // [badge, description, link] 147 | var data = searchData[i]; 148 | var badge = data[0]; 149 | var description = data[1]; 150 | var link = data[2]; 151 | var prefix = data[3]; 152 | results.push({ 153 | badge: badge, 154 | description: description, 155 | link: link, 156 | title: prefix + ' ' + title, 157 | }); 158 | } 159 | results.sort(function(a, b) { 160 | if (a.title < b.title) { 161 | return -1; 162 | } 163 | if (a.title > b.title) { 164 | return 1; 165 | } 166 | return 0; 167 | }); 168 | var ul = document.createElement('ul'); 169 | search.appendChild(ul); 170 | for (var i = 0; i < results.length; i++) { 171 | var result = results[i]; 172 | var el = createSearchResult(result); 173 | ul.appendChild(el); 174 | } 175 | } 176 | }); 177 | searchInput.addEventListener('input', onInputChange); 178 | } 179 | 180 | function createSearchResult(data) { 181 | var li = document.createElement('li'); 182 | li.classList.add('result'); 183 | var a = document.createElement('a'); 184 | a.href = data.link; 185 | a.classList.add('link'); 186 | li.appendChild(a); 187 | var defintion = document.createElement('div'); 188 | defintion.classList.add('definition'); 189 | a.appendChild(defintion); 190 | if (data.description) { 191 | var description = document.createElement('div'); 192 | description.classList.add('description'); 193 | description.textContent = data.description; 194 | a.appendChild(description); 195 | } 196 | var title = document.createElement('span'); 197 | title.classList.add('title'); 198 | title.textContent = data.title; 199 | defintion.appendChild(title); 200 | var badge = document.createElement('badge'); 201 | badge.classList.add('badge'); 202 | badge.textContent = data.badge; 203 | defintion.appendChild(badge); 204 | return li; 205 | } 206 | 207 | function setupCollapse() { 208 | var dropdownArrows = document.querySelectorAll('.dropdown-arrow'); 209 | for (var i = 0; i < dropdownArrows.length; i++) { 210 | var dropdownArrow = dropdownArrows[i]; 211 | dropdownArrow.addEventListener('click', function(e) { 212 | var parent = e.target.parentElement.parentElement.parentElement; 213 | parent.classList.toggle('open'); 214 | }); 215 | } 216 | } 217 | 218 | function debounce(func, timeout) { 219 | var timer; 220 | return (...args) => { 221 | const next = () => func(...args); 222 | if (timer) { 223 | clearTimeout(timer); 224 | } 225 | timer = setTimeout(next, timeout > 0 ? timeout : 300); 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

VIUP

3 |
4 | 5 | VIUP is a work-in-progress V wrapper for the C-based cross-platform UI library, [IUP](http://webserver2.tecgraf.puc-rio.br/iup/). The aim of this 6 | library is to provide a thorough implementation of IUP in V. The implmentation is faithful to the original API but takes some liberties to provide 7 | a native "V" feel and modernizes some of the calls. 8 | 9 |
10 | Windows Gallery Example 11 | Linux (Ubuntu) Gallery Example 12 |
13 | 14 | ## Features 15 | 16 | - [x] image 17 | - [x] load image 18 | - [x] convert image to native 19 | - [x] convert native to image 20 | - [x] basic controls 21 | - [x] containers 22 | - [x] dialogs 23 | - [ ] gl 24 | - [x] gl rendering 25 | - [ ] gl controls 26 | - [ ] scintilla 27 | - [ ] plot 28 | - [ ] extra controls 29 | - [ ] clipboard 30 | - [ ] browser 31 | 32 | ## Setup 33 | 34 | 1. Download the appropriate runtime libraries for your Operating system: https://sourceforge.net/projects/iup/files/3.30/ 35 | 2. If using image functions, download `IM` runtime libraries: http://webserver2.tecgraf.puc-rio.br/im/ 36 | 37 | ### Windows install 38 | 39 | Copy all applicable DLLs from Zip to binary directory. By default, only `iup.dll` is required. If using image functions, `iup_im.dll` is required as 40 | well as all of the DLLs frmo the `IM` library. 41 | 42 | #### Windows App Manifest 43 | 44 | Windows UI apps need to be built with a Manifest. This manifest includes details about the app such as the name, version, and characteristics. VIUP 45 | includes a basic manifest with the gallery that can be easily modified. The generated `manifest.syso` needs to be in the directory during build but 46 | does not need to be distributed with your application. 47 | 48 | To update the manifest: 49 | 50 | `cd winmanifest` 51 | `windres -i resources.rc -o manifest.syso -O coff` 52 | 53 | Copy manifest.syso to application directory. 54 | 55 | _Note: Currently running `v .` or `v run .` will not find the `.syso` file correctly. To include it in your project, add a `#flag windows "path\\to\\file\\manifest.syso` to the top of your application._ 56 | 57 | ### Linux install 58 | 59 | Extract runtime libraries to a folder and run `sudo ./install` to install libraries. 60 | 61 | #### Libraries Path 62 | 63 | I've noticed in testing that the libraries are installed to `/usr/lib64`. It does not appear that they are picked up by the compiler there. Copying from 64 | that folder to `/usr/lib` resolves the problem. This may not be necessary in all cases. 65 | 66 | ### Notes about dependencies 67 | 68 | This repo comes with a copy of the headers for the version of IUP that it was developed against (3.30), but does not ship with the runtime libraries. It is *not* necessary to get the IM library runtime if you do not plan to use it in your application. 69 | 70 | By default VIUP only initializes the subsystems that are imported. For example, importing just `viup` only initializes the standard dialogs, containers, and components. 71 | 72 | If an extension library is loaded (`viup.image`), the required runtime binaries must be installed or provided along with the build. 73 | 74 | ## Example 75 | 76 | This repo comes with a simple application that demos all of the available controls. This app is available in the "examples/gallery". It requires the IM libraries. Once all runtime libraries are in the folder, run the example with `v run .`. 77 | 78 | ## Using VIUP 79 | 80 | One of the strengths of IUP is that is it a very simple library. All controls are instances of `&Control` and share the same methods, though not all methods are applicable to a Control. Adjusting settings for a control is as simple as calling `set_attr` or providing the attributes when initializing the Control. 81 | 82 | Here's a basic example of initializing a simple window: 83 | 84 | ```v 85 | viup. 86 | dialog(viup.scroll(hbox), "title=Control Gallery") // Create our dialog with "Control Gallery" as the title and a scrollable Control 87 | .set_handle("MainWindow") // Define a global ID for our Window 88 | .set_menu("app_menu", menu) // Set an app menu if applicable 89 | .show_xy(viup.Pos.center, viup.Pos.center) // Display dialog in center of screen 90 | ``` 91 | 92 | ### Autofree 93 | 94 | VIUP should work with V's autofree, however, there are a few situations that can cause crashes. If a Control is accessed by calling `get_focused` or `get_handle`, 95 | the resulting variable, once it goes out of scope, will free the control that was restored by those functions. This may crash the application. For now if those 96 | methods are used, add `[manualfree]` to the method and call `free()` on the Controls within as necessary. 97 | 98 | ### Attributes 99 | 100 | All controls can be passed attributes as the last parameters when creating a Control. Any amount of attributes can provided. Attributes can adjust the various characteristics of a Control such as the title, value(s), background or foreground colors, control sub-type, sizing, etc. 101 | 102 | Not all available attributes apply to each control. If an invalid attribute is provided it is actually accessible via `get_attr` but will not affect the control itself. Read up more on attributes in the [IUP Documentation](http://webserver2.tecgraf.puc-rio.br/iup/). 103 | 104 | Example: 105 | 106 | ```v 107 | viup.list( 108 | "List", // control 'name' 109 | "1=Combo Item 1", // Attr 1: Slot 1 is 'Combo Item 1' 110 | "2=Combo Item 2", // Attr 2: Slot 2 is 'Combo Item 2' 111 | "3=Combo Item 3", // .... 112 | "4=Combo Item 4", // .... 113 | "dropdown=yes", // Attr 5: List is a dropdown 114 | "expand=horizontal", // Attr 6: Expand horizontally 115 | "value=1" // Attr 7: Set default value to Slot 1 116 | ) 117 | ``` 118 | 119 | ### Callbacks & Events 120 | 121 | All controls have callback methods available for various events. Each callback method starts with `on_` and can be quickly chained to add multiple callbacks. 122 | 123 | Example: 124 | 125 | ```v 126 | viup.button("Button", "action").on_action(button_clicked) 127 | 128 | fn button_clicked(control &viup.Control) viup.FuncResult { 129 | viup.message("Button Click", "Button clicked!") 130 | return .cont 131 | } 132 | ``` 133 | 134 | In the example above, a `Button` control is initialized with "Button" for the title. An `action` callback is added with `on_action(button_clicked)`. `button_clicked` is an `ActionFunc` callback and is automatically called when the button is clicked. VIUP mirrors the callbacks that IUP provides pretty closely, typically adding `Func` on the end for consistency. 135 | 136 | The majority of callback functions can return a `viup.FuncResult`. This result can be one of the following: 137 | 138 | - `cont` - continue action 139 | - `close` - close the application 140 | - `default` - perform default action (may be equivalent to `cont` in most cases) 141 | - `ignore` - ignores event and may stop propagation 142 | 143 | ### Chaining 144 | 145 | Most Control methods will return back the Control when finished. This makes it easy to chain several method calls together. 146 | 147 | Example: 148 | 149 | ```v 150 | viup 151 | .message_dialog( 152 | "title=About", 153 | "value=$about", 154 | "dialogtype=information" 155 | ) // Create a message dialog with attributes "title", "value", and "dialogtype" 156 | .popup(viup.Pos.current, viup.Pos.current) // Popup dialog to user 157 | .destroy() // Destroy dialog when closed 158 | ``` 159 | 160 | Example 2: 161 | 162 | ```v 163 | viup 164 | .button("Set font...", "", "expand=horizontal") // Create button with "Set font..." as title 165 | .set_handle("font_btn") // Set a handle name 166 | .on_action(font_button_clicked) // Set a Action callback 167 | ``` 168 | 169 | _Note: Dialogs return back an struct of `Dialog`. This struct has a few unique functions associated with it (i.e. `popup`, `show`, `show_xy`). It's not 170 | to chain to these methods from regular `Control` methods._ 171 | 172 | ### Controls 173 | 174 | All dialog, layouts and elements are "Controls" in IUP. As such, they all share common methods that can be utilized by any Control. 175 | 176 | Most used component methods: 177 | 178 | Method | Description 179 | ------- | ------------ 180 | `get_attr` / `set_attr` | Get or set an attribute value on the control. 181 | `set_attrs` | Used to set multiple attributes in a single call 182 | `set_handle` | Assigns this control a name on the global level. This is typically used in combination with `viup.get_handle` to restore the control in callbacks or other functions 183 | `get_font` / `set_font` | Get or set a `Font` 184 | `refresh` / `refresh_children` | Trigger a redraw for this component and/or its children 185 | 186 | ### Dialog Controls 187 | 188 | Function | Description 189 | -------- | ----------- 190 | `color_dialog(...attrs)` | Opens a color picker with optional color palette 191 | `dialog(child, attrs)` | Creates a standard Window or modal dialog 192 | `file_dialog(...attrs)` | Open a file chooser. This can be used to open or save files 193 | `font_dialog(...attrs)` | Opens a font picker 194 | `message_dialog(...attrs)` | Opens a customizable message modal 195 | `message(title, message)` | Shows a generic message box with a standard "OK" button to close 196 | 197 | ### Container Controls 198 | 199 | Function | Description 200 | -------- | ----------- 201 | `background(child, attrs)` | A simple container element that is designed to have a background color or image 202 | `detach_box(child, attrs)` | Container that is designed to be detachable from the parent container when needed. Can also be reattached. 203 | `fill(...attrs)` | Fills the remaining space for the parent container 204 | `flat_frame(child, attrs)` | Standard frame that allows custom rendering 205 | `flat_scroll(child, attrs)` | Standard scroll that allows custom rendering 206 | `frame(child, attrs)` | Container that puts a border around its children with an optional title 207 | `grid(children, attrs)` | Multi-control container that lays out its children in a table-like design 208 | `hbox(children, attrs)` | Multi-control container that lays out its children in a row 209 | `menu(children, attrs)` | Multi-control container for a dialog's menu items 210 | `radio_group(child, attrs)` | Container is used to group `toggle`s together into a radio button group 211 | `tabs(children, attrs)` | Multi-control container for tabbed content 212 | `vbox(children, attrs)` | Multi-control container that lays out its children in a column 213 | 214 | ### Standard Controls 215 | 216 | Function | Description 217 | -------- | ----------- 218 | `animated_label(animation, attrs)` | Creates a control that can display an animation 219 | `button(title, action, attrs)` | Creates a standard button with `title` for the text 220 | `canvas(action, attrs)` | A control that can be used to render custom content 221 | `divider(...attrs)` | Draws a horizontal or vertical line (horizontal by default) 222 | `label(title, attrs)` | A simple control to show text or images 223 | `link(url, title, attrs)` | Similar to a label, can be used to link to an external source 224 | `list(action, attrs)` | Creates a component that can be used to list multiple values 225 | `menu_item(action, attrs)` | Used in the `menu` component as a specific action (e.g. "Open File..." or "About") 226 | `menu_sep(...attrs)` | Create a simple horizontal line in a `menu` 227 | `multiline(action, attrs)` | Creates a multiline chooser component 228 | `progress(...attrs)` | Basic progressbar component 229 | `slider(orientation, attrs)` | Creates a number-line slider component 230 | `sub_menu(title, child, attrs)` | Creates a sub menu component. Sub-menues are children of `menu` components. Typically structured like: Menu -> Sub-menu -> Menu -> Menu Item. 231 | `text(action, attrs)` | Creates a standard text-input control. Can be set as multi-line, number input, etc. 232 | `toggle(title, action, attrs)` | A radio or checkbox component. Defaults to radio when in a `radio_group`. 233 | 234 | ## Contributing / Support 235 | 236 | This project was developed as a way of improving my understanding of V & C. I will not be providing active support for the project, but I'll happily accept any pull requests. Use at your own discretion! -------------------------------------------------------------------------------- /callbacks.v: -------------------------------------------------------------------------------- 1 | module viup 2 | 3 | fn C.IupSetCallback(voidptr, charptr, VIUPCallback) 4 | fn C.IupSetFunction(charptr, VIUPCallback) 5 | 6 | pub type ActionFunc = fn (&Control) FuncResult 7 | 8 | pub type BranchOpenFunc = fn (&Control, int) FuncResult 9 | 10 | pub type BranchCloseFunc = fn (&Control, int) FuncResult 11 | 12 | pub type ButtonFunc = fn (&Control) FuncResult 13 | 14 | pub type ButtonPressFunc = fn (&Control, f64) FuncResult 15 | 16 | pub type ButtonReleaseFunc = fn (&Control, f64) FuncResult 17 | 18 | pub type CaretFunc = fn (&Control, int, int, int) FuncResult 19 | 20 | pub type CellFunc = fn (&Control, int) FuncResult 21 | 22 | pub type ChangeFunc = fn (&Control, byte, byte, byte) FuncResult 23 | 24 | pub type DblClickFunc = fn (&Control, int, charptr) FuncResult 25 | 26 | pub type DestroyFunc = fn (&Control) FuncResult 27 | 28 | pub type DetachedFunc = fn (&Control, &Control, int, int) FuncResult 29 | 30 | pub type DragFunc = fn (&Control, byte, byte, byte) FuncResult 31 | 32 | pub type DragDropFunc = fn (&Control, int, int, int, int) FuncResult 33 | 34 | pub type DrawFunc = fn (&Control, f32, f32) FuncResult 35 | 36 | pub type DropDownFunc = fn (&Control, int) FuncResult 37 | 38 | pub type DropFilesFunc = fn (&Control, charptr, int, int, int) FuncResult 39 | 40 | pub type EditFunc = fn (&Control, int, charptr) FuncResult 41 | 42 | pub type EnteredFunc = fn (&Control) FuncResult 43 | 44 | pub type EntryFunc = fn () 45 | 46 | pub type ExecuteBranchFunc = fn (&Control, int) FuncResult 47 | 48 | pub type ExecuteLeafFunc = fn (&Control, int) FuncResult 49 | 50 | pub type ExitFunc = fn () 51 | 52 | pub type ExitedFunc = fn (&Control) FuncResult 53 | 54 | pub type ExtendedFunc = fn (&Control) FuncResult 55 | 56 | pub type ExtraButtonFunc = fn (&Control, int, bool) FuncResult 57 | 58 | pub type FlatActionFunc = fn (&Control) FuncResult 59 | 60 | pub type FocusedFunc = fn (&Control) FuncResult 61 | 62 | pub type HelpFunc = fn (&Control) FuncResult 63 | 64 | pub type IdleFunc = fn () 65 | 66 | pub type KeyFunc = fn (&Control, int) FuncResult 67 | 68 | pub type KeyPressFunc = fn (&Control, int, int) FuncResult 69 | 70 | pub type LayoutUpdateFunc = fn (&Control) FuncResult 71 | 72 | pub type MapFunc = fn (&Control) int 73 | 74 | pub type MotionFunc = fn (&Control, int, int, charptr) FuncResult 75 | 76 | pub type MouseButtonFunc = fn (&Control, MouseButton, bool, int, int, charptr) FuncResult 77 | 78 | pub type MouseMoveFunc = fn (&Control, f64) FuncResult 79 | 80 | pub type MultiSelectFunc = fn (&Control, charptr) FuncResult 81 | 82 | pub type MultiSelectionFunc = fn (&Control, voidptr, int) FuncResult 83 | 84 | pub type MultiUnselectionFunc = fn (&Control, voidptr, int) FuncResult 85 | 86 | pub type NodeRemovedFunc = fn (&Control, voidptr) FuncResult 87 | 88 | pub type MenuCloseFunc = fn (&Control) FuncResult 89 | 90 | pub type MenuOpenFunc = fn (&Control) FuncResult 91 | 92 | pub type OpenCloseFunc = fn (&Control, int) FuncResult 93 | 94 | pub type RenameFunc = fn (&Control, int, charptr) FuncResult 95 | 96 | pub type ResizeFunc = fn (&Control, int, int) FuncResult 97 | 98 | pub type RestoredFunc = fn (&Control, &Control, int, int) FuncResult 99 | 100 | pub type RightClickFunc = fn (&Control, int) FuncResult 101 | 102 | pub type SelectFunc = fn (&Control, int, int) FuncResult 103 | 104 | pub type SelectionFunc = fn (&Control, int, int) FuncResult 105 | 106 | pub type ShowRenameFunc = fn (&Control, int) FuncResult 107 | 108 | pub type ScrollFunc = fn (&Control, int, f32, f32) FuncResult 109 | 110 | pub type SpinFunc = fn (&Control, int) FuncResult 111 | 112 | pub type SwitchFunc = fn (&Control, int, int) FuncResult 113 | 114 | pub type TabChangeFunc = fn (&Control, &Control, &Control) FuncResult 115 | 116 | pub type TabChangePosFunc = fn (&Control, int, int) FuncResult 117 | 118 | pub type TabCloseFunc = fn (&Control, int) FuncResult 119 | 120 | pub type ToggleValueFunc = fn (&Control, int, int) FuncResult 121 | 122 | pub type UnfocusedFunc = fn (&Control) 123 | 124 | pub type UnmapFunc = fn (&Control) FuncResult 125 | 126 | pub type ValueChangedFunc = fn (&Control) FuncResult 127 | 128 | pub type ValueChangingFunc = fn (&Control, int) FuncResult 129 | 130 | pub type WheelFunc = fn (&Control, f32, int, int, charptr) FuncResult 131 | 132 | // on_action is triggered when the primary function of the element is performed (e.g. clicking a button) 133 | pub fn (control &Control) on_action(func ActionFunc) &Control { 134 | C.IupSetCallback(control, 'ACTION', func) 135 | return control 136 | } 137 | 138 | pub fn (control &Control) on_branch_open(func BranchOpenFunc) &Control { 139 | C.IupSetCallback(control, 'BRANCHOPEN_CB', func) 140 | return control 141 | } 142 | 143 | pub fn (control &Control) on_branch_close(func BranchCloseFunc) &Control { 144 | C.IupSetCallback(control, 'BRANCHCLOSE_CB', func) 145 | return control 146 | } 147 | 148 | // on_button occurs when a button is clicked 149 | pub fn (control &Control) on_button(func ButtonFunc) &Control { 150 | C.IupSetCallback(control, 'BUTTON_CB', func) 151 | return control 152 | } 153 | 154 | // on_button_press occurs when a button is pressed, but not released 155 | pub fn (control &Control) on_button_press(func ButtonPressFunc) &Control { 156 | C.IupSetCallback(control, 'BUTTON_PRESS_CB', func) 157 | return control 158 | } 159 | 160 | // on_button_release occurs when a button is pressed and then released 161 | pub fn (control &Control) on_button_release(func ButtonReleaseFunc) &Control { 162 | C.IupSetCallback(control, 'BUTTON_RELEASE_CB', func) 163 | return control 164 | } 165 | 166 | pub fn (control &Control) on_caret(func CaretFunc) &Control { 167 | C.IupSetCallback(control, 'CARET_CB', func) 168 | return control 169 | } 170 | 171 | pub fn (control &Control) on_cell(func CellFunc) &Control { 172 | C.IupSetCallback(control, 'CELL_CB', func) 173 | return control 174 | } 175 | 176 | // on_change occurs when the value in an input is changed 177 | pub fn (control &Control) on_change(func ChangeFunc) &Control { 178 | C.IupSetCallback(control, 'CHANGE_CB', func) 179 | return control 180 | } 181 | 182 | // on_dbl_click occurs when an element is double-clicked 183 | pub fn (control &Control) on_dbl_click(func DblClickFunc) &Control { 184 | C.IupSetCallback(control, 'DBLCLICK_CB', func) 185 | return control 186 | } 187 | 188 | // on_destroy occurs when an element is freed 189 | pub fn (control &Control) on_destroy(func DestroyFunc) &Control { 190 | C.IupSetCallback(control, 'DESTROY_CB', func) 191 | return control 192 | } 193 | 194 | pub fn (control &Control) on_detached(func DetachedFunc) &Control { 195 | C.IupSetCallback(control, 'DETACHED_CB', func) 196 | return control 197 | } 198 | 199 | // on_drag occurs when an element is being dragged 200 | pub fn (control &Control) on_drag(func DragFunc) &Control { 201 | C.IupSetCallback(control, 'DRAG_CB', func) 202 | return control 203 | } 204 | 205 | // on_drag_drop occurs when an element is dragged and then dropped 206 | pub fn (control &Control) on_drag_drop(func DragDropFunc) &Control { 207 | C.IupSetCallback(control, 'DRAGDROP_CB', func) 208 | return control 209 | } 210 | 211 | // on_draw occurs when an element needs to be redrawn (applies to Canvas elements) 212 | pub fn (control &Control) on_draw(func DrawFunc) &Control { 213 | C.IupSetCallback(control, 'ACTION', func) 214 | return control 215 | } 216 | 217 | pub fn (control &Control) on_drop_down(func DropDownFunc) &Control { 218 | C.IupSetCallback(control, 'DROPDOWN_CB', func) 219 | return control 220 | } 221 | 222 | pub fn (control &Control) on_drop_files(func DropFilesFunc) &Control { 223 | C.IupSetCallback(control, 'DROPFILES_CB', func) 224 | return control 225 | } 226 | 227 | // on_edit occurs when an element is being edited 228 | pub fn (control &Control) on_edit(func EditFunc) &Control { 229 | C.IupSetCallback(control, 'EDIT_CB', func) 230 | return control 231 | } 232 | 233 | pub fn (control &Control) on_entered(func EnteredFunc) &Control { 234 | C.IupSetCallback(control, 'ENTERWINDOW_CB', func) 235 | return control 236 | } 237 | 238 | pub fn (control &Control) on_execute_branch(func ExecuteBranchFunc) &Control { 239 | C.IupSetCallback(control, 'EXECUTEBRANCH_CB', func) 240 | return control 241 | } 242 | 243 | pub fn (control &Control) on_execute_left(func ExecuteLeafFunc) &Control { 244 | C.IupSetCallback(control, 'EXECUTELEAF_CB', func) 245 | return control 246 | } 247 | 248 | pub fn (control &Control) on_exited(func ExitedFunc) &Control { 249 | C.IupSetCallback(control, 'LEAVEWINDOW_CB', func) 250 | return control 251 | } 252 | 253 | pub fn (control &Control) on_extended(func ExtendedFunc) &Control { 254 | C.IupSetCallback(control, 'EXTENDED_CB', func) 255 | return control 256 | } 257 | 258 | pub fn (control &Control) on_extra_button(func ExtraButtonFunc) &Control { 259 | C.IupSetCallback(control, 'EXTRABUTTON_CB', func) 260 | return control 261 | } 262 | 263 | pub fn (control &Control) on_flat_action(func FlatActionFunc) &Control { 264 | C.IupSetCallback(control, 'FLAT_ACTION', func) 265 | return control 266 | } 267 | 268 | // on_focused occurs when an element receives focus 269 | pub fn (control &Control) on_focused(func FocusedFunc) &Control { 270 | C.IupSetCallback(control, 'GETFOCUS_CB', func) 271 | return control 272 | } 273 | 274 | // on_help occurs when the focused element has the "help" method called on it 275 | pub fn (control &Control) on_help(func HelpFunc) &Control { 276 | C.IupSetCallback(control, 'HELP_CB', func) 277 | return control 278 | } 279 | 280 | // on_key occurs when any key is pressed down 281 | pub fn (control &Control) on_key(func KeyFunc) &Control { 282 | C.IupSetCallback(control, 'K_ANY', func) 283 | return control 284 | } 285 | 286 | // on_key_press occurs when a key is fully pressed and released 287 | pub fn (control &Control) on_key_press(func KeyPressFunc) &Control { 288 | C.IupSetCallback(control, 'KEYPRESS_CB', func) 289 | return control 290 | } 291 | 292 | pub fn (control &Control) on_map(func MapFunc) &Control { 293 | C.IupSetCallback(control, 'MAP_CB', func) 294 | return control 295 | } 296 | 297 | pub fn (control &Control) on_motion(func MotionFunc) &Control { 298 | C.IupSetCallback(control, 'MOTION_CB', func) 299 | return control 300 | } 301 | 302 | // on_mouse_button occurs when any mouse button is pressed 303 | pub fn (control &Control) on_mouse_button(func MouseButtonFunc) &Control { 304 | C.IupSetCallback(control, 'BUTTON_CB', func) 305 | return control 306 | } 307 | 308 | // on_mouse_move occurs whenever mouse movement has happened 309 | pub fn (control &Control) on_mouse_move(func MouseMoveFunc) &Control { 310 | C.IupSetCallback(control, 'MOUSEMOVE_CB', func) 311 | return control 312 | } 313 | 314 | pub fn (control &Control) on_multiselect(func MultiSelectFunc) &Control { 315 | C.IupSetCallback(control, 'MULTISELECT_CB', func) 316 | return control 317 | } 318 | 319 | pub fn (control &Control) on_multiselection(func MultiSelectionFunc) &Control { 320 | C.IupSetCallback(control, 'MULTISELECTION_CB', func) 321 | return control 322 | } 323 | 324 | pub fn (control &Control) on_multiunselect(func MultiUnselectionFunc) &Control { 325 | C.IupSetCallback(control, 'MULTIUNSELECTION_CB', func) 326 | return control 327 | } 328 | 329 | pub fn (control &Control) on_node_removed(func NodeRemovedFunc) &Control { 330 | C.IupSetCallback(control, 'NODEREMOVED_CB', func) 331 | return control 332 | } 333 | 334 | pub fn (control &Control) on_open_close(func OpenCloseFunc) &Control { 335 | C.IupSetCallback(control, 'OPENCLOSE_CB', func) 336 | return control 337 | } 338 | 339 | pub fn (control &Control) on_rename(func RenameFunc) &Control { 340 | C.IupSetCallback(control, 'RENAME_CB', func) 341 | return control 342 | } 343 | 344 | // on_resize occurs whenever an element is resized 345 | pub fn (control &Control) on_resize(func ResizeFunc) &Control { 346 | C.IupSetCallback(control, 'RESIZE_CB', func) 347 | return control 348 | } 349 | 350 | // on_right_click occurs whenever a right-click even is detected 351 | pub fn (control &Control) on_right_click(func RightClickFunc) &Control { 352 | C.IupSetCallback(control, 'RIGHTCLICK_CB', func) 353 | return control 354 | } 355 | 356 | pub fn (control &Control) on_restored(func RestoredFunc) &Control { 357 | C.IupSetCallback(control, 'RESTORED_CB', func) 358 | return control 359 | } 360 | 361 | // on_select occurs whenever a value is selected in an element 362 | pub fn (control &Control) on_select(func SelectFunc) &Control { 363 | C.IupSetCallback(control, 'SELECT_CB', func) 364 | return control 365 | } 366 | 367 | pub fn (control &Control) on_selection(func SelectionFunc) &Control { 368 | C.IupSetCallback(control, 'SELECTION_CB', func) 369 | return control 370 | } 371 | 372 | pub fn (control &Control) on_scroll(func ScrollFunc) &Control { 373 | C.IupSetCallback(control, 'SCROLL_CB', func) 374 | return control 375 | } 376 | 377 | pub fn (control &Control) on_show_rename(func ShowRenameFunc) &Control { 378 | C.IupSetCallback(control, 'SHOWRENAME_CB', func) 379 | return control 380 | } 381 | 382 | pub fn (control &Control) on_switch(func SwitchFunc) &Control { 383 | C.IupSetCallback(control, 'SWITCH_CB', func) 384 | return control 385 | } 386 | 387 | // on_tab_change occurs when a tab is selected 388 | pub fn (control &Control) on_tab_change(func TabChangeFunc) &Control { 389 | C.IupSetCallback(control, 'TABCHANGE_CB', func) 390 | return control 391 | } 392 | 393 | pub fn (control &Control) on_tab_change_pos(func TabChangePosFunc) &Control { 394 | C.IupSetCallback(control, 'TABCHANGEPOS_CB', func) 395 | return control 396 | } 397 | 398 | // on_tab_close occurs when a tab is closed 399 | pub fn (control &Control) on_tab_close(func TabCloseFunc) &Control { 400 | C.IupSetCallback(control, 'TABCLOSE_CB', func) 401 | return control 402 | } 403 | 404 | // on_toggle_value occurs when a toggle element is changed 405 | pub fn (control &Control) on_toggle_value(func ToggleValueFunc) &Control { 406 | C.IupSetCallback(control, 'TOGGLEVALUE_CB', func) 407 | return control 408 | } 409 | 410 | // on_unfocused occurs when an element loses focus 411 | pub fn (control &Control) on_unfocused(func UnfocusedFunc) &Control { 412 | C.IupSetCallback(control, 'KILLFOCUS_CB', func) 413 | return control 414 | } 415 | 416 | pub fn (control &Control) on_unmap(func UnmapFunc) &Control { 417 | C.IupSetCallback(control, 'UNMAP_CB', func) 418 | return control 419 | } 420 | 421 | // on_value_changed occurs when the value of an element is modified 422 | pub fn (control &Control) on_value_changed(func ValueChangedFunc) &Control { 423 | C.IupSetCallback(control, 'VALUECHANGED_CB', func) 424 | return control 425 | } 426 | 427 | // on_value_changing occurs when the value of an element is being actively changed 428 | // (but the element still has focus so 'change' has not happened) 429 | pub fn (control &Control) on_value_changing(func ValueChangingFunc) &Control { 430 | C.IupSetCallback(control, 'VALUECHANGING_CB', func) 431 | return control 432 | } 433 | 434 | // on_wheel occurs when the scroll wheel on the mouse is adjusted 435 | pub fn (control &Control) on_wheel(func WheelFunc) &Control { 436 | C.IupSetCallback(control, 'WHEEL_CB', func) 437 | return control 438 | } 439 | -------------------------------------------------------------------------------- /_docs/doc.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --background-color: #fff; 3 | --link-color: #2779bd; 4 | --text-color: #000; 5 | --ref-symbol-color: #dae1e7; 6 | --ref-symbol-hover-color: #b8c2cc; 7 | --title-bottom-line-color: #f1f5f8; 8 | --footer-top-line-color: #f1f5f8; 9 | --footer-text-color: #616161; 10 | --code-signature-border-color: #a0aec0; 11 | --menu-background-color: #4b6c88; 12 | --menu-text-color: #fff; 13 | --menu-indent-line-color: #3b3b3b66; 14 | --menu-indent-line-active-color: #00000066; 15 | --menu-scrollbar-color: #a0aec0; 16 | --menu-toggle-icon-color: #fff; 17 | --menu-toggle-icon-hover-color: #00000044; 18 | --menu-search-background-color: #00000044; 19 | --menu-search-font-color: #fff; 20 | --menu-search-result-background-hover-color: #00000021; 21 | --menu-search-separator-color: #00000044; 22 | --menu-search-title-text-color: #d5efff; 23 | --menu-search-badge-background-color: #00000044; 24 | --menu-search-badge-background-hover-color: #0000004d; 25 | --toc-text-color: #2779bd; 26 | --toc-indicator-color: #4299e1; 27 | --code-default-text-color: #5c6e74; 28 | --code-background-color: #edf2f7; 29 | --code-keyword-text-color: #2b6cb0; 30 | --code-builtin-text-color: #0a0a0a; 31 | --code-function-text-color: #319795; 32 | --code-comment-text-color: #93a1a1; 33 | --code-punctuation-text-color: #999999; 34 | --code-symbol-text-color: #702459; 35 | --code-operator-text-color: #a67f59; 36 | } 37 | :root.dark .dark-icon { 38 | display: none; 39 | } 40 | :root:not(.dark) .light-icon { 41 | display: none; 42 | } 43 | 44 | .dark body { 45 | --background-color: #1a202c; 46 | --text-color: #fff; 47 | --link-color: #90cdf4; 48 | --ref-symbol-color: #2d3748; 49 | --ref-symbol-hover-color: #4a5568; 50 | --title-bottom-line-color: #2d3748; 51 | --footer-top-line-color: #2d3748; 52 | --footer-text-color: #bbd3e1; 53 | --code-signature-border-color: #4a5568; 54 | --menu-background-color: #2d3748; 55 | --menu-text-color: #fff; 56 | --menu-indent-line-color: #4a5568; 57 | --menu-indent-line-active-color: #90cdf4; /*#4a5568*/ 58 | --menu-scrollbar-color: #4a5568; 59 | --menu-toggle-icon-color: #fff; 60 | --menu-search-background-color: #4a5568; 61 | --menu-search-font-color: #fff; 62 | --menu-search-separator-color: #4a5568; 63 | --menu-search-title-text-color: #90cdf4; 64 | --menu-search-badge-background-color: #4a5568; 65 | --menu-search-badge-background-hover-color: #4a5568; 66 | --toc-text-color: #90cdf4; 67 | --toc-indicator-color: #4299e1; 68 | --code-default-text-color: #cbd5e0; 69 | --code-background-color: #2d3748; 70 | --code-builtin-text-color: #68d391; 71 | --code-keyword-text-color: #63b3ed; 72 | --code-function-text-color: #4fd1c5; 73 | --code-comment-text-color: #a0aec0; 74 | --code-punctuation-text-color: #a0aec0; 75 | --code-symbol-text-color: #ed64a6; 76 | } 77 | html { 78 | height: 100%; 79 | } 80 | body { 81 | margin: 0; 82 | font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; 83 | background-color: #fff; 84 | background-color: var(--background-color); 85 | color: #000; 86 | color: var(--text-color); 87 | height: 100%; 88 | } 89 | #page { 90 | height: 100%; 91 | padding-top: 56px; 92 | box-sizing: border-box; 93 | overflow: hidden; 94 | } 95 | 96 | /** Reset for menus */ 97 | .doc-nav ul, 98 | .doc-toc ul { 99 | list-style: none; 100 | padding: 0; 101 | margin: 0; 102 | } 103 | 104 | /* Left nav */ 105 | .doc-nav { 106 | position: fixed; 107 | width: 100%; 108 | left: 0; 109 | right: 0; 110 | top: 0; 111 | display: flex; 112 | background-color: #4b6c88; 113 | background-color: var(--menu-background-color); 114 | color: #fff; 115 | color: var(--menu-text-color); 116 | flex-direction: column; 117 | overflow-y: auto; 118 | height: 100vh; 119 | z-index: 10; 120 | scrollbar-width: thin; 121 | scrollbar-color: #a0aec0 transparent; 122 | scrollbar-color: var(--menu-scrollbar-color) transparent; 123 | font-family: "Work Sans", sans-serif; 124 | } 125 | *::-webkit-scrollbar { 126 | width: 4px; 127 | height: 4px; 128 | } 129 | *::-webkit-scrollbar-track { 130 | background: transparent; 131 | } 132 | *::-webkit-scrollbar-thumb { 133 | background-color: #a0aec0; 134 | background-color: var(--menu-scrollbar-color); 135 | border: 3px solid transparent; 136 | } 137 | .doc-nav .content li { 138 | line-height: 1.8; 139 | } 140 | .doc-nav .content.show { 141 | display: flex; 142 | } 143 | .doc-nav .content.hidden { 144 | display: none; 145 | } 146 | .doc-nav #toggle-menu { 147 | cursor: pointer; 148 | padding: 0.3rem; 149 | fill: #fff; 150 | fill: var(--menu-toggle-icon-color); 151 | } 152 | .doc-nav > .heading-container { 153 | position: relative; 154 | /* IE11 */ 155 | position: sticky; 156 | position: -webkit-sticky; 157 | top: 0; 158 | background-color: #4b6c88; 159 | background-color: var(--menu-background-color); 160 | z-index: 10; 161 | } 162 | .doc-nav > .heading-container > .heading { 163 | display: flex; 164 | flex-direction: column; 165 | } 166 | .doc-nav > .heading-container > .heading > .info { 167 | display: flex; 168 | padding: 0 1rem; 169 | height: 56px; 170 | } 171 | .doc-nav > .heading-container > .heading > .info > .module { 172 | font-size: 1.6rem; 173 | font-weight: 500; 174 | margin: 0; 175 | } 176 | .doc-nav > .heading-container > .heading > .info > .toggle-version-container { 177 | display: flex; 178 | align-items: center; 179 | } 180 | .doc-nav > .heading-container > .heading > .info > .toggle-version-container > #dark-mode-toggle { 181 | cursor: pointer; 182 | fill: #fff; 183 | display: flex; 184 | visibility: hidden; 185 | } 186 | .doc-nav > .heading-container > .heading > .info > .toggle-version-container > #dark-mode-toggle > svg { 187 | width: 1.2rem; 188 | height: 1.2rem; 189 | } 190 | .doc-nav > .heading-container > .heading > #search { 191 | margin: 0.6rem 1.2rem 1rem 1.2rem; 192 | border: none; 193 | border-radius: 0.2rem; 194 | padding: 0.5rem 1rem; 195 | outline: none; 196 | background-color: #00000044; 197 | background-color: var(--menu-search-background-color); 198 | color: #fff; 199 | color: var(--menu-search-text-color); 200 | } 201 | .doc-nav > .heading-container > .heading > #search::placeholder { 202 | color: #edf2f7; 203 | text-transform: uppercase; 204 | font-size: 12px; 205 | font-weight: 600; 206 | } 207 | .doc-nav > .heading-container > .heading > #search:-ms-input-placeholder { 208 | color: #edf2f7; 209 | text-transform: uppercase; 210 | font-size: 12px; 211 | font-weight: 600; 212 | } 213 | .doc-nav > .content { 214 | padding: 0 2rem 2rem 2rem; 215 | display: flex; 216 | flex-direction: column; 217 | } 218 | .doc-nav > .content > ul > li.active { 219 | font-weight: 600; 220 | } 221 | .doc-nav > .content > ul > li.open ul { 222 | display: initial; 223 | } 224 | .doc-nav > .content > ul > li.open > .menu-row > .dropdown-arrow { 225 | transform: initial; 226 | } 227 | .doc-nav > .content > ul > li > .menu-row { 228 | display: flex; 229 | align-items: center; 230 | } 231 | .doc-nav > .content > ul > li > .menu-row > .dropdown-arrow { 232 | transform: rotate(-90deg); 233 | height: 18px; 234 | width: 18px; 235 | margin-left: calc(-18px - 0.3rem); 236 | margin-right: 0.3rem; 237 | cursor: pointer; 238 | fill: #fff; 239 | pointer-events: all; 240 | } 241 | .doc-nav > .content > ul > li > ul { 242 | margin: 0.4rem 0; 243 | display: none; 244 | } 245 | .doc-nav > .content > ul > li > ul > li { 246 | border-color: #ffffff66; 247 | border-color: var(--menu-indent-line-color); 248 | border-left-width: 1.7px; 249 | border-left-style: solid; 250 | padding-left: 0.7rem; 251 | } 252 | .doc-nav > .content > ul > li > ul > li.active { 253 | border-color: #00000066; 254 | border-color: var(--menu-search-result-hover-background-color); 255 | } 256 | .doc-nav > .content a { 257 | color: #fff; 258 | color: var(--menu-text-color); 259 | text-decoration: none; 260 | user-select: none; 261 | } 262 | .doc-nav > .content a:hover { 263 | text-decoration: underline; 264 | } 265 | .doc-nav .search.hidden { 266 | display: none; 267 | } 268 | .doc-nav .search li { 269 | line-height: 1.5; 270 | } 271 | .doc-nav > .search .result:hover { 272 | background-color: #00000021; 273 | background-color: var(--menu-search-result-background-hover-color); 274 | } 275 | .doc-nav > .search .result:hover > .link > .definition > .badge { 276 | background-color: #0000004d; 277 | background-color: var(--menu-search-badge-background-hover-color); 278 | } 279 | .doc-nav > .search .result > .link { 280 | padding: 0.5rem 1.4rem; 281 | text-decoration: none; 282 | color: #fff; 283 | color: var(--menu-text-color); 284 | display: block; 285 | } 286 | .doc-nav > .search .result > .link > .definition { 287 | display: flex; 288 | } 289 | .doc-nav > .search .result > .link > .definition > .title { 290 | color: #90cdf4; 291 | color: var(--menu-search-title-text-color); 292 | font-size: 0.875rem; 293 | font-weight: 500; 294 | overflow: hidden; 295 | white-space: nowrap; 296 | text-overflow: ellipsis; 297 | } 298 | .doc-nav > .search .result > .link > .definition > .badge { 299 | font-size: 0.75rem; 300 | display: inline-flex; 301 | padding: 0 0.5rem; 302 | background-color: #00000044; 303 | background-color: var(--menu-search-badge-background-color); 304 | margin-left: auto; 305 | align-items: center; 306 | border-radius: 9999px; 307 | font-weight: 500; 308 | } 309 | .doc-nav > .search .result > .link > .description { 310 | font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; 311 | font-size: 0.75rem; 312 | overflow: hidden; 313 | white-space: nowrap; 314 | text-overflow: ellipsis; 315 | margin-top: 0.25rem; 316 | } 317 | .doc-nav > .search > hr.separator { 318 | margin: 0.5rem 0; 319 | border-color: #00000044; 320 | border-color: var(--menu-search-separator-color); 321 | box-sizing: content-box; 322 | height: 0; 323 | border-width: 0; 324 | border-top-width: 1px; 325 | border-style: solid; 326 | overflow: visible; 327 | } 328 | 329 | /* Main content */ 330 | .doc-scrollview { 331 | height: 100%; 332 | overflow-y: scroll; 333 | } 334 | .doc-container { 335 | display: flex; 336 | flex-direction: column-reverse; 337 | } 338 | .doc-content { 339 | display: flex; 340 | flex-direction: column; 341 | padding: 1rem; 342 | overflow: hidden; 343 | } 344 | .doc-content img { 345 | width: auto; 346 | max-width: 100%; 347 | } 348 | .doc-content p { 349 | line-height: 1.4; 350 | } 351 | .doc-content a { 352 | color: #2779bd; 353 | color: var(--link-color); 354 | } 355 | .doc-content > .doc-node { 356 | padding: 5rem 0 2rem 0; 357 | margin-top: -4rem; 358 | overflow: hidden; 359 | word-break: break-all; /* IE11 */ 360 | word-break: break-word; 361 | } 362 | .doc-content > .doc-node.const:nth-child(2) { 363 | padding-bottom: 0 !important; 364 | } 365 | .doc-content > .doc-node.const:not(:first-child) { 366 | padding-top: 4rem; 367 | } 368 | .doc-content > .doc-node.const:not(:last-child) { 369 | padding-bottom: 2rem; 370 | } 371 | .doc-content > .timestamp { 372 | font-size: 0.8rem; 373 | color: #b8c2cc; 374 | color: var(--timestamp-color); 375 | } 376 | .doc-content > .doc-node > .title { 377 | display: flex; 378 | font-family: "Work Sans", sans-serif; 379 | font-weight: 500; 380 | padding: 0.3rem; 381 | align-items: center; 382 | margin-bottom: 1rem; 383 | border-bottom: 1px solid #f1f5f8; 384 | border-bottom: 1px solid var(--title-bottom-line-color); 385 | } 386 | .doc-content > .doc-node > .title > .link { 387 | display: flex; 388 | margin-left: auto; 389 | fill: #dae1e7; 390 | fill: var(--ref-symbol-color); 391 | } 392 | .doc-content > .doc-node > .title > .link:hover { 393 | fill: #b8c2cc; 394 | fill: var(--ref-symbol-hover-color); 395 | } 396 | .doc-content > .doc-node h1 { 397 | font-size: 2rem; 398 | } 399 | .doc-content > .doc-node h2 { 400 | font-size: 1.3rem; 401 | } 402 | .doc-content > .doc-node .signature { 403 | border-color: #a0aec0; 404 | border-color: var(--code-signature-border-color); 405 | border-left-width: 3px; 406 | border-left-style: solid; 407 | } 408 | .doc-content > .doc-node > ul > li .task-list-item-checkbox { 409 | margin-right: 0.5rem; 410 | } 411 | .doc-content > .doc-node > .title h1, 412 | .doc-content > .doc-node > .title h2, 413 | .doc-content > .doc-node > .title h3, 414 | .doc-content > .doc-node > .title h4, 415 | .doc-content > .doc-node > .title h5, 416 | .doc-content > .doc-node > .title h6 { 417 | font-weight: 500; 418 | margin: 0; 419 | } 420 | .doc-content > .doc-node > .title h1 a, 421 | .doc-content > .doc-node > .title h2 a, 422 | .doc-content > .doc-node > .title h3 a, 423 | .doc-content > .doc-node > .title h4 a, 424 | .doc-content > .doc-node > .title h5 a, 425 | .doc-content > .doc-node > .title h6 a { 426 | text-decoration: none; 427 | color: #dae1e7; 428 | color: var(--ref-symbol-color); 429 | } 430 | .doc-content > .doc-node > .title h1 a:hover, 431 | .doc-content > .doc-node > .title h2 a:hover, 432 | .doc-content > .doc-node > .title h3 a:hover, 433 | .doc-content > .doc-node > .title h4 a:hover, 434 | .doc-content > .doc-node > .title h5 a:hover, 435 | .doc-content > .doc-node > .title h6 a:hover { 436 | color: #b8c2cc; 437 | color: var(--ref-symbol-hover-color); 438 | } 439 | .doc-content > .footer { 440 | padding-top: 1rem; 441 | margin-top: auto; 442 | bottom: 1rem; 443 | color: 616161; 444 | color: var(--footer-text-color); 445 | border-color: #f1f5f8; 446 | border-color: var(--footer-top-line-color); 447 | border-top-style: solid; 448 | border-top-width: 1px; 449 | font-size: 0.8rem; 450 | font-weight: 500; 451 | } 452 | 453 | /* Right menu */ 454 | .doc-toc { 455 | right: 0; 456 | top: 0; 457 | height: 100%; 458 | overflow-y: auto; 459 | padding: 1rem 1rem 0 1rem; 460 | width: 100%; 461 | box-sizing: border-box; 462 | -ms-overflow-style: none; 463 | scrollbar-width: none; 464 | font-family: "Work Sans", sans-serif; 465 | } 466 | .doc-toc::-webkit-scrollbar { 467 | display: none; 468 | } 469 | .doc-toc li { 470 | line-height: 1.5; 471 | } 472 | .doc-toc a { 473 | color: #2779bd; 474 | color: var(--toc-text-color); 475 | font-size: 0.9rem; 476 | font-weight: 600; 477 | overflow: hidden; 478 | text-overflow: ellipsis; 479 | display: block; 480 | text-decoration: none; 481 | border-left-width: 2px; 482 | border-left-style: solid; 483 | border-color: transparent; 484 | padding-left: 0.4rem; 485 | } 486 | .doc-toc a:hover { 487 | text-decoration: underline; 488 | } 489 | .doc-toc a.active { 490 | border-color: #4299e1; 491 | border-color: var(--toc-indicator-color); 492 | } 493 | .doc-toc li ul { 494 | margin: 0.2rem 0 0.2rem; 495 | font-size: 0.7rem; 496 | list-style: none; 497 | } 498 | .doc-toc li ul a { 499 | font-weight: 400; 500 | padding-left: 0.8rem; 501 | } 502 | 503 | /* Code highlight */ 504 | pre, code, pre code { 505 | color: #5c6e74; 506 | color: var(--code-default-text-color); 507 | font-size: 0.948em; 508 | text-shadow: none; 509 | font-family: monospace; 510 | background-color: #edf2f7; 511 | background-color: var(--code-background-color); 512 | border-radius: 0.25rem; 513 | } 514 | pre code { 515 | direction: ltr; 516 | text-align: left; 517 | white-space: pre; 518 | word-spacing: normal; 519 | word-break: normal; 520 | line-height: 1.5; 521 | -moz-tab-size: 4; 522 | -o-tab-size: 4; 523 | tab-size: 4; 524 | -webkit-hyphens: none; 525 | -moz-hyphens: none; 526 | -ms-hyphens: none; 527 | hyphens: none; 528 | display: block; 529 | overflow-x: auto; 530 | padding: 1rem; 531 | } 532 | code { 533 | padding: 0.2rem; 534 | vertical-align: middle; 535 | } 536 | pre { 537 | overflow: auto; 538 | margin: 0; 539 | } 540 | .namespace { 541 | opacity: .7; 542 | } 543 | .token.comment { 544 | color: #93a1a1; 545 | color: var(--code-comment-text-color) 546 | } 547 | .token.punctuation { 548 | color: #999999; 549 | color: var(--code-punctuation-text-color); 550 | } 551 | .token.number, 552 | .token.symbol { 553 | color: #702459; 554 | color: var(--code-symbol-text-color); 555 | } 556 | .token.string, 557 | .token.char, 558 | .token.builtin { 559 | color: #38a169; 560 | color: var(--code-builtin-text-color); 561 | } 562 | .token.operator, 563 | .token.entity, 564 | .token.url, 565 | .language-css .token.string, 566 | .style .token.string { 567 | color: #a67f59; 568 | color: var(--code-operator-text-color); 569 | background: transparent; 570 | } 571 | .token.boolean, 572 | .token.keyword { 573 | color: #2b6cb0; 574 | color: var(--code-keyword-text-color); 575 | } 576 | .token.function { 577 | color: #319795; 578 | color: var(--code-function-text-color); 579 | } 580 | 581 | /* Medium screen and up */ 582 | @media (min-width: 768px) { 583 | *::-webkit-scrollbar { 584 | width: 8px; 585 | height: 8px; 586 | } 587 | *::-webkit-scrollbar-thumb { 588 | border: 3px solid transparent; 589 | } 590 | .doc-container { 591 | flex-direction: row; 592 | } 593 | .doc-content { 594 | font-size: 0.95rem; 595 | flex: 1; 596 | padding: 0rem 2rem 1rem 2rem; 597 | } 598 | .doc-toc { 599 | position: relative; 600 | /* IE11 */ 601 | position: sticky; 602 | position: -webkit-sticky; 603 | align-self: flex-start; 604 | top: 56px; 605 | height: auto; 606 | height: 100vh; 607 | min-width: 200px; 608 | width: auto; 609 | max-width: 300px; 610 | } 611 | .doc-toc > ul { 612 | padding-bottom: 1rem; 613 | } 614 | } 615 | 616 | @media (max-width: 1023px) { 617 | .doc-nav.hidden { 618 | height: auto; 619 | } 620 | .doc-nav.hidden #search { 621 | display: none; 622 | } 623 | .doc-nav .search.mobile-hidden { 624 | display: none; 625 | } 626 | .doc-nav > .heading-container > .heading > .info { 627 | align-items: center; 628 | } 629 | .doc-nav > .heading-container > .heading > .info > .toggle-version-container { 630 | flex-grow: 1; 631 | padding: 0 1rem; 632 | justify-content: space-between; 633 | } 634 | } 635 | 636 | @media (min-width: 1024px) { 637 | #page { 638 | padding-top: 0; 639 | } 640 | .doc-nav { 641 | width: 300px; 642 | } 643 | .doc-nav #toggle-menu { 644 | display: none; 645 | } 646 | .doc-nav > .heading-container > .heading > .info { 647 | height: auto; 648 | padding: 1rem 2rem 0 2rem; 649 | flex-direction: column-reverse; 650 | justify-content: center; 651 | } 652 | .doc-nav > .heading-container > .heading > .info > .toggle-version-container { 653 | align-items: center; 654 | margin-bottom: 0.2rem; 655 | display: flex; 656 | flex-direction: row-reverse; 657 | } 658 | .doc-nav > .heading-container > .heading > .info > .toggle-version-container > #dark-mode-toggle { 659 | margin-right: auto; 660 | } 661 | .doc-nav .content.show, 662 | .doc-nav .content.hidden { 663 | display: flex; 664 | } 665 | .doc-content > .doc-node.const:nth-child(2) { 666 | padding-bottom: 0 !important; 667 | } 668 | .doc-content > .doc-node.const:not(:first-child) { 669 | padding-top: 0; 670 | } 671 | .doc-content > .doc-node.const:not(:last-child) { 672 | padding-bottom: 1rem; 673 | } 674 | .doc-container { 675 | margin-left: 300px; 676 | } 677 | .doc-node { 678 | padding-top: 1rem !important; 679 | margin-top: 0 !important; 680 | } 681 | .doc-toc { 682 | top: 0; 683 | } 684 | } 685 | -------------------------------------------------------------------------------- /_docs/search_index.js: -------------------------------------------------------------------------------- 1 | var searchModuleIndex = ["README","viup","viup.browser","viup.gl","viup.image",]; 2 | var searchIndex = ["Control","append","debug","debug_props","destroy","detach","focus","focus_next","focus_prev","free","get_attr","get_bgcolor","get_bool","get_class_name","get_class_type","get_data","get_f32","get_f64","get_fgcolor","get_font","get_int","get_int_int","get_rgb","get_rgba","insert","map_control","on_action","on_branch_close","on_branch_open","on_button","on_button_press","on_button_release","on_caret","on_cell","on_change","on_dbl_click","on_destroy","on_detached","on_drag","on_drag_drop","on_drop_down","on_drop_files","on_edit","on_entered","on_execute_branch","on_execute_left","on_exited","on_extended","on_extra_button","on_flat_action","on_focused","on_help","on_key","on_key_press","on_map","on_motion","on_mouse_button","on_mouse_move","on_multiselect","on_multiselection","on_multiunselect","on_node_removed","on_open_close","on_rename","on_resize","on_restored","on_right_click","on_scroll","on_select","on_selection","on_show_rename","on_switch","on_tab_change","on_tab_change_pos","on_tab_close","on_toggle_value","on_unfocused","on_unmap","on_value_changed","on_value_changing","on_wheel","refresh","refresh_children","set_attr","set_attrs","set_bgcolor","set_data","set_fgcolor","set_font","set_handle","set_image","unmap_control","unset_attr","ActionFunc","BranchOpenFunc","BranchCloseFunc","ButtonFunc","ButtonPressFunc","ButtonReleaseFunc","CaretFunc","CellFunc","ChangeFunc","DblClickFunc","DestroyFunc","DetachedFunc","DragFunc","DragDropFunc","DropDownFunc","DropFilesFunc","EditFunc","EnteredFunc","EntryFunc","ExecuteBranchFunc","ExecuteLeafFunc","ExitFunc","ExitedFunc","ExtendedFunc","ExtraButtonFunc","FlatActionFunc","FocusedFunc","HelpFunc","IdleFunc","KeyFunc","KeyPressFunc","LayoutUpdateFunc","MapFunc","MotionFunc","MouseButtonFunc","MouseMoveFunc","MultiSelectFunc","MultiSelectionFunc","MultiUnselectionFunc","NodeRemovedFunc","MenuCloseFunc","MenuOpenFunc","OpenCloseFunc","RenameFunc","ResizeFunc","RestoredFunc","RightClickFunc","SelectFunc","SelectionFunc","ShowRenameFunc","ScrollFunc","SpinFunc","SwitchFunc","TabChangeFunc","TabChangePosFunc","TabCloseFunc","ToggleValueFunc","UnfocusedFunc","UnmapFunc","ValueChangedFunc","ValueChangingFunc","WheelFunc","Color","show_picker","str","parse_color","background","cbox","detach_box","expander","fill","flat_frame","flat_scroll","flat_tabs","frame","grid","hbox","menu","multi_box","normalizer","radio_group","resizer","scroll","space","tabs","vbox","zbox","get_focused","animated_label","button","calendar","canvas","color_browser","date_picker","divider","drop_button","flat_button","flat_toggle","flat_slider","flat_tree","label","link","list","menu_item","menu_sep","multiline","progress","slider","spin","spin_box","sub_menu","text","tree","toggle","color_dialog","dialog","file_dialog","font_dialog","message_dialog","Dialog","popup","set_menu","show","show_xy","FuncResult","Key","MouseButton","parse_font","Font","show_picker","str","is_shift","is_ctrl","is_alt","is_sys","get_key","close","flush","get_global_reference","get_global_value","get_handle","help","log","loop_step","main_loop","message","set_global_reference","set_global_value","set_handle","new","create_context","is_current","make_current","set_palette","swap","wait","load","load_animation","new_grayscale","new_rgb","new_rgba",]; 3 | var searchModuleData = [["
","index.html"],["
","viup.html"],[" ","viup.browser.html"],[" ","viup.gl.html"],[" ","viup.image.html"],]; 4 | var searchData = [["viup","","viup.html#Control","struct "],["viup","","viup.html#Control.append","fn (Control)"],["viup"," debug shows a layout dialog that can be used to inspect the provided Dialog's ","viup.html#Control.debug","fn (Control)"],["viup"," debug_props shows a properites dialog that can be used to inspect the provided","viup.html#Control.debug_props","fn (Control)"],["viup","","viup.html#Control.destroy","fn (Control)"],["viup","","viup.html#Control.detach","fn (Control)"],["viup"," focus sets focus on to the current control and returns back the previously foc","viup.html#Control.focus","fn (Control)"],["viup"," focus_next focuses on the next element that can have focus Note: This may not ","viup.html#Control.focus_next","fn (Control)"],["viup"," focus_prev focuses on the previous element that can have focus Note: This may ","viup.html#Control.focus_prev","fn (Control)"],["viup"," free destroys this control and releases its memory (used by autofree) ","viup.html#Control.free","fn (Control)"],["viup","","viup.html#Control.get_attr","fn (Control)"],["viup"," get_bgcolor gets the background color for the control ","viup.html#Control.get_bgcolor","fn (Control)"],["viup"," get_bool retrieves an bool attribute (technically int > 0) ","viup.html#Control.get_bool","fn (Control)"],["viup","","viup.html#Control.get_class_name","fn (Control)"],["viup","","viup.html#Control.get_class_type","fn (Control)"],["viup"," get_data gets some data that has been associated with this control based on `na","viup.html#Control.get_data","fn (Control)"],["viup"," get_f32 retrieves a float attribute ","viup.html#Control.get_f32","fn (Control)"],["viup"," get_f64 retrieves an f64 attribute ","viup.html#Control.get_f64","fn (Control)"],["viup"," get_fgcolor gets the foreground color for the control ","viup.html#Control.get_fgcolor","fn (Control)"],["viup"," get_font returns back a formatted `Font` object for this control ","viup.html#Control.get_font","fn (Control)"],["viup"," get_int retrieves an int attribute ","viup.html#Control.get_int","fn (Control)"],["viup"," get_int_int retrieves an attribute that has a divider (x, :, -) It returns the","viup.html#Control.get_int_int","fn (Control)"],["viup"," get_rgb retrieves an attribute and returns it back in r, g, b form ","viup.html#Control.get_rgb","fn (Control)"],["viup"," get_rgba retrieves an attribute and returns it back in r, g, b, a form ","viup.html#Control.get_rgba","fn (Control)"],["viup"," insert inserts a `new_control` into this control after `ref_control` if provide","viup.html#Control.insert","fn (Control)"],["viup","","viup.html#Control.map_control","fn (Control)"],["viup","","viup.html#Control.on_action","fn (Control)"],["viup","","viup.html#Control.on_branch_close","fn (Control)"],["viup","","viup.html#Control.on_branch_open","fn (Control)"],["viup"," on_button occurs when a button is clicked ","viup.html#Control.on_button","fn (Control)"],["viup"," on_button_press occurs when a button is pressed, but not released ","viup.html#Control.on_button_press","fn (Control)"],["viup"," on_button_release occurs when a button is pressed and then released ","viup.html#Control.on_button_release","fn (Control)"],["viup","","viup.html#Control.on_caret","fn (Control)"],["viup","","viup.html#Control.on_cell","fn (Control)"],["viup"," on_change occurs when the value in an input is changed ","viup.html#Control.on_change","fn (Control)"],["viup"," on_dbl_click occurs when an element is double-clicked ","viup.html#Control.on_dbl_click","fn (Control)"],["viup"," on_destroy occurs when an element is freed ","viup.html#Control.on_destroy","fn (Control)"],["viup","","viup.html#Control.on_detached","fn (Control)"],["viup"," on_drag occurs when an element is being dragged ","viup.html#Control.on_drag","fn (Control)"],["viup"," on_drag_drop occurs when an element is dragged and then dropped ","viup.html#Control.on_drag_drop","fn (Control)"],["viup","","viup.html#Control.on_drop_down","fn (Control)"],["viup","","viup.html#Control.on_drop_files","fn (Control)"],["viup"," on_edit occurs when an element is being edited ","viup.html#Control.on_edit","fn (Control)"],["viup","","viup.html#Control.on_entered","fn (Control)"],["viup","","viup.html#Control.on_execute_branch","fn (Control)"],["viup","","viup.html#Control.on_execute_left","fn (Control)"],["viup","","viup.html#Control.on_exited","fn (Control)"],["viup","","viup.html#Control.on_extended","fn (Control)"],["viup","","viup.html#Control.on_extra_button","fn (Control)"],["viup","","viup.html#Control.on_flat_action","fn (Control)"],["viup"," on_focused occurs when an element receives focus ","viup.html#Control.on_focused","fn (Control)"],["viup"," on_help occurs when the focused element has the \"help\" method called on it ","viup.html#Control.on_help","fn (Control)"],["viup"," on_key occurs when any key is pressed down ","viup.html#Control.on_key","fn (Control)"],["viup"," on_key_press occurs when a key is fully pressed and released ","viup.html#Control.on_key_press","fn (Control)"],["viup","","viup.html#Control.on_map","fn (Control)"],["viup","","viup.html#Control.on_motion","fn (Control)"],["viup"," on_mouse_button occurs when any mouse button is pressed ","viup.html#Control.on_mouse_button","fn (Control)"],["viup"," on_mouse_move occurs whenever mouse movement has happened ","viup.html#Control.on_mouse_move","fn (Control)"],["viup","","viup.html#Control.on_multiselect","fn (Control)"],["viup","","viup.html#Control.on_multiselection","fn (Control)"],["viup","","viup.html#Control.on_multiunselect","fn (Control)"],["viup","","viup.html#Control.on_node_removed","fn (Control)"],["viup","","viup.html#Control.on_open_close","fn (Control)"],["viup","","viup.html#Control.on_rename","fn (Control)"],["viup"," on_resize occurs whenever an element is resized ","viup.html#Control.on_resize","fn (Control)"],["viup","","viup.html#Control.on_restored","fn (Control)"],["viup"," on_right_click occurs whenever a right-click even is detected ","viup.html#Control.on_right_click","fn (Control)"],["viup","","viup.html#Control.on_scroll","fn (Control)"],["viup"," on_select occurs whenever a value is selected in an element ","viup.html#Control.on_select","fn (Control)"],["viup","","viup.html#Control.on_selection","fn (Control)"],["viup","","viup.html#Control.on_show_rename","fn (Control)"],["viup","","viup.html#Control.on_switch","fn (Control)"],["viup"," on_tab_change occurs when a tab is selected ","viup.html#Control.on_tab_change","fn (Control)"],["viup","","viup.html#Control.on_tab_change_pos","fn (Control)"],["viup"," on_tab_close occurs when a tab is closed ","viup.html#Control.on_tab_close","fn (Control)"],["viup"," on_toggle_value occurs when a toggle element is changed ","viup.html#Control.on_toggle_value","fn (Control)"],["viup"," on_unfocused occurs when an element loses focus ","viup.html#Control.on_unfocused","fn (Control)"],["viup","","viup.html#Control.on_unmap","fn (Control)"],["viup"," on_value_changed occurs when the value of an element is modified ","viup.html#Control.on_value_changed","fn (Control)"],["viup"," on_value_changing occurs when the value of an element is being actively changed","viup.html#Control.on_value_changing","fn (Control)"],["viup"," on_wheel occurs when the scroll wheel on the mouse is adjusted ","viup.html#Control.on_wheel","fn (Control)"],["viup","","viup.html#Control.refresh","fn (Control)"],["viup","","viup.html#Control.refresh_children","fn (Control)"],["viup"," set_attr sets an attribute on `Control` and returns `Control` back for chainin","viup.html#Control.set_attr","fn (Control)"],["viup"," set_attrs takes all x=x values and applies them to `Control` and returns `Cont","viup.html#Control.set_attrs","fn (Control)"],["viup"," set_bgcolor updates the background color for this control to the provided `Colo","viup.html#Control.set_bgcolor","fn (Control)"],["viup"," set_data associates the provided `data` with `Control` and returns `Control` b","viup.html#Control.set_data","fn (Control)"],["viup"," set_fgcolor updates the foreground color for this control to the provided `Colo","viup.html#Control.set_fgcolor","fn (Control)"],["viup"," set_font updates the font for this control to the provided `Font` ","viup.html#Control.set_font","fn (Control)"],["viup"," set_handle is a helper function for `Control` that calls the global `set_handl","viup.html#Control.set_handle","fn (Control)"],["viup","","viup.html#Control.set_image","fn (Control)"],["viup","","viup.html#Control.unmap_control","fn (Control)"],["viup"," unset_attr clears the provided attribute ","viup.html#Control.unset_attr","fn (Control)"],["viup","","viup.html#ActionFunc","type "],["viup","","viup.html#BranchOpenFunc","type "],["viup","","viup.html#BranchCloseFunc","type "],["viup","","viup.html#ButtonFunc","type "],["viup","","viup.html#ButtonPressFunc","type "],["viup","","viup.html#ButtonReleaseFunc","type "],["viup","","viup.html#CaretFunc","type "],["viup","","viup.html#CellFunc","type "],["viup","","viup.html#ChangeFunc","type "],["viup","","viup.html#DblClickFunc","type "],["viup","","viup.html#DestroyFunc","type "],["viup","","viup.html#DetachedFunc","type "],["viup","","viup.html#DragFunc","type "],["viup","","viup.html#DragDropFunc","type "],["viup","","viup.html#DropDownFunc","type "],["viup","","viup.html#DropFilesFunc","type "],["viup","","viup.html#EditFunc","type "],["viup","","viup.html#EnteredFunc","type "],["viup","","viup.html#EntryFunc","type "],["viup","","viup.html#ExecuteBranchFunc","type "],["viup","","viup.html#ExecuteLeafFunc","type "],["viup","","viup.html#ExitFunc","type "],["viup","","viup.html#ExitedFunc","type "],["viup","","viup.html#ExtendedFunc","type "],["viup","","viup.html#ExtraButtonFunc","type "],["viup","","viup.html#FlatActionFunc","type "],["viup","","viup.html#FocusedFunc","type "],["viup","","viup.html#HelpFunc","type "],["viup","","viup.html#IdleFunc","type "],["viup","","viup.html#KeyFunc","type "],["viup","","viup.html#KeyPressFunc","type "],["viup","","viup.html#LayoutUpdateFunc","type "],["viup","","viup.html#MapFunc","type "],["viup","","viup.html#MotionFunc","type "],["viup","","viup.html#MouseButtonFunc","type "],["viup","","viup.html#MouseMoveFunc","type "],["viup","","viup.html#MultiSelectFunc","type "],["viup","","viup.html#MultiSelectionFunc","type "],["viup","","viup.html#MultiUnselectionFunc","type "],["viup","","viup.html#NodeRemovedFunc","type "],["viup","","viup.html#MenuCloseFunc","type "],["viup","","viup.html#MenuOpenFunc","type "],["viup","","viup.html#OpenCloseFunc","type "],["viup","","viup.html#RenameFunc","type "],["viup","","viup.html#ResizeFunc","type "],["viup","","viup.html#RestoredFunc","type "],["viup","","viup.html#RightClickFunc","type "],["viup","","viup.html#SelectFunc","type "],["viup","","viup.html#SelectionFunc","type "],["viup","","viup.html#ShowRenameFunc","type "],["viup","","viup.html#ScrollFunc","type "],["viup","","viup.html#SpinFunc","type "],["viup","","viup.html#SwitchFunc","type "],["viup","","viup.html#TabChangeFunc","type "],["viup","","viup.html#TabChangePosFunc","type "],["viup","","viup.html#TabCloseFunc","type "],["viup","","viup.html#ToggleValueFunc","type "],["viup","","viup.html#UnfocusedFunc","type "],["viup","","viup.html#UnmapFunc","type "],["viup","","viup.html#ValueChangedFunc","type "],["viup","","viup.html#ValueChangingFunc","type "],["viup","","viup.html#WheelFunc","type "],["viup","","viup.html#Color","struct "],["viup"," show_picker is a helper function to show a color_dialog. It will automatically","viup.html#Color.show_picker","fn (Color)"],["viup"," str converts the color to a IUP valid string Example format: 200 150 0 100 ","viup.html#Color.str","fn (Color)"],["viup"," parse_color parses the provided color string and converts it to a valid `Color","viup.html#parse_color","fn "],["viup","","viup.html#background","fn "],["viup","","viup.html#cbox","fn "],["viup"," detach_box is a container that can be detached as a dialog and reattached back","viup.html#detach_box","fn "],["viup","","viup.html#expander","fn "],["viup"," fill fills up the remaining space for the parent container ","viup.html#fill","fn "],["viup"," flat_frame is a standard frame that allows custom drawing ","viup.html#flat_frame","fn "],["viup"," flat_scroll is a standard scroll that allow custom drawing ","viup.html#flat_scroll","fn "],["viup"," flat_tabs is a standard tabs container that allows custom drawing ","viup.html#flat_tabs","fn "],["viup"," frame puts a border around its children with an optional title ","viup.html#frame","fn "],["viup"," grid is a container that can layout its children in a table-like configuration ","viup.html#grid","fn "],["viup"," hbox is a container that displays its children in a row ","viup.html#hbox","fn "],["viup"," menu is an application container for menu items ","viup.html#menu","fn "],["viup","","viup.html#multi_box","fn "],["viup","","viup.html#normalizer","fn "],["viup"," radio_group is designed to wrap around toggle controls to turn them into a rad","viup.html#radio_group","fn "],["viup","","viup.html#resizer","fn "],["viup"," scroll creates a scroll box that creates a virtual space that can hold an unli","viup.html#scroll","fn "],["viup","","viup.html#space","fn "],["viup"," tabs creates a tab group that can be switched between to view different conten","viup.html#tabs","fn "],["viup"," vbox is a container that displays its children in a column ","viup.html#vbox","fn "],["viup","","viup.html#zbox","fn "],["viup"," get_focused returns back the control that currently has focus ","viup.html#get_focused","fn "],["viup","","viup.html#animated_label","fn "],["viup"," button creates a standard button control with `title` for text ","viup.html#button","fn "],["viup","","viup.html#calendar","fn "],["viup"," canvas creates a control that can render custom content ","viup.html#canvas","fn "],["viup","","viup.html#color_browser","fn "],["viup","","viup.html#date_picker","fn "],["viup"," divider creates a simple line divider element (horizontal by default) ","viup.html#divider","fn "],["viup","","viup.html#drop_button","fn "],["viup","","viup.html#flat_button","fn "],["viup","","viup.html#flat_toggle","fn "],["viup","","viup.html#flat_slider","fn "],["viup","","viup.html#flat_tree","fn "],["viup"," label is used to draw simple text or images ","viup.html#label","fn "],["viup"," link creates a control similar to a `label` that can link to external resource","viup.html#link","fn "],["viup"," list creates a component that can list multiple values ","viup.html#list","fn "],["viup"," menu_item is a component that can be used in a `menu` to that is tied to a spe","viup.html#menu_item","fn "],["viup"," menu_sep creates a simple horizontal line in a `menu` ","viup.html#menu_sep","fn "],["viup"," multiline creates a multiline chooser component ","viup.html#multiline","fn "],["viup"," progress is a basic progressbar component ","viup.html#progress","fn "],["viup"," slider is a number-line slider component ","viup.html#slider","fn "],["viup","","viup.html#spin","fn "],["viup","","viup.html#spin_box","fn "],["viup"," sub_menu is a container control for `menu` controls ","viup.html#sub_menu","fn "],["viup"," text is a standard text input component. Can be configured to to be multi-line","viup.html#text","fn "],["viup","","viup.html#tree","fn "],["viup"," toggle is a radio or checkbox component. Defaults to radio in a `radio_group` ","viup.html#toggle","fn "],["viup"," color_dialog opens a color picker with optional palette ","viup.html#color_dialog","fn "],["viup"," dialog creates a standard Window or Modal dialog control ","viup.html#dialog","fn "],["viup"," file_dialog creates a file chooser dialog that can be used to open or save fil","viup.html#file_dialog","fn "],["viup"," font_dialog opens a font picker dialog ","viup.html#font_dialog","fn "],["viup"," message_dialog opens customizable message modal box ","viup.html#message_dialog","fn "],["viup","","viup.html#Dialog","type "],["viup"," popup displays the dialog as a modal at `x`, `y` position ","viup.html#Dialog.popup","fn (Dialog)"],["viup"," set_menu sets the provided menu to this control ","viup.html#Dialog.set_menu","fn (Dialog)"],["viup"," show shows the dialog (not as a modal), typically centered on the opening dial","viup.html#Dialog.show","fn (Dialog)"],["viup"," show_xy shows the dialog the the provided X/Y coordinates Note: Only to be use","viup.html#Dialog.show_xy","fn (Dialog)"],["viup","","viup.html#FuncResult","enum "],["viup","","viup.html#Key","enum "],["viup","","viup.html#MouseButton","enum "],["viup"," parse_font parses the provided font string and converts it to a valid `Font` ","viup.html#parse_font","fn "],["viup","","viup.html#Font","type "],["viup"," show_picker is a helper function to show a font_dialog. It will automatically ","viup.html#Font.show_picker","fn (Font)"],["viup"," str returns back the original font that was provided in `parse_font` ","viup.html#Font.str","fn (Font)"],["viup","","viup.html#is_shift","fn "],["viup","","viup.html#is_ctrl","fn "],["viup","","viup.html#is_alt","fn "],["viup","","viup.html#is_sys","fn "],["viup","","viup.html#get_key","fn "],["viup","","viup.html#close","fn "],["viup","","viup.html#flush","fn "],["viup","","viup.html#get_global_reference","fn "],["viup","","viup.html#get_global_value","fn "],["viup","","viup.html#get_handle","fn "],["viup"," help opens a browser to the provided `url` ","viup.html#help","fn "],["viup","","viup.html#log","fn "],["viup","","viup.html#loop_step","fn "],["viup","","viup.html#main_loop","fn "],["viup","","viup.html#message","fn "],["viup","","viup.html#set_global_reference","fn "],["viup","","viup.html#set_global_value","fn "],["viup","","viup.html#set_handle","fn "],["viup.browser","","viup.browser.html#new","fn "],["viup.gl","","viup.gl.html#create_context","fn "],["viup.gl","","viup.gl.html#is_current","fn "],["viup.gl","","viup.gl.html#make_current","fn "],["viup.gl","","viup.gl.html#set_palette","fn "],["viup.gl","","viup.gl.html#swap","fn "],["viup.gl","","viup.gl.html#wait","fn "],["viup.image","","viup.image.html#load","fn "],["viup.image","","viup.image.html#load_animation","fn "],["viup.image","","viup.image.html#new_grayscale","fn "],["viup.image","","viup.image.html#new_rgb","fn "],["viup.image","","viup.image.html#new_rgba","fn "],]; 5 | -------------------------------------------------------------------------------- /_docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | README | vdoc 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 49 |
50 |
51 |
52 |
53 |

README

<div align="center"> 54 | <h1>VIUP</h1> 55 | </div>

56 |

VIUP is a work-in-progress V wrapper for the C-based cross-platform UI library, IUP. The aim of this 57 | library is to provide a thorough implementation of IUP in V. The implmentation is faithful to the original API but takes some liberties to provide 58 | a native "V" feel and modernizes some of the calls.

59 |

<div align="center"> 60 | <img src="https://raw.githubusercontent.com/kjlaw89/viup/main/examples/gallery/gallery_windows.png" alt="Windows Gallery Example" style="width: 320px;" /> 61 | <img src="https://raw.githubusercontent.com/kjlaw89/viup/main/examples/gallery/gallery_linux.png" alt="Linux (Ubuntu) Gallery Example" style="width: 330px;" /> 62 | </div>

63 |

Features

64 |
    65 |
  • image
      66 |
    • load image
    • 67 |
    • convert image to native
    • 68 |
    • convert native to image
    • 69 |
    70 |
  • 71 |
  • basic controls
  • 72 |
  • containers
  • 73 |
  • dialogs
  • 74 |
  • gl
      75 |
    • gl rendering
    • 76 |
    • gl controls
    • 77 |
    78 |
  • 79 |
  • scintilla
  • 80 |
  • plot
  • 81 |
  • extra controls
  • 82 |
  • clipboard
  • 83 |
  • browser
  • 84 |
85 |

Setup

86 |
    87 |
  1. Download the appropriate runtime libraries for your Operating system: https://sourceforge.net/projects/iup/files/3.30/
  2. 88 |
  3. If using image functions, download IM runtime libraries: http://webserver2.tecgraf.puc-rio.br/im/
  4. 89 |
90 |

Windows install

91 |

Copy all applicable DLLs from Zip to binary directory. By default, only iup.dll is required. If using image functions, iup_im.dll is required as 92 | well as all of the DLLs frmo the IM library.

93 |

Windows App Manifest

94 |

Windows UI apps need to be built with a Manifest. This manifest includes details about the app such as the name, version, and characteristics. VIUP 95 | includes a basic manifest with the gallery that can be easily modified. The generated manifest.syso needs to be in the directory during build but 96 | does not need to be distributed with your application.

97 |

To update the manifest:

98 |

cd winmanifest 99 | windres -i resources.rc -o manifest.syso -O coff

100 |

Copy manifest.syso to application directory.

101 |

Note: Currently running v . or v run . will not find the .syso file correctly. To include it in your project, add a #flag windows "path\\to\\file\\manifest.syso to the top of your application.

102 |

Linux install

103 |

Extract runtime libraries to a folder and run sudo ./install to install libraries.

104 |

Libraries Path

105 |

I've noticed in testing that the libraries are installed to /usr/lib64. It does not appear that they are picked up by the compiler there. Copying from 106 | that folder to /usr/lib resolves the problem. This may not be necessary in all cases.

107 |

Notes about dependencies

108 |

This repo comes with a copy of the headers for the version of IUP that it was developed against (3.30), but does not ship with the runtime libraries. It is not necessary to get the IM library runtime if you do not plan to use it in your application.

109 |

By default VIUP only initializes the subsystems that are imported. For example, importing just viup only initializes the standard dialogs, containers, and components.

110 |

If an extension library is loaded (viup.image), the required runtime binaries must be installed or provided along with the build.

111 |

Example

112 |

This repo comes with a simple application that demos all of the available controls. This app is available in the "examples/gallery". It requires the IM libraries. Once all runtime libraries are in the folder, run the example with v run ..

113 |

Using VIUP

114 |

One of the strengths of IUP is that is it a very simple library. All controls are instances of &Control and share the same methods, though not all methods are applicable to a Control. Adjusting settings for a control is as simple as calling set_attr or providing the attributes when initializing the Control.

115 |

Here's a basic example of initializing a simple window:

116 |
viup.
117 |     dialog(viup.scroll(hbox), "title=Control Gallery")   // Create our dialog with "Control Gallery" as the title and a scrollable Control
118 |     .set_handle("MainWindow")                            // Define a global ID for our Window
119 |     .set_menu("app_menu", menu)                          // Set an app menu if applicable
120 |     .show_xy(viup.Pos.center, viup.Pos.center)           // Display dialog in center of screen
121 | 
122 |

Attributes

123 |

All controls can be passed attributes as the last parameters when creating a Control. Any amount of attributes can provided. Attributes can adjust the various characteristics of a Control such as the title, value(s), background or foreground colors, control sub-type, sizing, etc.

124 |

Not all available attributes apply to each control. If an invalid attribute is provided it is actually accessible via get_attr but will not affect the control itself. Read up more on attributes in the IUP Documentation.

125 |

Example:

126 |
viup.list(
127 |     "List",               // control 'name'
128 |     "1=Combo Item 1",     // Attr 1: Slot 1 is 'Combo Item 1'
129 |     "2=Combo Item 2",     // Attr 2: Slot 2 is 'Combo Item 2'
130 |     "3=Combo Item 3",     // ....
131 |     "4=Combo Item 4",     // ....
132 |     "dropdown=yes",       // Attr 5: List is a dropdown
133 |     "expand=horizontal",  // Attr 6: Expand horizontally
134 |     "value=1"             // Attr 7: Set default value to Slot 1
135 | )
136 | 
137 |

Callbacks & Events

138 |

All controls have callback methods available for various events. Each callback method starts with on_ and can be quickly chained to add multiple callbacks.

139 |

Example:

140 |
viup.button("Button", "action").on_action(button_clicked)
141 | 
142 | fn button_clicked(control &viup.Control) viup.FuncResult {
143 |     viup.message("Button Click", "Button clicked!")
144 |     return .cont
145 | }
146 | 
147 |

In the example above, a Button control is initialized with "Button" for the title. An action callback is added with on_action(button_clicked). button_clicked is an ActionFunc callback and is automatically called when the button is clicked. VIUP mirrors the callbacks that IUP provides pretty closely, typically adding Func on the end for consistency.

148 |

The majority of callback functions can return a viup.FuncResult. This result can be one of the following:

149 |
    150 |
  • cont - continue action
  • 151 |
  • close - close the application
  • 152 |
  • default - perform default action (may be equivalent to cont in most cases)
  • 153 |
  • ignore - ignores event and may stop propagation
  • 154 |
155 |

Chaining

156 |

Most Control methods will return back the Control when finished. This makes it easy to chain several method calls together.

157 |

Example:

158 |
viup
159 |     .message_dialog(
160 |         "title=About",
161 |         "value=$about",
162 |         "dialogtype=information"
163 |     )                                            // Create a message dialog with attributes "title", "value", and "dialogtype"
164 |     .popup(viup.Pos.current, viup.Pos.current)   // Popup dialog to user
165 |     .destroy()                                   // Destroy dialog when closed
166 | 
167 |

Example 2:

168 |
viup
169 |     .button("Set font...", "", "expand=horizontal") // Create button with "Set font..." as title
170 |     .set_handle("font_btn")                         // Set a handle name
171 |     .callback(viup.ActionFunc(font_button_clicked)) // Set a Action callback
172 | 
173 |

Note: Dialogs return back an struct of Dialog. This struct has a few unique functions associated with it (i.e. popup, show, show_xy). It's not 174 | to chain to these methods from regular Control methods.

175 |

Controls

176 |

All dialog, layouts and elements are "Controls" in IUP. As such, they all share common methods that can be utilized by any Control.

177 |

Most used component methods:

178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |
MethodDescription
get_attr / set_attrGet or set an attribute value on the control.
set_attrsUsed to set multiple attributes in a single call
set_handleAssigns this control a name on the global level. This is typically used in combination with viup.get_handle to restore the control in callbacks or other functions
get_font / set_fontGet or set a Font
refresh / refresh_childrenTrigger a redraw for this component and/or its children
208 |

Dialog Controls

209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 |
FunctionDescription
color_dialog(...attrs)Opens a color picker with optional color palette
dialog(child, attrs)Creates a standard Window or modal dialog
file_dialog(...attrs)Open a file chooser. This can be used to open or save files
font_dialog(...attrs)Opens a font picker
message_dialog(...attrs)Opens a customizable message modal
message(title, message)Shows a generic message box with a standard "OK" button to close
243 |

Container Controls

244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 |
FunctionDescription
background(child, attrs)A simple container element that is designed to have a background color or image
detach_box(child, attrs)Container that is designed to be detachable from the parent container when needed. Can also be reattached.
fill(...attrs)Fills the remaining space for the parent container
flat_frame(child, attrs)Standard frame that allows custom rendering
flat_scroll(child, attrs)Standard scroll that allows custom rendering
frame(child, attrs)Container that puts a border around its children with an optional title
grid(children, attrs)Multi-control container that lays out its children in a table-like design
hbox(children, attrs)Multi-control container that lays out its children in a row
menu(children, attrs)Multi-control container for a dialog's menu items
radio_group(child, attrs)Container is used to group toggles together into a radio button group
tabs(children, attrs)Multi-control container for tabbed content
vbox(children, attrs)Multi-control container that lays out its children in a column
302 |

Standard Controls

303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 |
FunctionDescription
animated_label(animation, attrs)Creates a control that can display an animation
button(title, action, attrs)Creates a standard button with title for the text
canvas(action, attrs)A control that can be used to render custom content
divider(...attrs)Draws a horizontal or vertical line (horizontal by default)
label(title, attrs)A simple control to show text or images
link(url, title, attrs)Similar to a label, can be used to link to an external source
list(action, attrs)Creates a component that can be used to list multiple values
menu_item(action, attrs)Used in the menu component as a specific action (e.g. "Open File..." or "About")
menu_sep(...attrs)Create a simple horizontal line in a menu
multiline(action, attrs)Creates a multiline chooser component
progress(...attrs)Basic progressbar component
slider(orientation, attrs)Creates a number-line slider component
sub_menu(title, child, attrs)Creates a sub menu component. Sub-menues are children of menu components. Typically structured like: Menu -> Sub-menu -> Menu -> Menu Item.
text(action, attrs)Creates a standard text-input control. Can be set as multi-line, number input, etc.
toggle(title, action, attrs)A radio or checkbox component. Defaults to radio when in a radio_group.
373 |

Contributing / Support

374 |

This project was developed as a way of improving my understanding of V & C. I will not be providing active support for the project, but I'll happily accept any pull requests. Use at your own discretion!

375 | 376 |
377 | 378 | 379 | 382 |
383 | 384 |
385 |
386 |
387 | 388 | 389 | 390 | --------------------------------------------------------------------------------