mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 10:44:56 +03:00
lock down many widgets from being used outside of Composites
This commit is contained in:
parent
4327322ea4
commit
14596d00ea
@ -64,7 +64,7 @@ impl Button {
|
||||
self.hitbox.translate(self.top_left.x, self.top_left.y)
|
||||
}
|
||||
|
||||
pub fn event(&mut self, ctx: &mut EventCtx) {
|
||||
pub(crate) fn event(&mut self, ctx: &mut EventCtx) {
|
||||
if self.clicked {
|
||||
panic!("Caller didn't consume button click");
|
||||
}
|
||||
@ -85,18 +85,12 @@ impl Button {
|
||||
}
|
||||
|
||||
if self.hovering {
|
||||
// Once we asserted this was None, but because of just_replaced, sometimes not true.
|
||||
// TODO Should we assert this is None?
|
||||
ctx.canvas.button_tooltip = Some(self.tooltip.clone());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn just_replaced(&mut self, ctx: &EventCtx) {
|
||||
self.hovering = self
|
||||
.get_hitbox()
|
||||
.contains_pt(ctx.canvas.get_cursor_in_screen_space().to_pt());
|
||||
}
|
||||
|
||||
pub fn clicked(&mut self) -> bool {
|
||||
pub(crate) fn clicked(&mut self) -> bool {
|
||||
if self.clicked {
|
||||
self.clicked = false;
|
||||
true
|
||||
@ -105,7 +99,7 @@ impl Button {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw(&self, g: &mut GfxCtx) {
|
||||
pub(crate) fn draw(&self, g: &mut GfxCtx) {
|
||||
if self.hovering {
|
||||
self.draw_hovered.redraw(self.top_left, g);
|
||||
} else {
|
||||
@ -299,9 +293,4 @@ impl Button {
|
||||
|
||||
Button::new(normal, hovered, hotkey, tooltip, geom)
|
||||
}
|
||||
|
||||
pub fn at(mut self, pt: ScreenPt) -> Button {
|
||||
self.set_pos(pt);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ impl Histogram {
|
||||
])
|
||||
}
|
||||
|
||||
pub fn draw(&self, g: &mut GfxCtx) {
|
||||
pub(crate) fn draw(&self, g: &mut GfxCtx) {
|
||||
self.draw.redraw(self.top_left, g);
|
||||
|
||||
let cursor = g.canvas.get_cursor_in_screen_space();
|
||||
|
@ -57,7 +57,7 @@ impl JustDraw {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw(&self, g: &mut GfxCtx) {
|
||||
pub(crate) fn draw(&self, g: &mut GfxCtx) {
|
||||
self.draw.redraw(self.top_left, g);
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ impl<T: 'static + Ord + PartialEq + Copy + core::fmt::Debug + Yvalue<T>> Plot<T>
|
||||
(plot, legend, x_axis, y_axis)
|
||||
}
|
||||
|
||||
pub fn draw(&self, g: &mut GfxCtx) {
|
||||
pub(crate) fn draw(&self, g: &mut GfxCtx) {
|
||||
self.draw.redraw(self.top_left, g);
|
||||
|
||||
let cursor = g.canvas.get_cursor_in_screen_space();
|
||||
|
@ -33,7 +33,7 @@ impl TextBox {
|
||||
tb
|
||||
}
|
||||
|
||||
pub(crate) fn get_text(&self) -> Text {
|
||||
pub fn get_text(&self) -> Text {
|
||||
let mut txt = Text::prompt(&self.prompt);
|
||||
txt.add(Line(&self.line[0..self.cursor_x]));
|
||||
if self.cursor_x < self.line.len() {
|
||||
@ -49,11 +49,11 @@ impl TextBox {
|
||||
txt
|
||||
}
|
||||
|
||||
pub(crate) fn get_line(&self) -> &str {
|
||||
pub fn get_line(&self) -> &str {
|
||||
&self.line
|
||||
}
|
||||
|
||||
pub(crate) fn set_text(&mut self, line: String) {
|
||||
pub fn set_text(&mut self, line: String) {
|
||||
self.line = line;
|
||||
self.cursor_x = self.line.len();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user