Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vizia Update #88

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,050 changes: 1,313 additions & 737 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ log = { version = "0.4", features = ["std", "release_max_level_info"] }
midi-consts = "0.1"
nih_log = "0.3.1"
parking_lot = "0.12"
raw-window-handle = "0.4"
raw-window-handle = "0.5.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
widestring = "1.0.0-beta.1"
Expand All @@ -100,7 +100,7 @@ assert_no_alloc = { git = "https://github.com/robbert-vdh/rust-assert-no-alloc.g
# Used for the `standalone` feature
# NOTE: OpenGL support is not needed here, but rust-analyzer gets confused when
# some crates do use it and others don't
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "1d9806d5bd92275d0d8142d9c9c90198757b9b25", features = ["opengl"], optional = true }
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "f0639b787bbda506434d3f6b5c91e94ca59904c6", features = ["opengl"], optional = true }
# All the claps!
clap = { version = "4.1.8", features = ["derive", "wrap_help"], optional = true }
cpal = { version = "0.15", optional = true }
Expand Down
6 changes: 4 additions & 2 deletions nih_plug_vizia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ description = "An adapter to use VIZIA GUIs with NIH-plug"
nih_plug = { path = ".." }
nih_plug_assets = { git = "https://github.com/robbert-vdh/nih_plug_assets.git" }

baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "7001c2521fa1a439a01967cb881b411cd75d9ee0" }
baseview = { git = "https://github.com/RustAudio/baseview.git", rev = "f0639b787bbda506434d3f6b5c91e94ca59904c6" }
crossbeam = "0.8"
# To make the state persistable
serde = { version = "1.0", features = ["derive"] }
# This fork contains some additional patches on top of Vizia to make it more
# suitable for use in NIH-plug. The set of patches constantly changes as things
# are merged into upstream Vizia. This also excludes the `embedded_fonts`
# feature.
vizia = { git = "https://github.com/robbert-vdh/vizia.git", branch = "patched", default_features = false, features = ["baseview", "clipboard", "x11"] }
# vizia = { git = "https://github.com/vizia/vizia", rev = "100502c33621c07be59eb218bab92e5f45b4e0c9", default_features = false, features = ["baseview", "clipboard", "x11"] }
vizia = { git = "https://github.com/vizia/vizia", default_features = false, features = ["baseview", "clipboard", "x11"] }
# vizia = { path = "../../vizia", default_features = false, features = ["baseview", "clipboard", "x11"] }
22 changes: 16 additions & 6 deletions nih_plug_vizia/assets/theme.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
/* Overrides for default VIZIA widgets */
/*
* {
border-width: 1px;
border-color: blue;
} */

* {
font-weight: light;
}

:root {
background-color: #fafafa;
color: #0a0a0a;
font-size: 15;
}

scrollview > vstack {
scrollview scroll_content {
/* Normally the scroll bar overlaps with the content, so we'll add a little offset to prevent that */
child-right: 15px;
height: auto;
}
scrollview scrollbar {
background-color: #dadada;
border-radius: 0;
child-space: 0;
border-radius: 0px;
child-space: 0px;
}
scrollview scrollbar.horizontal {
right: 10px;
Expand All @@ -24,12 +34,12 @@ scrollview scrollbar.vertical {
}
scrollview scrollbar .thumb {
background-color: #5d5d5d;
border-radius: 0;
border-radius: 0px;
min-width: 10px;
min-height: 10px;
transition: background-color 0.1 0;
transition: background-color 100ms;
}
scrollview scrollbar .thumb:hover {
background-color: #808080;
transition: background-color 0.1 0;
transition: background-color 100ms;
}
38 changes: 21 additions & 17 deletions nih_plug_vizia/assets/widgets.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ scrollview > vstack > generic-ui {
child-space: 5px;

/* Our scrollview styling will already add some padding here */
child-right: 0;
child-right: 0px;
}

generic-ui .row {
col-between: 6px;
layout-type: row;
height: auto;
child-top: 1s;
child-bottom: 1s;
}

generic-ui .label {
left: 1s;
top: 1s;
bottom: 1s;
right: 0;
}

param-button {
Expand All @@ -36,28 +38,28 @@ param-button {
child-bottom: 1s;
child-left: 7px;
background-color: #d0d0d000;
transition: background-color 0.1 0;
transition: background-color 100ms;
}
param-button:hover {
background-color: #d0d0d080;
transition: background-color 0.1 0;
transition: background-color 100ms;
}
param-button:checked {
background-color: #d0d0d0;
transition: background-color 0.1 0;
transition: background-color 100ms;
}

param-button.bypass {
background-color: #ffcfcb00;
transition: background-color 0.1 0;
transition: background-color 100ms;
}
param-button.bypass:hover {
background-color: #ffcfcb20;
transition: background-color 0.1 0;
transition: background-color 100ms;
}
param-button.bypass:checked {
background-color: #ffcfcb;
transition: background-color 0.1 0;
transition: background-color 100ms;
}

param-slider {
Expand All @@ -66,18 +68,18 @@ param-slider {
border-color: #0a0a0a;
border-width: 1px;
background-color: transparent;
transition: background-color 0.1 0;
transition: background-color 100ms;
}

/* Vizia doesn't support commas in selectors */
/* Also, WTB Sass */
param-slider:active {
background-color: #8080801a;
transition: background-color 0.1 0;
transition: background-color 100ms;
}
param-slider:hover {
background-color: #8080801a;
transition: background-color 0.1 0;
transition: background-color 100ms;
}

param-slider .fill {
Expand All @@ -92,6 +94,8 @@ param-slider .value-entry {
/* Vizia doesn't support the unset value */
background-color: transparent;
border-width: 0px;
child-left: 1s;
child-right: 1s;
}
param-slider .value-entry .caret {
background-color: #0a0a0a;
Expand All @@ -116,7 +120,7 @@ peak-meter .ticks {
}
peak-meter .ticks__tick {
background-color: #0a0a0a;
top: 0;
top: 0px;
width: 1px;
height: 30%;
}
Expand All @@ -126,24 +130,24 @@ peak-meter .ticks__label {
}

resize-handle {
bottom: 0;
bottom: 0px;
color: #696969;
height: 20px;
left: 1s;
opacity: 0.4;
position-type: self-directed;
right: 0;
right: 0px;
top: 1s;
transition: opacity 0.1 0;
transition: opacity 100ms;
width: 20px;
z-index: 1337;
}
resize-handle:active {
opacity: 0.8;
transition: opacity 0.1 0;
transition: opacity 100ms;
}
/* No commas in VIZIA */
resize-handle:hover {
opacity: 0.8;
transition: opacity 0.1 0;
transition: opacity 100ms;
}
44 changes: 10 additions & 34 deletions nih_plug_vizia/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,30 @@ use vizia::prelude::*;
// This module provides a re-export and simple font wrappers around the re-exported fonts.
pub use nih_plug_assets::*;

/// The font name for Noto Sans Regular, needs to be registered using
/// [`register_noto_sans_regular()`] first.
pub const NOTO_SANS_REGULAR: &str = "Noto Sans Regular";
/// The font name for Noto Sans Regular Italic, needs to be registered using
/// [`register_noto_sans_regular_italic()`] first.
pub const NOTO_SANS_REGULAR_ITALIC: &str = "Noto Sans Regular Italic";
/// The font name for Noto Sans Thin, needs to be registered using [`register_noto_sans_thin()`]
/// first.
pub const NOTO_SANS_THIN: &str = "Noto Sans Thin";
/// The font name for Noto Sans Thin Italic, needs to be registered using
/// [`register_noto_sans_thin_italic()`] first.
pub const NOTO_SANS_THIN_ITALIC: &str = "Noto Sans Thin Italic";
/// The font name for Noto Sans Light, needs to be registered using [`register_noto_sans_light()`]
/// first.
pub const NOTO_SANS_LIGHT: &str = "Noto Sans Light";
/// The font name for Noto Sans Light Italic, needs to be registered using
/// [`register_noto_sans_light_italic()`] first.
pub const NOTO_SANS_LIGHT_ITALIC: &str = "Noto Sans Light Italic";
/// The font name for Noto Sans Bold, needs to be registered using [`register_noto_sans_bold()`]
/// first.
// NOTE: I'd expect this to be an alias for Noto Sans Regular but this is what cosmic-text thinks
// the font is called
pub const NOTO_SANS_BOLD: &str = "Noto Sans";
/// The font name for Noto Sans Bold Italic, needs to be registered using
/// [`register_noto_sans_bold_italic()`] first.
pub const NOTO_SANS_BOLD_ITALIC: &str = "Noto Sans Italic";
/// The font name for Noto Sans needs to be registered using a register function, for example [`register_noto_sans_regular()`], first.
pub const NOTO_SANS: &str = "Noto Sans";

pub fn register_noto_sans_regular(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::NOTO_SANS_REGULAR]);
cx.add_font_mem(fonts::NOTO_SANS_REGULAR);
}
pub fn register_noto_sans_regular_italic(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::NOTO_SANS_REGULAR_ITALIC]);
cx.add_font_mem(fonts::NOTO_SANS_REGULAR_ITALIC);
}
pub fn register_noto_sans_thin(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::NOTO_SANS_THIN]);
cx.add_font_mem(fonts::NOTO_SANS_THIN);
}
pub fn register_noto_sans_thin_italic(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::NOTO_SANS_THIN_ITALIC]);
cx.add_font_mem(fonts::NOTO_SANS_THIN_ITALIC);
}
pub fn register_noto_sans_light(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::NOTO_SANS_LIGHT]);
cx.add_font_mem(fonts::NOTO_SANS_LIGHT);
}
pub fn register_noto_sans_light_italic(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::NOTO_SANS_LIGHT_ITALIC]);
cx.add_font_mem(fonts::NOTO_SANS_LIGHT_ITALIC);
}
pub fn register_noto_sans_bold(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::NOTO_SANS_BOLD]);
cx.add_font_mem(fonts::NOTO_SANS_BOLD);
}
pub fn register_noto_sans_bold_italic(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::NOTO_SANS_BOLD_ITALIC]);
cx.add_font_mem(fonts::NOTO_SANS_BOLD_ITALIC);
}
4 changes: 2 additions & 2 deletions nih_plug_vizia/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ impl Editor for ViziaEditor {
if theming >= ViziaTheming::Custom {
// NOTE: vizia's font rendering looks way too dark and thick. Going one font weight
// lower seems to compensate for this.
cx.set_default_font(&[assets::NOTO_SANS_LIGHT]);
cx.add_theme(include_str!("../assets/theme.css"));
cx.set_default_font(&[assets::NOTO_SANS]);
cx.add_stylesheet(include_style!("assets/theme.css"));

// There doesn't seem to be any way to bundle styles with a widget, so we'll always
// include the style sheet for our custom widgets at context creation
Expand Down
27 changes: 3 additions & 24 deletions nih_plug_vizia/src/vizia_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,11 @@ pub const ROBOTO: &str = "Roboto";
pub const ROBOTO_BOLD: &str = "Roboto Bold";
/// The font name for the icon font (Entypo), needs to be registered using [`register_icons()`]
/// first.
pub const ICONS: &str = "Entypo";
/// The font name for the emoji font (Open Sans Eomji), needs to be registered using
/// [`register_emoji()`] first.
pub const EMOJI: &str = "OpenSansEmoji";
/// The font name for the arabic font (Amiri Regular), needs to be registered using
/// [`register_arabic()`] first.
pub const ARABIC: &str = "Amiri";
/// The font name for the material font (Material Icons), needs to be registered using
/// [`register_material()`] first.
pub const MATERIAL: &str = "Material Icons";
pub const ICONS: &str = "tabler-icons";

pub fn register_roboto(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::ROBOTO_REGULAR]);
cx.add_font_mem(fonts::ROBOTO_REGULAR);
}
pub fn register_roboto_bold(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::ROBOTO_BOLD]);
}
pub fn register_icons(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::ENTYPO]);
}
pub fn register_emoji(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::OPEN_SANS_EMOJI]);
}
pub fn register_arabic(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::AMIRI_REGULAR]);
}
pub fn register_material(cx: &mut Context) {
cx.add_fonts_mem(&[fonts::MATERIAL_ICONS_REGULAR]);
cx.add_font_mem(fonts::ROBOTO_BOLD);
}
2 changes: 1 addition & 1 deletion nih_plug_vizia/src/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub use resize_handle::ResizeHandle;
/// Register the default theme for the widgets exported by this module. This is automatically called
/// for you when using [`create_vizia_editor()`][super::create_vizia_editor()].
pub fn register_theme(cx: &mut Context) {
cx.add_theme(include_str!("../assets/widgets.css"));
cx.add_stylesheet(include_style!("assets/widgets.css"));
}

/// An event that updates a parameter's value. Since NIH-plug manages the parameters, interacting
Expand Down
4 changes: 2 additions & 2 deletions nih_plug_vizia/src/widgets/generic_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl GenericUi {
Self::draw_widget(cx, params, param_ptr);
})
.class("row");
})
}).height(Auto)
}

/// Creates a new [`GenericUi`] for all provided parameters using a custom closure that receives
Expand Down Expand Up @@ -67,7 +67,7 @@ impl GenericUi {

make_widget(cx, param_ptr);
}
})
}).height(Auto)
}

/// The standard widget drawing function. This can be used together with `.new_custom()` to only
Expand Down
Loading
Loading