mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 07:08:12 +08:00
Refactor messages.ts by removing class-transformer and JS classes (#3858)
* Fix gamma correction with HTML-based editable Text tool text * Migrate simple, undecorated classes to types * Remove TupleToVec2 transformation * Remove @Transform from tooltips * Cleanup: replace value.toString() with String(value) everywhere * Convert documentId from string to bigint * Migrate the rest of the easy @Transform/@Type decorations * Migrate FillChoice * Migrate WidgetDiffUpdate * Migrate WidgetInstance * Migrate away from classes that extend WidgetProps * Remove class-transformer and all classes in messages.ts * Migrate UI layout passing * Remove dead code * Remove unnecessary export and readonly prefixes * Remove HSVA type * Break out Color, Gradient, and FillChoice functions into a utility-functions file * Move widget helper functions from messages.ts into a new utility-functions file; restructure type imports * Reduce internal type defs * Rename JsMessage to FrontendMessage * Code review fixes * Fix other usages * Tidying up
This commit is contained in:
@@ -847,7 +847,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
||||
};
|
||||
|
||||
self.context_menu = Some(ContextMenuInformation {
|
||||
context_menu_coordinates: (node_graph_point + node_graph_shift).into(),
|
||||
context_menu_coordinates: (node_graph_point + node_graph_shift).as_ivec2(),
|
||||
context_menu_data,
|
||||
});
|
||||
|
||||
@@ -1280,7 +1280,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
||||
let compatible_type = network_interface.output_type(&output_connector, selection_network_path).add_node_string();
|
||||
|
||||
self.context_menu = Some(ContextMenuInformation {
|
||||
context_menu_coordinates: (point + node_graph_shift).into(),
|
||||
context_menu_coordinates: (point + node_graph_shift).as_ivec2(),
|
||||
context_menu_data: ContextMenuData::CreateNode { compatible_type },
|
||||
});
|
||||
|
||||
@@ -2696,7 +2696,7 @@ impl NodeGraphMessageHandler {
|
||||
position += IVec2::new(12, -12)
|
||||
}
|
||||
|
||||
Some(NodeGraphErrorDiagnostic { position: position.into(), error })
|
||||
Some(NodeGraphErrorDiagnostic { position, error })
|
||||
}
|
||||
|
||||
fn update_layer_panel(network_interface: &NodeNetworkInterface, selection_network_path: &[NodeId], collapsed: &CollapsedLayers, layers_panel_open: bool, responses: &mut VecDeque<Message>) {
|
||||
@@ -2769,7 +2769,7 @@ impl NodeGraphMessageHandler {
|
||||
children_allowed,
|
||||
children_present: layer.has_children(network_interface.document_metadata()),
|
||||
expanded: layer.has_children(network_interface.document_metadata()) && !collapsed.0.contains(&layer),
|
||||
depth: layer.ancestors(network_interface.document_metadata()).count() - 1,
|
||||
depth: layer.ancestors(network_interface.document_metadata()).count() as u32 - 1,
|
||||
visible: network_interface.is_visible(&node_id, &[]),
|
||||
parents_visible,
|
||||
unlocked: !network_interface.is_locked(&node_id, &[]),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use glam::{DVec2, IVec2};
|
||||
use glam::IVec2;
|
||||
use graph_craft::document::NodeId;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graphene_std::Type;
|
||||
@@ -162,14 +162,14 @@ pub enum ContextMenuData {
|
||||
pub struct ContextMenuInformation {
|
||||
// Stores whether the context menu is open and its position in graph coordinates
|
||||
#[serde(rename = "contextMenuCoordinates")]
|
||||
pub context_menu_coordinates: FrontendXY,
|
||||
pub context_menu_coordinates: IVec2,
|
||||
#[serde(rename = "contextMenuData")]
|
||||
pub context_menu_data: ContextMenuData,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct NodeGraphErrorDiagnostic {
|
||||
pub position: FrontendXY,
|
||||
pub position: IVec2,
|
||||
pub error: String,
|
||||
}
|
||||
|
||||
@@ -196,22 +196,3 @@ pub enum Direction {
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
|
||||
/// Stores node graph coordinates which are then transformed in Svelte based on the node graph transform
|
||||
#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct FrontendXY {
|
||||
pub x: i32,
|
||||
pub y: i32,
|
||||
}
|
||||
|
||||
impl From<DVec2> for FrontendXY {
|
||||
fn from(v: DVec2) -> Self {
|
||||
FrontendXY { x: v.x as i32, y: v.y as i32 }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IVec2> for FrontendXY {
|
||||
fn from(v: IVec2) -> Self {
|
||||
FrontendXY { x: v.x, y: v.y }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ pub struct LayerPanelEntry {
|
||||
#[serde(rename = "childrenPresent")]
|
||||
pub children_present: bool,
|
||||
pub expanded: bool,
|
||||
pub depth: usize,
|
||||
pub depth: u32,
|
||||
pub visible: bool,
|
||||
#[serde(rename = "parentsVisible")]
|
||||
pub parents_visible: bool,
|
||||
|
||||
Reference in New Issue
Block a user