1
0
Fork 0

Add padding to the generic UI

This commit is contained in:
Robbert van der Helm 2022-03-05 19:39:28 +01:00
parent 2c56646cc9
commit cab6be5167

View file

@ -3,7 +3,7 @@
use std::pin::Pin; use std::pin::Pin;
use egui::Ui; use egui::{TextStyle, Ui, Vec2};
use nih_plug::context::ParamSetter; use nih_plug::context::ParamSetter;
use nih_plug::param::internals::ParamPtr; use nih_plug::param::internals::ParamPtr;
use nih_plug::prelude::{Param, Params}; use nih_plug::prelude::{Param, Params};
@ -39,12 +39,20 @@ pub fn create(
let param_map = params.param_map(); let param_map = params.param_map();
let param_ids = params.param_ids(); let param_ids = params.param_ids();
let padding = Vec2::splat(ui.text_style_height(&TextStyle::Body) * 0.2);
egui::containers::ScrollArea::vertical() egui::containers::ScrollArea::vertical()
// Take up all remaining space, use a wrapper container to adjust how much space that is // Take up all remaining space, use a wrapper container to adjust how much space that is
.auto_shrink([false, false]) .auto_shrink([false, false])
.show(ui, |ui| { .show(ui, |ui| {
for id in param_ids { for (widget_idx, id) in param_ids.into_iter().enumerate() {
let param = param_map[id]; let param = param_map[id];
// This list looks weird without a little padding
if widget_idx > 0 {
ui.allocate_space(padding);
}
ui.label(unsafe { param.name() });
unsafe { widget.add_widget_raw(ui, &param, setter) }; unsafe { widget.add_widget_raw(ui, &param, setter) };
} }
}); });