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
8 changes: 7 additions & 1 deletion src/ui/host_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,19 @@ fn render_header(
20
}),
);
icons::paint(
let chevron_t = ui.ctx().animate_bool_with_time(
ui.id().with("tb_new_menu_anim"),
*new_host_menu_open,
0.14,
);
icons::paint_rotated(
&painter,
chevron.center() + vec2(0.0, 0.5),
bold::CARET_DOWN,
12.0,
theme::TEXT_PRIMARY,
IconStyle::Bold,
chevron_t * std::f32::consts::PI,
);
if chresp.clicked() {
*new_host_menu_open = !*new_host_menu_open;
Expand Down
22 changes: 22 additions & 0 deletions src/ui/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@ pub fn paint(
);
}

/// Paints a Tabler icon glyph centered on `center`, rotated by `angle` radians clockwise.
pub fn paint_rotated(
painter: &Painter,
center: Pos2,
glyph: &str,
size: f32,
color: Color32,
style: IconStyle,
angle: f32,
) {
if angle.abs() < 1e-4 {
paint(painter, center, glyph, size, color, style);
return;
}
let galley = painter.layout_no_wrap(glyph.to_owned(), font(size, style), color);
let rot = egui::emath::Rot2::from_angle(angle);
let pos = center + rot * (-galley.size() / 2.0);
let mut shape = egui::epaint::TextShape::new(pos, galley, color);
shape.angle = angle;
painter.add(shape);
}

/// Tabler Icons (outline, 2px stroke).
#[allow(dead_code)]
pub mod regular {
Expand Down
Loading