mirror of
https://github.com/emilk/egui.git
synced 2026-09-03 15:20:05 -04:00
Clean up various small TODOs
This commit is contained in:
@@ -286,7 +286,6 @@ impl<'open> Window<'open> {
|
||||
let outer_rect = frame.end(&mut area_content_ui);
|
||||
|
||||
if possible.resizable {
|
||||
// TODO: draw BEHIND contents ?
|
||||
paint_resize_corner(&mut area_content_ui, outer_rect, frame_stroke);
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ impl FrameHistory {
|
||||
|
||||
for (time, cpu_usage) in history.iter() {
|
||||
let age = (right_side_time - time) as f32;
|
||||
let x = remap(age, history.max_age()..=0.0, rect.range_x());
|
||||
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(
|
||||
|
||||
@@ -269,7 +269,7 @@ fn vertex_gradient(ui: &mut Ui, bg_fill: Srgba, gradient: &Gradient) -> Response
|
||||
let mut triangles = Triangles::default();
|
||||
for (i, &color) in gradient.0.iter().enumerate() {
|
||||
let t = i as f32 / (n as f32 - 1.0);
|
||||
let x = lerp(rect.range_x(), t);
|
||||
let x = lerp(rect.x_range(), t);
|
||||
triangles.colored_vertex(pos2(x, rect.top()), color);
|
||||
triangles.colored_vertex(pos2(x, rect.bottom()), color);
|
||||
if i < n - 1 {
|
||||
|
||||
@@ -32,8 +32,8 @@ impl Texture {
|
||||
show_tooltip(ui.ctx(), |ui| {
|
||||
let pos = ui.input().mouse.pos.unwrap_or_else(|| ui.left_top());
|
||||
let zoom_rect = ui.allocate_space(vec2(128.0, 128.0));
|
||||
let u = remap_clamp(pos.x, rect.range_x(), 0.0..=tex_w);
|
||||
let v = remap_clamp(pos.y, rect.range_y(), 0.0..=tex_h);
|
||||
let u = remap_clamp(pos.x, rect.x_range(), 0.0..=tex_w);
|
||||
let v = remap_clamp(pos.y, rect.y_range(), 0.0..=tex_h);
|
||||
|
||||
let texel_radius = 32.0;
|
||||
let u = u.at_least(texel_radius).at_most(tex_w - texel_radius);
|
||||
|
||||
@@ -139,14 +139,12 @@ impl Rect {
|
||||
self.width() * self.height()
|
||||
}
|
||||
|
||||
pub fn range_x(&self) -> RangeInclusive<f32> {
|
||||
pub fn x_range(&self) -> RangeInclusive<f32> {
|
||||
self.min.x..=self.max.x
|
||||
}
|
||||
|
||||
pub fn range_y(&self) -> RangeInclusive<f32> {
|
||||
pub fn y_range(&self) -> RangeInclusive<f32> {
|
||||
self.min.y..=self.max.y
|
||||
}
|
||||
|
||||
pub fn bottom_up_range(&self) -> RangeInclusive<f32> {
|
||||
self.max.y..=self.min.y
|
||||
}
|
||||
|
||||
@@ -711,8 +711,13 @@ impl Ui {
|
||||
}
|
||||
|
||||
/// Start a ui with horizontal layout.
|
||||
/// Elements will be centered on the Y axis.
|
||||
/// Initial height is `style.spacing.interact_size.y`.
|
||||
/// After you have called this, the registers the contents as any other widget.
|
||||
///
|
||||
/// Elements will be centered on the Y axis, i.e.
|
||||
/// adjusted up and down to lie in the center of the horizontal layout.
|
||||
/// The initial height is `style.spacing.interact_size.y`.
|
||||
/// Centering is almost always what you want if you are
|
||||
/// planning to to mix widgets or just different types of text.
|
||||
pub fn horizontal<R>(&mut self, add_contents: impl FnOnce(&mut Ui) -> R) -> (R, Rect) {
|
||||
let initial_size = vec2(
|
||||
self.available().width(),
|
||||
|
||||
@@ -367,6 +367,7 @@ impl<'a> Widget for Checkbox<'a> {
|
||||
let mut desired_size =
|
||||
button_padding + vec2(icon_width + icon_spacing, 0.0) + galley.size + button_padding;
|
||||
desired_size = desired_size.at_least(spacing.interact_size);
|
||||
desired_size.y = desired_size.y.max(icon_width);
|
||||
let rect = ui.allocate_space(desired_size);
|
||||
|
||||
let response = ui.interact(rect, id, Sense::click());
|
||||
@@ -450,6 +451,7 @@ impl Widget for RadioButton {
|
||||
let mut desired_size =
|
||||
button_padding + vec2(icon_width + icon_spacing, 0.0) + galley.size + button_padding;
|
||||
desired_size = desired_size.at_least(ui.style().spacing.interact_size);
|
||||
desired_size.y = desired_size.y.max(icon_width);
|
||||
let rect = ui.allocate_space(desired_size);
|
||||
|
||||
let response = ui.interact(rect, id, Sense::click());
|
||||
|
||||
Reference in New Issue
Block a user