2012-12-21 07:08:48 -05:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2017-02-14 19:43:09 -05:00
|
|
|
const UI = imports.testcommon.ui;
|
|
|
|
|
2019-02-08 22:21:36 -05:00
|
|
|
const { Clutter, GLib, St } = imports.gi;
|
2012-12-21 07:08:48 -05:00
|
|
|
const Mainloop = imports.mainloop;
|
|
|
|
|
|
|
|
const DELAY = 2000;
|
|
|
|
|
|
|
|
function resize_animated(label) {
|
|
|
|
if (label.width == 100) {
|
|
|
|
label.save_easing_state();
|
|
|
|
label.set_easing_mode(Clutter.AnimationMode.EASE_OUT_QUAD);
|
|
|
|
label.set_easing_duration(DELAY - 50);
|
|
|
|
label.set_size(500, 500);
|
|
|
|
label.restore_easing_state();
|
|
|
|
} else {
|
|
|
|
label.save_easing_state();
|
|
|
|
label.set_easing_mode(Clutter.AnimationMode.EASE_OUT_QUAD);
|
|
|
|
label.set_easing_duration(DELAY - 50);
|
|
|
|
label.set_size(100, 100);
|
|
|
|
label.restore_easing_state();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_css_style(shadow_style)
|
|
|
|
{
|
|
|
|
return 'border: 20px solid black;' +
|
|
|
|
'border-radius: 20px;' +
|
|
|
|
'background-color: white; ' +
|
|
|
|
'padding: 5px;' + shadow_style;
|
|
|
|
}
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
let stage = new Clutter.Stage({ width: 1000, height: 600 });
|
|
|
|
UI.init(stage);
|
|
|
|
|
|
|
|
let iter = 0;
|
|
|
|
let shadowStyles = [ 'box-shadow: 3px 50px 0px 4px rgba(0,0,0,0.5);',
|
|
|
|
'box-shadow: 3px 4px 10px 4px rgba(0,0,0,0.5);',
|
|
|
|
'box-shadow: 0px 50px 0px 0px rgba(0,0,0,0.5);',
|
|
|
|
'box-shadow: 100px 100px 20px 4px rgba(0,0,0,0.5);'];
|
|
|
|
let label1 = new St.Label({ style: get_css_style(shadowStyles[iter]),
|
|
|
|
text: shadowStyles[iter],
|
|
|
|
x: 20,
|
|
|
|
y: 20,
|
|
|
|
width: 100,
|
|
|
|
height: 100
|
|
|
|
});
|
|
|
|
stage.add_actor(label1);
|
|
|
|
let label2 = new St.Label({ style: get_css_style(shadowStyles[iter]),
|
|
|
|
text: shadowStyles[iter],
|
|
|
|
x: 500,
|
|
|
|
y: 20,
|
|
|
|
width: 100,
|
|
|
|
height: 100
|
|
|
|
});
|
|
|
|
stage.add_actor(label2);
|
|
|
|
|
|
|
|
resize_animated(label1);
|
|
|
|
resize_animated(label2);
|
2017-10-30 20:38:18 -04:00
|
|
|
Mainloop.timeout_add(DELAY, () => {
|
2012-12-21 07:08:48 -05:00
|
|
|
log(label1 + label1.get_size());
|
|
|
|
resize_animated(label1);
|
|
|
|
resize_animated(label2);
|
|
|
|
return true;
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2012-12-21 07:08:48 -05:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
Mainloop.timeout_add(2 * DELAY, () => {
|
2012-12-21 07:08:48 -05:00
|
|
|
iter += 1;
|
|
|
|
iter %= shadowStyles.length;
|
|
|
|
label1.set_style(get_css_style(shadowStyles[iter]));
|
|
|
|
label1.set_text(shadowStyles[iter]);
|
|
|
|
label2.set_style(get_css_style(shadowStyles[iter]));
|
|
|
|
label2.set_text(shadowStyles[iter]);
|
|
|
|
return true;
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2012-12-21 07:08:48 -05:00
|
|
|
|
|
|
|
UI.main(stage);
|
|
|
|
}
|
|
|
|
test();
|