summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-12-15 06:45:20 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-12-15 06:45:20 +0100
commit232d4873ba0fb9b87d08c8d70b117e81aa7489b5 (patch)
treebfaac8e4887bbb0ea4ffa6a687151e13f4ae093e /examples
parentaa298499768bb50129cc3bd0dca6f3f858e5802e (diff)
downloadiced-232d4873ba0fb9b87d08c8d70b117e81aa7489b5.tar.gz
iced-232d4873ba0fb9b87d08c8d70b117e81aa7489b5.tar.bz2
iced-232d4873ba0fb9b87d08c8d70b117e81aa7489b5.zip
Put `svg` rendering behind a feature gate
This reduces binary size when SVG supoprt is not needed.
Diffstat (limited to 'examples')
-rw-r--r--examples/svg.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/examples/svg.rs b/examples/svg.rs
index 6dfd5202..cdf238f0 100644
--- a/examples/svg.rs
+++ b/examples/svg.rs
@@ -1,4 +1,4 @@
-use iced::{Column, Container, Element, Length, Sandbox, Settings, Svg};
+use iced::{Container, Element, Length, Sandbox, Settings};
pub fn main() {
Tiger::run(Settings::default())
@@ -21,14 +21,28 @@ impl Sandbox for Tiger {
fn update(&mut self, _message: ()) {}
fn view(&mut self) -> Element<()> {
- let content =
+ #[cfg(feature = "svg")]
+ let content = {
+ use iced::{Column, Svg};
+
Column::new()
.width(Length::Shrink)
.padding(20)
.push(Svg::new(format!(
"{}/examples/resources/tiger.svg",
env!("CARGO_MANIFEST_DIR")
- )));
+ )))
+ };
+
+ #[cfg(not(feature = "svg"))]
+ let content = {
+ use iced::{HorizontalAlignment, Text};
+
+ Text::new("You need to enable the `svg` feature!")
+ .width(Length::Shrink)
+ .horizontal_alignment(HorizontalAlignment::Center)
+ .size(30)
+ };
Container::new(content)
.width(Length::Fill)