svghmi/detachable_pages.ysl2
changeset 3685 570a738239f4
parent 3653 d5ff60e906b0
child 3877 ecb947e5bbb4
equal deleted inserted replaced
3684:2239f8e3de48 3685:570a738239f4
   135 
   135 
   136 // Avoid nested detachables
   136 // Avoid nested detachables
   137 const "_detachable_elements", "func:detachable_elements($hmi_pages | $keypads)";
   137 const "_detachable_elements", "func:detachable_elements($hmi_pages | $keypads)";
   138 const "detachable_elements", "$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]";
   138 const "detachable_elements", "$_detachable_elements[not(ancestor::*/@id = $_detachable_elements/@id)]";
   139 
   139 
       
   140 emit "declarations:page-class" {
       
   141     | class PageWidget extends Widget{}
       
   142 }
       
   143 
   140 emit "declarations:detachable-elements" {
   144 emit "declarations:detachable-elements" {
   141     |
   145     |
   142     | var detachable_elements = {
   146     | var detachable_elements = {
   143     foreach "$detachable_elements"{
   147     foreach "$detachable_elements"{
   144     |     "«@id»":[id("«@id»"), id("«../@id»")]`if "position()!=last()" > ,`
   148     |     "«@id»":[id("«@id»"), id("«../@id»")]`if "position()!=last()" > ,`
   163 
   167 
   164     const "page_all_elements", "func:all_related_elements($page)";
   168     const "page_all_elements", "func:all_related_elements($page)";
   165 
   169 
   166     const "all_page_widgets","$hmi_widgets[@id = $page_all_elements/@id and @id != $page/@id]";
   170     const "all_page_widgets","$hmi_widgets[@id = $page_all_elements/@id and @id != $page/@id]";
   167     const "page_managed_widgets","$all_page_widgets[not(@id=$in_forEach_widget_ids)]";
   171     const "page_managed_widgets","$all_page_widgets[not(@id=$in_forEach_widget_ids)]";
       
   172 
       
   173     const "page_root_path", "$desc/path[not(@assign)]";
       
   174     if "count($page_root_path)>1"
       
   175         error > Page id="«$page/@id»" : only one root path can be declared
       
   176 
   168     const "page_relative_widgets",
   177     const "page_relative_widgets",
   169         "$page_managed_widgets[func:is_descendant_path(func:widget(@id)/path/@value, $desc/path/@value)]";
   178         "$page_managed_widgets[func:is_descendant_path(func:widget(@id)/path/@value, $page_root_path/@value)]";
   170 
   179 
   171     // Take closest ancestor in detachable_elements
   180     // Take closest ancestor in detachable_elements
   172     // since nested detachable elements are filtered out
   181     // since nested detachable elements are filtered out
   173     const "sumarized_page", 
   182     const "sumarized_page", 
   174         """func:sumarized_elements($page_all_elements)""";
   183         """func:sumarized_elements($page_all_elements)""";
   176     const "required_detachables", 
   185     const "required_detachables", 
   177         """$sumarized_page/
   186         """$sumarized_page/
   178            ancestor-or-self::*[@id = $detachable_elements/@id]""";
   187            ancestor-or-self::*[@id = $detachable_elements/@id]""";
   179 
   188 
   180     |   "«$pagename»": {
   189     |   "«$pagename»": {
   181     //|     widget: hmi_widgets["«@id»"],
       
   182     |     bbox: [«$p/@x», «$p/@y», «$p/@w», «$p/@h»],
   190     |     bbox: [«$p/@x», «$p/@y», «$p/@w», «$p/@h»],
   183     if "$desc/path/@value" {
   191     if "count($page_root_path)=1"{
   184         if "count($desc/path/@index)=0"
   192         if "count($page_root_path/@index)=0"
   185             warning > Page id="«$page/@id»" : No match for path "«$desc/path/@value»" in HMI tree
   193             warning > Page id="«$page/@id»" : No match for path "«$page_root_path/@value»" in HMI tree
   186     |     page_index: «$desc/path/@index»,
   194     |     page_index: «$page_root_path/@index»,
   187     |     page_class: "«$indexed_hmitree/*[@hmipath = $desc/path/@value]/@class»",
   195     |     page_class: "«$indexed_hmitree/*[@hmipath = $page_root_path/@value]/@class»",
   188     }
   196     }
   189     |     widgets: [
   197     |     widgets: [
       
   198     |         [hmi_widgets["«$page/@id»"], []],
   190     foreach "$page_managed_widgets" {
   199     foreach "$page_managed_widgets" {
   191         const "widget_paths_relativeness" 
   200         const "widget_paths_relativeness" 
   192             foreach "func:widget(@id)/path" {
   201             foreach "func:widget(@id)/path" {
   193                 value "func:is_descendant_path(@value, $desc/path/@value)";
   202                 value "func:is_descendant_path(@value, $page_root_path/@value)";
   194                 if "position()!=last()" > ,
   203                 if "position()!=last()" > ,
   195             }
   204             }
   196     |         [hmi_widgets["«@id»"], [«$widget_paths_relativeness»]]`if "position()!=last()" > ,`
   205     |         [hmi_widgets["«@id»"], [«$widget_paths_relativeness»]]`if "position()!=last()" > ,`
   197     }
   206     }
   198     |     ],
   207     |     ],