Move `re_ui` UI functions to a trait to be implemented by `egui::Ui`
Most UI function in re_ui are #[allow(clippy::unused_self)], but they take a egui::Ui argument (obviously). This could be more cleanly implemented as a trait that would be implemented for egui::Ui.
Something like:
pub trait ReUi {
fn ui(&mut self) -> &mut egui::Ui;
fn small_icon_button(&self, icon: &Icon) -> egui::Response {
ui.add(
egui::ImageButton::new(icon.as_image().fit_to_exact_size(Self::small_icon_size()))
.tint(self.ui().visuals().widgets.inactive.fg_stroke.color),
)
}
// etc.
}
impl ReUi for egui::Ui {
fn ui(&mut self) -> &mut egui::Ui { self }
}
Before (typical):
ctx.re_ui.small_icon_button(ui, icon);
After:
use re_ui::ReUi as _;
ui.small_icon_button(icon);
be mindful that some of those functions are only NOT using self because they are using hard-coded values instead of the design tokens json
I'm getting tired of passing around ReUi everywhere, so perhaps it's time to do this.
One thing though: struct ReUi currently store the DesignTokens it uses in some of its member functions.
We would need to store that somewhere else, e.g. in egui's data store: ui.data(|data| data.get_temp::<Arc<DesignTokens>>())