mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Add getter/setter for the style
This commit is contained in:
parent
59d6866b13
commit
fd9d154b27
3 changed files with 44 additions and 0 deletions
|
@ -469,6 +469,19 @@ public:
|
||||||
cbindgen_private::sixtyfps_interpreter_component_compiler_set_include_paths(&inner, &paths);
|
cbindgen_private::sixtyfps_interpreter_component_compiler_set_include_paths(&inner, &paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_style(std::string_view style)
|
||||||
|
{
|
||||||
|
cbindgen_private::sixtyfps_interpreter_component_compiler_set_style(
|
||||||
|
&inner, sixtyfps::private_api::string_to_slice(style));
|
||||||
|
}
|
||||||
|
|
||||||
|
sixtyfps::SharedString style() const
|
||||||
|
{
|
||||||
|
sixtyfps::SharedString s;
|
||||||
|
cbindgen_private::sixtyfps_interpreter_component_compiler_get_style(&inner, &s);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
sixtyfps::SharedVector<sixtyfps::SharedString> include_paths() const
|
sixtyfps::SharedVector<sixtyfps::SharedString> include_paths() const
|
||||||
{
|
{
|
||||||
sixtyfps::SharedVector<sixtyfps::SharedString> paths;
|
sixtyfps::SharedVector<sixtyfps::SharedString> paths;
|
||||||
|
|
|
@ -259,6 +259,13 @@ SCENARIO("Component Compiler")
|
||||||
REQUIRE(out_paths[1] == "path2");
|
REQUIRE(out_paths[1] == "path2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("configure style")
|
||||||
|
{
|
||||||
|
REQUIRE(compiler.style() == "");
|
||||||
|
compiler.set_style("ugly");
|
||||||
|
REQUIRE(compiler.style() == "ugly");
|
||||||
|
}
|
||||||
|
|
||||||
SECTION("Compile failure from source")
|
SECTION("Compile failure from source")
|
||||||
{
|
{
|
||||||
auto result = compiler.build_from_source("Syntax Error!!", "");
|
auto result = compiler.build_from_source("Syntax Error!!", "");
|
||||||
|
|
|
@ -368,6 +368,11 @@ impl ComponentCompiler {
|
||||||
self.config.style = Some(style);
|
self.config.style = Some(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the style the compiler is currently using when compiling .60 files.
|
||||||
|
pub fn style(&self) -> Option<&String> {
|
||||||
|
self.config.style.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a new configuration that will use the provided callback for loading.
|
/// Create a new configuration that will use the provided callback for loading.
|
||||||
pub fn set_file_loader(
|
pub fn set_file_loader(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -1295,6 +1300,25 @@ pub(crate) mod ffi {
|
||||||
.set_include_paths(paths.iter().map(|path| path.as_str().into()).collect())
|
.set_include_paths(paths.iter().map(|path| path.as_str().into()).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn sixtyfps_interpreter_component_compiler_set_style(
|
||||||
|
compiler: &mut ComponentCompilerOpaque,
|
||||||
|
style: Slice<u8>,
|
||||||
|
) {
|
||||||
|
compiler
|
||||||
|
.as_component_compiler_mut()
|
||||||
|
.set_style(std::str::from_utf8(&style).unwrap().to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn sixtyfps_interpreter_component_compiler_get_style(
|
||||||
|
compiler: &ComponentCompilerOpaque,
|
||||||
|
style_out: &mut SharedString,
|
||||||
|
) {
|
||||||
|
*style_out =
|
||||||
|
compiler.as_component_compiler().style().map_or(SharedString::default(), |s| s.into());
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sixtyfps_interpreter_component_compiler_get_include_paths(
|
pub unsafe extern "C" fn sixtyfps_interpreter_component_compiler_get_include_paths(
|
||||||
compiler: &ComponentCompilerOpaque,
|
compiler: &ComponentCompilerOpaque,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue