From 1c9196c6db5ead08ef6bacb900cd3d651cd45488 Mon Sep 17 00:00:00 2001 From: Ultraxime Date: Tue, 27 Aug 2024 23:01:10 +0200 Subject: [PATCH] Mouving `iced_aw::widgets` to `iced_aw::widget` to mimic iced Updating `.vscode/lauch.json` to handle the new position of the examples Adding a pre-commit config --- .gitignore | 1 - .pre-commit-config.yaml | 49 ++ .vscode/launch.json | 671 ++++++++++-------- CHANGELOG.md | 25 +- Cargo.lock | 144 +--- Cargo.toml | 10 +- README.md | 9 +- examples/side_bar/fonts/LICENSE.txt | 2 - examples/side_bar/fonts/config.json | 2 +- examples/tabs/fonts/LICENSE.txt | 2 - examples/tabs/fonts/config.json | 2 +- src/core/icons.rs | 2 +- src/lib.rs | 49 +- src/style.rs | 2 +- src/style/badge.rs | 32 +- src/style/card.rs | 46 +- src/style/color_picker.rs | 20 +- src/style/context_menu.rs | 8 +- src/style/date_picker.rs | 20 +- src/style/menu_bar.rs | 4 +- src/style/number_input.rs | 12 +- src/style/selection_list.rs | 4 +- src/style/sidebar.rs | 20 +- src/style/status.rs | 2 +- src/style/tab_bar.rs | 20 +- src/style/time_picker.rs | 26 +- src/widget.rs | 104 +++ src/{widgets => widget}/badge.rs | 2 +- src/{widgets => widget}/card.rs | 24 +- src/{widgets => widget}/color_picker.rs | 0 src/{widgets => widget}/common.rs | 0 src/{widgets => widget}/context_menu.rs | 4 +- src/{widgets => widget}/date_picker.rs | 2 +- src/{widgets => widget}/drop_down.rs | 0 src/{widgets => widget}/grid/layout.rs | 2 +- src/{widgets => widget}/grid/mod.rs | 2 +- src/{widgets => widget}/grid/types.rs | 6 +- src/{widgets => widget}/grid/widget.rs | 0 src/{widgets => widget}/helpers.rs | 8 +- src/{widgets => widget}/menu.rs | 22 +- src/{widgets => widget}/menu/common.rs | 4 +- src/{widgets => widget}/menu/flex.rs | 0 src/{widgets => widget}/menu/menu_bar.rs | 4 +- .../menu/menu_bar_overlay.rs | 0 src/{widgets => widget}/menu/menu_tree.rs | 0 src/{widgets => widget}/number_input.rs | 9 +- .../overlay/color_picker.rs | 34 +- .../overlay/context_menu.rs | 10 +- .../overlay/date_picker.rs | 32 +- src/{widgets => widget}/overlay/mod.rs | 2 +- .../overlay/time_picker.rs | 30 +- src/{widgets => widget}/quad.rs | 2 +- src/{widgets => widget}/selection_list.rs | 2 +- .../selection_list/list.rs | 0 src/{widgets => widget}/sidebar.rs | 2 +- src/{widgets => widget}/sidebar/column.rs | 30 +- src/{widgets => widget}/sidebar/row.rs | 30 +- src/{widgets => widget}/sidebar/sidebar.rs | 62 +- src/{widgets => widget}/slide_bar.rs | 24 +- src/{widgets => widget}/spinner.rs | 0 src/{widgets => widget}/tab_bar.rs | 18 +- src/{widgets => widget}/tab_bar/tab_label.rs | 0 src/{widgets => widget}/tabs.rs | 72 +- .../tabs/tab_bar_position.rs | 8 +- src/{widgets => widget}/time_picker.rs | 4 +- src/{widgets => widget}/typed_input.rs | 0 src/{widgets => widget}/wrap.rs | 6 +- src/widgets.rs | 139 ---- 68 files changed, 913 insertions(+), 971 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 src/widget.rs rename src/{widgets => widget}/badge.rs (98%) rename src/{widgets => widget}/card.rs (96%) rename src/{widgets => widget}/color_picker.rs (100%) rename src/{widgets => widget}/common.rs (100%) rename src/{widgets => widget}/context_menu.rs (98%) rename src/{widgets => widget}/date_picker.rs (99%) rename src/{widgets => widget}/drop_down.rs (100%) rename src/{widgets => widget}/grid/layout.rs (99%) rename src/{widgets => widget}/grid/mod.rs (60%) rename src/{widgets => widget}/grid/types.rs (97%) rename src/{widgets => widget}/grid/widget.rs (100%) rename src/{widgets => widget}/helpers.rs (99%) rename src/{widgets => widget}/menu.rs (88%) rename src/{widgets => widget}/menu/common.rs (94%) rename src/{widgets => widget}/menu/flex.rs (100%) rename src/{widgets => widget}/menu/menu_bar.rs (99%) rename src/{widgets => widget}/menu/menu_bar_overlay.rs (100%) rename src/{widgets => widget}/menu/menu_tree.rs (100%) rename src/{widgets => widget}/number_input.rs (98%) rename src/{widgets => widget}/overlay/color_picker.rs (98%) rename src/{widgets => widget}/overlay/context_menu.rs (94%) rename src/{widgets => widget}/overlay/date_picker.rs (97%) rename src/{widgets => widget}/overlay/mod.rs (90%) rename src/{widgets => widget}/overlay/time_picker.rs (98%) rename src/{widgets => widget}/quad.rs (98%) rename src/{widgets => widget}/selection_list.rs (99%) rename src/{widgets => widget}/selection_list/list.rs (100%) rename src/{widgets => widget}/sidebar.rs (82%) rename src/{widgets => widget}/sidebar/column.rs (93%) rename src/{widgets => widget}/sidebar/row.rs (93%) rename src/{widgets => widget}/sidebar/sidebar.rs (96%) rename src/{widgets => widget}/slide_bar.rs (94%) rename src/{widgets => widget}/spinner.rs (100%) rename src/{widgets => widget}/tab_bar.rs (97%) rename src/{widgets => widget}/tab_bar/tab_label.rs (100%) rename src/{widgets => widget}/tabs.rs (88%) rename src/{widgets => widget}/tabs/tab_bar_position.rs (80%) rename src/{widgets => widget}/time_picker.rs (98%) rename src/{widgets => widget}/typed_input.rs (100%) rename src/{widgets => widget}/wrap.rs (98%) delete mode 100644 src/widgets.rs diff --git a/.gitignore b/.gitignore index 7fd137db..97c2e73d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,3 @@ pkg/ .idea .DS_Store .vscode/settings.json - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..199c01f6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,49 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + exclude: "(.*).pem" + - id: mixed-line-ending + exclude: "(.*).pem" + args: ['--fix=lf'] + description: Forces to replace line ending by the UNIX 'lf' character. + - id: check-case-conflict + - id: check-merge-conflict + - id: detect-private-key + - id: requirements-txt-fixer + - id: check-added-large-files + - id: check-symlinks + - id: check-toml + + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 + hooks: + - id: markdownlint + args: ['-r ~MD013'] + + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.5 + hooks: + - id: remove-crlf + - id: remove-tabs + + - repo: https://github.com/doublify/pre-commit-rust + rev: v1.0 + hooks: + - id: cargo-check + - id: clippy + + - repo: https://github.com/DevinR528/cargo-sort + rev: v1.0.9 + hooks: + - id: cargo-sort + - repo: local + hooks: + - id: rustfmt + name: rustfmt + description: Check if all files follow the rustfmt style + entry: cargo fmt --all -- --color always + language: system + pass_filenames: false diff --git a/.vscode/launch.json b/.vscode/launch.json index 7395ab2d..13744cd4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,314 +1,359 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'badge'", - "cargo": { - "args": [ - "build", - "--bin=badge", - "--package=badge" - ], - "filter": { - "name": "badge", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'slidebar'", - "cargo": { - "args": [ - "build", - "--bin=slidebar", - "--package=slidebar" - ], - "filter": { - "name": "slidebar", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'card'", - "cargo": { - "args": [ - "build", - "--bin=card", - "--package=card" - ], - "filter": { - "name": "card", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'color_picker'", - "cargo": { - "args": [ - "build", - "--bin=color_picker", - "--package=color_picker" - ], - "filter": { - "name": "color_picker", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'date_picker'", - "cargo": { - "args": [ - "build", - "--bin=date_picker", - "--package=date_picker" - ], - "filter": { - "name": "date_picker", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'grid'", - "cargo": { - "args": [ - "build", - "--bin=grid", - "--package=grid" - ], - "filter": { - "name": "grid", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'tab_bar'", - "cargo": { - "args": [ - "build", - "--bin=tab_bar", - "--package=tab_bar" - ], - "filter": { - "name": "tab_bar", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'tabs'", - "cargo": { - "args": [ - "build", - "--bin=tabs", - "--package=tabs" - ], - "filter": { - "name": "tabs", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'tabstest'", - "cargo": { - "args": [ - "build", - "--bin=tabstest", - "--package=tabstest" - ], - "filter": { - "name": "tabstest", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'widget_id'", - "cargo": { - "args": [ - "build", - "--bin=widget_id", - "--package=widget_id" - ], - "filter": { - "name": "widget_id", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'time_picker'", - "cargo": { - "args": [ - "build", - "--bin=time_picker", - "--package=time_picker" - ], - "filter": { - "name": "time_picker", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'wrap'", - "cargo": { - "args": [ - "build", - "--bin=wrap", - "--package=wrap" - ], - "filter": { - "name": "wrap", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'number_input'", - "cargo": { - "args": [ - "build", - "--bin=number_input", - "--package=number_input" - ], - "filter": { - "name": "number_input", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'selection_list'", - "cargo": { - "args": [ - "build", - "--bin=selection_list", - "--package=selection_list" - ], - "filter": { - "name": "selection_list", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'menu'", - "cargo": { - "args": [ - "build", - "--bin=menu", - "--package=menu" - ], - "filter": { - "name": "menu", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'context_menu'", - "cargo": { - "args": [ - "build", - "--bin=context_menu", - "--package=context_menu" - ], - "filter": { - "name": "context_menu", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "lldb", - "request": "launch", - "name": "Debug executable 'spinner'", - "cargo": { - "args": [ - "build", - "--bin=spinner", - "--package=spinner" - ], - "filter": { - "name": "spinner", - "kind": "bin" - } - }, - "args": [], - "cwd": "${workspaceFolder}" - }, - ] -} \ No newline at end of file + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'badge'", + "cargo": { + "args": [ + "build", + "--example=badge" + ], + "filter": { + "name": "badge", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'card'", + "cargo": { + "args": [ + "build", + "--example=card" + ], + "filter": { + "name": "card", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'color_picker'", + "cargo": { + "args": [ + "build", + "--example=color_picker" + ], + "filter": { + "name": "color_picker", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'context_menu'", + "cargo": { + "args": [ + "build", + "--example=context_menu" + ], + "filter": { + "name": "context_menu", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'date_picker'", + "cargo": { + "args": [ + "build", + "--example=date_picker" + ], + "filter": { + "name": "date_picker", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'drop_down'", + "cargo": { + "args": [ + "build", + "--example=drop_down" + ], + "filter": { + "name": "drop_down", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'grid'", + "cargo": { + "args": [ + "build", + "--example=grid" + ], + "filter": { + "name": "grid", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'menu'", + "cargo": { + "args": [ + "build", + "--example=menu" + ], + "filter": { + "name": "menu", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'number_input'", + "cargo": { + "args": [ + "build", + "--example=number_input" + ], + "filter": { + "name": "number_input", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'selection_list'", + "cargo": { + "args": [ + "build", + "--example=selection_list" + ], + "filter": { + "name": "selection_list", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'side_bar'", + "cargo": { + "args": [ + "build", + "--example=side_bar", + "--features=iced/image" + ], + "filter": { + "name": "side_bar", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'slide_bar'", + "cargo": { + "args": [ + "build", + "--example=slide_bar" + ], + "filter": { + "name": "slide_bar", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'spinner'", + "cargo": { + "args": [ + "build", + "--example=spinner" + ], + "filter": { + "name": "spinner", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'tab_bar'", + "cargo": { + "args": [ + "build", + "--example=tab_bar" + ], + "filter": { + "name": "tab_bar", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'tabs'", + "cargo": { + "args": [ + "build", + "--example=tabs", + "--features=iced/image" + ], + "filter": { + "name": "tabs", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'time_picker'", + "cargo": { + "args": [ + "build", + "--example=time_picker" + ], + "filter": { + "name": "time_picker", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'typed_input'", + "cargo": { + "args": [ + "build", + "--example=typed_input" + ], + "filter": { + "name": "typed_input", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'widget_id_return'", + "cargo": { + "args": [ + "build", + "--example=widget_id_return" + ], + "filter": { + "name": "widget_id_return", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug example 'wrap'", + "cargo": { + "args": [ + "build", + "--example=wrap" + ], + "filter": { + "name": "wrap", + "kind": "example" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + } + ], + "compounds": [ + { + "name": "Run all examples", + "configurations": [ + "Debug example 'badge'", + "Debug example 'card'", + "Debug example 'color_picker'", + "Debug example 'context_menu'", + "Debug example 'date_picker'", + "Debug example 'drop_down'", + "Debug example 'grid'", + "Debug example 'menu'", + "Debug example 'number_input'", + "Debug example 'selection_list'", + "Debug example 'side_bar'", + "Debug example 'slide_bar'", + "Debug example 'spinner'", + "Debug example 'tab_bar'", + "Debug example 'tabs'", + "Debug example 'time_picker'", + "Debug example 'typed_input'", + "Debug example 'widget_id_return'", + "Debug example 'wrap'" + ] + } + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 87b23d1b..937cf32c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Changelog + All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), @@ -7,42 +8,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changes + - Split removed in favor of Iced pane grid - Modal and Floating element removed in favor of Iced Stack. -- Segmented Button Removed use iced button. +- Segmented Button Removed use iced button. - cupertino Removed as we are not going to support these anymore. ## [0.9.3] - 2024-05-08 ### Fixed + - pub mod required being renamed to pub mod bootstrap via cfg. ## [0.9.2] - 2024-05-08 ### Fixed + - missing Bootstrap ## [0.9.1] - 2024-05-07 ### Added -- ability to disable scroll events for NumberInput. @airblast-dev + +- ability to disable scroll events for NumberInput. @airblast-dev ### Fixed + - number input over/underflow when T is set to Max and Min and T is signed. ## [0.9.0] - 2024-05-07 ### Added + - font loading example @Redhawk18 - Add font size to date_picker @Strosel ### Changed + - Replace Length with impl Into in width/height APIs @TitouanReal - use bounds directly for segmented_button @spamviech - Updated bootstrap fonts @RedHawk. - Migrated SF_UI fonts under extended fonts type removing cupertino feature requirement to use them. ### Fixed + - number input over/underflow @TitouanReal - Numberinput fixes & shortcut support @the-marenga - hide all fill_quad-calls behind intersects(viewport) or width/height>0 checks @spamviech @@ -55,19 +64,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - fixed tabs ## [0.8.0] - 2024-02-24 + ### Added + - Tab bar now follows native iced theme @Redhawk. - Added nerd fonts @RedHawk - Slider Bar widget. - DropDown Widget @wiiznokes. ### Changed + - Updated `Menu` @latidoremi. - Updated to latest iced 0.12.0. - Updated bootstrap fonts @RedHawk. - Updated to support latest winit changes for input. ### Fixed + - Tabs Icons and text not rendering correctly. - use_24h not working on time picker. - Tabs content offset not taking into consideration the Tabs height. @@ -77,29 +90,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.7.0] - 2023-08-30 ### Added + - DynamicHeight to menu bar @latidoremi . - [Breaking] Custom Style Options for all widgets. - Align Option for modal @wiiznokes . - width setting to `NumberInput`.` ### Changed + - Changed current width to content_width for `NumberInput`. - (Breaking) Removed `Icon_text`, Use `Iced::widget::Text` instead. ### Fixed + - TabBars hieght issue within container. - number input buttons not rendering correctly when they are oversized. - Fixed SFUIRounded family name to be correct. -- number input scrolling to be normal scrolling instead of inversed scrolling @Redhawk18. +- number input scrolling to be normal scrolling instead of inversed scrolling @Redhawk18. ## [0.6.0] - 2023-07-28 ### Added + - Selection List now will clear Selected if a new Item is added to the same ID location as the last and its Hash is different. - Manual Override will always be used over the internal selected if set to Some(). If the # doesn't exist it defaults Selected to None. - Added Helper functions for Widgets. ### Changed + - Breaking Selection List now Takes in Font and Manual Selected override on new_with. - Breaking Selection list Message Type is now Name((usize, T)) for on_select. - Upgraded to Latest Iced 0.10.0. @@ -107,4 +125,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Switched lazy_static to OnceCell ### Fixed + - Floating Element Position is corrected. Original position issue was due to Center_x containing both X and Width/2. diff --git a/Cargo.lock b/Cargo.lock index 4be6470f..688ea628 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,12 +303,6 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" -[[package]] -name = "bit_field" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" - [[package]] name = "bitflags" version = "1.3.2" @@ -551,12 +545,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - [[package]] name = "com" version = "0.6.0" @@ -985,22 +973,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "exr" -version = "1.72.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4" -dependencies = [ - "bit_field", - "flume", - "half", - "lebe", - "miniz_oxide", - "rayon-core", - "smallvec", - "zune-inflate", -] - [[package]] name = "fast-srgb8" version = "1.0.0" @@ -1038,15 +1010,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" -[[package]] -name = "flume" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" -dependencies = [ - "spin", -] - [[package]] name = "font-types" version = "0.6.0" @@ -1240,16 +1203,6 @@ dependencies = [ "wasi", ] -[[package]] -name = "gif" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2" -dependencies = [ - "color_quant", - "weezl", -] - [[package]] name = "gl_generator" version = "0.14.0" @@ -1463,13 +1416,12 @@ dependencies = [ "iced_renderer", "iced_widget", "iced_winit", - "image", "thiserror", ] [[package]] name = "iced_aw" -version = "0.9.3" +version = "0.9.4" dependencies = [ "cfg-if", "chrono", @@ -1526,8 +1478,6 @@ dependencies = [ "half", "iced_core", "iced_futures", - "image", - "kamadak-exif", "log", "lyon_path", "once_cell", @@ -1629,24 +1579,6 @@ dependencies = [ "winit", ] -[[package]] -name = "image" -version = "0.24.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" -dependencies = [ - "bytemuck", - "byteorder", - "color_quant", - "exr", - "gif", - "jpeg-decoder", - "num-traits", - "png", - "qoi", - "tiff", -] - [[package]] name = "indexmap" version = "2.3.0" @@ -1712,15 +1644,6 @@ dependencies = [ "libc", ] -[[package]] -name = "jpeg-decoder" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" -dependencies = [ - "rayon", -] - [[package]] name = "js-sys" version = "0.3.69" @@ -1730,15 +1653,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "kamadak-exif" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef4fc70d0ab7e5b6bafa30216a6b48705ea964cdfc29c050f2412295eba58077" -dependencies = [ - "mutate_once", -] - [[package]] name = "khronos-egl" version = "6.0.0" @@ -1766,12 +1680,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "lebe" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" - [[package]] name = "libc" version = "0.2.155" @@ -1969,12 +1877,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "mutate_once" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16cf681a23b4d0a43fc35024c176437f9dcd818db34e0f42ab456a0ee5ad497b" - [[package]] name = "naga" version = "0.19.2" @@ -2653,15 +2555,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" -[[package]] -name = "qoi" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" -dependencies = [ - "bytemuck", -] - [[package]] name = "quick-xml" version = "0.34.0" @@ -3100,15 +2993,6 @@ dependencies = [ "x11rb", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - [[package]] name = "spirv" version = "0.3.0+sdk-1.3.268.0" @@ -3219,17 +3103,6 @@ dependencies = [ "syn 2.0.72", ] -[[package]] -name = "tiff" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" -dependencies = [ - "flate2", - "jpeg-decoder", - "weezl", -] - [[package]] name = "time" version = "0.3.36" @@ -3705,12 +3578,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "weezl" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" - [[package]] name = "wgpu" version = "0.19.4" @@ -4341,15 +4208,6 @@ dependencies = [ "syn 2.0.72", ] -[[package]] -name = "zune-inflate" -version = "0.2.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" -dependencies = [ - "simd-adler32", -] - [[package]] name = "zvariant" version = "4.2.0" diff --git a/Cargo.toml b/Cargo.toml index 922c3a34..d8a83da5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iced_aw" -version = "0.9.3" +version = "0.9.4" authors = [ "Kaiden42 ", "Andrew Wheeler ", @@ -65,8 +65,8 @@ chrono = { version = "0.4.34", optional = true } itertools = { version = "0.12.1", optional = true } num-format = { version = "0.4.4", optional = true } num-traits = { version = "0.2.18", optional = true } -time = { version = "0.3.34", features = ["local-offset"], optional = true } once_cell = { version = "1.19.0", optional = true } +time = { version = "0.3.34", features = ["local-offset"], optional = true } [dependencies.iced] git = "https://github.com/iced-rs/iced.git" @@ -87,7 +87,7 @@ git = "https://github.com/iced-rs/iced.git" #rev = "b474a2b7a763dcde6a377cb409001a7b5285ee8d" version = "0.13.0-dev" #default-features = false -features = ["advanced", "wgpu", "image"] +features = ["advanced", "wgpu"] [dev-dependencies.iced_aw] path = "./" @@ -127,7 +127,7 @@ required-features = ["selection_list"] [[example]] name = "side_bar" -required-features = ["sidebar"] +required-features = ["sidebar", "iced/image"] [[example]] name = "slide_bar" @@ -143,7 +143,7 @@ required-features = ["tab_bar"] [[example]] name = "tabs" -required-features = ["tabs"] +required-features = ["tabs", "iced/image"] [[example]] name = "time_picker" diff --git a/README.md b/README.md index 1b33ebe1..e561c565 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,10 @@ This crate contains additional widgets for the GUI library [Iced](https://github Every widget is hidden by a feature gate. This allows you to cherry pick the widgets you actually need. -## Usage: +## Usage Include `iced_aw` as a dependency in your `Cargo.toml`: + ```toml [dependencies] iced = "0.12.0" @@ -32,7 +33,7 @@ iced_aw = { version = "0.9.3", default-features = false, features = [...] } ### Badge
- + ![Badge showcase](./images/showcase/badge.png)
@@ -43,7 +44,7 @@ Enable this widget with the feature `badge`. ### Card
- + ![Card showcase](./images/showcase/card.png)
@@ -65,7 +66,7 @@ Enable this widget with the feature `color_picker`. ### Date Picker
- + ![Date Picker showcase](./images/showcase/date_picker.png)
diff --git a/examples/side_bar/fonts/LICENSE.txt b/examples/side_bar/fonts/LICENSE.txt index 8fa3da36..9a34ddc3 100644 --- a/examples/side_bar/fonts/LICENSE.txt +++ b/examples/side_bar/fonts/LICENSE.txt @@ -8,5 +8,3 @@ Font license info Author: Dave Gandy License: SIL () Homepage: http://fortawesome.github.com/Font-Awesome/ - - diff --git a/examples/side_bar/fonts/config.json b/examples/side_bar/fonts/config.json index dfc22c08..58592163 100644 --- a/examples/side_bar/fonts/config.json +++ b/examples/side_bar/fonts/config.json @@ -37,4 +37,4 @@ "src": "fontawesome" } ] -} \ No newline at end of file +} diff --git a/examples/tabs/fonts/LICENSE.txt b/examples/tabs/fonts/LICENSE.txt index 8fa3da36..9a34ddc3 100644 --- a/examples/tabs/fonts/LICENSE.txt +++ b/examples/tabs/fonts/LICENSE.txt @@ -8,5 +8,3 @@ Font license info Author: Dave Gandy License: SIL () Homepage: http://fortawesome.github.com/Font-Awesome/ - - diff --git a/examples/tabs/fonts/config.json b/examples/tabs/fonts/config.json index dfc22c08..58592163 100644 --- a/examples/tabs/fonts/config.json +++ b/examples/tabs/fonts/config.json @@ -37,4 +37,4 @@ "src": "fontawesome" } ] -} \ No newline at end of file +} diff --git a/src/core/icons.rs b/src/core/icons.rs index 34bd9cd2..4abcaaf0 100644 --- a/src/core/icons.rs +++ b/src/core/icons.rs @@ -1,4 +1,4 @@ -//! The default icon font of the widgets of this library. +//! The default icon font of the widget of this library. use cfg_if::cfg_if; use iced::Font; diff --git a/src/lib.rs b/src/lib.rs index d87e42e4..2dd65133 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -//! Additional widgets for the Iced GUI library. +//! Additional widget for the Iced GUI library. //! //! # Examples //! @@ -71,7 +71,9 @@ clippy::let_unit_value )] -pub mod widgets; +pub mod widget; +#[deprecated(since = "0.9.4", note = "use `widget` instead")] +pub use widget as widgets; pub mod core; pub mod style; @@ -82,7 +84,7 @@ pub use iced::Element; mod platform { #[allow(unused_imports)] pub use crate::style; - pub use crate::widgets::helpers; + pub use crate::widget::helpers; cfg_if::cfg_if! { if #[cfg(feature = "icons")] { @@ -97,85 +99,88 @@ mod platform { #[doc(no_inline)] #[cfg(feature = "badge")] - pub use {crate::widgets::badge, badge::Badge}; + pub use {crate::widget::badge, badge::Badge}; #[doc(no_inline)] #[cfg(feature = "card")] - pub use {crate::widgets::card, card::Card}; + pub use {crate::widget::card, card::Card}; #[doc(no_inline)] #[cfg(feature = "color_picker")] - pub use {crate::widgets::color_picker, color_picker::ColorPicker}; + pub use {crate::widget::color_picker, color_picker::ColorPicker}; #[doc(no_inline)] #[cfg(feature = "date_picker")] - pub use {crate::widgets::date_picker, date_picker::DatePicker}; + pub use {crate::widget::date_picker, date_picker::DatePicker}; #[doc(no_inline)] #[cfg(feature = "grid")] - pub use crate::widgets::grid::{Grid, GridRow}; + pub use { + crate::widget::{grid, grid_row}, + grid::{Grid, GridRow}, + }; #[doc(no_inline)] #[cfg(feature = "tab_bar")] pub use { - crate::widgets::tab_bar, + crate::widget::tab_bar, tab_bar::{TabBar, TabLabel}, }; #[doc(no_inline)] #[cfg(feature = "tabs")] pub use { - crate::widgets::tabs, + crate::widget::tabs, tabs::{TabBarPosition, Tabs}, }; #[doc(no_inline)] #[cfg(feature = "time_picker")] - pub use {crate::widgets::time_picker, time_picker::TimePicker}; + pub use {crate::widget::time_picker, time_picker::TimePicker}; #[doc(no_inline)] #[cfg(feature = "wrap")] - pub use {crate::widgets::wrap, wrap::direction, wrap::Wrap}; + pub use {crate::widget::wrap, wrap::direction, wrap::Wrap}; #[doc(no_inline)] #[cfg(feature = "number_input")] - pub use {crate::widgets::number_input, number_input::NumberInput}; + pub use {crate::widget::number_input, number_input::NumberInput}; #[doc(no_inline)] #[cfg(feature = "typed_input")] - pub use {crate::widgets::typed_input, typed_input::TypedInput}; + pub use {crate::widget::typed_input, typed_input::TypedInput}; #[doc(no_inline)] #[cfg(feature = "selection_list")] - pub use {crate::widgets::selection_list, selection_list::SelectionList}; + pub use {crate::widget::selection_list, selection_list::SelectionList}; #[doc(no_inline)] #[cfg(feature = "menu")] - pub use crate::widgets::menu; + pub use {crate::widget::menu, menu::Menu, menu::MenuBar}; #[doc(no_inline)] #[cfg(feature = "quad")] - pub use crate::widgets::quad; + pub use {crate::widget::quad, quad::Quad}; #[doc(no_inline)] #[cfg(feature = "spinner")] - pub use {crate::widgets::spinner, spinner::Spinner}; + pub use {crate::widget::spinner, spinner::Spinner}; #[doc(no_inline)] #[cfg(feature = "slide_bar")] - pub use crate::widgets::SlideBar; + pub use crate::widget::SlideBar; #[doc(no_inline)] #[cfg(feature = "context_menu")] - pub use {crate::widgets::context_menu, context_menu::ContextMenu}; + pub use {crate::widget::context_menu, context_menu::ContextMenu}; #[doc(no_inline)] #[cfg(feature = "drop_down")] - pub use {crate::widgets::drop_down, drop_down::DropDown}; + pub use {crate::widget::drop_down, drop_down::DropDown}; #[doc(no_inline)] #[cfg(feature = "sidebar")] - pub use crate::widgets::sidebar; + pub use crate::widget::sidebar; } #[doc(no_inline)] diff --git a/src/style.rs b/src/style.rs index 294f4a02..7213cb4b 100644 --- a/src/style.rs +++ b/src/style.rs @@ -1,4 +1,4 @@ -//! The appearance of the widgets +//! The appearance of the widget pub mod colors; pub mod status; diff --git a/src/style/badge.rs b/src/style/badge.rs index d1b6c9b3..c271a16e 100644 --- a/src/style/badge.rs +++ b/src/style/badge.rs @@ -4,27 +4,27 @@ use super::{colors, Status, StyleFn}; use iced::{theme::palette, Background, Color, Theme}; -/// The style of a [`Badge`](crate::widgets::badge::Badge). +/// The style of a [`Badge`](crate::widget::badge::Badge). #[derive(Clone, Copy, Debug)] pub struct Style { - /// The background of the [`Badge`](crate::widgets::badge::Badge). + /// The background of the [`Badge`](crate::widget::badge::Badge). pub background: Background, - /// The border radius of the [`Badge`](crate::widgets::badge::Badge). + /// The border radius of the [`Badge`](crate::widget::badge::Badge). /// If no radius is specified the default one will be used. pub border_radius: Option, - /// The border with of the [`Badge`](crate::widgets::badge::Badge). + /// The border with of the [`Badge`](crate::widget::badge::Badge). pub border_width: f32, - /// The border color of the [`Badge`](crate::widgets::badge::Badge). + /// The border color of the [`Badge`](crate::widget::badge::Badge). pub border_color: Option, - /// The default text color of the [`Badge`](crate::widgets::badge::Badge). + /// The default text color of the [`Badge`](crate::widget::badge::Badge). pub text_color: Color, } -/// The Catalog of a [`Badge`](crate::widgets::badge::Badge). +/// The Catalog of a [`Badge`](crate::widget::badge::Badge). pub trait Catalog { ///Style for the trait to use. type Class<'a>; @@ -60,7 +60,7 @@ impl Catalog for Theme { } } -/// The primary theme of a [`Badge`](crate::widgets::badge::Badge). +/// The primary theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn primary(theme: &Theme, status: Status) -> Style { let palette = theme.extended_palette(); @@ -76,7 +76,7 @@ pub fn primary(theme: &Theme, status: Status) -> Style { } } -/// The secondary theme of a [`Badge`](crate::widgets::badge::Badge). +/// The secondary theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn secondary(theme: &Theme, status: Status) -> Style { let palette = theme.extended_palette(); @@ -92,7 +92,7 @@ pub fn secondary(theme: &Theme, status: Status) -> Style { } } -/// The success theme of a [`Badge`](crate::widgets::badge::Badge). +/// The success theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn success(theme: &Theme, status: Status) -> Style { let palette = theme.extended_palette(); @@ -108,7 +108,7 @@ pub fn success(theme: &Theme, status: Status) -> Style { } } -/// The danger theme of a [`Badge`](crate::widgets::badge::Badge). +/// The danger theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn danger(theme: &Theme, status: Status) -> Style { let palette = theme.extended_palette(); @@ -124,7 +124,7 @@ pub fn danger(theme: &Theme, status: Status) -> Style { } } -/// The warning theme of a [`Badge`](crate::widgets::badge::Badge). +/// The warning theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn warning(_theme: &Theme, status: Status) -> Style { let base = from_color(colors::WARNING, colors::BLACK); @@ -135,7 +135,7 @@ pub fn warning(_theme: &Theme, status: Status) -> Style { } } -/// The info theme of a [`Badge`](crate::widgets::badge::Badge). +/// The info theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn info(_theme: &Theme, status: Status) -> Style { let base = from_color(colors::INFO, colors::BLACK); @@ -146,7 +146,7 @@ pub fn info(_theme: &Theme, status: Status) -> Style { } } -/// The light theme of a [`Badge`](crate::widgets::badge::Badge). +/// The light theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn light(_theme: &Theme, status: Status) -> Style { let base = from_color(colors::LIGHT, colors::BLACK); @@ -157,7 +157,7 @@ pub fn light(_theme: &Theme, status: Status) -> Style { } } -/// The dark theme of a [`Badge`](crate::widgets::badge::Badge). +/// The dark theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn dark(_theme: &Theme, status: Status) -> Style { let base = from_color(colors::DARK, colors::WHITE); @@ -168,7 +168,7 @@ pub fn dark(_theme: &Theme, status: Status) -> Style { } } -/// The white theme of a [`Badge`](crate::widgets::badge::Badge). +/// The white theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn white(_theme: &Theme, status: Status) -> Style { let base = from_color(colors::WHITE, colors::BLACK); diff --git a/src/style/card.rs b/src/style/card.rs index 93ef71b6..c2057da8 100644 --- a/src/style/card.rs +++ b/src/style/card.rs @@ -1,48 +1,48 @@ -//! Displays a [`Card`](crate::widgets::Card). +//! Displays a [`Card`](crate::widget::Card). //! //! *This API requires the following crate features to be activated: card* use super::{colors, Status, StyleFn}; use iced::{Background, Color, Theme}; -/// The appearance of a [`Card`](crate::widgets::card::Card). +/// The appearance of a [`Card`](crate::widget::card::Card). #[derive(Clone, Copy, Debug)] pub struct Style { - /// The background of the [`Card`](crate::widgets::card::Card). + /// The background of the [`Card`](crate::widget::card::Card). pub background: Background, - /// The border radius of the [`Card`](crate::widgets::card::Card). + /// The border radius of the [`Card`](crate::widget::card::Card). pub border_radius: f32, - /// The border width of the [`Card`](crate::widgets::card::Card). + /// The border width of the [`Card`](crate::widget::card::Card). pub border_width: f32, - /// The border color of the [`Card`](crate::widgets::card::Card). + /// The border color of the [`Card`](crate::widget::card::Card). pub border_color: Color, - /// The background of the head of the [`Card`](crate::widgets::card::Card). + /// The background of the head of the [`Card`](crate::widget::card::Card). pub head_background: Background, - /// The text color of the head of the [`Card`](crate::widgets::card::Card). + /// The text color of the head of the [`Card`](crate::widget::card::Card). pub head_text_color: Color, - /// The background of the body of the [`Card`](crate::widgets::card::Card). + /// The background of the body of the [`Card`](crate::widget::card::Card). pub body_background: Background, - /// The text color of the body of the [`Card`](crate::widgets::card::Card). + /// The text color of the body of the [`Card`](crate::widget::card::Card). pub body_text_color: Color, - /// The background of the foot of the [`Card`](crate::widgets::card::Card). + /// The background of the foot of the [`Card`](crate::widget::card::Card). pub foot_background: Background, - /// The text color of the foot of the [`Card`](crate::widgets::card::Card). + /// The text color of the foot of the [`Card`](crate::widget::card::Card). pub foot_text_color: Color, - /// The color of the close icon of the [`Card`](crate::widgets::card::Card). + /// The color of the close icon of the [`Card`](crate::widget::card::Card). pub close_color: Color, } -/// The appearance of a [`Card`](crate::widgets::card::Card). +/// The appearance of a [`Card`](crate::widget::card::Card). pub trait Catalog { ///Style for the trait to use. type Class<'a>; @@ -84,55 +84,55 @@ impl Catalog for Theme { } } -/// The primary theme of a [`Card`](crate::widgets::card::Card). +/// The primary theme of a [`Card`](crate::widget::card::Card). #[must_use] pub fn primary(theme: &Theme, _status: Status) -> Style { backing_with_text(theme, colors::PRIMARY, colors::WHITE) } -/// The secondary theme of a [`Card`](crate::widgets::card::Card). +/// The secondary theme of a [`Card`](crate::widget::card::Card). #[must_use] pub fn secondary(theme: &Theme, _status: Status) -> Style { backing_with_text(theme, colors::SECONDARY, colors::WHITE) } -/// The success theme of a [`Card`](crate::widgets::card::Card). +/// The success theme of a [`Card`](crate::widget::card::Card). #[must_use] pub fn success(theme: &Theme, _status: Status) -> Style { backing_with_text(theme, colors::SUCCESS, colors::WHITE) } -/// The danger theme of a [`Card`](crate::widgets::card::Card). +/// The danger theme of a [`Card`](crate::widget::card::Card). #[must_use] pub fn danger(theme: &Theme, _status: Status) -> Style { backing_with_text(theme, colors::DANGER, colors::WHITE) } -/// The warning theme of a [`Card`](crate::widgets::card::Card). +/// The warning theme of a [`Card`](crate::widget::card::Card). #[must_use] pub fn warning(theme: &Theme, _status: Status) -> Style { backing_only(theme, colors::WARNING) } -/// The info theme of a [`Card`](crate::widgets::card::Card). +/// The info theme of a [`Card`](crate::widget::card::Card). #[must_use] pub fn info(theme: &Theme, _status: Status) -> Style { backing_only(theme, colors::INFO) } -/// The light theme of a [`Card`](crate::widgets::card::Card). +/// The light theme of a [`Card`](crate::widget::card::Card). #[must_use] pub fn light(theme: &Theme, _status: Status) -> Style { backing_only(theme, colors::LIGHT) } -/// The dark theme of a [`Card`](crate::widgets::card::Card). +/// The dark theme of a [`Card`](crate::widget::card::Card). #[must_use] pub fn dark(theme: &Theme, _status: Status) -> Style { backing_with_text(theme, colors::DARK, colors::WHITE) } -/// The white theme of a [`Card`](crate::widgets::card::Card). +/// The white theme of a [`Card`](crate::widget::card::Card). #[must_use] pub fn white(theme: &Theme, _status: Status) -> Style { backing_only(theme, colors::WHITE) diff --git a/src/style/color_picker.rs b/src/style/color_picker.rs index 42946f9c..83b601ee 100644 --- a/src/style/color_picker.rs +++ b/src/style/color_picker.rs @@ -5,32 +5,32 @@ use super::{Status, StyleFn}; use iced::{Background, Color, Theme}; -/// The appearance of a [`ColorPicker`](crate::widgets::ColorPicker). +/// The appearance of a [`ColorPicker`](crate::widget::ColorPicker). #[derive(Clone, Copy, Debug)] pub struct Style { - /// The background of the [`ColorPicker`](crate::widgets::ColorPicker). + /// The background of the [`ColorPicker`](crate::widget::ColorPicker). pub background: Background, - /// The border radius of the [`ColorPicker`](crate::widgets::ColorPicker). + /// The border radius of the [`ColorPicker`](crate::widget::ColorPicker). pub border_radius: f32, - /// The border with of the [`ColorPicker`](crate::widgets::ColorPicker). + /// The border with of the [`ColorPicker`](crate::widget::ColorPicker). pub border_width: f32, - /// The border color of the [`ColorPicker`](crate::widgets::ColorPicker). + /// The border color of the [`ColorPicker`](crate::widget::ColorPicker). pub border_color: Color, - /// The border radius of the bars of the [`ColorPicker`](crate::widgets::ColorPicker). + /// The border radius of the bars of the [`ColorPicker`](crate::widget::ColorPicker). pub bar_border_radius: f32, - /// The border width of the bars of the [`ColorPicker`](crate::widgets::ColorPicker). + /// The border width of the bars of the [`ColorPicker`](crate::widget::ColorPicker). pub bar_border_width: f32, - /// The border color of the bars of the [`ColorPicker`](crate::widgets::ColorPicker). + /// The border color of the bars of the [`ColorPicker`](crate::widget::ColorPicker). pub bar_border_color: Color, } -/// The Catalog of a [`ColorPicker`](crate::widgets::ColorPicker). +/// The Catalog of a [`ColorPicker`](crate::widget::ColorPicker). pub trait Catalog { ///Style for the trait to use. type Class<'a>; @@ -54,7 +54,7 @@ impl Catalog for Theme { } } -/// The primary theme of a [`Badge`](crate::widgets::badge::Badge). +/// The primary theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn primary(theme: &Theme, status: Status) -> Style { let palette = theme.extended_palette(); diff --git a/src/style/context_menu.rs b/src/style/context_menu.rs index f84e7dc0..58884c95 100644 --- a/src/style/context_menu.rs +++ b/src/style/context_menu.rs @@ -4,10 +4,10 @@ use super::{Status, StyleFn}; use iced::{Background, Color, Theme}; -/// The style of a [`ContextMenu`](crate::widgets::ContextMenu). +/// The style of a [`ContextMenu`](crate::widget::ContextMenu). #[derive(Clone, Copy, Debug)] pub struct Style { - /// The background of the [`ContextMenu`](crate::widgets::ContextMenu). + /// The background of the [`ContextMenu`](crate::widget::ContextMenu). /// /// This is used to color the backdrop of the modal. pub background: Background, @@ -21,7 +21,7 @@ impl Default for Style { } } -/// The Catalog of a [`ContextMenu`](crate::widgets::ContextMenu). +/// The Catalog of a [`ContextMenu`](crate::widget::ContextMenu). pub trait Catalog { ///Style for the trait to use. type Class<'a>; @@ -45,7 +45,7 @@ impl Catalog for Theme { } } -/// The primary theme of a [`ContextMenu`](crate::widgets::ContextMenu). +/// The primary theme of a [`ContextMenu`](crate::widget::ContextMenu). #[must_use] pub fn primary(theme: &Theme, _status: Status) -> Style { let palette = theme.extended_palette(); diff --git a/src/style/date_picker.rs b/src/style/date_picker.rs index 395d333a..7e1e8d45 100644 --- a/src/style/date_picker.rs +++ b/src/style/date_picker.rs @@ -4,34 +4,34 @@ use super::{Status, StyleFn}; use iced::{Background, Color, Theme}; -/// The appearance of a [`DatePicker`](crate::widgets::DatePicker). +/// The appearance of a [`DatePicker`](crate::widget::DatePicker). #[derive(Clone, Copy, Debug)] pub struct Style { - /// The background of the [`DatePicker`](crate::widgets::DatePicker). + /// The background of the [`DatePicker`](crate::widget::DatePicker). pub background: Background, - /// The border radius of the [`DatePicker`](crate::widgets::DatePicker). + /// The border radius of the [`DatePicker`](crate::widget::DatePicker). pub border_radius: f32, - /// The border with of the [`DatePicker`](crate::widgets::DatePicker). + /// The border with of the [`DatePicker`](crate::widget::DatePicker). pub border_width: f32, - /// The border color of the [`DatePicker`](crate::widgets::DatePicker). + /// The border color of the [`DatePicker`](crate::widget::DatePicker). pub border_color: Color, - /// The text color of the [`DatePicker`](crate::widgets::DatePicker). + /// The text color of the [`DatePicker`](crate::widget::DatePicker). pub text_color: Color, /// The attenuated color of the days which are not in the selected month - /// of the [`DatePicker`](crate::widgets::DatePicker). + /// of the [`DatePicker`](crate::widget::DatePicker). pub text_attenuated_color: Color, /// The background of the days in the calender of the - /// [`DatePicker`](crate::widgets::DatePicker). + /// [`DatePicker`](crate::widget::DatePicker). pub day_background: Background, } -/// The Catalog of a [`DatePicker`](crate::widgets::DatePicker). +/// The Catalog of a [`DatePicker`](crate::widget::DatePicker). pub trait Catalog { ///Style for the trait to use. type Class<'a>; @@ -55,7 +55,7 @@ impl Catalog for Theme { } } -/// The primary theme of a [`Badge`](crate::widgets::badge::Badge). +/// The primary theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn primary(theme: &Theme, status: Status) -> Style { let palette = theme.extended_palette(); diff --git a/src/style/menu_bar.rs b/src/style/menu_bar.rs index e5a6b38c..37ca6a5f 100644 --- a/src/style/menu_bar.rs +++ b/src/style/menu_bar.rs @@ -60,7 +60,7 @@ impl std::default::Default for Style { } } -/// The Catalog of a [`Menu`](crate::widgets::menu::Menu). +/// The Catalog of a [`Menu`](crate::widget::menu::Menu). pub trait Catalog { ///Style for the trait to use. type Class<'a>; @@ -84,7 +84,7 @@ impl Catalog for Theme { } } -/// The primary theme of a [`Menu`](crate::widgets::menu::Menu). +/// The primary theme of a [`Menu`](crate::widget::menu::Menu). #[must_use] pub fn primary(theme: &Theme, _status: Status) -> Style { let palette = theme.extended_palette(); diff --git a/src/style/number_input.rs b/src/style/number_input.rs index e5d2656a..c7d69f4f 100644 --- a/src/style/number_input.rs +++ b/src/style/number_input.rs @@ -5,12 +5,12 @@ use super::{Status, StyleFn}; use iced::{widget, Background, Color, Theme}; -/// The appearance of a [`NumberInput`](crate::widgets::number_input::NumberInput). +/// The appearance of a [`NumberInput`](crate::widget::number_input::NumberInput). #[derive(Clone, Copy, Debug)] pub struct Style { - /// The background of the [`NumberInput`](crate::widgets::number_input::NumberInput). + /// The background of the [`NumberInput`](crate::widget::number_input::NumberInput). pub button_background: Option, - /// The Color of the arrows of [`NumberInput`](crate::widgets::number_input::NumberInput). + /// The Color of the arrows of [`NumberInput`](crate::widget::number_input::NumberInput). pub icon_color: Color, } @@ -23,7 +23,7 @@ impl Default for Style { } } -/// The Catalog of a [`NumberInput`](crate::widgets::number_input::NumberInput). +/// The Catalog of a [`NumberInput`](crate::widget::number_input::NumberInput). pub trait Catalog { ///Style for the trait to use. type Class<'a>; @@ -47,7 +47,7 @@ impl Catalog for Theme { } } -/// The Extended Catalog of a [`NumberInput`](crate::widgets::number_input::NumberInput). +/// The Extended Catalog of a [`NumberInput`](crate::widget::number_input::NumberInput). pub trait ExtendedCatalog: widget::text_input::Catalog + widget::container::Catalog + widget::text::Catalog + self::Catalog { @@ -67,7 +67,7 @@ impl ExtendedCatalog for Theme { } } -/// The primary theme of a [`Badge`](crate::widgets::badge::Badge). +/// The primary theme of a [`Badge`](crate::widget::badge::Badge). #[must_use] pub fn primary(theme: &Theme, status: Status) -> Style { let palette = theme.extended_palette(); diff --git a/src/style/selection_list.rs b/src/style/selection_list.rs index 34497789..dda3e836 100644 --- a/src/style/selection_list.rs +++ b/src/style/selection_list.rs @@ -29,7 +29,7 @@ impl std::default::Default for Style { } } -/// The Catalog of a [`Badge`](crate::widgets::selection_list::SelectionList). +/// The Catalog of a [`Badge`](crate::widget::selection_list::SelectionList). pub trait Catalog { ///Style for the trait to use. type Class<'a>; @@ -53,7 +53,7 @@ impl Catalog for Theme { } } -/// The primary theme of a [`Badge`](crate::widgets::selection_list::SelectionList). +/// The primary theme of a [`Badge`](crate::widget::selection_list::SelectionList). #[must_use] pub fn primary(_theme: &Theme, status: Status) -> Style { let base = Style::default(); diff --git a/src/style/sidebar.rs b/src/style/sidebar.rs index 50af00dd..02f83ce5 100644 --- a/src/style/sidebar.rs +++ b/src/style/sidebar.rs @@ -1,12 +1,12 @@ -//! This is the style for [`Sidebar`](crate::widgets::sidebar::Sidebar) and -//! [`SidebarWithContent`](crate::widgets::sidebar::SidebarWithContent). +//! This is the style for [`Sidebar`](crate::widget::sidebar::Sidebar) and +//! [`SidebarWithContent`](crate::widget::sidebar::SidebarWithContent). //! //! *This API requires the following crate features to be activated: `sidebar`* use super::{Status, StyleFn}; use iced::{border::Radius, Background, Color, Theme}; -/// The appearance of a [`Sidebar`](crate::widgets::sidebar::Sidebar). +/// The appearance of a [`Sidebar`](crate::widget::sidebar::Sidebar). #[derive(Clone, Copy, Debug)] pub struct Style { /// The background of the sidebar. @@ -56,7 +56,7 @@ impl Default for Style { } } } -/// The Catalog of a [`Sidebar`](crate::widgets::sidebar::Sidebar). +/// The Catalog of a [`Sidebar`](crate::widget::sidebar::Sidebar). pub trait Catalog { ///Style for the trait to use. type Class<'a>; @@ -80,7 +80,7 @@ impl Catalog for Theme { } } -/// The primary theme of a [`Sidebar`](crate::widgets::sidebar::Sidebar). +/// The primary theme of a [`Sidebar`](crate::widget::sidebar::Sidebar). #[must_use] pub fn primary(theme: &Theme, status: Status) -> Style { let mut base = Style::default(); @@ -103,7 +103,7 @@ pub fn primary(theme: &Theme, status: Status) -> Style { base } -/// The dark theme of a [`Sidebar`](crate::widgets::sidebar::Sidebar). +/// The dark theme of a [`Sidebar`](crate::widget::sidebar::Sidebar). #[must_use] pub fn dark(_theme: &Theme, status: Status) -> Style { let mut base = Style { @@ -121,7 +121,7 @@ pub fn dark(_theme: &Theme, status: Status) -> Style { base } -/// The red theme of a [`Sidebar`](crate::widgets::sidebar::Sidebar). +/// The red theme of a [`Sidebar`](crate::widget::sidebar::Sidebar). #[must_use] pub fn red(_theme: &Theme, status: Status) -> Style { let mut base = Style { @@ -142,7 +142,7 @@ pub fn red(_theme: &Theme, status: Status) -> Style { base } -/// The blue theme of a [`Sidebar`](crate::widgets::sidebar::Sidebar). +/// The blue theme of a [`Sidebar`](crate::widget::sidebar::Sidebar). #[must_use] pub fn blue(_theme: &Theme, status: Status) -> Style { let mut base = Style { @@ -161,7 +161,7 @@ pub fn blue(_theme: &Theme, status: Status) -> Style { base } -/// The blue theme of a [`Sidebar`](crate::widgets::sidebar::Sidebar). +/// The blue theme of a [`Sidebar`](crate::widget::sidebar::Sidebar). #[must_use] pub fn green(_theme: &Theme, status: Status) -> Style { let mut base = Style { @@ -185,7 +185,7 @@ pub fn green(_theme: &Theme, status: Status) -> Style { base } -/// The purple theme of a [`Sidebar`](crate::widgets::sidebar::Sidebar). +/// The purple theme of a [`Sidebar`](crate::widget::sidebar::Sidebar). #[must_use] pub fn purple(_theme: &Theme, status: Status) -> Style { let mut base = Style { diff --git a/src/style/status.rs b/src/style/status.rs index c6a91d87..d6d51959 100644 --- a/src/style/status.rs +++ b/src/style/status.rs @@ -17,5 +17,5 @@ pub enum Status { Selected, } -/// The style function of widgets. +/// The style function of widget. pub type StyleFn<'a, Theme, Style> = Box Style + 'a>; diff --git a/src/style/tab_bar.rs b/src/style/tab_bar.rs index 0fdeb1c8..794eb209 100644 --- a/src/style/tab_bar.rs +++ b/src/style/tab_bar.rs @@ -1,15 +1,15 @@ -//! Displays a [`TabBar`](crate::widgets::tab_bar::TabBar) to select the content +//! Displays a [`TabBar`](crate::widget::tab_bar::TabBar) to select the content //! to be displayed. //! //! You have to manage the logic to show the contend by yourself or you may want -//! to use the [`Tabs`](crate::widgets::tabs::Tabs) widget instead. +//! to use the [`Tabs`](crate::widget::tabs::Tabs) widget instead. //! //! *This API requires the following crate features to be activated: `tab_bar`* use super::{Status, StyleFn}; use iced::{border::Radius, Background, Color, Theme}; -/// The appearance of a [`TabBar`](crate::widgets::tab_bar::TabBar). +/// The appearance of a [`TabBar`](crate::widget::tab_bar::TabBar). #[derive(Clone, Copy, Debug)] pub struct Style { /// The background of the tab bar. @@ -59,7 +59,7 @@ impl Default for Style { } } } -/// The Catalog of a [`TabBar`](crate::widgets::tab_bar::TabBar). +/// The Catalog of a [`TabBar`](crate::widget::tab_bar::TabBar). pub trait Catalog { ///Style for the trait to use. type Class<'a>; @@ -83,7 +83,7 @@ impl Catalog for Theme { } } -/// The primary theme of a [`TabBar`](crate::widgets::tab_bar::TabBar). +/// The primary theme of a [`TabBar`](crate::widget::tab_bar::TabBar). #[must_use] pub fn primary(theme: &Theme, status: Status) -> Style { let mut base = Style::default(); @@ -106,7 +106,7 @@ pub fn primary(theme: &Theme, status: Status) -> Style { base } -/// The dark theme of a [`TabBar`](crate::widgets::tab_bar::TabBar). +/// The dark theme of a [`TabBar`](crate::widget::tab_bar::TabBar). #[must_use] pub fn dark(_theme: &Theme, status: Status) -> Style { let mut base = Style { @@ -124,7 +124,7 @@ pub fn dark(_theme: &Theme, status: Status) -> Style { base } -/// The red theme of a [`TabBar`](crate::widgets::tab_bar::TabBar). +/// The red theme of a [`TabBar`](crate::widget::tab_bar::TabBar). #[must_use] pub fn red(_theme: &Theme, status: Status) -> Style { let mut base = Style { @@ -145,7 +145,7 @@ pub fn red(_theme: &Theme, status: Status) -> Style { base } -/// The blue theme of a [`TabBar`](crate::widgets::tab_bar::TabBar). +/// The blue theme of a [`TabBar`](crate::widget::tab_bar::TabBar). #[must_use] pub fn blue(_theme: &Theme, status: Status) -> Style { let mut base = Style { @@ -164,7 +164,7 @@ pub fn blue(_theme: &Theme, status: Status) -> Style { base } -/// The blue theme of a [`TabBar`](crate::widgets::tab_bar::TabBar). +/// The blue theme of a [`TabBar`](crate::widget::tab_bar::TabBar). #[must_use] pub fn green(_theme: &Theme, status: Status) -> Style { let mut base = Style { @@ -188,7 +188,7 @@ pub fn green(_theme: &Theme, status: Status) -> Style { base } -/// The purple theme of a [`TabBar`](crate::widgets::tab_bar::TabBar). +/// The purple theme of a [`TabBar`](crate::widget::tab_bar::TabBar). #[must_use] pub fn purple(_theme: &Theme, status: Status) -> Style { let mut base = Style { diff --git a/src/style/time_picker.rs b/src/style/time_picker.rs index 44937b74..fcc8ce89 100644 --- a/src/style/time_picker.rs +++ b/src/style/time_picker.rs @@ -5,46 +5,46 @@ use super::{Status, StyleFn}; use iced::{Background, Color, Theme}; -/// The style of a [`TimePicker`](crate::widgets::TimePicker). +/// The style of a [`TimePicker`](crate::widget::TimePicker). #[derive(Clone, Copy, Debug)] pub struct Style { - /// The background of the [`TimePicker`](crate::widgets::TimePicker). + /// The background of the [`TimePicker`](crate::widget::TimePicker). pub background: Background, - /// The border radius of the [`TimePicker`](crate::widgets::TimePicker). + /// The border radius of the [`TimePicker`](crate::widget::TimePicker). pub border_radius: f32, - /// The border width of the [`TimePicker`](crate::widgets::TimePicker). + /// The border width of the [`TimePicker`](crate::widget::TimePicker). pub border_width: f32, - /// The border color of the [`TimePicker`](crate::widgets::TimePicker). + /// The border color of the [`TimePicker`](crate::widget::TimePicker). pub border_color: Color, - /// The text color of the [`TimePicker`](crate::widgets::TimePicker). + /// The text color of the [`TimePicker`](crate::widget::TimePicker). pub text_color: Color, /// The color of the clock numbers of the - /// [`TimePicker`](crate::widgets::TimePicker). + /// [`TimePicker`](crate::widget::TimePicker). pub clock_number_color: Color, /// The background of the clock numbers of the - /// [`TimePicker`](crate::widgets::TimePicker). + /// [`TimePicker`](crate::widget::TimePicker). pub clock_number_background: Color, /// The color of the dots on the clock of the - /// [`TimePicker`](crate::widgets::TimePicker). + /// [`TimePicker`](crate::widget::TimePicker). pub clock_dots_color: Color, /// The color of the hands of the clock of the - /// [`TimePicker`](crate::widgets::TimePicker). + /// [`TimePicker`](crate::widget::TimePicker). pub clock_hand_color: Color, /// The with of the hands of the clock of the - /// [`TimePicker](crate::widgets::TimePicker). + /// [`TimePicker](crate::widget::TimePicker). pub clock_hand_width: f32, } -/// The Catalog of a [`TimePicker`](crate::widgets::TimePicker). +/// The Catalog of a [`TimePicker`](crate::widget::TimePicker). pub trait Catalog { ///Style for the trait to use. type Class<'a>; @@ -68,7 +68,7 @@ impl Catalog for Theme { } } -/// The primary theme of a [`TimePicker`](crate::widgets::TimePicker). +/// The primary theme of a [`TimePicker`](crate::widget::TimePicker). #[must_use] pub fn primary(theme: &Theme, status: Status) -> Style { let palette = theme.extended_palette(); diff --git a/src/widget.rs b/src/widget.rs new file mode 100644 index 00000000..44219783 --- /dev/null +++ b/src/widget.rs @@ -0,0 +1,104 @@ +//! Stateless, pure widget for iced +//use iced_widget::{renderer, style}; +pub mod helpers; +#[allow(unused_imports)] +pub use helpers::*; + +pub mod overlay; + +pub mod common; + +pub use common::InnerBounds; + +#[cfg(feature = "badge")] +pub mod badge; +#[cfg(feature = "badge")] +pub use badge::Badge; + +#[cfg(feature = "number_input")] +pub mod number_input; +#[cfg(feature = "number_input")] +pub use number_input::NumberInput; + +#[cfg(feature = "typed_input")] +pub mod typed_input; +#[cfg(feature = "typed_input")] +pub use typed_input::TypedInput; + +#[cfg(feature = "card")] +pub mod card; +#[cfg(feature = "card")] +pub use card::Card; + +#[cfg(feature = "color_picker")] +pub mod color_picker; +#[cfg(feature = "color_picker")] +pub use color_picker::ColorPicker; + +#[cfg(feature = "date_picker")] +pub mod date_picker; +#[cfg(feature = "date_picker")] +pub use date_picker::DatePicker; + +#[cfg(feature = "selection_list")] +pub mod selection_list; +#[cfg(feature = "selection_list")] +pub use selection_list::{List, SelectionList}; + +#[cfg(feature = "grid")] +pub mod grid; +#[cfg(feature = "grid")] +pub use grid::{Grid, GridRow}; + +#[cfg(feature = "tab_bar")] +pub mod tab_bar; +#[cfg(feature = "tab_bar")] +pub use tab_bar::{TabBar, TabLabel}; + +#[cfg(feature = "tabs")] +pub mod tabs; +#[cfg(feature = "tabs")] +pub use tabs::{TabBarPosition, Tabs}; + +#[cfg(feature = "time_picker")] +pub mod time_picker; +#[cfg(feature = "time_picker")] +pub use time_picker::TimePicker; + +#[cfg(feature = "wrap")] +pub mod wrap; +#[cfg(feature = "wrap")] +pub use wrap::Wrap; + +#[cfg(feature = "menu")] +pub mod menu; +#[cfg(feature = "menu")] +pub use menu::Menu; + +#[cfg(feature = "quad")] +pub mod quad; + +#[cfg(feature = "spinner")] +pub mod spinner; +#[cfg(feature = "spinner")] +pub use spinner::Spinner; + +#[cfg(feature = "context_menu")] +pub mod context_menu; +#[cfg(feature = "context_menu")] +pub use context_menu::ContextMenu; + +#[cfg(feature = "slide_bar")] +pub mod slide_bar; +#[cfg(feature = "slide_bar")] +pub use slide_bar::SlideBar; + +#[cfg(feature = "drop_down")] +pub mod drop_down; +#[cfg(feature = "drop_down")] +pub use drop_down::DropDown; + +#[cfg(feature = "sidebar")] +pub mod sidebar; +#[cfg(feature = "sidebar")] +pub use sidebar::{Sidebar, SidebarWithContent}; diff --git a/src/widgets/badge.rs b/src/widget/badge.rs similarity index 98% rename from src/widgets/badge.rs rename to src/widget/badge.rs index f94f2170..a3317602 100644 --- a/src/widgets/badge.rs +++ b/src/widget/badge.rs @@ -194,7 +194,7 @@ where layout .children() .next() - .expect("widgets: Layout should have a children layout for a badge."), + .expect("widget: Layout should have a children layout for a badge."), cursor, renderer, clipboard, diff --git a/src/widgets/card.rs b/src/widget/card.rs similarity index 96% rename from src/widgets/card.rs rename to src/widget/card.rs index d78cced0..d94ee35b 100644 --- a/src/widgets/card.rs +++ b/src/widget/card.rs @@ -318,14 +318,14 @@ where let head_layout = children .next() - .expect("widgets: Layout should have a head layout"); + .expect("widget: Layout should have a head layout"); let mut head_children = head_layout.children(); let head_status = self.head.as_widget_mut().on_event( &mut state.children[0], event.clone(), head_children .next() - .expect("widgets: Layout should have a head content layout"), + .expect("widget: Layout should have a head content layout"), cursor, renderer, clipboard, @@ -358,14 +358,14 @@ where let body_layout = children .next() - .expect("widgets: Layout should have a body layout"); + .expect("widget: Layout should have a body layout"); let mut body_children = body_layout.children(); let body_status = self.body.as_widget_mut().on_event( &mut state.children[1], event.clone(), body_children .next() - .expect("widgets: Layout should have a body content layout"), + .expect("widget: Layout should have a body content layout"), cursor, renderer, clipboard, @@ -375,7 +375,7 @@ where let foot_layout = children .next() - .expect("widgets: Layout should have a foot layout"); + .expect("widget: Layout should have a foot layout"); let mut foot_children = foot_layout.children(); let foot_status = self.foot.as_mut().map_or(event::Status::Ignored, |foot| { foot.as_widget_mut().on_event( @@ -383,7 +383,7 @@ where event, foot_children .next() - .expect("widgets: Layout should have a foot content layout"), + .expect("widget: Layout should have a foot content layout"), cursor, renderer, clipboard, @@ -410,12 +410,12 @@ where let head_layout = children .next() - .expect("widgets: Layout should have a head layout"); + .expect("widget: Layout should have a head layout"); let mut head_children = head_layout.children(); let head = head_children .next() - .expect("widgets: Layout should have a head layout"); + .expect("widget: Layout should have a head layout"); let close_layout = head_children.next(); let is_mouse_over_close = close_layout.map_or(false, |layout| { @@ -431,12 +431,12 @@ where let body_layout = children .next() - .expect("widgets: Layout should have a body layout"); + .expect("widget: Layout should have a body layout"); let mut body_children = body_layout.children(); let foot_layout = children .next() - .expect("widgets: Layout should have a foot layout"); + .expect("widget: Layout should have a foot layout"); let mut foot_children = foot_layout.children(); mouse_interaction @@ -452,7 +452,7 @@ where &state.children[1], body_children .next() - .expect("widgets: Layout should have a body content layout"), + .expect("widget: Layout should have a body content layout"), cursor, viewport, renderer, @@ -466,7 +466,7 @@ where &state.children[2], foot_children .next() - .expect("widgets: Layout should have a foot content layout"), + .expect("widget: Layout should have a foot content layout"), cursor, viewport, renderer, diff --git a/src/widgets/color_picker.rs b/src/widget/color_picker.rs similarity index 100% rename from src/widgets/color_picker.rs rename to src/widget/color_picker.rs diff --git a/src/widgets/common.rs b/src/widget/common.rs similarity index 100% rename from src/widgets/common.rs rename to src/widget/common.rs diff --git a/src/widgets/context_menu.rs b/src/widget/context_menu.rs similarity index 98% rename from src/widgets/context_menu.rs rename to src/widget/context_menu.rs index 9219634a..deb43f72 100644 --- a/src/widgets/context_menu.rs +++ b/src/widget/context_menu.rs @@ -17,7 +17,7 @@ pub use crate::style::{ status::{Status, StyleFn}, }; -use crate::widgets::overlay::ContextMenuOverlay; +use crate::widget::overlay::ContextMenuOverlay; /// A context menu /// @@ -88,7 +88,7 @@ where self } - /// Sets the class of the input of the [`Badge`]. + /// Sets the class of the input of the [`ContextMenu`]. #[must_use] pub fn class(mut self, class: impl Into>) -> Self { self.class = class.into(); diff --git a/src/widgets/date_picker.rs b/src/widget/date_picker.rs similarity index 99% rename from src/widgets/date_picker.rs rename to src/widget/date_picker.rs index 06759c88..a416f1e0 100644 --- a/src/widgets/date_picker.rs +++ b/src/widget/date_picker.rs @@ -102,7 +102,7 @@ where /// * a message that will be send when the cancel button of the [`DatePicker`] /// is pressed. /// * a function that will be called when the submit button of the [`DatePicker`] - /// is pressed, which takes the picked [`Date`](crate::date_picker::Date) value. + /// is pressed, which takes the picked [`Date`] value. pub fn new( show_picker: bool, date: impl Into, diff --git a/src/widgets/drop_down.rs b/src/widget/drop_down.rs similarity index 100% rename from src/widgets/drop_down.rs rename to src/widget/drop_down.rs diff --git a/src/widgets/grid/layout.rs b/src/widget/grid/layout.rs similarity index 99% rename from src/widgets/grid/layout.rs rename to src/widget/grid/layout.rs index cb082bd1..495d7c45 100644 --- a/src/widgets/grid/layout.rs +++ b/src/widget/grid/layout.rs @@ -74,7 +74,7 @@ where allocate_space(&mut column_widths, column_lengths, available_width); allocate_space(&mut row_heights, row_lengths, available_height); - // Lay out the widgets + // Lay out the widget create_grid_layout( tree, element_count, diff --git a/src/widgets/grid/mod.rs b/src/widget/grid/mod.rs similarity index 60% rename from src/widgets/grid/mod.rs rename to src/widget/grid/mod.rs index 026fd79f..c8c5512c 100644 --- a/src/widgets/grid/mod.rs +++ b/src/widget/grid/mod.rs @@ -1,4 +1,4 @@ -//! A container to layout widgets in a grid. +//! A container to layout widget in a grid. mod layout; mod types; diff --git a/src/widgets/grid/types.rs b/src/widget/grid/types.rs similarity index 97% rename from src/widgets/grid/types.rs rename to src/widget/grid/types.rs index 5cd6ba56..7ce99b04 100644 --- a/src/widgets/grid/types.rs +++ b/src/widget/grid/types.rs @@ -67,7 +67,7 @@ where self } - /// Sets the horizontal alignment of the widgets within their cells. Default: + /// Sets the horizontal alignment of the widget within their cells. Default: /// [`Horizontal::Left`] #[must_use] pub fn horizontal_alignment(mut self, align: Horizontal) -> Self { @@ -75,7 +75,7 @@ where self } - /// Sets the vertical alignment of the widgets within their cells. Default: + /// Sets the vertical alignment of the widget within their cells. Default: /// [`Vertical::Center`] #[must_use] pub fn vertical_alignment(mut self, align: Vertical) -> Self { @@ -228,7 +228,7 @@ where Self::default() } - /// Creates a new [`GridRow`] with the given widgets. + /// Creates a new [`GridRow`] with the given widget. #[must_use] pub fn with_elements(children: Vec>>) -> Self { Self { diff --git a/src/widgets/grid/widget.rs b/src/widget/grid/widget.rs similarity index 100% rename from src/widgets/grid/widget.rs rename to src/widget/grid/widget.rs diff --git a/src/widgets/helpers.rs b/src/widget/helpers.rs similarity index 99% rename from src/widgets/helpers.rs rename to src/widget/helpers.rs index 07fa125a..48655016 100644 --- a/src/widgets/helpers.rs +++ b/src/widget/helpers.rs @@ -26,7 +26,7 @@ macro_rules! grid { ); } -/// Creates a [`GridRow`] with the given widgets. +/// Creates a [`GridRow`] with the given widget. /// /// [`GridRow`]: crate::GridRow #[cfg(feature = "grid")] @@ -73,7 +73,7 @@ macro_rules! wrap_vertical { /// [`Item`]: crate::menu::Item /// /// Syntax: -/// ``` +/// ```ignore /// menu_items!( /// (widget) /// (widget) @@ -108,7 +108,7 @@ macro_rules! menu_items { /// [`Menu`]: crate::menu::Menu /// /// Syntax: -/// ``` +/// ```ignore /// menu!( /// (widget) /// (widget) @@ -132,7 +132,7 @@ macro_rules! menu { /// [`MenuBar`]: crate::menu::MenuBar /// /// Syntax: -/// ``` +/// ```ignore /// menu_bar!( /// (widget, menu) /// (widget, menu) diff --git a/src/widgets/menu.rs b/src/widget/menu.rs similarity index 88% rename from src/widgets/menu.rs rename to src/widget/menu.rs index 3c24a139..436153cd 100644 --- a/src/widgets/menu.rs +++ b/src/widget/menu.rs @@ -52,17 +52,17 @@ //! //! ``` //! -//! Alterwidgetsly you can use the helper macros +//! Alterwidgetly you can use the helper macros //! //! ## Example 2 //! ``` //! use iced::widget::button; -//! use iced_aw::menu::{Menu} -//! use iced_aw::{menu_bar, menu_items} +//! use iced_aw::menu::{Menu, Item, MenuBar}; +//! use iced_aw::{menu_bar, menu_items}; //! //! let menu_template = |items| Menu::new(items).max_width(180.0).offset(6.0); //! -//! let menu_bar = menu_bar!( +//! let menu_bar: MenuBar<'_, (), iced::Theme, iced::Renderer> = menu_bar!( //! (button("Menu 1"),menu_template(menu_items!( //! (button("item_1")) //! (button("item_2")) @@ -83,7 +83,7 @@ //! (button("item_2")) //! (button("item_3")) //! ))) -//! ) +//! ); //! ``` //! //! Here a menu_template function/closure is used in example 2, @@ -95,7 +95,8 @@ //! ## Example 3 //! //! ``` -//! use iced_aw::{menu}; +//! use iced::widget::button; +//! use iced_aw::{menu, Menu}; //! //! macro_rules! menu_template { //! ($($x:tt)+) => { @@ -104,7 +105,7 @@ //! } //! //! // then you can just write -//! let m = menu_template!( +//! let m: Menu<'_, (), iced::Theme, iced::Renderer> = menu_template!( //! (button("item_1")) //! (button("item_2")) //! (button("sub menu"), menu_template!( @@ -122,17 +123,20 @@ //! ## Example 4 //! //! ``` +//! use iced_aw::{menu, Menu}; +//! use iced::widget::button; +//! //! fn menu_template<'a, Message, Theme, Renderer>( //! menu: Menu<'a, Message, Theme, Renderer> //! ) -> Menu<'a, Message, Theme, Renderer> //! where -//! Theme: iced_aw::menu::StyleSheet, +//! Theme: iced_aw::menu::Catalog, //! Renderer: iced::advanced::Renderer, //! { //! menu.max_width(180.0).offset(6.0) //! } //! -//! let m = menu_template(menu!( +//! let m: Menu<'_, (), iced::Theme, iced::Renderer> = menu_template(menu!( //! (button("item_1")) //! (button("item_2")) //! (button("item_3")) diff --git a/src/widgets/menu/common.rs b/src/widget/menu/common.rs similarity index 94% rename from src/widgets/menu/common.rs rename to src/widget/menu/common.rs index 01aee96e..2e90e2df 100644 --- a/src/widgets/menu/common.rs +++ b/src/widget/menu/common.rs @@ -21,9 +21,9 @@ pub struct CloseCondition { /// useful when you want to customize the styling of each item in the path, /// or you simple want the look of the items when they are hovered over. /// -/// The downside is when some widgets in the path don't response to hovering, +/// The downside is when some widget in the path don't response to hovering, /// the path won't be fully drawn, and when you want uniform path styling -/// but some widgets response to hovering differently. +/// but some widget response to hovering differently. /// /// ## Backdrop: /// diff --git a/src/widgets/menu/flex.rs b/src/widget/menu/flex.rs similarity index 100% rename from src/widgets/menu/flex.rs rename to src/widget/menu/flex.rs diff --git a/src/widgets/menu/menu_bar.rs b/src/widget/menu/menu_bar.rs similarity index 99% rename from src/widgets/menu/menu_bar.rs rename to src/widget/menu/menu_bar.rs index 4d5b968f..f7c5453f 100644 --- a/src/widgets/menu/menu_bar.rs +++ b/src/widget/menu/menu_bar.rs @@ -114,7 +114,7 @@ where self } - /// Sets the style of the [`Badge`]. + /// Sets the style of the [`MenuBar`]. pub fn style(mut self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self where Theme::Class<'a>: From>, @@ -123,7 +123,7 @@ where self } - /// Sets the class of the input of the [`Badge`]. + /// Sets the class of the input of the [`MenuBar`]. pub fn class(mut self, class: impl Into>) -> Self { self.class = class.into(); self diff --git a/src/widgets/menu/menu_bar_overlay.rs b/src/widget/menu/menu_bar_overlay.rs similarity index 100% rename from src/widgets/menu/menu_bar_overlay.rs rename to src/widget/menu/menu_bar_overlay.rs diff --git a/src/widgets/menu/menu_tree.rs b/src/widget/menu/menu_tree.rs similarity index 100% rename from src/widgets/menu/menu_tree.rs rename to src/widget/menu/menu_tree.rs diff --git a/src/widgets/number_input.rs b/src/widget/number_input.rs similarity index 98% rename from src/widgets/number_input.rs rename to src/widget/number_input.rs index 5df21630..ae670ed8 100644 --- a/src/widgets/number_input.rs +++ b/src/widget/number_input.rs @@ -30,7 +30,7 @@ use std::{ }; use crate::style::{self, Status}; -use crate::widgets::typed_input::TypedInput; +use crate::widget::typed_input::TypedInput; pub use crate::{ core::icons::{bootstrap::icon_to_string, Bootstrap, BOOTSTRAP_FONT}, style::{ @@ -142,8 +142,9 @@ where /// Sets the minimum & maximum value (bound) of the [`NumberInput`]. /// # Example /// ``` + /// use iced_aw::widget::number_input; /// // Creates a range from -5 till 5. - /// number_input(my_value, my_message).bounds(-5..=5) + /// let input: iced_aw::NumberInput<'_, _, _, iced::Theme, iced::Renderer> = number_input(4 /* my_value */, 0..=4, |_| () /* my_message */).bounds(-5..=5); /// ``` #[must_use] pub fn bounds(mut self, bounds: impl RangeBounds) -> Self { @@ -162,8 +163,8 @@ where /// Sets the [`Font`] of the [`Text`]. /// - /// [`Font`]: core::Font - /// [`Text`]: core::widget::Text + /// [`Font`]: iced::Font + /// [`Text`]: iced::widget::Text #[allow(clippy::needless_pass_by_value)] #[must_use] pub fn font(mut self, font: Renderer::Font) -> Self { diff --git a/src/widgets/overlay/color_picker.rs b/src/widget/overlay/color_picker.rs similarity index 98% rename from src/widgets/overlay/color_picker.rs rename to src/widget/overlay/color_picker.rs index 55960522..4b98f01d 100644 --- a/src/widgets/overlay/color_picker.rs +++ b/src/widget/overlay/color_picker.rs @@ -48,7 +48,7 @@ const HUE_STEP: i32 = 1; /// The step value of the keyboard change of the RGBA color values. const RGBA_STEP: i16 = 1; -/// The overlay of the [`ColorPicker`](crate::widgets::ColorPicker). +/// The overlay of the [`ColorPicker`](crate::widget::ColorPicker). #[allow(missing_debug_implementations)] pub struct ColorPickerOverlay<'a, 'b, Message, Theme> where @@ -138,11 +138,11 @@ where let sat_value_bounds = hsv_color_children .next() - .expect("widgets: Layout should have a sat/value layout") + .expect("widget: Layout should have a sat/value layout") .bounds(); let hue_bounds = hsv_color_children .next() - .expect("widgets: Layout should have a hue layout") + .expect("widget: Layout should have a hue layout") .bounds(); match event { @@ -249,42 +249,42 @@ where let mut red_row_children = rgba_color_children .next() - .expect("widgets: Layout should have a red row layout") + .expect("widget: Layout should have a red row layout") .children(); let _ = red_row_children.next(); let red_bar_bounds = red_row_children .next() - .expect("widgets: Layout should have a red bar layout") + .expect("widget: Layout should have a red bar layout") .bounds(); let mut green_row_children = rgba_color_children .next() - .expect("widgets: Layout should have a green row layout") + .expect("widget: Layout should have a green row layout") .children(); let _ = green_row_children.next(); let green_bar_bounds = green_row_children .next() - .expect("widgets: Layout should have a green bar layout") + .expect("widget: Layout should have a green bar layout") .bounds(); let mut blue_row_children = rgba_color_children .next() - .expect("widgets: Layout should have a blue row layout") + .expect("widget: Layout should have a blue row layout") .children(); let _ = blue_row_children.next(); let blue_bar_bounds = blue_row_children .next() - .expect("widgets: Layout should have a blue bar layout") + .expect("widget: Layout should have a blue bar layout") .bounds(); let mut alpha_row_children = rgba_color_children .next() - .expect("widgets: Layout should have an alpha row layout") + .expect("widget: Layout should have an alpha row layout") .children(); let _ = alpha_row_children.next(); let alpha_bar_bounds = alpha_row_children .next() - .expect("widgets: Layout should have an alpha bar layout") + .expect("widget: Layout should have an alpha bar layout") .bounds(); match event { @@ -630,20 +630,20 @@ where // ----------- Block 1 ---------------------- let block1_layout = children .next() - .expect("widgets: Layout should have a 1. block layout"); + .expect("widget: Layout should have a 1. block layout"); let hsv_color_status = self.on_event_hsv_color(&event, block1_layout, cursor); // ----------- Block 1 end ------------------ // ----------- Block 2 ---------------------- let mut block2_children = children .next() - .expect("widgets: Layout should have a 2. block layout") + .expect("widget: Layout should have a 2. block layout") .children(); // ----------- RGB Color ----------------------- let rgba_color_layout = block2_children .next() - .expect("widgets: Layout should have a RGBA color layout"); + .expect("widget: Layout should have a RGBA color layout"); let rgba_color_status = self.on_event_rgba_color(&event, rgba_color_layout, cursor); let mut fake_messages: Vec = Vec::new(); @@ -651,12 +651,12 @@ where // ----------- Text input ---------------------- let _text_input_layout = block2_children .next() - .expect("widgets: Layout should have a hex text layout"); + .expect("widget: Layout should have a hex text layout"); // ----------- Buttons ------------------------- let cancel_button_layout = block2_children .next() - .expect("widgets: Layout should have a cancel button layout for a ColorPicker"); + .expect("widget: Layout should have a cancel button layout for a ColorPicker"); let cancel_button_status = self.cancel_button.on_event( &mut self.tree.children[0], event.clone(), @@ -670,7 +670,7 @@ where let submit_button_layout = block2_children .next() - .expect("widgets: Layout should have a submit button layout for a ColorPicker"); + .expect("widget: Layout should have a submit button layout for a ColorPicker"); let submit_button_status = self.submit_button.on_event( &mut self.tree.children[1], event, diff --git a/src/widgets/overlay/context_menu.rs b/src/widget/overlay/context_menu.rs similarity index 94% rename from src/widgets/overlay/context_menu.rs rename to src/widget/overlay/context_menu.rs index c72375dd..42f0d0e8 100644 --- a/src/widgets/overlay/context_menu.rs +++ b/src/widget/overlay/context_menu.rs @@ -20,7 +20,7 @@ use iced::{ touch, window, Border, Color, Element, Event, Point, Rectangle, Shadow, Size, }; -/// The overlay of the [`ContextMenu`](crate::widgets::ContextMenu). +/// The overlay of the [`ContextMenu`](crate::widget::ContextMenu). #[allow(missing_debug_implementations)] pub struct ContextMenuOverlay<'a, 'b, Message, Theme = iced::Theme, Renderer = iced::Renderer> where @@ -37,7 +37,7 @@ where content: Element<'a, Message, Theme, Renderer>, /// The style of the [`ContextMenuOverlay`]. class: &'a Theme::Class<'b>, - /// The state shared between [`ContextMenu`](crate::widgets::ContextMenu) and [`ContextMenuOverlay`]. + /// The state shared between [`ContextMenu`](crate::widget::ContextMenu) and [`ContextMenuOverlay`]. state: &'a mut context_menu::State, } @@ -137,7 +137,7 @@ where let content_layout = layout .children() .next() - .expect("widgets: Layout should have a content layout."); + .expect("widget: Layout should have a content layout."); // Modal self.content.as_widget().draw( @@ -163,7 +163,7 @@ where let layout_children = layout .children() .next() - .expect("widgets: Layout should have a content layout."); + .expect("widget: Layout should have a content layout."); let mut forward_event_to_children = true; @@ -237,7 +237,7 @@ where layout .children() .next() - .expect("widgets: Layout should have a content layout."), + .expect("widget: Layout should have a content layout."), cursor, viewport, renderer, diff --git a/src/widgets/overlay/date_picker.rs b/src/widget/overlay/date_picker.rs similarity index 97% rename from src/widgets/overlay/date_picker.rs rename to src/widget/overlay/date_picker.rs index 04225035..2bf441aa 100644 --- a/src/widgets/overlay/date_picker.rs +++ b/src/widget/overlay/date_picker.rs @@ -52,7 +52,7 @@ const DAY_CELL_PADDING: Padding = Padding::new(7.0); /// The spacing between the buttons. const BUTTON_SPACING: Pixels = Pixels(5.0); -/// The overlay of the [`DatePicker`](crate::widgets::DatePicker). +/// The overlay of the [`DatePicker`](crate::widget::DatePicker). #[allow(missing_debug_implementations)] pub struct DatePickerOverlay<'a, 'b, Message, Theme> where @@ -154,20 +154,20 @@ where // ----------- Month ---------------------- let month_layout = children .next() - .expect("widgets: Layout should have a month layout"); + .expect("widget: Layout should have a month layout"); let mut month_children = month_layout.children(); let left_bounds = month_children .next() - .expect("widgets: Layout should have a left month arrow layout") + .expect("widget: Layout should have a left month arrow layout") .bounds(); let _center_bounds = month_children .next() - .expect("widgets: Layout should have a center month layout") + .expect("widget: Layout should have a center month layout") .bounds(); let right_bounds = month_children .next() - .expect("widgets: Layout should have a right month arrow layout") + .expect("widget: Layout should have a right month arrow layout") .bounds(); match event { @@ -191,20 +191,20 @@ where // ----------- Year ----------------------- let year_layout = children .next() - .expect("widgets: Layout should have a year layout"); + .expect("widget: Layout should have a year layout"); let mut year_children = year_layout.children(); let left_bounds = year_children .next() - .expect("widgets: Layout should have a left year arrow layout") + .expect("widget: Layout should have a left year arrow layout") .bounds(); let _center_bounds = year_children .next() - .expect("widgets: Layout should have a center year layout") + .expect("widget: Layout should have a center year layout") .bounds(); let right_bounds = year_children .next() - .expect("widgets: Layout should have a right year arrow layout") + .expect("widget: Layout should have a right year arrow layout") .bounds(); match event { @@ -239,7 +239,7 @@ where let _day_labels_layout = children .next() - .expect("widgets: Layout should have a day label layout"); + .expect("widget: Layout should have a day label layout"); let mut status = event::Status::Ignored; @@ -562,28 +562,28 @@ where let mut date_children = children .next() - .expect("widgets: Layout should have date children") + .expect("widget: Layout should have date children") .children(); // ----------- Year/Month---------------------- let month_year_layout = date_children .next() - .expect("widgets: Layout should have a month/year layout"); + .expect("widget: Layout should have a month/year layout"); let month_year_status = self.on_event_month_year(&event, month_year_layout, cursor); // ----------- Days ---------------------- let days_layout = date_children .next() - .expect("widgets: Layout should have a days table parent") + .expect("widget: Layout should have a days table parent") .children() .next() - .expect("widgets: Layout should have a days table layout"); + .expect("widget: Layout should have a days table layout"); let days_status = self.on_event_days(&event, days_layout, cursor); // ----------- Buttons ------------------------ let cancel_button_layout = children .next() - .expect("widgets: Layout should have a cancel button layout for a DatePicker"); + .expect("widget: Layout should have a cancel button layout for a DatePicker"); let cancel_status = self.cancel_button.on_event( &mut self.tree.children[0], @@ -598,7 +598,7 @@ where let submit_button_layout = children .next() - .expect("widgets: Layout should have a submit button layout for a DatePicker"); + .expect("widget: Layout should have a submit button layout for a DatePicker"); let mut fake_messages: Vec = Vec::new(); diff --git a/src/widgets/overlay/mod.rs b/src/widget/overlay/mod.rs similarity index 90% rename from src/widgets/overlay/mod.rs rename to src/widget/overlay/mod.rs index d6ccbced..1e2cbf9f 100644 --- a/src/widgets/overlay/mod.rs +++ b/src/widget/overlay/mod.rs @@ -1,4 +1,4 @@ -//! Display interactive elements on top of other widgets. +//! Display interactive elements on top of other widget. #[cfg(feature = "color_picker")] pub mod color_picker; diff --git a/src/widgets/overlay/time_picker.rs b/src/widget/overlay/time_picker.rs similarity index 98% rename from src/widgets/overlay/time_picker.rs rename to src/widget/overlay/time_picker.rs index ec8e914a..e1919867 100644 --- a/src/widgets/overlay/time_picker.rs +++ b/src/widget/overlay/time_picker.rs @@ -69,7 +69,7 @@ const NUMBER_SIZE_PERCENTAGE: f32 = 0.15; /// The percentage size of the period. const PERIOD_SIZE_PERCENTAGE: f32 = 0.2; -/// The overlay of the [`TimePicker`](crate::widgets::TimePicker). +/// The overlay of the [`TimePicker`](crate::widget::TimePicker). #[allow(missing_debug_implementations)] pub struct TimePickerOverlay<'a, 'b, Message, Theme> where @@ -328,31 +328,31 @@ where let hour_layout = digital_clock_children .next() - .expect("widgets: Layout should have a hour layout"); + .expect("widget: Layout should have a hour layout"); let mut hour_children = hour_layout.children(); let hour_up_arrow = hour_children .next() - .expect("widgets: Layout should have an up arrow for hours"); + .expect("widget: Layout should have an up arrow for hours"); let _ = hour_children.next(); let hour_down_arrow = hour_children .next() - .expect("widgets: Layout should have a down arrow for hours"); + .expect("widget: Layout should have a down arrow for hours"); let _ = digital_clock_children.next(); let minute_layout = digital_clock_children .next() - .expect("widgets: Layout should have a minute layout"); + .expect("widget: Layout should have a minute layout"); let mut minute_children = minute_layout.children(); let minute_up_arrow = minute_children .next() - .expect("widgets: Layout should have an up arrow for minutes"); + .expect("widget: Layout should have an up arrow for minutes"); let _ = minute_children.next(); let minute_down_arrow = minute_children .next() - .expect("widgets: Layout should have a down arrow for minutes"); + .expect("widget: Layout should have a down arrow for minutes"); let calculate_time = |time: &mut NaiveTime, up_arrow: Layout<'_>, @@ -402,16 +402,16 @@ where let second_layout = digital_clock_children .next() - .expect("widgets: Layout should have a second layout"); + .expect("widget: Layout should have a second layout"); let mut second_children = second_layout.children(); let second_up_arrow = second_children .next() - .expect("widgets: Layout should have an up arrow for seconds"); + .expect("widget: Layout should have an up arrow for seconds"); let _ = second_children.next(); let second_down_arrow = second_children .next() - .expect("widgets: Layout should have a down arrow for seconds"); + .expect("widget: Layout should have a down arrow for seconds"); match event { Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left)) @@ -624,23 +624,23 @@ where // Clock canvas let clock_layout = children .next() - .expect("widgets: Layout should have a clock canvas layout"); + .expect("widget: Layout should have a clock canvas layout"); let clock_status = self.on_event_clock(&event, clock_layout, cursor); // ----------- Digital clock ------------------ let digital_clock_layout = children .next() - .expect("widgets: Layout should have a digital clock parent") + .expect("widget: Layout should have a digital clock parent") .children() .next() - .expect("widgets: Layout should have a digital clock layout"); + .expect("widget: Layout should have a digital clock layout"); let digital_clock_status = self.on_event_digital_clock(&event, digital_clock_layout, cursor); // ----------- Buttons ------------------------ let cancel_button_layout = children .next() - .expect("widgets: Layout should have a cancel button layout for a TimePicker"); + .expect("widget: Layout should have a cancel button layout for a TimePicker"); let cancel_status = self.cancel_button.on_event( &mut self.tree.children[0], @@ -655,7 +655,7 @@ where let submit_button_layout = children .next() - .expect("widgets: Layout should have a submit button layout for a TimePicker"); + .expect("widget: Layout should have a submit button layout for a TimePicker"); let mut fake_messages: Vec = Vec::new(); diff --git a/src/widgets/quad.rs b/src/widget/quad.rs similarity index 98% rename from src/widgets/quad.rs rename to src/widget/quad.rs index c1bbf5ed..679d713e 100644 --- a/src/widgets/quad.rs +++ b/src/widget/quad.rs @@ -2,7 +2,7 @@ //! //! *This API requires the following crate features to be activated: `quad`* -use crate::widgets::InnerBounds; +use crate::widget::InnerBounds; use iced::{ advanced::{ layout::{Limits, Node}, diff --git a/src/widgets/selection_list.rs b/src/widget/selection_list.rs similarity index 99% rename from src/widgets/selection_list.rs rename to src/widget/selection_list.rs index 27ee8082..7949bb90 100644 --- a/src/widgets/selection_list.rs +++ b/src/widget/selection_list.rs @@ -349,7 +349,7 @@ pub struct State { } impl State

{ - /// Creates a new [`State`], representing an unfocused [`TextInput`]. + /// Creates a new [`State`], representing an unfocused [`TextInput`](iced::widget::TextInput). pub fn new(options: &[T]) -> Self where T: Clone + Display + Eq + Hash, diff --git a/src/widgets/selection_list/list.rs b/src/widget/selection_list/list.rs similarity index 100% rename from src/widgets/selection_list/list.rs rename to src/widget/selection_list/list.rs diff --git a/src/widgets/sidebar.rs b/src/widget/sidebar.rs similarity index 82% rename from src/widgets/sidebar.rs rename to src/widget/sidebar.rs index de90e9a2..f59e3b3d 100644 --- a/src/widgets/sidebar.rs +++ b/src/widget/sidebar.rs @@ -1,4 +1,4 @@ -//! Contains the sidebar related widgets and data enums. +//! Contains the sidebar related widget and data enums. #[allow(clippy::module_inception)] pub mod sidebar; diff --git a/src/widgets/sidebar/column.rs b/src/widget/sidebar/column.rs similarity index 93% rename from src/widgets/sidebar/column.rs rename to src/widget/sidebar/column.rs index 539b93ae..765606f2 100644 --- a/src/widgets/sidebar/column.rs +++ b/src/widget/sidebar/column.rs @@ -36,19 +36,19 @@ impl<'a, Message: 'a, Theme: 'a, Renderer> FlushColumn<'a, Message, Theme, Rende where Renderer: iced::advanced::Renderer + 'a, { - /// Creates an empty [`Column`]. + /// Creates an empty [`FlushColumn`]. #[must_use] pub fn new() -> Self { Self::from_vec(Vec::new()) } - /// Creates a [`Column`] with the given capacity. + /// Creates a [`FlushColumn`] with the given capacity. #[must_use] pub fn with_capacity(capacity: usize) -> Self { Self::from_vec(Vec::with_capacity(capacity)) } - /// Creates a [`Column`] with the given elements. + /// Creates a [`FlushColumn`] with the given elements. #[must_use] pub fn with_children( children: impl IntoIterator>, @@ -57,13 +57,13 @@ where Self::with_capacity(iterator.size_hint().0).extend(iterator) } - /// Creates a [`Column`] from an already allocated [`Vec`]. + /// Creates a [`FlushColumn`] from an already allocated [`Vec`]. /// - /// Keep in mind that the [`Column`] will not inspect the [`Vec`], which means + /// Keep in mind that the [`FlushColumn`] will not inspect the [`Vec`], which means /// it won't automatically adapt to the sizing strategy of its contents. /// /// If any of the children have a [`Length::Fill`] strategy, you will need to - /// call [`Column::width`] or [`Column::height`] accordingly. + /// call [`FlushColumn::width`] or [`FlushColumn::height`] accordingly. #[must_use] pub fn from_vec(children: Vec>) -> Self { let children = children @@ -94,42 +94,42 @@ where self } - /// Sets the [`Padding`] of the [`Column`]. + /// Sets the [`Padding`] of the [`FlushColumn`]. #[must_use] pub fn padding>(mut self, padding: P) -> Self { self.padding = padding.into(); self } - /// Sets the width of the [`Column`]. + /// Sets the width of the [`FlushColumn`]. #[must_use] pub fn width(mut self, width: impl Into) -> Self { self.width = width.into(); self } - /// Sets the height of the [`Column`]. + /// Sets the height of the [`FlushColumn`]. #[must_use] pub fn height(mut self, height: impl Into) -> Self { self.height = height.into(); self } - /// Sets the maximum width of the [`Column`]. + /// Sets the maximum width of the [`FlushColumn`]. #[must_use] pub fn max_width(mut self, max_width: impl Into) -> Self { self.max_width = max_width.into().0; self } - /// Sets the horizontal alignment of the contents of the [`Column`] . + /// Sets the horizontal alignment of the contents of the [`FlushColumn`] . #[must_use] pub fn align_x(mut self, align: impl Into) -> Self { self.align = Alignment::from(align.into()); self } - /// Sets whether the contents of the [`Column`] should be clipped on + /// Sets whether the contents of the [`FlushColumn`] should be clipped on /// overflow. #[must_use] pub fn clip(mut self, clip: bool) -> Self { @@ -146,7 +146,7 @@ where self } - /// Adds an element to the [`Column`]. + /// Adds an element to the [`FlushColumn`]. #[must_use] pub fn push(mut self, child: impl Into>) -> Self { let child = child.into(); @@ -157,7 +157,7 @@ where self } - /// Adds an element to the [`Column`], if `Some`. + /// Adds an element to the [`FlushColumn`], if `Some`. #[must_use] pub fn push_maybe(self, child: Option>>) -> Self { if let Some(child) = child { @@ -167,7 +167,7 @@ where } } - /// Extends the [`Column`] with the given children. + /// Extends the [`FlushColumn`] with the given children. #[must_use] pub fn extend( self, diff --git a/src/widgets/sidebar/row.rs b/src/widget/sidebar/row.rs similarity index 93% rename from src/widgets/sidebar/row.rs rename to src/widget/sidebar/row.rs index 5e7ee6bf..54450f1e 100644 --- a/src/widgets/sidebar/row.rs +++ b/src/widget/sidebar/row.rs @@ -36,19 +36,19 @@ impl<'a, Message: 'a, Theme: 'a, Renderer> FlushRow<'a, Message, Theme, Renderer where Renderer: iced::advanced::Renderer + 'a, { - /// Creates an empty [`Row`]. + /// Creates an empty [`FlushRow`]. #[must_use] pub fn new() -> Self { Self::from_vec(Vec::new()) } - /// Creates a [`Row`] with the given capacity. + /// Creates a [`FlushRow`] with the given capacity. #[must_use] pub fn with_capacity(capacity: usize) -> Self { Self::from_vec(Vec::with_capacity(capacity)) } - /// Creates a [`Row`] with the given elements. + /// Creates a [`FlushRow`] with the given elements. #[must_use] pub fn with_children( children: impl IntoIterator>, @@ -57,13 +57,13 @@ where Self::with_capacity(iterator.size_hint().0).extend(iterator) } - /// Creates a [`Row`] from an already allocated [`Vec`]. + /// Creates a [`FlushRow`] from an already allocated [`Vec`]. /// - /// Keep in mind that the [`Row`] will not inspect the [`Vec`], which means + /// Keep in mind that the [`FlushRow`] will not inspect the [`Vec`], which means /// it won't automatically adapt to the sizing strategy of its contents. /// /// If any of the children have a [`Length::Fill`] strategy, you will need to - /// call [`Row::width`] or [`Row::height`] accordingly. + /// call [`FlushRow::width`] or [`FlushRow::height`] accordingly. #[must_use] pub fn from_vec(children: Vec>) -> Self { let children = children @@ -94,42 +94,42 @@ where self } - /// Sets the [`Padding`] of the [`Row`]. + /// Sets the [`Padding`] of the [`FlushRow`]. #[must_use] pub fn padding>(mut self, padding: P) -> Self { self.padding = padding.into(); self } - /// Sets the width of the [`Row`]. + /// Sets the width of the [`FlushRow`]. #[must_use] pub fn width(mut self, width: impl Into) -> Self { self.width = width.into(); self } - /// Sets the height of the [`Row`]. + /// Sets the height of the [`FlushRow`]. #[must_use] pub fn height(mut self, height: impl Into) -> Self { self.height = height.into(); self } - /// Sets the maximum width of the [`Row`]. + /// Sets the maximum width of the [`FlushRow`]. #[must_use] pub fn max_height(mut self, max_height: impl Into) -> Self { self.max_height = max_height.into().0; self } - /// Sets the horizontal alignment of the contents of the [`Row`] . + /// Sets the horizontal alignment of the contents of the [`FlushRow`] . #[must_use] pub fn align_y(mut self, align: impl Into) -> Self { self.align = Alignment::from(align.into()); self } - /// Sets whether the contents of the [`Row`] should be clipped on + /// Sets whether the contents of the [`FlushRow`] should be clipped on /// overflow. #[must_use] pub fn clip(mut self, clip: bool) -> Self { @@ -146,7 +146,7 @@ where self } - /// Adds an element to the [`Row`]. + /// Adds an element to the [`FlushRow`]. #[must_use] pub fn push(mut self, child: impl Into>) -> Self { let child = child.into(); @@ -157,7 +157,7 @@ where self } - /// Adds an element to the [`Row`], if `Some`. + /// Adds an element to the [`FlushRow`], if `Some`. #[must_use] pub fn push_maybe( self, @@ -170,7 +170,7 @@ where } } - /// Extends the [`Row`] with the given children. + /// Extends the [`FlushRow`] with the given children. #[must_use] pub fn extend( self, diff --git a/src/widgets/sidebar/sidebar.rs b/src/widget/sidebar/sidebar.rs similarity index 96% rename from src/widgets/sidebar/sidebar.rs rename to src/widget/sidebar/sidebar.rs index 9cc12292..3ca41ece 100644 --- a/src/widgets/sidebar/sidebar.rs +++ b/src/widget/sidebar/sidebar.rs @@ -50,7 +50,7 @@ const DEFAULT_PADDING: Padding = Padding::new(1.0); const DEFAULT_SPACING: Pixels = Pixels::ZERO; /// A [`TabLabel`] showing an icon and/or a text on a tab -/// on a [`TabBar`](super::TabBar). +/// on a [`Sidebar`]. #[allow(missing_debug_implementations)] #[derive(Clone, Hash)] pub enum TabLabel { @@ -176,7 +176,7 @@ where Self::with_tab_labels(Vec::new(), on_select) } - /// Similar to `new` but with a given Vector of the [`TabLabel`](crate::sidebar::TabLabel)s. + /// Similar to `new` but with a given Vector of the [`TabLabel`]s. /// /// It expects: /// * the index of the currently active tab. @@ -219,7 +219,7 @@ where } /// Sets the size of the close icon of the - /// [`TabLabel`](crate::sidebar::TabLabel)s of the [`Sidebar`]. + /// [`TabLabel`]s of the [`Sidebar`]. #[must_use] pub fn close_size(mut self, close_size: f32) -> Self { self.close_size = close_size; @@ -258,14 +258,14 @@ where } /// Sets the font of the icons of the - /// [`TabLabel`](crate::sidebar::TabLabel)s of the [`Sidebar`]. + /// [`TabLabel`]s of the [`Sidebar`]. #[must_use] pub fn icon_font(mut self, font: Font) -> Self { self.font = Some(font); self } - /// Sets the icon size of the [`TabLabel`](crate::sidebar::TabLabel)s of the [`Sidebar`]. + /// Sets the icon size of the [`TabLabel`]s of the [`Sidebar`]. #[must_use] pub fn icon_size(mut self, icon_size: f32) -> Self { self.icon_size = icon_size; @@ -292,7 +292,7 @@ where self } - /// Pushes a [`TabLabel`](crate::sidebar::TabLabel) to the [`Sidebar`]. + /// Pushes a [`TabLabel`] to the [`Sidebar`]. #[must_use] pub fn push(mut self, id: TabId, tab_label: TabLabel) -> Self { self.tab_labels.push(tab_label); @@ -314,14 +314,14 @@ where } /// Sets the font of the text of the - /// [`TabLabel`](crate::sidebar::TabLabel)s of the [`Sidebar`]. + /// [`TabLabel`]s of the [`Sidebar`]. #[must_use] pub fn text_font(mut self, text_font: Font) -> Self { self.text_font = Some(text_font); self } - /// Sets the text size of the [`TabLabel`](crate::sidebar::TabLabel)s of the [`Sidebar`]. + /// Sets the text size of the [`TabLabel`]s of the [`Sidebar`]. #[must_use] pub fn text_size(mut self, text_size: f32) -> Self { self.text_size = text_size; @@ -546,8 +546,8 @@ where self.on_close .as_ref() .filter(|_on_close| { - let tab_layout = layout.children().nth(new_selected).expect("widgets: Layout should have a tab layout at the selected index"); - let cross_layout = tab_layout.children().nth(1).expect("widgets: Layout should have a close layout"); + let tab_layout = layout.children().nth(new_selected).expect("widget: Layout should have a tab layout at the selected index"); + let cross_layout = tab_layout.children().nth(1).expect("widget: Layout should have a close layout"); cursor.position().map_or(false, |pos| cross_layout.bounds().contains(pos) ) }) @@ -1000,7 +1000,7 @@ where } /// Similar to `new` but with a given Vector of the - /// [`TabLabel`](super::sidebar::TabLabel) along with the tab's content. + /// [`TabLabel`] along with the tab's content. /// /// It expects: /// * the index of the currently active tab. @@ -1034,8 +1034,8 @@ where } /// Sets the size of the close icon of the - /// [`TabLabel`](super::sidebar::TabLabel) of the - /// [`Sidebar`](super::sidebar::Sidebar). + /// [`TabLabel`] of the + /// [`Sidebar`]. #[must_use] pub fn close_size(mut self, close_size: f32) -> Self { self.sidebar = self.sidebar.close_size(close_size); @@ -1050,8 +1050,8 @@ where } /// Sets the Icon render Position for the - /// [`TabLabel`](super::sidebar::TabLabel) of the - /// [`Sidebar`](super::sidebar::Sidebar). + /// [`TabLabel`] of the + /// [`Sidebar`]. #[must_use] pub fn tab_icon_position(mut self, position: Position) -> Self { self.sidebar = self.sidebar.set_position(position); @@ -1059,7 +1059,7 @@ where } /// Sets the close icon render Position for the tab of the - /// [`Sidebar`](super::sidebar::Sidebar). + /// [`Sidebar`]. #[must_use] pub fn close_icon_position(mut self, position: Position) -> Self { self.sidebar = self.sidebar.set_close_position(position); @@ -1074,16 +1074,16 @@ where } /// Sets the font of the icons of the - /// [`TabLabel`](super::sidebar::TabLabel)s of the - /// [`Sidebar`](super::sidebar::Sidebar). + /// [`TabLabel`]s of the + /// [`Sidebar`]. #[must_use] pub fn icon_font(mut self, font: Font) -> Self { self.sidebar = self.sidebar.icon_font(font); self } - /// Sets the icon size of the [`TabLabel`](super::sidebar::TabLabel) of the - /// [`Sidebar`](super::sidebar::Sidebar). + /// Sets the icon size of the [`TabLabel`] of the + /// [`Sidebar`]. #[must_use] pub fn icon_size(mut self, icon_size: f32) -> Self { self.sidebar = self.sidebar.icon_size(icon_size); @@ -1103,7 +1103,7 @@ where self } - /// Pushes a [`TabLabel`](super::sidebar::TabLabel) along with the tabs + /// Pushes a [`TabLabel`] along with the tabs /// content to the [`SidebarWithContent`]. #[must_use] pub fn push(mut self, id: TabId, tab_label: TabLabel, element: E) -> Self @@ -1123,28 +1123,28 @@ where self } - /// Sets the height of the [`Sidebar`](super::sidebar::Sidebar) of the [`SidebarWithContent`]. + /// Sets the height of the [`Sidebar`] of the [`SidebarWithContent`]. #[must_use] pub fn sidebar_height(mut self, height: Length) -> Self { self.sidebar = self.sidebar.height(height); self } - /// Sets the width of the [`Sidebar`](super::sidebar::Sidebar) of the [`SidebarWithContent`]. + /// Sets the width of the [`Sidebar`] of the [`SidebarWithContent`]. #[must_use] pub fn sidebar_width(mut self, width: Length) -> Self { self.sidebar = self.sidebar.width(width); self } - /// Sets the [`SidebarPosition`] of the [`Sidebar`](super::sidebar::Sidebar). + /// Sets the [`SidebarPosition`] of the [`Sidebar`]. #[must_use] pub fn sidebar_position(mut self, position: SidebarPosition) -> Self { self.sidebar_position = position; self } - /// Sets the style of the [`Sidebar`](super::sidebar::Sidebar). + /// Sets the style of the [`Sidebar`]. #[must_use] pub fn sidebar_style(mut self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self where @@ -1154,7 +1154,7 @@ where self } - /// Sets the padding of the tabs of the [`Sidebar`](super::sidebar::Sidebar). + /// Sets the padding of the tabs of the [`Sidebar`]. #[must_use] pub fn tab_label_padding(mut self, padding: impl Into) -> Self { self.sidebar = self.sidebar.padding(padding); @@ -1162,7 +1162,7 @@ where } /// Sets the spacing between the tabs of the - /// [`Sidebar`](super::sidebar::Sidebar). + /// [`Sidebar`]. #[must_use] pub fn tab_label_spacing(mut self, spacing: impl Into) -> Self { self.sidebar = self.sidebar.spacing(spacing); @@ -1170,16 +1170,16 @@ where } /// Sets the font of the text of the - /// [`TabLabel`](super::sidebar::TabLabel)s of the - /// [`Sidebar`](super::sidebar::Sidebar). + /// [`TabLabel`]s of the + /// [`Sidebar`]. #[must_use] pub fn text_font(mut self, text_font: Font) -> Self { self.sidebar = self.sidebar.text_font(text_font); self } - /// Sets the text size of the [`TabLabel`](super::sidebar::TabLabel) of the - /// [`Sidebar`](super::sidebar::Sidebar). + /// Sets the text size of the [`TabLabel`] of the + /// [`Sidebar`]. #[must_use] pub fn text_size(mut self, text_size: f32) -> Self { self.sidebar = self.sidebar.text_size(text_size); diff --git a/src/widgets/slide_bar.rs b/src/widget/slide_bar.rs similarity index 94% rename from src/widgets/slide_bar.rs rename to src/widget/slide_bar.rs index 0efb0e19..e80f05f4 100644 --- a/src/widgets/slide_bar.rs +++ b/src/widget/slide_bar.rs @@ -16,7 +16,7 @@ use iced::{ use std::ops::RangeInclusive; -/// Constant Default height of `SliderBar`. +/// Constant Default height of `SlideBar`. pub const DEFAULT_HEIGHT: f32 = 30.0; /// A widget that draws a `SlideBar` @@ -56,13 +56,13 @@ where T: Copy + From + std::cmp::PartialOrd, Message: Clone, { - /// Creates a new [`SliderBar`]. + /// Creates a new [`SlideBar`]. /// /// It expects: /// * an inclusive range of possible values - /// * the current value of the [`SliderBar`] - /// * a function that will be called when the [`SliderBar`] is dragged. - /// * the new value of the [`SliderBar`] and must produce a `Message`. + /// * the current value of the [`SlideBar`] + /// * a function that will be called when the [`SlideBar`] is dragged. + /// * the new value of the [`SlideBar`] and must produce a `Message`. /// pub fn new(range: RangeInclusive, value: T, on_change: F) -> Self where @@ -96,7 +96,7 @@ where } } - /// Sets the release message of the [`Slider`]. + /// Sets the release message of the [`SlideBar`]. /// This is called when the mouse is released from the slider. /// /// Typically, the user's interaction with the slider is finished when this message is produced. @@ -108,21 +108,21 @@ where self } - /// Sets the width of the [`Slider`]. + /// Sets the width of the [`SlideBar`]. #[must_use] pub fn width(mut self, width: impl Into) -> Self { self.width = width.into(); self } - /// Sets the height of the [`Slider`]. + /// Sets the height of the [`SlideBar`]. #[must_use] pub fn height(mut self, height: Option) -> Self { self.height = height; self } - /// Sets the step size of the [`Slider`]. + /// Sets the step size of the [`SlideBar`]. #[must_use] pub fn step(mut self, step: impl Into) -> Self { self.step = step.into(); @@ -204,7 +204,7 @@ where } } -/// Processes an [`Event`] and updates the [`State`] of a [`SliderBar`] +/// Processes an [`Event`] and updates the [`State`] of a [`SlideBar`] /// accordingly. #[allow(clippy::too_many_arguments)] pub fn update( @@ -290,7 +290,7 @@ where event::Status::Ignored } -/// Draws a [`SliderBar`]. +/// Draws a [`SlideBar`]. pub fn draw( renderer: &mut R, layout: Layout<'_>, @@ -367,7 +367,7 @@ where } } -/// The local state of a [`SliderBar`]. +/// The local state of a [`SlideBar`]. #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub struct State { is_dragging: bool, diff --git a/src/widgets/spinner.rs b/src/widget/spinner.rs similarity index 100% rename from src/widgets/spinner.rs rename to src/widget/spinner.rs diff --git a/src/widgets/tab_bar.rs b/src/widget/tab_bar.rs similarity index 97% rename from src/widgets/tab_bar.rs rename to src/widget/tab_bar.rs index 0ca2683f..f0276a0f 100644 --- a/src/widgets/tab_bar.rs +++ b/src/widget/tab_bar.rs @@ -153,7 +153,7 @@ where Self::with_tab_labels(Vec::new(), on_select) } - /// Similar to `new` but with a given Vector of the [`TabLabel`](crate::tab_bar::TabLabel)s. + /// Similar to [`new`](Self::new) but with a given Vector of the [`TabLabel`]s. /// /// It expects: /// * the index of the currently active tab. @@ -188,7 +188,7 @@ where } /// Sets the size of the close icon of the - /// [`TabLabel`](crate::tab_bar::TabLabel)s of the [`TabBar`]. + /// [`TabLabel`]s of the [`TabBar`]. #[must_use] pub fn close_size(mut self, close_size: f32) -> Self { self.close_size = close_size; @@ -227,14 +227,14 @@ where } /// Sets the font of the icons of the - /// [`TabLabel`](crate::tab_bar::TabLabel)s of the [`TabBar`]. + /// [`TabLabel`]s of the [`TabBar`]. #[must_use] pub fn icon_font(mut self, font: Font) -> Self { self.font = Some(font); self } - /// Sets the icon size of the [`TabLabel`](crate::tab_bar::TabLabel)s of the [`TabBar`]. + /// Sets the icon size of the [`TabLabel`]s of the [`TabBar`]. #[must_use] pub fn icon_size(mut self, icon_size: f32) -> Self { self.icon_size = icon_size; @@ -268,7 +268,7 @@ where self } - /// Pushes a [`TabLabel`](crate::tab_bar::TabLabel) to the [`TabBar`]. + /// Pushes a [`TabLabel`] to the [`TabBar`]. #[must_use] pub fn push(mut self, id: TabId, tab_label: TabLabel) -> Self { self.tab_labels.push(tab_label); @@ -290,14 +290,14 @@ where } /// Sets the font of the text of the - /// [`TabLabel`](crate::tab_bar::TabLabel)s of the [`TabBar`]. + /// [`TabLabel`]s of the [`TabBar`]. #[must_use] pub fn text_font(mut self, text_font: Font) -> Self { self.text_font = Some(text_font); self } - /// Sets the text size of the [`TabLabel`](crate::tab_bar::TabLabel)s of the [`TabBar`]. + /// Sets the text size of the [`TabLabel`]s of the [`TabBar`]. #[must_use] pub fn text_size(mut self, text_size: f32) -> Self { self.text_size = text_size; @@ -556,8 +556,8 @@ where self.on_close .as_ref() .filter(|_on_close| { - let tab_layout = layout.children().nth(new_selected).expect("widgets: Layout should have a tab layout at the selected index"); - let cross_layout = tab_layout.children().nth(1).expect("widgets: Layout should have a close layout"); + let tab_layout = layout.children().nth(new_selected).expect("widget: Layout should have a tab layout at the selected index"); + let cross_layout = tab_layout.children().nth(1).expect("widget: Layout should have a close layout"); cursor.position().map_or(false, |pos| cross_layout.bounds().contains(pos) ) }) diff --git a/src/widgets/tab_bar/tab_label.rs b/src/widget/tab_bar/tab_label.rs similarity index 100% rename from src/widgets/tab_bar/tab_label.rs rename to src/widget/tab_bar/tab_label.rs diff --git a/src/widgets/tabs.rs b/src/widget/tabs.rs similarity index 88% rename from src/widgets/tabs.rs rename to src/widget/tabs.rs index ce594158..32a12fea 100644 --- a/src/widgets/tabs.rs +++ b/src/widget/tabs.rs @@ -1,7 +1,7 @@ //! Displays a [`Tabs`] widget to select the content to be displayed. //! -//! This is a wrapper around the [`TabBar`](super::tab_bar::TabBar) widget. -//! Unlike the [`TabBar`](super::tab_bar::TabBar) widget it will also handle +//! This is a wrapper around the [`TabBar`] widget. +//! Unlike the [`TabBar`] widget it will also handle //! the content of the tabs. //! //! *This API requires the following crate features to be activated: tabs* @@ -13,7 +13,7 @@ use crate::{ tab_bar::{Catalog, Style}, Status, StyleFn, }, - widgets::tab_bar::TabBar, + widget::tab_bar::TabBar, TabLabel, }; @@ -35,7 +35,7 @@ use iced::{ pub use tab_bar_position::TabBarPosition; -/// A [`Tabs`] widget for showing a [`TabBar`](super::tab_bar::TabBar) +/// A [`Tabs`] widget for showing a [`TabBar`] /// along with the tab's content. /// /// # Example @@ -69,15 +69,15 @@ where Theme: Catalog, TabId: Eq + Clone, { - /// The [`TabBar`](crate::widgets::TabBar) of the [`Tabs`]. + /// The [`TabBar`](crate::widget::TabBar) of the [`Tabs`]. tab_bar: TabBar<'a, Message, TabId, Theme, Renderer>, /// The vector containing the content of the tabs. tabs: Vec>, /// The vector containing the indices of the tabs. indices: Vec, - /// The position of the [`TabBar`](crate::widgets::TabBar). + /// The position of the [`TabBar`](crate::widget::TabBar). tab_bar_position: TabBarPosition, - /// The position of the [`TabBar`](crate::widgets::TabBar) Icon. + /// The position of the [`TabBar`](crate::widget::TabBar) Icon. tab_icon_position: Position, /// the width of the [`Tabs`]. width: Length, @@ -106,7 +106,7 @@ where } /// Similar to `new` but with a given Vector of the - /// [`TabLabel`](super::tab_bar::TabLabel) along with the tab's content. + /// [`TabLabel`] along with the tab's content. /// /// It expects: /// * the index of the currently active tab. @@ -146,8 +146,8 @@ where } /// Sets the size of the close icon of the - /// [`TabLabel`](super::tab_bar::TabLabel) of the - /// [`TabBar`](super::tab_bar::TabBar). + /// [`TabLabel`] of the + /// [`TabBar`]. #[must_use] pub fn close_size(mut self, close_size: f32) -> Self { self.tab_bar = self.tab_bar.close_size(close_size); @@ -155,8 +155,8 @@ where } /// Sets the Tabs Icon render Position - /// [`TabLabel`](super::tab_bar::TabLabel) of the - /// [`TabBar`](super::tab_bar::TabBar). + /// [`TabLabel`] of the + /// [`TabBar`]. #[must_use] pub fn tab_icon_position(mut self, position: Position) -> Self { self.tab_icon_position = position; @@ -171,16 +171,16 @@ where } /// Sets the font of the icons of the - /// [`TabLabel`](super::tab_bar::TabLabel)s of the - /// [`TabBar`](super::tab_bar::TabBar). + /// [`TabLabel`]s of the + /// [`TabBar`]. #[must_use] pub fn icon_font(mut self, font: Font) -> Self { self.tab_bar = self.tab_bar.icon_font(font); self } - /// Sets the icon size of the [`TabLabel`](super::tab_bar::TabLabel) of the - /// [`TabBar`](super::tab_bar::TabBar). + /// Sets the icon size of the [`TabLabel`] of the + /// [`TabBar`]. #[must_use] pub fn icon_size(mut self, icon_size: f32) -> Self { self.tab_bar = self.tab_bar.icon_size(icon_size); @@ -200,7 +200,7 @@ where self } - /// Pushes a [`TabLabel`](super::tab_bar::TabLabel) along with the tabs + /// Pushes a [`TabLabel`] along with the tabs /// content to the [`Tabs`]. #[must_use] pub fn push(mut self, id: TabId, tab_label: TabLabel, element: E) -> Self @@ -223,35 +223,35 @@ where self } - /// Sets the height of the [`TabBar`](super::tab_bar::TabBar) of the [`Tabs`]. + /// Sets the height of the [`TabBar`] of the [`Tabs`]. #[must_use] pub fn tab_bar_height(mut self, height: Length) -> Self { self.tab_bar = self.tab_bar.height(height); self } - /// Sets the maximum height of the [`TabBar`](super::tab_bar::TabBar) of the [`Tabs`]. + /// Sets the maximum height of the [`TabBar`] of the [`Tabs`]. #[must_use] pub fn tab_bar_max_height(mut self, max_height: f32) -> Self { self.tab_bar = self.tab_bar.max_height(max_height); self } - /// Sets the width of the [`TabBar`](super::tab_bar::TabBar) of the [`Tabs`]. + /// Sets the width of the [`TabBar`] of the [`Tabs`]. #[must_use] pub fn tab_bar_width(mut self, width: Length) -> Self { self.tab_bar = self.tab_bar.width(width); self } - /// Sets the [`TabBarPosition`] of the [`TabBar`](super::tab_bar::TabBar). + /// Sets the [`TabBarPosition`] of the [`TabBar`]. #[must_use] pub fn tab_bar_position(mut self, position: TabBarPosition) -> Self { self.tab_bar_position = position; self } - /// Sets the style of the [`TabBar`](super::tab_bar::TabBar). + /// Sets the style of the [`TabBar`]. #[must_use] pub fn tab_bar_style(mut self, style: impl Fn(&Theme, Status) -> Style + 'a) -> Self where @@ -261,7 +261,7 @@ where self } - /// Sets the padding of the tabs of the [`TabBar`](super::tab_bar::TabBar). + /// Sets the padding of the tabs of the [`TabBar`]. #[must_use] pub fn tab_label_padding(mut self, padding: impl Into) -> Self { self.tab_bar = self.tab_bar.padding(padding); @@ -269,7 +269,7 @@ where } /// Sets the spacing between the tabs of the - /// [`TabBar`](super::tab_bar::TabBar). + /// [`TabBar`]. #[must_use] pub fn tab_label_spacing(mut self, spacing: impl Into) -> Self { self.tab_bar = self.tab_bar.spacing(spacing); @@ -277,16 +277,16 @@ where } /// Sets the font of the text of the - /// [`TabLabel`](super::tab_bar::TabLabel)s of the - /// [`TabBar`](super::tab_bar::TabBar). + /// [`TabLabel`]s of the + /// [`TabBar`]. #[must_use] pub fn text_font(mut self, text_font: Font) -> Self { self.tab_bar = self.tab_bar.text_font(text_font); self } - /// Sets the text size of the [`TabLabel`](super::tab_bar::TabLabel) of the - /// [`TabBar`](super::tab_bar::TabBar). + /// Sets the text size of the [`TabLabel`] of the + /// [`TabBar`]. #[must_use] pub fn text_size(mut self, text_size: f32) -> Self { self.tab_bar = self.tab_bar.text_size(text_size); @@ -411,19 +411,19 @@ where TabBarPosition::Top => { let tab_bar_layout = children .next() - .expect("widgets: Layout should have a TabBar layout at top position"); + .expect("widget: Layout should have a TabBar layout at top position"); let tab_content_layout = children .next() - .expect("widgets: Layout should have a tab content layout at top position"); + .expect("widget: Layout should have a tab content layout at top position"); (tab_bar_layout, tab_content_layout) } TabBarPosition::Bottom => { let tab_content_layout = children .next() - .expect("widgets: Layout should have a tab content layout at bottom position"); + .expect("widget: Layout should have a tab content layout at bottom position"); let tab_bar_layout = children .next() - .expect("widgets: Layout should have a TabBar layout at bottom position"); + .expect("widget: Layout should have a TabBar layout at bottom position"); (tab_bar_layout, tab_content_layout) } }; @@ -471,10 +471,10 @@ where let tab_bar_layout = match self.tab_bar_position { TabBarPosition::Top => children .next() - .expect("widgets: There should be a TabBar at the top position"), + .expect("widget: There should be a TabBar at the top position"), TabBarPosition::Bottom => children .last() - .expect("widgets: There should be a TabBar at the bottom position"), + .expect("widget: There should be a TabBar at the bottom position"), }; let mut mouse_interaction = mouse::Interaction::default(); @@ -532,10 +532,10 @@ where let tab_bar_layout = match self.tab_bar_position { TabBarPosition::Top => children .next() - .expect("widgets: There should be a TabBar at the top position"), + .expect("widget: There should be a TabBar at the top position"), TabBarPosition::Bottom => children .last() - .expect("widgets: There should be a TabBar at the bottom position"), + .expect("widget: There should be a TabBar at the bottom position"), }; self.tab_bar.draw( diff --git a/src/widgets/tabs/tab_bar_position.rs b/src/widget/tabs/tab_bar_position.rs similarity index 80% rename from src/widgets/tabs/tab_bar_position.rs rename to src/widget/tabs/tab_bar_position.rs index 206f3d1c..8b2c97f1 100644 --- a/src/widgets/tabs/tab_bar_position.rs +++ b/src/widget/tabs/tab_bar_position.rs @@ -1,16 +1,16 @@ -//! A [`TabBarPosition`] for defining the position of a [`TabBar`](crate::widgets::tab_bar::TabBar). +//! A [`TabBarPosition`] for defining the position of a [`TabBar`](crate::widget::tab_bar::TabBar). //! //! *This API requires the following crate features to be activated: tabs* -/// A [`TabBarPosition`] for defining the position of a [`TabBar`](crate::widgets::tab_bar::TabBar). +/// A [`TabBarPosition`] for defining the position of a [`TabBar`](crate::widget::tab_bar::TabBar). #[derive(Clone, Hash)] #[allow(missing_debug_implementations)] pub enum TabBarPosition { - /// A [`TabBarPosition`] for placing the [`TabBar`](crate::widgets::tab_bar::TabBar) + /// A [`TabBarPosition`] for placing the [`TabBar`](crate::widget::tab_bar::TabBar) /// on top of its content. Top, - /// A [`TabBarPosition`] for placing the [`TabBar`](crate::widgets::tab_bar::TabBar) + /// A [`TabBarPosition`] for placing the [`TabBar`](crate::widget::tab_bar::TabBar) /// on bottom of its content. Bottom, } diff --git a/src/widgets/time_picker.rs b/src/widget/time_picker.rs similarity index 98% rename from src/widgets/time_picker.rs rename to src/widget/time_picker.rs index 287a2901..1a34ea7c 100644 --- a/src/widgets/time_picker.rs +++ b/src/widget/time_picker.rs @@ -97,7 +97,7 @@ where /// will be wrapped around. /// * a message that will be send when the cancel button of the [`TimePicker`] is pressed. /// * a function that will be called when the submit button of the [`TimePicker`] - /// is pressed, which takes the picked [`Time`](crate::time_picker::Time) value. + /// is pressed, which takes the picked [`Time`] value. pub fn new( show_picker: bool, time: impl Into