1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-03 15:20:05 -04:00

[refactor] remove Ui::canvas (use Ui::allocate_space instead)

This commit is contained in:
Emil Ernerfeldt
2020-10-10 12:24:45 +02:00
parent b01690c7b8
commit 343648b94c
3 changed files with 4 additions and 22 deletions

View File

@@ -104,9 +104,10 @@ impl DemoWindow {
.show(ui, |ui| {
ui.horizontal(|ui| {
ui.label("You can pretty easily paint your own small icons:");
let painter = ui.canvas(Vec2::splat(16.0));
let c = painter.clip_rect().center();
let r = painter.clip_rect().width() / 2.0 - 1.0;
let rect = ui.allocate_space(Vec2::splat(16.0));
let painter = ui.painter();
let c = rect.center();
let r = rect.width() / 2.0 - 1.0;
let color = Srgba::gray(128);
let stroke = Stroke::new(1.0, color);
painter.circle_stroke(c, r, stroke);

View File

@@ -561,15 +561,6 @@ impl Ui {
response
}
/// Ask to allocate a certain amount of space and return a Painter for that region.
///
/// You may get back a `Painter` with a smaller or larger size than what you desired,
/// depending on the available space and the current layout.
pub fn canvas(&mut self, desired_size: Vec2) -> Painter {
let rect = self.allocate_space(desired_size);
self.painter_at(rect)
}
/// Show an image here with the given size
pub fn image(&mut self, texture_id: TextureId, desired_size: Vec2) -> Response {
self.add(Image::new(texture_id, desired_size))