mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 14:50:03 -04:00
code cleanup: Pos2::new -> pos2, Vec2::new -> vec2
This commit is contained in:
@@ -98,7 +98,7 @@ impl CollapsingState {
|
||||
ui: &mut Ui,
|
||||
icon_fn: impl FnOnce(&mut Ui, f32, &Response) + 'static,
|
||||
) -> Response {
|
||||
let size = Vec2::new(ui.spacing().indent, ui.spacing().icon_width);
|
||||
let size = vec2(ui.spacing().indent, ui.spacing().icon_width);
|
||||
let (_id, rect) = ui.allocate_space(size);
|
||||
let response = ui.interact(rect, self.id, Sense::click());
|
||||
if response.clicked() {
|
||||
|
||||
@@ -92,7 +92,7 @@ impl ComboBox {
|
||||
/// ) {
|
||||
/// let rect = egui::Rect::from_center_size(
|
||||
/// rect.center(),
|
||||
/// egui::Vec2::new(rect.width() * 0.6, rect.height() * 0.4),
|
||||
/// egui::vec2(rect.width() * 0.6, rect.height() * 0.4),
|
||||
/// );
|
||||
/// ui.painter().add(egui::Shape::convex_polygon(
|
||||
/// vec![rect.left_top(), rect.right_top(), rect.center_bottom()],
|
||||
|
||||
@@ -912,7 +912,7 @@ impl Context {
|
||||
/// How much space is used by panels and windows.
|
||||
/// You can shrink your egui area to this size and still fit all egui components.
|
||||
pub fn used_size(&self) -> Vec2 {
|
||||
self.used_rect().max - Pos2::new(0.0, 0.0)
|
||||
self.used_rect().max - Pos2::ZERO
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
@@ -1200,7 +1200,7 @@ impl Context {
|
||||
textures.len(),
|
||||
bytes as f64 * 1e-6
|
||||
));
|
||||
let max_preview_size = Vec2::new(48.0, 32.0);
|
||||
let max_preview_size = vec2(48.0, 32.0);
|
||||
|
||||
ui.group(|ui| {
|
||||
ScrollArea::vertical()
|
||||
@@ -1211,19 +1211,19 @@ impl Context {
|
||||
Grid::new("textures")
|
||||
.striped(true)
|
||||
.num_columns(4)
|
||||
.spacing(Vec2::new(16.0, 2.0))
|
||||
.spacing(vec2(16.0, 2.0))
|
||||
.min_row_height(max_preview_size.y)
|
||||
.show(ui, |ui| {
|
||||
for (&texture_id, meta) in textures {
|
||||
let [w, h] = meta.size;
|
||||
|
||||
let mut size = Vec2::new(w as f32, h as f32);
|
||||
let mut size = vec2(w as f32, h as f32);
|
||||
size *= (max_preview_size.x / size.x).min(1.0);
|
||||
size *= (max_preview_size.y / size.y).min(1.0);
|
||||
ui.image(texture_id, size).on_hover_ui(|ui| {
|
||||
// show larger on hover
|
||||
let max_size = 0.5 * ui.ctx().input().screen_rect().size();
|
||||
let mut size = Vec2::new(w as f32, h as f32);
|
||||
let mut size = vec2(w as f32, h as f32);
|
||||
size *= max_size.x / size.x.max(max_size.x);
|
||||
size *= max_size.y / size.y.max(max_size.y);
|
||||
ui.image(texture_id, size);
|
||||
|
||||
@@ -341,15 +341,15 @@ impl Margin {
|
||||
|
||||
/// Total margins on both sides
|
||||
pub fn sum(&self) -> Vec2 {
|
||||
Vec2::new(self.left + self.right, self.top + self.bottom)
|
||||
vec2(self.left + self.right, self.top + self.bottom)
|
||||
}
|
||||
|
||||
pub fn left_top(&self) -> Vec2 {
|
||||
Vec2::new(self.left, self.top)
|
||||
vec2(self.left, self.top)
|
||||
}
|
||||
|
||||
pub fn right_bottom(&self) -> Vec2 {
|
||||
Vec2::new(self.right, self.bottom)
|
||||
vec2(self.right, self.bottom)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user