diff --git a/crates/dc_bundle/src/legacy_definition.rs b/crates/dc_bundle/src/legacy_definition.rs index d7832432e..4d673fcc1 100644 --- a/crates/dc_bundle/src/legacy_definition.rs +++ b/crates/dc_bundle/src/legacy_definition.rs @@ -28,7 +28,6 @@ use crate::definition::element::VariableMap; use crate::legacy_definition::element::node::NodeQuery; pub mod element; -pub mod plugin; pub mod view; /// EncodedImageMap contains a mapping from ImageKey to network bytes. It can create an diff --git a/crates/dc_bundle/src/legacy_definition/plugin.rs b/crates/dc_bundle/src/legacy_definition/plugin.rs deleted file mode 100644 index 696641381..000000000 --- a/crates/dc_bundle/src/legacy_definition/plugin.rs +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -pub mod meter_data; diff --git a/crates/dc_bundle/src/legacy_definition/view/node_style.rs b/crates/dc_bundle/src/legacy_definition/view/node_style.rs index 2c2bc33b8..746cc7636 100644 --- a/crates/dc_bundle/src/legacy_definition/view/node_style.rs +++ b/crates/dc_bundle/src/legacy_definition/view/node_style.rs @@ -27,7 +27,7 @@ use crate::definition::modifier::{ BlendMode, FilterOp, TextAlign, TextAlignVertical, TextOverflow, }; use crate::definition::modifier::{BoxShadow, LayoutTransform, TextShadow}; -use crate::legacy_definition::plugin::meter_data::MeterData; +use crate::definition::plugin::meter_data::MeterData; use serde::{Deserialize, Serialize}; #[derive(Copy, Clone, PartialEq, Debug, Serialize, Deserialize)] diff --git a/crates/figma_import/src/figma_schema.rs b/crates/figma_import/src/figma_schema.rs index fb767a8ec..8ed495654 100644 --- a/crates/figma_import/src/figma_schema.rs +++ b/crates/figma_import/src/figma_schema.rs @@ -14,6 +14,7 @@ use std::collections::HashMap; +use dc_bundle::definition::element; use dc_bundle::definition::element::Color; use dc_bundle::definition::element::FloatColor; use serde::{Deserialize, Serialize}; @@ -1372,3 +1373,29 @@ pub struct VariablesResponse { pub status: i32, pub meta: VariablesMeta, } + +pub(crate) fn parse_path(path: &Path) -> Option { + let mut output = element::Path::new(); + for segment in svgtypes::SimplifyingPathParser::from(path.path.as_str()) { + match segment { + Ok(svgtypes::SimplePathSegment::MoveTo { x, y }) => { + output.move_to(x as f32, y as f32); + } + Ok(svgtypes::SimplePathSegment::LineTo { x, y }) => { + output.line_to(x as f32, y as f32); + } + Ok(svgtypes::SimplePathSegment::CurveTo { x1, y1, x2, y2, x, y }) => { + output.cubic_to(x1 as f32, y1 as f32, x2 as f32, y2 as f32, x as f32, y as f32); + } + Ok(svgtypes::SimplePathSegment::Quadratic { x1, y1, x, y }) => { + output.quad_to(x1 as f32, y1 as f32, x as f32, y as f32); + } + Ok(svgtypes::SimplePathSegment::ClosePath) => { + output.close(); + } + Err(_) => return None, + } + } + output.with_winding_rule(path.winding_rule.into()); + Some(output) +} diff --git a/crates/figma_import/src/lib.rs b/crates/figma_import/src/lib.rs index 84da945a2..bfe8c5908 100644 --- a/crates/figma_import/src/lib.rs +++ b/crates/figma_import/src/lib.rs @@ -26,8 +26,8 @@ mod extended_layout_schema; mod fetch; mod figma_schema; mod image_context; +pub mod meter_schema; pub mod reaction_schema; -pub mod toolkit_style; pub mod tools; mod transform_flexbox; mod variable_utils; diff --git a/crates/dc_bundle/src/legacy_definition/plugin/meter_data.rs b/crates/figma_import/src/meter_schema.rs similarity index 50% rename from crates/dc_bundle/src/legacy_definition/plugin/meter_data.rs rename to crates/figma_import/src/meter_schema.rs index 5e9cb2310..04abf211a 100644 --- a/crates/dc_bundle/src/legacy_definition/plugin/meter_data.rs +++ b/crates/figma_import/src/meter_schema.rs @@ -1,24 +1,27 @@ -/* - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! `toolkit_style` contains all of the style-related types that `toolkit_schema::View` +//! uses. + +use crate::figma_schema; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)] #[serde(rename_all = "camelCase")] -pub struct RotationMeterData { +pub struct RotationMeterJson { pub enabled: bool, pub start: f32, pub end: f32, @@ -28,7 +31,7 @@ pub struct RotationMeterData { #[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)] #[serde(rename_all = "camelCase")] -pub struct ArcMeterData { +pub struct ArcMeterJson { pub enabled: bool, pub start: f32, pub end: f32, @@ -39,7 +42,7 @@ pub struct ArcMeterData { #[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)] #[serde(rename_all = "camelCase")] -pub struct ProgressBarMeterData { +pub struct ProgressBarMeterJson { pub enabled: bool, pub discrete: bool, pub discrete_value: f32, @@ -53,7 +56,7 @@ pub struct ProgressBarMeterData { #[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)] #[serde(rename_all = "camelCase")] -pub struct ProgressMarkerMeterData { +pub struct ProgressMarkerMeterJson { pub enabled: bool, pub discrete: bool, pub discrete_value: f32, @@ -69,22 +72,32 @@ pub struct ProgressMarkerMeterData { pub end_y: f32, } -// Schema for progress vector data that we write to serialized data +// // Schema for progress vector data that we write to serialized data +// #[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)] +// #[serde(rename_all = "camelCase")] +// pub struct ProgressVectorMeterJson { +// pub enabled: bool, +// pub discrete: bool, +// pub discrete_value: f32, +// } + +// Schema for progress vector data that we read from Figma plugin data #[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)] #[serde(rename_all = "camelCase")] -pub struct ProgressVectorMeterData { +pub struct ProgressVectorMeterJson { pub enabled: bool, pub discrete: bool, pub discrete_value: f32, + pub paths: Vec, } -// Schema for dials & gauges data that we write to serialized data +// Schema for dials & gauges Figma plugin data #[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] #[serde(rename_all = "camelCase")] -pub enum MeterData { - ArcData(ArcMeterData), - RotationData(RotationMeterData), - ProgressBarData(ProgressBarMeterData), - ProgressMarkerData(ProgressMarkerMeterData), - ProgressVectorData(ProgressVectorMeterData), +pub enum MeterJson { + ArcJson(ArcMeterJson), + RotationJson(RotationMeterJson), + ProgressBarJson(ProgressBarMeterJson), + ProgressMarkerJson(ProgressMarkerMeterJson), + ProgressVectorJson(ProgressVectorMeterJson), } diff --git a/crates/figma_import/src/reflection.rs b/crates/figma_import/src/reflection.rs index 887b6f517..914be5179 100644 --- a/crates/figma_import/src/reflection.rs +++ b/crates/figma_import/src/reflection.rs @@ -95,23 +95,19 @@ pub fn registry() -> serde_reflection::Result { .trace_type::(&samples) .expect("couldn't trace GridLayoutType"); tracer - .trace_type::(&samples) + .trace_type::(&samples) .expect("couldn't trace RotationMeterData"); tracer - .trace_type::(&samples) + .trace_type::(&samples) .expect("couldn't trace ArcMeterData"); tracer - .trace_type::( - &samples, - ) + .trace_type::(&samples) .expect("couldn't trace ProgressBarMeterData"); tracer - .trace_type::( - &samples, - ) + .trace_type::(&samples) .expect("couldn't trace ProgressVectorMeterData"); tracer - .trace_type::(&samples) + .trace_type::(&samples) .expect("couldn't trace MeterData"); tracer .trace_type::(&samples) diff --git a/crates/figma_import/src/toolkit_style.rs b/crates/figma_import/src/toolkit_style.rs deleted file mode 100644 index c9ac4d3ca..000000000 --- a/crates/figma_import/src/toolkit_style.rs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! `toolkit_style` contains all of the style-related types that `toolkit_schema::View` -//! uses. - -use crate::figma_schema; -use dc_bundle::legacy_definition::plugin::meter_data::{ - ArcMeterData, MeterData, ProgressBarMeterData, ProgressMarkerMeterData, - ProgressVectorMeterData, RotationMeterData, -}; -use serde::{Deserialize, Serialize}; - -// Schema for progress vector data that we read from Figma plugin data -#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)] -#[serde(rename_all = "camelCase")] -pub struct ProgressVectorMeterDataSchema { - pub enabled: bool, - pub discrete: bool, - pub discrete_value: f32, - pub paths: Vec, -} - -// Schema for dials & gauges Figma plugin data -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] -#[serde(rename_all = "camelCase")] -pub enum MeterDataSchema { - ArcData(ArcMeterData), - RotationData(RotationMeterData), - ProgressBarData(ProgressBarMeterData), - ProgressMarkerData(ProgressMarkerMeterData), - ProgressVectorData(ProgressVectorMeterDataSchema), -} - -impl Into for MeterDataSchema { - fn into(self) -> MeterData { - match self { - MeterDataSchema::ArcData(data) => MeterData::ArcData(data), - MeterDataSchema::RotationData(data) => MeterData::RotationData(data), - MeterDataSchema::ProgressBarData(data) => MeterData::ProgressBarData(data), - MeterDataSchema::ProgressMarkerData(data) => MeterData::ProgressMarkerData(data), - MeterDataSchema::ProgressVectorData(data) => { - MeterData::ProgressVectorData(ProgressVectorMeterData { - enabled: data.enabled, - discrete: data.discrete, - discrete_value: data.discrete_value, - }) - } - } - } -} diff --git a/crates/figma_import/src/transform_flexbox.rs b/crates/figma_import/src/transform_flexbox.rs index 2232254a3..db9c47fe0 100644 --- a/crates/figma_import/src/transform_flexbox.rs +++ b/crates/figma_import/src/transform_flexbox.rs @@ -18,28 +18,28 @@ use std::collections::HashMap; use std::f32::consts::PI; -use crate::toolkit_style::MeterDataSchema; +use crate::meter_schema::MeterJson; +use crate::Error; use crate::{ component_context::ComponentContext, extended_layout_schema::{ExtendedAutoLayout, LayoutType, SizePolicy}, + figma_schema, image_context::ImageContext, variable_utils::{bound_variables_color, FromFigmaVar}, }; -use crate::{figma_schema, Error}; use dc_bundle::definition::element::{ view_shape, DimensionProto, DimensionRect, DimensionRectExt, FontFeature, FontStyle, FontWeight, Size, ViewShape, }; -use crate::figma_schema::LayoutPositioning; +use crate::figma_schema::{parse_path, LayoutPositioning}; use crate::reaction_schema::{FrameExtrasJson, ReactionJson}; use dc_bundle::definition; use dc_bundle::definition::element::dimension_proto::Dimension; use dc_bundle::definition::element::line_height::LineHeight; use dc_bundle::definition::element::num_or_var::NumOrVarType; use dc_bundle::definition::element::view_shape::RoundRect; -use dc_bundle::definition::element::Path; use dc_bundle::definition::element::{ background, stroke_weight, Background, StrokeAlign, StrokeWeight, }; @@ -52,8 +52,12 @@ use dc_bundle::definition::modifier::{ filter_op, BoxShadow, FilterOp, TextAlign, TextAlignVertical, TextOverflow, TextShadow, }; use dc_bundle::definition::modifier::{BlendMode, LayoutTransform}; -use dc_bundle::definition::plugin::FrameExtras; +use dc_bundle::definition::plugin::{ + ArcMeterData, FrameExtras, ProgressBarMeterData, ProgressMarkerMeterData, + ProgressVectorMeterData, RotationMeterData, +}; +use dc_bundle::definition::plugin::meter_data::MeterData; use dc_bundle::legacy_definition::view::component::ComponentInfo; use dc_bundle::legacy_definition::view::text_style::{StyledTextRun, TextStyle}; use dc_bundle::legacy_definition::view::view::{RenderMethod, ScrollInfo, View}; @@ -1427,7 +1431,7 @@ fn visit_node( // Convert any path data we have; we'll use it for non-frame types. let fill_paths = if let Some(fills) = &node.fill_geometry { - fills.iter().filter_map(parse_path).collect() + fills.iter().filter_map(figma_schema::parse_path).collect() } else { Vec::new() }; @@ -1437,7 +1441,7 @@ fn visit_node( // stroke treatment. However, when a shape has no area (e.g.: it is a line), then the // fill geometry will be empty so we *have* to use the stroke geometry. let mut stroke_paths = if let Some(strokes) = &node.stroke_geometry { - strokes.iter().filter_map(parse_path).collect() + strokes.iter().filter_map(figma_schema::parse_path).collect() } else { Vec::new() }; @@ -1541,18 +1545,60 @@ fn visit_node( // a type of meter (dials/gauges/progress bars) if let Some(vsw_data) = plugin_data { if let Some(data) = vsw_data.get("vsw-meter-data") { - let meter_data: Option = serde_json::from_str(data.as_str()).ok(); + let meter_data: Option = serde_json::from_str(data.as_str()).ok(); if let Some(meter_data) = meter_data { - if let MeterDataSchema::ProgressVectorData(vector_data) = &meter_data { - // If this is a progress vector node, we read in data as a ProgressVectorMeterDataSchema, - // which contains vector drawing instructions as a string. We convert this into vector - // drawing instructions in a ProgressVectorMeterData struct and replace the normal stroke - // vector data with it. - if vector_data.enabled { - stroke_paths = vector_data.paths.iter().filter_map(parse_path).collect(); + style.node_style.meter_data = Some(match meter_data { + MeterJson::ArcJson(data) => MeterData::ArcData(ArcMeterData { + enabled: data.enabled, + start: data.start, + end: data.end, + discrete: data.discrete, + discrete_value: data.discrete_value, + corner_radius: data.corner_radius, + }), + MeterJson::RotationJson(data) => MeterData::RotationData(RotationMeterData { + enabled: data.enabled, + start: data.start, + end: data.end, + discrete: data.discrete, + discrete_value: data.discrete_value, + }), + MeterJson::ProgressBarJson(data) => { + MeterData::ProgressBarData(ProgressBarMeterData { + enabled: data.enabled, + discrete: data.discrete, + discrete_value: data.discrete_value, + vertical: data.vertical, + end_x: data.end_x, + end_y: data.end_y, + }) } - } - style.node_style.meter_data = Some(meter_data.into()); + MeterJson::ProgressMarkerJson(data) => { + MeterData::ProgressMarkerData(ProgressMarkerMeterData { + enabled: data.enabled, + discrete: data.discrete, + discrete_value: data.discrete_value, + vertical: data.vertical, + start_x: data.start_x, + end_x: data.end_x, + start_y: data.start_y, + end_y: data.end_y, + }) + } + MeterJson::ProgressVectorJson(data) => { + // ProgressVectors contain vector drawing instructions as a string. We convert this into vector + // drawing instructions in a ProgressVectorMeterData struct and replace the normal stroke + // vector data with it. + if data.enabled { + stroke_paths = data.paths.iter().filter_map(parse_path).collect(); + } + MeterData::ProgressVectorData(ProgressVectorMeterData { + enabled: data.enabled, + discrete: data.discrete, + discrete_value: data.discrete_value, + }) + } + }) } } } @@ -1710,32 +1756,6 @@ pub fn create_component_flexbox( ) } -fn parse_path(path: &figma_schema::Path) -> Option { - let mut output = Path::new(); - for segment in svgtypes::SimplifyingPathParser::from(path.path.as_str()) { - match segment { - Ok(svgtypes::SimplePathSegment::MoveTo { x, y }) => { - output.move_to(x as f32, y as f32); - } - Ok(svgtypes::SimplePathSegment::LineTo { x, y }) => { - output.line_to(x as f32, y as f32); - } - Ok(svgtypes::SimplePathSegment::CurveTo { x1, y1, x2, y2, x, y }) => { - output.cubic_to(x1 as f32, y1 as f32, x2 as f32, y2 as f32, x as f32, y as f32); - } - Ok(svgtypes::SimplePathSegment::Quadratic { x1, y1, x, y }) => { - output.quad_to(x1 as f32, y1 as f32, x as f32, y as f32); - } - Ok(svgtypes::SimplePathSegment::ClosePath) => { - output.close(); - } - Err(_) => return None, - } - } - output.with_winding_rule(path.winding_rule.into()); - Some(output) -} - impl Into for figma_schema::LayoutSizing { fn into(self) -> LayoutSizing { match self { diff --git a/crates/figma_import/tests/layout-unit-tests.dcf b/crates/figma_import/tests/layout-unit-tests.dcf index 932d88998..7e3de40b6 100644 Binary files a/crates/figma_import/tests/layout-unit-tests.dcf and b/crates/figma_import/tests/layout-unit-tests.dcf differ diff --git a/designcompose/src/main/assets/figma/DesignSwitcherDoc_Ljph4e3sC0lHcynfXpoh9f.dcf b/designcompose/src/main/assets/figma/DesignSwitcherDoc_Ljph4e3sC0lHcynfXpoh9f.dcf index 1d53f0093..b2971e4b4 100644 Binary files a/designcompose/src/main/assets/figma/DesignSwitcherDoc_Ljph4e3sC0lHcynfXpoh9f.dcf and b/designcompose/src/main/assets/figma/DesignSwitcherDoc_Ljph4e3sC0lHcynfXpoh9f.dcf differ diff --git a/designcompose/src/main/java/com/android/designcompose/FrameRender.kt b/designcompose/src/main/java/com/android/designcompose/FrameRender.kt index c90262b91..4cf8f1307 100644 --- a/designcompose/src/main/java/com/android/designcompose/FrameRender.kt +++ b/designcompose/src/main/java/com/android/designcompose/FrameRender.kt @@ -123,7 +123,7 @@ private fun calculateRotationData( ): androidx.compose.ui.graphics.Matrix { val rotation = (rotationData.start + meterValue / 100f * (rotationData.end - rotationData.start)) - .coerceDiscrete(rotationData.discrete, rotationData.discreteValue) + .coerceDiscrete(rotationData.discrete, rotationData.discrete_value) val nodeWidth = style.fixedWidth(density) val nodeHeight = style.fixedHeight(density) @@ -170,7 +170,7 @@ private fun calculateProgressBarData( ): Pair { // Progress bar discrete values are done by percentage val discretizedMeterValue = - meterValue.coerceDiscrete(progressBarData.discrete, progressBarData.discreteValue) + meterValue.coerceDiscrete(progressBarData.discrete, progressBarData.discrete_value) // Resize the progress bar by interpolating between 0 and endX or endY depending on whether it // is a horizontal or vertical progress bar @@ -178,7 +178,7 @@ private fun calculateProgressBarData( val width = style.layout_style.width.getDim().pointsAsDp(density).value // Calculate bar extents from the parent layout if it exists, or from the progress bar data // if not. - var endY = progressBarData.endY + var endY = progressBarData.end_y parent?.let { p -> val parentSize = p.computedLayout?.let { Size(it.width, it.height) } parentSize?.let { pSize -> @@ -196,7 +196,7 @@ private fun calculateProgressBarData( val height = style.layout_style.height.getDim().pointsAsDp(density).value // Calculate bar extents from the parent layout if it exists, or from the progress bar data // if not. - var endX = progressBarData.endX + var endX = progressBarData.end_x parent?.let { p -> val parentSize = p.computedLayout?.let { Size(it.width, it.height) } parentSize?.let { pSize -> @@ -219,7 +219,7 @@ private fun calculateProgressMarkerData( ): androidx.compose.ui.graphics.Matrix { // Progress marker discrete values are done by percentage val discretizedMeterValue = - meterValue.coerceDiscrete(markerData.discrete, markerData.discreteValue) + meterValue.coerceDiscrete(markerData.discrete, markerData.discrete_value) // Calculate node and parent render sizes if available. These will only be available for // squoosh, and will be used to calculate the progress sizes and extents @@ -239,14 +239,14 @@ private fun calculateProgressMarkerData( val overrideTransform = style.getTransform(density) if (markerData.vertical) { var startY = - parentSize?.let { it.height - (mySize?.height ?: 0f) / 2f } ?: markerData.startY - val endY = mySize?.let { -it.height / 2f } ?: markerData.endY + parentSize?.let { it.height - (mySize?.height ?: 0f) / 2f } ?: markerData.start_y + val endY = mySize?.let { -it.height / 2f } ?: markerData.end_y val moveY = lerp(startY, endY, discretizedMeterValue, density) val topOffset = style.layout_style.margin.top.pointsAsDp(density).value overrideTransform.setYTranslation(moveY - topOffset) } else { - var startX = mySize?.let { -it.width / 2f } ?: markerData.startX - var endX = parentSize?.let { it.width - (mySize?.width ?: 0f) / 2f } ?: markerData.endX + var startX = mySize?.let { -it.width / 2f } ?: markerData.start_x + var endX = parentSize?.let { it.width - (mySize?.width ?: 0f) / 2f } ?: markerData.end_x val moveX = lerp(startX, endX, discretizedMeterValue, density) val leftOffset = style.layout_style.margin.start.pointsAsDp(density).value overrideTransform.setXTranslation(moveX - leftOffset) @@ -266,7 +266,7 @@ private fun calculateArcData( val arcAngleMeter = (arcMeterValue / 100f * (arcData.end - arcData.start)).coerceDiscrete( arcData.discrete, - arcData.discreteValue, + arcData.discrete_value, ) if (shape.shape.get() is Shape.Arc) { val arc = (shape.shape.get() as Shape.Arc).value @@ -280,7 +280,7 @@ private fun calculateArcData( arcData.start, arcAngleMeter, arc.inner_radius, - arcData.cornerRadius, + arcData.corner_radius, arc.is_mask, ) ) @@ -302,7 +302,7 @@ private fun calculateProgressVectorData( density: Float, ) { val strokeWidth = style.node_style.stroke.stroke_weight.toUniform() * density - val discretizedMeterValue = meterValue.coerceDiscrete(data.discrete, data.discreteValue) + val discretizedMeterValue = meterValue.coerceDiscrete(data.discrete, data.discrete_value) // Get full length of path var pathLen = 0f @@ -357,14 +357,14 @@ internal fun ContentDrawScope.render( // Check if there is meter data for a dial/gauge/progress bar if (style.node_style.meter_data.isPresent) { when (val meterData = style.node_style.meter_data.get()) { - is MeterData.rotationData -> { + is MeterData.RotationData -> { val rotationData = meterData.value if (rotationData.enabled) { overrideTransform = calculateRotationData(rotationData, meterValue, style, density) } } - is MeterData.progressBarData -> { + is MeterData.ProgressBarData -> { val progressBarData = meterData.value if (progressBarData.enabled) { val progressBarSizeTransform = @@ -379,7 +379,7 @@ internal fun ContentDrawScope.render( overrideTransform = progressBarSizeTransform.second } } - is MeterData.progressMarkerData -> { + is MeterData.ProgressMarkerData -> { val progressMarkerData = meterData.value if (progressMarkerData.enabled) { overrideTransform = @@ -393,14 +393,14 @@ internal fun ContentDrawScope.render( ) } } - is MeterData.arcData -> { + is MeterData.ArcData -> { val arcData = meterData.value if (arcData.enabled) { shape = calculateArcData(arcData, meterValue, shape) customArcAngle = true } } - is MeterData.progressVectorData -> { + is MeterData.ProgressVectorData -> { // If this is a vector path progress bar, save it here so we can convert it to a // set of path instructions and render it instead of the normal stroke. if (meterData.value.enabled) progressVectorMeterData = meterData.value @@ -633,14 +633,14 @@ internal fun ContentDrawScope.squooshShapeRender( // Check if there is meter data for a dial/gauge/progress bar if (style.node_style.meter_data.isPresent) { when (val meterData = style.node_style.meter_data.get()) { - is MeterData.rotationData -> { + is MeterData.RotationData -> { val rotationData = meterData.value if (rotationData.enabled) { overrideTransform = calculateRotationData(rotationData, meterValue, style, density) } } - is MeterData.progressBarData -> { + is MeterData.ProgressBarData -> { val progressBarData = meterData.value if (progressBarData.enabled) { val progressBarSizeTransform = @@ -655,7 +655,7 @@ internal fun ContentDrawScope.squooshShapeRender( overrideTransform = progressBarSizeTransform.second } } - is MeterData.progressMarkerData -> { + is MeterData.ProgressMarkerData -> { val progressMarkerData = meterData.value if (progressMarkerData.enabled) { overrideTransform = @@ -669,14 +669,14 @@ internal fun ContentDrawScope.squooshShapeRender( ) } } - is MeterData.arcData -> { + is MeterData.ArcData -> { val arcData = meterData.value if (arcData.enabled) { shape = calculateArcData(arcData, meterValue, shape) customArcAngle = true } } - is MeterData.progressVectorData -> { + is MeterData.ProgressVectorData -> { // If this is a vector path progress bar, save it here so we can convert it to a // set of path instructions and render it instead of the normal stroke. if (meterData.value.enabled) progressVectorMeterData = meterData.value diff --git a/integration-tests/validation/src/main/assets/figma/AlignmentTestDoc_JIjE9oKQbq8ipi66ab5UaK.dcf b/integration-tests/validation/src/main/assets/figma/AlignmentTestDoc_JIjE9oKQbq8ipi66ab5UaK.dcf index d7e117e2e..56e69bc82 100644 Binary files a/integration-tests/validation/src/main/assets/figma/AlignmentTestDoc_JIjE9oKQbq8ipi66ab5UaK.dcf and b/integration-tests/validation/src/main/assets/figma/AlignmentTestDoc_JIjE9oKQbq8ipi66ab5UaK.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/BattleshipDoc_RfGl9SWnBEvdg8T1Ex6ZAR.dcf b/integration-tests/validation/src/main/assets/figma/BattleshipDoc_RfGl9SWnBEvdg8T1Ex6ZAR.dcf index ce1186db9..d2b02ad24 100644 Binary files a/integration-tests/validation/src/main/assets/figma/BattleshipDoc_RfGl9SWnBEvdg8T1Ex6ZAR.dcf and b/integration-tests/validation/src/main/assets/figma/BattleshipDoc_RfGl9SWnBEvdg8T1Ex6ZAR.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/ComponentReplaceDoc_bQVVy2GSZJ8veYaJUrG6Ni.dcf b/integration-tests/validation/src/main/assets/figma/ComponentReplaceDoc_bQVVy2GSZJ8veYaJUrG6Ni.dcf index 832198f9b..85a92a27c 100644 Binary files a/integration-tests/validation/src/main/assets/figma/ComponentReplaceDoc_bQVVy2GSZJ8veYaJUrG6Ni.dcf and b/integration-tests/validation/src/main/assets/figma/ComponentReplaceDoc_bQVVy2GSZJ8veYaJUrG6Ni.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/ComponentTapCallbackDoc_1jeKYynjk1nqYblZ66QDDK.dcf b/integration-tests/validation/src/main/assets/figma/ComponentTapCallbackDoc_1jeKYynjk1nqYblZ66QDDK.dcf index de1ab4a3b..ec81bae89 100644 Binary files a/integration-tests/validation/src/main/assets/figma/ComponentTapCallbackDoc_1jeKYynjk1nqYblZ66QDDK.dcf and b/integration-tests/validation/src/main/assets/figma/ComponentTapCallbackDoc_1jeKYynjk1nqYblZ66QDDK.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/CrossAxisFillTestDoc_GPr1cx4n3zBPwLhqlSL1ba.dcf b/integration-tests/validation/src/main/assets/figma/CrossAxisFillTestDoc_GPr1cx4n3zBPwLhqlSL1ba.dcf index 01d2d98a6..8a3a9caec 100644 Binary files a/integration-tests/validation/src/main/assets/figma/CrossAxisFillTestDoc_GPr1cx4n3zBPwLhqlSL1ba.dcf and b/integration-tests/validation/src/main/assets/figma/CrossAxisFillTestDoc_GPr1cx4n3zBPwLhqlSL1ba.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/DialsGaugesTestDoc_lZj6E9GtIQQE4HNLpzgETw.dcf b/integration-tests/validation/src/main/assets/figma/DialsGaugesTestDoc_lZj6E9GtIQQE4HNLpzgETw.dcf index db96c42bb..c93b995a1 100644 Binary files a/integration-tests/validation/src/main/assets/figma/DialsGaugesTestDoc_lZj6E9GtIQQE4HNLpzgETw.dcf and b/integration-tests/validation/src/main/assets/figma/DialsGaugesTestDoc_lZj6E9GtIQQE4HNLpzgETw.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/FancyFillTestDoc_xQ9cunHt8VUm6xqJJ2Pjb2.dcf b/integration-tests/validation/src/main/assets/figma/FancyFillTestDoc_xQ9cunHt8VUm6xqJJ2Pjb2.dcf index ecc7b2caf..0cc8038ca 100644 Binary files a/integration-tests/validation/src/main/assets/figma/FancyFillTestDoc_xQ9cunHt8VUm6xqJJ2Pjb2.dcf and b/integration-tests/validation/src/main/assets/figma/FancyFillTestDoc_xQ9cunHt8VUm6xqJJ2Pjb2.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/GridLayoutDoc_MBNjjSbzzKeN7nBjVoewsl.dcf b/integration-tests/validation/src/main/assets/figma/GridLayoutDoc_MBNjjSbzzKeN7nBjVoewsl.dcf index eadf5ea5d..a249e9829 100644 Binary files a/integration-tests/validation/src/main/assets/figma/GridLayoutDoc_MBNjjSbzzKeN7nBjVoewsl.dcf and b/integration-tests/validation/src/main/assets/figma/GridLayoutDoc_MBNjjSbzzKeN7nBjVoewsl.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/GridLayoutTestDoc_JOSOEvsrjvMqanyQa5OpNR.dcf b/integration-tests/validation/src/main/assets/figma/GridLayoutTestDoc_JOSOEvsrjvMqanyQa5OpNR.dcf index f923a59e2..fa6d66959 100644 Binary files a/integration-tests/validation/src/main/assets/figma/GridLayoutTestDoc_JOSOEvsrjvMqanyQa5OpNR.dcf and b/integration-tests/validation/src/main/assets/figma/GridLayoutTestDoc_JOSOEvsrjvMqanyQa5OpNR.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/GridWidgetTestDoc_OBhNItd9i9J2LwVYuLxEIx.dcf b/integration-tests/validation/src/main/assets/figma/GridWidgetTestDoc_OBhNItd9i9J2LwVYuLxEIx.dcf index 5838ef5bc..525b3871f 100644 Binary files a/integration-tests/validation/src/main/assets/figma/GridWidgetTestDoc_OBhNItd9i9J2LwVYuLxEIx.dcf and b/integration-tests/validation/src/main/assets/figma/GridWidgetTestDoc_OBhNItd9i9J2LwVYuLxEIx.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/HelloVersionDoc_v62Vwlxa4Bb6nopJiAxQAQ_5668177823.dcf b/integration-tests/validation/src/main/assets/figma/HelloVersionDoc_v62Vwlxa4Bb6nopJiAxQAQ_5668177823.dcf index b67d73887..6db8b1063 100644 Binary files a/integration-tests/validation/src/main/assets/figma/HelloVersionDoc_v62Vwlxa4Bb6nopJiAxQAQ_5668177823.dcf and b/integration-tests/validation/src/main/assets/figma/HelloVersionDoc_v62Vwlxa4Bb6nopJiAxQAQ_5668177823.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/ImageUpdateTestDoc_oQw7kiy94fvdVouCYBC9T0.dcf b/integration-tests/validation/src/main/assets/figma/ImageUpdateTestDoc_oQw7kiy94fvdVouCYBC9T0.dcf index b4708bd75..52c62b399 100644 Binary files a/integration-tests/validation/src/main/assets/figma/ImageUpdateTestDoc_oQw7kiy94fvdVouCYBC9T0.dcf and b/integration-tests/validation/src/main/assets/figma/ImageUpdateTestDoc_oQw7kiy94fvdVouCYBC9T0.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/InteractionTestDoc_8Zg9viyjYTnyN29pbkR1CE.dcf b/integration-tests/validation/src/main/assets/figma/InteractionTestDoc_8Zg9viyjYTnyN29pbkR1CE.dcf index 98d7c345b..79ff1ca79 100644 Binary files a/integration-tests/validation/src/main/assets/figma/InteractionTestDoc_8Zg9viyjYTnyN29pbkR1CE.dcf and b/integration-tests/validation/src/main/assets/figma/InteractionTestDoc_8Zg9viyjYTnyN29pbkR1CE.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/LayoutReplacementTestDoc_dwk2GF7RiNvlbbAKPjqldx.dcf b/integration-tests/validation/src/main/assets/figma/LayoutReplacementTestDoc_dwk2GF7RiNvlbbAKPjqldx.dcf index 9f4cf8572..b4a4297f9 100644 Binary files a/integration-tests/validation/src/main/assets/figma/LayoutReplacementTestDoc_dwk2GF7RiNvlbbAKPjqldx.dcf and b/integration-tests/validation/src/main/assets/figma/LayoutReplacementTestDoc_dwk2GF7RiNvlbbAKPjqldx.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/LayoutTestsDoc_Gv63fYTzpeH2ZtxP4go31E.dcf b/integration-tests/validation/src/main/assets/figma/LayoutTestsDoc_Gv63fYTzpeH2ZtxP4go31E.dcf index c3961590a..50ee2f22c 100644 Binary files a/integration-tests/validation/src/main/assets/figma/LayoutTestsDoc_Gv63fYTzpeH2ZtxP4go31E.dcf and b/integration-tests/validation/src/main/assets/figma/LayoutTestsDoc_Gv63fYTzpeH2ZtxP4go31E.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/ListWidgetTestDoc_9ev0MBNHFrgTqJOrAGcEpV.dcf b/integration-tests/validation/src/main/assets/figma/ListWidgetTestDoc_9ev0MBNHFrgTqJOrAGcEpV.dcf index 04f9864fd..d9dc580b2 100644 Binary files a/integration-tests/validation/src/main/assets/figma/ListWidgetTestDoc_9ev0MBNHFrgTqJOrAGcEpV.dcf and b/integration-tests/validation/src/main/assets/figma/ListWidgetTestDoc_9ev0MBNHFrgTqJOrAGcEpV.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/MaskTestDoc_mEmdUVEIjvBBbV0kELPy37.dcf b/integration-tests/validation/src/main/assets/figma/MaskTestDoc_mEmdUVEIjvBBbV0kELPy37.dcf index ff233c347..09ffea331 100644 Binary files a/integration-tests/validation/src/main/assets/figma/MaskTestDoc_mEmdUVEIjvBBbV0kELPy37.dcf and b/integration-tests/validation/src/main/assets/figma/MaskTestDoc_mEmdUVEIjvBBbV0kELPy37.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/ModuleExampleDoc_hPEGkrF0LUqNYEZObXqjXZ.dcf b/integration-tests/validation/src/main/assets/figma/ModuleExampleDoc_hPEGkrF0LUqNYEZObXqjXZ.dcf index b7a39b63c..94bfc282f 100644 Binary files a/integration-tests/validation/src/main/assets/figma/ModuleExampleDoc_hPEGkrF0LUqNYEZObXqjXZ.dcf and b/integration-tests/validation/src/main/assets/figma/ModuleExampleDoc_hPEGkrF0LUqNYEZObXqjXZ.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/OpenLinkTestDoc_r7m4tqyKv6y9DWcg7QBEDf.dcf b/integration-tests/validation/src/main/assets/figma/OpenLinkTestDoc_r7m4tqyKv6y9DWcg7QBEDf.dcf index ab506c049..314740032 100644 Binary files a/integration-tests/validation/src/main/assets/figma/OpenLinkTestDoc_r7m4tqyKv6y9DWcg7QBEDf.dcf and b/integration-tests/validation/src/main/assets/figma/OpenLinkTestDoc_r7m4tqyKv6y9DWcg7QBEDf.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/RecursiveCustomizationsDoc_o0GWzcqdOWEgzj4kIeIlAu.dcf b/integration-tests/validation/src/main/assets/figma/RecursiveCustomizationsDoc_o0GWzcqdOWEgzj4kIeIlAu.dcf index dd87b2707..b57a118cf 100644 Binary files a/integration-tests/validation/src/main/assets/figma/RecursiveCustomizationsDoc_o0GWzcqdOWEgzj4kIeIlAu.dcf and b/integration-tests/validation/src/main/assets/figma/RecursiveCustomizationsDoc_o0GWzcqdOWEgzj4kIeIlAu.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/ShadowsTestDoc_OqK58Y46IqP4wIgKCWys48.dcf b/integration-tests/validation/src/main/assets/figma/ShadowsTestDoc_OqK58Y46IqP4wIgKCWys48.dcf index 621fd352c..3d0fb5cab 100644 Binary files a/integration-tests/validation/src/main/assets/figma/ShadowsTestDoc_OqK58Y46IqP4wIgKCWys48.dcf and b/integration-tests/validation/src/main/assets/figma/ShadowsTestDoc_OqK58Y46IqP4wIgKCWys48.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/SmartAnimateTestDoc_RW3lFurXCoVDeqY2Y7bf4v.dcf b/integration-tests/validation/src/main/assets/figma/SmartAnimateTestDoc_RW3lFurXCoVDeqY2Y7bf4v.dcf index 84f8699c1..2d522324b 100644 Binary files a/integration-tests/validation/src/main/assets/figma/SmartAnimateTestDoc_RW3lFurXCoVDeqY2Y7bf4v.dcf and b/integration-tests/validation/src/main/assets/figma/SmartAnimateTestDoc_RW3lFurXCoVDeqY2Y7bf4v.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/StateCustomizationsDoc_POWyniB6moGRmhZTJyejwa.dcf b/integration-tests/validation/src/main/assets/figma/StateCustomizationsDoc_POWyniB6moGRmhZTJyejwa.dcf index 959381f4f..ede59f6c3 100644 Binary files a/integration-tests/validation/src/main/assets/figma/StateCustomizationsDoc_POWyniB6moGRmhZTJyejwa.dcf and b/integration-tests/validation/src/main/assets/figma/StateCustomizationsDoc_POWyniB6moGRmhZTJyejwa.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/TelltaleTestDoc_TZgHrKWx8wvQM7UPTyEpmz.dcf b/integration-tests/validation/src/main/assets/figma/TelltaleTestDoc_TZgHrKWx8wvQM7UPTyEpmz.dcf index d3f8736ec..e2db55a73 100644 Binary files a/integration-tests/validation/src/main/assets/figma/TelltaleTestDoc_TZgHrKWx8wvQM7UPTyEpmz.dcf and b/integration-tests/validation/src/main/assets/figma/TelltaleTestDoc_TZgHrKWx8wvQM7UPTyEpmz.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/TextElideTestDoc_oQ7nK49Ya5PJ3GpjI5iy8d.dcf b/integration-tests/validation/src/main/assets/figma/TextElideTestDoc_oQ7nK49Ya5PJ3GpjI5iy8d.dcf index 7c32de4ae..a4c4b77f3 100644 Binary files a/integration-tests/validation/src/main/assets/figma/TextElideTestDoc_oQ7nK49Ya5PJ3GpjI5iy8d.dcf and b/integration-tests/validation/src/main/assets/figma/TextElideTestDoc_oQ7nK49Ya5PJ3GpjI5iy8d.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/VariablesTestDoc_HhGxvL4aHhP8ALsLNz56TP.dcf b/integration-tests/validation/src/main/assets/figma/VariablesTestDoc_HhGxvL4aHhP8ALsLNz56TP.dcf index 3793efd9f..32bacdaa6 100644 Binary files a/integration-tests/validation/src/main/assets/figma/VariablesTestDoc_HhGxvL4aHhP8ALsLNz56TP.dcf and b/integration-tests/validation/src/main/assets/figma/VariablesTestDoc_HhGxvL4aHhP8ALsLNz56TP.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/VariantAnimationTestDoc_pghyUUhlzJNoxxSK86ngiw.dcf b/integration-tests/validation/src/main/assets/figma/VariantAnimationTestDoc_pghyUUhlzJNoxxSK86ngiw.dcf index 7aeeb5c99..acf92ec2a 100644 Binary files a/integration-tests/validation/src/main/assets/figma/VariantAnimationTestDoc_pghyUUhlzJNoxxSK86ngiw.dcf and b/integration-tests/validation/src/main/assets/figma/VariantAnimationTestDoc_pghyUUhlzJNoxxSK86ngiw.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/VariantAnimationTimelineTestDoc_vJRf4zxY4QX4zzSSUd1nJ5.dcf b/integration-tests/validation/src/main/assets/figma/VariantAnimationTimelineTestDoc_vJRf4zxY4QX4zzSSUd1nJ5.dcf index 4862e098e..3f8208f4d 100644 Binary files a/integration-tests/validation/src/main/assets/figma/VariantAnimationTimelineTestDoc_vJRf4zxY4QX4zzSSUd1nJ5.dcf and b/integration-tests/validation/src/main/assets/figma/VariantAnimationTimelineTestDoc_vJRf4zxY4QX4zzSSUd1nJ5.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/VariantAsteriskTestDoc_gQeYHGCSaBE4zYSFpBrhre.dcf b/integration-tests/validation/src/main/assets/figma/VariantAsteriskTestDoc_gQeYHGCSaBE4zYSFpBrhre.dcf index ae6d6a177..1989a5023 100644 Binary files a/integration-tests/validation/src/main/assets/figma/VariantAsteriskTestDoc_gQeYHGCSaBE4zYSFpBrhre.dcf and b/integration-tests/validation/src/main/assets/figma/VariantAsteriskTestDoc_gQeYHGCSaBE4zYSFpBrhre.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/VariantInteractionsTestDoc_WcsgoLR4aDRSkZHY29Qdhq.dcf b/integration-tests/validation/src/main/assets/figma/VariantInteractionsTestDoc_WcsgoLR4aDRSkZHY29Qdhq.dcf index 99807033f..d049b673e 100644 Binary files a/integration-tests/validation/src/main/assets/figma/VariantInteractionsTestDoc_WcsgoLR4aDRSkZHY29Qdhq.dcf and b/integration-tests/validation/src/main/assets/figma/VariantInteractionsTestDoc_WcsgoLR4aDRSkZHY29Qdhq.dcf differ diff --git a/integration-tests/validation/src/main/assets/figma/VariantPropertiesTestDoc_4P7zDdrQxj7FZsKJoIQcx1.dcf b/integration-tests/validation/src/main/assets/figma/VariantPropertiesTestDoc_4P7zDdrQxj7FZsKJoIQcx1.dcf index b7d2dabe2..dcb39e86f 100644 Binary files a/integration-tests/validation/src/main/assets/figma/VariantPropertiesTestDoc_4P7zDdrQxj7FZsKJoIQcx1.dcf and b/integration-tests/validation/src/main/assets/figma/VariantPropertiesTestDoc_4P7zDdrQxj7FZsKJoIQcx1.dcf differ diff --git a/proto/definition/plugin/meter_data.proto b/proto/definition/plugin/meter_data.proto index 53a0eafd1..175a529c9 100644 --- a/proto/definition/plugin/meter_data.proto +++ b/proto/definition/plugin/meter_data.proto @@ -68,6 +68,13 @@ message ProgressMarkerMeterData { float end_y = 8; } +// Schema for progress vector data that we write to serialized data +message ProgressVectorMeterData { + bool enabled = 1; + bool discrete = 2; + float discrete_value = 3; +} + // A container message that holds one of the meter data types (rotation, arc, // progress bar, or progress marker). message MeterData { @@ -76,5 +83,6 @@ message MeterData { ArcMeterData arc_data = 2; ProgressBarMeterData progress_bar_data = 3; ProgressMarkerMeterData progress_marker_data = 4; + ProgressVectorMeterData progress_vector_data = 5; } } diff --git a/reference-apps/tutorial/app/src/main/assets/figma/TutorialDoc_3z4xExq0INrL9vxPhj9tl7.dcf b/reference-apps/tutorial/app/src/main/assets/figma/TutorialDoc_3z4xExq0INrL9vxPhj9tl7.dcf index e7a446eab..fba68f76c 100644 Binary files a/reference-apps/tutorial/app/src/main/assets/figma/TutorialDoc_3z4xExq0INrL9vxPhj9tl7.dcf and b/reference-apps/tutorial/app/src/main/assets/figma/TutorialDoc_3z4xExq0INrL9vxPhj9tl7.dcf differ