Skip to content

Commit 72d1323

Browse files
committed
rename Editor to View
1 parent ef908ed commit 72d1323

File tree

11 files changed

+88
-88
lines changed

11 files changed

+88
-88
lines changed

coupler-reflector/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use coupler::editor::{Editor, ParentWindow, RawParent, Size};
21
use coupler::params::{ParamId, ParamValue};
2+
use coupler::view::{ParentWindow, RawParent, Size, View};
33
use reflector::platform::{
44
App, AppMode, AppOptions, Bitmap, Event, RawWindow, Response, Result, Window, WindowContext,
55
WindowOptions,
@@ -63,7 +63,7 @@ impl PluginWindow {
6363
}
6464
}
6565

66-
impl Editor for PluginWindow {
66+
impl View for PluginWindow {
6767
fn size(&self) -> Size {
6868
let size = self.window.size();
6969

examples/gain/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
44

55
use coupler::format::clap::*;
66
use coupler::format::vst3::*;
7-
use coupler::{buffers::*, bus::*, editor::*, engine::*, events::*, host::*, params::*, plugin::*};
7+
use coupler::{buffers::*, bus::*, engine::*, events::*, host::*, params::*, plugin::*, view::*};
88

99
use coupler_reflector::PluginWindow;
1010

@@ -26,7 +26,7 @@ pub struct Gain {
2626

2727
impl Plugin for Gain {
2828
type Engine = GainEngine;
29-
type Editor = PluginWindow;
29+
type View = PluginWindow;
3030

3131
fn info() -> PluginInfo {
3232
PluginInfo {
@@ -48,7 +48,7 @@ impl Plugin for Gain {
4848
},
4949
],
5050
params: GainParams::params(),
51-
has_editor: true,
51+
has_view: true,
5252
}
5353
}
5454

@@ -84,7 +84,7 @@ impl Plugin for Gain {
8484
}
8585
}
8686

87-
fn editor(&mut self, _host: EditorHost, parent: &ParentWindow) -> Self::Editor {
87+
fn view(&mut self, _host: ViewHost, parent: &ParentWindow) -> Self::View {
8888
let size = Size {
8989
width: 512.0,
9090
height: 512.0,

src/format/clap/gui.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ use clap_sys::ext::{gui::*, params::*};
77
use clap_sys::{host::*, plugin::*};
88

99
use super::instance::Instance;
10-
use crate::editor::{Editor, EditorHost, EditorHostInner, ParentWindow, RawParent};
1110
use crate::params::{ParamId, ParamValue};
1211
use crate::plugin::Plugin;
1312
use crate::sync::param_gestures::ParamGestures;
13+
use crate::view::{ParentWindow, RawParent, View, ViewHost, ViewHostInner};
1414

15-
struct ClapEditorHost {
15+
struct ClapViewHost {
1616
host: *const clap_host,
1717
host_params: Option<*const clap_host_params>,
1818
param_map: Arc<HashMap<ParamId, usize>>,
1919
param_gestures: Arc<ParamGestures>,
2020
}
2121

22-
impl EditorHostInner for ClapEditorHost {
22+
impl ViewHostInner for ClapViewHost {
2323
fn begin_gesture(&self, id: ParamId) {
2424
self.param_gestures.begin_gesture(self.param_map[&id]);
2525

@@ -113,7 +113,7 @@ impl<P: Plugin> Instance<P> {
113113
let instance = &*(plugin as *const Self);
114114
let main_thread_state = &mut *instance.main_thread_state.get();
115115

116-
main_thread_state.editor = None;
116+
main_thread_state.view = None;
117117
}
118118

119119
unsafe extern "C" fn gui_set_scale(_plugin: *const clap_plugin, _scale: f64) -> bool {
@@ -128,8 +128,8 @@ impl<P: Plugin> Instance<P> {
128128
let instance = &*(plugin as *const Self);
129129
let main_thread_state = &mut *instance.main_thread_state.get();
130130

131-
if let Some(editor) = &main_thread_state.editor {
132-
let size = editor.size();
131+
if let Some(view) = &main_thread_state.view {
132+
let size = view.size();
133133

134134
*width = size.width.round() as u32;
135135
*height = size.height.round() as u32;
@@ -189,15 +189,15 @@ impl<P: Plugin> Instance<P> {
189189
let instance = &*(plugin as *const Self);
190190
let main_thread_state = &mut *instance.main_thread_state.get();
191191

192-
let host = EditorHost::from_inner(Rc::new(ClapEditorHost {
192+
let host = ViewHost::from_inner(Rc::new(ClapViewHost {
193193
host: instance.host,
194194
host_params: main_thread_state.host_params,
195195
param_map: Arc::clone(&instance.param_map),
196196
param_gestures: Arc::clone(&instance.param_gestures),
197197
}));
198198
let parent = ParentWindow::from_raw(raw_parent);
199-
let editor = main_thread_state.plugin.editor(host, &parent);
200-
main_thread_state.editor = Some(editor);
199+
let view = main_thread_state.plugin.view(host, &parent);
200+
main_thread_state.view = Some(view);
201201

202202
true
203203
}

src/format/clap/instance.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use clap_sys::{events::*, host::*, id::*, plugin::*, process::*, stream::*};
1212
use super::host::ClapHost;
1313
use crate::buffers::{BufferData, BufferType, Buffers};
1414
use crate::bus::{BusDir, Format};
15-
use crate::editor::Editor;
1615
use crate::engine::{Config, Engine};
1716
use crate::events::{Data, Event, Events};
1817
use crate::host::Host;
@@ -21,6 +20,7 @@ use crate::plugin::{Plugin, PluginInfo};
2120
use crate::sync::param_gestures::{GestureStates, GestureUpdate, ParamGestures};
2221
use crate::sync::params::ParamValues;
2322
use crate::util::{copy_cstring, slice_from_raw_parts_checked, DisplayParam};
23+
use crate::view::View;
2424

2525
fn port_type_from_format(format: &Format) -> &'static CStr {
2626
match format {
@@ -49,7 +49,7 @@ pub struct MainThreadState<P: Plugin> {
4949
pub host_params: Option<*const clap_host_params>,
5050
pub layout_index: usize,
5151
pub plugin: P,
52-
pub editor: Option<P::Editor>,
52+
pub view: Option<P::View>,
5353
}
5454

5555
pub struct ProcessState<P: Plugin> {
@@ -131,7 +131,7 @@ impl<P: Plugin> Instance<P> {
131131
host_params: None,
132132
layout_index: 0,
133133
plugin: P::new(Host::from_inner(Arc::new(ClapHost {}))),
134-
editor: None,
134+
view: None,
135135
}),
136136
process_state: UnsafeCell::new(ProcessState {
137137
gesture_states: GestureStates::with_count(info.params.len()),
@@ -148,8 +148,8 @@ impl<P: Plugin> Instance<P> {
148148
let id = self.info.params[index].id;
149149
main_thread_state.plugin.set_param(id, value);
150150

151-
if let Some(editor) = &mut main_thread_state.editor {
152-
editor.param_changed(id, value);
151+
if let Some(view) = &mut main_thread_state.view {
152+
view.param_changed(id, value);
153153
}
154154
}
155155
}
@@ -519,7 +519,7 @@ impl<P: Plugin> Instance<P> {
519519

520520
if id == CLAP_EXT_GUI {
521521
let instance = &*(plugin as *const Self);
522-
if instance.info.has_editor {
522+
if instance.info.has_view {
523523
return &Self::GUI as *const _ as *const c_void;
524524
}
525525
}
@@ -830,8 +830,8 @@ impl<P: Plugin> Instance<P> {
830830
let value = map_param_in(&instance.info.params[index], event.value);
831831
main_thread_state.plugin.set_param(event.param_id, value);
832832

833-
if let Some(editor) = &mut main_thread_state.editor {
834-
editor.param_changed(event.param_id, value);
833+
if let Some(view) = &mut main_thread_state.view {
834+
view.param_changed(event.param_id, value);
835835
}
836836
}
837837
}
@@ -843,8 +843,8 @@ impl<P: Plugin> Instance<P> {
843843
if let Some(value) = update.set_value {
844844
main_thread_state.plugin.set_param(param.id, value);
845845

846-
if let Some(editor) = &mut main_thread_state.editor {
847-
editor.param_changed(param.id, value);
846+
if let Some(view) = &mut main_thread_state.view {
847+
view.param_changed(param.id, value);
848848
}
849849
}
850850

@@ -935,8 +935,8 @@ impl<P: Plugin> Instance<P> {
935935
let value = main_thread_state.plugin.get_param(param.id);
936936
instance.engine_params.set(index, value);
937937

938-
if let Some(editor) = &mut main_thread_state.editor {
939-
editor.param_changed(param.id, value);
938+
if let Some(view) = &mut main_thread_state.view {
939+
view.param_changed(param.id, value);
940940
}
941941
}
942942

src/format/clap/tests.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use std::ffi::{c_char, CStr};
22
use std::io::{self, Read, Write};
33

44
use crate::buffers::Buffers;
5-
use crate::editor::{Editor, EditorHost, ParentWindow, Size};
65
use crate::events::Events;
6+
use crate::view::{ParentWindow, Size, View, ViewHost};
77

88
use clap_sys::plugin_factory::{clap_plugin_factory, CLAP_PLUGIN_FACTORY_ID};
99
use clap_sys::version::CLAP_VERSION;
@@ -26,7 +26,7 @@ struct TestPlugin;
2626

2727
impl Plugin for TestPlugin {
2828
type Engine = TestEngine;
29-
type Editor = TestEditor;
29+
type View = TestView;
3030

3131
fn info() -> PluginInfo {
3232
PluginInfo {
@@ -38,7 +38,7 @@ impl Plugin for TestPlugin {
3838
buses: Vec::new(),
3939
layouts: vec![],
4040
params: Vec::new(),
41-
has_editor: false,
41+
has_view: false,
4242
}
4343
}
4444
fn new(_host: Host) -> Self {
@@ -57,8 +57,8 @@ impl Plugin for TestPlugin {
5757
fn engine(&mut self, _config: Config) -> Self::Engine {
5858
TestEngine
5959
}
60-
fn editor(&mut self, _host: EditorHost, _parent: &ParentWindow) -> Self::Editor {
61-
TestEditor
60+
fn view(&mut self, _host: ViewHost, _parent: &ParentWindow) -> Self::View {
61+
TestView
6262
}
6363

6464
#[allow(unused_variables)]
@@ -81,9 +81,9 @@ impl Engine for TestEngine {
8181
fn process(&mut self, _buffers: Buffers, _events: Events) {}
8282
}
8383

84-
struct TestEditor;
84+
struct TestView;
8585

86-
impl Editor for TestEditor {
86+
impl View for TestView {
8787
fn size(&self) -> Size {
8888
Size {
8989
width: 0.0,

src/format/vst3/component.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ use vst3::{Class, ComRef, ComWrapper, Steinberg::Vst::*, Steinberg::*};
1010
use super::buffers::ScratchBuffers;
1111
use super::host::Vst3Host;
1212
use super::util::{copy_wstring, utf16_from_ptr};
13-
use super::view::{PlugView, Vst3EditorHost};
13+
use super::view::{PlugView, Vst3ViewHost};
1414
use crate::bus::{BusDir, Format, Layout};
15-
use crate::editor::Editor;
1615
use crate::engine::{Config, Engine};
1716
use crate::events::{Data, Event, Events};
1817
use crate::host::Host;
1918
use crate::params::ParamId;
2019
use crate::plugin::{Plugin, PluginInfo};
2120
use crate::sync::params::ParamValues;
2221
use crate::util::{slice_from_raw_parts_checked, DisplayParam};
22+
use crate::view::View;
2323

2424
fn format_to_speaker_arrangement(format: &Format) -> SpeakerArrangement {
2525
match format {
@@ -39,9 +39,9 @@ fn speaker_arrangement_to_format(speaker_arrangement: SpeakerArrangement) -> Opt
3939
pub struct MainThreadState<P: Plugin> {
4040
pub config: Config,
4141
pub plugin: P,
42-
pub editor_params: Vec<f64>,
43-
pub editor_host: Rc<Vst3EditorHost>,
44-
pub editor: Option<P::Editor>,
42+
pub view_params: Vec<f64>,
43+
pub view_host: Rc<Vst3ViewHost>,
44+
pub view: Option<P::View>,
4545
}
4646

4747
struct ProcessState<P: Plugin> {
@@ -95,7 +95,7 @@ impl<P: Plugin> Component<P> {
9595
max_buffer_size: 0,
9696
};
9797

98-
let editor_params = info.params.iter().map(|p| p.default).collect();
98+
let view_params = info.params.iter().map(|p| p.default).collect();
9999

100100
let scratch_buffers = ScratchBuffers::new(input_bus_map.len(), output_bus_map.len());
101101

@@ -113,9 +113,9 @@ impl<P: Plugin> Component<P> {
113113
main_thread_state: Arc::new(UnsafeCell::new(MainThreadState {
114114
config: config.clone(),
115115
plugin: P::new(Host::from_inner(host)),
116-
editor_params,
117-
editor_host: Rc::new(Vst3EditorHost::new()),
118-
editor: None,
116+
view_params,
117+
view_host: Rc::new(Vst3ViewHost::new()),
118+
view: None,
119119
})),
120120
process_state: UnsafeCell::new(ProcessState {
121121
config,
@@ -314,10 +314,10 @@ impl<P: Plugin> IComponentTrait for Component<P> {
314314
for (index, param) in self.info.params.iter().enumerate() {
315315
let value = main_thread_state.plugin.get_param(param.id);
316316
self.engine_params.set(index, value);
317-
main_thread_state.editor_params[index] = value;
317+
main_thread_state.view_params[index] = value;
318318

319-
if let Some(editor) = &mut main_thread_state.editor {
320-
editor.param_changed(param.id, value);
319+
if let Some(view) = &mut main_thread_state.view {
320+
view.param_changed(param.id, value);
321321
}
322322
}
323323

@@ -675,7 +675,7 @@ impl<P: Plugin> IEditControllerTrait for Component<P> {
675675
let main_thread_state = &*self.main_thread_state.get();
676676

677677
if let Some(&index) = self.param_map.get(&id) {
678-
return main_thread_state.editor_params[index];
678+
return main_thread_state.view_params[index];
679679
}
680680

681681
0.0
@@ -685,10 +685,10 @@ impl<P: Plugin> IEditControllerTrait for Component<P> {
685685
let main_thread_state = &mut *self.main_thread_state.get();
686686

687687
if let Some(&index) = self.param_map.get(&id) {
688-
main_thread_state.editor_params[index] = value;
688+
main_thread_state.view_params[index] = value;
689689

690-
if let Some(editor) = &mut main_thread_state.editor {
691-
editor.param_changed(id, value);
690+
if let Some(view) = &mut main_thread_state.view {
691+
view.param_changed(id, value);
692692
}
693693

694694
return kResultOk;
@@ -700,7 +700,7 @@ impl<P: Plugin> IEditControllerTrait for Component<P> {
700700
unsafe fn setComponentHandler(&self, handler: *mut IComponentHandler) -> tresult {
701701
let main_thread_state = &mut *self.main_thread_state.get();
702702

703-
let mut current_handler = main_thread_state.editor_host.handler.borrow_mut();
703+
let mut current_handler = main_thread_state.view_host.handler.borrow_mut();
704704
if let Some(handler) = ComRef::from_raw(handler) {
705705
*current_handler = Some(handler.to_com_ptr());
706706
} else {
@@ -711,7 +711,7 @@ impl<P: Plugin> IEditControllerTrait for Component<P> {
711711
}
712712

713713
unsafe fn createView(&self, name: FIDString) -> *mut IPlugView {
714-
if !self.info.has_editor {
714+
if !self.info.has_view {
715715
return ptr::null_mut();
716716
}
717717

0 commit comments

Comments
 (0)