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/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 55% rename from crates/dc_bundle/src/legacy_definition/plugin/meter_data.rs rename to crates/figma_import/src/meter_schema.rs index 5e9cb2310..dfdf8c42e 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,23 @@ 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 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 { + ArcData(ArcMeterJson), + RotationData(RotationMeterJson), + ProgressBarData(ProgressBarMeterJson), + ProgressMarkerData(ProgressMarkerMeterJson), + ProgressVectorData(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 4cac2ca19..688d7aa3d 100644 --- a/crates/figma_import/src/transform_flexbox.rs +++ b/crates/figma_import/src/transform_flexbox.rs @@ -18,18 +18,19 @@ 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, + FontWeight, Path, Size, ViewShape, }; use crate::figma_schema::LayoutPositioning; @@ -39,7 +40,6 @@ 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}; @@ -1562,18 +1566,67 @@ 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(); - 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(); - } + let meter_data = serde_json::from_str::(data.as_str()); + match meter_data { + Ok(meter_data) => { + style.node_style.meter_data = Some(match meter_data { + MeterJson::ArcData(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::RotationData(data) => { + MeterData::RotationData(RotationMeterData { + enabled: data.enabled, + start: data.start, + end: data.end, + discrete: data.discrete, + discrete_value: data.discrete_value, + }) + } + MeterJson::ProgressBarData(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, + }) + } + MeterJson::ProgressMarkerData(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::ProgressVectorData(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, + }) + } + }) + } + Err(e) => { + error!("Failed to parse meter data: {}", e); } - style.node_style.meter_data = Some(meter_data.into()); } } } diff --git a/crates/figma_import/tests/layout-unit-tests.dcf b/crates/figma_import/tests/layout-unit-tests.dcf index 243048886..a61ab2f2e 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/crates/figma_import/tests/test_fetches.rs b/crates/figma_import/tests/test_fetches.rs index 90f7bcc62..9e0dec7da 100644 --- a/crates/figma_import/tests/test_fetches.rs +++ b/crates/figma_import/tests/test_fetches.rs @@ -19,18 +19,14 @@ use figma_import::tools::fetch::{build_definition, load_figma_token}; use figma_import::{Document, ProxyConfig}; // Simply fetches and serializes a doc -#[test] -#[cfg_attr(not(feature = "test_fetches"), ignore)] -fn fetch_variable_modes() { - const DOC_ID: &str = "HhGxvL4aHhP8ALsLNz56TP"; - const QUERIES: &[&str] = &["#stage", "#Box"]; - let queries: Vec = QUERIES.iter().map(|s| s.to_string()).collect(); +fn run_test(doc_id: &str, queries: &[&str]) { + let queries: Vec = queries.iter().map(|s| s.to_string()).collect(); let figma_token = load_figma_token().unwrap(); let mut doc: Document = Document::new( figma_token.as_str(), - DOC_ID.to_string(), + doc_id.to_string(), String::new(), &ProxyConfig::None, None, @@ -41,3 +37,18 @@ fn fetch_variable_modes() { bincode::serialize(&dc_definition).unwrap(); } + +#[test] +#[cfg_attr(not(feature = "test_fetches"), ignore)] +fn fetch_variable_modes() { + run_test("HhGxvL4aHhP8ALsLNz56TP", &["#stage", "#Box"]); +} + +#[test] +#[cfg_attr(not(feature = "test_fetches"), ignore)] +fn fetch_dials_gauges_progress_constraints() { + run_test( + "lZj6E9GtIQQE4HNLpzgETw", + &["#stage-constraints", "#progress-bar", "#progress-indicator"], + ); +} diff --git a/designcompose/src/main/assets/figma/DesignSwitcherDoc_Ljph4e3sC0lHcynfXpoh9f.dcf b/designcompose/src/main/assets/figma/DesignSwitcherDoc_Ljph4e3sC0lHcynfXpoh9f.dcf index 65c12c921..c3019ceda 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 3a033519a..d6e1469b3 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 c3b53b61f..2ab2e831b 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 b7efd9e7c..653c4a770 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/ComponentReplaceRelayoutDoc_qIh0IOQTCtgeAWZFF5gYSk.dcf b/integration-tests/validation/src/main/assets/figma/ComponentReplaceRelayoutDoc_qIh0IOQTCtgeAWZFF5gYSk.dcf index 423690c22..1b0f56394 100644 Binary files a/integration-tests/validation/src/main/assets/figma/ComponentReplaceRelayoutDoc_qIh0IOQTCtgeAWZFF5gYSk.dcf and b/integration-tests/validation/src/main/assets/figma/ComponentReplaceRelayoutDoc_qIh0IOQTCtgeAWZFF5gYSk.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 69d339ee7..f5018eeb1 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/DialsGaugesTestDoc_lZj6E9GtIQQE4HNLpzgETw.dcf b/integration-tests/validation/src/main/assets/figma/DialsGaugesTestDoc_lZj6E9GtIQQE4HNLpzgETw.dcf index b9bfe6021..aeee3fda3 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 e43545fa0..f88d2a9ac 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 801fa390f..13ce516ef 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 8f1a77fe7..df4a65030 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 e0fb10558..64f7a81dd 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 e7753dfc7..74576104c 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 7f688c3f7..91751cad7 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 00c234913..a28e23450 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/ItemSpacingTestDoc_YXrHBp6C6OaW5ShcCYeGJc.dcf b/integration-tests/validation/src/main/assets/figma/ItemSpacingTestDoc_YXrHBp6C6OaW5ShcCYeGJc.dcf index 3bc689eb7..52a8d9121 100644 Binary files a/integration-tests/validation/src/main/assets/figma/ItemSpacingTestDoc_YXrHBp6C6OaW5ShcCYeGJc.dcf and b/integration-tests/validation/src/main/assets/figma/ItemSpacingTestDoc_YXrHBp6C6OaW5ShcCYeGJc.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 6f343d3a5..e066f5e68 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 6aa65e663..af40ad32e 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 77b4e32af..c205e966f 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 4b43fdb87..c9bbf749e 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 42e907d35..ba7c851f3 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 34a8e4570..3b530b90c 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 3abba02f3..1f86e38a2 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 878d5f80b..fbc7ce534 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 1d1699d1c..3ffa69c6f 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..2f299a2df 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 6f823f0b7..0549b3dc9 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 94e8ab15c..3f9171aca 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/VariableBorderTestDoc_MWnVAfW3FupV4VMLNR1m67.dcf b/integration-tests/validation/src/main/assets/figma/VariableBorderTestDoc_MWnVAfW3FupV4VMLNR1m67.dcf index 9d89867f1..e260114d9 100644 Binary files a/integration-tests/validation/src/main/assets/figma/VariableBorderTestDoc_MWnVAfW3FupV4VMLNR1m67.dcf and b/integration-tests/validation/src/main/assets/figma/VariableBorderTestDoc_MWnVAfW3FupV4VMLNR1m67.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 0631bc0eb..994693c2a 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 9dc537ef8..c6075a29c 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 6c24da1a2..bc6ba06a8 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 3b7e204aa..68516bbe6 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 a410a2249..0056a1156 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 fc48b74da..98175ebc6 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 abd251b2d..0579fdad1 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