mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-25 15:33:44 +03:00
Add a free-form lane width spinner, alongside the dropdown with presets.
Achieves immediate goal of more control, but: 1) it reveals how painfully slow lane editing is! 2) the units are always meters in the spinner, which don't look great
This commit is contained in:
parent
98a081303f
commit
a297937ffa
@ -8,8 +8,8 @@ use map_model::{
|
||||
};
|
||||
use widgetry::{
|
||||
lctrl, Choice, Color, ControlState, Drawable, EventCtx, GeomBatch, GeomBatchStack, GfxCtx,
|
||||
HorizontalAlignment, Image, Key, Line, Outcome, Panel, State, Text, TextExt, VerticalAlignment,
|
||||
Widget, DEFAULT_CORNER_RADIUS,
|
||||
HorizontalAlignment, Image, Key, Line, Outcome, Panel, Spinner, State, Text, TextExt,
|
||||
VerticalAlignment, Widget, DEFAULT_CORNER_RADIUS,
|
||||
};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
@ -313,8 +313,14 @@ impl State<App> for RoadEditor {
|
||||
new.speed_limit = speed_limit;
|
||||
});
|
||||
}
|
||||
"width" => {
|
||||
let width = self.main_panel.dropdown_value("width");
|
||||
"width preset" => {
|
||||
let width = self.main_panel.dropdown_value("width preset");
|
||||
return self.modify_current_lane(ctx, app, Some(0), |new, idx| {
|
||||
new.lanes_ltr[idx].width = width;
|
||||
});
|
||||
}
|
||||
"width custom" => {
|
||||
let width = self.main_panel.spinner("width custom");
|
||||
return self.modify_current_lane(ctx, app, Some(0), |new, idx| {
|
||||
new.lanes_ltr[idx].width = width;
|
||||
});
|
||||
@ -480,7 +486,17 @@ fn make_main_panel(
|
||||
.hotkey(Key::F)
|
||||
.build_def(ctx),
|
||||
Line("Width").secondary().into_widget(ctx).centered_vert(),
|
||||
Widget::dropdown(ctx, "width", lane.width, width_choices(app, l)),
|
||||
Widget::col(vec![
|
||||
Widget::dropdown(ctx, "width preset", lane.width, width_choices(app, l)),
|
||||
Spinner::widget(
|
||||
ctx,
|
||||
"width custom",
|
||||
(Distance::feet(1.0), Distance::feet(20.0)),
|
||||
lane.width,
|
||||
Distance::feet(0.5),
|
||||
)
|
||||
.centered_horiz(),
|
||||
]),
|
||||
ctx.style()
|
||||
.btn_prev()
|
||||
.disabled(idx == 0)
|
||||
|
Loading…
Reference in New Issue
Block a user