Files
fleen/src/ui_ext.rs
T

17 lines
658 B
Rust
Raw Normal View History

2025-09-04 23:29:46 -05:00
use eframe::egui::{Align, InnerResponse, Layout, Response, Ui, Widget};
pub trait UiExtensions {
fn fill_button(&mut self, widget: impl Widget) -> Response;
fn column<R>(&mut self, width: f32, f: impl FnOnce(&mut Self)-> R) -> InnerResponse<R>;
}
impl UiExtensions for Ui {
fn fill_button(&mut self, widget: impl Widget) -> Response {
self.add_sized((self.available_width(), 20.0), widget)
}
fn column<R>(&mut self, width: f32, f: impl FnOnce(&mut Self) -> R) -> InnerResponse<R> {
let third = (width, self.available_height()).into();
self.allocate_ui_with_layout(third, Layout::top_down(Align::Max), f)
}
}