Skip to content

Commit d9ac89b

Browse files
committed
fixes
1 parent 691ba8c commit d9ac89b

3 files changed

Lines changed: 16 additions & 15 deletions

File tree

examples/plugin_clack/src/gui.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use baseview::dpi::*;
44
use baseview::gl::GlConfig;
55
use baseview::{WindowHandle, WindowOpenOptions, WindowSize};
66
use clack_extensions::gui::{
7-
GuiApiType, GuiConfiguration, GuiResizeHints, GuiSize, PluginGuiImpl, Window as ClapWindow,
7+
AspectRatioStrategy, GuiApiType, GuiConfiguration, GuiResizeHints, GuiSize, PluginGuiImpl,
8+
Window as ClapWindow,
89
};
910
use clack_plugin::plugin::PluginError;
1011

@@ -49,15 +50,26 @@ impl PluginGuiImpl for ExamplePluginMainThread {
4950
}
5051

5152
fn get_size(&mut self) -> Option<GuiSize> {
52-
Some(window_size_to_gui_size(self.gui.as_ref()?.handle.size()))
53+
let Some(gui) = self.gui.as_ref() else {
54+
// Because we delayed the window creation, this will get called without a GUI active.
55+
// During that time, return the default UI size.
56+
return Some(GuiSize { width: 400, height: 200 });
57+
};
58+
Some(window_size_to_gui_size(gui.handle.size()))
5359
}
5460

5561
fn can_resize(&mut self) -> bool {
5662
true // Non-resizeable windows not supported yet
5763
}
5864

5965
fn get_resize_hints(&mut self) -> Option<GuiResizeHints> {
60-
None // Not supported yet
66+
Some(GuiResizeHints {
67+
strategy: AspectRatioStrategy::Disregard, // Not supported
68+
69+
// Non-resizeable windows not supported yet
70+
can_resize_vertically: true,
71+
can_resize_horizontally: true,
72+
})
6173
}
6274

6375
fn adjust_size(&mut self, size: GuiSize) -> Option<GuiSize> {

examples/plugin_clack/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl DefaultPluginFactory for ExamplePlugin {
2626
fn get_descriptor() -> PluginDescriptor {
2727
use clack_plugin::plugin::features::*;
2828

29-
PluginDescriptor::new("org.rust-audio.clack.gain-egui", "Clack Gain EGUI Example")
29+
PluginDescriptor::new("org.rust-audio.clack.gain-baseview", "Clack Gain Baseview Example")
3030
.with_features([AUDIO_EFFECT, STEREO])
3131
}
3232

examples/plugin_clack/src/window_handler.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ impl WindowHandler for OpenWindowExample {
114114
_ => {}
115115
}
116116

117-
log_event(&event);
118-
119117
EventStatus::Captured
120118
}
121119
}
@@ -136,12 +134,3 @@ impl OpenWindowExample {
136134
})
137135
}
138136
}
139-
140-
fn log_event(event: &Event) {
141-
match event {
142-
Event::Mouse(e) => println!("Mouse event: {:?}", e),
143-
Event::Keyboard(e) => println!("Keyboard event: {:?}", e),
144-
Event::Window(e) => println!("Window event: {:?}", e),
145-
_ => {}
146-
}
147-
}

0 commit comments

Comments
 (0)