{"id":20089909,"url":"https://github.com/bugadani/embedded-layout","last_synced_at":"2025-05-06T03:30:31.128Z","repository":{"id":48554044,"uuid":"274230058","full_name":"bugadani/embedded-layout","owner":"bugadani","description":"Simple layout operations for embedded-graphics","archived":false,"fork":false,"pushed_at":"2025-04-25T22:05:31.000Z","size":244,"stargazers_count":23,"open_issues_count":7,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-25T23:19:00.641Z","etag":null,"topics":["embedded-graphics","embedded-layout","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/bugadani.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2020-06-22T19:58:47.000Z","updated_at":"2025-04-25T22:05:36.000Z","dependencies_parsed_at":"2025-04-25T23:28:47.453Z","dependency_job_id":null,"html_url":"https://github.com/bugadani/embedded-layout","commit_stats":{"total_commits":157,"total_committers":2,"mean_commits":78.5,"dds":0.03821656050955413,"last_synced_commit":"b6403eee34e16f78186e6f164876cae40de29c97"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugadani%2Fembedded-layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugadani%2Fembedded-layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugadani%2Fembedded-layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bugadani%2Fembedded-layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bugadani","download_url":"https://codeload.github.com/bugadani/embedded-layout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252615954,"owners_count":21776889,"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":["embedded-graphics","embedded-layout","rust"],"created_at":"2024-11-13T16:20:44.144Z","updated_at":"2025-05-06T03:30:30.796Z","avatar_url":"https://github.com/bugadani.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"embedded-layout\n===============\n\n`embedded-layout` extends [`embedded-graphics`] with basic layout functions.\n\n`embedded-layout` consists of three main parts:\n - alignments that can be used to position two objects relative to one another\n   * `horizontal`\n     * `NoAlignment`, `Left`, `Right`, `Center`\n     * `LeftToRight`, `RightToLeft`\n   * `vertical`\n     * `NoAlignment`, `Top`, `Bottom`, `Center`\n     * `TopToBottom`, `BottomToTop`\n - layouts that can be used to arrange multiple views\n   * `LinearLayout`\n - view groups which are collections of view objects\n   * `Chain` to create ad-hoc collections (can hold views of different types)\n   * `Views` to create view groups from arrays and slices (can only hold views of a single  type)\n   * `derive(ViewGroup)` to turn any plain old Rust struct into a view group\n\n## Example\n\nThe examples are based on [the embedded-graphics simulator]. The simulator is built on top of\n`SDL2`. See the [simulator README] for more information.\n\n![embedded-layout example](assets/nested-layout-example.png)\n\n```rust\nuse embedded_graphics_simulator::{\n    BinaryColorTheme, OutputSettingsBuilder, SimulatorDisplay, Window,\n};\n\nuse embedded_graphics::{\n    mono_font::{ascii::FONT_6X9, MonoTextStyle},\n    pixelcolor::BinaryColor,\n    prelude::*,\n    primitives::{Circle, PrimitiveStyle, Triangle},\n    text::Text,\n};\nuse embedded_layout::{layout::linear::LinearLayout, prelude::*};\n\nfn main() -\u003e Result\u003c(), core::convert::Infallible\u003e {\n    let mut display: SimulatorDisplay\u003cBinaryColor\u003e = SimulatorDisplay::new(Size::new(128, 64));\n\n    let output_settings = OutputSettingsBuilder::new()\n        .theme(BinaryColorTheme::OledBlue)\n        .build();\n\n    // Create a Rectangle from the display's dimensions\n    let display_area = display.bounding_box();\n\n    // Style objects\n    let text_style = MonoTextStyle::new(\u0026FONT_6X9, BinaryColor::On);\n\n    let thin_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 1);\n    let thick_stroke = PrimitiveStyle::with_stroke(BinaryColor::On, 3);\n    let fill_on = PrimitiveStyle::with_fill(BinaryColor::On);\n    let fill_off = PrimitiveStyle::with_fill(BinaryColor::Off);\n\n    // Primitives to be displayed\n    let triangle = Triangle::new(Point::new(0, 0), Point::new(12, 0), Point::new(6, 12))\n        .into_styled(thin_stroke);\n\n    let circle = Circle::new(Point::zero(), 11).into_styled(thick_stroke);\n    let circle2 = Circle::new(Point::zero(), 15).into_styled(fill_on);\n    let triangle2 =\n        Triangle::new(Point::new(0, 0), Point::new(10, 0), Point::new(5, 8)).into_styled(fill_off);\n    let text = Text::new(\"embedded-layout\", Point::zero(), text_style);\n\n    // The layout\n    LinearLayout::vertical(\n        Chain::new(text)\n            .append(LinearLayout::horizontal(Chain::new(triangle).append(circle)).arrange())\n            .append(\n                Chain::new(triangle2.align_to(\u0026circle2, horizontal::Center, vertical::Top))\n                    .append(circle2),\n            ),\n    )\n    .with_alignment(horizontal::Center)\n    .arrange()\n    .align_to(\u0026display_area, horizontal::Center, vertical::Center)\n    .draw(\u0026mut display)\n    .unwrap();\n\n    Window::new(\"Layout example\", \u0026output_settings).show_static(\u0026display);\n    Ok(())\n}\n```\n\n## Development setup\n\n### Minimum supported Rust version\nThe minimum supported Rust version for embedded-layout is 1.61.0 or greater.\n\n### Installation\n\nFor setup in general, follow the installation instructions for [`embedded-graphics`].\n\nTo install SDL2 on Windows, see https://github.com/Rust-SDL2/rust-sdl2#windows-msvc\n\n[`embedded-graphics`]: https://github.com/embedded-graphics/embedded-graphics/\n[the embedded-graphics simulator]: https://github.com/embedded-graphics/simulator\n[simulator README]: https://github.com/embedded-graphics/simulator/blob/master/README.md#usage-without-sdl2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugadani%2Fembedded-layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbugadani%2Fembedded-layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugadani%2Fembedded-layout/lists"}