feat: use cached window control icons on other OSes
This commit is contained in:
parent
22138671b4
commit
716b3dee56
4 changed files with 33 additions and 11 deletions
3
res/icons/window-close-symbolic.svg
Normal file
3
res/icons/window-close-symbolic.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M5 4.00299C4.73478 4.00299 4.48043 4.10835 4.29289 4.29588C4.10536 4.48342 4 4.73777 4 5.00299C4.00006 5.26819 4.10545 5.5225 4.293 5.70999L6.586 8.00299L4.293 10.296C4.10545 10.4835 4.00006 10.7378 4 11.003C4 11.2682 4.10536 11.5226 4.29289 11.7101C4.48043 11.8976 4.73478 12.003 5 12.003C5.26519 12.0029 5.51951 11.8975 5.707 11.71L8 9.41699L10.283 11.7C10.3762 11.7959 10.4877 11.8721 10.6108 11.9241C10.734 11.9762 10.8663 12.003 11 12.003C11.2652 12.003 11.5196 11.8976 11.7071 11.7101C11.8946 11.5226 12 11.2682 12 11.003C11.9999 10.7378 11.8945 10.4835 11.707 10.296L9.414 8.00299L11.697 5.71999C11.7929 5.6268 11.8691 5.51534 11.9211 5.39218C11.9732 5.26903 12 5.13669 12 5.00299C12 4.73777 11.8946 4.48342 11.7071 4.29588C11.5196 4.10835 11.2652 4.00299 11 4.00299C10.7348 4.00305 10.4805 4.10844 10.293 4.29599L8 6.58899L5.717 4.30599C5.71369 4.30263 5.71036 4.2993 5.707 4.29599C5.51951 4.10844 5.26519 4.00305 5 4.00299Z" fill="#232323"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1 KiB |
4
res/icons/window-maximize-symbolic.svg
Normal file
4
res/icons/window-maximize-symbolic.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4 12H8L6.5 10.5L7.78947 9.15789C7.78947 9.15789 8.26316 8.68421 7.78947 8.21053C7.31579 7.73684 6.8421 8.21053 6.8421 8.21053L5.5 9.5L4 8V12Z" fill="#232323"/>
|
||||
<path d="M12 4H8L9.5 5.5L8.21053 6.84211C8.21053 6.84211 7.73684 7.31579 8.21053 7.78947C8.68421 8.26316 9.1579 7.78947 9.1579 7.78947L10.5 6.5L12 8V4Z" fill="#232323"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 443 B |
3
res/icons/window-minimize-symbolic.svg
Normal file
3
res/icons/window-minimize-symbolic.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 10V12H12V10H4Z" fill="#232323"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 188 B |
|
|
@ -5,7 +5,7 @@ use crate::config::Density;
|
|||
use crate::{ext::CollectionWidget, widget, Element};
|
||||
use apply::Apply;
|
||||
use derive_setters::Setters;
|
||||
use iced::{Length, Padding};
|
||||
use iced::Length;
|
||||
use iced_core::{widget::tree, Widget};
|
||||
use std::borrow::Cow;
|
||||
|
||||
|
|
@ -358,15 +358,27 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
|||
|
||||
/// Creates the widget for window controls.
|
||||
fn window_controls(&mut self) -> Element<'a, Message> {
|
||||
let icon = |name, size, on_press| {
|
||||
widget::icon::from_name(name)
|
||||
.symbolic(true)
|
||||
macro_rules! icon {
|
||||
($name:expr, $size:expr, $on_press:expr) => {{
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
widget::icon::from_name($name).apply(widget::button::icon)
|
||||
}
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
widget::icon::from_svg_bytes(include_bytes!(concat!(
|
||||
"../../res/icons/",
|
||||
$name,
|
||||
".svg"
|
||||
)))
|
||||
.apply(widget::button::icon)
|
||||
}
|
||||
.style(crate::theme::Button::HeaderBar)
|
||||
.selected(self.focused)
|
||||
.icon_size(size)
|
||||
.on_press(on_press)
|
||||
};
|
||||
.icon_size($size)
|
||||
.on_press($on_press)
|
||||
}};
|
||||
}
|
||||
|
||||
let density = self.density.unwrap_or_else(crate::config::header_size);
|
||||
let spacing = if matches!(density, Density::Compact) {
|
||||
|
|
@ -379,17 +391,17 @@ impl<'a, Message: Clone + 'static> HeaderBar<'a, Message> {
|
|||
.push_maybe(
|
||||
self.on_minimize
|
||||
.take()
|
||||
.map(|m| icon("window-minimize-symbolic", 16, m)),
|
||||
.map(|m| icon!("window-minimize-symbolic", 16, m)),
|
||||
)
|
||||
.push_maybe(
|
||||
self.on_maximize
|
||||
.take()
|
||||
.map(|m| icon("window-maximize-symbolic", 16, m)),
|
||||
.map(|m| icon!("window-maximize-symbolic", 16, m)),
|
||||
)
|
||||
.push_maybe(
|
||||
self.on_close
|
||||
.take()
|
||||
.map(|m| icon("window-close-symbolic", 16, m)),
|
||||
.map(|m| icon!("window-close-symbolic", 16, m)),
|
||||
)
|
||||
.spacing(spacing)
|
||||
.apply(widget::container)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue