mirror of
https://github.com/obsqrbtz/egui_knob.git
synced 2026-04-09 20:47:40 +03:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c31936f3b0 | |||
| d20180729a | |||
|
|
353dcd8cc4 |
@@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [0.3.11] - 2026-03-30
|
||||||
|
|
||||||
|
- bumped egui version ([#PR10](https://github.com/obsqrbtz/egui_knob/pull/10) by [elwerene](https://github.com/elwerene)
|
||||||
|
|
||||||
|
### 🛠 Maintenance
|
||||||
|
|
||||||
## [0.3.10] - 2026-01-23
|
## [0.3.10] - 2026-01-23
|
||||||
|
|
||||||
### 🚀 Features
|
### 🚀 Features
|
||||||
|
|||||||
1692
Cargo.lock
generated
1692
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "egui_knob"
|
name = "egui_knob"
|
||||||
version = "0.3.10"
|
version = "0.3.11"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Daniel Dada"]
|
authors = ["Daniel Dada"]
|
||||||
description = "A simple knob widget for egui"
|
description = "A simple knob widget for egui"
|
||||||
@@ -21,7 +21,7 @@ name = "example_knob"
|
|||||||
path = "examples/example_knob.rs"
|
path = "examples/example_knob.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
egui = "0.33"
|
egui = "0.34"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
eframe = { version = "0.33", features = ["default_fonts"] }
|
eframe = { version = "0.34", features = ["default_fonts"] }
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ To use the Knob widget in your project, add the following to your `Cargo.toml`:
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
egui = "0.33"
|
egui = "0.33"
|
||||||
eframe = "0.33"
|
eframe = "0.33"
|
||||||
egui_knob = "0.3.10"
|
egui_knob = "0.3.11"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ impl Default for KnobDemo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl eframe::App for KnobDemo {
|
impl eframe::App for KnobDemo {
|
||||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
|
||||||
ui.heading("Knob demo");
|
ui.heading("Knob demo");
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
|
||||||
@@ -54,7 +53,6 @@ impl eframe::App for KnobDemo {
|
|||||||
ui.checkbox(&mut self.show_filled, "Filled segment");
|
ui.checkbox(&mut self.show_filled, "Filled segment");
|
||||||
ui.checkbox(&mut self.use_step, "Step (0.02)");
|
ui.checkbox(&mut self.use_step, "Step (0.02)");
|
||||||
ui.checkbox(&mut self.logarithmic_scaling, "Logarithmic");
|
ui.checkbox(&mut self.logarithmic_scaling, "Logarithmic");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
@@ -126,6 +124,5 @@ impl eframe::App for KnobDemo {
|
|||||||
|
|
||||||
ui.add_space(10.0);
|
ui.add_space(10.0);
|
||||||
ui.separator();
|
ui.separator();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,8 +209,7 @@ impl Widget for Knob<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
response.mark_changed();
|
response.mark_changed();
|
||||||
} else if response.hovered() & self.config.allow_scroll {
|
} else if response.hovered() & self.config.allow_scroll && let Some(scoll) = ui.input(|input| {
|
||||||
if let Some(scoll) = ui.input(|input| {
|
|
||||||
input.events.iter().find_map(|e| match e {
|
input.events.iter().find_map(|e| match e {
|
||||||
egui::Event::MouseWheel { delta, .. } => Some(*delta),
|
egui::Event::MouseWheel { delta, .. } => Some(*delta),
|
||||||
_ => None,
|
_ => None,
|
||||||
@@ -220,7 +219,6 @@ impl Widget for Knob<'_> {
|
|||||||
+ scoll.y * self.config.step.unwrap_or(self.config.drag_sensitivity))
|
+ scoll.y * self.config.step.unwrap_or(self.config.drag_sensitivity))
|
||||||
.clamp(0.0, 1.0);
|
.clamp(0.0, 1.0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
*self.value = if self.config.logarithmic_scaling {
|
*self.value = if self.config.logarithmic_scaling {
|
||||||
remap(10f32.powf(raw), 1.0..=10.0, self.min..=self.max)
|
remap(10f32.powf(raw), 1.0..=10.0, self.min..=self.max)
|
||||||
@@ -228,11 +226,10 @@ impl Widget for Knob<'_> {
|
|||||||
remap(raw, 0.0..=1.0, self.min..=self.max)
|
remap(raw, 0.0..=1.0, self.min..=self.max)
|
||||||
};
|
};
|
||||||
|
|
||||||
if response.double_clicked() {
|
if response.double_clicked()
|
||||||
if let Some(reset_value) = self.config.reset_value {
|
&& let Some(reset_value) = self.config.reset_value {
|
||||||
*self.value = reset_value
|
*self.value = reset_value
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let knob_rect = renderer.calculate_knob_rect(rect);
|
let knob_rect = renderer.calculate_knob_rect(rect);
|
||||||
let center = knob_rect.center();
|
let center = knob_rect.center();
|
||||||
|
|||||||
Reference in New Issue
Block a user