{"id":13728746,"url":"https://github.com/kjlaw89/viup","last_synced_at":"2025-05-08T01:30:21.597Z","repository":{"id":69353207,"uuid":"303896012","full_name":"kjlaw89/viup","owner":"kjlaw89","description":"A V wrapper for the cross-platform UI library, IUP.","archived":false,"fork":false,"pushed_at":"2024-01-05T12:53:08.000Z","size":332,"stargazers_count":46,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-05T16:56:44.993Z","etag":null,"topics":["cross-platform","iup","ui","vlang","vlang-module","wrapper"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kjlaw89.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-10-14T03:48:46.000Z","updated_at":"2024-08-23T20:41:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"f6ab7f0f-bb75-42cf-8a3a-5e948427ad22","html_url":"https://github.com/kjlaw89/viup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjlaw89%2Fviup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjlaw89%2Fviup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjlaw89%2Fviup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kjlaw89%2Fviup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kjlaw89","download_url":"https://codeload.github.com/kjlaw89/viup/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252981349,"owners_count":21835413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-platform","iup","ui","vlang","vlang-module","wrapper"],"created_at":"2024-08-03T02:00:49.421Z","updated_at":"2025-05-08T01:30:20.842Z","avatar_url":"https://github.com/kjlaw89.png","language":"HTML","funding_links":[],"categories":["👓 Alternatives to the [Electron.js](https://electronjs.org) ⚛","Libraries"],"sub_categories":["V","Graphics"],"readme":"\u003cdiv align=\"center\"\u003e\n\t\u003ch1\u003eVIUP\u003c/h1\u003e\n\u003c/div\u003e\n\nVIUP 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\nlibrary is to provide a thorough implementation of IUP in V. The implmentation is faithful to the original API but takes some liberties to provide\na native \"V\" feel and modernizes some of the calls.\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"https://raw.githubusercontent.com/kjlaw89/viup/main/examples/gallery/gallery_windows.png\" alt=\"Windows Gallery Example\" style=\"width: 320px;\" /\u003e\n\t\u003cimg src=\"https://raw.githubusercontent.com/kjlaw89/viup/main/examples/gallery/gallery_linux.png\" alt=\"Linux (Ubuntu) Gallery Example\" style=\"width: 330px;\" /\u003e\n\u003c/div\u003e\n\n## Features\n\n- [x] image\n  - [x] load image\n  - [x] convert image to native\n  - [x] convert native to image\n- [x] basic controls\n- [x] containers\n- [x] dialogs\n- [ ] gl\n  - [x] gl rendering\n  - [ ] gl controls\n- [ ] scintilla\n- [ ] plot\n- [ ] extra controls\n- [ ] clipboard\n- [ ] browser\n\n## Setup\n\n1. Download the appropriate runtime libraries for your Operating system: https://sourceforge.net/projects/iup/files/3.30/\n2. If using image functions, download `IM` runtime libraries: http://webserver2.tecgraf.puc-rio.br/im/\n\n### Windows install\n\nCopy 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\nwell as all of the DLLs frmo the `IM` library.\n\n#### Windows App Manifest\n\nWindows UI apps need to be built with a Manifest. This manifest includes details about the app such as the name, version, and characteristics. VIUP\nincludes a basic manifest with the gallery that can be easily modified. The generated `manifest.syso` needs to be in the directory during build but\ndoes not need to be distributed with your application.\n\nTo update the manifest:\n\n`cd winmanifest`\n`windres -i resources.rc -o manifest.syso -O coff`\n\nCopy manifest.syso to application directory.\n\n_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._\n\n### Linux install\n\nExtract runtime libraries to a folder and run `sudo ./install` to install libraries.\n\n#### Libraries Path\n\nI'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\nthat folder to `/usr/lib` resolves the problem. This may not be necessary in all cases.\n\n### Notes about dependencies\n\nThis 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.\n\nBy default VIUP only initializes the subsystems that are imported. For example, importing just `viup` only initializes the standard dialogs, containers, and components.\n\nIf an extension library is loaded (`viup.image`), the required runtime binaries must be installed or provided along with the build.\n\n## Example\n\nThis 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 .`.\n\n## Using VIUP\n\nOne of the strengths of IUP is that is it a very simple library. All controls are instances of `\u0026Control` 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.\n\nHere's a basic example of initializing a simple window:\n\n```v\nviup.\n\tdialog(viup.scroll(hbox), \"title=Control Gallery\")   // Create our dialog with \"Control Gallery\" as the title and a scrollable Control\n\t.set_handle(\"MainWindow\")                            // Define a global ID for our Window\n\t.set_menu(\"app_menu\", menu)                          // Set an app menu if applicable\n\t.show_xy(viup.Pos.center, viup.Pos.center)           // Display dialog in center of screen\n```\n\n### Autofree\n\nVIUP 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`,\nthe 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\nmethods are used, add `[manualfree]` to the method and call `free()` on the Controls within as necessary.\n\n### Attributes\n\nAll 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.\n\nNot 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/).\n\nExample:\n\n```v\nviup.list(\n\t\"List\",               // control 'name'\n\t\"1=Combo Item 1\",     // Attr 1: Slot 1 is 'Combo Item 1'\n\t\"2=Combo Item 2\",     // Attr 2: Slot 2 is 'Combo Item 2'\n\t\"3=Combo Item 3\",     // ....\n\t\"4=Combo Item 4\",     // ....\n\t\"dropdown=yes\",       // Attr 5: List is a dropdown\n\t\"expand=horizontal\",  // Attr 6: Expand horizontally\n\t\"value=1\"             // Attr 7: Set default value to Slot 1\n)\n```\n\n### Callbacks \u0026 Events\n\nAll controls have callback methods available for various events. Each callback method starts with `on_` and can be quickly chained to add multiple callbacks.\n\nExample:\n\n```v\nviup.button(\"Button\", \"action\").on_action(button_clicked)\n\nfn button_clicked(control \u0026viup.Control) viup.FuncResult {\n\tviup.message(\"Button Click\", \"Button clicked!\")\n\treturn .cont\n}\n```\n\nIn 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.\n\nThe majority of callback functions can return a `viup.FuncResult`. This result can be one of the following:\n\n- `cont` - continue action\n- `close` - close the application\n- `default` - perform default action (may be equivalent to `cont` in most cases)\n- `ignore` - ignores event and may stop propagation \n\n### Chaining\n\nMost Control methods will return back the Control when finished. This makes it easy to chain several method calls together.\n\nExample:\n\n```v\nviup\n\t.message_dialog(\n\t\t\"title=About\",\n\t\t\"value=$about\",\n\t\t\"dialogtype=information\"\n\t)                                            // Create a message dialog with attributes \"title\", \"value\", and \"dialogtype\"\n\t.popup(viup.Pos.current, viup.Pos.current)   // Popup dialog to user\n\t.destroy()                                   // Destroy dialog when closed\n```\n\nExample 2:\n\n```v\nviup\n\t.button(\"Set font...\", \"\", \"expand=horizontal\") // Create button with \"Set font...\" as title\n\t.set_handle(\"font_btn\")                         // Set a handle name\n\t.on_action(font_button_clicked) // Set a Action callback\n```\n\n_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\nto chain to these methods from regular `Control` methods._\n\n### Controls\n\nAll dialog, layouts and elements are \"Controls\" in IUP. As such, they all share common methods that can be utilized by any Control. \n\nMost used component methods:\n\nMethod | Description\n------- | ------------\n`get_attr` / `set_attr` | Get or set an attribute value on the control.\n`set_attrs` | Used to set multiple attributes in a single call\n`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\n`get_font` / `set_font` | Get or set a `Font`\n`refresh` / `refresh_children` | Trigger a redraw for this component and/or its children\n\n### Dialog Controls\n\nFunction | Description\n-------- | -----------\n`color_dialog(...attrs)` | Opens a color picker with optional color palette\n`dialog(child, attrs)` | Creates a standard Window or modal dialog\n`file_dialog(...attrs)` | Open a file chooser. This can be used to open or save files\n`font_dialog(...attrs)` | Opens a font picker\n`message_dialog(...attrs)` | Opens a customizable message modal\n`message(title, message)` | Shows a generic message box with a standard \"OK\" button to close\n\n### Container Controls\n\nFunction | Description\n-------- | -----------\n`background(child, attrs)` | A simple container element that is designed to have a background color or image\n`detach_box(child, attrs)` | Container that is designed to be detachable from the parent container when needed. Can also be reattached.\n`fill(...attrs)` | Fills the remaining space for the parent container\n`flat_frame(child, attrs)` | Standard frame that allows custom rendering\n`flat_scroll(child, attrs)` | Standard scroll that allows custom rendering\n`frame(child, attrs)` | Container that puts a border around its children with an optional title\n`grid(children, attrs)` | Multi-control container that lays out its children in a table-like design\n`hbox(children, attrs)` | Multi-control container that lays out its children in a row\n`menu(children, attrs)` | Multi-control container for a dialog's menu items\n`radio_group(child, attrs)` | Container is used to group `toggle`s together into a radio button group\n`tabs(children, attrs)` | Multi-control container for tabbed content\n`vbox(children, attrs)` | Multi-control container that lays out its children in a column\n\n### Standard Controls\n\nFunction | Description\n-------- | -----------\n`animated_label(animation, attrs)` | Creates a control that can display an animation\n`button(title, action, attrs)` | Creates a standard button with `title` for the text\n`canvas(action, attrs)` | A control that can be used to render custom content\n`divider(...attrs)` | Draws a horizontal or vertical line (horizontal by default)\n`label(title, attrs)` | A simple control to show text or images\n`link(url, title, attrs)` | Similar to a label, can be used to link to an external source\n`list(action, attrs)` | Creates a component that can be used to list multiple values\n`menu_item(action, attrs)` | Used in the `menu` component as a specific action (e.g. \"Open File...\" or \"About\")\n`menu_sep(...attrs)` | Create a simple horizontal line in a `menu`\n`multiline(action, attrs)` | Creates a multiline chooser component\n`progress(...attrs)` | Basic progressbar component\n`slider(orientation, attrs)` | Creates a number-line slider component\n`sub_menu(title, child, attrs)` | Creates a sub menu component. Sub-menues are children of `menu` components. Typically structured like: Menu -\u003e Sub-menu -\u003e Menu -\u003e Menu Item.\n`text(action, attrs)` | Creates a standard text-input control. Can be set as multi-line, number input, etc.\n`toggle(title, action, attrs)` | A radio or checkbox component. Defaults to radio when in a `radio_group`.\n\n## Contributing / Support\n\nThis project was developed as a way of improving my understanding of V \u0026 C. I will not be providing active support for the project, but I'll happily accept any pull requests. Use at your own discretion! ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkjlaw89%2Fviup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkjlaw89%2Fviup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkjlaw89%2Fviup/lists"}