Skip to content

Commit ed1c191

Browse files
committed
Update tests and examples to removal of event::Raw type
1 parent 23f728c commit ed1c191

18 files changed

+31
-32
lines changed

examples/canvas.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
events.set_ups(60);
2525

2626
// construct our `Ui`.
27-
let mut ui = conrod::UiBuilder::new().build();
27+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
2828

2929
// Add a `Font` to the `Ui`'s `font::Map` from file.
3030
let assets = find_folder::Search::KidsThenParents(3, 5).for_folder("assets").unwrap();

examples/counter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
events.set_ups(60);
2525

2626
// construct our `Ui`.
27-
let mut ui = conrod::UiBuilder::new().build();
27+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
2828

2929
// Generate the widget identifiers.
3030
widget_ids!(struct Ids { canvas, counter });

examples/custom_widget.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ pub fn main() {
248248
events.set_ups(60);
249249

250250
// construct our `Ui`.
251-
let mut ui = conrod::UiBuilder::new().build();
251+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
252252

253253
// The `widget_ids` macro is a easy, safe way of generating a type for producing `widget::Id`s.
254254
widget_ids! {

examples/file_navigator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
events.set_ups(60);
2525

2626
// Construct our `Ui`.
27-
let mut ui = conrod::UiBuilder::new().build();
27+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
2828

2929
// A unique identifier for each widget.
3030
widget_ids!(struct Ids { canvas, file_navigator });

examples/glutin_gfx.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ mod feature {
168168
let mut app = support::DemoApp::new();
169169

170170
// Create Ui and Ids of widgets to instantiate
171-
let mut ui = conrod::UiBuilder::new().theme(support::theme()).build();
171+
let mut ui = conrod::UiBuilder::new([WIN_W as f64, WIN_H as f64]).theme(support::theme()).build();
172172
let ids = support::Ids::new(ui.widget_id_generator());
173173

174174
// Load font from file
@@ -209,9 +209,6 @@ mod feature {
209209

210210
let dpi_factor = window.hidpi_factor();
211211

212-
let dt_secs = 0.0;
213-
ui.handle_event(conrod::event::render(dt_secs, win_w, win_h, dpi_factor as conrod::Scalar));
214-
215212
if let Some(mut primitives) = ui.draw_if_changed() {
216213
let (screen_width, screen_height) = (win_w as f32 * dpi_factor, win_h as f32 * dpi_factor);
217214
let mut vertices = Vec::new();

examples/glutin_glium.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mod feature {
3939
let mut app = support::DemoApp::new();
4040

4141
// Construct our `Ui`.
42-
let mut ui = conrod::UiBuilder::new().theme(support::theme()).build();
42+
let mut ui = conrod::UiBuilder::new([WIN_W as f64, WIN_H as f64]).theme(support::theme()).build();
4343

4444
// The `widget::Id` of each widget instantiated in `support::gui`.
4545
let ids = support::Ids::new(ui.widget_id_generator());
@@ -81,12 +81,6 @@ mod feature {
8181
// - Repeat.
8282
'main: loop {
8383

84-
// Construct a render event for conrod at the beginning of rendering.
85-
// NOTE: This will be removed in a future version of conrod as Render events shouldn't
86-
// be necessary.
87-
let window = display.get_window().unwrap();
88-
ui.handle_event(conrod::backend::glutin::render_event(window).unwrap());
89-
9084
// Poll for events.
9185
for event in display.poll_events() {
9286

@@ -115,7 +109,7 @@ mod feature {
115109
let (win_w, win_h) = (win_rect.w() as u32, win_rect.h() as u32);
116110
let (w, h) = display.get_window().unwrap().get_inner_size_points().unwrap();
117111
if w != win_w || h != win_h {
118-
let event: conrod::event::Raw = conrod::event::Input::Resize(w, h).into();
112+
let event = conrod::event::Input::Resize(w, h);
119113
ui.handle_event(event);
120114
}
121115
}

examples/image.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn main() {
2828
events.set_ups(60);
2929

3030
// construct our `Ui`.
31-
let mut ui = conrod::UiBuilder::new().build();
31+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
3232

3333
// Create an empty texture to pass for the text cache as we're not drawing any text.
3434
let mut text_texture_cache = piston_window::GlyphCache::new(&mut window, 0, 0);
@@ -48,7 +48,11 @@ fn main() {
4848

4949
// Poll events from the window.
5050
while let Some(event) = events.next(&mut window) {
51-
ui.handle_event(event.clone());
51+
52+
// Convert the piston event to a conrod input event.
53+
if let Some(e) = piston_window::convert_event(event.clone(), &window) {
54+
ui.handle_event(e);
55+
}
5256

5357
window.draw_2d(&event, |c, g| {
5458
if let Some(primitives) = ui.draw_if_changed() {

examples/image_button.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fn main() {
3232
let mut events = WindowEvents::new();
3333

3434
// construct our `Ui`.
35-
let mut ui = conrod::UiBuilder::new().build();
35+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
3636

3737
// Add a `Font` to the `Ui`'s `font::Map` from file.
3838
let assets = find_folder::Search::KidsThenParents(3, 5).for_folder("assets").unwrap();

examples/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn main() {
2525
events.set_ups(60);
2626

2727
// Construct our `Ui`.
28-
let mut ui = conrod::UiBuilder::new().build();
28+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
2929

3030
// Unique identifier for each widget.
3131
let ids = Ids::new(ui.widget_id_generator());

examples/list_select.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929
events.set_ups(60);
3030

3131
// Construct our `Ui`.
32-
let mut ui = conrod::UiBuilder::new().build();
32+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
3333

3434
// A unique identifier for each widget.
3535
let ids = Ids::new(ui.widget_id_generator());

examples/old_demo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn main() {
110110
events.set_ups(60);
111111

112112
// construct our `Ui`.
113-
let mut ui = conrod::UiBuilder::new().build();
113+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
114114

115115
// Identifiers used for instantiating our widgets.
116116
let mut ids = Ids::new(ui.widget_id_generator());

examples/plot_path.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ widget_ids! {
1010
}
1111

1212
fn main() {
13+
const WIDTH: u32 = 720;
14+
const HEIGHT: u32 = 360;
1315

1416
// Construct the window.
1517
let mut window: Window =
16-
piston_window::WindowSettings::new("PlotPath Demo", [720, 360])
18+
piston_window::WindowSettings::new("PlotPath Demo", [WIDTH, HEIGHT])
1719
.opengl(OpenGL::V3_2)
1820
.samples(4)
1921
.exit_on_esc(true)
@@ -25,7 +27,7 @@ fn main() {
2527
events.set_ups(60);
2628

2729
// Construct our `Ui`.
28-
let mut ui = conrod::UiBuilder::new().build();
30+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
2931

3032
// A unique identifier for each widget.
3133
let ids = Ids::new(ui.widget_id_generator());

examples/primitives.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,23 @@ widget_ids! {
2222

2323

2424
fn main() {
25+
const WIDTH: u32 = 400;
26+
const HEIGHT: u32 = 720;
2527

2628
// Change this to OpenGL::V2_1 if not working.
2729
let opengl = OpenGL::V3_2;
2830

2931
// Construct the window.
3032
let mut window: Window =
31-
piston_window::WindowSettings::new("Primitives Demo", [400, 720])
33+
piston_window::WindowSettings::new("Primitives Demo", [WIDTH, HEIGHT])
3234
.opengl(opengl).samples(4).exit_on_esc(true).build().unwrap();
3335

3436
// Create the event loop.
3537
let mut events = WindowEvents::new();
3638
events.set_ups(60);
3739

3840
// construct our `Ui`.
39-
let mut ui = conrod::UiBuilder::new().build();
41+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
4042

4143
// A unique identifier for each widget.
4244
let ids = Ids::new(ui.widget_id_generator());

examples/range_slider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727
events.set_ups(60);
2828

2929
// Construct our `Ui`.
30-
let mut ui = conrod::UiBuilder::new().build();
30+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
3131

3232
// A unique identifier for each widget.
3333
let ids = Ids::new(ui.widget_id_generator());

examples/text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() {
2222
events.set_ups(60);
2323

2424
// Construct our `Ui`.
25-
let mut ui = conrod::UiBuilder::new().build();
25+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
2626

2727
// A unique identifier for each widget.
2828
let ids = Ids::new(ui.widget_id_generator());

examples/text_edit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323
events.set_ups(60);
2424

2525
// Construct our `Ui`.
26-
let mut ui = conrod::UiBuilder::new().build();
26+
let mut ui = conrod::UiBuilder::new([WIDTH as f64, HEIGHT as f64]).build();
2727

2828
// A unique identifier for each widget.
2929
let ids = Ids::new(ui.widget_id_generator());

src/tests/ui.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn to_window_coordinates(xy: Point, ui: &Ui) -> Point {
6565
}
6666

6767
fn windowless_ui() -> Ui {
68-
UiBuilder::new().build()
68+
UiBuilder::new([800.0, 600.0]).build()
6969
}
7070

7171

src/widget/id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ fn test() {
371371
}
372372
}
373373

374-
let mut ui = UiBuilder::new().build();
374+
let mut ui = UiBuilder::new([800.0, 600.0]).build();
375375
let mut ids = Ids::new(ui.widget_id_generator());
376376

377377
for _ in 0..10 {
@@ -402,7 +402,7 @@ fn test_invocation_variations() {
402402
widget_ids! { struct G { foo[], bar, } }
403403
widget_ids! { pub struct H { foo, bar[], } }
404404

405-
let mut ui = UiBuilder::new().build();
405+
let mut ui = UiBuilder::new([800.0, 600.0]).build();
406406
let mut ui = ui.set_widgets();
407407
let a = A::new(ui.widget_id_generator());
408408
let b = B::new(ui.widget_id_generator());

0 commit comments

Comments
 (0)