Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aspect ratio box #1645

Merged
merged 13 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 0 additions & 53 deletions druid/examples/aspect_ratio_box.rs

This file was deleted.

13 changes: 12 additions & 1 deletion druid/examples/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! This example shows how to construct a basic layout,
//! using columns, rows, and loops, for repeated Widgets.

use druid::widget::{Button, Flex, Label};
use druid::widget::{AspectRatioBox, Button, Flex, Label, LineBreaking};
use druid::{AppLauncher, Color, Widget, WidgetExt, WindowDesc};

fn build_app() -> impl Widget<u32> {
Expand Down Expand Up @@ -60,6 +60,17 @@ fn build_app() -> impl Widget<u32> {
weight,
);
}

// aspect ratio box
let aspect_ratio_label = Label::new("Hello there, this box it's aspect-ratio. Notice text will overflow if box becomes too small.")
arthmis marked this conversation as resolved.
Show resolved Hide resolved
.with_text_color(Color::BLACK)
.with_line_break_mode(LineBreaking::WordWrap)
.center();
let aspect_ratio_box = AspectRatioBox::new(aspect_ratio_label, 4.0)
.border(Color::BLACK, 1.0)
.background(Color::WHITE);
col.add_flex_child(aspect_ratio_box.center(), 1.0);

// This method asks druid to draw colored rectangles around our widgets,
// so we can visually inspect their layout rectangles.
col.debug_paint_layout()
Expand Down