svghmi/widget_animate.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Thu, 07 Apr 2022 07:40:32 +0200
branchwxPython4
changeset 3447 65c5f66e9298
parent 3232 7bdb766c2a4d
permissions -rw-r--r--
Tests: add HTML report generation and a workaround to bad exception handling in sikuli.

In case of exception in python code, and since a thread is running
to observe stdout, sikuli was never terminated after an exception.
Unfortunately sys.exepthook doesn't work in that version of jython/sikuli.
Test are now written inside functions witch are passed to run_test to deal
with exception.
// widget_animate.ysl2

widget_class("Animate") {
    ||
        frequency = 5;
        speed = 0;
        start = false;
        widget_center = undefined;

        dispatch(value) {
            this.speed = value / 5;

            //reconfigure animation
            this.request_animate();
        }

        animate(){
           // change animation properties
           for(let child of this.element.children){
                if(child.nodeName.startsWith("animate")){
                    if(this.speed != 0 && !this.start){
                        this.start = true;
                        this.element.beginElement();
                    }

                    if(this.speed > 0){
                        child.setAttribute("dur", this.speed+"s");
                    }
                    else if(this.speed < 0){
                        child.setAttribute("dur", (-1)*this.speed+"s");
                    }
                    else{
                        this.start = false;
                        this.element.endElement();
                    }
                }
           }
        }

        init() {
            let widget_pos = this.element.getBBox();
            this.widget_center = [(widget_pos.x+widget_pos.width/2), (widget_pos.y+widget_pos.height/2)];
        }
    ||
}