1
0
Fork 0

Revert "Update the Vizia fork"

This reverts commit f646ffcfb5.

Text sizes are broken with the current master branch version of Vizia.
This commit is contained in:
Robbert van der Helm 2022-04-20 00:39:07 +02:00
parent f646ffcfb5
commit 0fa6eab4d3
3 changed files with 106 additions and 55 deletions

93
Cargo.lock generated
View file

@ -47,6 +47,15 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "aho-corasick"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "aliasable" name = "aliasable"
version = "0.1.3" version = "0.1.3"
@ -709,16 +718,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "cstr_core"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "644828c273c063ab0d39486ba42a5d1f3a499d35529c759e763a9c6cb8a0fb08"
dependencies = [
"cty",
"memchr",
]
[[package]] [[package]]
name = "ctor" name = "ctor"
version = "0.1.22" version = "0.1.22"
@ -1318,9 +1317,9 @@ dependencies = [
[[package]] [[package]]
name = "gloo-timers" name = "gloo-timers"
version = "0.2.4" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fb7d06c1c8cc2a29bee7ec961009a0b2caa0793ee4900c2ffb348734ba1c8f9" checksum = "4d12a7f4e95cfe710f1d624fb1210b7d961a5fb05c4fd942f4feab06e61f590e"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
@ -1773,9 +1772,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.124" version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" checksum = "ec647867e2bf0772e28c8bcde4f0d19a9216916e890543b5a03ed8ef27b8f259"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -1793,6 +1792,19 @@ version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]]
name = "locale_config"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d2c35b16f4483f6c26f0e4e9550717a2f6575bcd6f12a53ff0c490a94a6934"
dependencies = [
"lazy_static",
"objc",
"objc-foundation",
"regex",
"winapi",
]
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.7" version = "0.4.7"
@ -2682,9 +2694,9 @@ dependencies = [
[[package]] [[package]]
name = "rayon" name = "rayon"
version = "1.5.2" version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd249e82c21598a9a426a4e00dd7adc1d640b22445ec8545feef801d1a74c221" checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"crossbeam-deque", "crossbeam-deque",
@ -2694,13 +2706,14 @@ dependencies = [
[[package]] [[package]]
name = "rayon-core" name = "rayon-core"
version = "1.9.2" version = "1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f51245e1e62e1f1629cbfec37b5793bbabcaeb90f30e94d2ba03564687353e4" checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e"
dependencies = [ dependencies = [
"crossbeam-channel", "crossbeam-channel",
"crossbeam-deque", "crossbeam-deque",
"crossbeam-utils", "crossbeam-utils",
"lazy_static",
"num_cpus", "num_cpus",
] ]
@ -2748,6 +2761,23 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "regex"
version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]] [[package]]
name = "renderdoc-sys" name = "renderdoc-sys"
version = "0.7.1" version = "0.7.1"
@ -3180,19 +3210,6 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "sys-locale"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3913c5a3d30054d7f77cf07cdd800c8103ace15c6e44437c5db66a43dd3a92cf"
dependencies = [
"cc",
"cstr_core",
"libc",
"web-sys",
"winapi",
]
[[package]] [[package]]
name = "termcolor" name = "termcolor"
version = "1.1.3" version = "1.1.3"
@ -3254,9 +3271,9 @@ dependencies = [
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.5.9" version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -3445,7 +3462,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]] [[package]]
name = "vizia" name = "vizia"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#3e8238ef97f5e355259131aef0632656209bc1bd" source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#c52aad2d80018965266e145d2e125721ed7c9219"
dependencies = [ dependencies = [
"vizia_baseview", "vizia_baseview",
"vizia_core", "vizia_core",
@ -3454,7 +3471,7 @@ dependencies = [
[[package]] [[package]]
name = "vizia_baseview" name = "vizia_baseview"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#3e8238ef97f5e355259131aef0632656209bc1bd" source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#c52aad2d80018965266e145d2e125721ed7c9219"
dependencies = [ dependencies = [
"baseview 0.1.0 (git+https://github.com/robbert-vdh/baseview.git?branch=feature/resize)", "baseview 0.1.0 (git+https://github.com/robbert-vdh/baseview.git?branch=feature/resize)",
"femtovg", "femtovg",
@ -3466,7 +3483,7 @@ dependencies = [
[[package]] [[package]]
name = "vizia_core" name = "vizia_core"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#3e8238ef97f5e355259131aef0632656209bc1bd" source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#c52aad2d80018965266e145d2e125721ed7c9219"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"copypasta", "copypasta",
@ -3479,8 +3496,8 @@ dependencies = [
"image 0.24.1", "image 0.24.1",
"instant", "instant",
"keyboard-types", "keyboard-types",
"locale_config",
"morphorm", "morphorm",
"sys-locale",
"unic-langid", "unic-langid",
"unicode-bidi", "unicode-bidi",
"unicode-segmentation", "unicode-segmentation",
@ -3491,7 +3508,7 @@ dependencies = [
[[package]] [[package]]
name = "vizia_derive" name = "vizia_derive"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#3e8238ef97f5e355259131aef0632656209bc1bd" source = "git+https://github.com/robbert-vdh/vizia.git?branch=patched#c52aad2d80018965266e145d2e125721ed7c9219"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -143,28 +143,44 @@ where
L: Lens<Target = f32>, L: Lens<Target = f32>,
P: Lens<Target = f32>, P: Lens<Target = f32>,
{ {
fn draw(&self, cx: &mut DrawContext, canvas: &mut Canvas) { fn draw(&self, cx: &mut Context, canvas: &mut Canvas) {
let level_dbfs = self.level_dbfs.get(cx); let level_dbfs = self.level_dbfs.get(cx);
let peak_dbfs = self.peak_dbfs.get(cx); let peak_dbfs = self.peak_dbfs.get(cx);
// These basics are taken directly from the default implementation of this function // These basics are taken directly from the default implementation of this function
let entity = cx.current(); let entity = cx.current;
let bounds = cx.cache().get_bounds(entity); let bounds = cx.cache.get_bounds(entity);
if bounds.w == 0.0 || bounds.h == 0.0 { if bounds.w == 0.0 || bounds.h == 0.0 {
return; return;
} }
// TODO: It would be cool to allow the text color property to control the gradient here. For // TODO: It would be cool to allow the text color property to control the gradient here. For
// now we'll only support basic background colors and borders. // now we'll only support basic background colors and borders.
let background_color = cx.background_color(entity).cloned().unwrap_or_default(); let background_color = cx
let border_color = cx.border_color(entity).cloned().unwrap_or_default(); .style
let opacity = cx.cache().get_opacity(entity); .background_color
.get(entity)
.cloned()
.unwrap_or_default();
let border_color = cx
.style
.border_color
.get(entity)
.cloned()
.unwrap_or_default();
let opacity = cx.cache.get_opacity(entity);
let mut background_color: vg::Color = background_color.into(); let mut background_color: vg::Color = background_color.into();
background_color.set_alphaf(background_color.a * opacity); background_color.set_alphaf(background_color.a * opacity);
let mut border_color: vg::Color = border_color.into(); let mut border_color: vg::Color = border_color.into();
border_color.set_alphaf(border_color.a * opacity); border_color.set_alphaf(border_color.a * opacity);
let border_width = match cx.border_width(entity).unwrap_or_default() { let border_width = match cx
.style
.border_width
.get(entity)
.cloned()
.unwrap_or_default()
{
Units::Pixels(val) => val, Units::Pixels(val) => val,
Units::Percentage(val) => bounds.w.min(bounds.h) * (val / 100.0), Units::Percentage(val) => bounds.w.min(bounds.h) * (val / 100.0),
_ => 0.0, _ => 0.0,
@ -196,7 +212,7 @@ where
// NOTE: We'll scale this with the nearest integer DPI ratio. That way it will still look // NOTE: We'll scale this with the nearest integer DPI ratio. That way it will still look
// good at 2x scaling, and it won't look blurry at 1.x times scaling. // good at 2x scaling, and it won't look blurry at 1.x times scaling.
let dpi_scale = cx.logical_to_physical(1.0).floor().max(1.0) as f32; let dpi_scale = cx.style.dpi_factor.floor().max(1.0) as f32;
let bar_tick_coordinates = (bar_ticks_start_x..bar_ticks_end_x) let bar_tick_coordinates = (bar_ticks_start_x..bar_ticks_end_x)
.step_by(((TICK_WIDTH + TICK_GAP) * dpi_scale).round() as usize); .step_by(((TICK_WIDTH + TICK_GAP) * dpi_scale).round() as usize);
for tick_x in bar_tick_coordinates { for tick_x in bar_tick_coordinates {

View file

@ -101,25 +101,41 @@ impl View for ResizeHandle {
} }
} }
fn draw(&self, cx: &mut DrawContext, canvas: &mut Canvas) { fn draw(&self, cx: &mut Context, canvas: &mut Canvas) {
// We'll draw the handle directly as styling elements for this is going to be a bit tricky // We'll draw the handle directly as styling elements for this is going to be a bit tricky
// These basics are taken directly from the default implementation of this function // These basics are taken directly from the default implementation of this function
let entity = cx.current(); let entity = cx.current;
let bounds = cx.cache().get_bounds(entity); let bounds = cx.cache.get_bounds(entity);
if bounds.w == 0.0 || bounds.h == 0.0 { if bounds.w == 0.0 || bounds.h == 0.0 {
return; return;
} }
let background_color = cx.background_color(entity).copied().unwrap_or_default(); let background_color = cx
let border_color = cx.border_color(entity).copied().unwrap_or_default(); .style
let opacity = cx.cache().get_opacity(entity); .background_color
.get(entity)
.cloned()
.unwrap_or_default();
let border_color = cx
.style
.border_color
.get(entity)
.cloned()
.unwrap_or_default();
let opacity = cx.cache.get_opacity(entity);
let mut background_color: vg::Color = background_color.into(); let mut background_color: vg::Color = background_color.into();
background_color.set_alphaf(background_color.a * opacity); background_color.set_alphaf(background_color.a * opacity);
let mut border_color: vg::Color = border_color.into(); let mut border_color: vg::Color = border_color.into();
border_color.set_alphaf(border_color.a * opacity); border_color.set_alphaf(border_color.a * opacity);
let border_width = match cx.border_width(entity).unwrap_or_default() { let border_width = match cx
.style
.border_width
.get(entity)
.cloned()
.unwrap_or_default()
{
Units::Pixels(val) => val, Units::Pixels(val) => val,
Units::Percentage(val) => bounds.w.min(bounds.h) * (val / 100.0), Units::Percentage(val) => bounds.w.min(bounds.h) * (val / 100.0),
_ => 0.0, _ => 0.0,
@ -175,8 +191,10 @@ impl View for ResizeHandle {
// path.close(); // path.close();
let mut color: vg::Color = cx let mut color: vg::Color = cx
.font_color(entity) .style
.copied() .font_color
.get(entity)
.cloned()
.unwrap_or(Color::white()) .unwrap_or(Color::white())
.into(); .into();
color.set_alphaf(color.a * opacity); color.set_alphaf(color.a * opacity);