ui: external connection check and ui repaint fix, tab button callback argument

This commit is contained in:
ardocrat
2024-09-20 13:42:45 +03:00
parent 2b83944f34
commit 2adb29f4ee
11 changed files with 121 additions and 101 deletions
+17 -2
View File
@@ -217,7 +217,10 @@ impl View {
pub const TAB_ITEMS_PADDING: f32 = 5.0;
/// Tab button with white background fill color, contains only icon.
pub fn tab_button(ui: &mut egui::Ui, icon: &str, active: bool, action: impl FnOnce()) {
pub fn tab_button(ui: &mut egui::Ui,
icon: &str,
active: bool,
action: impl FnOnce(&mut egui::Ui)) {
ui.scope(|ui| {
let text_color = match active {
true => Colors::title(false),
@@ -245,7 +248,7 @@ impl View {
let br = button.ui(ui).on_hover_cursor(CursorIcon::PointingHand);
br.surrender_focus();
if Self::touched(ui, br) {
(action)();
(action)(ui);
}
});
}
@@ -280,6 +283,18 @@ impl View {
}
}
/// Draw [`Button`] with specified background fill color and text color.
pub fn colored_text_button_ui(ui: &mut egui::Ui,
text: String,
text_color: Color32,
fill: Color32,
action: impl FnOnce(&mut egui::Ui)) {
let br = Self::button_resp(ui, text, text_color, fill);
if Self::touched(ui, br) {
(action)(ui);
}
}
/// Draw gold action [`Button`].
pub fn action_button(ui: &mut egui::Ui,
text: String, action: impl FnOnce()) {