| 81 | } |
| 82 | |
| 83 | fn thumbnails_panel(&mut self, ui: &mut egui::Ui, default_width: f32) { |
| 84 | egui::Panel::left("examples_panel") |
| 85 | .default_size(default_width) |
| 86 | // Set min_size so the heading is well rendered. |
| 87 | .min_size(100.0) |
| 88 | // 3 columns + some space extra for buttons. |
| 89 | // TODO(#193): get rid of "extra space" calc. |
| 90 | .max_size(Self::COL_WIDTH * 3. + 30.) |
| 91 | .resizable(true) |
| 92 | .show(ui, |ui| { |
| 93 | ScrollArea::vertical().show(ui, |ui| { |
| 94 | let available_width = ui.available_width(); |
| 95 | let num_columns = 1.max((available_width / Self::COL_WIDTH).floor() as usize); |
| 96 | let scale = 1.0_f32.min(available_width / (Self::COL_WIDTH * num_columns as f32)); |
| 97 | |
| 98 | ui.heading("Examples"); |
| 99 | ui.separator(); |
| 100 | |
| 101 | let num_examples = self.examples.len(); |
| 102 | egui::Grid::new("examples_grid").show(ui, |ui| { |
| 103 | for index in 0..num_examples { |
| 104 | self.make_cell(index, ui, scale); |
| 105 | if (index + 1) % num_columns == 0 { |
| 106 | ui.end_row(); |
| 107 | } |
| 108 | } |
| 109 | }); |
| 110 | }); |
| 111 | }); |
| 112 | } |
| 113 | |
| 114 | fn info_panel(&mut self, ui: &mut egui::Ui, index: usize) { |
| 115 | egui::Panel::right("info_panel") |