1
0
Fork 0
forked from wry/wry

all: remove traditional i3 titlebars, add corner rounding

This commit is contained in:
kossLAN 2026-04-09 23:04:33 -04:00
parent e1928863d9
commit a41dbae899
No known key found for this signature in database
52 changed files with 1866 additions and 1047 deletions

View file

@ -6,11 +6,11 @@ use {
},
gfx_api::{
AcquireSync, AlphaMode, BufferResv, CopyTexture, FillRect, FramebufferRect, GfxApiOpt,
GfxTexture, ReleaseSync, SampleRect,
GfxTexture, ReleaseSync, RoundedCopyTexture, RoundedFillRect, SampleRect,
},
rect::Rect,
scale::Scale,
theme::Color,
theme::{Color, CornerRadius},
tree::Transform,
},
std::rc::Rc,
@ -250,6 +250,123 @@ impl RendererBase<'_> {
}));
}
pub fn fill_rounded_rect(
&mut self,
rect: Rect,
color: &Color,
alpha: Option<f32>,
cd: &Rc<LinearColorDescription>,
render_intent: RenderIntent,
corner_radius: CornerRadius,
border_width: f32,
) {
if *color == Color::TRANSPARENT {
return;
}
let rect = self.scale_rect(rect);
let width = (rect.x2() - rect.x1()) as f32;
let height = (rect.y2() - rect.y1()) as f32;
let scale = self.scalef as f32;
let fitted = corner_radius.fit_to(width, height);
let cr: [f32; 4] = fitted.into();
self.ops
.push(GfxApiOpt::RoundedFillRect(RoundedFillRect {
rect: FramebufferRect::new(
rect.x1() as f32,
rect.y1() as f32,
rect.x2() as f32,
rect.y2() as f32,
self.transform,
self.fb_width,
self.fb_height,
),
color: *color,
alpha,
render_intent,
cd: cd.clone(),
size: [width, height],
corner_radius: cr,
border_width,
scale,
}));
}
pub fn render_rounded_texture(
&mut self,
texture: &Rc<dyn GfxTexture>,
alpha: Option<f32>,
x: i32,
y: i32,
tpoints: Option<SampleRect>,
tsize: Option<(i32, i32)>,
tscale: Scale,
bounds: Option<&Rect>,
buffer_resv: Option<Rc<dyn BufferResv>>,
acquire_sync: AcquireSync,
release_sync: ReleaseSync,
cd: &Rc<ColorDescription>,
render_intent: RenderIntent,
alpha_mode: AlphaMode,
corner_radius: CornerRadius,
) {
let mut texcoord = tpoints.unwrap_or_else(SampleRect::identity);
let (twidth, theight) = if let Some(size) = tsize {
size
} else {
let (mut w, mut h) = texcoord.buffer_transform.maybe_swap(texture.size());
if tscale != self.scale {
let tscale = tscale.to_f64();
w = (w as f64 * self.scalef / tscale).round() as _;
h = (h as f64 * self.scalef / tscale).round() as _;
}
(w, h)
};
let mut target_x = [x, x + twidth];
let mut target_y = [y, y + theight];
if let Some(bounds) = bounds
&& bound_target(&mut target_x, &mut target_y, &mut texcoord, bounds)
{
return;
}
let target = FramebufferRect::new(
target_x[0] as f32,
target_y[0] as f32,
target_x[1] as f32,
target_y[1] as f32,
self.transform,
self.fb_width,
self.fb_height,
);
let width = (target_x[1] - target_x[0]) as f32;
let height = (target_y[1] - target_y[0]) as f32;
let scale = self.scalef as f32;
let fitted = corner_radius.fit_to(width, height);
let cr: [f32; 4] = fitted.into();
self.ops
.push(GfxApiOpt::RoundedCopyTexture(RoundedCopyTexture {
tex: texture.clone(),
source: texcoord,
target,
alpha,
buffer_resv,
acquire_sync,
release_sync,
opaque: false,
render_intent,
cd: cd.clone(),
alpha_mode,
size: [width, height],
corner_radius: cr,
scale,
}));
}
pub fn sync(&mut self) {
self.ops.push(GfxApiOpt::Sync);
}