Replace globals with editor environment (#3656)

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Timon
2026-01-19 18:06:02 +01:00
committed by GitHub
parent 07fbcd489c
commit 95d3556204
29 changed files with 193 additions and 259 deletions

View File

@@ -1,11 +1,10 @@
use graphene_std::Color;
use graphene_std::raster::Image;
use graphite_editor::messages::app_window::app_window_message_handler::AppWindowPlatform;
use graphite_editor::messages::clipboard::utility_types::ClipboardContentRaw;
use graphite_editor::messages::prelude::*;
use super::DesktopWrapperMessageDispatcher;
use super::messages::{DesktopFrontendMessage, DesktopWrapperMessage, EditorMessage, OpenFileDialogContext, Platform, SaveFileDialogContext};
use super::messages::{DesktopFrontendMessage, DesktopWrapperMessage, EditorMessage, OpenFileDialogContext, SaveFileDialogContext};
pub(super) fn handle_desktop_wrapper_message(dispatcher: &mut DesktopWrapperMessageDispatcher, message: DesktopWrapperMessage) {
match message {
@@ -111,15 +110,6 @@ pub(super) fn handle_desktop_wrapper_message(dispatcher: &mut DesktopWrapperMess
dispatcher.queue_editor_message(message);
}
DesktopWrapperMessage::PollNodeGraphEvaluation => dispatcher.poll_node_graph_evaluation(),
DesktopWrapperMessage::UpdatePlatform(platform) => {
let platform = match platform {
Platform::Windows => AppWindowPlatform::Windows,
Platform::Mac => AppWindowPlatform::Mac,
Platform::Linux => AppWindowPlatform::Linux,
};
let message = AppWindowMessage::UpdatePlatform { platform };
dispatcher.queue_editor_message(message);
}
DesktopWrapperMessage::UpdateMaximized { maximized } => {
let message = FrontendMessage::UpdateMaximized { maximized };
dispatcher.queue_editor_message(message);

View File

@@ -1,5 +1,5 @@
use graph_craft::wasm_application_io::WasmApplicationIo;
use graphite_editor::application::Editor;
use graphite_editor::application::{Editor, Environment, Host, Platform};
use graphite_editor::messages::prelude::{FrontendMessage, Message};
// TODO: Remove usage of this reexport in desktop create and remove this line
@@ -27,8 +27,18 @@ pub struct DesktopWrapper {
}
impl DesktopWrapper {
pub fn new() -> Self {
Self { editor: Editor::new() }
pub fn new(uuid_random_seed: u64) -> Self {
#[cfg(target_os = "windows")]
let host = Host::Windows;
#[cfg(target_os = "macos")]
let host = Host::Mac;
#[cfg(target_os = "linux")]
let host = Host::Linux;
let env = Environment { platform: Platform::Desktop, host };
Self {
editor: Editor::new(env, uuid_random_seed),
}
}
pub fn init(&self, wgpu_context: WgpuContext) {
@@ -51,12 +61,6 @@ impl DesktopWrapper {
}
}
impl Default for DesktopWrapper {
fn default() -> Self {
Self::new()
}
}
pub enum NodeGraphExecutionResult {
HasRun(Option<wgpu::Texture>),
NotRun,

View File

@@ -109,7 +109,6 @@ pub enum DesktopWrapperMessage {
content: Vec<u8>,
},
PollNodeGraphEvaluation,
UpdatePlatform(Platform),
UpdateMaximized {
maximized: bool,
},
@@ -163,12 +162,6 @@ pub enum SaveFileDialogContext {
File { content: Vec<u8> },
}
pub enum Platform {
Windows,
Mac,
Linux,
}
pub enum MenuItem {
Action {
id: String,