what the helly
This commit is contained in:
+25
-24
@@ -36,10 +36,10 @@ enum SelectionState {
|
||||
Cancelled,
|
||||
}
|
||||
|
||||
const MAX_TEX: u32 = 2048;
|
||||
const MAX_TEX: u32 = 8192;
|
||||
|
||||
pub struct SelectionOverlay {
|
||||
background: egui::TextureHandle,
|
||||
background: Option<egui::TextureHandle>,
|
||||
/// Hyprland monitor scale (logical→physical). Used only for window rect conversion.
|
||||
scale: f32,
|
||||
state: SelectionState,
|
||||
@@ -50,16 +50,17 @@ pub struct SelectionOverlay {
|
||||
}
|
||||
|
||||
impl SelectionOverlay {
|
||||
pub fn new(cc: &eframe::CreationContext<'_>, background_snapshot: RgbaImage, scale: f32) -> Self {
|
||||
let tex_image = fit_to_max_texture(background_snapshot);
|
||||
let (tw, th) = tex_image.dimensions();
|
||||
let color_image = egui::ColorImage::from_rgba_unmultiplied(
|
||||
[tw as usize, th as usize],
|
||||
tex_image.as_raw(),
|
||||
);
|
||||
let texture =
|
||||
pub fn new(cc: &eframe::CreationContext<'_>, background_snapshot: Option<RgbaImage>, scale: f32) -> Self {
|
||||
let texture = background_snapshot.map(|img| {
|
||||
let tex_image = fit_to_max_texture(img);
|
||||
let (tw, th) = tex_image.dimensions();
|
||||
let color_image = egui::ColorImage::from_rgba_unmultiplied(
|
||||
[tw as usize, th as usize],
|
||||
tex_image.as_raw(),
|
||||
);
|
||||
cc.egui_ctx
|
||||
.load_texture("background", color_image, egui::TextureOptions::LINEAR);
|
||||
.load_texture("background", color_image, egui::TextureOptions::LINEAR)
|
||||
});
|
||||
|
||||
let windows = crate::hyprland::active_workspace_windows();
|
||||
|
||||
@@ -201,13 +202,15 @@ impl eframe::App for SelectionOverlay {
|
||||
.show(ctx, |ui| {
|
||||
let painter = ui.painter();
|
||||
|
||||
// 1. Background screenshot.
|
||||
painter.image(
|
||||
self.background.id(),
|
||||
screen_rect,
|
||||
Rect::from_min_max(Pos2::ZERO, Pos2::new(1.0, 1.0)),
|
||||
Color32::WHITE,
|
||||
);
|
||||
// 1. Background screenshot (if in freeze mode).
|
||||
if let Some(bg) = &self.background {
|
||||
painter.image(
|
||||
bg.id(),
|
||||
screen_rect,
|
||||
Rect::from_min_max(Pos2::ZERO, Pos2::new(1.0, 1.0)),
|
||||
Color32::WHITE,
|
||||
);
|
||||
}
|
||||
|
||||
// 2. Dim overlay.
|
||||
let active_rect = current_rect.or_else(|| {
|
||||
@@ -240,12 +243,10 @@ impl eframe::App for SelectionOverlay {
|
||||
Rounding::ZERO, dim,
|
||||
);
|
||||
|
||||
let border_color = if self.hovered_window.is_some() && current_rect.is_none() {
|
||||
Color32::from_rgb(255, 190, 50)
|
||||
} else {
|
||||
Color32::from_rgb(100, 180, 255)
|
||||
};
|
||||
painter.rect_stroke(s, Rounding::ZERO, Stroke::new(1.5, border_color));
|
||||
// Only draw a stroke if we are actively dragging a selection.
|
||||
if current_rect.is_some() {
|
||||
painter.rect_stroke(s, Rounding::ZERO, Stroke::new(1.5, Color32::from_rgb(100, 180, 255)));
|
||||
}
|
||||
|
||||
// Size label in physical pixels.
|
||||
let label = format!("{} × {}", s.width().round() as u32, s.height().round() as u32);
|
||||
|
||||
Reference in New Issue
Block a user