summaryrefslogtreecommitdiff
path: root/iced_builder/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--iced_builder/src/error.rs4
-rw-r--r--iced_builder/src/icon.rs23
-rw-r--r--iced_builder/src/lib.rs1
-rw-r--r--iced_builder/src/main.rs8
-rw-r--r--iced_builder/src/views/code_view.rs6
5 files changed, 31 insertions, 11 deletions
diff --git a/iced_builder/src/error.rs b/iced_builder/src/error.rs
index ab102a6..2fea184 100644
--- a/iced_builder/src/error.rs
+++ b/iced_builder/src/error.rs
@@ -3,12 +3,10 @@ use std::sync::Arc;
use thiserror::Error;
#[derive(Debug, Clone, Error)]
+#[error(transparent)]
pub enum Error {
- #[error(transparent)]
IOError(Arc<io::Error>),
- #[error(transparent)]
SerdeError(Arc<serde_json::Error>),
- #[error(transparent)]
FormatError(Arc<rust_format::Error>),
#[error("The element tree contains no matching element")]
NonExistentElement,
diff --git a/iced_builder/src/icon.rs b/iced_builder/src/icon.rs
new file mode 100644
index 0000000..334f820
--- /dev/null
+++ b/iced_builder/src/icon.rs
@@ -0,0 +1,23 @@
+// Generated automatically by iced_fontello at build time.
+// Do not edit manually.
+// 02c7558d187cdc056fdd0e6a638ef805fa10f5955f834575e51d75acd35bc70e
+use iced::widget::{text, Text};
+use iced::Font;
+
+pub const FONT: &[u8] = include_bytes!("../fonts/icons.ttf");
+
+pub fn copy<'a>() -> Text<'a> {
+ icon("\u{F1C9}")
+}
+
+pub fn open<'a>() -> Text<'a> {
+ icon("\u{F115}")
+}
+
+pub fn save<'a>() -> Text<'a> {
+ icon("\u{1F4BE}")
+}
+
+fn icon<'a>(codepoint: &'a str) -> Text<'a> {
+ text(codepoint).font(Font::with_name("icons"))
+}
diff --git a/iced_builder/src/lib.rs b/iced_builder/src/lib.rs
index a98a379..48a2728 100644
--- a/iced_builder/src/lib.rs
+++ b/iced_builder/src/lib.rs
@@ -1,5 +1,6 @@
pub mod dialogs;
pub mod error;
+pub mod icon;
pub mod types;
pub mod views;
diff --git a/iced_builder/src/main.rs b/iced_builder/src/main.rs
index c2ac7a5..8adc15d 100644
--- a/iced_builder/src/main.rs
+++ b/iced_builder/src/main.rs
@@ -8,11 +8,12 @@ use iced::{
pane_grid::{self, Pane, PaneGrid},
pick_list, row, text_editor, Column,
},
- Alignment, Element, Length, Settings, Task, Theme,
+ Alignment, Element, Length, Task, Theme,
};
use iced_anim::{Animation, Spring};
use iced_builder::{
dialogs::{error_dialog, unsaved_changes_dialog},
+ icon,
types::{Action, DesignerPage, ElementName, Message, Project},
views::{code_view, designer_view, element_list},
};
@@ -22,10 +23,7 @@ const THEMES: &'static [Theme] = &[Theme::SolarizedDark, Theme::SolarizedLight];
fn main() -> iced::Result {
iced::application(App::title, App::update, App::view)
- .settings(Settings {
- fonts: vec![include_bytes!("../fonts/icons.ttf").as_slice().into()],
- ..Settings::default()
- })
+ .font(icon::FONT)
.theme(|state| state.theme.value().clone())
.subscription(App::subscription)
.run_with(App::new)
diff --git a/iced_builder/src/views/code_view.rs b/iced_builder/src/views/code_view.rs
index 98f0b48..5b5fd37 100644
--- a/iced_builder/src/views/code_view.rs
+++ b/iced_builder/src/views/code_view.rs
@@ -1,9 +1,10 @@
use super::style;
+use crate::icon::copy;
use crate::types::{DesignerPage, Message};
use iced::{
highlighter,
widget::{button, container, pane_grid, row, text, text_editor, tooltip, Space},
- Alignment, Font, Length, Theme,
+ Alignment, Length,
};
pub fn view<'a>(
@@ -15,8 +16,7 @@ pub fn view<'a>(
text("Generated Code"),
Space::with_width(Length::Fill),
tooltip(
- button(container(text('\u{0e801}').font(Font::with_name("editor-icons"))).center_x(30))
- .on_press(Message::CopyCode),
+ button(container(copy()).center_x(30)).on_press(Message::CopyCode),
"Copy code to clipboard",
tooltip::Position::FollowCursor
),