mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 23:15:24 +03:00
style row header
This commit is contained in:
parent
09fcca8533
commit
577192bb89
@ -1,8 +1,8 @@
|
||||
use geom::{Circle, Distance, FindClosest, Polygon};
|
||||
use sim::TripEndpoint;
|
||||
use widgetry::{
|
||||
Color, ControlState, DragDrop, Drawable, EventCtx, GeomBatch, GfxCtx, Image, Line, Outcome,
|
||||
StackAxis, Text, Widget,
|
||||
Color, ControlState, CornerRounding, DragDrop, Drawable, EventCtx, GeomBatch, GfxCtx, Image,
|
||||
Line, Outcome, StackAxis, Text, Widget,
|
||||
};
|
||||
|
||||
use crate::app::App;
|
||||
@ -69,11 +69,25 @@ impl InputWaypoints {
|
||||
let mut delete_buttons = Vec::new();
|
||||
|
||||
for (idx, waypt) in self.waypoints.iter().enumerate() {
|
||||
let icon = {
|
||||
let text = Text::from(Line(waypt.order.to_string()).fg(Color::WHITE).bold_body());
|
||||
let batch = text.render(ctx);
|
||||
let bounds = batch.get_bounds();
|
||||
let image = Image::from_batch(batch, bounds)
|
||||
.untinted()
|
||||
.bg_color(Color::RED)
|
||||
.padding(10)
|
||||
.dims(16)
|
||||
.corner_rounding(CornerRounding::FullyRounded);
|
||||
image
|
||||
};
|
||||
|
||||
let waypoint = ctx
|
||||
.style()
|
||||
.btn_plain
|
||||
.text(format!("{}) {}", waypt.order, waypt.label))
|
||||
.padding(16);
|
||||
.text(&waypt.label)
|
||||
.image(icon)
|
||||
.padding(10);
|
||||
|
||||
let build_batch = |control_state: ControlState| {
|
||||
let batch = waypoint.batch(ctx, control_state);
|
||||
|
@ -187,6 +187,12 @@ impl From<f64> for ScreenDims {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i64> for ScreenDims {
|
||||
fn from(square: i64) -> ScreenDims {
|
||||
ScreenDims::square(square as f64)
|
||||
}
|
||||
}
|
||||
|
||||
/// (Width, Height) -> ScreenDims
|
||||
impl From<(f64, f64)> for ScreenDims {
|
||||
fn from(width_and_height: (f64, f64)) -> ScreenDims {
|
||||
|
@ -298,6 +298,13 @@ impl<'b, 'a: 'b, 'c> ButtonBuilder<'a, 'c> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn image(mut self, image: Image<'a, 'c>) -> Self {
|
||||
// Currently we don't support setting image for other states like "hover", we easily
|
||||
// could, but the API gets more verbose for a thing we don't currently need.
|
||||
self.default_style.image = Some(image);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the image for the button. If not set, the button will have no image.
|
||||
///
|
||||
/// This will replace any image previously set.
|
||||
|
Loading…
Reference in New Issue
Block a user