Bump version to 0.1.1 and add font color option

This commit is contained in:
2025-02-03 14:33:32 +03:00
parent 7c2ab9654e
commit 89f83c28a7
9 changed files with 3826 additions and 8 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
/target /target
/examples/target

2
Cargo.lock generated
View File

@@ -72,7 +72,7 @@ dependencies = [
[[package]] [[package]]
name = "egui_knob" name = "egui_knob"
version = "0.1.0" version = "0.1.1"
dependencies = [ dependencies = [
"egui", "egui",
] ]

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "egui_knob" name = "egui_knob"
version = "0.1.0" version = "0.1.1"
edition = "2021" edition = "2021"
description = "A simple knob widget for egui" description = "A simple knob widget for egui"
homepage = "https://github.com/obsqrbtz/egui_knob" homepage = "https://github.com/obsqrbtz/egui_knob"

View File

@@ -1,7 +1,9 @@
# Knob Widget # egui_knob
Simple knob widget for egui. Simple knob widget for egui.
![Knob Widget Screenshot](scrot.png)
## Features ## Features
- Adjustable size, font size, and stroke width. - 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_size(50.0)
.with_font_size(14.0) .with_font_size(14.0)
.with_stroke_width(3.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); .with_label("Volume", LabelPosition::Top);
egui::CentralPanel::default().show(ctx, |ui| { egui::CentralPanel::default().show(ctx, |ui| {

3781
examples/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,13 @@
[package] [package]
name = "egui_knob_demo" name = "egui_knob_demo"
version = "0.1.0" version = "0.1.1"
edition = "2021" edition = "2021"
[[bin]]
name = "egui_knob_demo"
path = "demo.rs"
[dependencies] [dependencies]
egui = "0.30" egui = "0.30"
egui_knob = "0.1.0" egui_knob = "0.1.1"
eframe = { version = "0.30.0", features = ["default_fonts"] } eframe = { version = "0.30.0", features = ["default_fonts"] }

View File

@@ -35,6 +35,28 @@ impl eframe::App for KnobExample {
.with_label("Gain", egui_knob::LabelPosition::Bottom) .with_label("Gain", egui_knob::LabelPosition::Bottom)
.with_size(50.0), .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),
);
}); });
}); });
} }

BIN
scrot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -21,6 +21,7 @@ pub struct Knob<'a> {
stroke_width: f32, stroke_width: f32,
knob_color: Color32, knob_color: Color32,
line_color: Color32, line_color: Color32,
text_color: Color32,
label: Option<String>, label: Option<String>,
label_position: LabelPosition, label_position: LabelPosition,
style: KnobStyle, style: KnobStyle,
@@ -37,6 +38,7 @@ impl<'a> Knob<'a> {
stroke_width: 2.0, stroke_width: 2.0,
knob_color: Color32::GRAY, knob_color: Color32::GRAY,
line_color: Color32::GRAY, line_color: Color32::GRAY,
text_color: Color32::WHITE,
label: None, label: None,
label_position: LabelPosition::Bottom, label_position: LabelPosition::Bottom,
style, style,
@@ -58,9 +60,15 @@ impl<'a> Knob<'a> {
self 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.knob_color = knob_color;
self.line_color = line_color; self.line_color = line_color;
self.text_color = text_color;
self self
} }
@@ -143,7 +151,7 @@ impl Widget for Knob<'_> {
Align2::LEFT_TOP, Align2::LEFT_TOP,
label_text, label_text,
font_id, font_id,
Color32::WHITE, self.text_color,
); );
} }