-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
540 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,137 @@ | ||
# Cheat Sheet | ||
|
||
Again, views are the heart of Quarve. There is a decent number of provided views, | ||
of which we will cover commonly used ones. | ||
(really, the standard library has a wide collection of ViewProviders and | ||
IntoViewProviders rather than Views, but we'll generally blur the distinction for sake | ||
of notational convenience). | ||
|
||
Here is a guide | ||
Some concepts are mentioned in more detail in later lessons. Treat this lesson more as a | ||
'cheat sheet' of good to know views rather than full explanation. | ||
'cheat sheet' of good to know methods rather than a full explanation. | ||
|
||
## General | ||
## Views | ||
Construct basic text with the `text` function located in the prelude. | ||
```rust | ||
text("rabbit") | ||
``` | ||
|
||
All colors are IVPs so | ||
(usually you will also want to set a size, hence the second line) | ||
Display image | ||
```rust | ||
ImageView::new("path_to_resource_in_res_folder") | ||
``` | ||
|
||
## Controls | ||
All colors are IVPs (usually you want to set a size, hence the second line) | ||
```rust | ||
BLACK | ||
.intrinsic(100, 100) | ||
``` | ||
|
||
Dropdown Menu | ||
```rust | ||
let selection = Store::new(None); | ||
|
||
Dropdown::new(selection.binding()) | ||
.option("Alpha") | ||
.option("Beta"); | ||
``` | ||
|
||
TextField | ||
```rust | ||
let text = Store::new("initial".into()); | ||
TextField::new(text.binding()); | ||
``` | ||
|
||
Button | ||
Text Button | ||
```rust | ||
button("Label", |s| {...}) | ||
``` | ||
|
||
\*There are many controls that one would expect from a UI library that are yet to | ||
be added. I apologize for this and may add them in the future if there is interest. | ||
|
||
## Layouts | ||
|
||
You can use a `vstack`, `hstack`, and `zstack` to c | ||
You can use a `vstack`, `hstack`, or `zstack` to organize content easily. | ||
There are also flex layouts, but these are needed less. | ||
|
||
You can either layout heterogenous data known at compile time,or dynamically | ||
based off of bindings and signals. | ||
```rust | ||
// hetereogenous | ||
vstack() | ||
.push(ivp1) | ||
.push(ivp2) | ||
|
||
// binding | ||
binding.binding_vmap(|content, s| text(content.to_string()); | ||
|
||
// signal (slow) | ||
signal.sig_vmap(|content, s| text(content.to_string()); | ||
``` | ||
|
||
## Modifiers | ||
|
||
Apply padding to an ivp | ||
```rust | ||
ivp | ||
.padding(amount) | ||
``` | ||
|
||
Offset the ivp by some amount | ||
```rust | ||
ivp | ||
.offset(dx, dy) | ||
``` | ||
|
||
These and other layout views are covered in more detail [here](./layouts.md). | ||
Set the intrinsic size, essentially allocating a rectangle of space. | ||
```rust | ||
ivp | ||
.intrinsic(width, height) | ||
// shorthand for .frame(F.intrinsic(width, height)) | ||
``` | ||
|
||
Setting text attributes | ||
```rust | ||
ivp | ||
.text_font("font_file_in_res/font") | ||
.text_size(size) | ||
.text_color(color) | ||
``` | ||
|
||
Set the background color | ||
```rust | ||
ivp | ||
.bg_color(COLOR) | ||
``` | ||
|
||
Add a foreground view | ||
```rust | ||
ivp | ||
.foreground(attraction) | ||
``` | ||
|
||
Add a background view | ||
```rust | ||
ivp | ||
.background(attraction) | ||
``` | ||
|
||
Lifecycle methods | ||
```rust | ||
ivp | ||
.pre_show(|s| { ... }) // called before children and before being shown | ||
.post_show(|s| { ... }) // called after children and after being shown | ||
.pre_hide(|s| { ... }) // called before children and before being hidden | ||
.post_hide(|s| { ... }) // called after children and after being hidden | ||
``` | ||
|
||
## Conditional | ||
|
||
if else | ||
```rust | ||
view_if(condition_signal, IVP1) | ||
.view_else(IVP2) | ||
``` | ||
|
||
view match | ||
```rust | ||
view_match!(signal; | ||
0 => arm1ivp, | ||
1 => arm2ivp, | ||
_ => default_arm_ivp | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
# Layouts | ||
|
||
## Types of Layouts | ||
|
||
## Heterogenous layouts | ||
|
||
## Binding | ||
|
||
## Signal | ||
|
||
## LayoutProvider | ||
|
||
## VecLayoutProvider (Advanced) |
Oops, something went wrong.