Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions crates/cp-panel/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ impl App {
ui: panel.as_weak(),
state,
};
if app.state.borrow().options.flat {
panel.global::<crate::Theme>().set_shadow_blur(0.0);
}
app.wire(&panel);
dress_theme(&panel, kept.light(here::system_is_light()), kept.look);
refresh(&panel, &app.state);
Expand Down
4 changes: 0 additions & 4 deletions crates/cp-panel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,20 @@ pub struct Options {
pub serve: bool,
pub signals: Option<PathBuf>,
pub backdrop: String,
pub flat: bool,
}

impl Options {
fn from_args() -> Result<Self, &'static str> {
let mut db = None;
let mut measure = false;
let mut serve = false;
let mut flat = false;
let mut backdrop = "none".to_owned();
let mut args = std::env::args().skip(1);
while let Some(arg) = args.next() {
match arg.as_str() {
"--db" => db = args.next().map(PathBuf::from),
"--measure" => measure = true,
"--serve" => serve = true,
"--flat" => flat = true,
"--backdrop" => backdrop = args.next().unwrap_or_default(),
other => eprintln!("argument ignored: {other}"),
}
Expand All @@ -164,7 +161,6 @@ impl Options {
serve,
signals: std::env::var_os("CP_PANEL_SIGNALS").map(PathBuf::from),
backdrop,
flat,
})
}
}
Expand Down
6 changes: 2 additions & 4 deletions crates/cp-panel/src/main_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn centre_of(bench: &Bench, index: usize) -> LogicalPosition {
} else {
0.0
};
let list_top = panel.global::<Theme>().get_margin() + panel.get_list_top();
let list_top = panel.get_list_top();
let y = list_top + panel.get_scroll_y() + top + head + (span - head - GAP) / 2.0;
LogicalPosition::new(200.0, y)
}
Expand Down Expand Up @@ -151,9 +151,7 @@ fn a_double_click_pastes_the_card_under_it_whatever_was_open_and_however_slow()
}
bench.moved.borrow_mut().clear();
let at = centre_of(&bench, target);
let floor = bench.panel.global::<Theme>().get_margin()
+ bench.panel.get_list_top()
+ bench.panel.get_viewport_height();
let floor = bench.panel.get_list_top() + bench.panel.get_viewport_height();
assert!(at.y < floor, "card {target} is out of sight at {}", at.y);
click(&bench.panel, at, 90);
tick(gap);
Expand Down
9 changes: 3 additions & 6 deletions crates/cp-panel/src/showing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
}

pub fn place(panel: &Panel) {
let Some(pointer) = crate::here::pointer() else {
return;
};
let theme = panel.global::<crate::Theme>();
let zoom = f64::from(theme.get_zoom());
let width = f64::from(theme.get_width() + theme.get_margin() * 2.0) * zoom;
let height = f64::from(theme.get_height() + theme.get_margin() * 2.0) * zoom;
let width = f64::from(theme.get_width()) * zoom;

Check warning on line 23 in crates/cp-panel/src/showing.rs

View workflow job for this annotation

GitHub Actions / windows 1 of 2 / the lines this branch changed

Missed mutant

replace * with + in place

Check warning on line 23 in crates/cp-panel/src/showing.rs

View workflow job for this annotation

GitHub Actions / windows 1 of 2 / the lines this branch changed

Missed mutant

replace * with / in place
let height = f64::from(theme.get_height()) * zoom;

Check warning on line 24 in crates/cp-panel/src/showing.rs

View workflow job for this annotation

GitHub Actions / windows 2 of 2 / the lines this branch changed

Missed mutant

replace * with / in place

Check warning on line 24 in crates/cp-panel/src/showing.rs

View workflow job for this annotation

GitHub Actions / windows 2 of 2 / the lines this branch changed

Missed mutant

replace * with + in place
let window = panel.window();
let scale = pointer.scale;
if pointer.physical {
Expand All @@ -44,32 +44,29 @@
}

pub fn zoom(panel: &Panel) {
use i_slint_backend_winit::WinitWindowAccessor;
let window = panel.window();
let Some(device) = window.with_winit_window(|winit| winit.scale_factor()) else {
return;
};
let theme = panel.global::<crate::Theme>();
#[allow(clippy::cast_possible_truncation)]
let wanted = (device * f64::from(theme.get_zoom())) as f32;
if (window.scale_factor() - wanted).abs() < 0.001 {
return;
}
window.dispatch_event(slint::platform::WindowEvent::ScaleFactorChanged {
scale_factor: wanted,
});
let side = |logical: f32| (logical * wanted).round().max(1.0) as u32;
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
let size = slint::PhysicalSize::new(
side(theme.get_width() + theme.get_margin() * 2.0),
side(theme.get_height() + theme.get_margin() * 2.0),
);
let size = slint::PhysicalSize::new(side(theme.get_width()), side(theme.get_height()));
let bound = i_slint_backend_winit::winit::dpi::PhysicalSize::new(size.width, size.height);
window.with_winit_window(|winit| {
winit.set_min_inner_size(Some(bound));
winit.set_max_inner_size(Some(bound));
});
window.set_size(size);

Check warning on line 69 in crates/cp-panel/src/showing.rs

View workflow job for this annotation

GitHub Actions / windows 2 of 2 / the lines this branch changed

Missed mutant

replace zoom with ()
}

pub fn nudge(panel: &Panel, dx: f32, dy: f32) {
Expand Down
10 changes: 2 additions & 8 deletions crates/cp-panel/ui/panel.slint
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { NewerStrip } from "newer.slint";
export { Card, Chip, FormRow, Theme, Words }

export component Panel inherits Window {
width: Theme.width + Theme.margin * 2;
height: Theme.height + Theme.margin * 2;
width: Theme.width;
height: Theme.height;
no-frame: true;
always-on-top: true;
background: Theme.apple ? Theme.panel : transparent;
Expand Down Expand Up @@ -126,21 +126,15 @@ export component Panel inherits Window {

panel := Rectangle {
property <length> sheet-top: root.list-top + root.sheet-anchor + root.sheet-span + list.content-y + 4px;
x: Theme.margin;
y: Theme.margin + (1.0 - root.shown) * (Theme.apple ? 0px : 8px);
width: Theme.width;
height: Theme.height;
border-radius: Theme.radius;
border-width: 1px;
border-color: Theme.panel-border;
background: Theme.panel;
opacity: Theme.apple ? 1.0 : root.shown;
drop-shadow-blur: Theme.shadow-blur;
drop-shadow-color: Theme.shadow;
drop-shadow-offset-y: Theme.apple ? 0px : 10px;
clip: true;
animate opacity { duration: Theme.appear; easing: ease-out; }
animate y { duration: Theme.appear; easing: ease-out; }

VerticalLayout {
padding: 0px;
Expand Down
3 changes: 0 additions & 3 deletions crates/cp-panel/ui/theme.slint
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ export global Theme {
out property <color> alert-back: light ? #FDE9B5 : #46351C;
out property <color> alert-ink: light ? #7A4E07 : #FCD34D;
out property <color> scrim: #000000A6;
out property <color> shadow: light ? #0000002E : #00000099;
in-out property <length> shadow-blur: apple ? 0px : 22px;
out property <length> radius: apple ? 0px : 8px;
out property <length> margin: apple ? 0px : 18px;
out property <length> radius-card: 10px;
out property <length> radius-control: 8px;
out property <length> radius-inset: 6px;
Expand Down
Loading