A light windows GUI toolkit for rust

Overview

Native Windows GUI

Welcome to Native Windows GUI (aka NWG). A rust library to develop native GUI applications on the desktop for Microsoft Windows.

NWG is a very light wrapper over WINAPI. It allows you, the developer, to handle the quirks and rough edges of the API by providing a simple, safe and rust-like interface.

Native Windows GUI keeps things simple. This means small compile times, minimal resource usage, less time searching the documentation and more time for you to develop your application.

Of course, you don't have to take my word for it, check out the showcase and the examples.

This is the 3rd and final version of NWG. It is considered "mature" or, as I would say "the backlog is empty, and it will most likely stay that way". This version implements pretty much everything required to develop applications on Windows. Don't bother using the older versions as they have "irreconcilable design decisions" and cannot support some key features. Future development will be done in other libraries.

If you've managed to read through this introduction, you should know that my twitter handle is #gdube_dev and you can support this project with GitHub Sponsors.

Any support is greatly appreciated.

Installation

To use NWG in your project add it to cargo.toml:

[dependencies]
native-windows-gui = "1.0.12"
native-windows-derive = "1.0.3" # Optional. Only if the derive macro is used.

And then, in main.rs or lib.rs :

extern crate native_windows_gui as nwg;
extern crate native_windows_derive as nwd;  // Optional. Only if the derive macro is used.

Rust 2018 aliasing

You can skip the extern crate define in your source code by adding the following code in Cargo.toml Note that procedural macros still require an extern crate definition, so this wont work with native-windows-derive

[dependencies]
nwg = {version = "^1.0.12", package = "native-windows-gui"}

Trying it out

See it for yourself. NWG has plenty of examples and a fully interactive test suite. The only thing you need to do is:

git clone [email protected]:gabdube/native-windows-gui.git

cd native-windows-gui/native-windows-gui # Running the tests from the workspace screws up the features

cargo test everything --features "all"  # For the test suite
cargo run --example basic
cargo run --example calculator
cargo run --example message_bank
cargo run --example image_decoder_d --features "extern-canvas"
cargo run --example partials --features "listbox frame combobox"
cargo run --example system_tray --features "tray-notification message-window menu cursor"
cargo run --example dialog_multithreading_d --features "notice"
cargo run --example image_decoder_d --features "image-decoder file-dialog"
cargo run --example month_name_d --features "winnls textbox"
cargo run --example splash_screen_d --features "image-decoder"
cargo run --example drop_files_d --features "textbox"

cd examples/opengl_canvas
cargo run

# The closest thing to a real application in the examples
cd ../examples/sync-draw
cargo run

# Requires the console to be run as Admin because of the embed resource
cd ../examples/embed_resources
cargo run

Cross-compiling from Ubuntu

Requirement: MinGW compiler

sudo apt install gcc-mingw-w64-x86-64

Requirement: Rust support

rustup target add x86_64-pc-windows-gnu

Compiling and running basic example:

cargo build --release --target=x86_64-pc-windows-gnu
cargo build --release --target=x86_64-pc-windows-gnu --example basic
wine target/x86_64-pc-windows-gnu/release/examples/basic.exe

Project structure

This is the main project git. It is separated in multiple sections

  • native-windows-gui
    • The base library. Includes an interactive test suite and plenty of examples
  • native-windows-derive
    • A procedural macro that generates the GUI application from rust structure (pretty cool stuff IMO)
  • docs/native-windows-docs read it online
    • Hefty documentation that goes over everything you need to know about NWG
  • showcase
    • Images of the examples. If you've made an NWG application and want to share it here, send me a message or open a PR. It's free real estate.

Supported features

  • The WHOLE winapi control library (reference)
    • Some very niche controls are not supported: flat scroll bar, ip control, rebar, and pager.
  • Menus and menu bar
  • Image and font resource
    • BMP
    • ICO
    • CUR
    • PNG*
    • GIF*
    • JPG*
    • TIFF*
    • DDS*
    • *: Extended image formats with the Windows Imaging Component (WIC).
  • Localization support
    • Uses Windows National Language Support internally (reference)
  • Tooltip
  • System tray notification
  • Cursor handling
  • A full clipboard wrapper
  • Partial templates support
    • Split large application into chunks
  • Dynamic controls support
    • Add/Remove controls at runtime
    • Bind or unbind new events at runtime
  • Multithreaded application support
    • Communicate to the GUI thread from another thread
    • Run multiple windows on different threads
  • Simple layout configurations
    • FlexboxLayout
    • GridLayout
  • Drag and drop
    • Drop files from the desktop to a window
  • The most common dialog boxes
    • File dialog (save, open, open folder)
    • Font dialog
    • Color dialog
  • A canvas that can be used by external rendering APIs
  • High-DPI aware
  • Support for accessibility functions
    • Tab navigation
  • Support for low level system message capture (HWND, MSG, WPARAM, LPARAM)
  • Cross compiling and testing from Linux to Windows with Wine and mingw.
    • Not all features are supported (but the majority are, thanks WINE!)
    • See https://zork.net/~st/jottings/rust-windows-and-debian.html for the steps to follow

Performance

This was measured on a Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz, 3401 Mhz, 4 Core(s), 8 Logical Processor(s)

In release mode, the basic example weighs 163kb on disk and takes 900kb in memory. Launch time is instantaneous.

The interactive test suite (with every feature and 100s of tests) weighs 931 kb on disk and takes 8MB in memory. Launch time is still instantaneous.

Initial build time takes around 22 seconds for a basic application. This is mainly due to winapi-rs initial compile time. Subsequent compile time takes around 0.7 seconds.

Development

The development of this library is considered "done". By that, I mean that there won't be any change to the API. Issues can be raised if a bug is found or if some area in the documentation is unclear. If I overlooked a very important feature, it will most likely be added.

License

NWG uses the MIT license

Code example

With native windows derive

#![windows_subsystem = "windows"]
/*!
    A very simple application that shows your name in a message box.
    Unlike `basic_d`, this example uses layout to position the controls in the window
*/


extern crate native_windows_gui as nwg;
extern crate native_windows_derive as nwd;

use nwd::NwgUi;
use nwg::NativeUi;


#[derive(Default, NwgUi)]
pub struct BasicApp {
    #[nwg_control(size: (300, 115), position: (300, 300), title: "Basic example", flags: "WINDOW|VISIBLE")]
    #[nwg_events( OnWindowClose: [BasicApp::say_goodbye] )]
    window: nwg::Window,

    #[nwg_layout(parent: window, spacing: 1)]
    grid: nwg::GridLayout,

    #[nwg_control(text: "Heisenberg", focus: true)]
    #[nwg_layout_item(layout: grid, row: 0, col: 0)]
    name_edit: nwg::TextInput,

    #[nwg_control(text: "Say my name")]
    #[nwg_layout_item(layout: grid, col: 0, row: 1, row_span: 2)]
    #[nwg_events( OnButtonClick: [BasicApp::say_hello] )]
    hello_button: nwg::Button
}

impl BasicApp {

    fn say_hello(&self) {
        nwg::modal_info_message(&self.window, "Hello", &format!("Hello {}", self.name_edit.text()));
    }
    
    fn say_goodbye(&self) {
        nwg::modal_info_message(&self.window, "Goodbye", &format!("Goodbye {}", self.name_edit.text()));
        nwg::stop_thread_dispatch();
    }

}

fn main() {
    nwg::init().expect("Failed to init Native Windows GUI");
    nwg::Font::set_global_family("Segoe UI").expect("Failed to set default font");
    let _app = BasicApp::build_ui(Default::default()).expect("Failed to build UI");
    nwg::dispatch_thread_events();
}

Barebone example. Suitable if you only need a simple static UI

#![windows_subsystem = "windows"]
/**
    A very simple application that show your name in a message box.

    This demo shows how to use NWG without the NativeUi trait boilerplate.
    Note that this way of doing things is alot less extensible and cannot make use of native windows derive.

    See `basic` for the NativeUi version and `basic_d` for the derive version
*/
extern crate native_windows_gui as nwg;
use std::rc::Rc;

fn main() {
    nwg::init().expect("Failed to init Native Windows GUI");
    nwg::Font::set_global_family("Segoe UI").expect("Failed to set default font");

    let mut window = Default::default();
    let mut name_edit = Default::default();
    let mut hello_button = Default::default();
    let layout = Default::default();

    nwg::Window::builder()
        .size((300, 115))
        .position((300, 300))
        .title("Basic example")
        .build(&mut window)
        .unwrap();

    nwg::TextInput::builder()
        .text("Heisenberg")
        .focus(true)
        .parent(&window)
        .build(&mut name_edit)
        .unwrap();

    nwg::Button::builder()
        .text("Say my name")
        .parent(&window)
        .build(&mut hello_button)
        .unwrap();

    nwg::GridLayout::builder()
        .parent(&window)
        .spacing(1)
        .child(0, 0, &name_edit)
        .child_item(nwg::GridLayoutItem::new(&hello_button, 0, 1, 1, 2))
        .build(&layout)
        .unwrap();

    let window = Rc::new(window);
    let events_window = window.clone();

    let handler = nwg::full_bind_event_handler(&window.handle, move |evt, _evt_data, handle| {
        use nwg::Event as E;

        match evt {
            E::OnWindowClose => 
                if &handle == &events_window as &nwg::Window {
                    nwg::modal_info_message(&events_window.handle, "Goodbye", &format!("Goodbye {}", name_edit.text()));
                    nwg::stop_thread_dispatch();
                },
            E::OnButtonClick => 
                if &handle == &hello_button {
                    nwg::modal_info_message(&events_window.handle, "Hello", &format!("Hello {}", name_edit.text()));
                },
            _ => {}
        }
    });

    nwg::dispatch_thread_events();
    nwg::unbind_event_handler(&handler);
}

With the NativeUi boilerplate

#![windows_subsystem = "windows"]
/*!
    A very simple application that shows your name in a message box.
    Uses layouts to position the controls in the window
*/

extern crate native_windows_gui as nwg;
use nwg::NativeUi;


#[derive(Default)]
pub struct BasicApp {
    window: nwg::Window,
    layout: nwg::GridLayout,
    name_edit: nwg::TextInput,
    hello_button: nwg::Button
}

impl BasicApp {

    fn say_hello(&self) {
        nwg::modal_info_message(&self.window, "Hello", &format!("Hello {}", self.name_edit.text()));
    }
    
    fn say_goodbye(&self) {
        nwg::modal_info_message(&self.window, "Goodbye", &format!("Goodbye {}", self.name_edit.text()));
        nwg::stop_thread_dispatch();
    }

}

//
// ALL of this stuff is handled by native-windows-derive
//
mod basic_app_ui {
    use native_windows_gui as nwg;
    use super::*;
    use std::rc::Rc;
    use std::cell::RefCell;
    use std::ops::Deref;

    pub struct BasicAppUi {
        inner: Rc<BasicApp>,
        default_handler: RefCell<Option<nwg::EventHandler>>
    }

    impl nwg::NativeUi<BasicAppUi> for BasicApp {
        fn build_ui(mut data: BasicApp) -> Result<BasicAppUi, nwg::NwgError> {
            use nwg::Event as E;
            
            // Controls
            nwg::Window::builder()
                .flags(nwg::WindowFlags::WINDOW | nwg::WindowFlags::VISIBLE)
                .size((300, 115))
                .position((300, 300))
                .title("Basic example")
                .build(&mut data.window)?;

            nwg::TextInput::builder()
                .text("Heisenberg")
                .parent(&data.window)
                .focus(true)
                .build(&mut data.name_edit)?;

            nwg::Button::builder()
                .text("Say my name")
                .parent(&data.window)
                .build(&mut data.hello_button)?;

            // Wrap-up
            let ui = BasicAppUi {
                inner: Rc::new(data),
                default_handler: Default::default(),
            };

            // Events
            let evt_ui = Rc::downgrade(&ui.inner);
            let handle_events = move |evt, _evt_data, handle| {
                if let Some(ui) = evt_ui.upgrade() {
                    match evt {
                        E::OnButtonClick => 
                            if &handle == &ui.hello_button {
                                BasicApp::say_hello(&ui);
                            },
                        E::OnWindowClose => 
                            if &handle == &ui.window {
                                BasicApp::say_goodbye(&ui);
                            },
                        _ => {}
                    }
                }
            };

           *ui.default_handler.borrow_mut() = Some(nwg::full_bind_event_handler(&ui.window.handle, handle_events));

           // Layouts
           nwg::GridLayout::builder()
            .parent(&ui.window)
            .spacing(1)
            .child(0, 0, &ui.name_edit)
            .child_item(nwg::GridLayoutItem::new(&ui.hello_button, 0, 1, 1, 2))
            .build(&ui.layout)?;

            return Ok(ui);
        }
    }

    impl Drop for BasicAppUi {
        /// To make sure that everything is freed without issues, the default handler must be unbound.
        fn drop(&mut self) {
            let handler = self.default_handler.borrow();
            if handler.is_some() {
                nwg::unbind_event_handler(handler.as_ref().unwrap());
            }
        }
    }

    impl Deref for BasicAppUi {
        type Target = BasicApp;

        fn deref(&self) -> &BasicApp {
            &self.inner
        }
    }
}

fn main() {
    nwg::init().expect("Failed to init Native Windows GUI");
    nwg::Font::set_global_family("Segoe UI").expect("Failed to set default font");
    let _ui = BasicApp::build_ui(Default::default()).expect("Failed to build UI");
    nwg::dispatch_thread_events();
}

Attributions

For the icons used in the test suite (and only there):

Comments
  • About item selection in TreeView

    About item selection in TreeView

    Hello sir. I always have questions. It seems that the program controlled item selection in TreeView is invalid unless the TreeView is focused. And another problem is , the previous selection is not cleared when I try to select new items. How to tackle these two problems? Thanks for your coming help.

    opened by lotusstudio 11
  • Clipboard improvements (integrate clipboard-win?)

    Clipboard improvements (integrate clipboard-win?)

    There are few aspects that you can improve in clipboard:

    • Use IsClipboardFormatAvailable to determine if format is available which can be used without clipboard open
    • Check for failure SetClipboardData - if it fails you need to free memory
    • Use MultiByteToWideChar to efficiently write encoded string onto allocated memory instead of using intermediate allocation (and then append 0)

    You can use my code in clipboard-win as reference if you want something more

    opened by DoumanAsh 11
  • I need your help(about the listview)

    I need your help(about the listview)

    I'm trying to the add listview support. But failed. Can you test my fork? https://github.com/zoumi/native-windows-gui The problem is: 1,after add the listview to the window , all the control will blink 2,can't add the full string to listview cell.(If i add "what is this" it will show "xhat is this")

    Here is the code to test the listview:

    //#![windows_subsystem = "windows"]
    //#![feature(link_args)]
    //#[link_args = "-Wl,--subsystem,windows"]
    //#[link_args = "/SUBSYSTEM:WINDOWS"]
    #[macro_use] extern crate native_windows_gui as nwg;
    
    use nwg::{Event, Ui, simple_message, fatal_message, dispatch_events};
    extern crate winapi;
    use winapi::{LPCWSTR,HWND};
    
    extern "system"{
    pub fn SetWindowTheme(hwnd: HWND,
                          pszSubAppName: LPCWSTR,
                          pszSubIdList: LPCWSTR);
    }
    
    /// Custom enums are the preferred way to define ui ids. 
    /// It's clearer and more extensible than any other types (such as &'str).
    #[derive(Debug, Clone, Hash)]
    pub enum AppId {
        // Controls
        MainWindow,
        NameInput, 
        HelloButton,
        Label(u8),   // Ids for static controls that won't be referenced in the Ui logic can be shortened this way.
        MyListView,
    
        // Events
        SayHello,
    
        // Resources
        MainFont,
        TextFont
    }
    
    use AppId::*; // Shortcut
    
    nwg_template!(
        head: setup_ui<AppId>,
        controls: [
            (MainWindow, nwg_window!( title="Template Example"; size=(280, 305) )),
            (Label(0), nwg_label!(
                 parent=MainWindow;
                 text="Your Name: ";
                 position=(5,15); size=(80, 25);
                 font=Some(TextFont) )),
    
            (NameInput, nwg_textinput!( 
                 parent=MainWindow; 
                 position=(85,13); size=(185,22); 
                 font=Some(TextFont) )),
    
            (HelloButton, nwg_button!( 
                 parent=MainWindow; 
                 text="Hello World!"; 
                 position=(5, 45); size=(270, 50); 
                 font=Some(MainFont) )),
    
            (MyListView, nwg_list_view!(
                    parent=MainWindow;
                    text="oh my list view";
                    position=(5,100);size=(270,200);
                    font=Some(MainFont) ))
        ];
    
        events: [
            (HelloButton, SayHello, Event::Click, |ui,_,_,_| {
    
                let my_list_view = nwg_get!(ui; (MyListView,nwg::ListView));
               // unsafe { SetWindowTheme}
                my_list_view.insert_col(0,"FIRST",50);
                my_list_view.insert_col(1,"wsec",50);
                my_list_view.insert_col(2,"wtrd",50);
                my_list_view.add(vec!["1fsafas".to_owned(),"ewheh2".to_owned(),"3sfsaga".to_owned()]);
                my_list_view.insert(1,
                    vec!["1o8u53b".to_owned(),"iluou2".to_owned(),"3wvrwr".to_owned()]);
                my_list_view.insert(2,
                    vec!["1333".to_owned(),"266666".to_owned(),"00003".to_owned()]);
                println!("list_view hwnd: {:?}",my_list_view);
                //let your_name = nwg_get!(ui; (NameInput, nwg::TextInput));
                //simple_message("Hello", &format!("Hello {}!", your_name.get_text()) );
            }),
            (MyListView, SayHello, Event::Notify, |ui,hwnd,wpara,lpara| {
            
            })
        ];
        resources: [
            (MainFont, nwg_font!(family="Arial"; size=27)),
            (TextFont, nwg_font!(family="Arial"; size=17))
        ];
        values: []
    );
    
    fn main() {
        let app: Ui<AppId>;
    
        match Ui::new() {
            Ok(_app) => { app = _app; },
            Err(e) => { fatal_message("Fatal Error", &format!("{:?}", e) ); }
        }
    
        if let Err(e) = setup_ui(&app) {
            //fatal_message("Fatal Error", &format!("{:?}", e));
        }
    
    
        dispatch_events();
    }
    
    opened by zoumi 10
  • Mouse cursor flickering

    Mouse cursor flickering

    In the application I have developed with native-windows-gui, the mouse cursor flickers between Normal and IBeam when positioned over a RichLabel element. It also flickers between Normal and one of the Size cursors when positioned over the window border (if the window is resizable).

    In the case of RichLabel, I can workaround this by implementing a handler for WM_SETCURSOR but I do find it strange that the cursor is modified for RichLabel elements and no others.

    I have been unable to workaround the flickering for the border. I suspect the flickering may be because Window specifies a cursor when instantiating WNDCLASSEXW. I've tried setting the cursor myself in my WM_SETCURSOR handler, and I've also tried calling DefWindowProcA from the handler.

    opened by StevePER 9
  • Support for nested flexboxes

    Support for nested flexboxes

    Basic support for nested flexboxes, mostly through changing style modification style (unification between item and layout subitems).

    This required adding a new child_layout functionality to prevent sub-layouts from registering their own callbacks. Sublayout are thus only recalculated when the parent layout is recalculated.

    Happy to change or explain anything if required!

    opened by Voragain 8
  • Fixed image loading from byte stream

    Fixed image loading from byte stream

    Minimal changes in API were required. Added additional reference inside ImageSource. ImageSource and ImageData are now wrapped in LifetimeRef. It didn't change much, since it implements deref. Also they usually don't require mutation and are local.

    opened by Kolsky 8
  • Add add_child, remove_child function for FlexboxLayout

    Add add_child, remove_child function for FlexboxLayout

    This allows a flexible dynamic UI. I think adding the children to the FlexboxLayout is merely taking out the children Control of the child FlexboxLayout and add it on the parent FlexboxLayout, I'm not sure though. I'm also surprise that the underlying windows UI doesn't actually have a native layout support. So, the higher level UI frameworks will have to calculate them.

    Take note also, that the stretch layout computation is calculating the location of each children relative to the parent container. So, to put the child component in their absolute position, I have to add the parent location to each of the child location after the layout computation.

    opened by ivanceras 8
  • Placeholder Text for TextInput

    Placeholder Text for TextInput

    Hey,

    Started using this fantastic library today and I'm missing a few things that would be neat. One of them is being able to set a placeholder text for text inputs.

    I believe it can be accomplished with:

    https://docs.microsoft.com/en-us/windows/win32/controls/em-setcuebanner

    But I'm not sure if it's viable to use it because of the note:

    To use this API, you must provide a manifest specifying Comclt32.dll version 6.0

    What do you think?

    Thanks!

    opened by morshcode 7
  • Simplify GUI construction by nesting control code

    Simplify GUI construction by nesting control code

    Instead of setting parent, we can use nesting:

    let main_window = Window {
        caption: "Hello".to_string(),
        size: (200, 200),
        position: (100, 100),
        visible: true,
        resizable: false,
        exit_on_close: true,
        children: vec![
          TextInput {
              name: "Name",
              text: "".to_string(),
              size: (180, 20),
              position: (10, 10),
              placeholder: Some("Your name Here".to_string()),
              text_align: HTextAlign::Left,
              password: false,
              readonly: false
          },
          Button {
              text: "Say Hello!".to_string(),
              size: (180, 130),
              position: (10, 50),
              text_align: (HTextAlign::Center, VTextAlign::Center),
              on_click: Box::new(|ui, caller|{
                  println!("Caller is: {:?}", caller);
                  if let Ok(ActionReturn::Text(name)) = ui.exec("Name", Action::GetText) {
                      let msg = actions_help::message(
                          "Hello!", format!("Hello {}!", name),
                          MessageButtons::Ok, MessageIcons::None
                      );
                      ui.exec("MainWindow", msg).unwrap();
                  }
            })
          }
        ]
    };
    main_window.run();
    

    Please take a look at https://github.com/lxn/walk and borrow some ideas from there.

    opened by J-F-Liu 7
  • BoxLayout should be able to have independent sizes for each of its children

    BoxLayout should be able to have independent sizes for each of its children

    https://github.com/gabdube/native-windows-gui/blob/1.0-prerelease/native-windows-gui/src/layouts/box_layout.rs#L237

                let local_width = (_item_width * item.span) + (sp2 * (item.span - 1));
                let local_height = (_item_height * item.span) + (sp2 * (item.span - 1));
    

    My understand is that Box (such as in Gtk) should be able to accommodate the children content independent on the size of the cells. It looks like the BoxLayout in nwg is implemented in the assumption that the cells must have the same sizes.

    Is this something we could change the behavior of BoxLayout or is there an alternative control should I be using instead.

    enhancement 
    opened by ivanceras 6
  • Capturing globally registered hotkeys

    Capturing globally registered hotkeys

    First off, let me say I am a beginner in Rust and to this library so there might be an easy solution to this.

    I've been trying to bind a raw event handler, which will allow me to capture the WM_HOTKEY event globally for whenever a given hotkey I've registered with RegisterHotKey. I want this hotkey to be captured even if the focused HWND doesn't belong to my process.

    This is what my code looks like right now:

    pub fn register_hotkey() {
      unsafe {
        RegisterHotKey(
          HWND::NULL,
          CUSTOM_HANDLER_ID as i32,
          MOD_CONTROL | MOD_SHIFT,
          'X' as u32,
        );
      };
    }
    

    And to register the raw event handler:

     let raw_handler = bind_raw_event_handler(
            &ui.window.handle,
            CUSTOM_HANDLER_ID ,
            |_hwnd, msg, _w, l| {
              match msg {
                WM_HOTKEY => {
                  println!("Hotkey called");
                }
                _ => {
                  println!("Some other evt")
                }
              }
    
              None
            },
          );
    

    My problem is that although the raw handler is registered fine (I do get console output for the "Some other evt" line which is capture-all), I cannot get my registered hotkey to trigger.

    I took a look at the source code and I saw that in the implementation of pub fn dispatch_thread_events there's a check for IsDialogMessageW (https://github.com/gabdube/native-windows-gui/blob/d0ab1cdacd83b73572907e5f064a4c3a02458e99/native-windows-gui/src/win32/mod.rs#L49)

    Could it be that my event is not fired because of this check?

    Thank you in advance for the time taken to look at the question :)

    opened by giotiskl 5
  • Allow to set a default filter in file dialogs

    Allow to set a default filter in file dialogs

    It was weird that I couldn't make one of the filters the default option.

    Prior to this change, the first filter is always the default. Now, the filter prefixed with > is the default.

    I chose > because you can't name a file with it.

    Here's a file dialog with the filter string PNG(*.png)|JPEG(*.jpg;*.jpeg)|WebP(*.webp)|>Supported image files(*.png;*.jpg;*.jpeg;*.webp):

    image

    opened by hch12907 0
  • support multiple tray icons per parent

    support multiple tray icons per parent

    Just like a parent (HWND) can have multiple timers, it can have multiple notification area icons (TrayNotifications) differentiated by an ID. Use similar functionality as with timers to extend support to multiple icons per parent.

    The Shell_NotifyIconW(NIM_SETVERSION, &mut data); call is necessary to ensure that the icon ID is passed in the expected format to process_events(...), as the version field is ignored otherwise (well, interpreted as the timeout value). This has been previously pointed out by @iquanxin in issue #246.

    opened by RavuAlHemio 0
  • System Tray Disappears When Explorer Crashes/Restarts

    System Tray Disappears When Explorer Crashes/Restarts

    When explorer.exe crashes or restarts the icon disappears from the system tray. This happens on Windows 11 using rust stable-x86_64-pc-windows-msvc 1.63.0.

    Steps to reproduce: Run either system_tray example

    • cargo run --example system_tray --features "tray-notification message-window menu cursor"
    • cargo run --example system_tray_d --features "tray-notification message-window menu cursor"

    Then open Task Manager to the Processes tab and find "Windows Explorer" and right click and then select "restart"

    After a few seconds the taskbar will reload and when you navigate to the system tray area the icon for the system_tray app will be gone but the application will still be running(you can see the process exe is still running if you look at Task Manager). No output is shown on the terminal you run the example from.

    opened by Ep0chalypse 0
  • Focus position isn't restored after an application switch

    Focus position isn't restored after an application switch

    Currently, when switching from and then back to an NWG application window the keyboard focus isn't given to the control it was previously on. Instead, it always goes to the parent window.

    opened by a11cf0 1
  • The initialization window position changes. when center=true

    The initialization window position changes. when center=true

    pub fn builder<'a>() -> WindowBuilder<'a> {
            WindowBuilder {
                title: "New Window",
                size: (500, 500),
                position: (300, 300),
                accept_files: false,
                topmost: false,
                center: false,
                maximized: false,
                minimized: false,
                flags: None,
                ex_flags: 0,
                icon: None,
                parent: None
            }
    
    

    When setting center=true, the window will display the default position first. Then jump to the center position, and the generated window will move, It's a bad experience. It is recommended that the screen be centered by default.

    opened by cbr0769 0
Releases(1.0.0)
A cross-platform GUI toolkit in Rust

NXUI - Native X UI A cross-platform GUI toolkit in Rust NXUI is a GUI toolkit that calls OS native APIs as much as possible to achieve fast operation.

らて 11 Jun 3, 2022
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

libui: a portable GUI library for C This README is being written. Status It has come to my attention that I have not been particularly clear about how

Pietro Gagliardi 10.4k Dec 31, 2022
Send Windows 10 styled notifications on Windows 7.

win7-notifications Send Windows 10 styled notifications on Windows 7. Note: This crate requires a win32 event loop to be running, otherwise the notifi

Tauri 9 Aug 29, 2022
A data-first Rust-native UI design toolkit.

Druid A data-first Rust-native UI toolkit. Druid is an experimental Rust-native UI toolkit. Its main goal is to offer a polished user experience. Ther

null 8.2k Dec 31, 2022
The Rust UI-Toolkit.

The Orbital Widget Toolkit is a cross-platform (G)UI toolkit for building scalable user interfaces with the programming language Rust. It's based on t

Redox OS 3.7k Jan 1, 2023
Rust bindings to the minimalist, native, cross-platform UI toolkit `libui`

Improved User Interface A cross-platform UI toolkit for Rust based on libui iui: ui-sys: iui is a simple (about 4 kLOC of Rust), small (about 800kb, i

Rust Native UI Group 865 Dec 27, 2022
SixtyFPS is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications. We support multiple programming languages, such as Rust, C++ or JavaScript.

SixtyFPS is a toolkit to efficiently develop fluid graphical user interfaces for any display: embedded devices and desktop applications. We support multiple programming languages, such as Rust, C++ or JavaScript.

SixtyFPS 5.5k Jan 1, 2023
A Rust binding of the wxWidgets cross platform toolkit.

wxRust master: / mac(0.10): This is a Rust binding for the wxWidgets cross platform toolkit. API wxRust API documentation How it works The wxRust libr

KENZ 129 Jan 4, 2023
Modular FFXIV data toolkit written in rust.

ironworks Modular FFXIV data toolkit written in rust. ironworks is pre-1.0, and as such its API should be considered unstable. Breaking API changes wi

Saxon Landers 10 Oct 21, 2022
A graphical user interface toolkit for audio plugins.

HexoTK - A graphic user interface toolkit for audio plugins State of Development Super early! Building cargo run --example demo TODO / Features Every

Weird Constructor 14 Oct 20, 2022
A simple, cross-platform GUI automation module for Rust.

AutoPilot AutoPilot is a Rust port of the Python C extension AutoPy, a simple, cross-platform GUI automation library for Python. For more information,

null 271 Dec 27, 2022
An easy-to-use, 2D GUI library written entirely in Rust.

Conrod An easy-to-use, 2D GUI library written entirely in Rust. Guide What is Conrod? A Brief Summary Screenshots and Videos Feature Overview Availabl

PistonDevelopers 3.3k Jan 1, 2023
Rust bindings for the FLTK GUI library.

fltk-rs Rust bindings for the FLTK Graphical User Interface library. The FLTK crate is a crossplatform lightweight gui library which can be statically

Mohammed Alyousef 1.1k Jan 9, 2023
Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust

Relm Asynchronous, GTK+-based, GUI library, inspired by Elm, written in Rust. This library is in beta stage: it has not been thoroughly tested and its

null 2.2k Dec 31, 2022
Clear Coat is a Rust wrapper for the IUP GUI library.

Clear Coat Clear Coat is a Rust wrapper for the IUP GUI library. IUP uses native controls and has Windows and GTK backends. A macOS backend has been o

Jordan Miner 18 Feb 13, 2021
A cross-platform GUI library for Rust, inspired by Elm

Iced A cross-platform GUI library for Rust focused on simplicity and type-safety. Inspired by Elm. Features Simple, easy-to-use, batteries-included AP

Héctor Ramón 17.5k Jan 2, 2023
Truly cross platform, truly native. multiple backend GUI for rust

WIP: Sauron-native a rust UI library that conquers all platforms ranging from desktop to mobile devices. An attempt to create a truly native, truly cr

Jovansonlee Cesar 627 Jan 5, 2023
A cross-platform GUI library for Rust focused on simplicity and type-safety

A cross-platform GUI library for Rust, inspired by Elm

Héctor Ramón 17.5k Jan 8, 2023
A simple news reading GUI app built in Rust

Headlines [WIP] A native GUI app built with Rust using egui. Uses newsapi.org as the source to fetch news articles. This is a WIP and the current stat

creativcoder 89 Dec 29, 2022