Skip to content

Commit

Permalink
Update ui.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxxcode committed Feb 1, 2024
1 parent c6d0db4 commit fb57fbe
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ui.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// Adds a dynamically sized button to the UI that can be enabled or disabled.
/// Returns true if the button is clicked. Otherwise None is returned.
pub fn button_enabled_disabled(ui: &mut egui::Ui, text: &str, enabled: bool) -> bool {
if !enabled {
let button = egui::Button::new(text)
Expand All @@ -12,6 +14,8 @@ pub fn button_enabled_disabled(ui: &mut egui::Ui, text: &str, enabled: bool) ->
ui.add(egui::Button::new(text)).clicked()
}

/// Adds a fixed sized button to the UI that can be enabled or disabled.
/// Returns true if the button is clicked. Otherwise None is returned.
pub fn button_sized_enabled_disabled(
ui: &mut egui::Ui,
size: egui::Vec2,
Expand All @@ -31,6 +35,7 @@ pub fn button_sized_enabled_disabled(
ui.add_sized(size, egui::Button::new(text)).clicked()
}

/// Returns the fill color of disabled buttons
#[inline]
fn get_disabled_fill_color(ui: &egui::Ui) -> egui::Color32 {
let c = ui.style().visuals.widgets.noninteractive.bg_fill;
Expand Down

0 comments on commit fb57fbe

Please sign in to comment.