mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-23 17:07:12 +03:00
Upgrade to Rust 1.50. Use the new f64 clamp instead of our own. [rebuild]
This commit is contained in:
parent
e333838560
commit
6e7a91ada1
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
||||
|
||||
- uses: hecrj/setup-rust-action@v1
|
||||
with:
|
||||
rust-version: 1.47.0
|
||||
rust-version: 1.50.0
|
||||
|
||||
- name: Cache build
|
||||
uses: actions/cache@v2
|
||||
|
@ -1,16 +1,6 @@
|
||||
use std::collections::BTreeSet;
|
||||
use std::fmt::Write;
|
||||
|
||||
pub fn clamp(x: f64, min: f64, max: f64) -> f64 {
|
||||
if x < min {
|
||||
min
|
||||
} else if x > max {
|
||||
max
|
||||
} else {
|
||||
x
|
||||
}
|
||||
}
|
||||
|
||||
pub fn plain_list_names(names: BTreeSet<String>) -> String {
|
||||
let mut s = String::new();
|
||||
let len = names.len();
|
||||
|
@ -1,6 +1,5 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use abstutil::clamp;
|
||||
use geom::{Distance, Polygon, Pt2D, Ring};
|
||||
use widgetry::{
|
||||
ControlState, Drawable, EventCtx, Filler, GeomBatch, GfxCtx, HorizontalAlignment, Line,
|
||||
@ -236,8 +235,8 @@ impl<A: AppLike + 'static, T: MinimapControls<A>> Minimap<A, T> {
|
||||
let bounds = app.map().get_bounds();
|
||||
// TODO For boundaries without rectangular shapes, it'd be even nicer to clamp to the
|
||||
// boundary.
|
||||
self.offset_x = off_x.max(0.0).min(bounds.max_x * self.zoom - rect.width());
|
||||
self.offset_y = off_y.max(0.0).min(bounds.max_y * self.zoom - rect.height());
|
||||
self.offset_x = off_x.clamp(0.0, bounds.max_x * self.zoom - rect.width());
|
||||
self.offset_y = off_y.clamp(0.0, bounds.max_y * self.zoom - rect.height());
|
||||
}
|
||||
|
||||
pub fn event(&mut self, ctx: &mut EventCtx, app: &mut A) -> Option<Transition<A>> {
|
||||
@ -355,8 +354,8 @@ impl<A: AppLike + 'static, T: MinimapControls<A>> Minimap<A, T> {
|
||||
self.dragging = false;
|
||||
}
|
||||
// Don't drag out of inner_rect
|
||||
pt.x = clamp(pt.x, inner_rect.x1, inner_rect.x2);
|
||||
pt.y = clamp(pt.y, inner_rect.y1, inner_rect.y2);
|
||||
pt.x = pt.x.clamp(inner_rect.x1, inner_rect.x2);
|
||||
pt.y = pt.y.clamp(inner_rect.y1, inner_rect.y2);
|
||||
} else if inner_rect.contains(pt) && ctx.input.left_mouse_button_pressed() {
|
||||
self.dragging = true;
|
||||
} else {
|
||||
|
@ -221,7 +221,7 @@ impl Panel {
|
||||
self.slider_mut("horiz scrollbar").set_percent(ctx, 0.0);
|
||||
} else {
|
||||
self.slider_mut("horiz scrollbar")
|
||||
.set_percent(ctx, abstutil::clamp(offset.0, 0.0, max) / max);
|
||||
.set_percent(ctx, offset.0.clamp(0.0, max) / max);
|
||||
}
|
||||
}
|
||||
if self.scrollable_y {
|
||||
@ -231,7 +231,7 @@ impl Panel {
|
||||
self.slider_mut("vert scrollbar").set_percent(ctx, 0.0);
|
||||
} else {
|
||||
self.slider_mut("vert scrollbar")
|
||||
.set_percent(ctx, abstutil::clamp(offset.1, 0.0, max) / max);
|
||||
.set_percent(ctx, offset.1.clamp(0.0, max) / max);
|
||||
}
|
||||
}
|
||||
changed
|
||||
|
Loading…
Reference in New Issue
Block a user