Skip to content

Commit

Permalink
Update to egui 0.29
Browse files Browse the repository at this point in the history
  • Loading branch information
dimtpap committed Oct 4, 2024
1 parent fd75fcd commit 1565d43
Show file tree
Hide file tree
Showing 12 changed files with 791 additions and 694 deletions.
1,085 changes: 575 additions & 510 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "coppwr"
version = "1.6.0"
authors = ["Dimitris Papaioannou <[email protected]>"]
edition = "2021"
rust-version = "1.72"
rust-version = "1.76"
license = "GPL-3.0-only"
description = "Low level control GUI for the PipeWire multimedia server"
repository = "https://github.com/dimtpap/coppwr"
Expand All @@ -16,11 +16,11 @@ categories = ["gui", "multimedia"]

[dependencies]
pipewire = {version = "*", git = "https://gitlab.freedesktop.org/dimtpap/pipewire-rs.git", rev = "605d15996f3258b3e1cc34e445dfbdf16a366c7e"}
egui_node_graph = {version = "*", git = "https://github.com/dimtpap/egui_node_graph.git", rev = "3e99a2af2025e72365a4ec5048011041a85002e5"}
eframe = "0.27.2"
egui = {version = "0.27.2", features = ["rayon"]}
egui_plot = "0.27.2"
egui_dock = "0.12.0"
egui_node_graph = {version = "*", git = "https://github.com/dimtpap/egui_node_graph.git", rev = "87b3f084c1cf70ac9ad489ae1f2e2a8234efdde4"}
eframe = "0.29.1"
egui = {version = "0.29.1", features = ["rayon"]}
egui_plot = "0.29.0"
egui_dock = "0.14.0"
serde = {version = "1.0", optional = true}
ashpd = {version = "0.7.0", optional = true}
pollster = {version = "0.3.0", optional = true}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ makepkg -i
Debian and RPM packages are available from the [releases](https://github.com/dimtpap/coppwr/releases/latest).
## Building
### Requirements
- Rust and Cargo version `1.72.0` or later - https://www.rust-lang.org/tools/install
- Rust and Cargo version `1.76.0` or later - https://www.rust-lang.org/tools/install
- bindgen [requirements](https://rust-lang.github.io/rust-bindgen/requirements.html)
- PipeWire library headers/PipeWire development packages

Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ fn main() {
{
#[cfg(not(feature = "persistence"))]
{
Box::new(|_| Box::new(CoppwrApp::new()))
Box::new(|_| Ok(Box::new(CoppwrApp::new())))
}

#[cfg(feature = "persistence")]
{
Box::new(|cc| Box::new(CoppwrApp::new(cc.storage)))
Box::new(|cc| Ok(Box::new(CoppwrApp::new(cc.storage))))
}
},
) {
Expand Down
7 changes: 2 additions & 5 deletions src/ui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ impl eframe::App for App {
self.settings.update_rate.as_secs_f64()
}
})
.clamp_range(0f64..=86_400f64)
.range(0f64..=86_400f64)
.speed(0.001)
.custom_parser(|v| v.parse::<f64>().ok().map(|v| v / 1000.))
.custom_formatter(|n, _| format!("{:.0}ms", n * 1000.)),
Expand All @@ -638,10 +638,7 @@ impl eframe::App for App {
egui::Window::new("About")
.collapsible(false)
.fixed_size([350f32, 150f32])
.default_pos([
(window_size.x - 350f32) / 2f32,
(window_size.y - 150f32) / 2f32,
])
.default_pos([window_size.x / 2f32, window_size.y / 2f32])
.open(&mut self.about_open)
.show(ctx, Self::about_ui);

Expand Down
2 changes: 1 addition & 1 deletion src/ui/context_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl ContextManager {

match self.view {
View::PropertiesEditor => {
self.properties.show(ui, 0f32, 250f32);
self.properties.show(ui, 20f32, ui.available_height() - 30.);

ui.separator();

Expand Down
8 changes: 4 additions & 4 deletions src/ui/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl Global {
pub fn show(&mut self, ui: &mut egui::Ui, draw_subobjects: bool, sx: &backend::Sender) {
fn subobjects_display(
ui: &mut egui::Ui,
id_source: Option<&str>,
id_salt: Option<&str>,
len: usize,
subobjects: impl Iterator<Item = Rc<RefCell<Global>>>,
sx: &backend::Sender,
Expand All @@ -281,8 +281,8 @@ impl Global {

let sc = egui::ScrollArea::horizontal();

if let Some(id_source) = id_source {
sc.id_source(id_source)
if let Some(id_salt) = id_salt {
sc.id_salt(id_salt)
} else {
sc
}
Expand All @@ -305,7 +305,7 @@ impl Global {
}

ui.scope(|ui| {
ui.style_mut().wrap = Some(false);
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);

if let Some(name) = self.name() {
ui.label(name);
Expand Down
265 changes: 142 additions & 123 deletions src/ui/metadata_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,144 +133,163 @@ impl MetadataEditor {
}

fn show(&mut self, ui: &mut egui::Ui, sx: &backend::Sender) {
for (id, metadata) in &mut self.metadatas {
ui.group(|ui| {
ui.heading(metadata.global.borrow().name().map_or("", String::as_str));
ui.horizontal(|ui| {
global_info_button(ui, Some(&metadata.global), sx);
egui::ScrollArea::vertical()
.min_scrolled_height(0.0)
.show(ui, |ui| {
for (id, metadata) in &mut self.metadatas {
ui.group(|ui| {
ui.heading(metadata.global.borrow().name().map_or("", String::as_str));
ui.horizontal(|ui| {
global_info_button(ui, Some(&metadata.global), sx);

ui.label(format!("ID: {id}"));
ui.label(format!("ID: {id}"));

if ui.small_button("Clear").clicked() {
sx.send(Request::CallObjectMethod(*id, ObjectMethod::MetadataClear))
.ok();
}
});
egui::Grid::new(id)
.num_columns(2)
.striped(true)
.show(ui, |ui| {
for (key, prop) in &mut metadata.properties {
ui.label(key);
if ui.small_button("Clear").clicked() {
sx.send(Request::CallObjectMethod(
*id,
ObjectMethod::MetadataClear,
))
.ok();
}
});
egui::Grid::new(id)
.num_columns(2)
.striped(true)
.show(ui, |ui| {
for (key, prop) in &mut metadata.properties {
ui.label(key);

ui.with_layout(egui::Layout::right_to_left(egui::Align::Min), |ui| {
if ui.small_button("Clear").clicked() {
sx.send(Request::CallObjectMethod(
*id,
prop.clear_request(key.clone()),
))
.ok();
}
if ui.small_button("Set").clicked() {
sx.send(Request::CallObjectMethod(
*id,
prop.set_request(key.clone()),
))
.ok();
}
let input = ui.add(
egui::TextEdit::singleline(&mut prop.value)
.hint_text("Value")
.desired_width(f32::INFINITY),
);
if let Some(type_) = prop.type_.as_ref() {
input.on_hover_text(format!(
"Type: {type_}\nSubject: {}",
prop.subject
));
} else {
input.on_hover_text(format!("Subject: {}", prop.subject));
ui.with_layout(
egui::Layout::right_to_left(egui::Align::Min),
|ui| {
if ui.small_button("Clear").clicked() {
sx.send(Request::CallObjectMethod(
*id,
prop.clear_request(key.clone()),
))
.ok();
}
if ui.small_button("Set").clicked() {
sx.send(Request::CallObjectMethod(
*id,
prop.set_request(key.clone()),
))
.ok();
}
let input = ui.add(
egui::TextEdit::singleline(&mut prop.value)
.hint_text("Value")
.desired_width(f32::INFINITY),
);
if let Some(type_) = prop.type_.as_ref() {
input.on_hover_text(format!(
"Type: {type_}\nSubject: {}",
prop.subject
));
} else {
input.on_hover_text(format!(
"Subject: {}",
prop.subject
));
}
},
);

ui.end_row();
}
});

ui.end_row();
}
});
ui.separator();

ui.separator();
egui::CollapsingHeader::new("Add properites")
.id_salt(*id)
.show(ui, |ui| {
metadata.user_properties.retain_mut(|(key, prop)| {
ui.horizontal(|ui| {
ui.add(
egui::TextEdit::singleline(key)
.hint_text("Key")
.desired_width(ui.available_width() / 2.),
);
ui.add(
egui::TextEdit::singleline(&mut prop.value)
.hint_text("Value")
.desired_width(f32::INFINITY),
);
});
ui.horizontal(|ui| {
ui.label("Subject");
ui.add(egui::widgets::DragValue::new(&mut prop.subject));

egui::CollapsingHeader::new("Add properites")
.id_source(*id)
.show(ui, |ui| {
metadata.user_properties.retain_mut(|(key, prop)| {
ui.horizontal(|ui| {
ui.add(
egui::TextEdit::singleline(key)
.hint_text("Key")
.desired_width(ui.available_width() / 2.),
);
ui.add(
egui::TextEdit::singleline(&mut prop.value)
.hint_text("Value")
.desired_width(f32::INFINITY),
);
});
ui.horizontal(|ui| {
ui.label("Subject");
ui.add(egui::widgets::DragValue::new(&mut prop.subject));
if ui.checkbox(&mut prop.type_.is_some(), "Type").changed()
{
if prop.type_.is_none() {
prop.type_ = Some(String::new());
} else {
prop.type_ = None;
}
}
if let Some(ref mut type_) = prop.type_ {
ui.add(
egui::TextEdit::singleline(type_)
.hint_text("Type")
.desired_width(f32::INFINITY),
);
}
});
let keep = ui
.horizontal(|ui| {
if ui.small_button("Set").clicked() {
sx.send(Request::CallObjectMethod(
*id,
prop.set_request(key.clone()),
))
.ok();
}
!ui.small_button("Delete").clicked()
})
.inner;

if ui.checkbox(&mut prop.type_.is_some(), "Type").changed() {
if prop.type_.is_none() {
prop.type_ = Some(String::new());
} else {
prop.type_ = None;
}
}
if let Some(ref mut type_) = prop.type_ {
ui.add(
egui::TextEdit::singleline(type_)
.hint_text("Type")
.desired_width(f32::INFINITY),
);
}
});
let keep = ui
.horizontal(|ui| {
if ui.small_button("Set").clicked() {
sx.send(Request::CallObjectMethod(
*id,
prop.set_request(key.clone()),
))
.ok();
}
!ui.small_button("Delete").clicked()
})
.inner;
ui.separator();

ui.separator();
keep
});

keep
});
ui.horizontal(|ui| {
if ui.button("Add").clicked() {
metadata.user_properties.push((
String::new(),
Property {
subject: 0,
type_: None,
value: String::new(),
},
));
}

ui.horizontal(|ui| {
if ui.button("Add").clicked() {
metadata.user_properties.push((
String::new(),
Property {
subject: 0,
type_: None,
value: String::new(),
},
));
}
ui.add_enabled_ui(!metadata.user_properties.is_empty(), |ui| {
if ui.button("Clear").clicked() {
metadata.user_properties.clear();
}
});
});

ui.add_enabled_ui(!metadata.user_properties.is_empty(), |ui| {
if ui.button("Clear").clicked() {
metadata.user_properties.clear();
}
ui.add_enabled_ui(!metadata.user_properties.is_empty(), |ui| {
if ui.button("Set all").clicked() {
for (key, prop) in
std::mem::take(&mut metadata.user_properties)
{
sx.send(Request::CallObjectMethod(
*id,
prop.set_request(key),
))
.ok();
}
}
});
});
});

ui.add_enabled_ui(!metadata.user_properties.is_empty(), |ui| {
if ui.button("Set all").clicked() {
for (key, prop) in std::mem::take(&mut metadata.user_properties) {
sx.send(Request::CallObjectMethod(*id, prop.set_request(key)))
.ok();
}
}
});
});
}
});
}
}
}
Loading

0 comments on commit 1565d43

Please sign in to comment.