debug: Update for egui 0.18

This commit is contained in:
Victoria Brekenfeld 2022-07-04 16:00:03 +02:00
parent 270f06182e
commit 43062c1754
8 changed files with 54 additions and 73 deletions

38
Cargo.lock generated
View file

@ -324,7 +324,7 @@ dependencies = [
"bitflags",
"cosmic-protocols",
"edid-rs",
"egui 0.16.1",
"egui",
"id_tree",
"indexmap",
"lazy_static",
@ -556,17 +556,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ab5fa33485cd85ac354df485819a63360fefa312fe04cffe65e6f175be1522c"
[[package]]
name = "egui"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c733356eb5f1139fdeedc370c00e9ea689c5d9120502c43925285bc7249a333"
dependencies = [
"ahash",
"epaint 0.16.0",
"nohash-hasher",
]
[[package]]
name = "egui"
version = "0.18.1"
@ -574,35 +563,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb095a8b9feb9b7ff8f00b6776dffcef059538a3f4a91238e03c900e9c9ad9a2"
dependencies = [
"ahash",
"epaint 0.18.1",
"epaint",
"nohash-hasher",
]
[[package]]
name = "emath"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55673de2eb96660dde25ba7b2d36a7054beead1a2bec74dcfd5eb05a1e1ba76d"
[[package]]
name = "emath"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c223f58c7e38abe1770f367b969f1b3fbd4704b67666bcb65dbb1adb0980ba72"
[[package]]
name = "epaint"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adfd9296f7f92902e41c0e8e5deca6d2fb29f289c86d03a01ea01bd7498316c2"
dependencies = [
"ab_glyph",
"ahash",
"atomic_refcell",
"emath 0.16.0",
"nohash-hasher",
]
[[package]]
name = "epaint"
version = "0.18.1"
@ -612,7 +582,7 @@ dependencies = [
"ab_glyph",
"ahash",
"atomic_refcell",
"emath 0.18.0",
"emath",
"nohash-hasher",
"parking_lot 0.12.1",
]
@ -1573,7 +1543,7 @@ version = "0.1.0"
source = "git+https://github.com/Smithay/smithay-egui.git?rev=1969c96d#1969c96d21743134bb11eadde4866245ae7c0478"
dependencies = [
"cgmath",
"egui 0.18.1",
"egui",
"lazy_static",
"memoffset",
"slog",

View file

@ -15,7 +15,7 @@ slog-scope = "4.4"
slog-stdlog = "4.1"
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", optional = true }
egui = { version = "0.16", optional = true }
egui = { version = "0.18.1", optional = true }
edid-rs = { version = "0.1" }
lazy_static = "1.4.0"
thiserror = "1.0.26"

View file

@ -5,7 +5,8 @@ use crate::state::Common;
use crate::{
debug::{debug_ui, fps_ui, log_ui, EguiFrame},
state::Fps,
};
utils::prelude::*,
};
use slog::Logger;
use smithay::{
@ -200,11 +201,13 @@ where
.unwrap_or(Rectangle::from_loc_and_size((0, 0), (0, 0)));
let scale = output.current_scale().fractional_scale();
let fps_overlay = fps_ui(_gpu, state, fps, output_geo, scale);
let fps_overlay = fps_ui(_gpu, state, fps, output_geo.to_f64().to_physical(scale), scale);
custom_elements.push(fps_overlay.into());
let mut area = state.shell.global_space();
area.loc = state.shell.space_relative_output_geometry((0, 0), output);
let area = Rectangle::<f64, smithay::utils::Logical>::from_loc_and_size(
state.shell.space_relative_output_geometry((0.0f64, 0.0f64), output),
state.shell.global_space().to_f64().size,
).to_physical(scale);
if let Some(log_ui) = log_ui(state, area, scale, output_geo.size.w as f32 * 0.6) {
custom_elements.push(log_ui.into());
}
@ -264,12 +267,12 @@ where
#[cfg(feature = "debug")]
{
let output_geo = state.shell.output_geometry(output);
let output_geo = output.geometry();
let fps_overlay = fps_ui(
_gpu,
state,
fps,
Rectangle::from_loc_and_size((0, 0), output_geo.size),
Rectangle::from_loc_and_size((0, 0), output_geo.size).to_f64().to_physical(scale),
scale,
);
custom_elements.push(fps_overlay.into());

View file

@ -36,7 +36,7 @@ pub struct StaticConfig {
pub workspace_mode: WorkspaceMode,
}
#[derive(Debug, Deserialize, Clone, Copy)]
#[derive(Debug, Deserialize, Clone, Copy, PartialEq, Eq)]
pub enum WorkspaceMode {
OutputBound,
Global,

View file

@ -3,7 +3,7 @@
use crate::state::{Common, Fps};
use smithay::{
backend::drm::DrmNode,
utils::{Logical, Rectangle},
utils::{Physical, Rectangle},
};
pub use smithay_egui::EguiFrame;
@ -11,7 +11,7 @@ pub fn fps_ui(
gpu: Option<&DrmNode>,
state: &Common,
fps: &mut Fps,
area: Rectangle<i32, Logical>,
area: Rectangle<f64, Physical>,
scale: f64,
) -> EguiFrame {
use egui::widgets::plot::{Bar, BarChart, HLine, Legend, Plot};
@ -80,7 +80,7 @@ pub fn fps_ui(
.show(ui, |plot_ui| {
plot_ui.bar_chart(fps_chart);
plot_ui.hline(
HLine::new(avg).highlight().color(egui::Color32::LIGHT_BLUE),
HLine::new(avg).highlight(true).color(egui::Color32::LIGHT_BLUE),
);
});
}
@ -96,7 +96,7 @@ pub fn fps_ui(
pub fn debug_ui(
state: &mut Common,
area: Rectangle<i32, Logical>,
area: Rectangle<f64, Physical>,
scale: f64,
) -> Option<EguiFrame> {
if !state.egui.active {
@ -105,39 +105,46 @@ pub fn debug_ui(
Some(state.egui.debug_state.run(
|ctx| {
use crate::utils::prelude::*;
egui::Window::new("Workspaces")
.default_pos([0.0, 300.0])
.vscroll(true)
.collapsible(true)
.show(ctx, |ui| {
use crate::shell::{ActiveWorkspace, Mode, MAX_WORKSPACES};
use crate::{
config::WorkspaceMode as ConfigMode,
shell::{OutputBoundState, WorkspaceMode, MAX_WORKSPACES},
};
ui.set_min_width(250.0);
// Mode
ui.label(egui::RichText::new("Mode").heading());
let mut mode = *state.shell.mode();
let active = if let Mode::Global { active } = mode {
active
} else {
0
let mut mode = match &state.shell.workspace_mode {
WorkspaceMode::Global { .. } => ConfigMode::Global,
WorkspaceMode::OutputBound => ConfigMode::OutputBound,
};
ui.radio_value(&mut mode, Mode::OutputBound, "Output bound");
ui.radio_value(&mut mode, Mode::Global { active }, "Global");
ui.radio_value(&mut mode, ConfigMode::OutputBound, "Output bound");
ui.radio_value(&mut mode, ConfigMode::Global, "Global");
state.shell.set_mode(mode);
match *state.shell.mode() {
Mode::OutputBound => {
let mode = match &state.shell.workspace_mode {
WorkspaceMode::OutputBound => (ConfigMode::OutputBound, None),
WorkspaceMode::Global { ref active, .. } => (ConfigMode::Global, Some(*active)),
};
match mode {
(ConfigMode::OutputBound, _) => {
ui.label("Workspaces:");
for output in state.shell.outputs().cloned().collect::<Vec<_>>() {
ui.horizontal(|ui| {
let active = output
.user_data()
.get::<ActiveWorkspace>()
.get::<OutputBoundState>()
.unwrap()
.get()
.unwrap();
.active
.get();
let mut active_val = active as f64;
ui.label(output.name());
ui.add(
@ -155,7 +162,7 @@ pub fn debug_ui(
});
}
}
Mode::Global { active } => {
(ConfigMode::Global, Some(active)) => {
ui.horizontal(|ui| {
let mut active_val = active as f64;
ui.label("Workspace:");
@ -173,7 +180,8 @@ pub fn debug_ui(
);
}
});
}
},
_ => unreachable!(),
}
// Spaces
@ -219,7 +227,7 @@ pub fn debug_ui(
ui.label(format!("Output: {:#?}", output));
ui.label(format!(
"Geometry: {:?}",
state.shell.output_geometry(&output)
output.geometry()
));
ui.label(format!(
"Local Geometry: {:?}",
@ -231,7 +239,7 @@ pub fn debug_ui(
));
ui.label(format!(
"Relative Geometry: {:?}",
state.shell.space_relative_output_geometry((0, 0), &output)
state.shell.space_relative_output_geometry((0i32, 0i32), &output)
));
});
}
@ -247,7 +255,7 @@ pub fn debug_ui(
pub fn log_ui(
state: &mut Common,
area: Rectangle<i32, Logical>,
area: Rectangle<f64, Physical>,
scale: f64,
default_width: f32,
) -> Option<EguiFrame> {
@ -259,8 +267,9 @@ pub fn log_ui(
|ctx| {
egui::SidePanel::right("Log")
.frame(egui::Frame {
margin: egui::Vec2::new(10.0, 10.0),
corner_radius: 5.0,
inner_margin: egui::Vec2::new(10.0, 10.0).into(),
outer_margin: egui::Vec2::new(0.0, 0.0).into(),
rounding: 5.0.into(),
shadow: egui::epaint::Shadow {
extrusion: 0.0,
color: egui::Color32::TRANSPARENT,
@ -286,7 +295,7 @@ pub fn log_ui(
let mut message = egui::text::LayoutJob::single_section(
record.level.as_short_str().to_string(),
egui::TextFormat::simple(
egui::TextStyle::Monospace,
egui::FontId::monospace(16.0),
match record.level {
slog::Level::Critical => egui::Color32::RED,
slog::Level::Error => egui::Color32::LIGHT_RED,
@ -301,7 +310,7 @@ pub fn log_ui(
&record.message,
6.0,
egui::TextFormat::simple(
egui::TextStyle::Body,
egui::FontId::default(),
egui::Color32::WHITE,
),
);

View file

@ -283,7 +283,6 @@ impl State {
x => x - 1,
};
self.common.shell.activate(
dh,
seat,
&current_output,
workspace as usize,

View file

@ -85,7 +85,7 @@ pub enum ShellMode {
#[derive(Debug, Clone)]
pub struct OutputBoundState {
active: Cell<usize>,
pub active: Cell<usize>,
group: Cell<WorkspaceGroupHandle>,
}
@ -245,7 +245,7 @@ impl Shell {
}
}
pub fn activate(&mut self, _dh: &DisplayHandle, seat: &Seat<State>, output: &Output, idx: usize) -> Option<MotionEvent> {
pub fn activate(&mut self, seat: &Seat<State>, output: &Output, idx: usize) -> Option<MotionEvent> {
if idx > MAX_WORKSPACES {
return None;
}

View file

@ -29,14 +29,14 @@ impl WorkspaceHandler for State {
&mut self.common.shell.workspace_state
}
fn commit_requests(&mut self, dh: &DisplayHandle, requests: Vec<Request>) {
fn commit_requests(&mut self, _dh: &DisplayHandle, requests: Vec<Request>) {
for request in requests.into_iter() {
match request {
Request::Activate(handle) => {
if let Some(idx) = self.common.shell.spaces.iter().position(|w| w.handle == handle) {
let seat = &self.common.last_active_seat;
let output = active_output(seat, &self.common);
self.common.shell.activate(dh, seat, &output, idx);
self.common.shell.activate(seat, &output, idx);
}
},
_ => {},