{"id":17773425,"url":"https://github.com/luleyleo/conrod-boilerplate","last_synced_at":"2025-03-15T16:32:09.993Z","repository":{"id":135663041,"uuid":"145246975","full_name":"luleyleo/conrod-boilerplate","owner":"luleyleo","description":"A minimal Conrod project setup","archived":true,"fork":false,"pushed_at":"2018-08-18T21:14:08.000Z","size":19,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T14:44:16.668Z","etag":null,"topics":["boilerplate","conrod","gui","rust"],"latest_commit_sha":null,"homepage":null,"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/luleyleo.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":"2018-08-18T19:24:11.000Z","updated_at":"2023-09-04T08:40:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"3a1929f9-d2a5-408a-9d83-0b4be46d7120","html_url":"https://github.com/luleyleo/conrod-boilerplate","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/luleyleo%2Fconrod-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luleyleo%2Fconrod-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luleyleo%2Fconrod-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luleyleo%2Fconrod-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luleyleo","download_url":"https://codeload.github.com/luleyleo/conrod-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243760345,"owners_count":20343626,"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":["boilerplate","conrod","gui","rust"],"created_at":"2024-10-26T21:44:03.505Z","updated_at":"2025-03-15T16:32:09.985Z","avatar_url":"https://github.com/luleyleo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Getting started with Conrod\n\n## Why this repository exists\nThis is a cleaner and documented rewrite of the template that I personally use when I write an app using Conrod. I've written this to make it easier to get started with Conrod (or just start a new project) and because many people complained about the current state of the guide (righteously)\n\nIn order to be flexible Conrod leaves a lot of choices (and thus work) to you an requires a fair amount of boilerplate to get started.\n\nThis repository provides a starting point, implemented in the way I personally use Conrod.\nYou can develop an application with Conrod using any model you like, mine is inspired by React.js and thus this boilerplate makes it ease to do this.\n\nAnd while this template gives an idea of how to structure an application that uses Conrod, it wont teach you about how layout so forth work, for this you can use the examples of Conrod.\n\n## Its structure\nThe basic structure of a Conrod app looks like this:\n```\n- project\n    - src\n        - components\n            - app.rs\n        - boiler.rs\n        - eventloop.rs\n        - main.rs\n    - Cargo.toml\n```\n\n### The main file\nI prefer to keep my `main.rs` as clean as possible and use it only for `extern crate` and `mod` declarations.\nThe main function simply looks like this:\n```rust\nmain() {\n    boiler::boil();\n}\n```\n\n### The eventloop\nThis file is literally a copy of the end of the `examples/support/mod.rs` file of Conrod and contains the `EventLoop` struct which keeps the app running.  It works and that is all I care about.\n\n### The boiler\nThis file is a lot more interesting. It is a copy of `examples/counter.rs` modified to simply render my `App`.\nThose are the interesting parts of this file:\n- window title and dimensions\n- fonts\n- images\n- render the `App`\n\nUsing the `TITLE`,  `INITIAL_WINDOW_WIDTH` and `INITIAL_WINDOW_HEIGHT` statics/contants you can control those properties **at startup**.\n\n\u003e How you deal with multiple fonts or any images is not *yet* included in this template but I intend to do this in a branch.\n\n### The app\nThis is the heart of your application.\n\n#### The simple case\nIn a simple application this is where everything happens.\nBy adding stuff to the `State` struct you can preserve well... state.\nAnd your apps ui will be where the `Button` is currently created.\n\n#### The complex case\nIn this case your `App` component should stay as simple as possible, otherwise things can get messy.\nIt will basically connect your apps pieces. Anything that has even just some logic and state should go into its own `component` which basically is just a custom `Widget` just like the `App`.\nFor example if you have a todo app that consists out of a `Header`, `List` and `Footer` you'll probably end up with the following structure:\n\n```rust\n- project\n    - src\n        - components\n            - app.rs\n            - header.rs\n            - list.rs\n            - todo_item.rs\n            - footer.rs\n        - models\n            - todo.rs\n        - boiler.rs\n        - eventloop.rs\n        - main.rs\n    - Cargo.toml\n```\n\nThe header job will be to provide a `TextField` so a user can write down a new todo and a `Button` to submit it. Thus the headers `State` will have a field `input: String` and emit `Option\u003cTodo\u003e` as Event.\n\nThe list will render all todos as `TodoItem`s that it gets passed in a list and emit a `Vec\u003cTodoListEvent\u003e`\n```rust\nenum TodoListEvent {\n    Toggled(Id),\n    Removed(Id),\n    Updated(Id, String),\n}\n```\n\nA `TodoItem` shows a `Toggle` whether the task is completed, a `Button` to delete it and lets you edit its content. Thus it will emit a `Vec\u003cTodoItemEvent\u003e`\n```rust\nenum TodoItemEvent {\n    Toggled,\n    Removed,\n    Updated(String),\n}\n```\nthat can be picked up by the `TodoList` and, combined with its Id, be sent further up to the `App`.\n\nThe `Footer` lets the user filter the todos (All / Open / Closed) and thus shows for example three `Toggle`s and emits an `Option\u003cTodoFilter\u003e`\n```rust\nenum TodoFilter {\n    All,\n    Open,\n    Closed\n}\n```\n\nAnd then the `App` combines those three to an actually useful piece.\nThe `App` holds a `Vec\u003cTodo\u003e` and `TodoFilter` in its State.\nThen it then creates the three parts and deals with their events.\n```rust\nfn update(...) {\n    for new_todo in Header::new()\n        .do_some_layout()\n        .set(state.ids.header, ui)\n    {\n        state.update(|state| state.todos.push(new_todo));\n    }\n\n    for event in List::new(state.todos.iter().filter(state.filter.check))\n        .do_some_layout()\n        .set(state.ids.list, ui)\n    {\n        match event {\n            TodoListEvent::Toggled(id) =\u003e do_stuff(),\n            ...\n        }\n    }\n\n    for new_filter in Footer::new()\n        .do_some_layout()\n        .set(state.ids.footer, ui)\n    {\n        state.update(|state| state.filter = new_filter);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluleyleo%2Fconrod-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluleyleo%2Fconrod-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluleyleo%2Fconrod-boilerplate/lists"}