-
Notifications
You must be signed in to change notification settings - Fork 71
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
Please add NSOpenGLView #70
Comments
You have a very good point here - If you want to PR that change and test whether it allows you to do what you need, definitely feel free - otherwise I'll leave this open and get to it for the next release. |
@dagit use cacao::foundation::id;
use cacao::layout::Layout;
use cacao::objc_access::ObjcAccess;
use objc::rc::StrongPtr;
use objc::runtime::Object;
use objc::{class, msg_send, sel, sel_impl};
use virtualization_rs::virtualization::virtual_machine::VZVirtualMachine;
#[derive(Clone)]
pub struct VZVirtualMachineView(StrongPtr);
impl VZVirtualMachineView {
pub fn new() -> Self {
Self(unsafe { StrongPtr::new(msg_send![class!(VZVirtualMachineView), new]) })
}
pub fn set_virtual_machine(&self, vm: &VZVirtualMachine) {
println!("{:?}", unsafe { vm.id() });
let _: () = unsafe { msg_send![*self.0, setVirtualMachine: vm.id()] };
}
}
impl Default for VZVirtualMachineView {
fn default() -> Self {
Self::new()
}
}
impl ObjcAccess for VZVirtualMachineView {
fn with_backing_obj_mut<F: Fn(id)>(&self, handler: F) {
handler(*self.0)
}
fn get_from_backing_obj<F: Fn(&Object) -> R, R>(&self, handler: F) -> R {
handler(unsafe { &**self.0 })
}
}
impl Layout for VZVirtualMachineView {} Footnotes |
I tried to do this in my project code but it seems like I need access to
ObjcAccess
in order to write aLayout
impl. It seems like maybe new widgets need to be wrapped directly in cacao or certain interfaces would need to be made public?I just want a way to render to an OpenGL area from within a program that I was thinking of writing in cacao. I don't really know the API well enough, but looking at the image example it seemed like maybe I need to use
add_subview
orset_content_view
passing the wrapper I made forNSOpenGLView
? That's the point where I run into the issue that I can't write aLayout
impl.The text was updated successfully, but these errors were encountered: