slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.94k stars 568 forks source link

Cannot export to native code from more than one module #4613

Closed martinellison closed 7 months ago

martinellison commented 7 months ago

If I try something like

export * from "./exports.slint";
export * from "./meta.slint";

then I get an error message re-exporting modules is only allowed once per file.

Also, I can only export to native code from one slint file.

So I can only export to native code from (a) my main slint file and (b) one more file.

But I want to be able to modularise my slint code into several files (modules) and export from all of them to the native code.

Please add this capabilty (or document how to do this).

FloVanGH commented 7 months ago

Hi,

It's only the export * from that is currently allowed once in a file. What you work is this:

import { MyType } from "./exports.slint";
import { MyMetaType } from "./meta.slint";

export { MyType, MyMetaType }
ogoffart commented 7 months ago

This is done on purpose, to make sure there can't be conflicts if two files have the same exports

(Commit 7980eda7e11bc3399e2eb53207443eb7e921466d adds a note in the docs)

martinellison commented 7 months ago

Ok thanks, I'll try that.

Regards, Martin Ellison (he/him)

On Wed, 14 Feb 2024, 18:06 Florian Blasius, @.***> wrote:

Hi,

It's only the export * from that is currently allowed once in a file. What you work is this:

import { MyType } from "./exports.slint"; import { MyMetaType } from "./meta.slint";

export { MyType, MyMetaType }

— Reply to this email directly, view it on GitHub https://github.com/slint-ui/slint/issues/4613#issuecomment-1943438433, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACEA3AV7TZ5JXOU5UP2VXMLYTSEBHAVCNFSM6AAAAABDHZAESSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNBTGQZTQNBTGM . You are receiving this because you authored the thread.Message ID: @.***>

Necro-U commented 7 months ago

Hello, I have a issue with this. I am using 1.3.2 version of slint and i am exporting 2 views ( MainView and App ) but the native code takes just one of them. Actually the last one that I exported. Here is the explanation:

export MainView:=Window {
    // Style
    width: 500px;
    height: 500px;
    title: "Program";
    background: goldenrod;
    }

This is MainView module and,

import {MainView} from "./index.slint";
import {ROOT_GLOBAL} from "./global.slint";
export {App,MainView}
component App inherits Window {
  height: ROOT-GLOBAL.window-height;
  width: ROOT-GLOBAL.window-width;
  title: @tr("Slint + SurrealismUI + Rust");
  // MainView {}
}

This is where i export the modules. When I export export {App,MainView} like this inative code can see the MainView but it can't see App module. In the other hand if I try to export like export {MainView,App} then it can see App but not MainView.

Why is that happening?

ogoffart commented 7 months ago

@Necro-U Your issue is different, this is issue https://github.com/slint-ui/slint/issues/784