Skip to content

Remove lenses module from derived lenses #340

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

Merged
merged 1 commit into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ To use the lens, wrap your widget with `LensWrap` (note the conversion of
CamelCase to snake_case):

```rust
LensWrap::new(WidgetThatExpectsf64::new(), lenses::app_state::value);
LensWrap::new(WidgetThatExpectsf64::new(), app_state::value);
```

## Using druid
Expand Down
13 changes: 5 additions & 8 deletions druid-derive/src/lens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,12 @@ fn derive_struct(input: &syn::DeriveInput) -> Result<proc_macro2::TokenStream, s
});

let expanded = quote! {
pub mod lenses {
pub mod #twizzled_name {
use super::super::*;

use druid::Lens;
#(#structs)*
#(#impls)*
}
pub mod #twizzled_name {
use super::*;

use druid::Lens;
#(#structs)*
#(#impls)*
}
};

Expand Down
2 changes: 1 addition & 1 deletion druid/examples/calc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn build_calc() -> impl Widget<CalcState> {
let mut column = Flex::column();
let display = LensWrap::new(
DynLabel::new(|data: &String, _env| data.clone()),
lenses::calc_state::value,
calc_state::value,
);
column.add_child(pad(display), 0.0);
column.add_child(
Expand Down
7 changes: 2 additions & 5 deletions druid/examples/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ fn ui_builder() -> impl Widget<AppState> {

let mut col = Flex::column();
col.add_child(
Padding::new(
5.0,
LensWrap::new(Checkbox::new(), lenses::app_state::which),
),
Padding::new(5.0, LensWrap::new(Checkbox::new(), app_state::which)),
0.0,
);
let either = Either::new(
|data, _env| data.which,
Padding::new(5.0, LensWrap::new(Slider::new(), lenses::app_state::value)),
Padding::new(5.0, LensWrap::new(Slider::new(), app_state::value)),
Padding::new(5.0, label),
);
col.add_child(either, 0.0);
Expand Down
6 changes: 3 additions & 3 deletions druid/examples/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ fn build_widget() -> impl Widget<DemoState> {
}
});
let mut row = Flex::row();
let checkbox = LensWrap::new(Checkbox::new(), lenses::demo_state::double);
let checkbox = LensWrap::new(Checkbox::new(), demo_state::double);
let checkbox_label = Label::new("double the value");
row.add_child(checkbox, 0.0);
row.add_child(Padding::new(5.0, checkbox_label), 1.0);

let bar = LensWrap::new(ProgressBar::new(), lenses::demo_state::value);
let slider = LensWrap::new(Slider::new(), lenses::demo_state::value);
let bar = LensWrap::new(ProgressBar::new(), demo_state::value);
let slider = LensWrap::new(Slider::new(), demo_state::value);

let button_1 = Button::sized(
"increment ",
Expand Down
2 changes: 1 addition & 1 deletion druid/examples/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct DemoState {
fn build_widget() -> impl Widget<DemoState> {
let mut col = Flex::column();
let mut row = Flex::row();
let switch = LensWrap::new(Switch::new(), lenses::demo_state::value);
let switch = LensWrap::new(Switch::new(), demo_state::value);
let switch_label = Label::new("Setting label");

row.add_child(Padding::new(5.0, switch_label), 0.0);
Expand Down