mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
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
10 changed files with 33 additions and 20 deletions
|
@ -1,9 +1,8 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"packages/*",
|
||||
"web-frontend/wasm-wrapper",
|
||||
"web-frontend/wasm-wrapper",
|
||||
]
|
||||
|
||||
[profile.release.package.wasm-bindings]
|
||||
# Tell `rustc` to optimize for small code size.
|
||||
[profile.release.package.wasm-wrapper]
|
||||
opt-level = "s"
|
||||
|
|
|
@ -4,6 +4,5 @@ version = "0.1.0"
|
|||
authors = ["Keavon Chambers <graphite@keavon.com>"]
|
||||
edition = "2018"
|
||||
|
||||
|
||||
[dependencies]
|
||||
log = "0.4"
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::error::Error;
|
|||
use std::fmt::{self, Display};
|
||||
|
||||
/// The error type used by the graphite editor.
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum EditorError {
|
||||
InvalidOperation(String),
|
||||
Misc(String),
|
||||
|
|
|
@ -11,9 +11,10 @@ pub use error::EditorError;
|
|||
pub use color::Color;
|
||||
|
||||
use tools::ToolState;
|
||||
use workspace::Workspace;
|
||||
|
||||
// TODO: serialize with serde to save the current editor state
|
||||
struct Editor {
|
||||
tools: ToolState,
|
||||
workspace: workspace::Workspace,
|
||||
workspace: Workspace,
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::EditorError;
|
||||
pub type PanelId = usize;
|
||||
|
||||
struct Workspace {
|
||||
pub struct Workspace {
|
||||
hovered_panel: PanelId,
|
||||
root: PanelGroup,
|
||||
}
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
mod utils;
|
||||
mod viewport;
|
||||
mod window;
|
||||
pub mod utils;
|
||||
pub mod viewport;
|
||||
pub mod window;
|
||||
pub mod wrappers;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
fn alert(s: &str);
|
||||
}
|
||||
|
||||
#[wasm_bindgen(start)]
|
||||
pub fn init() {
|
||||
utils::set_panic_hook();
|
||||
alert("Hello, Graphite!");
|
||||
}
|
||||
|
||||
/// Send events
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
use crate::wrappers::Color;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
/// Modify the currently selected tool in the document state store
|
||||
#[wasm_bindgen]
|
||||
pub fn select_tool(tool: String) {
|
||||
|
@ -10,7 +13,6 @@ pub fn on_mouse_move(x: u32, y: u32) {
|
|||
todo!()
|
||||
}
|
||||
|
||||
use graphite_editor::Color;
|
||||
/// Update working colors
|
||||
#[wasm_bindgen]
|
||||
pub fn update_colors(primary_color: Color, secondary_color: Color) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use wasm_bindgen::prelude::*;
|
||||
|
||||
type DocumentId = u32;
|
||||
|
||||
/// Modify the active Document in the editor state store
|
||||
|
@ -18,7 +20,7 @@ pub fn get_active_document() -> DocumentId {
|
|||
todo!()
|
||||
}
|
||||
|
||||
use graphite_editor::layout::PanelId;
|
||||
use graphite_editor::workspace::PanelId;
|
||||
/// Notify the editor that the mouse hovers above a panel
|
||||
#[wasm_bindgen]
|
||||
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
|
||||
#[wasm_bindgen]
|
||||
pub fn get_available_operations() -> Box<[String]> {
|
||||
todo!()
|
||||
pub fn get_available_operations() -> Vec<JsValue> {
|
||||
todo!();
|
||||
// vec!["example1", "example2"].into_iter().map(JsValue::from).collect()
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
13
web-frontend/wasm-wrapper/src/wrappers.rs
Normal file
13
web-frontend/wasm-wrapper/src/wrappers.rs
Normal file
|
@ -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…
Add table
Add a link
Reference in a new issue