Make it compile (#37)
* Fix indentation * Set the correct name of the crate in root Cargo.toml * Fix all compile errors
This commit is contained in:
parent
e235c0cf30
commit
a8a9e15a4a
|
|
@ -1,9 +1,8 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"packages/*",
|
"packages/*",
|
||||||
"web-frontend/wasm-wrapper",
|
"web-frontend/wasm-wrapper",
|
||||||
]
|
]
|
||||||
|
|
||||||
[profile.release.package.wasm-bindings]
|
[profile.release.package.wasm-wrapper]
|
||||||
# Tell `rustc` to optimize for small code size.
|
|
||||||
opt-level = "s"
|
opt-level = "s"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,5 @@ version = "0.1.0"
|
||||||
authors = ["Keavon Chambers <graphite@keavon.com>"]
|
authors = ["Keavon Chambers <graphite@keavon.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use std::error::Error;
|
||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
|
|
||||||
/// The error type used by the graphite editor.
|
/// The error type used by the graphite editor.
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum EditorError {
|
pub enum EditorError {
|
||||||
InvalidOperation(String),
|
InvalidOperation(String),
|
||||||
Misc(String),
|
Misc(String),
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,10 @@ pub use error::EditorError;
|
||||||
pub use color::Color;
|
pub use color::Color;
|
||||||
|
|
||||||
use tools::ToolState;
|
use tools::ToolState;
|
||||||
|
use workspace::Workspace;
|
||||||
|
|
||||||
// TODO: serialize with serde to save the current editor state
|
// TODO: serialize with serde to save the current editor state
|
||||||
struct Editor {
|
struct Editor {
|
||||||
tools: ToolState,
|
tools: ToolState,
|
||||||
workspace: workspace::Workspace,
|
workspace: Workspace,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::EditorError;
|
use crate::EditorError;
|
||||||
pub type PanelId = usize;
|
pub type PanelId = usize;
|
||||||
|
|
||||||
struct Workspace {
|
pub struct Workspace {
|
||||||
hovered_panel: PanelId,
|
hovered_panel: PanelId,
|
||||||
root: PanelGroup,
|
root: PanelGroup,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,13 @@
|
||||||
mod utils;
|
pub mod utils;
|
||||||
mod viewport;
|
pub mod viewport;
|
||||||
mod window;
|
pub mod window;
|
||||||
|
pub mod wrappers;
|
||||||
|
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
extern "C" {
|
|
||||||
fn alert(s: &str);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen(start)]
|
#[wasm_bindgen(start)]
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
utils::set_panic_hook();
|
utils::set_panic_hook();
|
||||||
alert("Hello, Graphite!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send events
|
/// Send events
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
use crate::wrappers::Color;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
/// Modify the currently selected tool in the document state store
|
/// Modify the currently selected tool in the document state store
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn select_tool(tool: String) {
|
pub fn select_tool(tool: String) {
|
||||||
|
|
@ -10,7 +13,6 @@ pub fn on_mouse_move(x: u32, y: u32) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
use graphite_editor::Color;
|
|
||||||
/// Update working colors
|
/// Update working colors
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn update_colors(primary_color: Color, secondary_color: Color) {
|
pub fn update_colors(primary_color: Color, secondary_color: Color) {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
type DocumentId = u32;
|
type DocumentId = u32;
|
||||||
|
|
||||||
/// Modify the active Document in the editor state store
|
/// Modify the active Document in the editor state store
|
||||||
|
|
@ -18,7 +20,7 @@ pub fn get_active_document() -> DocumentId {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
use graphite_editor::layout::PanelId;
|
use graphite_editor::workspace::PanelId;
|
||||||
/// Notify the editor that the mouse hovers above a panel
|
/// Notify the editor that the mouse hovers above a panel
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn panel_hover_enter(panel_id: PanelId) {
|
pub fn panel_hover_enter(panel_id: PanelId) {
|
||||||
|
|
@ -27,8 +29,9 @@ pub fn panel_hover_enter(panel_id: PanelId) {
|
||||||
|
|
||||||
/// Query a list of currently available operations
|
/// Query a list of currently available operations
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn get_available_operations() -> Box<[String]> {
|
pub fn get_available_operations() -> Vec<JsValue> {
|
||||||
todo!()
|
todo!();
|
||||||
|
// vec!["example1", "example2"].into_iter().map(JsValue::from).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
use graphite_editor::Color as InnerColor;
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub struct Color(InnerColor);
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
impl Color {
|
||||||
|
#[wasm_bindgen(constructor)]
|
||||||
|
pub fn new(red: f32, green: f32, blue: f32, alpha: f32) -> Self {
|
||||||
|
Self(InnerColor::from_rgbaf32(red, green, blue, alpha).unwrap_throw())
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue