Skip to content

Instantly share code, notes, and snippets.

@4JX
Last active February 7, 2022 18:30
Show Gist options
  • Save 4JX/3e3c08aeeb51445a9d8c295161a3402c to your computer and use it in GitHub Desktop.
Save 4JX/3e3c08aeeb51445a9d8c295161a3402c to your computer and use it in GitHub Desktop.
use eframe::{
egui::{self, Color32, Vec2},
epi,
};
#[derive(Default)]
struct UiApp {}
impl epi::App for UiApp {
fn name(&self) -> &str {
"An App"
}
fn setup(
&mut self,
_ctx: &egui::Context,
_frame: &epi::Frame,
_storage: Option<&dyn epi::Storage>,
) {
}
fn update(&mut self, ctx: &egui::Context, _frame: &epi::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
// Set the x value to something excessively high
ui.style_mut().spacing.item_spacing = Vec2::new(80., 3.);
ui.vertical_centered_justified(|ui| {
egui::ScrollArea::vertical().show(ui, |ui| {
for _ in 0..10 {
// Frame is for visualization purposes, not needed
egui::Frame {
fill: Color32::DARK_GRAY,
..Default::default()
}
.show(ui, |ui| {
ui.set_height(20.);
ui.centered_and_justified(|ui| {
ui.label("Fill");
});
});
}
});
});
});
}
}
fn main() {
let app = UiApp::default();
let native_options = eframe::NativeOptions::default();
eframe::run_native(Box::new(app), native_options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment