control-center: add compositor pane
This commit is contained in:
parent
186d5b694b
commit
eb917648c1
5 changed files with 122 additions and 22 deletions
88
src/control_center/cc_compositor.rs
Normal file
88
src/control_center/cc_compositor.rs
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
use {
|
||||
crate::{
|
||||
compositor::{LIBEI_SOCKET, WAYLAND_DISPLAY},
|
||||
control_center::{ControlCenterInner, bool, combo_box, grid, label, row},
|
||||
state::State,
|
||||
version::VERSION,
|
||||
},
|
||||
egui::{DragValue, OpenUrl, Ui, Widget},
|
||||
std::rc::Rc,
|
||||
};
|
||||
|
||||
pub struct CompositorPane {
|
||||
state: Rc<State>,
|
||||
switch_to_vt: u32,
|
||||
}
|
||||
|
||||
impl ControlCenterInner {
|
||||
pub fn create_compositor_pane(self: &Rc<Self>) -> CompositorPane {
|
||||
CompositorPane {
|
||||
state: self.state.clone(),
|
||||
switch_to_vt: 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CompositorPane {
|
||||
pub fn title(&self, res: &mut String) {
|
||||
res.push_str("Compositor");
|
||||
}
|
||||
|
||||
pub fn show(&mut self, ui: &mut Ui) {
|
||||
let s = &self.state;
|
||||
grid(ui, "compositor", |ui| {
|
||||
row(ui, "Repository", |ui| {
|
||||
let url = "https://github.com/mahkoh/jay";
|
||||
if ui.link(url).clicked() {
|
||||
ui.ctx().open_url(OpenUrl::new_tab(url));
|
||||
}
|
||||
});
|
||||
label(ui, "Version", VERSION);
|
||||
label(ui, "PID", s.pid.to_string());
|
||||
if let Some(acceptor) = s.acceptor.get() {
|
||||
label(ui, WAYLAND_DISPLAY, acceptor.socket_name());
|
||||
}
|
||||
if let Some(dir) = &s.config_dir {
|
||||
label(ui, "Config DIR", dir);
|
||||
}
|
||||
bool(ui, "Libei Socket", s.enable_ei_acceptor.get(), |v| {
|
||||
s.set_ei_socket_enabled(v);
|
||||
});
|
||||
if let Some(a) = s.ei_acceptor.get() {
|
||||
label(ui, LIBEI_SOCKET, a.socket_name());
|
||||
}
|
||||
combo_box(
|
||||
ui,
|
||||
"Workspace Display Order",
|
||||
s.workspace_display_order.get(),
|
||||
|o| s.set_workspace_display_order(o),
|
||||
);
|
||||
if let Some(logger) = &s.logger {
|
||||
combo_box(ui, "Log Level", logger.level(), |l| s.set_log_level(l));
|
||||
row(ui, "Log File", |ui| {
|
||||
let path = logger.path().to_string();
|
||||
if ui
|
||||
.link(&path)
|
||||
.on_hover_text_at_pointer("Copy to clipboard")
|
||||
.clicked()
|
||||
{
|
||||
ui.ctx().copy_text(path);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if ui.button("Quit").clicked() {
|
||||
s.quit();
|
||||
}
|
||||
if ui.button("Reload Config").clicked() {
|
||||
s.reload_config();
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
let button = ui.button("Switch to VT");
|
||||
DragValue::new(&mut self.switch_to_vt).ui(ui);
|
||||
if button.clicked() {
|
||||
s.backend.get().switch_to(self.switch_to_vt);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
use {
|
||||
crate::control_center::{ControlCenterInner, Pane},
|
||||
crate::control_center::{ControlCenterInner, Pane, PaneType},
|
||||
egui::{Align, Layout, ScrollArea, Ui, ViewportCommand},
|
||||
egui_tiles::Tree,
|
||||
linearize::{Linearize, LinearizeExt},
|
||||
|
|
@ -7,11 +7,15 @@ use {
|
|||
};
|
||||
|
||||
#[derive(Copy, Clone, Linearize)]
|
||||
enum PaneName {}
|
||||
enum PaneName {
|
||||
Compositor,
|
||||
}
|
||||
|
||||
impl PaneName {
|
||||
fn name(self) -> &'static str {
|
||||
match self {}
|
||||
match self {
|
||||
PaneName::Compositor => "Compositor",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -34,9 +38,12 @@ impl ControlCenterInner {
|
|||
ScrollArea::vertical().show(ui, |ui| {
|
||||
for &ty in &*TYPES {
|
||||
if ui.button(ty.name()).clicked() {
|
||||
let _ty = match ty {};
|
||||
#[expect(unreachable_code)]
|
||||
self.open(tree, _ty);
|
||||
let ty = match ty {
|
||||
PaneName::Compositor => {
|
||||
PaneType::Compositor(self.create_compositor_pane())
|
||||
}
|
||||
};
|
||||
self.open(tree, ty);
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue