-
Notifications
You must be signed in to change notification settings - Fork 27
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
23 changed files
with
338 additions
and
176 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
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use gooey::value::{Dynamic, StringValue}; | ||
use gooey::widget::MakeWidget; | ||
use gooey::Run; | ||
|
||
// begin rustme snippet: readme | ||
fn main() -> gooey::Result { | ||
// Create a dynamic usize. | ||
let count = Dynamic::new(0_isize); | ||
// Create a dynamic that contains `count.to_string()` | ||
let count_label = count.map_each(ToString::to_string); | ||
|
||
// Create a new button whose text is our dynamic string. | ||
count_label | ||
.into_button() | ||
// Set the `on_click` callback to a closure that increments the counter. | ||
.on_click(count.with_clone(|count| move |_| count.set(count.get() + 1))) | ||
// Position the button in the center | ||
.centered() | ||
// Run the application | ||
.run() | ||
} | ||
// end rustme snippet |
File renamed without changes.
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
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,7 +1,7 @@ | ||
use gooey::value::StringValue; | ||
use gooey::widget::MakeWidget; | ||
use gooey::widgets::Input; | ||
use gooey::Run; | ||
|
||
fn main() -> gooey::Result { | ||
Input::new("Hello").expand().run() | ||
"Hello".into_input().expand().run() | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use gooey::value::StringValue; | ||
use gooey::widget::MakeWidget; | ||
use gooey::Run; | ||
|
||
/// This example shows a tricky layout problem. The hierarchy of widgets is | ||
/// this: | ||
/// | ||
/// ```text | ||
/// Expand (.expand()) | ||
/// | Align (.centered()) | ||
/// | | Stack (.into_rows()) | ||
/// | | | Label | ||
/// | | | Align (.centered()) | ||
/// | | | | Button | ||
/// ``` | ||
/// | ||
/// When the Stack widget attempted to implmement a single-pass layout, this | ||
/// caused the Button to be aligned to the left inside of the stack. The Stack | ||
/// widget now utilizes two `layout()` operations for layouts like this. Here's | ||
/// the reasoning: | ||
/// | ||
/// At the window root, we have an Align wrapped by an Expand. The Align widget | ||
/// during layout asks its children to size-to-fit. This means the Stack is | ||
/// asking its children to size-to-fit as well. | ||
/// | ||
/// The Stack's orientation is Rows, and since the children are Resizes or | ||
/// Expands, the widgets are size-to-fit. This means that the Stack will measure | ||
/// these widgets asking them to size to fit. | ||
/// | ||
/// After running this pass of measurement, we can assign the heights of each of | ||
/// the rows to the measurements we received. The width of the stack becomes the | ||
/// maximum width of all children measured. | ||
/// | ||
/// In a single-pass layout, this means the Align widget inside of the Stack | ||
/// never receives an opportunity to lay its children out with the final width. | ||
/// The Button does end up centered because of this. Fixing it also becomes | ||
/// tricky, because if surround the button in an Expand, it now instructs the | ||
/// Stack to expand to fill its parent. | ||
/// | ||
/// After some careful deliberation, @ecton reasoned that in the situation where | ||
/// a Stack is asked to layout with the Stack's non-primary being a size-to-fit | ||
/// measurement, a second layout call for all children is required with Known | ||
/// measurements to allow layouts like this example to work correctly. | ||
fn main() -> gooey::Result { | ||
// TODO once we have offscreen rendering, turn this into a test case | ||
"Really Long Label" | ||
.and("Short".into_button().centered()) | ||
.into_rows() | ||
.contain() | ||
.centered() | ||
.expand() | ||
.run() | ||
} |
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
Oops, something went wrong.