Skip to content

Commit

Permalink
Render shortcut text behind flight mode buttons
Browse files Browse the repository at this point in the history
With the new egui version, the text selection would prevent interaction
with the button when hovering over the text.
  • Loading branch information
KoffeinFlummi committed Feb 21, 2024
1 parent 6a03d43 commit 1bf5837
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/gui/top_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,17 @@ impl TopBarUiExt for egui::Ui {
self.add_space(5.0);
let pos = self.next_widget_position();
let size = Vec2::new(self.available_width(), 50.0);
if self.add_sized(size, button).clicked() {
data_source.send_command(Command::SetFlightMode(fm)).unwrap();
}

let shortcut = if is_current {
Label::new(RichText::new(format!("Shift+{}", shortcut)).size(9.0).color(fg))
} else {
Label::new(RichText::new(format!("Shift+{}", shortcut)).size(9.0).weak())
};

self.put(Rect::from_two_pos(pos + size * Vec2::new(0.0, 0.6), pos + size), shortcut);
if self.put(Rect::from_two_pos(pos, pos + size), button).clicked() {
data_source.send_command(Command::SetFlightMode(fm)).unwrap();
}
}

fn flight_mode_buttons(&mut self, current: Option<FlightMode>, data_source: &mut dyn DataSource) {
Expand Down

0 comments on commit 1bf5837

Please sign in to comment.