A simple UI framework for Rust(github.com)
github.com
A simple UI framework for Rust
https://github.com/cybergeek94/kiss-ui
7 comments
Screenshots would be helpful for a project like this.
http://iup.sourceforge.net/en/screenshots.html
These are for the widget toolkit this project is based on, rather than from the project proper, but it's better than nothing I guess.
These are for the widget toolkit this project is based on, rather than from the project proper, but it's better than nothing I guess.
Rather than seeing more GTK bindings or lookalikes I personally am waiting for something like WPF/XAML or JavaFx/FXML to turn up.
Anyone seen any projects like this for rust?
Anyone seen any projects like this for rust?
It's not like that, but the other non-bindings toolkit that exists is Conrod: https://github.com/PistonDevelopers/conrod
Cool, I didn't know about IUP at all! Rust has burned me a bit lately (muh 128-bit arithmetic, no!), but I still have a fair bit of nostalgia for Lua; I have a sneaking suspicion I will look to IUP for some of my planned projects. At the very least, cool project and I learned about another cool thing!
IUP is one of the friendliest toolkits to write bindings for.
IUP is a little quirky and a pain to install, but really nice to work with.
Out of curiosity: why the author tends to write "self" at the end of the methods ?
In rust that will return itself, which allows you to chain method calls, if that's your style. For example, with the Timer class [1], you could write:
someTimer.set_interval(1000).start();
instead of writing: someTimer.set_interval(1000);
someTimer.start();
[1]: https://github.com/cybergeek94/kiss-ui/blob/master/src/timer...All the other comments are right, and in Rust this is referred to as "the builder pattern", and is used quite commonly. Here's a guidelines link[0] describing it in more detail.
[0]: https://aturon.github.io/ownership/builders.html
[0]: https://aturon.github.io/ownership/builders.html
Note that those guidelines are outdated, superseded by https://github.com/rust-lang/rust-guidelines
Note that _those_ guidelines are outdated, superseded by https://github.com/rust-lang/rust/tree/master/src/doc/style and http://doc.rust-lang.org/style/
Note that we haven't linked to those publicly all that much yet, as there's so much TODO in them still.
Ahh, Rust. :)
There's a part in the book about the builder pattern: http://doc.rust-lang.org/stable/book/method-syntax.html#buil...
Note that _those_ guidelines are outdated, superseded by https://github.com/rust-lang/rust/tree/master/src/doc/style and http://doc.rust-lang.org/style/
Note that we haven't linked to those publicly all that much yet, as there's so much TODO in them still.
Ahh, Rust. :)
There's a part in the book about the builder pattern: http://doc.rust-lang.org/stable/book/method-syntax.html#buil...
Thanks for the updated links! I totally committed the sin of linking to the first thing from google that looked approximately right.
It's at least partially our fault. (And basically entirely so, really :) ) Gotta get on that rel=canonical at least. Old search results are a big problem :/
This would be to enable method chaining so you can do stuff like:
dialog.set_title("blah").set_size_pixels(100, 100);
(note syntax may be out - I am not a Rust expert...)Couldn't one write a chain macro instead ? That way you don't have to rely on the library to return self.
chain!(dialog, set_title("blah"), set_size_piels(100, 100));Okay, yes, you could do that, but the library itself provides this as its idiomatic way of doing things.
The macro is a better solution, since you can't rely on every library doing this kind of thing.
Why wouldn't I want to do
dialog.set_title("blah");
dialog.set_size_piels(100, 100);
on two lines?
dialog.set_title("blah");
dialog.set_size_piels(100, 100);
on two lines?
Different strokes. It's a common idiom in JavaScript, for instance. You can do multiple lines if you want, nothing stops you.
Because functional programming.
To expand a bit: Sometimes, instead of thinking about nouns all the time, you want to think about verbs. Instead of saying "mutate this noun by applying verb1" and then "mutate this noun by applying verb2" etc, you are creating a new verb. The new verb is "verb1 then verb2 then...." And then when you have the verb defined, you apply it to your object.
I feel APIs like that are a bit misleading in Rust in many cases, though, since they're also mutating the original. In Rust, if you want to perform a functional update like that you should take the type by move, but almost everyone just uses mutating APIs because mutation is explicit in the signature anyway. I think that's one of the biggest differences in practice between Rust and other MLs (with which it otherwise has a lot in common): in most MLs, mutation is treated as a last resort, while in Rust it's extremely common because it (generally) doesn't have nonlocal effects.
[deleted]
Impressive what people are building in little time with Rust!
Cool, but why not build on top of the Servo engine? Or am I missing something?
Because it is not web based.
Does that matter? I bet the core Servo libraries don't even deal with networking. And using Servo has obvious advantages such as a being a good render engine supporting incremental updates, probably being well-documented, well-tested, and conforming to well-known standards (yes, also used on the web, but does that matter really?)
Honestly, it matters. Current web technologies aren't the end game solution for interfaces and, IMO, are pretty horrible to work with for that purpose. (Pretty beaten up topic by now, but lets take a moment to think for a second about vertical centering in HTML+CSS. /sigh </rant>)
Still, my answer was just referring to the fact that this is not using web tech, and thus, not using servo or any other existing browser engine.
Still, my answer was just referring to the fact that this is not using web tech, and thus, not using servo or any other existing browser engine.
flexbox + viewport units have made this better.
Because it is not HTML based.