diff --git a/ezgui/src/input.rs b/ezgui/src/input.rs index e4e7749c97..ebf1ed1ede 100644 --- a/ezgui/src/input.rs +++ b/ezgui/src/input.rs @@ -242,13 +242,26 @@ impl UserInput { // Returns the bottom left of the modal menu. // TODO It'd be nice to scope the return value to the next draw()s only. - pub fn set_mode_with_extra( + pub fn set_mode(&mut self, mode: &str, canvas: &Canvas) -> ScreenPt { + self.set_mode_with_prompt(mode, mode.to_string(), canvas) + } + + pub fn set_mode_with_prompt( + &mut self, + mode: &str, + prompt: String, + canvas: &Canvas, + ) -> ScreenPt { + let mut txt = Text::new(); + txt.add_styled_line(prompt, None, Some(text::PROMPT_COLOR), None); + self.set_mode_with_new_prompt(mode, txt, canvas) + } + + pub fn set_mode_with_new_prompt( &mut self, mode: &str, prompt: Text, canvas: &Canvas, - extra_width: f64, - _extra_height: f64, ) -> ScreenPt { self.set_mode_called.insert(mode.to_string()); self.current_mode = Some(mode.to_string()); @@ -266,7 +279,7 @@ impl UserInput { .collect(), false, true, - Position::TopRightOfScreen(extra_width), + Position::TopRightOfScreen, canvas, ); menu.mark_all_inactive(); @@ -279,30 +292,6 @@ impl UserInput { } } - pub fn set_mode_with_prompt( - &mut self, - mode: &str, - prompt: String, - canvas: &Canvas, - ) -> ScreenPt { - let mut txt = Text::new(); - txt.add_styled_line(prompt, None, Some(text::PROMPT_COLOR), None); - self.set_mode_with_extra(mode, txt, canvas, 0.0, 0.0) - } - - pub fn set_mode_with_new_prompt( - &mut self, - mode: &str, - prompt: Text, - canvas: &Canvas, - ) -> ScreenPt { - self.set_mode_with_extra(mode, prompt, canvas, 0.0, 0.0) - } - - pub fn set_mode(&mut self, mode: &str, canvas: &Canvas) -> ScreenPt { - self.set_mode_with_prompt(mode, mode.to_string(), canvas) - } - pub fn modal_action(&mut self, action: &str) -> bool { if let Some(ref mode) = self.current_mode { if self.chosen_action == Some(action.to_string()) { diff --git a/ezgui/src/widgets/menu.rs b/ezgui/src/widgets/menu.rs index 2385c45acb..b02fc494b9 100644 --- a/ezgui/src/widgets/menu.rs +++ b/ezgui/src/widgets/menu.rs @@ -24,8 +24,7 @@ pub struct Menu { pub enum Position { ScreenCenter, TopLeftAt(ScreenPt), - // Extra width needed -- if more than the natural menu length, this'll pad the menu. - TopRightOfScreen(f64), + TopRightOfScreen, } impl Menu { @@ -63,14 +62,7 @@ impl Menu { pt.y -= total_height / 2.0; pt } - Position::TopRightOfScreen(extra_width) => { - let w = if extra_width > total_width { - extra_width - } else { - total_width - }; - ScreenPt::new(canvas.window_width - w, 0.0) - } + Position::TopRightOfScreen => ScreenPt::new(canvas.window_width - total_width, 0.0), }; Menu {