mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-18 06:50:01 +02:00
This commit changes the way icons are displayed on the bar. There was an issue with how app icons were sized using shrink_to_fit. This has been changed to use fit_to_exact_size instead, relying on the font size as a starting point and scaling it to 1.4 of its size, making the icons to appear larger. The same scaling was done to all the widget icons as well to make them look unified.
57 lines
1.8 KiB
Rust
57 lines
1.8 KiB
Rust
use eframe::egui::CursorIcon;
|
|
use eframe::egui::Frame;
|
|
use eframe::egui::Margin;
|
|
use eframe::egui::Response;
|
|
use eframe::egui::Sense;
|
|
use eframe::egui::Ui;
|
|
|
|
/// Same as SelectableLabel, but supports all content
|
|
pub struct SelectableFrame {
|
|
selected: bool,
|
|
}
|
|
|
|
impl SelectableFrame {
|
|
pub fn new(selected: bool) -> Self {
|
|
Self { selected }
|
|
}
|
|
|
|
pub fn show<R>(self, ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> Response {
|
|
let Self { selected } = self;
|
|
|
|
Frame::none()
|
|
.show(ui, |ui| {
|
|
let response = ui.interact(ui.max_rect(), ui.unique_id(), Sense::click());
|
|
|
|
if ui.is_rect_visible(response.rect) {
|
|
let inner_margin = Margin::symmetric(
|
|
ui.style().spacing.button_padding.x,
|
|
ui.style().spacing.button_padding.y,
|
|
);
|
|
|
|
if selected
|
|
|| response.hovered()
|
|
|| response.highlighted()
|
|
|| response.has_focus()
|
|
{
|
|
let visuals = ui.style().interact_selectable(&response, selected);
|
|
|
|
Frame::none()
|
|
.stroke(visuals.bg_stroke)
|
|
.rounding(visuals.rounding)
|
|
.fill(visuals.bg_fill)
|
|
.inner_margin(inner_margin)
|
|
.show(ui, add_contents);
|
|
} else {
|
|
Frame::none()
|
|
.inner_margin(inner_margin)
|
|
.show(ui, add_contents);
|
|
}
|
|
}
|
|
|
|
response
|
|
})
|
|
.inner
|
|
.on_hover_cursor(CursorIcon::PointingHand)
|
|
}
|
|
}
|