From 774ea940dd76e365a6f9f8ce3bcc0fc0d76755d5 Mon Sep 17 00:00:00 2001 From: edwloef Date: Sat, 7 Sep 2024 18:39:37 +0200 Subject: [PATCH] Add `text::Wrapping` support --- Cargo.lock | 49 +++++++++++++++--------------- src/widget/card.rs | 7 +++-- src/widget/number_input.rs | 4 ++- src/widget/overlay/color_picker.rs | 6 +++- src/widget/overlay/date_picker.rs | 10 +++++- src/widget/overlay/time_picker.rs | 10 +++++- src/widget/selection_list.rs | 3 +- src/widget/selection_list/list.rs | 3 +- src/widget/sidebar/sidebar.rs | 7 ++++- src/widget/tab_bar.rs | 7 ++++- 10 files changed, 72 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 688ea628..363e30df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1409,7 +1409,7 @@ dependencies = [ [[package]] name = "iced" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced.git#fd593f8fb0c8476463f9c04ae2bcc96784b8c530" +source = "git+https://github.com/iced-rs/iced.git#9426418adbaac40f584fe16b623521a3a21a1a4c" dependencies = [ "iced_core", "iced_futures", @@ -1438,7 +1438,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced.git#fd593f8fb0c8476463f9c04ae2bcc96784b8c530" +source = "git+https://github.com/iced-rs/iced.git#9426418adbaac40f584fe16b623521a3a21a1a4c" dependencies = [ "bitflags 2.6.0", "bytes", @@ -1457,7 +1457,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced.git#fd593f8fb0c8476463f9c04ae2bcc96784b8c530" +source = "git+https://github.com/iced-rs/iced.git#9426418adbaac40f584fe16b623521a3a21a1a4c" dependencies = [ "futures", "iced_core", @@ -1470,7 +1470,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced.git#fd593f8fb0c8476463f9c04ae2bcc96784b8c530" +source = "git+https://github.com/iced-rs/iced.git#9426418adbaac40f584fe16b623521a3a21a1a4c" dependencies = [ "bitflags 2.6.0", "bytemuck", @@ -1490,7 +1490,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced.git#fd593f8fb0c8476463f9c04ae2bcc96784b8c530" +source = "git+https://github.com/iced-rs/iced.git#9426418adbaac40f584fe16b623521a3a21a1a4c" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -1502,7 +1502,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced.git#fd593f8fb0c8476463f9c04ae2bcc96784b8c530" +source = "git+https://github.com/iced-rs/iced.git#9426418adbaac40f584fe16b623521a3a21a1a4c" dependencies = [ "bytes", "iced_core", @@ -1514,7 +1514,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced.git#fd593f8fb0c8476463f9c04ae2bcc96784b8c530" +source = "git+https://github.com/iced-rs/iced.git#9426418adbaac40f584fe16b623521a3a21a1a4c" dependencies = [ "bytemuck", "cosmic-text", @@ -1529,7 +1529,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced.git#fd593f8fb0c8476463f9c04ae2bcc96784b8c530" +source = "git+https://github.com/iced-rs/iced.git#9426418adbaac40f584fe16b623521a3a21a1a4c" dependencies = [ "bitflags 2.6.0", "bytemuck", @@ -1549,7 +1549,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced.git#fd593f8fb0c8476463f9c04ae2bcc96784b8c530" +source = "git+https://github.com/iced-rs/iced.git#9426418adbaac40f584fe16b623521a3a21a1a4c" dependencies = [ "iced_renderer", "iced_runtime", @@ -1563,7 +1563,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.13.0-dev" -source = "git+https://github.com/iced-rs/iced.git#fd593f8fb0c8476463f9c04ae2bcc96784b8c530" +source = "git+https://github.com/iced-rs/iced.git#9426418adbaac40f584fe16b623521a3a21a1a4c" dependencies = [ "iced_futures", "iced_graphics", @@ -1646,9 +1646,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] @@ -3345,19 +3345,20 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", @@ -3382,9 +3383,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3392,9 +3393,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", @@ -3405,9 +3406,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-timer" @@ -3560,9 +3561,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/src/widget/card.rs b/src/widget/card.rs index fe9b403e..ddf5bfda 100644 --- a/src/widget/card.rs +++ b/src/widget/card.rs @@ -15,8 +15,10 @@ use iced::{ alignment::{Horizontal, Vertical}, event, mouse::{self, Cursor}, - touch, Alignment, Border, Color, Element, Event, Length, Padding, Pixels, Point, Rectangle, - Shadow, Size, Vector, + touch, + widget::text::Wrapping, + Alignment, Border, Color, Element, Event, Length, Padding, Pixels, Point, Rectangle, Shadow, + Size, Vector, }; pub use crate::style::{ @@ -841,6 +843,7 @@ fn draw_head( vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(close_bounds.center_x(), close_bounds.center_y()), style.close_color, diff --git a/src/widget/number_input.rs b/src/widget/number_input.rs index a2b22d6b..b3f2587b 100644 --- a/src/widget/number_input.rs +++ b/src/widget/number_input.rs @@ -15,7 +15,7 @@ use iced::{ event, keyboard, mouse::{self, Cursor}, widget::{ - text::LineHeight, + text::{LineHeight, Wrapping}, text_input::{self, cursor, Value}, Column, Container, Row, Text, }, @@ -752,6 +752,7 @@ where vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(dec_bounds.center_x(), dec_bounds.center_y()), decrease_btn_style.icon_color, @@ -786,6 +787,7 @@ where vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(inc_bounds.center_x(), inc_bounds.center_y()), increase_btn_style.icon_color, diff --git a/src/widget/overlay/color_picker.rs b/src/widget/overlay/color_picker.rs index 4b98f01d..7fabde92 100644 --- a/src/widget/overlay/color_picker.rs +++ b/src/widget/overlay/color_picker.rs @@ -27,7 +27,8 @@ use iced::{ touch, widget::{ canvas::{self, LineCap, Path, Stroke}, - text, Button, Column, Row, + text::{self, Wrapping}, + Button, Column, Row, }, Alignment, Border, Color, Element, Event, Length, Padding, Pixels, Point, Rectangle, Renderer, Shadow, Size, Vector, @@ -1427,6 +1428,7 @@ fn rgba_color( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new( label_layout.bounds().center_x(), @@ -1510,6 +1512,7 @@ fn rgba_color( vertical_alignment: Vertical::Center, line_height: iced::widget::text::LineHeight::Relative(1.3), shaping: iced::widget::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new( value_layout.bounds().center_x(), @@ -1651,6 +1654,7 @@ fn hex_text( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Basic, + wrapping: Wrapping::default(), }, Point::new(bounds.center_x(), bounds.center_y()), Color { diff --git a/src/widget/overlay/date_picker.rs b/src/widget/overlay/date_picker.rs index 2bf441aa..e26b5a96 100644 --- a/src/widget/overlay/date_picker.rs +++ b/src/widget/overlay/date_picker.rs @@ -26,7 +26,10 @@ use iced::{ keyboard, mouse::{self, Cursor}, touch, - widget::{text, Button, Column, Container, Row, Text}, + widget::{ + text::{self, Wrapping}, + Button, Column, Container, Row, Text, + }, Alignment, Border, Color, @@ -1170,6 +1173,7 @@ fn month_year( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(left_bounds.center_x(), left_bounds.center_y()), style @@ -1190,6 +1194,7 @@ fn month_year( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Basic, + wrapping: Wrapping::default(), }, Point::new(center_bounds.center_x(), center_bounds.center_y()), style @@ -1210,6 +1215,7 @@ fn month_year( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(right_bounds.center_x(), right_bounds.center_y()), style @@ -1279,6 +1285,7 @@ fn day_labels( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Basic, + wrapping: Wrapping::default(), }, Point::new(bounds.center_x(), bounds.center_y()), style @@ -1371,6 +1378,7 @@ fn day_table( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Basic, + wrapping: Wrapping::default(), }, Point::new(bounds.center_x(), bounds.center_y()), if is_in_month == IsInMonth::Same { diff --git a/src/widget/overlay/time_picker.rs b/src/widget/overlay/time_picker.rs index e1919867..20eaccc0 100644 --- a/src/widget/overlay/time_picker.rs +++ b/src/widget/overlay/time_picker.rs @@ -39,7 +39,9 @@ use iced::{ widget::{ button, canvas::{self, LineCap, Path, Stroke, Text as CanvasText}, - container, text, Button, Column, Container, Row, + container, + text::{self, Wrapping}, + Button, Column, Container, Row, }, Alignment, Border, @@ -1481,6 +1483,7 @@ fn draw_digital_clock( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Basic, + wrapping: Wrapping::default(), }, Point::new(up_bounds.center_x(), up_bounds.center_y()), style @@ -1501,6 +1504,7 @@ fn draw_digital_clock( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Basic, + wrapping: Wrapping::default(), }, Point::new(center_bounds.center_x(), center_bounds.center_y()), style @@ -1524,6 +1528,7 @@ fn draw_digital_clock( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Basic, + wrapping: Wrapping::default(), }, Point::new(down_bounds.center_x(), down_bounds.center_y()), style @@ -1575,6 +1580,7 @@ fn draw_digital_clock( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Basic, + wrapping: Wrapping::default(), }, Point::new( hour_minute_separator.bounds().center_x(), @@ -1613,6 +1619,7 @@ fn draw_digital_clock( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Basic, + wrapping: Wrapping::default(), }, Point::new( minute_second_separator.bounds().center_x(), @@ -1653,6 +1660,7 @@ fn draw_digital_clock( vertical_alignment: Vertical::Center, line_height: text::LineHeight::Relative(1.3), shaping: text::Shaping::Basic, + wrapping: Wrapping::default(), }, Point::new(period.bounds().center_x(), period.bounds().center_y()), style[&StyleState::Active].text_color, diff --git a/src/widget/selection_list.rs b/src/widget/selection_list.rs index 7949bb90..c137471b 100644 --- a/src/widget/selection_list.rs +++ b/src/widget/selection_list.rs @@ -18,7 +18,7 @@ use iced::{ mouse::{self, Cursor}, widget::{ container, scrollable, - text::{self, LineHeight}, + text::{self, LineHeight, Wrapping}, Container, Scrollable, }, Border, Element, Event, Font, Length, Padding, Pixels, Rectangle, Shadow, Size, @@ -229,6 +229,7 @@ where horizontal_alignment: Horizontal::Left, vertical_alignment: Vertical::Top, shaping: text::Shaping::Advanced, + wrapping: Wrapping::default(), }; state.values[id].update(text); diff --git a/src/widget/selection_list/list.rs b/src/widget/selection_list/list.rs index 3ac5ca49..f5c58ebb 100644 --- a/src/widget/selection_list/list.rs +++ b/src/widget/selection_list/list.rs @@ -16,7 +16,7 @@ use iced::{ event, mouse::{self, Cursor}, touch, - widget::text::LineHeight, + widget::text::{LineHeight, Wrapping}, Border, Color, Element, Event, Length, Padding, Pixels, Point, Rectangle, Shadow, Size, }; use std::{ @@ -277,6 +277,7 @@ where vertical_alignment: Vertical::Center, line_height: LineHeight::default(), shaping: iced::widget::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(bounds.x, bounds.center_y()), text_color, diff --git a/src/widget/sidebar/sidebar.rs b/src/widget/sidebar/sidebar.rs index 3ca41ece..fceb0de7 100644 --- a/src/widget/sidebar/sidebar.rs +++ b/src/widget/sidebar/sidebar.rs @@ -30,7 +30,7 @@ use iced::{ mouse::{self, Cursor}, touch, widget::{ - text::{self, LineHeight}, + text::{self, LineHeight, Wrapping}, Row, Text, }, Alignment, Background, Border, Color, Element, Event, Font, Length, Padding, Pixels, Point, @@ -706,6 +706,7 @@ fn draw_tab( vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(icon_bounds.center_x(), icon_bounds.center_y()), style.icon_color, @@ -724,6 +725,7 @@ fn draw_tab( vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(text_bounds.center_x(), text_bounds.center_y()), style.text_color, @@ -753,6 +755,7 @@ fn draw_tab( vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(icon_bounds.center_x(), icon_bounds.center_y()), style.icon_color, @@ -768,6 +771,7 @@ fn draw_tab( vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(text_bounds.center_x(), text_bounds.center_y()), style.text_color, @@ -799,6 +803,7 @@ fn draw_tab( vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Basic, + wrapping: Wrapping::default(), }, Point::new(cross_bounds.center_x(), cross_bounds.center_y()), style.text_color, diff --git a/src/widget/tab_bar.rs b/src/widget/tab_bar.rs index f0276a0f..41242f7a 100644 --- a/src/widget/tab_bar.rs +++ b/src/widget/tab_bar.rs @@ -20,7 +20,7 @@ use iced::{ mouse::{self, Cursor}, touch, widget::{ - text::{self, LineHeight}, + text::{self, LineHeight, Wrapping}, Column, Row, Text, }, Alignment, Background, Border, Color, Element, Event, Font, Length, Padding, Pixels, Point, @@ -738,6 +738,7 @@ fn draw_tab( vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(icon_bounds.center_x(), icon_bounds.center_y()), style.icon_color, @@ -758,6 +759,7 @@ fn draw_tab( vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(text_bounds.center_x(), text_bounds.center_y()), style.text_color, @@ -805,6 +807,7 @@ fn draw_tab( vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(icon_bounds.center_x(), icon_bounds.center_y()), style.icon_color, @@ -821,6 +824,7 @@ fn draw_tab( vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(text_bounds.center_x(), text_bounds.center_y()), style.text_color, @@ -843,6 +847,7 @@ fn draw_tab( vertical_alignment: Vertical::Center, line_height: LineHeight::Relative(1.3), shaping: iced::advanced::text::Shaping::Advanced, + wrapping: Wrapping::default(), }, Point::new(cross_bounds.center_x(), cross_bounds.center_y()), style.text_color,