@@ -80,78 +80,74 @@ export class LVGLIdentifiers {
80
80
return styles ;
81
81
}
82
82
83
- get widgetIdentifiers ( ) : {
84
- global : LVGLIdentifier [ ] ;
85
- userWidget : Map < Page , LVGLIdentifier [ ] > ;
86
- } {
87
- const result = {
88
- global : [ ] ,
89
- userWidget : new Map ( )
90
- } ;
91
-
92
- function enumIdentifiers (
93
- page : Page ,
94
- identifiers : LVGLIdentifier [ ] ,
95
- prefix : string
96
- ) {
97
- page . _lvglWidgets . forEach ( widget => {
98
- let identifierName ;
83
+ enumIdentifiers ( page : Page , identifiers : LVGLIdentifier [ ] , prefix : string ) {
84
+ page . _lvglWidgets . forEach ( widget => {
85
+ let identifierName ;
86
+
87
+ if ( widget instanceof ProjectEditor . LVGLScreenWidgetClass ) {
88
+ identifierName = getName (
89
+ "" ,
90
+ page . name ,
91
+ NamingConvention . UnderscoreLowerCase
92
+ ) ;
93
+ } else {
94
+ if ( ! widget . identifier ) {
95
+ return ;
96
+ }
99
97
100
- if ( widget instanceof ProjectEditor . LVGLScreenWidgetClass ) {
101
- identifierName = getName (
98
+ identifierName =
99
+ prefix +
100
+ getName (
102
101
"" ,
103
- page . name ,
102
+ widget . identifier ,
104
103
NamingConvention . UnderscoreLowerCase
105
104
) ;
106
- } else {
107
- if ( ! widget . identifier ) {
108
- return ;
109
- }
110
-
111
- identifierName =
112
- prefix +
113
- getName (
114
- "" ,
115
- widget . identifier ,
116
- NamingConvention . UnderscoreLowerCase
117
- ) ;
118
- }
105
+ }
119
106
120
- if ( ! identifierName ) {
121
- return ;
122
- }
107
+ if ( ! identifierName ) {
108
+ return ;
109
+ }
123
110
124
- const identifier = identifiers . find (
125
- identifier => identifier . identifier == identifierName
126
- ) ;
127
- if ( identifier ) {
128
- identifier . widgets . push ( widget ) ;
129
- } else {
130
- identifiers . push ( {
131
- identifier : identifierName ,
132
- widgets : [ widget ]
133
- } ) ;
134
- }
111
+ const identifier = identifiers . find (
112
+ identifier => identifier . identifier == identifierName
113
+ ) ;
114
+ if ( identifier ) {
115
+ identifier . widgets . push ( widget ) ;
116
+ } else {
117
+ identifiers . push ( {
118
+ identifier : identifierName ,
119
+ widgets : [ widget ]
120
+ } ) ;
121
+ }
135
122
136
- if ( widget instanceof ProjectEditor . LVGLUserWidgetWidgetClass ) {
137
- if ( widget . userWidgetPage ) {
138
- enumIdentifiers (
139
- widget . userWidgetPage ,
140
- identifiers ,
141
- identifierName + USER_WIDGET_IDENTIFIER_SEPARATOR
142
- ) ;
143
- }
123
+ if ( widget instanceof ProjectEditor . LVGLUserWidgetWidgetClass ) {
124
+ if ( widget . userWidgetPage ) {
125
+ this . enumIdentifiers (
126
+ widget . userWidgetPage ,
127
+ identifiers ,
128
+ identifierName + USER_WIDGET_IDENTIFIER_SEPARATOR
129
+ ) ;
144
130
}
145
- } ) ;
146
- }
131
+ }
132
+ } ) ;
133
+ }
134
+
135
+ get widgetIdentifiers ( ) : {
136
+ global : LVGLIdentifier [ ] ;
137
+ userWidget : Map < Page , LVGLIdentifier [ ] > ;
138
+ } {
139
+ const result = {
140
+ global : [ ] ,
141
+ userWidget : new Map ( )
142
+ } ;
147
143
148
144
for ( const page of this . pages ) {
149
145
if ( page . isUsedAsUserWidget ) {
150
146
const identifiers : LVGLIdentifier [ ] = [ ] ;
151
- enumIdentifiers ( page , identifiers , "" ) ;
147
+ this . enumIdentifiers ( page , identifiers , "" ) ;
152
148
result . userWidget . set ( page , identifiers ) ;
153
149
} else {
154
- enumIdentifiers ( page , result . global , "" ) ;
150
+ this . enumIdentifiers ( page , result . global , "" ) ;
155
151
}
156
152
}
157
153
@@ -169,7 +165,19 @@ export class LVGLIdentifiers {
169
165
flow : Flow ,
170
166
displayName : string
171
167
) : LVGLIdentifier | undefined {
172
- const identifiers = this . getIdentifiersVisibleFromFlow ( flow ) ;
168
+ let identifiers = this . getIdentifiersVisibleFromFlow ( flow ) ;
169
+
170
+ if ( ! identifiers ) {
171
+ if (
172
+ flow instanceof ProjectEditor . PageClass &&
173
+ flow . _lvglUserWidgetOfPageCopy
174
+ ) {
175
+ identifiers = [ ] ;
176
+ this . enumIdentifiers ( flow , identifiers , "" ) ;
177
+ } else {
178
+ return undefined ;
179
+ }
180
+ }
173
181
174
182
return identifiers . find (
175
183
lvglIdentifier => lvglIdentifier . identifier == displayName
0 commit comments