{"id":21497302,"url":"https://github.com/jazzfool/vx","last_synced_at":"2025-03-17T12:25:27.000Z","repository":{"id":137122658,"uuid":"255380998","full_name":"jazzfool/vx","owner":"jazzfool","description":"Idiomatic-oriented Rust UI library experiment","archived":false,"fork":false,"pushed_at":"2020-04-18T05:40:24.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T22:13:59.430Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jazzfool.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-13T16:25:50.000Z","updated_at":"2020-04-18T05:40:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f32787e-b88c-409b-a4ec-ef06eab713a5","html_url":"https://github.com/jazzfool/vx","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/jazzfool%2Fvx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzfool%2Fvx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzfool%2Fvx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jazzfool%2Fvx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jazzfool","download_url":"https://codeload.github.com/jazzfool/vx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244031712,"owners_count":20386651,"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":[],"created_at":"2024-11-23T16:23:04.459Z","updated_at":"2025-03-17T12:25:26.978Z","avatar_url":"https://github.com/jazzfool.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vx\n\n## Yet another GUI experiment of mine\n\n## Goals\n\n- No `Rc\u003cRefCell\u003c..\u003e\u003e` whatsoever.\n- No inherently `unsafe` code whatsoever.\n- No non-trivial or non-derive macros whatsoever.\n\nIn essence, `vx` aims to be written in only the most _pure_ form of Rust. No interior mutability, 100% safety, and no fancy macros.\n\n```rust\nstruct Counter {\n    count: u32,\n}\n\nimpl ComponentFactory for Counter {\n    fn new(globals: \u0026mut Globals, cref: ComponentRef\u003cSelf\u003e) -\u003e Self {\n        let btn: ButtonRef = globals.child(cref);\n\n        globals.listen(globals.get(btn).on_click, cref, move |globals, _| {\n            globals.get_mut(cref).count += 1;\n            globals.update(cref, Repaint::No, Propagate::No);\n        });\n\n        Counter { count: 0 }\n    }\n}\n\nimpl Component for Counter {\n    fn update(\u0026mut self, _globals: \u0026mut Globals) {\n        println!(\"Count: {}\", self.count);\n    }\n}\n```\n\nDue to how it's designed, you can even have graph-like widget relatives;\n\n```rust\nlet parent: UntypedComponentRef = globals.parent(cref);\nlet grandparent: UntypedComponentRef = globals.untyped_node(parent).parent();\n\nlet parent_idx = globals.untyped_node(grandparent)\n    .children()\n    .iter()\n    .position(|x| *x == parent)\n    .expect(\"this will never fail\");\n```\n\nYou can even get a typed reference if you're absolutely certain of the parent type;\n\n```rust\nlet parent: UntypedComponentRef = globals.parent(cref);\nlet parent: ComponentRef\u003cFooComponent\u003e = parent.to_typed();\nlet parent: \u0026mut FooComponent = globals.get_mut(parent);\n\n// We now have a mutable reference to our parent\n```\n\nMuch like other UI libraries, there are downsides to this kind of implementation;\n\n- The global object moves things in and out for processing. This means you can't just do whatever you want whenever you want. The object you may be referencing may be \"in use\".\n- Component references aren't aware of deletion state. A reference may very well be invalid and thus cause a `panic` when used.\n\n## License\n\nVX is licensed under either\n\n- [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)\n- [MIT](http://opensource.org/licenses/MIT)\n\nat your choosing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjazzfool%2Fvx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjazzfool%2Fvx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjazzfool%2Fvx/lists"}