svghmi/widget_button.ysl2
author Edouard Tisserant
Mon, 26 Jul 2021 10:20:39 +0200
branchsvghmi
changeset 3291 7d0e7e4d88cd
parent 3241 fe945f1f48b7
child 3413 2e84a2782295
permissions -rw-r--r--
IDE: On windows, align better "reset to default" button in CTN config panel.
2944
2a20038fbea9 Added button and circular bar widgets.
dgaberscek
parents:
diff changeset
     1
// widget_button.ysl2
2a20038fbea9 Added button and circular bar widgets.
dgaberscek
parents:
diff changeset
     2
3241
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     3
widget_desc("Button") {
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     4
    longdesc
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     5
    ||
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     6
    Button widget takes one boolean variable path, and reflect current true
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     7
    or false value by showing "active" or "inactive" labeled element
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     8
    respectively. Pressing and releasing button changes variable to true and
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     9
    false respectively. Potential inconsistency caused by quick consecutive
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    10
    presses on the button is mitigated by using a state machine that wait for
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    11
    previous state change to be reflected on variable before applying next one.
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    12
    ||
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    13
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    14
    shortdesc > Push button reflecting consistently given boolean variable
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    15
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    16
    path name="value" accepts="HMI_BOOL" > Boolean variable
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    17
    
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    18
}
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    19
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    20
// Finite state machine
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    21
decl fsm(name);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    22
decl state(name);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    23
decl on_mouse(position);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    24
decl on_dispatch(value);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    25
decl jump(state);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    26
decl show(eltname);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    27
decl hmi_value(value);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    28
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3086
diff changeset
    29
gen_index_xhtml {
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3086
diff changeset
    30
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    31
// State machine to drive HMI_BOOL on a potentially laggy connection
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    32
const "_button_fsm" fsm {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    33
    state "init" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    34
        on_dispatch "false" jump "released";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    35
        on_dispatch "true" jump "pressed";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    36
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    37
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    38
    state "pressing" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    39
        // show "waitactive";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    40
        hmi_value "true";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    41
        on_dispatch "true" jump "pressed";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    42
        on_mouse "up" jump "shortpress";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    43
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    44
    state "pressed" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    45
        show "active";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    46
        on_mouse "up" jump "releasing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    47
        on_dispatch "false" jump "released";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    48
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    49
    state "shortpress" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    50
        on_dispatch "true" jump "releasing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    51
        on_mouse "down" jump "pressing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    52
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    53
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    54
    state "releasing" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    55
        // show "waitinactive";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    56
        hmi_value "false";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    57
        on_dispatch "false" jump "released";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    58
        on_mouse "down" jump "shortrelease";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    59
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    60
    state "released" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    61
        show "inactive";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    62
        on_mouse "down" jump "pressing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    63
        on_dispatch "true" jump "pressed";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    64
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    65
    state "shortrelease" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    66
        on_dispatch "false" jump "pressing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    67
        on_mouse "up" jump "releasing";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    68
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    69
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    70
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    71
template "fsm", mode="dispatch_transition" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    72
    |         switch (this.state) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    73
    apply "state", mode="dispatch_transition";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    74
    |         }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    75
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    76
template "state", mode="dispatch_transition" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    77
    |           case "«@name»":
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
    78
       apply "on-dispatch";
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    79
    |             break;
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    80
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    81
template "on-dispatch" {
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
    82
    |             if(value ==  «@value») {
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
    83
    apply "jump", mode="transition";
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
    84
    |             }
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    85
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    86
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    87
template "fsm", mode="mouse_transition" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    88
    param "position";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    89
    |         switch (this.state) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    90
    apply "state", mode="mouse_transition" with "position", "$position";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    91
    |         }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    92
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    93
template "state", mode="mouse_transition" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    94
    param "position";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    95
    |           case "«@name»":
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    96
    apply "on-mouse[@position = $position]";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    97
    |             break;
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    98
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
    99
template "on-mouse" {
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   100
    // up or down state is already assumed because apply statement filters it
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   101
    apply "jump", mode="transition";
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   102
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   103
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   104
template "jump", mode="transition" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   105
    |             this.state = "«@state»";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   106
    |             this.«@state»_action();
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   107
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   108
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   109
template "fsm", mode="actions" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   110
    apply "state", mode="actions";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   111
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   112
template "state", mode="actions" {
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   113
    |     «@name»_action(){
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   114
    //| console.log("Entering state «@name»");
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   115
    apply "*", mode="actions";
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   116
    |     }
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   117
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   118
template "show", mode="actions" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   119
    |         this.display = "«@eltname»";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   120
    |         this.request_animate();
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   121
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   122
template "hmi-value", mode="actions" {
3086
a70a97196654 SVGHMI: cosmetic fixes in button widget
Edouard Tisserant
parents: 3085
diff changeset
   123
    |         this.apply_hmi_value(0, «@value»);
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   124
}
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   125
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3086
diff changeset
   126
}
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3086
diff changeset
   127
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3086
diff changeset
   128
widget_class("Button"){
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   129
    const "fsm","exsl:node-set($_button_fsm)";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   130
    |     frequency = 5;
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
   131
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   132
    |     display = "inactive";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   133
    |     state = "init";
3059
e0db3f6a5f39 Button and toggle reworked to use animate and dispatch
usveticic
parents: 3058
diff changeset
   134
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   135
    |     dispatch(value) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   136
    // |         console.log("dispatch"+value);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   137
    apply "$fsm", mode="dispatch_transition";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   138
    |     }
3056
827bf284feec Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents: 3024
diff changeset
   139
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   140
    |     onmouseup(evt) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   141
    |         svg_root.removeEventListener("pointerup", this.bound_onmouseup, true);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   142
    // |         console.log("onmouseup");
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   143
    apply "$fsm", mode="mouse_transition" with "position", "'up'";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   144
    |     }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   145
    |     onmousedown(evt) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   146
    |         svg_root.addEventListener("pointerup", this.bound_onmouseup, true);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   147
    // |         console.log("onmousedown");
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   148
    apply "$fsm", mode="mouse_transition" with "position", "'down'";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   149
    |     }
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
   150
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   151
    apply "$fsm", mode="actions";
3056
827bf284feec Button, ToggleButton and slider updated. Error to warning when building
usveticic
parents: 3024
diff changeset
   152
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   153
    |     animate(){
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   154
    |         if (this.active_elt && this.inactive_elt) {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   155
    foreach "str:split('active inactive')" {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   156
    |             if(this.display == "«.»")
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   157
    |                 this.«.»_elt.style.display = "";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   158
    |             else
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   159
    |                 this.«.»_elt.style.display = "none";
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   160
    }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   161
    |         }
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   162
    |     }
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
   163
3085
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   164
    |     init() {
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   165
    |         this.bound_onmouseup = this.onmouseup.bind(this);
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   166
    |         this.element.addEventListener("pointerdown", this.onmousedown.bind(this));
6b1b23971960 SVGHMI: Rewrote button widget.
Edouard Tisserant
parents: 3062
diff changeset
   167
    |     }
3024
Edouard Tisserant
parents: 3018
diff changeset
   168
}
3009
7c6960f09881 Reworked button widget so it uses classes.
usveticic
parents: 3004
diff changeset
   169
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3086
diff changeset
   170
widget_defs("Button") {
2976
99c4521bb844 SVGHMI: Changed widget button handler to element attribute.
dgaberscek
parents: 2961
diff changeset
   171
    optional_labels("active inactive");
3000
a9a45977bac0 SVGHMI: prefer apply_hmi_value() to change_hmi_value() when possible
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2976
diff changeset
   172
}