{"id":9406061,"url":"https://github.com/linebender/masonry","last_synced_at":"2025-08-20T09:31:35.671Z","repository":{"id":65707054,"uuid":"545009481","full_name":"linebender/masonry","owner":"linebender","description":"Rust UI design toolkit - moved.","archived":true,"fork":false,"pushed_at":"2024-05-29T15:20:05.000Z","size":7488,"stargazers_count":405,"open_issues_count":0,"forks_count":15,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-08-04T15:02:53.835Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/linebender/xilem/tree/main/masonry","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linebender.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-03T16:16:21.000Z","updated_at":"2024-08-04T15:02:56.939Z","dependencies_parsed_at":"2024-01-13T16:48:04.054Z","dependency_job_id":"6afdcf1c-f33e-4dff-b123-a4dfb5ab4df0","html_url":"https://github.com/linebender/masonry","commit_stats":{"total_commits":2215,"total_committers":161,"mean_commits":13.75776397515528,"dds":0.7602708803611739,"last_synced_commit":"3cfc2cddec05d48a31a9812bdda27792d336f03f"},"previous_names":["linebender/masonry","poignardazur/masonry-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linebender%2Fmasonry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linebender%2Fmasonry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linebender%2Fmasonry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linebender%2Fmasonry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linebender","download_url":"https://codeload.github.com/linebender/masonry/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":217049681,"owners_count":16117040,"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-05-10T17:03:13.429Z","updated_at":"2024-08-26T18:31:11.177Z","avatar_url":"https://github.com/linebender.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\u003e [!Important]\n\u003e Masonry has been moved into the [Xilem](https://github.com/linebender/xilem/tree/main/masonry) repository.\n\u003e It can be found in the `masonry` folder at the root in that repository, which in turn can be found at \u003chttps://github.com/linebender/xilem/\u003e.\n\u003e This repository may be useful for exploring the history of Masonry.\n\u003e\n\u003e The version of Masonry in that repository is now also [published](https://crates.io/crates/masonry) on crates.io.\n\n## Masonry\n\n\u003e [!Caution]\n\u003e **This README is outdated.**\n\u003e\n\u003e See the info box above for more details.\n\u003e The previous README is included for historical reference.\n\nMasonry is a framework that aims to provide the foundation for Rust GUI libraries.\n\nMasonry gives you a platform to create windows (using [Glazier](https://github.com/linebender/glazier) as a backend) each with a tree of widgets. It also gives you tools to inspect that widget tree at runtime, write unit tests on it, and generally have an easier time debugging and maintaining your app.\n\nThe framework is not opinionated about what your user-facing abstraction will be: you can implement immediate-mode GUI, the Elm architecture, functional reactive GUI, etc, on top of Masonry.\n\nThis project was originally a fork of [Druid](https://github.com/linebender/druid) that emerged from discussions I had with Raph Levien and Colin Rofls about what it would look like to turn Druid into a foundational library.\n\n\u003c!-- ## Installing\n\n```sh\ncargo add masonry\n```\n\n### Linux\n\nOn Linux, Masonry requires gtk+3; see [GTK installation page](https://www.gtk.org/docs/installations/linux/).\n(On ubuntu-based distro, running `sudo apt-get install libgtk-3-dev` from the terminal will do the job.)\n\n### OpenBSD\n\nOn OpenBSD, Masonry requires gtk+3; install from packages:\n\n```sh\npkg_add gtk+3\n``` --\u003e\n\n## Example\n\nThe todo-list example looks like this:\n\n```rust\nuse masonry::widget::{prelude::*, TextBox};\nuse masonry::widget::{Button, Flex, Label, Portal, WidgetMut};\nuse masonry::Action;\nuse masonry::{AppDelegate, AppLauncher, DelegateCtx, WindowDescription, WindowId};\n\nconst VERTICAL_WIDGET_SPACING: f64 = 20.0;\n\nstruct Delegate {\n    next_task: String,\n}\n\nimpl AppDelegate for Delegate {\n    fn on_action(\n        \u0026mut self,\n        ctx: \u0026mut DelegateCtx,\n        _window_id: WindowId,\n        _widget_id: WidgetId,\n        action: Action,\n    ) {\n        match action {\n            Action::ButtonPressed =\u003e {\n                let mut root: WidgetMut\u003cPortal\u003cFlex\u003e\u003e = ctx.get_root();\n                let mut flex = root.child_mut();\n                flex.add_child(Label::new(self.next_task.clone()));\n            }\n            Action::TextChanged(new_text) =\u003e {\n                self.next_task = new_text.clone();\n            }\n            _ =\u003e {}\n        }\n    }\n}\n\nfn main() {\n    // The main button with some space below, all inside a scrollable area.\n    let root_widget = Portal::new(\n        Flex::column()\n            .with_child(\n                Flex::row()\n                    .with_child(TextBox::new(\"\"))\n                    .with_child(Button::new(\"Add task\")),\n            )\n            .with_spacer(VERTICAL_WIDGET_SPACING),\n    );\n\n    let main_window = WindowDescription::new(root_widget)\n        .title(\"To-do list\")\n        .window_size((400.0, 400.0));\n\n    AppLauncher::with_window(main_window)\n        .with_delegate(Delegate {\n            next_task: String::new(),\n        })\n        .log_to_console()\n        .launch()\n        .expect(\"Failed to launch application\");\n}\n```\n\nAs you can see, compared to crates like Druid or Iced, Masonry takes a fairly low-level approach to GUI: there is no complex reconciliation logic or dataflow going on behind the scenes; if you want to add a widget to the flex container, you call `flex.add_child(your_widget)`.\n\nThis simplicity makes Masonry somewhat painful if you want to use it to actually build GUI applications. The hope is that, by being low-level and straightforward, developers can easily build GUI frameworks on top of it.\n\n(Well, in theory. The first stress-test will be porting [Panoramix](https://github.com/PoignardAzur/panoramix), a React-style GUI in Rust, to Masonry.)\n\n## Unit tests\n\nMasonry is designed to make unit tests easy to write, as if the test function were a mouse-and-keyboard user. Tests look like this:\n\n```rust\n#[test]\nfn some_test_with_a_button() {\n    let [button_id] = widget_ids();\n    let widget = Button::new(\"Hello\").with_id(button_id);\n\n    let mut harness = TestHarness::create(widget);\n\n    // Make a snapshot test of the visual contents of the window\n    assert_render_snapshot!(harness, \"hello\");\n\n    harness.edit_root_widget(|mut button, _| {\n        let mut button = button.downcast::\u003cButton\u003e().unwrap();\n        button.set_text(\"World\");\n    });\n\n    // Make new snapshot test now that the window has changed\n    assert_render_snapshot!(harness, \"world\");\n\n    // References to widget automatically implement Debug, and\n    // will print their part of the widget hierarchy.\n    println!(\"Window contents: {:?}\", harness.root_widget());\n\n    // You can also use insta to snapshot-test the widget hierarchy\n    assert_debug_snapshot!(harness.root_widget());\n\n    // Clicking on a button will produce a \"ButtonPressed\" action.\n    harness.mouse_click_on(button_id);\n    assert_eq!(\n        harness.pop_action(),\n        Some((Action::ButtonPressed, button_id))\n    );\n}\n```\n\n\u003c!-- ## Contributing\n\nIssues and PRs are welcome. See [`help-wanted` issues](https://github.com/PoignardAzur/masonry-rs/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) if you don't know where to begin. --\u003e\n\n## Roadmap\n\nThe immediate next steps are:\n\n- [X] Remove Env type and Data trait (#8)\n- [ ] Re-add Dialog feature (#25)\n- [ ] Switch to using Vello and Glazier (#24)\n- [ ] Refactor TextLayout (#23)\n\n- [ ] Rework Widget trait (#26)\n\n- [ ] Port [Panoramix](https://github.com/PoignardAzur/panoramix) to Masonry\n- [ ] Port [Xilem](https://github.com/linebender/xilem) to Masonry\n\nSee [ROADMAP.md](./ROADMAP.md) and [the issues page](https://github.com/PoignardAzur/masonry-rs/issues) for more.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinebender%2Fmasonry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinebender%2Fmasonry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinebender%2Fmasonry/lists"}