8989//! }
9090//! ```
9191
92- use baseview:: WindowScalePolicy ;
92+ use :: baseview:: WindowScalePolicy ;
9393use crossbeam:: atomic:: AtomicCell ;
9494use crossbeam:: channel;
95+ use iced_baseview:: core:: { Color , Element , Font } ;
96+ use iced_baseview:: futures:: { Executor , Subscription } ;
97+ use iced_baseview:: graphics:: Antialiasing ;
98+ use iced_baseview:: runtime:: Command ;
99+ use iced_baseview:: style:: application:: StyleSheet ;
100+ use iced_baseview:: widget:: renderer:: Settings as RendererSettings ;
101+ use iced_baseview:: window:: WindowSubs ;
95102use nih_plug:: params:: persist:: PersistentField ;
96103use nih_plug:: prelude:: { Editor , GuiContext } ;
97104use serde:: { Deserialize , Serialize } ;
105+ use std:: borrow:: Cow ;
98106// This doesn't need to be re-export but otherwise the compiler complains about
99107// `hidden_glob_reexports`
100108pub use std:: fmt:: Debug ;
@@ -126,6 +134,7 @@ mod wrapper;
126134pub fn create_iced_editor < E : IcedEditor > (
127135 iced_state : Arc < IcedState > ,
128136 initialization_flags : E :: InitializationFlags ,
137+ fonts : Vec < Cow < ' static , [ u8 ] > > ,
129138) -> Option < Box < dyn Editor > > {
130139 // We need some way to communicate parameter changes to the `IcedEditor` since parameter updates
131140 // come from outside of the editor's reactive model. This contains only capacity to store only
@@ -147,6 +156,7 @@ pub fn create_iced_editor<E: IcedEditor>(
147156
148157 parameter_updates_sender,
149158 parameter_updates_receiver : Arc :: new ( parameter_updates_receiver) ,
159+ fonts,
150160 } ) )
151161}
152162
@@ -162,6 +172,8 @@ pub trait IcedEditor: 'static + Send + Sync + Sized {
162172 type Message : ' static + Clone + Debug + Send ;
163173 /// See [`Application::Flags`].
164174 type InitializationFlags : ' static + Clone + Send + Sync ;
175+ /// See [`Application::Theme`]
176+ type Theme : Default + StyleSheet ;
165177
166178 /// See [`Application::new`]. This also receivs the GUI context in addition to the flags.
167179 fn new (
@@ -179,7 +191,6 @@ pub trait IcedEditor: 'static + Send + Sync + Sized {
179191 /// [`handle_param_message()`][Self::handle_param_message()] to handle the parameter update.
180192 fn update (
181193 & mut self ,
182- window : & mut WindowQueue ,
183194 message : Self :: Message ,
184195 ) -> Command < Self :: Message > ;
185196
@@ -192,13 +203,21 @@ pub trait IcedEditor: 'static + Send + Sync + Sized {
192203 }
193204
194205 /// See [`Application::view`].
195- fn view ( & mut self ) -> Element < ' _ , Self :: Message > ;
206+ fn view ( & self ) -> Element < ' _ , Self :: Message , Renderer < Self :: Theme > > ;
196207
197208 /// See [`Application::background_color`].
198209 fn background_color ( & self ) -> Color {
199210 Color :: WHITE
200211 }
201212
213+ fn theme ( & self ) -> Self :: Theme {
214+ Self :: Theme :: default ( )
215+ }
216+
217+ fn title ( & self ) -> String {
218+ "nih_plug plugin" . to_owned ( )
219+ }
220+
202221 /// See [`Application::scale_policy`].
203222 ///
204223 /// TODO: Is this needed? Editors shouldn't change the scale policy.
@@ -207,16 +226,13 @@ pub trait IcedEditor: 'static + Send + Sync + Sized {
207226 }
208227
209228 /// See [`Application::renderer_settings`].
210- fn renderer_settings ( ) -> iced_baseview :: backend :: settings :: Settings {
211- iced_baseview :: backend :: settings :: Settings {
229+ fn renderer_settings ( ) -> RendererSettings {
230+ RendererSettings {
212231 // Enable some anti-aliasing by default. Since GUIs are likely very simple and most of
213232 // the work will be on the CPU anyways this should not affect performance much.
214- antialiasing : Some ( iced_baseview:: backend:: settings:: Antialiasing :: MSAAx4 ) ,
215- // Use Noto Sans as the default font as that renders a bit more cleanly than the default
216- // Lato font. This crate also contains other weights and versions of this font you can
217- // use for individual widgets.
218- default_font : Some ( crate :: assets:: fonts:: NOTO_SANS_REGULAR ) ,
219- ..iced_baseview:: backend:: settings:: Settings :: default ( )
233+ antialiasing : Some ( Antialiasing :: MSAAx4 ) ,
234+ default_font : Font :: DEFAULT ,
235+ ..RendererSettings :: default ( )
220236 }
221237 }
222238
0 commit comments