mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 09:48:12 +08:00
Rename project structure with /core and /client
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
pub mod utils;
|
||||
pub mod viewport;
|
||||
pub mod window;
|
||||
pub mod wrappers;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen(start)]
|
||||
pub fn init() {
|
||||
utils::set_panic_hook();
|
||||
}
|
||||
|
||||
/// Send events
|
||||
#[wasm_bindgen]
|
||||
pub fn handle_event(event_name: String) {
|
||||
// TODO: add payload
|
||||
todo!()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
pub fn set_panic_hook() {
|
||||
// When the `console_error_panic_hook` feature is enabled, we can call the
|
||||
// `set_panic_hook` function at least once during initialization, and then
|
||||
// we will get better error messages if our code ever panics.
|
||||
//
|
||||
// For more details see
|
||||
// https://github.com/rustwasm/console_error_panic_hook#readme
|
||||
#[cfg(feature = "console_error_panic_hook")]
|
||||
console_error_panic_hook::set_once();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
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) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Mouse movement with the bounds of the canvas
|
||||
#[wasm_bindgen]
|
||||
pub fn on_mouse_move(x: u32, y: u32) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Update working colors
|
||||
#[wasm_bindgen]
|
||||
pub fn update_colors(primary_color: Color, secondary_color: Color) {
|
||||
todo!()
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
type DocumentId = u32;
|
||||
|
||||
/// Modify the active Document in the editor state store
|
||||
#[wasm_bindgen]
|
||||
pub fn set_active_document(document_id: DocumentId) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Query the name of a specific document
|
||||
#[wasm_bindgen]
|
||||
pub fn get_document_name(document_id: DocumentId) -> String {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Query the id of the most recently interacted with document
|
||||
#[wasm_bindgen]
|
||||
pub fn get_active_document() -> DocumentId {
|
||||
todo!()
|
||||
}
|
||||
|
||||
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) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Query a list of currently available operations
|
||||
#[wasm_bindgen]
|
||||
pub fn get_available_operations() -> Vec<JsValue> {
|
||||
todo!();
|
||||
// vec!["example1", "example2"].into_iter().map(JsValue::from).collect()
|
||||
}
|
||||
|
||||
/*
|
||||
/// Load a new .gdd file into the editor
|
||||
/// Returns a unique document identifier
|
||||
#[wasm_bindgen]
|
||||
pub fn load_document(raw_data: &[u8]) -> DocumentId {
|
||||
todo!()
|
||||
}*/
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user