S015: Material You foundation: M3 schemes, Outfit, icons, springs, widgets, gallery
Fixes R1-01 (icon glyphs) and R1-02 (clock contrast). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c91795ca69
commit
7b7e0cec7f
35 changed files with 2292 additions and 308 deletions
|
|
@ -63,9 +63,11 @@ Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference onl
|
|||
| Tool | Role | Available after |
|
||||
|---|---|---|
|
||||
| `nice cargo build --release -j 2` | compile check, produces `target/release/nacre` | now |
|
||||
| `nice cargo test --release -j 2` | unit tests (29, ~16 s test-profile build then <1 s run; shares the S001 build) (util, settings, history, bookmarks, permissions, vault, dns, bridge loopback, download, adblock, keys, scripts, updates, inject, hub, theme) | first successful build; not alongside a build |
|
||||
| `nice cargo test --release -j 2` | unit tests (38, ~16 s test-profile build then <1 s run; shares the S001 build) (util, settings, history, bookmarks, permissions, vault, dns, bridge loopback, download, adblock, keys, scripts, updates, inject, hub, theme, ui::widgets input, ui::paint) | first successful build; not alongside a build |
|
||||
| `src/selftest.rs` | in-app self test: `NACRE_SCRIPT=<file>` runs script commands (listed at its top) | now |
|
||||
| `tools/smoke.sh <script> [outdir]` | smoke run on a hidden Xvfb display with a throwaway home and software GL; outdir (default `target/smoke/<name>-<time>`) gets `nacre.log`, `selftest.log`, `<shot>.png`, `<status>.json`, `home/`; exits non-zero on crash, panic or no `status done`. Scripts in `tests/smoke/` (`launch.txt` offline, `https.txt` needs internet, `restore.txt` with `SMOKE_HOME=<launch outdir>/home`); header documents env vars and commands. Read the PNGs | now (S003) |
|
||||
| `nacre://gallery` + `SMOKE_SIZE=1400x2800 tools/smoke.sh tests/smoke/gallery.txt` | every design token and widget, dark and light (+ new tab and settings shots); read the PNGs | now (S015) |
|
||||
| `python tools/icons.py` | rebuilds the icon font subset and `src/ui/icons.rs` from `tools/icons.txt` (needs fontTools and Arch's ttf-material-symbols-variable) | now (S015) |
|
||||
| appimagetool, wine + Inno Setup, VM "Windows 10" | packaging and Windows checks | see the user's global CLAUDE.md "Building" |
|
||||
|
||||
Don't assume a tool exists: check first. When your plan creates a tool, add its row here.
|
||||
|
|
|
|||
12
Cargo.lock
generated
12
Cargo.lock
generated
|
|
@ -4535,6 +4535,17 @@ dependencies = [
|
|||
"web_atoms",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "material-colors"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e226ffda362d5bc26bb8f730d637a0851eedfb05e35d92108c9d8b48d2e47941"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"indexmap 2.14.2",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maybe-rayon"
|
||||
version = "0.1.1"
|
||||
|
|
@ -4887,6 +4898,7 @@ dependencies = [
|
|||
"keyboard-types",
|
||||
"libc",
|
||||
"log",
|
||||
"material-colors",
|
||||
"qrcode",
|
||||
"raw-window-handle",
|
||||
"rfd",
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ winit = { version = "0.30.13", default-features = false, features = ["rwh_06", "
|
|||
egui = { version = "0.37", default-features = false, features = ["default_fonts"] }
|
||||
egui_glow = { version = "0.37", default-features = false, features = ["winit", "x11", "wayland", "clipboard"] }
|
||||
glow = "0.17"
|
||||
# Material You colour schemes (HCT, tonal palettes). 0.4.2: 0.5 needs Rust 1.97 (D-009).
|
||||
material-colors = { version = "=0.4.2", default-features = false, features = ["std"] }
|
||||
euclid = "0.22"
|
||||
dpi = "0.1"
|
||||
raw-window-handle = "0.6"
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@ Build the design system every later UI plan uses: Material 3 tonal-spot palettes
|
|||
- `src/theme.rs`, `src/ui/widgets.rs`, `src/ui/mod.rs` (whole)
|
||||
|
||||
## Steps
|
||||
- [ ] Implement HCT + tonal palettes + tonal-spot scheme (own code ported from Material Color Utilities, or the `material-colors` crate; record choice in DECISIONS); unit tests against known reference colours for a few seeds, light and dark
|
||||
- [ ] Map the scheme to `Palette` roles and add the missing M3 roles (surface containers, on-*, outline-variant); seeds from website / system / palette / custom still work
|
||||
- [ ] Download Outfit (OFL, Google Fonts) into `assets/fonts/` with its licence file; register it in egui for UI text, with thin weights for the clock
|
||||
- [ ] Add motion helpers: spring animation (stiffness/damping tokens) driven by egui animation time, scaled or off by the Motion setting
|
||||
- [ ] Add shape tokens (corner sizes, pill) and drawing helpers: cookie/scalloped shape, wavy line and wavy progress
|
||||
- [ ] Restyle `widgets.rs`: switch (with thumb icon), segmented buttons with check mark, pill buttons (filled/tonal/outlined/text), cards, rows; every control has hover/press/focus/disabled states
|
||||
- [ ] Add a hidden `nacre://gallery` (or selftest page) that shows every widget and token in light and dark; smoke shot of it and check by eye
|
||||
- [ ] Document tokens and helpers in `docs/DESIGN.md` § UI system so later plans only read that section
|
||||
- [ ] PROGRESS entry, INDEX line, commit `S015: …` and push
|
||||
- [x] Implement HCT + tonal palettes + tonal-spot scheme (own code ported from Material Color Utilities, or the `material-colors` crate; record choice in DECISIONS); unit tests against known reference colours for a few seeds, light and dark
|
||||
- [x] Map the scheme to `Palette` roles and add the missing M3 roles (surface containers, on-*, outline-variant); seeds from website / system / palette / custom still work
|
||||
- [x] Download Outfit (OFL, Google Fonts) into `assets/fonts/` with its licence file; register it in egui for UI text, with thin weights for the clock
|
||||
- [x] Add motion helpers: spring animation (stiffness/damping tokens) driven by egui animation time, scaled or off by the Motion setting
|
||||
- [x] Add shape tokens (corner sizes, pill) and drawing helpers: cookie/scalloped shape, wavy line and wavy progress
|
||||
- [x] Restyle `widgets.rs`: switch (with thumb icon), segmented buttons with check mark, pill buttons (filled/tonal/outlined/text), cards, rows; every control has hover/press/focus/disabled states
|
||||
- [x] Add a hidden `nacre://gallery` (or selftest page) that shows every widget and token in light and dark; smoke shot of it and check by eye
|
||||
- [x] Document tokens and helpers in `docs/DESIGN.md` § UI system so later plans only read that section
|
||||
- [x] PROGRESS entry, INDEX line, commit `S015: …` and push
|
||||
|
||||
## End criteria
|
||||
- Theme unit tests green (reference colours match).
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ Tracker: https://claude.ai/artifact/9AD7fPfwJ4ASFzVTJGKU4h
|
|||
- [ ] [S014 — Phase 3 review with the user](03%20Gaps/S014-phase3-review.md) · Sonnet medium · 🧑
|
||||
|
||||
## 04 UI redesign
|
||||
- [ ] [S015 — Material You foundation](04%20UI%20redesign/S015-material-foundation.md) · Opus high
|
||||
- [x] [S015 — Material You foundation](04%20UI%20redesign/S015-material-foundation.md) · Opus high
|
||||
- [ ] [S016 — Chrome and menus redesign](04%20UI%20redesign/S016-ui-chrome.md) · Opus medium
|
||||
- [ ] [S017 — New tab page: elements](04%20UI%20redesign/S017-ntp-elements.md) · Opus medium
|
||||
- [ ] [S018 — New tab page: backgrounds and Customize](04%20UI%20redesign/S018-ntp-backgrounds.md) · Opus medium
|
||||
|
|
|
|||
202
assets/fonts/LICENSE-MaterialSymbols.txt
Normal file
202
assets/fonts/LICENSE-MaterialSymbols.txt
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
BIN
assets/fonts/MaterialSymbolsOutlined-Nacre.ttf
Normal file
BIN
assets/fonts/MaterialSymbolsOutlined-Nacre.ttf
Normal file
Binary file not shown.
93
assets/fonts/OFL-Outfit.txt
Normal file
93
assets/fonts/OFL-Outfit.txt
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
Copyright 2021 The Outfit Project Authors (https://github.com/Outfitio/Outfit-Fonts)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
BIN
assets/fonts/Outfit[wght].ttf
Normal file
BIN
assets/fonts/Outfit[wght].ttf
Normal file
Binary file not shown.
|
|
@ -10,3 +10,4 @@
|
|||
- D-006 — 2026-11-11 — egui's epaint is vendored (`vendor/epaint`, 0.37.0 + a patch rendering glyphs single-threaded) via `[patch.crates-io]`. — Servo's canvas enables vello_cpu/multithreading, which makes stock epaint 0.37.0 panic on every glyph; no fixed release exists. — any plan that upgrades egui: drop the patch once epaint fixes it, keep `theme::tests::egui_draws_text`
|
||||
- D-007 — 2026-11-11 — Run order changed: after S005 the UI redesign (S015–S021) runs next, then the rest of Verify and Gaps (S006–S014). S015's dependency on S014 is replaced by S005. Phase 1 review items R1-01 (icons), R1-02 (clock), R1-05 and R1-06 (old-Nacre feel, animations, "unslop" look) are redesign input; R1-03 (YouTube) and R1-04 (captchas, caching) go to S006/S007. — The user chose it after the phase 1 review. — S006–S021
|
||||
- D-008 — 2026-11-11 — One painter per window, shared by all its tabs (not one per tab). Picture-in-picture reloads the page in a dedicated web view and seeks the video (page state is lost). — Per-tab painters cost ~56 MB + 6 threads each (15 tabs: 1128 MB vs 341 MB) with equal frame time; the 4 GB target PC. The user chose it (option B in S005). — S005, any plan touching painters or PiP
|
||||
- D-009 — 2026-11-11 — Material You colours come from the `material-colors` crate pinned at `=0.4.2` (MCU port: HCT, tonal palettes, all scheme variants), not an own port. Icons are Material Symbols Outlined, cut to the names in `tools/icons.txt` by `tools/icons.py` (55 KB, FILL and wght axes kept). — 0.5.0 needs Rust 1.97 and the project allows 1.88; the crate matches MCU's reference colours (theme tests). The user's old Nacre used Material Symbols too. — S015–S020: add an icon by editing tools/icons.txt and running the tool
|
||||
|
|
|
|||
|
|
@ -140,6 +140,86 @@ picture-in-picture, extensions, password capture, printing.
|
|||
- Hardware acceleration switch: Servo needs GL; "Off" selects software GL (LIBGL_ALWAYS_SOFTWARE) on next start.
|
||||
- Printing: "Save page as PDF/PNG" through a full-page screenshot.
|
||||
|
||||
## UI system (S015)
|
||||
|
||||
Everything the interface draws takes its colours, radii, sizes and springs from `src/theme.rs`; widgets live in
|
||||
`src/ui/widgets.rs`, Expressive shapes in `src/ui/paint.rs`, icons in `src/ui/icons.rs`. `nacre://gallery`
|
||||
(`src/ui/pages/gallery.rs`, not linked from the UI) shows all of it; `SMOKE_SIZE=1400x2800 tools/smoke.sh
|
||||
tests/smoke/gallery.txt` shoots it dark and light. Rules: the `app-taste` skill. No one-off colour, radius or duration.
|
||||
|
||||
**Tokens reach widgets through the egui context.** `theme::apply(ctx, &palette, &settings)` (called by
|
||||
`App::style_window` whenever the theme, seed or settings change) stores `theme::Tokens { palette, roundness, motion }`
|
||||
and sets egui visuals, text styles and spacing. From any `Ui`: `theme::palette(ui.ctx())`,
|
||||
`theme::radius(ui.ctx(), theme::L)`, `theme::spring(...)`. Fonts are set once per window: `ui::fonts()` in
|
||||
`window.rs`.
|
||||
|
||||
**Colour** (`theme::Palette`, from the `material-colors` crate, D-009). `Palette::new(seed, dark, variant, contrast)`
|
||||
builds the M3 scheme; `variant` is a `theme::VARIANTS` key (tonal_spot default), `contrast` -1..1. Seeds:
|
||||
`theme::seed` (website colour if chroma ≥ 12 and tone 8..95, else fallback; system accent; preset; custom).
|
||||
- M3 roles: `primary`, `on_primary`, `primary_container`, `on_primary_container`, `inverse_primary`, `secondary*`,
|
||||
`tertiary*` (same four each), `error`, `on_error`, `error_container`, `on_error_container`, `surface`,
|
||||
`surface_dim`, `surface_bright`, `surface_container_lowest`, `surface_container_low`, `surface_container`, `surface_container_high`,
|
||||
`surface_container_highest`, `on_surface`,
|
||||
`on_surface_variant`, `outline`, `outline_variant`, `inverse_surface`, `inverse_on_surface`, `scrim`, `shadow`.
|
||||
- Extra: `warning`, `success` (fixed hues at primary's tones).
|
||||
- Old names kept as aliases for existing code: `accent` = primary, `on_accent` = on_primary, `accent_soft` =
|
||||
secondary_container, `surface_high` = surface_container_high, `surface_low` = surface_container_lowest (the page
|
||||
background), `text` = on_surface, `text_weak` = on_surface_variant. New code uses the M3 names.
|
||||
- Usage: page background `surface_container_lowest`; cards `surface_container`; floating surfaces
|
||||
`surface_container_high`; fields `surface_container_highest`; hairlines `outline_variant`; selection
|
||||
`secondary_container` + `on_secondary_container`; main action `primary`.
|
||||
- State layers: `theme::layer(base, over, amount)` mixes opaque; constants `HOVER` 0.08, `FOCUS` 0.10, `PRESS` 0.10,
|
||||
`DRAG` 0.16, `DISABLED_CONTENT` 0.38, `DISABLED_CONTAINER` 0.12 (content colour over the container).
|
||||
|
||||
**Shape and space.** Radii `XS` 4, `S` 8, `M` 12, `L` 16, `XL` 28, `FULL` (pill); always read through
|
||||
`theme::radius(ctx, token)` (Roundness setting: Subtle ×0.5, Default ×1, Round ×1.4) and convert with
|
||||
`theme::corner_radius(f32)`. Spacing `GAP_XS` 4, `GAP_S` 8, `GAP_M` 12, `GAP_L` 16, `GAP_XL` 24. Heights
|
||||
`CONTROL_SMALL` 32 (icon buttons), `CONTROL` 40 (buttons, segmented), `ROW` 56 (list rows). Cards use `L`, chrome
|
||||
pills `FULL`, small egui widgets `S` (`theme::corner`).
|
||||
|
||||
**Type.** Outfit (OFL, `assets/fonts/Outfit[wght].ttf`, one variable font) at `theme::Weight` Thin 200, Light 300,
|
||||
Regular 400 (egui's Proportional), Medium 500, SemiBold 600; `theme::font(size, weight)`. Sizes `SMALL` 12, `BODY` 14,
|
||||
`TITLE` 18, `HEADLINE` 24, `DISPLAY` 64 (clock: Thin, primary). egui text styles: Small/Body/Button/Heading(24
|
||||
Medium)/Monospace 13. Outfit is Latin only: every family falls back to Material Symbols, then egui's Ubuntu-Light
|
||||
(Cyrillic, Greek). No CJK font is bundled.
|
||||
|
||||
**Icons.** Material Symbols Outlined (Apache 2.0), cut to `tools/icons.txt` by `tools/icons.py` into
|
||||
`assets/fonts/MaterialSymbolsOutlined-Nacre.ttf` (FILL and wght axes kept). Use the constants `icons::HOME` etc.
|
||||
(`icons::ALL` lists them). To add one: add its name (fonts.google.com/icons) to `tools/icons.txt`, run
|
||||
`python tools/icons.py`. Draw with `widgets::icon(ui, center, glyph, size, filled, colour)` or
|
||||
`theme::icon_font(size, filled)`; filled (FILL 1) is for selected states. Icons also work inside text (`format!("{}
|
||||
Open folder", icons::FOLDER_OPEN)`) through the fallback. Sizes `ICON` 20, `ICON_LARGE` 32. Never emoji.
|
||||
|
||||
**Motion.** `theme::spring(ctx, id, target, spring) -> f32`: per-id state in egui memory, retargets keeping
|
||||
velocity, starts at the target on first use, repaints only while moving, returns the target at once with Motion off.
|
||||
`theme::effect(ctx, id, on) -> 0..1` is the colour/opacity spring. Presets (stiffness/damping ratio): `FAST`
|
||||
1400/0.62 (press, small controls), `DEFAULT` 700/0.68 (panels, movement), `SLOW` 300/0.74 (big transitions),
|
||||
`EFFECT` 900/1.0 (colour, opacity; never overshoots). Motion setting = time factor (Off 0, Fast 0.6, Normal 1,
|
||||
Slow 1.8; stiffness ÷ factor²); `theme::animation_time` drives egui's own animations (0.1 s × factor).
|
||||
|
||||
**Widgets** (`ui::widgets`; all have hover state layer, press squeeze, focus ring in `secondary`, disabled 38 %):
|
||||
- `button(ui, ButtonKind::{Filled, Tonal, Outlined, Text}, Option<icon>, label) -> Response`: 40 px pill, press
|
||||
morphs to radius `S`.
|
||||
- `icon_button(ui, icon, tooltip)`, `icon_toggle(ui, icon, tooltip, on)`: 32 px circle, press squashes to a squircle;
|
||||
selected = `secondary_container` fill and filled icon.
|
||||
- `switch(ui, &mut bool) -> changed`: M3 switch, handle travels (FAST) and grows with a check when on, hover halo.
|
||||
- `segmented(ui, &mut T, &[(T, label)]) -> changed`: equal-width segments, selected = tonal fill + check that slides in.
|
||||
- `card(ui, |ui| ...)`: `surface_container`, radius `L`; rows inside get hairlines between them (not above the first).
|
||||
- `row(ui, title, description, |ui| control)`, `switch_row`, `link_row(ui, title, description) -> clicked` (whole
|
||||
row is the button, chevron at the end), `section(ui, title)` (group title in `primary`, above a card).
|
||||
- `text_field`, `number`, `page_column`, `glyph(toolbar key) -> icon`.
|
||||
|
||||
**Shapes** (`ui::paint`): `cookie(painter, center, radius, lobes, rotation, fill, stroke)`,
|
||||
`cookie_image(painter, texture, center, radius, lobes, rotation)` (artwork in a cookie), `cookie_points`,
|
||||
`wavy_line(painter, x0, x1, y, amplitude, wavelength, phase, stroke)`, `wavy_progress(painter, rect, fraction,
|
||||
amplitude, phase, &palette)` (amplitude 0 = flat, animate it with a spring when playing/paused; advance `phase` only
|
||||
while something plays), `shadow(painter, rect, radius, dark)` (one soft shadow for floating surfaces; egui's
|
||||
`window_shadow`/`popup_shadow` are set to match).
|
||||
|
||||
**What egui can't do here:** no text blur or text shadows; no per-glyph variable axes inside one label (a weight is
|
||||
a font family); shadows are tessellator-blurred rectangles only (not arbitrary shapes); `Ui::id`/`Id::new` are
|
||||
deprecated in 0.37 but still used across the code.
|
||||
|
||||
## Feature checklist
|
||||
|
||||
See `docs/FEATURES.md`; every row names the file that implements it and its review state.
|
||||
|
|
|
|||
|
|
@ -54,6 +54,20 @@ One entry per session, newest last, ≤ 15 lines: done, verified how, not done,
|
|||
- Not done: real-GPU check (S010). PiP loses page state (in DESIGN engine limits). Split view now impossible.
|
||||
- Later: status field `painters` counts web views, not painters; rename. malloc_trim after discard.
|
||||
|
||||
## S015 — Material You foundation (2026-11-11)
|
||||
- Done: `theme.rs` M3 schemes from `material-colors =0.4.2` (D-009) with all roles + old aliases; `theme::apply` stores
|
||||
tokens (palette, roundness, motion) in the egui context; shape/space/type tokens; springs (FAST/DEFAULT/SLOW/EFFECT,
|
||||
Motion setting scales or disables). Outfit variable font (5 weights) + Material Symbols subset (`tools/icons.py`,
|
||||
139 icons, 55 KB). `widgets.rs` restyled (buttons, icon buttons, switch, segmented, card, rows), `ui/paint.rs`
|
||||
(cookie, wavy line/progress, shadow), hidden `nacre://gallery` + `tests/smoke/gallery.txt`. DESIGN.md § UI system.
|
||||
- Fixed: R1-01 (every emoji/Unicode glyph in src/ui now an icon constant); R1-02 (strong text used on_primary =
|
||||
white in light theme; clock now Thin Outfit in primary).
|
||||
- Verified: 38 unit tests (reference colours #555992/#BEC2FF/#65558F/#CFBDFE, contrast ≥ 4.5 for 12 presets light and
|
||||
dark, widget click/Tab+Space/hover-settle); gallery.txt and launch.txt exit 0, shots checked by eye.
|
||||
- Not done: focus ring and pressed states not seen in screenshots (tests only); no real-GPU check; no CJK font.
|
||||
- Later: chrome toolbar glyphs still drawn at text size via egui Buttons (S016); `egui::Ui::id`/`Id::new`
|
||||
deprecation warnings across src/ui.
|
||||
|
||||
## Later
|
||||
- Reader mode, split view, translate, real gamepad rumble (D-002: not planned for now).
|
||||
- Packaging and first release (D-001: plan when the user asks).
|
||||
|
|
|
|||
|
|
@ -1357,10 +1357,7 @@ impl App {
|
|||
let site = win.tab().and_then(|t| t.theme_color);
|
||||
let palette = theme::Palette::new(theme::seed(&settings, site, self.shared.system_accent), dark, &settings.theme.variant, settings.theme.contrast);
|
||||
let ctx = &win.egui.egui_ctx;
|
||||
// Pin egui's theme to ours so a system theme change can't swap in egui's default style.
|
||||
ctx.set_theme(if dark { egui::Theme::Dark } else { egui::Theme::Light });
|
||||
ctx.set_visuals(theme::visuals(&palette, theme::corner(&settings)));
|
||||
ctx.all_styles_mut(|style| style.animation_time = theme::animation_time(&settings));
|
||||
theme::apply(ctx, &palette, &settings);
|
||||
if (settings.ui.scale - 1.0).abs() > 0.01 {
|
||||
ctx.set_zoom_factor(settings.ui.scale.clamp(0.5, 3.0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ pub enum Page {
|
|||
Welcome,
|
||||
TaskManager,
|
||||
DevTools,
|
||||
/// Every widget and design token (not linked from the UI; for checking the design system).
|
||||
Gallery,
|
||||
/// Page source of the URL.
|
||||
Source(String),
|
||||
/// Network error page for a URL the browser itself couldn't open.
|
||||
|
|
@ -51,6 +53,7 @@ impl Page {
|
|||
"welcome" | "setup" => Page::Welcome,
|
||||
"task-manager" | "tasks" => Page::TaskManager,
|
||||
"devtools" => Page::DevTools,
|
||||
"gallery" => Page::Gallery,
|
||||
"source" => Page::Source(crate::util::percent_decode(&arg)),
|
||||
_ => return None,
|
||||
})
|
||||
|
|
@ -73,6 +76,7 @@ impl Page {
|
|||
Page::Welcome => "nacre://welcome".into(),
|
||||
Page::TaskManager => "nacre://task-manager".into(),
|
||||
Page::DevTools => "nacre://devtools".into(),
|
||||
Page::Gallery => "nacre://gallery".into(),
|
||||
Page::Source(url) => format!("nacre://source/{}", crate::util::encode_query(url)),
|
||||
Page::Error(url, _) => url.clone(),
|
||||
}
|
||||
|
|
@ -93,6 +97,7 @@ impl Page {
|
|||
Page::Welcome => "Welcome to Nacre".into(),
|
||||
Page::TaskManager => "Task manager".into(),
|
||||
Page::DevTools => "Developer tools".into(),
|
||||
Page::Gallery => "Gallery".into(),
|
||||
Page::Source(url) => format!("Source of {url}"),
|
||||
Page::Error(_, _) => crate::resources::ERROR_TITLE.into(),
|
||||
}
|
||||
|
|
|
|||
619
src/theme.rs
619
src/theme.rs
|
|
@ -1,7 +1,11 @@
|
|||
//! Colours and shapes for the interface, from the Appearance settings. Kept plain on purpose:
|
||||
//! one accent colour drives a small set of roles; the designed look comes later.
|
||||
//! The design tokens (docs/DESIGN.md "UI system"): Material You colour roles from a seed colour, shape, space, type
|
||||
//! and motion. Everything the interface draws takes its colours, radii, sizes and springs from here.
|
||||
|
||||
use egui::{Color32, CornerRadius, Visuals};
|
||||
use egui::{Color32, Context, CornerRadius, FontFamily, FontId, Id, Visuals};
|
||||
use material_colors::color::Argb;
|
||||
use material_colors::dynamic_color::{DynamicScheme, Variant};
|
||||
use material_colors::hct::Hct;
|
||||
use material_colors::palette::TonalPalette;
|
||||
|
||||
use crate::store::settings::{ColourFallback, ColourSource, Motion, Roundness, Settings, ThemeMode};
|
||||
|
||||
|
|
@ -44,49 +48,6 @@ pub fn to_hex(c: Color32) -> String {
|
|||
format!("#{:02X}{:02X}{:02X}", c.r(), c.g(), c.b())
|
||||
}
|
||||
|
||||
fn to_hsl(c: Color32) -> (f32, f32, f32) {
|
||||
let (r, g, b) = (c.r() as f32 / 255.0, c.g() as f32 / 255.0, c.b() as f32 / 255.0);
|
||||
let max = r.max(g).max(b);
|
||||
let min = r.min(g).min(b);
|
||||
let l = (max + min) / 2.0;
|
||||
if (max - min).abs() < 1e-6 {
|
||||
return (0.0, 0.0, l);
|
||||
}
|
||||
let d = max - min;
|
||||
let s = if l > 0.5 { d / (2.0 - max - min) } else { d / (max + min) };
|
||||
let h = if max == r { (g - b) / d + if g < b { 6.0 } else { 0.0 } } else if max == g { (b - r) / d + 2.0 } else { (r - g) / d + 4.0 };
|
||||
(h * 60.0, s, l)
|
||||
}
|
||||
|
||||
fn from_hsl(h: f32, s: f32, l: f32) -> Color32 {
|
||||
let hue = |p: f32, q: f32, mut t: f32| {
|
||||
if t < 0.0 {
|
||||
t += 1.0;
|
||||
}
|
||||
if t > 1.0 {
|
||||
t -= 1.0;
|
||||
}
|
||||
if t < 1.0 / 6.0 {
|
||||
p + (q - p) * 6.0 * t
|
||||
} else if t < 0.5 {
|
||||
q
|
||||
} else if t < 2.0 / 3.0 {
|
||||
p + (q - p) * (2.0 / 3.0 - t) * 6.0
|
||||
} else {
|
||||
p
|
||||
}
|
||||
};
|
||||
let (s, l) = (s.clamp(0.0, 1.0), l.clamp(0.0, 1.0));
|
||||
if s == 0.0 {
|
||||
let v = (l * 255.0) as u8;
|
||||
return Color32::from_rgb(v, v, v);
|
||||
}
|
||||
let q = if l < 0.5 { l * (1.0 + s) } else { l + s - l * s };
|
||||
let p = 2.0 * l - q;
|
||||
let h = h.rem_euclid(360.0) / 360.0;
|
||||
Color32::from_rgb((hue(p, q, h + 1.0 / 3.0) * 255.0) as u8, (hue(p, q, h) * 255.0) as u8, (hue(p, q, h - 1.0 / 3.0) * 255.0) as u8)
|
||||
}
|
||||
|
||||
/// The system accent colour: KDE's kdeglobals, else GNOME's accent-color setting.
|
||||
pub fn system_accent() -> Option<Color32> {
|
||||
#[cfg(unix)]
|
||||
|
|
@ -151,75 +112,158 @@ pub fn system_dark(winit_theme: Option<winit::window::Theme>) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
/// The colour roles the interface uses.
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
// Colour
|
||||
|
||||
/// The colour roles of a Material 3 scheme. The first block holds the names the older UI code uses; they alias M3
|
||||
/// roles (see `Palette::new`). New code uses the M3 names.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Palette {
|
||||
pub dark: bool,
|
||||
/// = primary.
|
||||
pub accent: Color32,
|
||||
/// = on_primary.
|
||||
pub on_accent: Color32,
|
||||
/// = secondary_container.
|
||||
pub accent_soft: Color32,
|
||||
/// = surface.
|
||||
pub surface: Color32,
|
||||
/// = surface_container_high.
|
||||
pub surface_high: Color32,
|
||||
/// = surface_container_lowest.
|
||||
pub surface_low: Color32,
|
||||
/// = on_surface.
|
||||
pub text: Color32,
|
||||
/// = on_surface_variant.
|
||||
pub text_weak: Color32,
|
||||
pub outline: Color32,
|
||||
pub error: Color32,
|
||||
/// Not an M3 role: an amber from a fixed hue, at the tones primary uses.
|
||||
pub warning: Color32,
|
||||
/// Not an M3 role: a green from a fixed hue, at the tones primary uses.
|
||||
pub success: Color32,
|
||||
|
||||
pub primary: Color32,
|
||||
pub on_primary: Color32,
|
||||
pub primary_container: Color32,
|
||||
pub on_primary_container: Color32,
|
||||
pub inverse_primary: Color32,
|
||||
pub secondary: Color32,
|
||||
pub on_secondary: Color32,
|
||||
pub secondary_container: Color32,
|
||||
pub on_secondary_container: Color32,
|
||||
pub tertiary: Color32,
|
||||
pub on_tertiary: Color32,
|
||||
pub tertiary_container: Color32,
|
||||
pub on_tertiary_container: Color32,
|
||||
pub on_error: Color32,
|
||||
pub error_container: Color32,
|
||||
pub on_error_container: Color32,
|
||||
pub surface_dim: Color32,
|
||||
pub surface_bright: Color32,
|
||||
pub surface_container_lowest: Color32,
|
||||
pub surface_container_low: Color32,
|
||||
pub surface_container: Color32,
|
||||
pub surface_container_high: Color32,
|
||||
pub surface_container_highest: Color32,
|
||||
pub on_surface: Color32,
|
||||
pub on_surface_variant: Color32,
|
||||
pub outline_variant: Color32,
|
||||
pub inverse_surface: Color32,
|
||||
pub inverse_on_surface: Color32,
|
||||
pub scrim: Color32,
|
||||
pub shadow: Color32,
|
||||
}
|
||||
|
||||
fn argb(c: Color32) -> Argb {
|
||||
Argb::new(255, c.r(), c.g(), c.b())
|
||||
}
|
||||
|
||||
fn color(a: Argb) -> Color32 {
|
||||
Color32::from_rgb(a.red, a.green, a.blue)
|
||||
}
|
||||
|
||||
impl Palette {
|
||||
/// The scheme for `seed`: `variant` is one of `VARIANTS`' keys, `contrast` runs from -1 (less) to 1 (more).
|
||||
pub fn new(seed: Color32, dark: bool, variant: &str, contrast: f32) -> Palette {
|
||||
let (h, s, _) = to_hsl(seed);
|
||||
let s = match variant {
|
||||
"vibrant" => (s * 1.25).min(1.0),
|
||||
"expressive" => (s * 1.1).min(1.0),
|
||||
"neutral" => s * 0.35,
|
||||
"monochrome" => 0.0,
|
||||
"fidelity" | "content" => s,
|
||||
_ => s * 0.8,
|
||||
let variant = match variant {
|
||||
"vibrant" => Variant::Vibrant,
|
||||
"expressive" => Variant::Expressive,
|
||||
"neutral" => Variant::Neutral,
|
||||
"monochrome" => Variant::Monochrome,
|
||||
"fidelity" => Variant::Fidelity,
|
||||
"content" => Variant::Content,
|
||||
_ => Variant::TonalSpot,
|
||||
};
|
||||
let h2 = if variant == "expressive" { h + 60.0 } else { h };
|
||||
let c = contrast.clamp(-1.0, 1.0) * 0.08;
|
||||
let tint = if variant == "monochrome" { 0.0 } else { (s * 0.22).min(0.18) };
|
||||
if dark {
|
||||
Palette {
|
||||
dark,
|
||||
accent: from_hsl(h, s.max(0.3).min(0.8), 0.72 + c),
|
||||
on_accent: from_hsl(h, 0.6, 0.18),
|
||||
accent_soft: from_hsl(h2, s * 0.5, 0.28),
|
||||
surface: from_hsl(h, tint, 0.075 - c * 0.5),
|
||||
surface_high: from_hsl(h, tint, 0.14),
|
||||
surface_low: from_hsl(h, tint, 0.05),
|
||||
text: from_hsl(h, tint * 0.5, 0.92 + c),
|
||||
text_weak: from_hsl(h, tint, 0.68 + c),
|
||||
outline: from_hsl(h, tint, 0.32),
|
||||
error: Color32::from_rgb(0xF2, 0xB8, 0xB5),
|
||||
warning: Color32::from_rgb(0xFF, 0xCC, 0x80),
|
||||
success: Color32::from_rgb(0xA5, 0xD6, 0xA7),
|
||||
}
|
||||
} else {
|
||||
Palette {
|
||||
dark,
|
||||
accent: from_hsl(h, s.max(0.35).min(0.85), 0.40 - c),
|
||||
on_accent: Color32::WHITE,
|
||||
accent_soft: from_hsl(h2, s * 0.6, 0.88),
|
||||
surface: from_hsl(h, tint, 0.975 + c * 0.2),
|
||||
surface_high: from_hsl(h, tint, 0.92),
|
||||
surface_low: from_hsl(h, tint, 0.995),
|
||||
text: from_hsl(h, tint * 0.5, 0.10 - c),
|
||||
text_weak: from_hsl(h, tint, 0.36 - c),
|
||||
outline: from_hsl(h, tint, 0.78),
|
||||
error: Color32::from_rgb(0xB3, 0x26, 0x1E),
|
||||
warning: Color32::from_rgb(0x8B, 0x50, 0x00),
|
||||
success: Color32::from_rgb(0x38, 0x6A, 0x20),
|
||||
}
|
||||
let s = DynamicScheme::by_variant(argb(seed), &variant, dark, Some(f64::from(contrast.clamp(-1.0, 1.0))));
|
||||
// Status colours keep their own hue and follow primary's tones, so they sit with the scheme.
|
||||
let tone = if dark { 80 } else { 40 };
|
||||
let status = |hue: f64, chroma: f64| color(TonalPalette::of(hue, chroma).tone(tone));
|
||||
Palette {
|
||||
dark,
|
||||
accent: color(s.primary()),
|
||||
on_accent: color(s.on_primary()),
|
||||
accent_soft: color(s.secondary_container()),
|
||||
surface: color(s.surface()),
|
||||
surface_high: color(s.surface_container_high()),
|
||||
surface_low: color(s.surface_container_lowest()),
|
||||
text: color(s.on_surface()),
|
||||
text_weak: color(s.on_surface_variant()),
|
||||
outline: color(s.outline()),
|
||||
error: color(s.error()),
|
||||
warning: status(75.0, 60.0),
|
||||
success: status(140.0, 48.0),
|
||||
primary: color(s.primary()),
|
||||
on_primary: color(s.on_primary()),
|
||||
primary_container: color(s.primary_container()),
|
||||
on_primary_container: color(s.on_primary_container()),
|
||||
inverse_primary: color(s.inverse_primary()),
|
||||
secondary: color(s.secondary()),
|
||||
on_secondary: color(s.on_secondary()),
|
||||
secondary_container: color(s.secondary_container()),
|
||||
on_secondary_container: color(s.on_secondary_container()),
|
||||
tertiary: color(s.tertiary()),
|
||||
on_tertiary: color(s.on_tertiary()),
|
||||
tertiary_container: color(s.tertiary_container()),
|
||||
on_tertiary_container: color(s.on_tertiary_container()),
|
||||
on_error: color(s.on_error()),
|
||||
error_container: color(s.error_container()),
|
||||
on_error_container: color(s.on_error_container()),
|
||||
surface_dim: color(s.surface_dim()),
|
||||
surface_bright: color(s.surface_bright()),
|
||||
surface_container_lowest: color(s.surface_container_lowest()),
|
||||
surface_container_low: color(s.surface_container_low()),
|
||||
surface_container: color(s.surface_container()),
|
||||
surface_container_high: color(s.surface_container_high()),
|
||||
surface_container_highest: color(s.surface_container_highest()),
|
||||
on_surface: color(s.on_surface()),
|
||||
on_surface_variant: color(s.on_surface_variant()),
|
||||
outline_variant: color(s.outline_variant()),
|
||||
inverse_surface: color(s.inverse_surface()),
|
||||
inverse_on_surface: color(s.inverse_on_surface()),
|
||||
scrim: color(s.scrim()),
|
||||
shadow: color(s.shadow()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Seed colour from the settings; `site` is the current page's colour when the source is "Website".
|
||||
/// `over` laid on `base` at `amount` (0..1): state layers (hover, press) and tints, always opaque.
|
||||
pub fn layer(base: Color32, over: Color32, amount: f32) -> Color32 {
|
||||
let mix = |a: u8, b: u8| (f32::from(a) + (f32::from(b) - f32::from(a)) * amount.clamp(0.0, 1.0)).round() as u8;
|
||||
Color32::from_rgb(mix(base.r(), over.r()), mix(base.g(), over.g()), mix(base.b(), over.b()))
|
||||
}
|
||||
|
||||
/// State layer opacities (M3): the content colour laid over the container.
|
||||
pub const HOVER: f32 = 0.08;
|
||||
pub const FOCUS: f32 = 0.10;
|
||||
pub const PRESS: f32 = 0.10;
|
||||
pub const DRAG: f32 = 0.16;
|
||||
/// Disabled controls: content and container opacity.
|
||||
pub const DISABLED_CONTENT: f32 = 0.38;
|
||||
pub const DISABLED_CONTAINER: f32 = 0.12;
|
||||
|
||||
/// Seed colour from the settings; `site` is the current page's colour when the source is "Website". Greys and
|
||||
/// near-black or near-white site colours make poor seeds, so they fall back.
|
||||
pub fn seed(settings: &Settings, site: Option<Color32>, system: Option<Color32>) -> Color32 {
|
||||
let preset = parse_hex(&settings.theme.preset).unwrap_or(Color32::from_rgb(0x67, 0x50, 0xA4));
|
||||
let fallback = || match settings.theme.fallback {
|
||||
|
|
@ -227,13 +271,18 @@ pub fn seed(settings: &Settings, site: Option<Color32>, system: Option<Color32>)
|
|||
ColourFallback::Palette => preset,
|
||||
};
|
||||
match settings.theme.source {
|
||||
ColourSource::Website => site.filter(|c| { let (_, s, l) = to_hsl(*c); s > 0.15 && l > 0.1 && l < 0.9 }).unwrap_or_else(fallback),
|
||||
ColourSource::Website => site.filter(|c| usable_seed(*c)).unwrap_or_else(fallback),
|
||||
ColourSource::System => system.unwrap_or(preset),
|
||||
ColourSource::Palette => preset,
|
||||
ColourSource::Custom => parse_hex(&settings.theme.custom).unwrap_or(preset),
|
||||
}
|
||||
}
|
||||
|
||||
fn usable_seed(c: Color32) -> bool {
|
||||
let hct = Hct::new(argb(c));
|
||||
hct.get_chroma() >= 12.0 && (8.0..=95.0).contains(&hct.get_tone())
|
||||
}
|
||||
|
||||
pub fn is_dark(settings: &Settings, system_is_dark: bool) -> bool {
|
||||
match settings.theme.mode {
|
||||
ThemeMode::System => system_is_dark,
|
||||
|
|
@ -242,56 +291,295 @@ pub fn is_dark(settings: &Settings, system_is_dark: bool) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn corner(settings: &Settings) -> u8 {
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
// Shape and space
|
||||
|
||||
/// Corner radii (M3 shape scale) at the Default roundness. Read them through `radius`, which applies the
|
||||
/// Roundness setting. `FULL` makes pills and circles.
|
||||
pub const XS: f32 = 4.0;
|
||||
pub const S: f32 = 8.0;
|
||||
pub const M: f32 = 12.0;
|
||||
pub const L: f32 = 16.0;
|
||||
pub const XL: f32 = 28.0;
|
||||
pub const FULL: f32 = 1000.0;
|
||||
|
||||
/// Spacing on a 4 px grid.
|
||||
pub const GAP_XS: f32 = 4.0;
|
||||
pub const GAP_S: f32 = 8.0;
|
||||
pub const GAP_M: f32 = 12.0;
|
||||
pub const GAP_L: f32 = 16.0;
|
||||
pub const GAP_XL: f32 = 24.0;
|
||||
|
||||
/// Control heights: compact chrome controls, standard buttons and fields, list rows.
|
||||
pub const CONTROL_SMALL: f32 = 32.0;
|
||||
pub const CONTROL: f32 = 40.0;
|
||||
pub const ROW: f32 = 56.0;
|
||||
|
||||
fn roundness_scale(settings: &Settings) -> f32 {
|
||||
match settings.ui.roundness {
|
||||
Roundness::Subtle => 4,
|
||||
Roundness::Normal => 8,
|
||||
Roundness::Round => 14,
|
||||
Roundness::Subtle => 0.5,
|
||||
Roundness::Normal => 1.0,
|
||||
Roundness::Round => 1.4,
|
||||
}
|
||||
}
|
||||
|
||||
/// Seconds for UI animations (0 = off).
|
||||
pub fn animation_time(settings: &Settings) -> f32 {
|
||||
/// A radius token with the Roundness setting applied. `FULL` stays full.
|
||||
pub fn radius(ctx: &Context, token: f32) -> f32 {
|
||||
if token >= FULL { FULL } else { token * tokens(ctx).roundness }
|
||||
}
|
||||
|
||||
/// egui's corner type, which holds whole points up to 255.
|
||||
pub fn corner_radius(r: f32) -> CornerRadius {
|
||||
CornerRadius::same(r.round().clamp(0.0, 255.0) as u8)
|
||||
}
|
||||
|
||||
/// Corner radius of small controls (the egui default widgets), from the Roundness setting.
|
||||
pub fn corner(settings: &Settings) -> u8 {
|
||||
(S * roundness_scale(settings)).round() as u8
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
// Type
|
||||
|
||||
/// Type scale. Weight and colour carry hierarchy before size does.
|
||||
pub const SMALL: f32 = 12.0;
|
||||
pub const BODY: f32 = 14.0;
|
||||
pub const TITLE: f32 = 18.0;
|
||||
pub const HEADLINE: f32 = 24.0;
|
||||
pub const DISPLAY: f32 = 64.0;
|
||||
|
||||
/// Outfit weights registered as font families (`ui::fonts`). Regular is egui's Proportional family.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Weight {
|
||||
Thin,
|
||||
Light,
|
||||
Regular,
|
||||
Medium,
|
||||
SemiBold,
|
||||
}
|
||||
|
||||
impl Weight {
|
||||
pub const ALL: [Weight; 5] = [Weight::Thin, Weight::Light, Weight::Regular, Weight::Medium, Weight::SemiBold];
|
||||
|
||||
pub fn wght(self) -> f32 {
|
||||
match self {
|
||||
Weight::Thin => 200.0,
|
||||
Weight::Light => 300.0,
|
||||
Weight::Regular => 400.0,
|
||||
Weight::Medium => 500.0,
|
||||
Weight::SemiBold => 600.0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn family(self) -> FontFamily {
|
||||
match self {
|
||||
Weight::Regular => FontFamily::Proportional,
|
||||
Weight::Thin => FontFamily::Name("outfit-thin".into()),
|
||||
Weight::Light => FontFamily::Name("outfit-light".into()),
|
||||
Weight::Medium => FontFamily::Name("outfit-medium".into()),
|
||||
Weight::SemiBold => FontFamily::Name("outfit-semibold".into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn font(size: f32, weight: Weight) -> FontId {
|
||||
FontId::new(size, weight.family())
|
||||
}
|
||||
|
||||
/// Material Symbols families: outlined (FILL 0) and filled (FILL 1, for selected states).
|
||||
pub fn icon_font(size: f32, filled: bool) -> FontId {
|
||||
FontId::new(size, FontFamily::Name(if filled { "icons-filled" } else { "icons" }.into()))
|
||||
}
|
||||
|
||||
/// Icon sizes: in chrome and lists, and large (empty states, cards).
|
||||
pub const ICON: f32 = 20.0;
|
||||
pub const ICON_LARGE: f32 = 32.0;
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
// Motion
|
||||
|
||||
/// A spring: `stiffness` and `damping` ratio (1 = critically damped, no overshoot). Presets from M3 Expressive.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Spring {
|
||||
pub stiffness: f32,
|
||||
pub damping: f32,
|
||||
}
|
||||
|
||||
/// Press and small controls.
|
||||
pub const FAST: Spring = Spring { stiffness: 1400.0, damping: 0.62 };
|
||||
/// Panels and movement.
|
||||
pub const DEFAULT: Spring = Spring { stiffness: 700.0, damping: 0.68 };
|
||||
/// Big transitions.
|
||||
pub const SLOW: Spring = Spring { stiffness: 300.0, damping: 0.74 };
|
||||
/// Colour, opacity and tints: never overshoots.
|
||||
pub const EFFECT: Spring = Spring { stiffness: 900.0, damping: 1.0 };
|
||||
|
||||
/// Motion setting as a time factor: 1 = Normal, 0 = Off.
|
||||
fn motion_scale(settings: &Settings) -> f32 {
|
||||
match settings.ui.motion {
|
||||
Motion::Off => 0.0,
|
||||
Motion::Fast => 0.06,
|
||||
Motion::Normal => 0.1,
|
||||
Motion::Slow => 0.18,
|
||||
Motion::Fast => 0.6,
|
||||
Motion::Normal => 1.0,
|
||||
Motion::Slow => 1.8,
|
||||
}
|
||||
}
|
||||
|
||||
/// egui visuals for a palette.
|
||||
/// Seconds for egui's own animations (collapsing headers, scroll), 0 = off.
|
||||
pub fn animation_time(settings: &Settings) -> f32 {
|
||||
0.1 * motion_scale(settings)
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct SpringState {
|
||||
value: f32,
|
||||
velocity: f32,
|
||||
frame: u64,
|
||||
}
|
||||
|
||||
/// A spring's current value, for tests.
|
||||
#[cfg(test)]
|
||||
pub fn spring_value(ctx: &Context, id: Id) -> Option<f32> {
|
||||
ctx.data(|d| d.get_temp::<SpringState>(id)).map(|s| s.value)
|
||||
}
|
||||
|
||||
/// Animates towards `target` with `spring` and returns this frame's value. The first call for an `id` starts at
|
||||
/// the target. Retargeting mid-flight keeps the velocity, so motion never snaps. Repaints only while moving; with
|
||||
/// Motion off it returns the target.
|
||||
pub fn spring(ctx: &Context, id: Id, target: f32, spring: Spring) -> f32 {
|
||||
let scale = tokens(ctx).motion;
|
||||
let frame = ctx.cumulative_frame_nr();
|
||||
let dt = ctx.input(|i| i.stable_dt).min(0.05);
|
||||
let (value, moving) = ctx.data_mut(|d| {
|
||||
let s = d.get_temp_mut_or_insert_with(id, || SpringState { value: target, velocity: 0.0, frame });
|
||||
if scale <= 0.0 {
|
||||
*s = SpringState { value: target, velocity: 0.0, frame };
|
||||
} else if s.frame != frame {
|
||||
s.frame = frame;
|
||||
spring_step(s, target, spring, scale, dt);
|
||||
}
|
||||
(s.value, s.value != target)
|
||||
});
|
||||
if moving {
|
||||
ctx.request_repaint();
|
||||
}
|
||||
value
|
||||
}
|
||||
|
||||
/// A 0..1 value for an on/off state with the `EFFECT` spring: hover and selection tints, fades.
|
||||
pub fn effect(ctx: &Context, id: Id, on: bool) -> f32 {
|
||||
spring(ctx, id, if on { 1.0 } else { 0.0 }, EFFECT).clamp(0.0, 1.0)
|
||||
}
|
||||
|
||||
/// Semi-implicit Euler in steps of at most 1/240 s. `scale` stretches time: the spring's stiffness drops with its
|
||||
/// square, so Slow takes `scale` times as long with the same shape.
|
||||
fn spring_step(s: &mut SpringState, target: f32, spring: Spring, scale: f32, dt: f32) {
|
||||
let k = spring.stiffness / (scale * scale);
|
||||
let c = 2.0 * spring.damping * k.sqrt();
|
||||
let steps = (dt * 240.0).ceil().max(1.0);
|
||||
let h = dt / steps;
|
||||
for _ in 0..steps as u32 {
|
||||
let a = -k * (s.value - target) - c * s.velocity;
|
||||
s.velocity += a * h;
|
||||
s.value += s.velocity * h;
|
||||
}
|
||||
if (s.value - target).abs() < 1e-3 && s.velocity.abs() < 1e-2 {
|
||||
s.value = target;
|
||||
s.velocity = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
// Applying the tokens
|
||||
|
||||
/// The tokens a window draws with, kept in its egui context so widgets can reach them from any `Ui`.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Tokens {
|
||||
pub palette: Palette,
|
||||
/// Roundness setting as a factor on the radius tokens.
|
||||
pub roundness: f32,
|
||||
/// Motion setting as a time factor (0 = off).
|
||||
pub motion: f32,
|
||||
}
|
||||
|
||||
pub fn tokens(ctx: &Context) -> Tokens {
|
||||
ctx.data(|d| d.get_temp::<Tokens>(Id::NULL)).unwrap_or_else(|| Tokens { palette: Palette::new(Color32::from_rgb(0x67, 0x50, 0xA4), true, "tonal_spot", 0.0), roundness: 1.0, motion: 1.0 })
|
||||
}
|
||||
|
||||
/// Shortcut for the palette in widgets.
|
||||
pub fn palette(ctx: &Context) -> Palette {
|
||||
tokens(ctx).palette
|
||||
}
|
||||
|
||||
/// Styles a window's egui context: tokens, visuals, text styles and spacing.
|
||||
pub fn apply(ctx: &Context, palette: &Palette, settings: &Settings) {
|
||||
ctx.data_mut(|d| d.insert_temp(Id::NULL, Tokens { palette: *palette, roundness: roundness_scale(settings), motion: motion_scale(settings) }));
|
||||
// Pin egui's theme to ours so a system theme change can't swap in egui's default style.
|
||||
ctx.set_theme(if palette.dark { egui::Theme::Dark } else { egui::Theme::Light });
|
||||
ctx.set_visuals(visuals(palette, corner(settings)));
|
||||
let time = animation_time(settings);
|
||||
ctx.all_styles_mut(|style| {
|
||||
use egui::TextStyle;
|
||||
style.animation_time = time;
|
||||
style.text_styles = [
|
||||
(TextStyle::Small, FontId::proportional(SMALL)),
|
||||
(TextStyle::Body, FontId::proportional(BODY)),
|
||||
(TextStyle::Button, FontId::proportional(BODY)),
|
||||
(TextStyle::Heading, font(HEADLINE, Weight::Medium)),
|
||||
(TextStyle::Monospace, FontId::monospace(13.0)),
|
||||
]
|
||||
.into();
|
||||
style.spacing.item_spacing = egui::vec2(GAP_S, 6.0);
|
||||
style.spacing.button_padding = egui::vec2(GAP_M, GAP_XS);
|
||||
style.spacing.interact_size.y = 24.0;
|
||||
style.spacing.menu_margin = egui::Margin::same(GAP_S as i8);
|
||||
});
|
||||
}
|
||||
|
||||
/// egui visuals for a palette: egui's own widgets (plain buttons, fields, menus) in the scheme's roles.
|
||||
pub fn visuals(p: &Palette, corner_radius: u8) -> Visuals {
|
||||
let mut v = if p.dark { Visuals::dark() } else { Visuals::light() };
|
||||
let r = CornerRadius::same(corner_radius);
|
||||
let big = CornerRadius::same(corner_radius.saturating_mul(2));
|
||||
v.panel_fill = p.surface;
|
||||
v.window_fill = p.surface_high;
|
||||
v.extreme_bg_color = p.surface_low;
|
||||
v.faint_bg_color = p.surface_high;
|
||||
v.override_text_color = Some(p.text);
|
||||
v.hyperlink_color = p.accent;
|
||||
v.selection.bg_fill = p.accent.gamma_multiply(0.45);
|
||||
v.selection.stroke.color = p.accent;
|
||||
v.window_corner_radius = r;
|
||||
v.menu_corner_radius = r;
|
||||
v.window_stroke.color = p.outline;
|
||||
v.window_fill = p.surface_container;
|
||||
v.extreme_bg_color = p.surface_container_highest;
|
||||
v.text_edit_bg_color = Some(p.surface_container_highest);
|
||||
v.faint_bg_color = p.surface_container_low;
|
||||
v.code_bg_color = p.surface_container_high;
|
||||
v.override_text_color = Some(p.on_surface);
|
||||
v.weak_text_color = Some(p.on_surface_variant);
|
||||
v.hyperlink_color = p.primary;
|
||||
v.selection.bg_fill = layer(p.surface, p.primary, 0.35);
|
||||
v.selection.stroke.color = p.primary;
|
||||
v.window_corner_radius = big;
|
||||
v.menu_corner_radius = big;
|
||||
v.window_stroke.color = p.outline_variant;
|
||||
v.window_shadow = egui::Shadow { offset: [0, 4], blur: 16, spread: 0, color: Color32::from_black_alpha(if p.dark { 90 } else { 40 }) };
|
||||
v.popup_shadow = egui::Shadow { offset: [0, 2], blur: 10, spread: 0, color: Color32::from_black_alpha(if p.dark { 80 } else { 32 }) };
|
||||
v.error_fg_color = p.error;
|
||||
v.warn_fg_color = p.warning;
|
||||
for w in [&mut v.widgets.noninteractive, &mut v.widgets.inactive, &mut v.widgets.hovered, &mut v.widgets.active, &mut v.widgets.open] {
|
||||
let base = p.surface_container_highest;
|
||||
for (w, fill) in [
|
||||
(&mut v.widgets.noninteractive, p.surface),
|
||||
(&mut v.widgets.inactive, base),
|
||||
(&mut v.widgets.hovered, layer(base, p.on_surface, HOVER)),
|
||||
(&mut v.widgets.active, layer(base, p.on_surface, HOVER + PRESS)),
|
||||
(&mut v.widgets.open, layer(base, p.on_surface, HOVER)),
|
||||
] {
|
||||
w.corner_radius = r;
|
||||
w.bg_fill = fill;
|
||||
w.weak_bg_fill = fill;
|
||||
w.bg_stroke = egui::Stroke::NONE;
|
||||
// Strong text is egui's active foreground: it must stay readable on the page (R1-02).
|
||||
w.fg_stroke.color = p.on_surface;
|
||||
w.expansion = 0.0;
|
||||
}
|
||||
v.widgets.noninteractive.bg_fill = p.surface;
|
||||
v.widgets.noninteractive.bg_stroke.color = p.outline;
|
||||
v.widgets.noninteractive.fg_stroke.color = p.text;
|
||||
v.widgets.inactive.bg_fill = p.surface_high;
|
||||
v.widgets.inactive.weak_bg_fill = p.surface_high;
|
||||
v.widgets.inactive.fg_stroke.color = p.text;
|
||||
v.widgets.hovered.bg_fill = p.accent_soft;
|
||||
v.widgets.hovered.weak_bg_fill = p.accent_soft;
|
||||
v.widgets.hovered.bg_stroke.color = p.accent;
|
||||
v.widgets.active.bg_fill = p.accent;
|
||||
v.widgets.active.weak_bg_fill = p.accent;
|
||||
v.widgets.active.fg_stroke.color = p.on_accent;
|
||||
v.widgets.noninteractive.bg_stroke = egui::Stroke::new(1.0, p.outline_variant);
|
||||
v.widgets.noninteractive.fg_stroke.color = p.on_surface_variant;
|
||||
v.widgets.inactive.fg_stroke.color = p.on_surface_variant;
|
||||
v.widgets.hovered.bg_stroke = egui::Stroke::new(1.0, p.outline);
|
||||
v.widgets.active.bg_stroke = egui::Stroke::new(1.0, p.primary);
|
||||
v.widgets.open.bg_stroke = egui::Stroke::new(1.0, p.outline);
|
||||
v
|
||||
}
|
||||
|
||||
|
|
@ -315,9 +603,82 @@ mod tests {
|
|||
assert_eq!(parse_hex("#6750A4"), Some(Color32::from_rgb(0x67, 0x50, 0xA4)));
|
||||
assert_eq!(parse_css_color("rgb(10, 20, 30)"), Some(Color32::from_rgb(10, 20, 30)));
|
||||
assert_eq!(parse_css_color("rgba(0, 0, 0, 0)"), None);
|
||||
let c = Color32::from_rgb(200, 100, 50);
|
||||
let (h, s, l) = to_hsl(c);
|
||||
let back = from_hsl(h, s, l);
|
||||
assert!((back.r() as i32 - 200).abs() <= 1 && (back.g() as i32 - 100).abs() <= 1);
|
||||
assert_eq!(to_hex(Color32::from_rgb(200, 100, 50)), "#C86432");
|
||||
}
|
||||
|
||||
fn hex(c: Color32) -> String {
|
||||
to_hex(c)
|
||||
}
|
||||
|
||||
/// Reference colours from Material Color Utilities' tonal spot tests (seed 0xff0000ff, standard contrast) and
|
||||
/// Material Theme Builder (seed #6750A4).
|
||||
#[test]
|
||||
fn tonal_spot_reference_colours() {
|
||||
let blue = Color32::from_rgb(0, 0, 255);
|
||||
let light = Palette::new(blue, false, "tonal_spot", 0.0);
|
||||
let dark = Palette::new(blue, true, "tonal_spot", 0.0);
|
||||
assert_eq!(hex(light.primary), "#555992");
|
||||
assert_eq!(hex(light.primary_container), "#E0E0FF");
|
||||
assert_eq!(hex(dark.primary), "#BEC2FF");
|
||||
let violet = parse_hex("#6750A4").unwrap();
|
||||
assert_eq!(hex(Palette::new(violet, false, "tonal_spot", 0.0).primary), "#65558F");
|
||||
assert_eq!(hex(Palette::new(violet, true, "tonal_spot", 0.0).primary), "#CFBDFE");
|
||||
}
|
||||
|
||||
fn tone(c: Color32) -> f64 {
|
||||
Hct::new(argb(c)).get_tone()
|
||||
}
|
||||
|
||||
/// The scheme's tones follow the M3 spec for every preset seed: surface T98 / T6, primary T40 / T80, and text
|
||||
/// at least 4.5:1 on every surface, in light and dark.
|
||||
#[test]
|
||||
fn scheme_tones_and_contrast() {
|
||||
for preset in PRESETS {
|
||||
let seed = parse_hex(preset).unwrap();
|
||||
for dark in [false, true] {
|
||||
let p = Palette::new(seed, dark, "tonal_spot", 0.0);
|
||||
let (surface, primary) = if dark { (6.0, 80.0) } else { (98.0, 40.0) };
|
||||
assert!((tone(p.surface) - surface).abs() < 1.0, "{preset} dark={dark} surface tone {}", tone(p.surface));
|
||||
assert!((tone(p.primary) - primary).abs() < 1.0, "{preset} dark={dark} primary tone {}", tone(p.primary));
|
||||
for (name, bg) in [("surface", p.surface), ("lowest", p.surface_container_lowest), ("highest", p.surface_container_highest)] {
|
||||
for (text_name, fg) in [("on_surface", p.on_surface), ("on_surface_variant", p.on_surface_variant)] {
|
||||
let ratio = material_colors::contrast::ratio_of_tones(tone(fg), tone(bg));
|
||||
assert!(ratio >= 4.5, "{preset} dark={dark} {text_name} on {name}: {ratio:.2}");
|
||||
}
|
||||
}
|
||||
let ratio = material_colors::contrast::ratio_of_tones(tone(p.on_primary), tone(p.primary));
|
||||
assert!(ratio >= 4.5, "{preset} dark={dark} on_primary: {ratio:.2}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Every variant builds, and grey site colours don't become seeds.
|
||||
#[test]
|
||||
fn variants_and_seeds() {
|
||||
for (key, _) in VARIANTS {
|
||||
let p = Palette::new(Color32::from_rgb(0x00, 0x6A, 0x6A), true, key, 0.0);
|
||||
assert_ne!(p.primary, p.surface, "{key}");
|
||||
}
|
||||
assert!(!usable_seed(Color32::from_rgb(128, 128, 128)));
|
||||
assert!(!usable_seed(Color32::WHITE));
|
||||
assert!(usable_seed(Color32::from_rgb(0x0B, 0x57, 0xD0)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spring_settles_on_target() {
|
||||
let mut s = SpringState { value: 0.0, velocity: 0.0, frame: 0 };
|
||||
let mut peak: f32 = 0.0;
|
||||
for _ in 0..120 {
|
||||
spring_step(&mut s, 1.0, FAST, 1.0, 1.0 / 60.0);
|
||||
peak = peak.max(s.value);
|
||||
}
|
||||
assert_eq!(s.value, 1.0);
|
||||
assert!(peak > 1.0, "FAST overshoots a little");
|
||||
let mut s = SpringState { value: 0.0, velocity: 0.0, frame: 0 };
|
||||
for _ in 0..120 {
|
||||
spring_step(&mut s, 1.0, EFFECT, 1.0, 1.0 / 60.0);
|
||||
assert!(s.value <= 1.0, "EFFECT never overshoots");
|
||||
}
|
||||
assert_eq!(s.value, 1.0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use crate::net::VpnStatus;
|
|||
use crate::store::settings::{BookmarksBar, MediaButton};
|
||||
use crate::tabs::Page;
|
||||
use crate::util;
|
||||
use crate::ui::icons;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum SuggestionKind {
|
||||
|
|
@ -45,13 +46,13 @@ pub fn title_bar(root: &mut Ui, f: &mut Frame) {
|
|||
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
||||
// Same size for all three, flush right.
|
||||
let size = Vec2::new(40.0, 26.0);
|
||||
if ui.add_sized(size, egui::Button::new("✕").frame(false)).on_hover_text("Close").clicked() {
|
||||
if ui.add_sized(size, egui::Button::new(icons::CLOSE).frame(false)).on_hover_text("Close").clicked() {
|
||||
f.send(Command::WindowClose);
|
||||
}
|
||||
if ui.add_sized(size, egui::Button::new("🗖").frame(false)).on_hover_text("Maximize").clicked() {
|
||||
if ui.add_sized(size, egui::Button::new(icons::CROP_SQUARE).frame(false)).on_hover_text("Maximize").clicked() {
|
||||
f.send(Command::WindowMaximize);
|
||||
}
|
||||
if ui.add_sized(size, egui::Button::new("🗕").frame(false)).on_hover_text("Minimize").clicked() {
|
||||
if ui.add_sized(size, egui::Button::new(icons::MINIMIZE).frame(false)).on_hover_text("Minimize").clicked() {
|
||||
f.send(Command::WindowMinimize);
|
||||
}
|
||||
});
|
||||
|
|
@ -83,7 +84,7 @@ pub fn tab_strip(root: &mut Ui, f: &mut Frame) {
|
|||
}
|
||||
});
|
||||
});
|
||||
if icon_button(ui, "➕", "New tab (Ctrl+T)").clicked() {
|
||||
if icon_button(ui, icons::ADD, "New tab (Ctrl+T)").clicked() {
|
||||
f.send(Command::NewTab);
|
||||
}
|
||||
});
|
||||
|
|
@ -117,7 +118,7 @@ fn tab_button(ui: &mut Ui, f: &mut Frame, index: usize, width: f32) -> Option<us
|
|||
} else if let Some(texture) = &tab.favicon {
|
||||
ui.painter().image(texture.id(), icon_rect, egui::Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), Color32::WHITE);
|
||||
} else {
|
||||
let g = if tab.page.is_some() { "◆" } else { "●" };
|
||||
let g = if tab.page.is_some() { icons::TAB } else { icons::PUBLIC };
|
||||
ui.painter().text(icon_rect.center(), egui::Align2::CENTER_CENTER, g, egui::FontId::proportional(11.0), palette.text_weak);
|
||||
}
|
||||
x += 22.0;
|
||||
|
|
@ -130,13 +131,13 @@ fn tab_button(ui: &mut Ui, f: &mut Frame, index: usize, width: f32) -> Option<us
|
|||
if close.hovered() {
|
||||
ui.painter().rect_filled(close_rect, 4.0, palette.outline);
|
||||
}
|
||||
ui.painter().text(close_rect.center(), egui::Align2::CENTER_CENTER, "✕", egui::FontId::proportional(11.0), palette.text);
|
||||
ui.painter().text(close_rect.center(), egui::Align2::CENTER_CENTER, icons::CLOSE, crate::theme::icon_font(14.0, false), palette.text);
|
||||
close_clicked = close.clicked();
|
||||
let mut title_right = close_rect.left() - 4.0;
|
||||
if tab.audible() || tab.muted {
|
||||
let mute_rect = egui::Rect::from_center_size(egui::pos2(title_right - 9.0, center_y), Vec2::splat(18.0));
|
||||
let mute = ui.interact(mute_rect, ui.id().with(("mute", tab_id)), Sense::click()).on_hover_text(if tab.muted { "Unmute tab" } else { "Mute tab" });
|
||||
ui.painter().text(mute_rect.center(), egui::Align2::CENTER_CENTER, if tab.muted { "🔇" } else { "🔊" }, egui::FontId::proportional(12.0), palette.text);
|
||||
ui.painter().text(mute_rect.center(), egui::Align2::CENTER_CENTER, if tab.muted { icons::VOLUME_OFF } else { icons::VOLUME_UP }, crate::theme::icon_font(14.0, false), palette.text);
|
||||
mute_clicked = mute.clicked();
|
||||
title_right = mute_rect.left() - 2.0;
|
||||
}
|
||||
|
|
@ -198,7 +199,7 @@ pub fn toolbar(root: &mut Ui, f: &mut Frame) {
|
|||
}
|
||||
if settings.toolbar_has("reload") {
|
||||
if loading {
|
||||
if icon_button(ui, "✕", "Stop").clicked() {
|
||||
if icon_button(ui, icons::CLOSE, "Stop").clicked() {
|
||||
f.send(Command::Stop);
|
||||
}
|
||||
} else if icon_button(ui, glyph("reload"), "Reload (Ctrl+R) · Shift-click: without cache").clicked() {
|
||||
|
|
@ -212,7 +213,7 @@ pub fn toolbar(root: &mut Ui, f: &mut Frame) {
|
|||
// Buttons on the right first, so the address bar can take what's left.
|
||||
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
||||
ui.spacing_mut().item_spacing.x = 2.0;
|
||||
let menu = icon_button(ui, "☰", "Menu");
|
||||
let menu = icon_button(ui, icons::MENU, "Menu");
|
||||
if menu.clicked() {
|
||||
f.ui.toggle(Flyout::Main, Some(menu.rect));
|
||||
}
|
||||
|
|
@ -226,7 +227,7 @@ pub fn toolbar(root: &mut Ui, f: &mut Frame) {
|
|||
fn right_buttons(ui: &mut Ui, f: &mut Frame, settings: &crate::store::settings::Settings) {
|
||||
let palette = f.palette();
|
||||
if f.shared.profile_count() > 1 || f.incognito() {
|
||||
let label = if f.incognito() { "🕶".to_owned() } else { f.shared.paths.profile.chars().next().map(|c| c.to_uppercase().to_string()).unwrap_or_default() };
|
||||
let label = if f.incognito() { icons::DOMINO_MASK.to_owned() } else { f.shared.paths.profile.chars().next().map(|c| c.to_uppercase().to_string()).unwrap_or_default() };
|
||||
let r = ui.add(egui::Button::new(label).min_size(Vec2::splat(28.0))).on_hover_text(format!("Profile: {}", f.shared.paths.profile));
|
||||
if r.clicked() {
|
||||
f.ui.toggle(Flyout::Profiles, Some(r.rect));
|
||||
|
|
@ -262,7 +263,7 @@ fn right_buttons(ui: &mut Ui, f: &mut Frame, settings: &crate::store::settings::
|
|||
if settings.toolbar_has("adblock") {
|
||||
let blocked = f.tab().map(|t| t.blocked).unwrap_or(0);
|
||||
let paused = f.tab().is_some_and(|t| settings.adblock_paused_on(&t.host()));
|
||||
let label = if !settings.adblock.enabled || paused { RichText::new("🛡").weak() } else if blocked > 0 { RichText::new(format!("🛡{blocked}")) } else { RichText::new("🛡") };
|
||||
let label = if !settings.adblock.enabled || paused { RichText::new(icons::SHIELD).weak() } else if blocked > 0 { RichText::new(format!("{}{blocked}", icons::SHIELD)) } else { RichText::new(icons::SHIELD) };
|
||||
let r = ui.add(egui::Button::new(label.size(14.0)).min_size(Vec2::splat(28.0)).frame(false)).on_hover_text(format!("Ad blocker · {blocked} blocked on this page"));
|
||||
if r.clicked() {
|
||||
f.ui.toggle(Flyout::Shield, Some(r.rect));
|
||||
|
|
@ -275,8 +276,8 @@ fn right_buttons(ui: &mut Ui, f: &mut Frame, settings: &crate::store::settings::
|
|||
drop(downloads);
|
||||
let label = match (running, progress) {
|
||||
(0, _) => RichText::new(glyph("downloads")),
|
||||
(_, Some(p)) => RichText::new(format!("⬇{:.0}%", p * 100.0)).color(palette.accent),
|
||||
(n, None) => RichText::new(format!("⬇{n}")).color(palette.accent),
|
||||
(_, Some(p)) => RichText::new(format!("{}{:.0}%", icons::DOWNLOAD, p * 100.0)).color(palette.accent),
|
||||
(n, None) => RichText::new(format!("{}{n}", icons::DOWNLOAD)).color(palette.accent),
|
||||
};
|
||||
let r = ui.add(egui::Button::new(label.size(14.0)).min_size(Vec2::splat(28.0)).frame(false)).on_hover_text("Downloads (Ctrl+J)");
|
||||
if r.clicked() {
|
||||
|
|
@ -322,7 +323,7 @@ fn omnibox(ui: &mut Ui, f: &mut Frame) {
|
|||
let bookmarked = is_web && f.shared.bookmarks.borrow().is_bookmarked(&tab.url);
|
||||
let installable = is_web && shown.starts_with("http") && f.shared.apps.borrow().for_url(&url::Url::parse(&shown).unwrap_or_else(|_| url::Url::parse("about:blank").expect("valid"))).is_none();
|
||||
// Site info button.
|
||||
let lock = if !is_web { "◆" } else if secure { "🔒" } else if shown.starts_with("http://") { "⚠" } else { "ℹ" };
|
||||
let lock = if !is_web { icons::TAB } else if secure { icons::LOCK } else if shown.starts_with("http://") { icons::WARNING } else { icons::INFO };
|
||||
let r = ui.add(egui::Button::new(lock).frame(false).min_size(Vec2::splat(26.0))).on_hover_text(if secure { "Connection is secure" } else if is_web { "Connection is not secure" } else { "Nacre page" });
|
||||
if r.clicked() && is_web {
|
||||
f.ui.toggle(Flyout::SiteInfo, Some(r.rect));
|
||||
|
|
@ -406,11 +407,11 @@ fn omnibox(ui: &mut Ui, f: &mut Frame) {
|
|||
if (zoom - 1.0).abs() > 0.001 && ui.add(egui::Button::new(format!("{:.0}%", zoom * 100.0)).frame(false)).on_hover_text("Zoom · click to reset").clicked() {
|
||||
f.send(Command::Zoom(0));
|
||||
}
|
||||
if installable && icon_button(ui, "⊕", "Install this site as an app").clicked() {
|
||||
if installable && icon_button(ui, icons::INSTALL_DESKTOP, "Install this site as an app").clicked() {
|
||||
f.send(Command::InstallApp);
|
||||
}
|
||||
if is_web {
|
||||
let star = ui.add(egui::Button::new(RichText::new(if bookmarked { "★" } else { "☆" }).color(if bookmarked { palette.accent } else { palette.text })).frame(false).min_size(Vec2::splat(26.0))).on_hover_text("Bookmark this page (Ctrl+D)");
|
||||
let star = ui.add(egui::Button::new(RichText::new(icons::STAR).font(crate::theme::icon_font(18.0, bookmarked)).color(if bookmarked { palette.accent } else { palette.text })).frame(false).min_size(Vec2::splat(26.0))).on_hover_text("Bookmark this page (Ctrl+D)");
|
||||
if star.clicked() {
|
||||
if bookmarked {
|
||||
f.ui.toggle(Flyout::EditBookmark(f.tabs[*f.active].url.clone()), Some(star.rect));
|
||||
|
|
@ -494,12 +495,12 @@ fn suggestion_popup(ui: &mut Ui, f: &mut Frame, below: egui::Rect) {
|
|||
ui.set_width(below.width());
|
||||
for (i, s) in items.iter().enumerate() {
|
||||
let icon = match s.kind {
|
||||
SuggestionKind::Search | SuggestionKind::SearchSuggestion => "🔍",
|
||||
SuggestionKind::Url => "↗",
|
||||
SuggestionKind::History => "🕘",
|
||||
SuggestionKind::Bookmark => "★",
|
||||
SuggestionKind::Tab(_) => "▭",
|
||||
SuggestionKind::Page => "◆",
|
||||
SuggestionKind::Search | SuggestionKind::SearchSuggestion => icons::SEARCH,
|
||||
SuggestionKind::Url => icons::OPEN_IN_NEW,
|
||||
SuggestionKind::History => icons::HISTORY,
|
||||
SuggestionKind::Bookmark => icons::STAR,
|
||||
SuggestionKind::Tab(_) => icons::TAB,
|
||||
SuggestionKind::Page => icons::TAB,
|
||||
};
|
||||
let detail = if matches!(s.kind, SuggestionKind::History | SuggestionKind::Bookmark | SuggestionKind::Tab(_)) { format!(" {}", util::ellipsize(&s.url, 70)) } else { String::new() };
|
||||
let text = format!("{icon} {}{detail}", util::ellipsize(if s.title.is_empty() { &s.url } else { &s.title }, 80));
|
||||
|
|
@ -563,7 +564,7 @@ fn bookmark_item(ui: &mut Ui, f: &mut Frame, node: &crate::store::bookmarks::Nod
|
|||
}
|
||||
},
|
||||
None => {
|
||||
ui.menu_button(format!("📁 {}", util::ellipsize(&node.title, 20)), |ui| {
|
||||
ui.menu_button(format!("{} {}", icons::FOLDER, util::ellipsize(&node.title, 20)), |ui| {
|
||||
folder_menu(ui, f, node);
|
||||
});
|
||||
},
|
||||
|
|
@ -583,7 +584,7 @@ fn folder_menu(ui: &mut Ui, f: &mut Frame, folder: &crate::store::bookmarks::Nod
|
|||
}
|
||||
},
|
||||
None => {
|
||||
ui.menu_button(format!("📁 {}", util::ellipsize(&child.title, 40)), |ui| folder_menu(ui, f, child));
|
||||
ui.menu_button(format!("{} {}", icons::FOLDER, util::ellipsize(&child.title, 40)), |ui| folder_menu(ui, f, child));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -603,10 +604,10 @@ pub fn app_bar(root: &mut Ui, f: &mut Frame) {
|
|||
egui::Panel::top("app-bar").exact_size(32.0).show(root, |ui| {
|
||||
ui.horizontal_centered(|ui| {
|
||||
let can_back = f.tab().is_some_and(|t| t.can_go_back());
|
||||
if ui.add_enabled(can_back, egui::Button::new("⬅").frame(false)).clicked() {
|
||||
if ui.add_enabled(can_back, egui::Button::new(icons::ARROW_BACK).frame(false)).clicked() {
|
||||
f.send(Command::Back);
|
||||
}
|
||||
if icon_button(ui, "⟳", "Reload").clicked() {
|
||||
if icon_button(ui, icons::REFRESH, "Reload").clicked() {
|
||||
f.send(Command::Reload { hard: false });
|
||||
}
|
||||
let title = f.tab().map(|t| t.display_title()).unwrap_or_default();
|
||||
|
|
@ -615,11 +616,11 @@ pub fn app_bar(root: &mut Ui, f: &mut Frame) {
|
|||
ui.label(RichText::new(util::host_of_str(&url)).weak().small());
|
||||
}
|
||||
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
||||
let menu = icon_button(ui, "☰", "Menu");
|
||||
let menu = icon_button(ui, icons::MENU, "Menu");
|
||||
if menu.clicked() {
|
||||
f.ui.toggle(Flyout::Main, Some(menu.rect));
|
||||
}
|
||||
if icon_button(ui, "↗", "Open in the browser").clicked()
|
||||
if icon_button(ui, icons::OPEN_IN_NEW, "Open in the browser").clicked()
|
||||
&& let Some(url) = f.tab().map(|t| t.url.clone())
|
||||
{
|
||||
f.send(Command::Open { url, how: Disposition::NewForegroundTab, from: None });
|
||||
|
|
@ -655,19 +656,19 @@ pub fn pip_window(root: &mut Ui, f: &mut Frame) {
|
|||
egui::Frame::popup(ui.style()).fill(Color32::from_black_alpha(170)).show(ui, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
let white = |t: &str| RichText::new(t).color(Color32::WHITE).size(16.0);
|
||||
if ui.add(egui::Button::new(white("⏪")).frame(false)).on_hover_text("Back 10 seconds").clicked() {
|
||||
if ui.add(egui::Button::new(white(icons::FAST_REWIND)).frame(false)).on_hover_text("Back 10 seconds").clicked() {
|
||||
f.send(Command::PipAct { action: "skip".into(), value: -10.0 });
|
||||
}
|
||||
if ui.add(egui::Button::new(white("⏯")).frame(false)).on_hover_text("Play or pause").clicked() {
|
||||
if ui.add(egui::Button::new(white(icons::PLAY_PAUSE)).frame(false)).on_hover_text("Play or pause").clicked() {
|
||||
f.send(Command::PipAct { action: "toggle".into(), value: 0.0 });
|
||||
}
|
||||
if ui.add(egui::Button::new(white("⏩")).frame(false)).on_hover_text("Forward 10 seconds").clicked() {
|
||||
if ui.add(egui::Button::new(white(icons::FAST_FORWARD)).frame(false)).on_hover_text("Forward 10 seconds").clicked() {
|
||||
f.send(Command::PipAct { action: "skip".into(), value: 10.0 });
|
||||
}
|
||||
if ui.add(egui::Button::new(white("🔇")).frame(false)).on_hover_text("Mute").clicked() {
|
||||
if ui.add(egui::Button::new(white(icons::VOLUME_OFF)).frame(false)).on_hover_text("Mute").clicked() {
|
||||
f.send(Command::PipAct { action: "mute".into(), value: 0.0 });
|
||||
}
|
||||
if ui.add(egui::Button::new(white("⤶")).frame(false)).on_hover_text("Back to the tab").clicked() {
|
||||
if ui.add(egui::Button::new(white(icons::PIP_EXIT)).frame(false)).on_hover_text("Back to the tab").clicked() {
|
||||
f.send(Command::ExitPip);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use super::Frame;
|
|||
use crate::actions::{Command, DialogResult, PromptAnswer};
|
||||
use crate::tabs::{Dialog, Prompt};
|
||||
use crate::util;
|
||||
use crate::ui::icons;
|
||||
|
||||
pub fn prompt_bars(root: &mut Ui, f: &mut Frame) {
|
||||
let Some(tab) = f.tab() else { return };
|
||||
|
|
@ -42,7 +43,7 @@ pub fn prompt_bars(root: &mut Ui, f: &mut Frame) {
|
|||
}
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let mut answer = None;
|
||||
if ui.small_button("✕").on_hover_text("Not now").clicked() {
|
||||
if ui.small_button(icons::CLOSE).on_hover_text("Not now").clicked() {
|
||||
answer = Some(PromptAnswer::Dismiss);
|
||||
}
|
||||
match kind {
|
||||
|
|
@ -117,17 +118,17 @@ pub fn find_bar(root: &mut Ui, f: &mut Frame) {
|
|||
}
|
||||
let label = if find.text.is_empty() { String::new() } else if find.count == 0 { "No matches".into() } else { format!("{} of {}", find.index, find.count) };
|
||||
ui.label(RichText::new(label).weak());
|
||||
if ui.small_button("⬆").on_hover_text("Previous (Shift+Enter)").clicked() {
|
||||
if ui.small_button(icons::ARROW_UPWARD).on_hover_text("Previous (Shift+Enter)").clicked() {
|
||||
f.send(Command::Find { text: find.text.clone(), forward: false, case: find.case_sensitive });
|
||||
}
|
||||
if ui.small_button("⬇").on_hover_text("Next (Enter)").clicked() {
|
||||
if ui.small_button(icons::ARROW_DOWNWARD).on_hover_text("Next (Enter)").clicked() {
|
||||
f.send(Command::Find { text: find.text.clone(), forward: true, case: find.case_sensitive });
|
||||
}
|
||||
if ui.checkbox(&mut find.case_sensitive, "Match case").changed() {
|
||||
f.send(Command::Find { text: find.text.clone(), forward: true, case: find.case_sensitive });
|
||||
}
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
if ui.small_button("✕").clicked() {
|
||||
if ui.small_button(icons::CLOSE).clicked() {
|
||||
f.send(Command::FindClose);
|
||||
}
|
||||
});
|
||||
|
|
@ -340,7 +341,7 @@ pub fn page_dialogs(ctx: &egui::Context, f: &mut Frame) {
|
|||
}
|
||||
for (id, user) in items {
|
||||
let label = if user.is_empty() { "(no user name)".to_owned() } else { user.clone() };
|
||||
if ui.button(format!("🔑 {label}")).clicked() {
|
||||
if ui.button(format!("{} {label}", icons::KEY)).clicked() {
|
||||
extra.push(Command::FillLogin { tab: tab_id, id: *id });
|
||||
}
|
||||
}
|
||||
|
|
@ -374,13 +375,13 @@ pub fn page_dialogs(ctx: &egui::Context, f: &mut Frame) {
|
|||
if kind == "card" {
|
||||
for c in &vault.contents.cards {
|
||||
let label = if c.nickname.is_empty() { c.masked() } else { format!("{} {}", c.nickname, c.masked()) };
|
||||
if ui.button(format!("💳 {label}")).clicked() {
|
||||
if ui.button(format!("{} {label}", icons::CREDIT_CARD)).clicked() {
|
||||
extra.push(Command::FillCard { tab: tab_id, id: c.id });
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for a in &vault.contents.addresses {
|
||||
if ui.button(format!("🏠 {}, {}", a.name, a.street)).clicked() {
|
||||
if ui.button(format!("{} {}, {}", icons::HOME, a.name, a.street)).clicked() {
|
||||
extra.push(Command::FillAddress { tab: tab_id, id: a.id });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
285
src/ui/icons.rs
Normal file
285
src/ui/icons.rs
Normal file
|
|
@ -0,0 +1,285 @@
|
|||
//! Material Symbols Outlined code points (Apache 2.0), from tools/icons.txt. Generated by tools/icons.py:
|
||||
//! edit the list and run the tool, don't edit this file.
|
||||
|
||||
pub const ARROW_BACK: &str = "\u{e5c4}";
|
||||
pub const ARROW_FORWARD: &str = "\u{e5c8}";
|
||||
pub const ARROW_UPWARD: &str = "\u{e5d8}";
|
||||
pub const ARROW_DOWNWARD: &str = "\u{e5db}";
|
||||
pub const REFRESH: &str = "\u{e5d5}";
|
||||
pub const CLOSE: &str = "\u{e5cd}";
|
||||
pub const HOME: &str = "\u{e9b2}";
|
||||
pub const ADD: &str = "\u{e145}";
|
||||
pub const REMOVE: &str = "\u{e15b}";
|
||||
pub const CHECK: &str = "\u{e5ca}";
|
||||
pub const CHEVRON_LEFT: &str = "\u{e5cb}";
|
||||
pub const CHEVRON_RIGHT: &str = "\u{e5cc}";
|
||||
pub const EXPAND_MORE: &str = "\u{e5cf}";
|
||||
pub const EXPAND_LESS: &str = "\u{e5ce}";
|
||||
pub const MORE_VERT: &str = "\u{e5d4}";
|
||||
pub const MORE_HORIZ: &str = "\u{e5d3}";
|
||||
pub const MENU: &str = "\u{e5d2}";
|
||||
pub const OPEN_IN_NEW: &str = "\u{e89e}";
|
||||
pub const UNDO: &str = "\u{e166}";
|
||||
pub const FULLSCREEN: &str = "\u{e5d0}";
|
||||
pub const FULLSCREEN_EXIT: &str = "\u{e5d1}";
|
||||
pub const MINIMIZE: &str = "\u{e931}";
|
||||
pub const CROP_SQUARE: &str = "\u{e3c6}";
|
||||
pub const SELECT_WINDOW: &str = "\u{e6fa}";
|
||||
pub const TAB: &str = "\u{e8d8}";
|
||||
pub const TAB_GROUP: &str = "\u{f743}";
|
||||
pub const DRAG_INDICATOR: &str = "\u{e945}";
|
||||
pub const DRAG_PAN: &str = "\u{f71e}";
|
||||
pub const SIDE_NAVIGATION: &str = "\u{e9e2}";
|
||||
pub const SEARCH: &str = "\u{e8b6}";
|
||||
pub const STAR: &str = "\u{f09a}";
|
||||
pub const BOOKMARK: &str = "\u{e8e7}";
|
||||
pub const BOOKMARK_ADD: &str = "\u{e598}";
|
||||
pub const BOOKMARKS: &str = "\u{e98b}";
|
||||
pub const HISTORY: &str = "\u{e8b3}";
|
||||
pub const DOWNLOAD: &str = "\u{f090}";
|
||||
pub const UPLOAD: &str = "\u{f09b}";
|
||||
pub const FOLDER: &str = "\u{e2c7}";
|
||||
pub const FOLDER_OPEN: &str = "\u{e2c8}";
|
||||
pub const DELETE: &str = "\u{e92e}";
|
||||
pub const SETTINGS: &str = "\u{e8b8}";
|
||||
pub const SHIELD: &str = "\u{e9e0}";
|
||||
pub const KEY: &str = "\u{e73c}";
|
||||
pub const PASSWORD: &str = "\u{f042}";
|
||||
pub const CREDIT_CARD: &str = "\u{e8a1}";
|
||||
pub const QR_CODE_2: &str = "\u{e00a}";
|
||||
pub const APPS: &str = "\u{e5c3}";
|
||||
pub const GRID_VIEW: &str = "\u{e9b0}";
|
||||
pub const CODE: &str = "\u{e86f}";
|
||||
pub const BUG_REPORT: &str = "\u{e868}";
|
||||
pub const MUSIC_NOTE: &str = "\u{e405}";
|
||||
pub const LANGUAGE: &str = "\u{e894}";
|
||||
pub const VPN_LOCK: &str = "\u{e62f}";
|
||||
pub const SCREENSHOT_MONITOR: &str = "\u{ec08}";
|
||||
pub const PICTURE_IN_PICTURE_ALT: &str = "\u{e911}";
|
||||
pub const PIP_EXIT: &str = "\u{f70d}";
|
||||
pub const INSTALL_DESKTOP: &str = "\u{eb71}";
|
||||
pub const ZOOM_IN: &str = "\u{e8ff}";
|
||||
pub const ZOOM_OUT: &str = "\u{e900}";
|
||||
pub const SHARE: &str = "\u{e80d}";
|
||||
pub const CHROME_READER_MODE: &str = "\u{e86d}";
|
||||
pub const DOMINO_MASK: &str = "\u{f5e4}";
|
||||
pub const EXTENSION: &str = "\u{e87b}";
|
||||
pub const TRANSLATE: &str = "\u{e8e2}";
|
||||
pub const PUBLIC: &str = "\u{e80b}";
|
||||
pub const TRAVEL_EXPLORE: &str = "\u{e2db}";
|
||||
pub const COOKIE: &str = "\u{eaac}";
|
||||
pub const BLOCK: &str = "\u{f08c}";
|
||||
pub const FILTER_LIST: &str = "\u{e152}";
|
||||
pub const SYNC: &str = "\u{e627}";
|
||||
pub const LINK: &str = "\u{e250}";
|
||||
pub const CONTENT_COPY: &str = "\u{e14d}";
|
||||
pub const EDIT: &str = "\u{f097}";
|
||||
pub const PUSH_PIN: &str = "\u{f10d}";
|
||||
pub const PRINT: &str = "\u{e8ad}";
|
||||
pub const INFO: &str = "\u{e88e}";
|
||||
pub const WARNING: &str = "\u{f083}";
|
||||
pub const ERROR: &str = "\u{f8b6}";
|
||||
pub const HELP: &str = "\u{e8fd}";
|
||||
pub const LOCK: &str = "\u{e899}";
|
||||
pub const LOCK_OPEN: &str = "\u{e898}";
|
||||
pub const VISIBILITY: &str = "\u{e8f4}";
|
||||
pub const VISIBILITY_OFF: &str = "\u{e8f5}";
|
||||
pub const CHECK_CIRCLE: &str = "\u{f0be}";
|
||||
pub const RADIO_BUTTON_UNCHECKED: &str = "\u{e836}";
|
||||
pub const CIRCLE: &str = "\u{ef4a}";
|
||||
pub const PROGRESS_ACTIVITY: &str = "\u{e9d0}";
|
||||
pub const NOTIFICATIONS: &str = "\u{e7f5}";
|
||||
pub const MIC: &str = "\u{e31d}";
|
||||
pub const VIDEOCAM: &str = "\u{e04b}";
|
||||
pub const PIN_DROP: &str = "\u{e55e}";
|
||||
pub const BLUETOOTH: &str = "\u{e1a7}";
|
||||
pub const SPORTS_ESPORTS: &str = "\u{ea28}";
|
||||
pub const SPEED: &str = "\u{e9e4}";
|
||||
pub const STORAGE: &str = "\u{e1db}";
|
||||
pub const DEVICES: &str = "\u{e326}";
|
||||
pub const DNS: &str = "\u{e875}";
|
||||
pub const VERIFIED_USER: &str = "\u{f013}";
|
||||
pub const PERSON: &str = "\u{f0d3}";
|
||||
pub const ACCOUNT_CIRCLE: &str = "\u{f20b}";
|
||||
pub const GROUP: &str = "\u{ea21}";
|
||||
pub const LOGOUT: &str = "\u{e9ba}";
|
||||
pub const SCHEDULE: &str = "\u{efd6}";
|
||||
pub const TIMER: &str = "\u{e425}";
|
||||
pub const PLAY_ARROW: &str = "\u{e037}";
|
||||
pub const PAUSE: &str = "\u{e034}";
|
||||
pub const PLAY_PAUSE: &str = "\u{f137}";
|
||||
pub const STOP: &str = "\u{e047}";
|
||||
pub const SKIP_PREVIOUS: &str = "\u{e045}";
|
||||
pub const SKIP_NEXT: &str = "\u{e044}";
|
||||
pub const FAST_REWIND: &str = "\u{e020}";
|
||||
pub const FAST_FORWARD: &str = "\u{e01f}";
|
||||
pub const SHUFFLE: &str = "\u{e043}";
|
||||
pub const REPEAT: &str = "\u{e040}";
|
||||
pub const VOLUME_UP: &str = "\u{e050}";
|
||||
pub const VOLUME_DOWN: &str = "\u{e04d}";
|
||||
pub const VOLUME_OFF: &str = "\u{e04f}";
|
||||
pub const GRAPHIC_EQ: &str = "\u{e1b8}";
|
||||
pub const IMAGE: &str = "\u{e3f4}";
|
||||
pub const PALETTE: &str = "\u{e40a}";
|
||||
pub const DARK_MODE: &str = "\u{e51c}";
|
||||
pub const LIGHT_MODE: &str = "\u{e518}";
|
||||
pub const CONTRAST: &str = "\u{eb37}";
|
||||
pub const TUNE: &str = "\u{e429}";
|
||||
pub const SHAPES: &str = "\u{e602}";
|
||||
pub const WAVES: &str = "\u{e176}";
|
||||
pub const BUBBLE_CHART: &str = "\u{e6dd}";
|
||||
pub const SCATTER_PLOT: &str = "\u{e268}";
|
||||
pub const BLUR_ON: &str = "\u{e3a5}";
|
||||
pub const TEXTURE: &str = "\u{e421}";
|
||||
pub const SUNNY: &str = "\u{e81a}";
|
||||
pub const BEDTIME: &str = "\u{f159}";
|
||||
pub const PARTLY_CLOUDY_DAY: &str = "\u{f172}";
|
||||
pub const PARTLY_CLOUDY_NIGHT: &str = "\u{f174}";
|
||||
pub const CLOUD: &str = "\u{f15c}";
|
||||
pub const RAINY: &str = "\u{f176}";
|
||||
pub const WEATHER_SNOWY: &str = "\u{e2cd}";
|
||||
pub const THUNDERSTORM: &str = "\u{ebdb}";
|
||||
pub const FOGGY: &str = "\u{e818}";
|
||||
|
||||
/// Every icon with its name, for the gallery.
|
||||
pub const ALL: &[(&str, &str)] = &[
|
||||
("arrow_back", ARROW_BACK),
|
||||
("arrow_forward", ARROW_FORWARD),
|
||||
("arrow_upward", ARROW_UPWARD),
|
||||
("arrow_downward", ARROW_DOWNWARD),
|
||||
("refresh", REFRESH),
|
||||
("close", CLOSE),
|
||||
("home", HOME),
|
||||
("add", ADD),
|
||||
("remove", REMOVE),
|
||||
("check", CHECK),
|
||||
("chevron_left", CHEVRON_LEFT),
|
||||
("chevron_right", CHEVRON_RIGHT),
|
||||
("expand_more", EXPAND_MORE),
|
||||
("expand_less", EXPAND_LESS),
|
||||
("more_vert", MORE_VERT),
|
||||
("more_horiz", MORE_HORIZ),
|
||||
("menu", MENU),
|
||||
("open_in_new", OPEN_IN_NEW),
|
||||
("undo", UNDO),
|
||||
("fullscreen", FULLSCREEN),
|
||||
("fullscreen_exit", FULLSCREEN_EXIT),
|
||||
("minimize", MINIMIZE),
|
||||
("crop_square", CROP_SQUARE),
|
||||
("select_window", SELECT_WINDOW),
|
||||
("tab", TAB),
|
||||
("tab_group", TAB_GROUP),
|
||||
("drag_indicator", DRAG_INDICATOR),
|
||||
("drag_pan", DRAG_PAN),
|
||||
("side_navigation", SIDE_NAVIGATION),
|
||||
("search", SEARCH),
|
||||
("star", STAR),
|
||||
("bookmark", BOOKMARK),
|
||||
("bookmark_add", BOOKMARK_ADD),
|
||||
("bookmarks", BOOKMARKS),
|
||||
("history", HISTORY),
|
||||
("download", DOWNLOAD),
|
||||
("upload", UPLOAD),
|
||||
("folder", FOLDER),
|
||||
("folder_open", FOLDER_OPEN),
|
||||
("delete", DELETE),
|
||||
("settings", SETTINGS),
|
||||
("shield", SHIELD),
|
||||
("key", KEY),
|
||||
("password", PASSWORD),
|
||||
("credit_card", CREDIT_CARD),
|
||||
("qr_code_2", QR_CODE_2),
|
||||
("apps", APPS),
|
||||
("grid_view", GRID_VIEW),
|
||||
("code", CODE),
|
||||
("bug_report", BUG_REPORT),
|
||||
("music_note", MUSIC_NOTE),
|
||||
("language", LANGUAGE),
|
||||
("vpn_lock", VPN_LOCK),
|
||||
("screenshot_monitor", SCREENSHOT_MONITOR),
|
||||
("picture_in_picture_alt", PICTURE_IN_PICTURE_ALT),
|
||||
("pip_exit", PIP_EXIT),
|
||||
("install_desktop", INSTALL_DESKTOP),
|
||||
("zoom_in", ZOOM_IN),
|
||||
("zoom_out", ZOOM_OUT),
|
||||
("share", SHARE),
|
||||
("chrome_reader_mode", CHROME_READER_MODE),
|
||||
("domino_mask", DOMINO_MASK),
|
||||
("extension", EXTENSION),
|
||||
("translate", TRANSLATE),
|
||||
("public", PUBLIC),
|
||||
("travel_explore", TRAVEL_EXPLORE),
|
||||
("cookie", COOKIE),
|
||||
("block", BLOCK),
|
||||
("filter_list", FILTER_LIST),
|
||||
("sync", SYNC),
|
||||
("link", LINK),
|
||||
("content_copy", CONTENT_COPY),
|
||||
("edit", EDIT),
|
||||
("push_pin", PUSH_PIN),
|
||||
("print", PRINT),
|
||||
("info", INFO),
|
||||
("warning", WARNING),
|
||||
("error", ERROR),
|
||||
("help", HELP),
|
||||
("lock", LOCK),
|
||||
("lock_open", LOCK_OPEN),
|
||||
("visibility", VISIBILITY),
|
||||
("visibility_off", VISIBILITY_OFF),
|
||||
("check_circle", CHECK_CIRCLE),
|
||||
("radio_button_unchecked", RADIO_BUTTON_UNCHECKED),
|
||||
("circle", CIRCLE),
|
||||
("progress_activity", PROGRESS_ACTIVITY),
|
||||
("notifications", NOTIFICATIONS),
|
||||
("mic", MIC),
|
||||
("videocam", VIDEOCAM),
|
||||
("pin_drop", PIN_DROP),
|
||||
("bluetooth", BLUETOOTH),
|
||||
("sports_esports", SPORTS_ESPORTS),
|
||||
("speed", SPEED),
|
||||
("storage", STORAGE),
|
||||
("devices", DEVICES),
|
||||
("dns", DNS),
|
||||
("verified_user", VERIFIED_USER),
|
||||
("person", PERSON),
|
||||
("account_circle", ACCOUNT_CIRCLE),
|
||||
("group", GROUP),
|
||||
("logout", LOGOUT),
|
||||
("schedule", SCHEDULE),
|
||||
("timer", TIMER),
|
||||
("play_arrow", PLAY_ARROW),
|
||||
("pause", PAUSE),
|
||||
("play_pause", PLAY_PAUSE),
|
||||
("stop", STOP),
|
||||
("skip_previous", SKIP_PREVIOUS),
|
||||
("skip_next", SKIP_NEXT),
|
||||
("fast_rewind", FAST_REWIND),
|
||||
("fast_forward", FAST_FORWARD),
|
||||
("shuffle", SHUFFLE),
|
||||
("repeat", REPEAT),
|
||||
("volume_up", VOLUME_UP),
|
||||
("volume_down", VOLUME_DOWN),
|
||||
("volume_off", VOLUME_OFF),
|
||||
("graphic_eq", GRAPHIC_EQ),
|
||||
("image", IMAGE),
|
||||
("palette", PALETTE),
|
||||
("dark_mode", DARK_MODE),
|
||||
("light_mode", LIGHT_MODE),
|
||||
("contrast", CONTRAST),
|
||||
("tune", TUNE),
|
||||
("shapes", SHAPES),
|
||||
("waves", WAVES),
|
||||
("bubble_chart", BUBBLE_CHART),
|
||||
("scatter_plot", SCATTER_PLOT),
|
||||
("blur_on", BLUR_ON),
|
||||
("texture", TEXTURE),
|
||||
("sunny", SUNNY),
|
||||
("bedtime", BEDTIME),
|
||||
("partly_cloudy_day", PARTLY_CLOUDY_DAY),
|
||||
("partly_cloudy_night", PARTLY_CLOUDY_NIGHT),
|
||||
("cloud", CLOUD),
|
||||
("rainy", RAINY),
|
||||
("weather_snowy", WEATHER_SNOWY),
|
||||
("thunderstorm", THUNDERSTORM),
|
||||
("foggy", FOGGY),
|
||||
];
|
||||
|
|
@ -11,6 +11,7 @@ use crate::store::downloads::State as DlState;
|
|||
use crate::store::settings::{VpnProvider, Visualizer};
|
||||
use crate::tabs::Page;
|
||||
use crate::util;
|
||||
use crate::ui::icons;
|
||||
|
||||
/// A right-click menu on a page: Servo's own items plus Nacre's.
|
||||
pub struct PageMenu {
|
||||
|
|
@ -254,7 +255,7 @@ fn main_menu(ui: &mut Ui, f: &mut Frame) {
|
|||
if ui.button("+").clicked() {
|
||||
run = Some(Command::Zoom(1));
|
||||
}
|
||||
if ui.button("⛶").on_hover_text("Full screen (F11)").clicked() {
|
||||
if ui.button(icons::FULLSCREEN).on_hover_text("Full screen (F11)").clicked() {
|
||||
run = Some(Command::Action(Action::Fullscreen));
|
||||
}
|
||||
});
|
||||
|
|
@ -308,7 +309,7 @@ fn downloads(ui: &mut Ui, f: &mut Frame) {
|
|||
f.send(Command::ShowPage(Page::Downloads));
|
||||
f.ui.flyout = None;
|
||||
}
|
||||
if ui.small_button("📂").on_hover_text("Open the downloads folder").clicked() {
|
||||
if ui.small_button(icons::FOLDER_OPEN).on_hover_text("Open the downloads folder").clicked() {
|
||||
f.send(Command::Download(DownloadOp::OpenFolder));
|
||||
}
|
||||
});
|
||||
|
|
@ -376,34 +377,34 @@ pub fn download_row(ui: &mut Ui, f: &mut Frame, d: &crate::store::downloads::Dow
|
|||
});
|
||||
match d.state {
|
||||
DlState::Running => {
|
||||
if ui.small_button("⏸").on_hover_text("Pause").clicked() {
|
||||
if ui.small_button(icons::PAUSE).on_hover_text("Pause").clicked() {
|
||||
f.send(Command::Download(DownloadOp::Pause(d.id)));
|
||||
}
|
||||
if ui.small_button("✕").on_hover_text("Cancel").clicked() {
|
||||
if ui.small_button(icons::CLOSE).on_hover_text("Cancel").clicked() {
|
||||
f.send(Command::Download(DownloadOp::Cancel(d.id)));
|
||||
}
|
||||
},
|
||||
DlState::Paused => {
|
||||
if ui.small_button("▶").on_hover_text("Resume").clicked() {
|
||||
if ui.small_button(icons::PLAY_ARROW).on_hover_text("Resume").clicked() {
|
||||
f.send(Command::Download(DownloadOp::Resume(d.id)));
|
||||
}
|
||||
if ui.small_button("✕").on_hover_text("Cancel").clicked() {
|
||||
if ui.small_button(icons::CLOSE).on_hover_text("Cancel").clicked() {
|
||||
f.send(Command::Download(DownloadOp::Cancel(d.id)));
|
||||
}
|
||||
},
|
||||
DlState::Failed => {
|
||||
if ui.small_button("⟳").on_hover_text("Try again").clicked() {
|
||||
if ui.small_button(icons::REFRESH).on_hover_text("Try again").clicked() {
|
||||
f.send(Command::Download(DownloadOp::Retry(d.id)));
|
||||
}
|
||||
},
|
||||
DlState::Done => {
|
||||
if ui.small_button("📂").on_hover_text("Show in folder").clicked() {
|
||||
if ui.small_button(icons::FOLDER_OPEN).on_hover_text("Show in folder").clicked() {
|
||||
f.send(Command::Download(DownloadOp::ShowInFolder(d.id)));
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
if !d.active() && ui.small_button("🗑").on_hover_text("Remove from the list").clicked() {
|
||||
if !d.active() && ui.small_button(icons::DELETE).on_hover_text("Remove from the list").clicked() {
|
||||
f.send(Command::Download(DownloadOp::Remove(d.id)));
|
||||
}
|
||||
});
|
||||
|
|
@ -563,19 +564,19 @@ fn media(ui: &mut Ui, f: &mut Frame) {
|
|||
}
|
||||
ui.horizontal(|ui| {
|
||||
let big = |t: &str| RichText::new(t).size(18.0);
|
||||
if ui.button(big("⏮")).on_hover_text("Previous").clicked() {
|
||||
if ui.button(big(icons::SKIP_PREVIOUS)).on_hover_text("Previous").clicked() {
|
||||
f.send(Command::Media { tab: now.tab, action: "prev".into(), value: 0.0 });
|
||||
}
|
||||
if ui.button(big(if state.paused { "▶" } else { "⏸" })).clicked() {
|
||||
if ui.button(big(if state.paused { icons::PLAY_ARROW } else { icons::PAUSE })).clicked() {
|
||||
f.send(Command::Media { tab: now.tab, action: "toggle".into(), value: 0.0 });
|
||||
}
|
||||
if ui.button(big("⏭")).on_hover_text("Next").clicked() {
|
||||
if ui.button(big(icons::SKIP_NEXT)).on_hover_text("Next").clicked() {
|
||||
f.send(Command::Media { tab: now.tab, action: "next".into(), value: 0.0 });
|
||||
}
|
||||
if ui.button(big(if now.muted { "🔇" } else { "🔊" })).on_hover_text("Mute tab").clicked() {
|
||||
if ui.button(big(if now.muted { icons::VOLUME_OFF } else { icons::VOLUME_UP })).on_hover_text("Mute tab").clicked() {
|
||||
f.send(Command::MuteTab(now.tab));
|
||||
}
|
||||
if state.is_video && ui.button(big("⧉")).on_hover_text("Picture in picture").clicked() {
|
||||
if state.is_video && ui.button(big(icons::PICTURE_IN_PICTURE_ALT)).on_hover_text("Picture in picture").clicked() {
|
||||
if let Some(i) = f.tabs.iter().position(|t| t.id == now.tab) {
|
||||
f.send(Command::SelectTab(i));
|
||||
}
|
||||
|
|
@ -603,7 +604,7 @@ fn site_info(ui: &mut Ui, f: &mut Frame) {
|
|||
let url = tab.url.clone();
|
||||
let secure = url.starts_with("https://");
|
||||
ui.label(RichText::new(&host).strong());
|
||||
ui.label(if secure { "🔒 The connection is secure" } else { "⚠ The connection is not secure: others on the network can see and change this page" });
|
||||
ui.label(if secure { format!("{} The connection is secure", icons::LOCK) } else { format!("{} The connection is not secure: others on the network can see and change this page", icons::WARNING) });
|
||||
ui.separator();
|
||||
ui.label(RichText::new("Permissions").strong());
|
||||
let decisions = f.shared.permissions.borrow().for_host(&host);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
pub mod chrome;
|
||||
pub mod dialogs;
|
||||
pub mod icons;
|
||||
pub mod menus;
|
||||
pub mod paint;
|
||||
pub mod pages;
|
||||
pub mod widgets;
|
||||
|
||||
|
|
@ -38,6 +40,33 @@ pub enum Flyout {
|
|||
Apps,
|
||||
}
|
||||
|
||||
static OUTFIT: &[u8] = include_bytes!("../../assets/fonts/Outfit[wght].ttf");
|
||||
static SYMBOLS: &[u8] = include_bytes!("../../assets/fonts/MaterialSymbolsOutlined-Nacre.ttf");
|
||||
|
||||
/// The interface fonts: Outfit at each `theme::Weight` (one variable font), Material Symbols for `icons`, then
|
||||
/// egui's own fonts for scripts Outfit lacks (Cyrillic, Greek). Set once per window.
|
||||
pub fn fonts() -> egui::FontDefinitions {
|
||||
use egui::{FontData, FontFamily, FontTweak};
|
||||
use std::sync::Arc;
|
||||
let mut fonts = egui::FontDefinitions::default();
|
||||
let fallback: Vec<String> = fonts.families.get(&FontFamily::Proportional).cloned().unwrap_or_default();
|
||||
let variable = |bytes: &'static [u8], coords: &[(&str, f32)]| Arc::new(FontData::from_static(bytes).tweak(FontTweak { coords: egui::epaint::text::VariationCoords::new(coords.iter().copied()), ..Default::default() }));
|
||||
for weight in crate::theme::Weight::ALL {
|
||||
let name = format!("outfit-{}", weight.wght());
|
||||
fonts.font_data.insert(name.clone(), variable(OUTFIT, &[("wght", weight.wght())]));
|
||||
let family = [name, "symbols".to_owned()].into_iter().chain(fallback.iter().cloned()).collect();
|
||||
fonts.families.insert(weight.family(), family);
|
||||
}
|
||||
fonts.font_data.insert("symbols".to_owned(), variable(SYMBOLS, &[("FILL", 0.0)]));
|
||||
fonts.font_data.insert("symbols-filled".to_owned(), variable(SYMBOLS, &[("FILL", 1.0)]));
|
||||
fonts.families.insert(FontFamily::Name("icons".into()), vec!["symbols".to_owned()]);
|
||||
fonts.families.insert(FontFamily::Name("icons-filled".into()), vec!["symbols-filled".to_owned()]);
|
||||
if let Some(mono) = fonts.families.get_mut(&FontFamily::Monospace) {
|
||||
mono.push("symbols".to_owned());
|
||||
}
|
||||
fonts
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct WindowUi {
|
||||
pub palette: Option<Palette>,
|
||||
|
|
@ -252,7 +281,7 @@ fn toasts(ctx: &egui::Context, f: &mut Frame) {
|
|||
t.until = std::time::Instant::now();
|
||||
}
|
||||
}
|
||||
if ui.small_button("✕").clicked()
|
||||
if ui.small_button(icons::CLOSE).clicked()
|
||||
&& let Some(t) = f.shared.toasts.borrow_mut().get_mut(i)
|
||||
{
|
||||
t.until = std::time::Instant::now();
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue