mirror of
https://github.com/obsqrbtz/egui_knob.git
synced 2026-04-08 20:19:17 +03:00
Bump version to 0.1.1 and add font color option
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
/target
|
||||
/examples/target
|
||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -72,7 +72,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "egui_knob"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"egui",
|
||||
]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "egui_knob"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
description = "A simple knob widget for egui"
|
||||
homepage = "https://github.com/obsqrbtz/egui_knob"
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# Knob Widget
|
||||
# egui_knob
|
||||
|
||||
Simple knob widget for egui.
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
|
||||
- Adjustable size, font size, and stroke width.
|
||||
@@ -31,7 +33,7 @@ let knob = Knob::new(&mut value, 0.0, 1.0, KnobStyle::Wiper)
|
||||
.with_size(50.0)
|
||||
.with_font_size(14.0)
|
||||
.with_stroke_width(3.0)
|
||||
.with_colors(Color32::GRAY, Color32::WHITE)
|
||||
.with_colors(Color32::GRAY, Color32::WHITE, Color32::WHITE)
|
||||
.with_label("Volume", LabelPosition::Top);
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
|
||||
3781
examples/Cargo.lock
generated
Normal file
3781
examples/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,13 @@
|
||||
[package]
|
||||
name = "egui_knob_demo"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "egui_knob_demo"
|
||||
path = "demo.rs"
|
||||
|
||||
[dependencies]
|
||||
egui = "0.30"
|
||||
egui_knob = "0.1.0"
|
||||
egui_knob = "0.1.1"
|
||||
eframe = { version = "0.30.0", features = ["default_fonts"] }
|
||||
@@ -35,6 +35,28 @@ impl eframe::App for KnobExample {
|
||||
.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),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
12
src/lib.rs
12
src/lib.rs
@@ -21,6 +21,7 @@ pub struct Knob<'a> {
|
||||
stroke_width: f32,
|
||||
knob_color: Color32,
|
||||
line_color: Color32,
|
||||
text_color: Color32,
|
||||
label: Option<String>,
|
||||
label_position: LabelPosition,
|
||||
style: KnobStyle,
|
||||
@@ -37,6 +38,7 @@ impl<'a> Knob<'a> {
|
||||
stroke_width: 2.0,
|
||||
knob_color: Color32::GRAY,
|
||||
line_color: Color32::GRAY,
|
||||
text_color: Color32::WHITE,
|
||||
label: None,
|
||||
label_position: LabelPosition::Bottom,
|
||||
style,
|
||||
@@ -58,9 +60,15 @@ impl<'a> Knob<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_colors(mut self, knob_color: Color32, line_color: Color32) -> Self {
|
||||
pub fn with_colors(
|
||||
mut self,
|
||||
knob_color: Color32,
|
||||
line_color: Color32,
|
||||
text_color: Color32,
|
||||
) -> Self {
|
||||
self.knob_color = knob_color;
|
||||
self.line_color = line_color;
|
||||
self.text_color = text_color;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -143,7 +151,7 @@ impl Widget for Knob<'_> {
|
||||
Align2::LEFT_TOP,
|
||||
label_text,
|
||||
font_id,
|
||||
Color32::WHITE,
|
||||
self.text_color,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user