mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 05:10:03 -04:00
Rename PaintCmd to Shape
This commit is contained in:
@@ -300,7 +300,7 @@ fn vertex_gradient(ui: &mut Ui, bg_fill: Color32, gradient: &Gradient) -> Respon
|
||||
if bg_fill != Default::default() {
|
||||
let mut triangles = Triangles::default();
|
||||
triangles.add_colored_rect(rect, bg_fill);
|
||||
ui.painter().add(PaintCmd::triangles(triangles));
|
||||
ui.painter().add(Shape::triangles(triangles));
|
||||
}
|
||||
{
|
||||
let n = gradient.0.len();
|
||||
@@ -317,7 +317,7 @@ fn vertex_gradient(ui: &mut Ui, bg_fill: Color32, gradient: &Gradient) -> Respon
|
||||
triangles.add_triangle(2 * i + 1, 2 * i + 2, 2 * i + 3);
|
||||
}
|
||||
}
|
||||
ui.painter().add(PaintCmd::triangles(triangles));
|
||||
ui.painter().add(Shape::triangles(triangles));
|
||||
}
|
||||
response
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ impl super::View for DancingStrings {
|
||||
let desired_size = ui.available_width() * vec2(1.0, 0.35);
|
||||
let (_id, rect) = ui.allocate_space(desired_size);
|
||||
|
||||
let mut cmds = vec![];
|
||||
let mut shapes = vec![];
|
||||
|
||||
for &mode in &[2, 3, 5] {
|
||||
let mode = mode as f32;
|
||||
@@ -55,13 +55,13 @@ impl super::View for DancingStrings {
|
||||
.collect();
|
||||
|
||||
let thickness = 10.0 / mode;
|
||||
cmds.push(paint::PaintCmd::line(
|
||||
shapes.push(paint::Shape::line(
|
||||
points,
|
||||
Stroke::new(thickness, Color32::from_additive_luminance(196)),
|
||||
));
|
||||
}
|
||||
|
||||
ui.painter().extend(cmds);
|
||||
ui.painter().extend(shapes);
|
||||
});
|
||||
ui.add(crate::__egui_github_link_file!());
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ pub fn drop_target<R>(
|
||||
|
||||
let outer_rect_bounds = ui.available_rect_before_wrap();
|
||||
let inner_rect = outer_rect_bounds.shrink2(margin);
|
||||
let where_to_put_background = ui.painter().add(PaintCmd::Noop);
|
||||
let where_to_put_background = ui.painter().add(Shape::Noop);
|
||||
let mut content_ui = ui.child_ui(inner_rect, *ui.layout());
|
||||
let ret = body(&mut content_ui);
|
||||
let outer_rect = Rect::from_min_max(outer_rect_bounds.min, content_ui.min_rect().max + margin);
|
||||
@@ -61,7 +61,7 @@ pub fn drop_target<R>(
|
||||
|
||||
ui.painter().set(
|
||||
where_to_put_background,
|
||||
PaintCmd::Rect {
|
||||
Shape::Rect {
|
||||
corner_radius: style.corner_radius,
|
||||
fill: style.bg_fill,
|
||||
stroke: style.bg_stroke,
|
||||
|
||||
@@ -52,7 +52,7 @@ impl Painting {
|
||||
for line in &self.lines {
|
||||
if line.len() >= 2 {
|
||||
let points: Vec<Pos2> = line.iter().map(|p| rect.min + *p).collect();
|
||||
painter.add(PaintCmd::line(points, self.stroke));
|
||||
painter.add(Shape::line(points, self.stroke));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ impl FrameHistory {
|
||||
let (rect, response) = ui.allocate_at_least(size, Sense::hover());
|
||||
let style = ui.style().noninteractive();
|
||||
|
||||
let mut cmds = vec![PaintCmd::Rect {
|
||||
let mut shapes = vec![Shape::Rect {
|
||||
rect,
|
||||
corner_radius: style.corner_radius,
|
||||
fill: ui.style().visuals.dark_bg_color,
|
||||
@@ -82,13 +82,13 @@ impl FrameHistory {
|
||||
if let Some(mouse_pos) = ui.input().mouse.pos {
|
||||
if rect.contains(mouse_pos) {
|
||||
let y = mouse_pos.y;
|
||||
cmds.push(PaintCmd::line_segment(
|
||||
shapes.push(Shape::line_segment(
|
||||
[pos2(rect.left(), y), pos2(rect.right(), y)],
|
||||
line_stroke,
|
||||
));
|
||||
let cpu_usage = remap(y, rect.bottom_up_range(), 0.0..=graph_top_cpu_usage);
|
||||
let text = format!("{:.1} ms", 1e3 * cpu_usage);
|
||||
cmds.push(PaintCmd::text(
|
||||
shapes.push(Shape::text(
|
||||
ui.fonts(),
|
||||
pos2(rect.left(), y),
|
||||
egui::Align2::LEFT_BOTTOM,
|
||||
@@ -108,17 +108,17 @@ impl FrameHistory {
|
||||
let x = remap(age, history.max_age()..=0.0, rect.x_range());
|
||||
let y = remap_clamp(cpu_usage, 0.0..=graph_top_cpu_usage, rect.bottom_up_range());
|
||||
|
||||
cmds.push(PaintCmd::line_segment(
|
||||
shapes.push(Shape::line_segment(
|
||||
[pos2(x, rect.bottom()), pos2(x, y)],
|
||||
line_stroke,
|
||||
));
|
||||
|
||||
if cpu_usage < graph_top_cpu_usage {
|
||||
cmds.push(PaintCmd::circle_filled(pos2(x, y), radius, circle_color));
|
||||
shapes.push(Shape::circle_filled(pos2(x, y), radius, circle_color));
|
||||
}
|
||||
}
|
||||
|
||||
ui.painter().extend(cmds);
|
||||
ui.painter().extend(shapes);
|
||||
|
||||
response
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ fn test_egui_e2e() {
|
||||
for _ in 0..NUM_FRAMES {
|
||||
ctx.begin_frame(raw_input.clone());
|
||||
demo_windows.ui(&ctx);
|
||||
let (_output, paint_commands) = ctx.end_frame();
|
||||
let paint_jobs = ctx.tessellate(paint_commands);
|
||||
let (_output, shapes) = ctx.end_frame();
|
||||
let paint_jobs = ctx.tessellate(shapes);
|
||||
assert!(!paint_jobs.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user