diff options
| author | pml68 <contact@pml68.me> | 2024-12-08 00:15:12 +0100 |
|---|---|---|
| committer | pml68 <contact@pml68.me> | 2024-12-08 00:15:12 +0100 |
| commit | 9b23b535e256840717d8b6476bfdc41d2a51e580 (patch) | |
| tree | 0b0b004124a5b884cc92f01a9f5c57fbb39235d7 /iced_builder | |
| parent | feat: animated theme switching with `iced_anim` crate (diff) | |
| download | iced-builder-9b23b535e256840717d8b6476bfdc41d2a51e580.tar.gz | |
feat: switch to `hecrj/iced_fontello` for icon font management
Diffstat (limited to '')
| -rw-r--r-- | iced_builder/Cargo.toml | 19 | ||||
| -rw-r--r-- | iced_builder/build.rs | 2 | ||||
| -rw-r--r-- | iced_builder/fonts/icons.toml | 6 | ||||
| -rw-r--r-- | iced_builder/fonts/icons.ttf | bin | 6352 -> 6348 bytes | |||
| -rw-r--r-- | iced_builder/src/error.rs | 4 | ||||
| -rw-r--r-- | iced_builder/src/icon.rs | 23 | ||||
| -rw-r--r-- | iced_builder/src/lib.rs | 1 | ||||
| -rw-r--r-- | iced_builder/src/main.rs | 8 | ||||
| -rw-r--r-- | iced_builder/src/views/code_view.rs | 6 |
9 files changed, 50 insertions, 19 deletions
diff --git a/iced_builder/Cargo.toml b/iced_builder/Cargo.toml index 5676d8a..3520046 100644 --- a/iced_builder/Cargo.toml +++ b/iced_builder/Cargo.toml @@ -11,19 +11,22 @@ keywords = ["gui", "iced"] [dependencies] iced = { version = "0.13.1", features = [ "image","svg","canvas","qr_code","advanced","tokio","highlighter"] } iced_aw = { version = "0.11.0", default-features = false, features = ["menu","color_picker"] } -iced_anim = { version = "0.1.4", features = ["derive", "serde"] } +iced_anim = { git = "https://github.com/pml68/iced_anim", branch = "main", features = ["derive", "serde"] } iced_drop = { path = "../iced_drop" } -serde = { version = "1.0.214", features = ["derive"] } -serde_json = "1.0.132" -tokio = { version = "1.41.0", features = ["fs"] } -rfd = { version = "0.15.0", default-features = false, features = ["async-std", "gtk3"] } +serde = { version = "1.0.215", features = ["derive"] } +serde_json = "1.0.133" +tokio = { version = "1.42.0", features = ["fs"] } +rfd = { version = "0.15.1", default-features = false, features = ["async-std", "gtk3"] } rust-format = "0.3.4" unique_id = "0.1.5" -indexmap = { version = "2.6.0", features = ["serde"] } -thiserror = "1.0.65" +indexmap = { version = "2.7.0", features = ["serde"] } +thiserror = "2.0.5" + +[build-dependencies] +iced_fontello = "0.13.0" [target.'cfg(windows)'.build-dependencies] -embed-resource = "2.5.0" +embed-resource = "3.0.1" windows_exe_info = "0.4" [[bin]] diff --git a/iced_builder/build.rs b/iced_builder/build.rs index 75261f8..54edc54 100644 --- a/iced_builder/build.rs +++ b/iced_builder/build.rs @@ -1,4 +1,6 @@ fn main() { + println!("cargo::rerun-if-changed=fonts/icons.toml"); + iced_fontello::build("fonts/icons.toml").expect("Build icons font"); #[cfg(windows)] { embed_resource::compile("assets/windows/iced_builder.rc", embed_resource::NONE); diff --git a/iced_builder/fonts/icons.toml b/iced_builder/fonts/icons.toml new file mode 100644 index 0000000..a70c0e7 --- /dev/null +++ b/iced_builder/fonts/icons.toml @@ -0,0 +1,6 @@ +module = "icon" + +[glyphs] +save = "entypo-floppy" +open = "fontawesome-folder-open-empty" +copy = "fontawesome-file-code" diff --git a/iced_builder/fonts/icons.ttf b/iced_builder/fonts/icons.ttf Binary files differindex 393c692..dba1266 100644 --- a/iced_builder/fonts/icons.ttf +++ b/iced_builder/fonts/icons.ttf 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 ), |
