Skip to content

Commit

Permalink
Merge branch 'master' into Clear-Artboards
Browse files Browse the repository at this point in the history
  • Loading branch information
moOsama76 authored Jan 8, 2025
2 parents 6589d9b + 93a60da commit f6587ca
Show file tree
Hide file tree
Showing 101 changed files with 1,048 additions and 790 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/comment-clippy-warnings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jobs:
clippy:
name: Run Clippy
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
# TODO(Keavon): Find a workaround (passing the output text to a separate action with permission to read the secrets?) that allows this to work on fork PRs
if: ${{ !github.event.pull_request.draft && !github.event.pull_request.head.repo.fork }}
permissions:
contents: read
pull-requests: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: 🌐 Build Graphite website with Zola
run: |
cd website
zola build
zola --config config_prod.toml build
- name: 🔍 Check if `website/other` directory changed
uses: dorny/paths-filter@v3
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ spirv-std = { git = "https://github.com/Rust-GPU/rust-gpu.git" }
wgpu-types = "23"
wgpu = "23"
once_cell = "1.13" # Remove when `core::cell::LazyCell` (<https://doc.rust-lang.org/core/cell/struct.LazyCell.html>) is stabilized in Rust 1.80 and we bump our MSRV
wasm-bindgen = "=0.2.99" # NOTICE: ensure this stays in sync with the `wasm-bindgen-cli` version in `website/content/volunteer/guide/getting-started/_index.md`. We pin this version because wasm-bindgen upgrades may break various things.
wasm-bindgen = "=0.2.99" # NOTICE: ensure this stays in sync with the `wasm-bindgen-cli` version in `website/content/volunteer/guide/project-setup/_index.md`. We pin this version because wasm-bindgen upgrades may break various things.
wasm-bindgen-futures = "0.4"
js-sys = "=0.3.76"
web-sys = "=0.3.76"
Expand Down
2 changes: 1 addition & 1 deletion editor/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Dispatcher {

pub fn handle_message<T: Into<Message>>(&mut self, message: T, process_after_all_current: bool) {
let message = message.into();
// Add all aditional messages to the buffer if it exists (except from the end buffer message)
// Add all additional messages to the buffer if it exists (except from the end buffer message)
if !matches!(message, Message::EndBuffer(_)) {
if let Some(buffered_queue) = &mut self.buffered_queue {
Self::schedule_execution(buffered_queue, true, [message]);
Expand Down
6 changes: 3 additions & 3 deletions editor/src/messages/frontend/frontend_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub enum FrontendMessage {
#[serde(rename = "copyText")]
copy_text: String,
},
// TODO: Eventually remove this (probably starting late 2024)
// TODO: Eventually remove this document upgrade code
TriggerUpgradeDocumentToVectorManipulationFormat {
#[serde(rename = "documentId")]
document_id: DocumentId,
Expand Down Expand Up @@ -234,7 +234,7 @@ pub enum FrontendMessage {
#[serde(rename = "hintData")]
hint_data: HintData,
},
UpdateLayersPanelOptionsLayout {
UpdateLayersPanelControlBarLayout {
#[serde(rename = "layoutTarget")]
layout_target: LayoutTarget,
diff: Vec<WidgetDiff>,
Expand All @@ -251,7 +251,7 @@ pub enum FrontendMessage {
nodes: Vec<FrontendNode>,
wires: Vec<FrontendNodeWire>,
},
UpdateNodeGraphBarLayout {
UpdateNodeGraphControlBarLayout {
#[serde(rename = "layoutTarget")]
layout_target: LayoutTarget,
diff: Vec<WidgetDiff>,
Expand Down
4 changes: 2 additions & 2 deletions editor/src/messages/layout/layout_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ impl LayoutMessageHandler {
LayoutTarget::DialogColumn2 => FrontendMessage::UpdateDialogColumn2 { layout_target, diff },
LayoutTarget::DocumentBar => FrontendMessage::UpdateDocumentBarLayout { layout_target, diff },
LayoutTarget::DocumentMode => FrontendMessage::UpdateDocumentModeLayout { layout_target, diff },
LayoutTarget::LayersPanelOptions => FrontendMessage::UpdateLayersPanelOptionsLayout { layout_target, diff },
LayoutTarget::LayersPanelControlBar => FrontendMessage::UpdateLayersPanelControlBarLayout { layout_target, diff },
LayoutTarget::MenuBar => unreachable!("Menu bar is not diffed"),
LayoutTarget::NodeGraphBar => FrontendMessage::UpdateNodeGraphBarLayout { layout_target, diff },
LayoutTarget::NodeGraphControlBar => FrontendMessage::UpdateNodeGraphControlBarLayout { layout_target, diff },
LayoutTarget::PropertiesSections => FrontendMessage::UpdatePropertyPanelSectionsLayout { layout_target, diff },
LayoutTarget::ToolOptions => FrontendMessage::UpdateToolOptionsLayout { layout_target, diff },
LayoutTarget::ToolShelf => FrontendMessage::UpdateToolShelfLayout { layout_target, diff },
Expand Down
4 changes: 2 additions & 2 deletions editor/src/messages/layout/utility_types/layout_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ pub enum LayoutTarget {
/// Contains the dropdown for design / select / guide mode found on the top left of the canvas.
DocumentMode,
/// Options for opacity seen at the top of the Layers panel.
LayersPanelOptions,
LayersPanelControlBar,
/// The dropdown menu at the very top of the application: File, Edit, etc.
MenuBar,
/// Bar at the top of the node graph containing the location and the "Preview" and "Hide" buttons.
NodeGraphBar,
NodeGraphControlBar,
/// The body of the Properties panel containing many collapsable sections.
PropertiesSections,
/// The bar directly above the canvas, left-aligned and to the right of the document mode dropdown.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
let data_buffer: RawBuffer = Self::default().serialize_root();
responses.add(FrontendMessage::UpdateDocumentLayerStructure { data_buffer });

// Clear the options bar
// Clear the control bar
responses.add(LayoutMessage::SendLayout {
layout: Layout::WidgetLayout(Default::default()),
layout_target: LayoutTarget::LayersPanelOptions,
layout_target: LayoutTarget::LayersPanelControlBar,
});
}
DocumentMessage::InsertBooleanOperation { operation } => {
Expand Down Expand Up @@ -350,7 +350,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
DocumentMessage::DocumentHistoryBackward => self.undo_with_history(ipp, responses),
DocumentMessage::DocumentHistoryForward => self.redo_with_history(ipp, responses),
DocumentMessage::DocumentStructureChanged => {
self.update_layers_panel_options_bar_widgets(responses);
self.update_layers_panel_control_bar_widgets(responses);

self.network_interface.load_structure();
let data_buffer: RawBuffer = self.serialize_root();
Expand Down Expand Up @@ -1903,7 +1903,7 @@ impl DocumentMessageHandler {
});
}

pub fn update_layers_panel_options_bar_widgets(&self, responses: &mut VecDeque<Message>) {
pub fn update_layers_panel_control_bar_widgets(&self, responses: &mut VecDeque<Message>) {
// Get an iterator over the selected layers (excluding artboards which don't have an opacity or blend mode).
let selected_nodes = self.network_interface.selected_nodes(&[]).unwrap();
let selected_layers_except_artboards = selected_nodes.selected_layers_except_artboards(&self.network_interface);
Expand Down Expand Up @@ -1971,7 +1971,7 @@ impl DocumentMessageHandler {
.selected_layers(self.metadata())
.all(|layer| self.network_interface.is_locked(&layer.to_node(), &[]));

let layers_panel_options_bar = WidgetLayout::new(vec![LayoutGroup::Row {
let layers_panel_control_bar = WidgetLayout::new(vec![LayoutGroup::Row {
widgets: vec![
DropdownInput::new(blend_mode_menu_entries)
.selected_index(blend_mode.and_then(|blend_mode| blend_mode.index_in_list_svg_subset()).map(|index| index as u32))
Expand Down Expand Up @@ -2039,8 +2039,8 @@ impl DocumentMessageHandler {
}]);

responses.add(LayoutMessage::SendLayout {
layout: Layout::WidgetLayout(layers_panel_options_bar),
layout_target: LayoutTarget::LayersPanelOptions,
layout: Layout::WidgetLayout(layers_panel_control_bar),
layout_target: LayoutTarget::LayersPanelControlBar,
});
}

Expand Down Expand Up @@ -2297,7 +2297,7 @@ impl Iterator for ClickXRayIter<'_> {
}
}

// TODO: Eventually remove this (probably starting late 2024)
// TODO: Eventually remove this document upgrade code
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct OldDocumentMessageHandler {
// ============================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1642,11 +1642,11 @@ impl NodeGraphMessageHandler {
common
}

/// Send the cached layout to the frontend for the options bar at the top of the node panel
/// Send the cached layout to the frontend for the control bar at the top of the node panel
fn send_node_bar_layout(&self, responses: &mut VecDeque<Message>) {
responses.add(LayoutMessage::SendLayout {
layout: Layout::WidgetLayout(WidgetLayout::new(self.widgets.to_vec())),
layout_target: LayoutTarget::NodeGraphBar,
layout_target: LayoutTarget::NodeGraphControlBar,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ fn grid_overlay_isometric_dot(document: &DocumentMessageHandler, overlay_context
document_to_viewport.transform_point2(start),
document_to_viewport.transform_point2(end),
Some(&("#".to_string() + &grid_color.rgba_hex())),
Some((spacing_x / cos_a) * document_to_viewport.matrix2.x_axis.length()),
Some(1.),
Some((spacing_x / cos_a) * document_to_viewport.matrix2.x_axis.length() - 1.),
None,
);
}
Expand Down
40 changes: 30 additions & 10 deletions editor/src/messages/portfolio/document/overlays/utility_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,23 @@ impl core::hash::Hash for OverlayContext {

impl OverlayContext {
pub fn quad(&mut self, quad: Quad, color_fill: Option<&str>) {
self.dashed_quad(quad, color_fill, None, None);
self.dashed_quad(quad, color_fill, None, None, None);
}

pub fn dashed_quad(&mut self, quad: Quad, color_fill: Option<&str>, dash_width: Option<f64>, gap_width: Option<f64>) {
pub fn dashed_quad(&mut self, quad: Quad, color_fill: Option<&str>, dash_width: Option<f64>, dash_gap_width: Option<f64>, dash_offset: Option<f64>) {
// Set the dash pattern
if let Some(dash_width) = dash_width {
let gap_width = gap_width.unwrap_or(1.);
let dash_gap_width = dash_gap_width.unwrap_or(1.);
let array = js_sys::Array::new();
array.push(&JsValue::from(dash_width - 1.));
array.push(&JsValue::from(gap_width));
array.push(&JsValue::from(dash_width));
array.push(&JsValue::from(dash_gap_width));

if let Some(dash_offset) = dash_offset {
if dash_offset != 0. {
self.render_context.set_line_dash_offset(dash_offset);
}
}

self.render_context
.set_line_dash(&JsValue::from(array))
.map_err(|error| log::warn!("Error drawing dashed line: {:?}", error))
Expand Down Expand Up @@ -70,19 +77,29 @@ impl OverlayContext {
.map_err(|error| log::warn!("Error drawing dashed line: {:?}", error))
.ok();
}
if dash_offset.is_some() && dash_offset != Some(0.) {
self.render_context.set_line_dash_offset(0.);
}
}

pub fn line(&mut self, start: DVec2, end: DVec2, color: Option<&str>) {
self.dashed_line(start, end, color, None, None)
self.dashed_line(start, end, color, None, None, None)
}

pub fn dashed_line(&mut self, start: DVec2, end: DVec2, color: Option<&str>, dash_width: Option<f64>, gap_width: Option<f64>) {
pub fn dashed_line(&mut self, start: DVec2, end: DVec2, color: Option<&str>, dash_width: Option<f64>, dash_gap_width: Option<f64>, dash_offset: Option<f64>) {
// Set the dash pattern
if let Some(dash_width) = dash_width {
let gap_width = gap_width.unwrap_or(1.);
let dash_gap_width = dash_gap_width.unwrap_or(1.);
let array = js_sys::Array::new();
array.push(&JsValue::from(dash_width - 1.));
array.push(&JsValue::from(gap_width));
array.push(&JsValue::from(dash_width));
array.push(&JsValue::from(dash_gap_width));

if let Some(dash_offset) = dash_offset {
if dash_offset != 0. {
self.render_context.set_line_dash_offset(dash_offset);
}
}

self.render_context
.set_line_dash(&JsValue::from(array))
.map_err(|error| log::warn!("Error drawing dashed line: {:?}", error))
Expand All @@ -105,6 +122,9 @@ impl OverlayContext {
.map_err(|error| log::warn!("Error drawing dashed line: {:?}", error))
.ok();
}
if dash_offset.is_some() && dash_offset != Some(0.) {
self.render_context.set_line_dash_offset(0.);
}
}

pub fn manipulator_handle(&mut self, position: DVec2, selected: bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3311,7 +3311,7 @@ impl NodeNetworkInterface {
node.implementation = implementation;
}

// TODO: Eventually remove this (probably starting late 2024)
// TODO: Eventually remove this document upgrade code
/// Keep metadata in sync with the new implementation if this is used by anything other than the upgrade scripts
pub fn replace_implementation_metadata(&mut self, node_id: &NodeId, network_path: &[NodeId], metadata: DocumentNodePersistentMetadata) {
let Some(network_metadata) = self.network_metadata_mut(network_path) else {
Expand Down
8 changes: 4 additions & 4 deletions editor/src/messages/portfolio/portfolio_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
}
};

// TODO: Eventually remove this (probably starting late 2024)
// TODO: Eventually remove this document upgrade code
// Upgrade all old nodes to support editable subgraphs introduced in #1750
if upgrade_from_before_editable_subgraphs {
// This can be used, if uncommented, to upgrade demo artwork with outdated document node internals from their definitions. Delete when it's no longer needed.
Expand Down Expand Up @@ -461,7 +461,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
};

// Upgrade Fill nodes to the format change in #1778
// TODO: Eventually remove this (probably starting late 2024)
// TODO: Eventually remove this document upgrade code
let Some(ref reference) = node_metadata.persistent_metadata.reference.clone() else {
continue;
};
Expand Down Expand Up @@ -616,7 +616,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
}
}

// TODO: Eventually remove this (probably starting late 2024)
// TODO: Eventually remove this document upgrade code
// Upgrade document to the new vector manipulation format introduced in #1676
let document_serialized_content = document.serialize_document();
if upgrade_vector_manipulation_format && !document_serialized_content.is_empty() {
Expand Down Expand Up @@ -974,7 +974,7 @@ impl PortfolioMessageHandler {
fn load_document(&mut self, new_document: DocumentMessageHandler, document_id: DocumentId, responses: &mut VecDeque<Message>) {
let new_document = new_document;
self.document_ids.push(document_id);
new_document.update_layers_panel_options_bar_widgets(responses);
new_document.update_layers_panel_control_bar_widgets(responses);

self.documents.insert(document_id, new_document);

Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/common_functionality/measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn draw_dashed_line(line_start: DVec2, line_end: DVec2, transform: DAffine2, ove
let min_viewport = transform.transform_point2(line_start);
let max_viewport = transform.transform_point2(line_end);

overlay_context.dashed_line(min_viewport, max_viewport, None, Some(2.), Some(3.));
overlay_context.dashed_line(min_viewport, max_viewport, None, Some(2.), Some(2.), Some(0.5));
}
/// Draws a solid line with a length annotation between two points transformed by the given affine transformations.
fn draw_line_with_length(line_start: DVec2, line_end: DVec2, transform: DAffine2, document_to_viewport: DAffine2, overlay_context: &mut OverlayContext, label_alignment: LabelAlignment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ impl ShapeState {
while let Some((anchor, handles)) = missing_anchors.keys().next().copied().and_then(|id| missing_anchors.remove_entry(&id)) {
visited.push(anchor);

// If the adgacent point is just this point then skip
// If the adjacent point is just this point then skip
let mut handles = handles.map(|handle| (handle.1 != anchor).then_some(handle));

// If the adjacent points are themselves being deleted, then repeatedly visit the newest agacent points.
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/select_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl Fsm for SelectToolFsmState {
let quad = Quad::from_box([DVec2::ZERO, far]);
let transformed_quad = document.metadata().transform_to_viewport(layer) * quad;

overlay_context.dashed_quad(transformed_quad, None, Some(7.), Some(5.));
overlay_context.dashed_quad(transformed_quad, None, Some(4.), Some(4.), Some(0.5));
}
}

Expand Down
3 changes: 1 addition & 2 deletions editor/src/messages/tool/utility_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ pub trait Fsm {
/// The implementing tool must set this to a struct designed to store the internal values stored in the tool.
/// For example, it might be used to store the starting location of a point when a drag began so the displacement distance can be calculated.
type ToolData;
/// The implementing tool must set this to a struct (or `()` if none) designed to store the values of the tool options set by the user in the Options Bar
/// (located above the viewport, below the document's tab).
/// The implementing tool must set this to a struct (or `()` if none) designed to store the values of the tool options set by the user in the tool controls portion on the left of the control bar.
type ToolOptions;

/// Implementing this mandatory trait function lets a specific tool react accordingly (and potentially change its state or internal variables) upon receiving an event to do something.
Expand Down
2 changes: 1 addition & 1 deletion frontend/assets/LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021-2023 Graphite Labs, LLC.
Copyright (c) 2021-2025 Graphite Labs, LLC.

The design assets in this directory (including SVG code for icons and logos) are NOT licensed under the Apache 2.0 license terms applied to other Graphite source code files. This directory and its entire contents are excluded from the Apache 2.0 source code license, and full copyright is held by the rightsholder for the creative works contained as files herein.

Expand Down
Loading

0 comments on commit f6587ca

Please sign in to comment.