mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-24 23:15:24 +03:00
use btn_close instead of "X"s
This commit is contained in:
parent
2387975fac
commit
a0ea2ba14e
@ -96,8 +96,8 @@ impl InputWaypoints {
|
||||
|
||||
delete_buttons.push(
|
||||
ctx.style()
|
||||
.btn_plain_destructive
|
||||
.text("X")
|
||||
.btn_close()
|
||||
.override_style(&ctx.style().btn_plain_destructive)
|
||||
.build_widget(ctx, &format!("delete waypoint {}", idx)),
|
||||
);
|
||||
}
|
||||
|
@ -17,7 +17,11 @@ pub struct ButtonStyle {
|
||||
|
||||
impl<'a, 'c> ButtonStyle {
|
||||
pub fn btn(&self) -> ButtonBuilder<'a, 'c> {
|
||||
let base = ButtonBuilder::new()
|
||||
self.apply(ButtonBuilder::new())
|
||||
}
|
||||
|
||||
pub fn apply(&self, builder: ButtonBuilder<'a, 'c>) -> ButtonBuilder<'a, 'c> {
|
||||
let builder = builder
|
||||
.label_color(self.fg, ControlState::Default)
|
||||
.label_color(self.fg_disabled, ControlState::Disabled)
|
||||
.image_color(self.fg, ControlState::Default)
|
||||
@ -27,9 +31,9 @@ impl<'a, 'c> ButtonStyle {
|
||||
.bg_color(self.bg_disabled, ControlState::Disabled);
|
||||
|
||||
if self.outline.0 > 0.0 {
|
||||
base.outline(self.outline, ControlState::Default)
|
||||
builder.outline(self.outline, ControlState::Default)
|
||||
} else {
|
||||
base
|
||||
builder
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,17 +94,19 @@ impl<'a, 'c> Style {
|
||||
.icon_bytes(include_labeled_bytes!("../../icons/prev.svg"))
|
||||
}
|
||||
|
||||
/// An "X" button to close the current state. Bound to the escape key.
|
||||
/// An "X" button
|
||||
pub fn btn_close(&self) -> ButtonBuilder<'a, 'c> {
|
||||
self.btn_plain
|
||||
.icon_bytes(include_labeled_bytes!("../../icons/close.svg"))
|
||||
.hotkey(Key::Escape)
|
||||
}
|
||||
|
||||
/// An "X" button to close the current state. Bound to the escape key and aligned to the right,
|
||||
/// usually after a title.
|
||||
pub fn btn_close_widget(&self, ctx: &EventCtx) -> Widget {
|
||||
self.btn_close().build_widget(ctx, "close").align_right()
|
||||
self.btn_close()
|
||||
.hotkey(Key::Escape)
|
||||
.build_widget(ctx, "close")
|
||||
.align_right()
|
||||
}
|
||||
|
||||
pub fn btn_popup_icon_text(&self, icon_path: &'a str, text: &'a str) -> ButtonBuilder<'a, 'c> {
|
||||
|
@ -1,9 +1,10 @@
|
||||
use geom::Polygon;
|
||||
|
||||
use crate::{
|
||||
style::DEFAULT_OUTLINE_THICKNESS, text::Font, Color, ContentMode, ControlState, CornerRounding,
|
||||
Drawable, EdgeInsets, EventCtx, GeomBatch, GfxCtx, Image, Line, MultiKey, Outcome,
|
||||
OutlineStyle, RewriteColor, ScreenDims, ScreenPt, Text, Widget, WidgetImpl, WidgetOutput,
|
||||
style::DEFAULT_OUTLINE_THICKNESS, text::Font, ButtonStyle, Color, ContentMode, ControlState,
|
||||
CornerRounding, Drawable, EdgeInsets, EventCtx, GeomBatch, GfxCtx, Image, Line, MultiKey,
|
||||
Outcome, OutlineStyle, RewriteColor, ScreenDims, ScreenPt, Text, Widget, WidgetImpl,
|
||||
WidgetOutput,
|
||||
};
|
||||
|
||||
use crate::geom::geom_batch_stack::{Axis, GeomBatchStack};
|
||||
@ -367,6 +368,10 @@ impl<'b, 'a: 'b, 'c> ButtonBuilder<'a, 'c> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn override_style(self, style: &ButtonStyle) -> Self {
|
||||
style.apply(self)
|
||||
}
|
||||
|
||||
/// If a custom `image_dims` was set, control how the image should be scaled to its new bounds
|
||||
///
|
||||
/// If `image_dims` were not specified, the image will not be scaled, so content_mode has no
|
||||
|
Loading…
Reference in New Issue
Block a user