use super::shape_helpers::ShapeHelpers;
pub trait UiEffectHelpers: ShapeHelpers {
fn draw_blur_background(&mut self, x: f64, y: f64, width: f64, height: f64) {
let _ = (x, y, width, height);
}
fn has_blur_background(&self) -> bool {
false
}
fn use_convex_glass_buttons(&self) -> bool {
false
}
#[allow(clippy::too_many_arguments)]
fn draw_glass_button_3d(
&mut self,
x: f64,
y: f64,
width: f64,
height: f64,
radius: f64,
_is_active: bool,
color: &str,
) {
self.draw_blur_background(x, y, width, height);
self.set_fill_color(color);
self.fill_rounded_rect(x, y, width, height, radius);
}
fn draw_hover_rect(&mut self, x: f64, y: f64, width: f64, height: f64, color: &str) {
if self.use_convex_glass_buttons() {
self.draw_glass_button_3d(x, y, width, height, 2.0, false, color);
} else if self.has_blur_background() {
self.draw_blur_background(x, y, width, height);
self.set_fill_color(color);
self.fill_rect(x, y, width, height);
} else {
self.set_fill_color(color);
self.fill_rect(x, y, width, height);
}
}
fn draw_active_rect(&mut self, x: f64, y: f64, width: f64, height: f64, color: &str) {
if self.use_convex_glass_buttons() {
self.draw_glass_button_3d(x, y, width, height, 2.0, true, color);
} else if self.has_blur_background() {
self.draw_blur_background(x, y, width, height);
self.set_fill_color(color);
self.fill_rect(x, y, width, height);
} else {
self.set_fill_color(color);
self.fill_rect(x, y, width, height);
}
}
fn draw_hover_rounded_rect(
&mut self,
x: f64,
y: f64,
width: f64,
height: f64,
radius: f64,
color: &str,
) {
if self.use_convex_glass_buttons() {
self.draw_glass_button_3d(x, y, width, height, radius, false, color);
} else if self.has_blur_background() {
self.draw_blur_background(x, y, width, height);
self.set_fill_color(color);
self.fill_rounded_rect(x, y, width, height, radius);
} else {
self.set_fill_color(color);
self.fill_rounded_rect(x, y, width, height, radius);
}
}
fn draw_active_rounded_rect(
&mut self,
x: f64,
y: f64,
width: f64,
height: f64,
radius: f64,
color: &str,
) {
if self.use_convex_glass_buttons() {
self.draw_glass_button_3d(x, y, width, height, radius, true, color);
} else if self.has_blur_background() {
self.draw_blur_background(x, y, width, height);
self.set_fill_color(color);
self.fill_rounded_rect(x, y, width, height, radius);
} else {
self.set_fill_color(color);
self.fill_rounded_rect(x, y, width, height, radius);
}
}
#[allow(clippy::too_many_arguments)]
fn draw_sidebar_hover_item(
&mut self,
x: f64,
y: f64,
width: f64,
height: f64,
accent_color: &str,
bg_color: &str,
indicator_width: f64,
) {
self.set_fill_color(accent_color);
self.fill_rect(x, y, indicator_width, height);
self.draw_hover_rect(x + indicator_width, y, width - indicator_width, height, bg_color);
}
#[allow(clippy::too_many_arguments)]
fn draw_sidebar_active_item(
&mut self,
x: f64,
y: f64,
width: f64,
height: f64,
accent_color: &str,
bg_color: &str,
indicator_width: f64,
) {
self.set_fill_color(accent_color);
self.fill_rect(x, y, indicator_width, height);
self.draw_active_rect(x + indicator_width, y, width - indicator_width, height, bg_color);
}
}