Skip to content

Commit 8dd855a

Browse files
committed
Add Flex::row/column, deprecate Column/Row
I'm actually fairly ambivalent about this change, but it makes things more consistent and perhaps slightly less confusing.
1 parent 8d1680f commit 8dd855a

File tree

15 files changed

+57
-46
lines changed

15 files changed

+57
-46
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ active development and its API might change.
2222
Here's a simple counter example app.
2323

2424
```rust
25-
use druid::widget::{Align, Button, Column, Label, Padding, WidgetExt};
25+
use druid::widget::{Align, Button, Flex, Label, Padding, WidgetExt};
2626
use druid::{AppLauncher, LocalizedString, Widget, WindowDesc};
2727

2828
fn main() {
@@ -44,7 +44,7 @@ fn ui_builder() -> impl Widget<u32> {
4444
let button = Button::new("increment", |_ctx, data, _env| *data += 1)
4545
.padding(5.0);
4646

47-
let mut col = Column::new();
47+
let mut col = Flex::column();
4848
col.add_child(label, 1.0);
4949
col.add_child(button, 1.0);
5050
col
@@ -153,7 +153,7 @@ implement your own. You can also compose widgets into new widgets:
153153

154154
```rust
155155
fn build_widget() -> impl Widget<u32> {
156-
let mut col = Column::new();
156+
let mut col = Flex::column();
157157
for i in 0..30 {
158158
let button = Button::new(format!("Button {}", i), Button::noop)
159159
.padding(5.0).;

druid/examples/calc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
1717
use druid::{AppLauncher, Data, Lens, LensWrap, Widget, WindowDesc};
1818

19-
use druid::widget::{Button, Column, DynLabel, Padding, Row};
19+
use druid::widget::{Button, DynLabel, Flex, Padding};
2020

2121
#[derive(Clone, Data, Lens)]
2222
struct CalcState {
@@ -140,7 +140,7 @@ fn flex_row<T: Data>(
140140
w3: impl Widget<T> + 'static,
141141
w4: impl Widget<T> + 'static,
142142
) -> impl Widget<T> {
143-
let mut row = Row::new();
143+
let mut row = Flex::row();
144144
row.add_child(w1, 1.0);
145145
row.add_child(w2, 1.0);
146146
row.add_child(w3, 1.0);
@@ -149,7 +149,7 @@ fn flex_row<T: Data>(
149149
}
150150

151151
fn build_calc() -> impl Widget<CalcState> {
152-
let mut column = Column::new();
152+
let mut column = Flex::column();
153153
let display = LensWrap::new(
154154
DynLabel::new(|data: &String, _env| data.clone()),
155155
lenses::calc_state::value,

druid/examples/either.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use druid::widget::{Checkbox, Column, Either, Label, Padding, Slider};
15+
use druid::widget::{Checkbox, Either, Flex, Label, Padding, Slider};
1616
use druid::{AppLauncher, Data, Lens, LensWrap, Widget, WindowDesc};
1717

1818
#[derive(Clone, Default, Data, Lens)]
@@ -33,7 +33,7 @@ fn main() {
3333
fn ui_builder() -> impl Widget<AppState> {
3434
let label = Label::new("Click to reveal slider");
3535

36-
let mut col = Column::new();
36+
let mut col = Flex::column();
3737
col.add_child(
3838
Padding::new(
3939
5.0,

druid/examples/hello.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use druid::widget::{Align, Button, Column, Label, Padding};
15+
use druid::widget::{Align, Button, Flex, Label, Padding};
1616
use druid::{AppLauncher, LocalizedString, Widget, WindowDesc};
1717

1818
fn main() {
@@ -30,7 +30,7 @@ fn ui_builder() -> impl Widget<u32> {
3030
let label = Label::new(text);
3131
let button = Button::new("increment", |_ctx, data, _env| *data += 1);
3232

33-
let mut col = Column::new();
33+
let mut col = Flex::column();
3434
col.add_child(Align::centered(Padding::new(5.0, label)), 1.0);
3535
col.add_child(Padding::new(5.0, button), 1.0);
3636
col

druid/examples/layout.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
//! This example shows how to construct a basic layout.
1616
1717
use druid::piet::Color;
18-
use druid::widget::{Button, Column, Label, Row, SizedBox, WidgetExt};
18+
use druid::widget::{Button, Flex, Label, SizedBox, WidgetExt};
1919
use druid::{AppLauncher, Widget, WindowDesc};
2020

2121
fn build_app() -> impl Widget<u32> {
2222
// Begin construction of vertical layout
23-
let mut col = Column::new();
23+
let mut col = Flex::column();
2424

2525
// Construct a horizontal layout.
26-
let mut header = Row::new();
26+
let mut header = Flex::row();
2727
header.add_child(
2828
Label::new("One")
2929
.center()

druid/examples/list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::sync::Arc;
1717

1818
use druid::piet::Color;
1919

20-
use druid::widget::{Button, Column, Container, DynLabel, List, Padding, Scroll, SizedBox};
20+
use druid::widget::{Button, Container, DynLabel, Flex, List, Padding, Scroll, SizedBox};
2121
use druid::{AppLauncher, Widget, WindowDesc};
2222

2323
type AppData = Arc<Vec<u32>>;
@@ -32,7 +32,7 @@ fn main() {
3232
}
3333

3434
fn ui_builder() -> impl Widget<AppData> {
35-
let mut root = Column::new();
35+
let mut root = Flex::column();
3636

3737
root.add_child(
3838
SizedBox::new(Button::new("Add", |_, data: &mut AppData, _| {

druid/examples/multiwin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
//! Opening and closing windows and using window and context menus.
1616
17-
use druid::widget::{Align, Button, Column, Label, Padding, Row};
17+
use druid::widget::{Align, Button, Flex, Label, Padding};
1818
use druid::{
1919
AppDelegate, AppLauncher, Command, ContextMenu, Data, DelegateCtx, Env, Event, EventCtx,
2020
LocalizedString, MenuDesc, MenuItem, Selector, Widget, WindowDesc, WindowId,
@@ -73,9 +73,9 @@ fn ui_builder() -> impl Widget<State> {
7373
ctx.set_menu(make_menu::<State>(data));
7474
});
7575

76-
let mut col = Column::new();
76+
let mut col = Flex::column();
7777
col.add_child(Align::centered(Padding::new(5.0, label)), 1.0);
78-
let mut row = Row::new();
78+
let mut row = Flex::row();
7979
row.add_child(Padding::new(5.0, inc_button), 1.0);
8080
row.add_child(Padding::new(5.0, dec_button), 1.0);
8181
col.add_child(row, 1.0);

druid/examples/radio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use druid::widget::{Column, Padding, Radio, RadioGroup, SizedBox};
15+
use druid::widget::{Flex, Padding, Radio, RadioGroup, SizedBox};
1616
use druid::{AppLauncher, Data, Widget, WindowDesc};
1717

1818
#[derive(Clone, PartialEq, Data)]
@@ -24,7 +24,7 @@ enum Choice {
2424
}
2525

2626
fn build_widget() -> impl Widget<Choice> {
27-
let mut col = Column::new();
27+
let mut col = Flex::column();
2828

2929
col.add_child(
3030
Padding::new(5.0, Radio::new("First choice", Choice::A)),

druid/examples/scroll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use druid::widget::{Button, Column, Padding, Scroll};
15+
use druid::widget::{Button, Flex, Padding, Scroll};
1616
use druid::{AppLauncher, Widget, WindowDesc};
1717

1818
fn main() {
@@ -24,7 +24,7 @@ fn main() {
2424
}
2525

2626
fn build_widget() -> impl Widget<u32> {
27-
let mut col = Column::new();
27+
let mut col = Flex::column();
2828
for i in 0..30 {
2929
let button = Button::new(format!("Button {}", i), Button::noop);
3030
col.add_child(Padding::new(3.0, button), 0.0);

druid/examples/scroll_colors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
//! This example allows to play with scroll bars over different color tones.
1616
1717
use druid::piet::Color;
18-
use druid::widget::{Column, Container, Row, Scroll, SizedBox};
18+
use druid::widget::{Container, Flex, Scroll, SizedBox};
1919
use druid::{AppLauncher, Widget, WindowDesc};
2020

2121
fn build_app() -> impl Widget<u32> {
22-
let mut col = Column::new();
22+
let mut col = Flex::column();
2323
let rows = 30;
2424
let cols = 30;
2525

2626
for i in 0..cols {
27-
let mut row = Row::new();
27+
let mut row = Flex::row();
2828
let col_progress = i as f64 / cols as f64;
2929

3030
for j in 0..rows {

0 commit comments

Comments
 (0)