A GUI frontend in Rust based on web-view

Overview

neutrino

I am not working anymore on this project. If you want to become a maintainer of neutrino, please answer to this issue.

Preamble

Docs | Repo | Wiki | Crate

Neutrino is a MVC GUI framework written in Rust. It lets users create GUI applications by positioning widgets on a window and by handling events. Neutrino is based on the web-view crate provided by Boscop. As such, Neutrino renders the application using web technologies as HTML and CSS. As it is based on web-view, Neutrino does not embed a whole web browser. So don't worry, due to the very lightweight footprint of web-view, you won't have to buy more memory for your computer.

Install

In order to use Neutrino, you will have to use cargo. Just add the following line to your Cargo.toml and you'll be done :

neutrino = "<last_version>"

On Linux, you'll have to install webkit2gtk's development library. For example, in Ubuntu or Debian:

sudo apt install -y libwebkit2gtk-4.0-dev

Examples

Comments
  • Time based events

    Time based events

    I think this does not come under MVC. But is it possible to generate update events artificially to force-execute on_update functions?

    Example, I want to auto-reload the window from time to time, but I don't want to click on a button every 5 minutes.

    opened by rnbguy 7
  • Blurry interface on Windows

    Blurry interface on Windows

    After setting up a simple UI with just a menu, I realized that the text is a bit blurry (small resolution). This is a screen shot: neutrino_blurry

    These are my system specification: image

    opened by GioPat 6
  • Unset selectable

    Unset selectable

    As selectable is false by default, we don't need an unset_selectable function. Moreover, set_selectable should take no arguments, and only set selectable to true. All the other flags are already implemented like that, we should not change the API for one function.

    Let me know if you want to do it @fabrixxm, I'll do it otherwise.

    opened by alexislozano 6
  • Am I blind or how do I build the `neutrino` app mentioned in the wiki examples

    Am I blind or how do I build the `neutrino` app mentioned in the wiki examples

    All wiki examples mention a binary neutrino. Where do I find it. Or how can I build it?

    https://github.com/alexislozano/neutrino/wiki/Hello-World

    neutrino run --example hello_world
    

    or

    https://github.com/alexislozano/neutrino/wiki/Adding-data

    neutrino run --example add_data
    
    opened by zzeroo 4
  • cargo test fails

    cargo test fails

    A git clone, followed by cargo test gave me:

    failures:
    
    ---- src/widgets/menubar.rs - widgets::menubar::MenuBar (line 89) stdout ----
    error[E0061]: this function takes 3 parameters but 1 parameter was supplied
      --> src/widgets/menubar.rs:151:20
       |
    64 |     let mut file = MenuItem::new("File");
       |                    ^^^^^^^^^^^^^^^^^^^^^ expected 3 parameters
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0061`.
    Couldn't compile the test.
    
    rustc --version
    rustc 1.40.0 (73528e339 2019-12-16)
    
    cargo --version
    cargo 1.40.0 (bc8e4c8be 2019-11-22)
    
    opened by andrewdavidmackenzie 4
  • Examples are blank on macOS Mojave

    Examples are blank on macOS Mojave

    I tried these:

    hello_world demo_default image_viewer

    A window appears, but its content is blank.

    Here a screenshot of hello_world:

    Screen Shot 2019-09-04 at 22 49 02

    When I click inside of the window, a context menu with the field "Reload" appears (not sure whether it's a bug or a feature — should I open an issue for this too?). I do reload, but the window stays blank anyway.

    Screen Shot 2019-09-04 at 22 51 02

    opened by ales-tsurko 4
  • TextInput resets itself

    TextInput resets itself

    The TextInput field keeps resetting itself after typing in some text and clicking somewhere else on the screen (or pressing keys like Alt). A change event never occurs

    Platform: Windows 10, 1909 Compiler: Rust 1.40.0 (stable-x86_64-pc-windows-msvc)

    Code constructing the component
    use {
        neutrino::widgets::{
            button::*,
            container::{Alignment, Container, Direction, Position},
            label::Label,
            textinput::*,
        },
        std::{cell::RefCell, rc::Rc},
    };
    
    pub struct Options {
        game_path: String,
    }
    
    impl Options {
        fn new() -> Self {
            Self {
                game_path: "".to_string(),
            }
        }
    
        #[allow(dead_code)]
        fn get_game_path(&self) -> &str {
            &self.game_path
        }
    
        fn set_game_path(&mut self, game_path: String) {
            self.game_path = game_path;
        }
    }
    
    pub struct GamePathListener {
        options: Rc<RefCell<Options>>,
    }
    
    impl GamePathListener {
        fn new(options: Rc<RefCell<Options>>) -> Self {
            Self { options }
        }
    }
    
    impl TextInputListener for GamePathListener {
        fn on_change(&self, state: &TextInputState) {
            println!("{:#?}", state.value());
            self.options
                .borrow_mut()
                .set_game_path(state.value().into());
        }
    
        fn on_update(&self, _state: &mut TextInputState) {}
    }
    
    pub struct SaveButtonListener {
        options: Rc<RefCell<Options>>,
    }
    
    impl SaveButtonListener {
        fn new(options: Rc<RefCell<Options>>) -> Self {
            Self { options }
        }
    }
    
    impl ButtonListener for SaveButtonListener {
        fn on_change(&self, _state: &ButtonState) {
            println!("{}", self.options.borrow().get_game_path());
        }
    
        fn on_update(&self, _state: &mut ButtonState) {}
    }
    
    pub fn construct_options_container() -> Box<Container> {
        let options = Rc::new(RefCell::new(Options::new()));
    
        let mut root_container = Container::new("options-page");
        root_container.set_position(Position::Center);
        root_container.set_alignment(Alignment::Center);
    
        let mut game_path_container = Container::new("game-path-container");
        game_path_container.set_alignment(Alignment::Center);
        game_path_container.set_position(Position::Center);
        game_path_container.set_direction(Direction::Horizontal);
    
        let mut game_path_label = Label::new("game-path-label");
        game_path_label.set_text("Game path: ");
    
        let mut game_path_input = TextInput::new("game-path");
        let game_path_input_listener = GamePathListener::new(Rc::clone(&options));
        game_path_input.set_listener(Box::new(game_path_input_listener));
        game_path_input.set_placeholder("Game path");
        game_path_input.set_size(70);
    
        game_path_container.add(Box::new(game_path_label));
        game_path_container.add(Box::new(game_path_input));
    
        let mut save_button = Button::new("save-options");
        let save_button_listener = SaveButtonListener::new(Rc::clone(&options));
        save_button.set_listener(Box::new(save_button_listener));
        save_button.set_text("Save");
    
        root_container.add(Box::new(game_path_container));
        root_container.add(Box::new(save_button));
    
        Box::new(root_container)
    }
    
    opened by aumetra 3
  • State issues with login example on Windows

    State issues with login example on Windows

    The textboxes do not store the input correctly. If I write something and switch via Tab it works just fine. However if I switch via the mouse the textbox clears itself. Trying to log in doesn't work either. Not sure if I misstype the password or the button is not working.

    opened by Songtronix 3
  • Can reload from context menu in examples

    Can reload from context menu in examples

    But according to this reply, the Reload button:

    should appear only when the debug attribute of window is set to true, which is not the case by default

    opened by ales-tsurko 3
  • [Question]: write html and attach events to rust from it.

    [Question]: write html and attach events to rust from it.

    Hi, first of all nice work! I really like your library!

    I was wondering if there was a way to write html and add rust event listeners directly to it.

    Thanks!

    opened by rollback91 2
  • A bucket list of feedback

    A bucket list of feedback

    I have tried running this only on Windows. There are enough problems that I’m just filing this lot in one issue rather than filing many issues. Do what you will with this feedback; I doubt I shall return to the project. (I was trying it out out of curiosity; I have no near-future projects that could benefit from such a thing.)

    • Doesn’t handle high-DPI displays.
    • The web view is not initially focused, so keyboard shortcuts don’t work until you click into the window.
    • Alt should be getting me access to the menus, e.g. Alt followed by F, or Alt+F, for the File menu. Use access keys everywhere, with & prefixing being the standard (e.g. “&File”), and underline the corresponding character in the menus when interacting with them by keyboard (that is, it’s acceptable, though not required, to hide the underline if you’re clicking, but it’s required that you show the underlines if you’re using the keyboard at all).
    • Arrow keys should navigate around inside and between menus.
    • Menus need to completely steal and hold focus.
      • You should very strongly consider using native menus rather than HTML ones, since you basically need to do that on macOS to feel native anyway.
    • In tabs, I expect Ctrl+Tab to switch to the next and Ctrl+Shift+Tab the previous.
    • The keyboard shortcut technical mechanism is way too simple and will not scale well at all.
    • Keyboard shortcuts are not formatted according to platform conventions. On Windows the keyboard shortcut platform convention is to use + for chords, not -; e.g. Ctrl+Q, not Ctrl-Q. macOS’s conventions are much more radically different, and better-documented too.
    • You should set cursor: default on the root, to go with the user-select: none behaviour. cursor: auto should be withheld for places like .selectable.
    • user-select: none doesn’t work properly in MSHTML (which you’re using on Windows), as it only blocks selection from starting inside such an area, not from selecting text. This means that to do things properly you need to manage the selection more actively. We do this in Fastmail’s webmail (on which I work), where UI elements are generally user-select: none, and we also want to contain the selection, so that when showing multiple emails in a thread, a selection starting inside one message doesn’t extend outside that message (this matches people’s expectations).
      • Setting * { user-select: none; } is a bad idea; it’s generally better to set :root { user-select: none } and rely on the cascade.
    • You look to have implemented what you could with div soup. This is a terribly bad idea. Effects include:
      • Most controls are not focusable.
      • Basically nothing is screen-reader accessible.

    I strongly recommend that you have a look at how other projects do things, both desktop and web. For desktop, Qt is often a good one to look at, and Microsoft and Apple’s native toolkits are good too. For web, the story is much weaker, in part because it’s generally not about using web tech on the desktop, but rather on the web where various additional limitations apply and where you’re not trying to imitate a desktop platform; but there are a few options out there that work well for general UI, and I would consider Office UI Fabric’s React implementation to be the best in most regards.

    On the div soup problem: use the native control elements everywhere, even when it makes styling harder, as long as it’s still possible. Set ARIA attributes where suitable and definitely where you don’t use the native form field types. Manage focus properly. Familiarise yourself with documents like ARIA in HTML and WAI-ARIA Authoring Practices.

    As it stands, I like the goals of this project, but I think you’re ignoring too much good work that already exists, and implementing all the same basic problems all over again, with some additional problems to boot where you’re doing things in ways that are discouraged everywhere, and not just a matter of web tech not being perfectly adapted to desktop problems.

    The feel of the entire library at present is “technical proof of concept”. In web terms, it feels more like jQuery in its ad-hocness and less like a solid MVC framework. There’s far more code than there should be in many places due to things like you reimplementing parts of the DOM, but not as much as the DOM provides either. I strongly recommend aiming to wrap existing DOM functionality more of the time, rather than reimplementing it badly on top of it. There are various other places where the design is not going to scale well; for example, the listener approach is quite insufficient for keyboard shortcuts, because you often want to enable or disable keyboard shortcuts based upon the presence of widgets on screen, but the widgets won’t ancestors of the focused element, so under your current design such things would tend to need to go on the window listener, which scales very poorly.

    The underlying library that we use at Fastmail is a home-grown one and open source, Overture. We don’t generally recommend other people use it (I’m not aware of anyone other than us that uses it, and we definitely maintain it for ourselves), but there are parts of it that you could find useful to think about in its design—because unlike most JS libraries, it is very much designed for making applications, and not web pages. Perhaps most immediately pertinent is its handling of keyboard shortcuts and modals. It starts with needing to track when views enter and exit the document, so that they can register and unregister things.

    In more popular code for the web, I again recommend Fabric React. Its management of things like focus styling and functionality is exquisite, peerless in web tech. It’s just a pity it’s React rather than generic JS!

    opened by chris-morgan 2
  • I don't have time anymore for this project

    I don't have time anymore for this project

    Hello people! For those using neutrino, I'm very happy my work was useful for someone. But it's been some time I don't intend to work anymore on this project. I could add some new maintainers to the project, would it be a solution ? If you want to become a maintainer of neutrino, please answer to this issue ;)

    meta 
    opened by alexislozano 1
  • failed to run custom build command for `webview-sys v0.1.4`

    failed to run custom build command for `webview-sys v0.1.4`

    Hello!There is some question when running the example given by the wiki. It reminds this:

    error: failed to run custom build command for webview-sys v0.1.4

    Caused by: process didn't exit successfully: D:\vsc\boo\target\debug\build\webview-sys-4677667d63293584\build-script-build (exit code: 1) --- stderr

    error occurred: Command "D:\Microsoft Visual Studio 11.0\VC\bin\amd64\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "webview.h" "-W4" "-DDEBUG" "-DWEBVIEW_WINAPI" "-FoD:\vsc\boo\target\debug\build\webview-sys-e15e5e355a126747\out\webview.o" "-c" "webview.c" with args "cl.exe" did not execute successfully (status code exit code: 2).

    Whats wrong?I dont know how to solve it. Can you help me?Thank YOU!

    opened by majiayu000 0
  • How do I create a frameless/tiltlebarless window?

    How do I create a frameless/tiltlebarless window?

    As neutrino windows can have a theme which does not always match frame and titlebar (especially for MS windows) I woluld like to open a window without frame and titlebar so that everything is completly customizable (if necessary a custom titlebar could be created out of a small container with an image (app-icon), a label titlebartext) and 3 small buttons (minimize, maximize, close) - or whatever you like to have here) and even frame could follw the chosen theme. What do I have to do, to get such a window?

    opened by Maikel1963 5
  • Add travis CI and code coverage

    Add travis CI and code coverage

    This PR adds a .travis.yml file to the repo. If the repo is added to your travis-ci.org account then you will have CI integrated into the project.

    I have added code coverage reporting to codecov.io, but in my first test I couldn't get the reports to show - so that's a WIP. If you wanted, we could remove that and try separately.

    opened by andrewdavidmackenzie 3
Owner
null
example of a full stack web app (backend and frontend) wrtiten in Rust

rust-fullstack-example An example of creating a full stack web application (backend and frontend) using Rust. Backend Go to ./backend and start the se

mario 41 Dec 16, 2022
A simple authentication flow using Rust and Actix-web, with a PostgreSQL database and a sveltekit frontend.

Rust-auth-example This repository aims to represent a simple authentication flow using Rust and Actix-web, with a PostgreSQL database and a sveltekit

Kival Mahadew 4 Feb 19, 2023
Quick demo of a REST frontend with a Redis session store.

axum-rest-starter-example Important Tasks Ensure session UUID is unique Protect /api/ with JWT Add CSRF CORS? Dev Setup (1) Run docker compose up to f

Michael de Silva 23 Dec 31, 2022
Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix 16.2k Jan 2, 2023
Sauron is an html web framework for building web-apps. It is heavily inspired by elm.

sauron Guide Sauron is an web framework for creating fast and interactive client side web application, as well as server-side rendering for back-end w

Jovansonlee Cesar 1.7k Dec 26, 2022
Hot reload static web server for deploying mutiple static web site with version control.

SPA-SERVER It is to provide a static web http server with cache and hot reload. 中文 README Feature Built with Hyper and Warp, fast and small! SSL with

null 7 Dec 18, 2022
Code template for a production Web Application using Axum: The AwesomeApp Blueprint for Professional Web Development.

AwesomeApp rust-web-app More info at: https://awesomeapp.dev/rust-web-app/ rust-web-app YouTube episodes: Episode 01 - Rust Web App - Course to Produc

null 45 Sep 6, 2023
A highly customizable, full scale web backend for web-rwkv, built on axum with websocket protocol.

web-rwkv-axum A axum web backend for web-rwkv, built on websocket. Supports BNF-constrained grammar, CFG sampling, etc., all streamed over network. St

Li Junyu 12 Sep 25, 2023
Murasaki is a Fast, Secure, and Reliable Webkit based web browser.

Murasaki is a Fast, Secure, and Reliable Webkit based web browser. Table of Contents Goals Status Usage License Goals Security: Be secure, and not com

Moon Laboratories 5 Nov 17, 2021
A web application to configuration Caddy based on MoonZoon.

Cream A web application to configuration Caddy based on MoonZoon. MoonZoon is a Rust Fullstack Framework. Live demo Run on a local machine Check you'v

Tw 4 Sep 19, 2022
📝 Web-based, reactive Datalog notebooks for data analysis and visualization

Percival is a declarative data query and visualization language. It provides a reactive, web-based notebook environment for exploring complex datasets, producing interactive graphics, and sharing results.

Eric Zhang 486 Dec 28, 2022
Layers, extractors and template engine wrappers for axum based Web MVC applications

axum-template Layers, extractors and template engine wrappers for axum based Web MVC applications Getting started Cargo.toml [dependencies] axum-templ

Altair Bueno 11 Dec 15, 2022
axum-serde is a library that provides multiple serde-based extractors and responders for the Axum web framework.

axum-serde ?? Overview axum-serde is a library that provides multiple serde-based extractors / responses for the Axum web framework. It also offers a

GengTeng 3 Dec 12, 2023
A Rust web framework

cargonauts - a Rust web framework Documentation cargonauts is a Rust web framework intended for building maintainable, well-factored web apps. This pr

null 179 Dec 25, 2022
A Rust library to extract useful data from HTML documents, suitable for web scraping.

select.rs A library to extract useful data from HTML documents, suitable for web scraping. NOTE: The following example only works in the upcoming rele

Utkarsh Kukreti 829 Dec 28, 2022
A rust web framework with safety and speed in mind.

darpi A web api framework with speed and safety in mind. One of the big goals is to catch all errors at compile time, if possible. The framework uses

null 32 Apr 11, 2022
A web framework for Rust.

Rocket Rocket is an async web framework for Rust with a focus on usability, security, extensibility, and speed. #[macro_use] extern crate rocket; #[g

Sergio Benitez 19.4k Jan 4, 2023
Rust / Wasm framework for building client web apps

Yew Rust / Wasm client web app framework Documentation (stable) | Documentation (latest) | Examples | Changelog | Roadmap | 简体中文文档 | 繁體中文文檔 | ドキュメント A

Yew Stack 25.8k Jan 2, 2023
Thruster - An fast and intuitive rust web framework

A fast, middleware based, web framework written in Rust

null 913 Dec 27, 2022