Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Fix cargo fmt issues (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
askeksa authored Nov 7, 2020
1 parent 9ddb54f commit 19a17cc
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,14 @@ impl EditorInstance {
let mut rect: *mut Rect = std::ptr::null_mut();
let rect_ptr: *mut *mut Rect = &mut rect;

let result = self.params.dispatch(plugin::OpCode::EditorGetRect, 0, 0, rect_ptr as *mut c_void, 0.0);
let result = self
.params
.dispatch(plugin::OpCode::EditorGetRect, 0, 0, rect_ptr as *mut c_void, 0.0);

if result == 0 || rect.is_null() {
return None;
}
Some(unsafe{ *rect }) // TODO: Who owns rect? Who should free the memory?
Some(unsafe { *rect }) // TODO: Who owns rect? Who should free the memory?
}
}

Expand All @@ -324,26 +326,21 @@ impl Editor for EditorInstance {
// Assuming coordinate origins from top-left
match self.get_rect() {
None => (0, 0),
Some(rect) => (
(rect.right - rect.left) as i32,
(rect.bottom - rect.top) as i32
),
Some(rect) => ((rect.right - rect.left) as i32, (rect.bottom - rect.top) as i32),
}
}

fn position(&self) -> (i32, i32) {
// Assuming coordinate origins from top-left
match self.get_rect() {
None => (0, 0),
Some(rect) => (
rect.left as i32,
rect.top as i32
),
Some(rect) => (rect.left as i32, rect.top as i32),
}
}

fn close(&mut self) {
self.params.dispatch(plugin::OpCode::EditorClose, 0, 0, ptr::null_mut(), 0.0);
self.params
.dispatch(plugin::OpCode::EditorClose, 0, 0, ptr::null_mut(), 0.0);
self.is_open = false;
}

Expand Down Expand Up @@ -657,15 +654,17 @@ impl Plugin for PluginInstance {
}

fn get_editor(&mut self) -> Option<Box<dyn Editor>> {
if self.is_editor_active
{
if self.is_editor_active {
// An editor is already active, the caller should be using the active editor instead of
// requesting for a new one.
return None;
}

self.is_editor_active = true;
Some(Box::new(EditorInstance{ params: self.params.clone(), is_open: false }))
Some(Box::new(EditorInstance {
params: self.params.clone(),
is_open: false,
}))
}
}

Expand Down

0 comments on commit 19a17cc

Please sign in to comment.