From 1d54947de97aeff8f996591732ca766eedbc046c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 3 Feb 2021 13:22:44 +0100 Subject: [PATCH] Fix compilation of @linear-gradient with brush properties in C++ --- sixtyfps_compiler/generator/cpp.rs | 2 +- tests/cases/types/gradients.60 | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/cases/types/gradients.60 diff --git a/sixtyfps_compiler/generator/cpp.rs b/sixtyfps_compiler/generator/cpp.rs index f0de65a9c..c4ff271f6 100644 --- a/sixtyfps_compiler/generator/cpp.rs +++ b/sixtyfps_compiler/generator/cpp.rs @@ -1661,7 +1661,7 @@ fn compile_expression( format!("sixtyfps::GradientStop{{ {}, {}, }}", color, position) }); format!( - "[&] {{ const sixtyfps::GradientStop stops[] = {{ {} }}; return sixtyfps::LinearGradientBrush({}, stops, {}); }}()", + "[&] {{ const sixtyfps::GradientStop stops[] = {{ {} }}; return sixtyfps::Brush(sixtyfps::LinearGradientBrush({}, stops, {})); }}()", stops_it.join(", "), angle, stops.len() ) } diff --git a/tests/cases/types/gradients.60 b/tests/cases/types/gradients.60 new file mode 100644 index 000000000..b33937b32 --- /dev/null +++ b/tests/cases/types/gradients.60 @@ -0,0 +1,16 @@ +/* LICENSE BEGIN + This file is part of the SixtyFPS Project -- https://sixtyfps.io + Copyright (c) 2020 Olivier Goffart + Copyright (c) 2020 Simon Hausmann + + SPDX-License-Identifier: GPL-3.0-only + This file is also available under commercial licensing terms. + Please contact info@sixtyfps.io for more information. +LICENSE END */ + +// Verify that this compiles with all generators + +Test := Rectangle { + background: @linear-gradient(45deg, #ff9a9e 0%, #fad0c4 99%, #fad0c4 100%); +} +