grade

Crates.iograde
lib.rsgrade
version0.3.0
sourcesrc
created_at2019-08-02 00:11:26.261853
updated_at2019-08-21 13:38:44.238671
descriptionA convenience macro for gtk-rs.
homepage
repositoryhttps://github.com/TomSteu/grade
max_upload_size
id153662
size27,253
(TomSteu)

documentation

README

Grade - A macro for rapid gtk-rs development

Grade is a macro for declarative development of gtk-rs. It provides the macro build! that creates a GTK widget from declaration.


use gtk::*;
use grade::build;

// build! macro provided by this crate
let main_window = build! {

	// any Object that has a corresponding ObjectBuilder
	Window {
		
		// properties (methods to the ObjectBuilder)
		title: "Grade test",
		show_menubar: false,
		default_height: 300,
		default_width: 400,
		
		// conncect signals of the Object
		=> activate_focus: |_| { /*...*/ },
		=> notify(title): |_| { /*...*/ }, 
		
		// children
		-- Viewport {
		
			// named object, will be saved under this identifier
			-- main_grid: Grid {
				vexpand: true,
				name: "main_grid",
				
				// child added with `parent.attach(&child, 1,1,1,1);`
				// the default `--` is short for `-- [add]`
				-- [attach, 1, 1, 1, 1] Label {
					label: "Please type...",
				}
				
				// cascade-style syntax for methods of the parent
				..insert_row(2)
				
				// of course, `build!` is nestable 
				..attach(
					& build!(/*...*/).downcast::<Widget>(), 
					1, 2, 3, 3
				)
			}
		}
	}
};
Commit count: 12

cargo fmt