mirror of
https://github.com/obsqrbtz/egui_knob.git
synced 2026-04-08 20:19:17 +03:00
fix: knob rect
This commit is contained in:
61
examples/example_knob.rs
Normal file
61
examples/example_knob.rs
Normal file
@@ -0,0 +1,61 @@
|
||||
use eframe::egui;
|
||||
use egui_knob::Knob;
|
||||
|
||||
fn main() -> eframe::Result<()> {
|
||||
eframe::run_native(
|
||||
"Knob Example",
|
||||
eframe::NativeOptions::default(),
|
||||
Box::new(|_cc| Ok(Box::new(KnobExample::default()))),
|
||||
)
|
||||
}
|
||||
|
||||
struct KnobExample {
|
||||
value: f32,
|
||||
}
|
||||
|
||||
impl Default for KnobExample {
|
||||
fn default() -> Self {
|
||||
Self { value: 0.0 }
|
||||
}
|
||||
}
|
||||
|
||||
impl eframe::App for KnobExample {
|
||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.add(
|
||||
Knob::new(&mut self.value, 0.0, 100.0, egui_knob::KnobStyle::Dot)
|
||||
.with_label("Gain", egui_knob::LabelPosition::Bottom)
|
||||
.with_size(50.0),
|
||||
);
|
||||
ui.add(
|
||||
Knob::new(&mut self.value, 0.0, 100.0, egui_knob::KnobStyle::Wiper)
|
||||
.with_label("Gain", egui_knob::LabelPosition::Bottom)
|
||||
.with_size(50.0),
|
||||
);
|
||||
ui.add_space(15.0);
|
||||
ui.add(
|
||||
Knob::new(&mut self.value, 0.0, 100.0, egui_knob::KnobStyle::Dot)
|
||||
.with_label("Gain", egui_knob::LabelPosition::Bottom)
|
||||
.with_colors(
|
||||
egui::Color32::DARK_GRAY,
|
||||
egui::Color32::WHITE,
|
||||
egui::Color32::WHITE,
|
||||
)
|
||||
.with_size(50.0),
|
||||
);
|
||||
ui.add_space(15.0);
|
||||
ui.add(
|
||||
Knob::new(&mut self.value, 0.0, 100.0, egui_knob::KnobStyle::Wiper)
|
||||
.with_label("Gain", egui_knob::LabelPosition::Bottom)
|
||||
.with_colors(
|
||||
egui::Color32::DARK_GRAY,
|
||||
egui::Color32::WHITE,
|
||||
egui::Color32::LIGHT_BLUE,
|
||||
)
|
||||
.with_size(50.0),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user