{"id":22292382,"url":"https://github.com/abodelot/sfml-widgets","last_synced_at":"2025-08-24T02:10:57.252Z","repository":{"id":55349503,"uuid":"21246159","full_name":"abodelot/sfml-widgets","owner":"abodelot","description":"A simple GUI module for SFML","archived":false,"fork":false,"pushed_at":"2024-03-14T05:28:00.000Z","size":521,"stargazers_count":102,"open_issues_count":4,"forks_count":22,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T05:22:33.094Z","etag":null,"topics":["gui","sfml"],"latest_commit_sha":null,"homepage":"","language":"C++","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/abodelot.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}},"created_at":"2014-06-26T15:49:04.000Z","updated_at":"2025-03-23T10:04:44.000Z","dependencies_parsed_at":"2022-08-14T21:52:52.921Z","dependency_job_id":null,"html_url":"https://github.com/abodelot/sfml-widgets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abodelot/sfml-widgets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abodelot%2Fsfml-widgets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abodelot%2Fsfml-widgets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abodelot%2Fsfml-widgets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abodelot%2Fsfml-widgets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abodelot","download_url":"https://codeload.github.com/abodelot/sfml-widgets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abodelot%2Fsfml-widgets/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262959560,"owners_count":23391057,"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":["gui","sfml"],"created_at":"2024-12-03T17:21:38.645Z","updated_at":"2025-07-01T12:05:44.057Z","avatar_url":"https://github.com/abodelot.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"SFML Widgets\n============\n\nA simple GUI module for SFML.\n\n- Spritesheet based: a single image file to customize widget style\n- Simple events: set a `std::function\u003cvoid(void)\u003e` callback on widgets to trigger functions on UI events.\n- Layouts: automatically align content without computing positions\n\n![workflow](https://github.com/abodelot/sfml-widgets/actions/workflows/ci.yml/badge.svg)\n\n- Author: Alexandre Bodelot \u003calexandre.bodelot@gmail.com\u003e\n- License: [MIT License](http://opensource.org/licenses/MIT) (See LICENSE file)\n\nRun `make` to build the library (`lib/libsfml-widgets.a`) and the demo program.\n\nYou can then run the demo: `./sfml-widgets-demo`\n\n## Setup\n\n1. Load resources (font, spritesheet) in static class `gui::Theme`\n2. Use `gui::Menu` to create a new sfml-widgets menu. It needs to be connected to your SFML render window, which is given to the constructor.\n3. Create widgets, add theme to the menu and define callbacks on them. NOTE: widgets must be dynamically allocated (`new`). The `gui::Menu` destructor will take care of deallocating widgets.\n\nMinimal example:\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cSFML/Graphics.hpp\u003e\n#include \"Gui/Gui.hpp\"\n\nint main()\n{\n    sf::RenderWindow app(sf::VideoMode(800, 600), \"SFML Widgets\", sf::Style::Close);\n\n    // Declare menu\n    gui::Menu menu(app);\n\n    gui::Theme::loadFont(\"demo/tahoma.ttf\");\n    gui::Theme::loadTexture(\"demo/texture-default.png\");\n\n    // Create some button widget\n    gui::Button* button = new gui::Button(\"My button\");\n\n    // Insert button into menu\n    menu.add(button);\n\n    // Define a callback\n    button-\u003esetCallback([] {\n        std::cout \u003c\u003c \"click!\" \u003c\u003c std::endl;\n    });\n\n    // Start the application loop\n    while (app.isOpen())\n    {\n        // Process events\n        sf::Event event;\n        while (app.pollEvent(event))\n        {\n            // Send events to the menu\n            menu.onEvent(event);\n\n            if (event.type == sf::Event::Closed)\n                app.close();\n        }\n\n        // Optional: clear window with theme background color\n        app.clear(gui::Theme::windowBgColor);\n\n        // Render menu\n        app.draw(menu);\n\n        // Update the window\n        app.display();\n    }\n\n    return 0;\n}\n```\n\n`demo/demo.cpp` conains a more complex example, featuring all widgets.\n\n## Widgets\n\n### `gui::Button`\n\nA simple press button.\n\n![button](doc/button.png)\n\n### `gui::Checkbox`\n\nA button with enabled/disabled state.\n\n![checkbox](doc/checkbox.png)\n\n### `gui::Image`\n\nDisplays an SFML texture.\n\nIt's a simple wrapper around `sf::Texture`, to display a texture as part of the UI.\n\n### `gui::Label`\n\nA static text element.\n\nIt's a simple wrapper around `sf::Text`, to display a text as part of the UI.\n\n### `gui::OptionsBox`\n\nA list of label/value pairs.\n\n![optionsbox](doc/optionsbox.png)\n\nUse templates to define value type. Example: `gui::OptionsBox\u003csf::Color\u003e`.\n\nAdd value with: `optionsBox-\u003eaddItem(\"Red\", sf::Color::Red)`;\n\n### `gui::ProgressBar`\n\nA simple horizontal or vertical progress bar.\n\n![progress-bar](doc/progress-bar.png)\n\n* `orientation`: `gui::Horizontal` or `gui::Vertical`\n* `labelPlacement`: `gui::LabelNone`, or `gui::LabelOver`, or `gui::Outside`\n\n### `gui::Slider`\n\nProvides an horizontal or vertical slider.\n\n![slider](doc/slider.png)\n\n* `orientation`: `gui::Horizontal` or `gui::Vertical`\n\n### `gui::TextBox`\n\nA one-line text editor.\n\n![textbox](doc/textbox.png)\n\nIt supports text cursor, and text selection (with mouse or keyboard shortcuts).\n\n## Layouts\n\nLayouts are containers for widgets. They are also widgets themselves, and can be nested!\n\n### `gui::Menu`\n\nThe special, unique root layout. It behave like a `VBoxLayout`.\n\n### `gui::HBoxLayout`\n\nLines up widgets horizontally.\n\nUse `layout-\u003eadd(widget)` to append a widget on a new line.\n\n### `gui::VBoxLayout`\n\nLines up widgets vertically.\n\nUse `layout-\u003eadd(widget)` to append a widget on a new column.\n\n### `gui::FormLayout`\n\nManages forms of input widgets and their associated labels.\n\nUse `layout-\u003eaddRow(\"my label\", widget)` to add a new line with label on the left, and widget on the right.\n\n## Theming\n\nTo customize the theme, you can:\n\n- Change the theme values (padding, color, font, etc.) defined the static class `gui::Theme`.\n- Use a custom spritesheet image.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabodelot%2Fsfml-widgets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabodelot%2Fsfml-widgets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabodelot%2Fsfml-widgets/lists"}