diff --git a/lapce-ui/src/editor/header.rs b/lapce-ui/src/editor/header.rs index 15600db5..e6b50353 100644 --- a/lapce-ui/src/editor/header.rs +++ b/lapce-ui/src/editor/header.rs @@ -55,7 +55,7 @@ pub fn get_icons(&self, self_size: Size, data: &LapceTabData) -> Vec let x = self_size.width - ((icons.len() + 1) as f64) * (gap + self.icon_size); let icon = LapceIcon { - icon: "close.svg".to_string(), + icon: "close.svg", rect: Size::new(self.icon_size, self.icon_size) .to_rect() .with_origin(Point::new(x, gap)), @@ -73,7 +73,7 @@ pub fn get_icons(&self, self_size: Size, data: &LapceTabData) -> Vec let x = self_size.width - ((icons.len() + 1) as f64) * (gap + self.icon_size); let icon = LapceIcon { - icon: "split-horizontal.svg".to_string(), + icon: "split-horizontal.svg", rect: Size::new(self.icon_size, self.icon_size) .to_rect() .with_origin(Point::new(x, gap)), diff --git a/lapce-ui/src/editor/tab_header.rs b/lapce-ui/src/editor/tab_header.rs index b6eaa30f..da200793 100644 --- a/lapce-ui/src/editor/tab_header.rs +++ b/lapce-ui/src/editor/tab_header.rs @@ -152,7 +152,7 @@ fn layout( let x = size.width - ((self.icons.len() + 1) as f64) * (gap + icon_size); let icon = LapceIcon { - icon: "close.svg".to_string(), + icon: "close.svg", rect: Size::new(icon_size, icon_size) .to_rect() .with_origin(Point::new(x, gap)), @@ -167,7 +167,7 @@ fn layout( let x = size.width - ((self.icons.len() + 1) as f64) * (gap + icon_size); let icon = LapceIcon { - icon: "split-horizontal.svg".to_string(), + icon: "split-horizontal.svg", rect: Size::new(icon_size, icon_size) .to_rect() .with_origin(Point::new(x, gap)), diff --git a/lapce-ui/src/find.rs b/lapce-ui/src/find.rs index 22f4085b..f9780200 100644 --- a/lapce-ui/src/find.rs +++ b/lapce-ui/src/find.rs @@ -27,7 +27,7 @@ pub fn new(view_id: WidgetId, parent_view_id: WidgetId) -> Self { .padding((10.0, 5.0)); let icons = vec![ LapceIcon { - icon: "arrow-up.svg".to_string(), + icon: "arrow-up.svg", rect: Rect::ZERO, command: Command::new( LAPCE_COMMAND, @@ -39,7 +39,7 @@ pub fn new(view_id: WidgetId, parent_view_id: WidgetId) -> Self { ), }, LapceIcon { - icon: "arrow-down.svg".to_string(), + icon: "arrow-down.svg", rect: Rect::ZERO, command: Command::new( LAPCE_COMMAND, @@ -51,7 +51,7 @@ pub fn new(view_id: WidgetId, parent_view_id: WidgetId) -> Self { ), }, LapceIcon { - icon: "close.svg".to_string(), + icon: "close.svg", rect: Rect::ZERO, command: Command::new( LAPCE_COMMAND, diff --git a/lapce-ui/src/panel.rs b/lapce-ui/src/panel.rs index bbaa31d6..73cd170d 100644 --- a/lapce-ui/src/panel.rs +++ b/lapce-ui/src/panel.rs @@ -408,7 +408,7 @@ fn update_icons(&mut self, self_size: Size, data: &LapceTabData) { let mut icons = Vec::new(); let x = self_size.width - ((icons.len() + 1) as f64) * (gap + icon_size); let icon = LapceIcon { - icon: "close.svg".to_string(), + icon: "close.svg", rect: Size::new(icon_size, icon_size) .to_rect() .with_origin(Point::new(x, gap)), @@ -441,7 +441,7 @@ fn update_icons(&mut self, self_size: Size, data: &LapceTabData) { let x = self_size.width - ((icons.len() + 1) as f64) * (gap + icon_size); let icon = LapceIcon { - icon: icon_svg.to_string(), + icon: icon_svg, rect: Size::new(icon_size, icon_size) .to_rect() .with_origin(Point::new(x, gap)), diff --git a/lapce-ui/src/status.rs b/lapce-ui/src/status.rs index 6fea164f..c1fca4ab 100644 --- a/lapce-ui/src/status.rs +++ b/lapce-ui/src/status.rs @@ -67,7 +67,7 @@ fn panel_icons(&self, self_size: Size, data: &LapceTabData) -> Vec { }; LapceIcon { - icon: p.svg_name().to_string(), + icon: p.svg_name(), rect: Size::new(self_size.height, self_size.height) .to_rect() .with_origin(Point::new( diff --git a/lapce-ui/src/svg.rs b/lapce-ui/src/svg.rs index 88a334ed..b87df234 100644 --- a/lapce-ui/src/svg.rs +++ b/lapce-ui/src/svg.rs @@ -44,8 +44,8 @@ pub fn logo_svg() -> Svg { svgs.get(name).cloned().unwrap().unwrap() } -pub fn get_svg(name: &str) -> Option { - SVG_STORE.get_svg(name) +pub fn get_svg(name: impl AsRef) -> Option { + SVG_STORE.get_svg(name.as_ref()) } pub fn file_svg_new(path: &Path) -> Svg { diff --git a/lapce-ui/src/tab.rs b/lapce-ui/src/tab.rs index a1322504..c779ea4a 100644 --- a/lapce-ui/src/tab.rs +++ b/lapce-ui/src/tab.rs @@ -48,7 +48,7 @@ pub struct LapceIcon { pub rect: Rect, pub command: Command, - pub icon: String, + pub icon: &'static str, } pub struct LapceButton { diff --git a/lapce-ui/src/terminal.rs b/lapce-ui/src/terminal.rs index b3fd3472..89df51f7 100644 --- a/lapce-ui/src/terminal.rs +++ b/lapce-ui/src/terminal.rs @@ -331,7 +331,7 @@ fn get_icons(&self, self_size: Size, data: &LapceTabData) -> Vec { let x = self_size.width - ((icons.len() + 1) as f64) * (gap + self.icon_size); let icon = LapceIcon { - icon: "close.svg".to_string(), + icon: "close.svg", rect: Size::new(self.icon_size, self.icon_size) .to_rect() .with_origin(Point::new(x, gap)), @@ -346,7 +346,7 @@ fn get_icons(&self, self_size: Size, data: &LapceTabData) -> Vec { let x = self_size.width - ((icons.len() + 1) as f64) * (gap + self.icon_size); let icon = LapceIcon { - icon: "split-horizontal.svg".to_string(), + icon: "split-horizontal.svg", rect: Size::new(self.icon_size, self.icon_size) .to_rect() .with_origin(Point::new(x, gap)),