2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2009-09-20 20:21:47 +00:00
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const St = imports.gi.St;
|
|
|
|
|
|
|
|
const UI = imports.testcommon.ui;
|
|
|
|
|
|
|
|
UI.init();
|
|
|
|
let stage = Clutter.Stage.get_default();
|
2010-01-15 23:32:48 +00:00
|
|
|
stage.width = 640;
|
|
|
|
stage.height = 480;
|
2009-09-20 20:21:47 +00:00
|
|
|
|
2010-12-09 12:20:09 +00:00
|
|
|
let vbox = new St.BoxLayout({ width: stage.width,
|
2009-09-20 20:21:47 +00:00
|
|
|
height: stage.height,
|
2010-12-09 12:20:09 +00:00
|
|
|
style: 'background: #ffee88;' });
|
|
|
|
stage.add_actor(vbox);
|
|
|
|
|
2010-01-15 23:32:48 +00:00
|
|
|
let scroll = new St.ScrollView();
|
2010-12-09 12:20:09 +00:00
|
|
|
vbox.add(scroll, { expand: true });
|
|
|
|
|
|
|
|
let box = new St.BoxLayout({ vertical: true,
|
|
|
|
style: 'padding: 10px;'
|
|
|
|
+ 'spacing: 20px;' });
|
|
|
|
scroll.add_actor(box);
|
|
|
|
|
|
|
|
box.add(new St.Label({ text: "Hello World",
|
|
|
|
style: 'border: 1px solid black; '
|
|
|
|
+ 'padding: 5px;' }));
|
2009-09-20 20:21:47 +00:00
|
|
|
|
2010-12-09 12:20:09 +00:00
|
|
|
box.add(new St.Label({ text: "Hello Round World",
|
|
|
|
style: 'border: 3px solid green; '
|
|
|
|
+ 'border-radius: 8px; '
|
|
|
|
+ 'padding: 5px;' }));
|
2009-09-20 20:21:47 +00:00
|
|
|
|
2010-12-09 12:20:09 +00:00
|
|
|
box.add(new St.Label({ text: "Hello Background",
|
|
|
|
style: 'border: 3px solid green; '
|
|
|
|
+ 'border-radius: 8px; '
|
|
|
|
+ 'background: white; '
|
|
|
|
+ 'padding: 5px;' }));
|
2009-09-20 20:21:47 +00:00
|
|
|
|
2010-12-09 12:20:09 +00:00
|
|
|
box.add(new St.Label({ text: "Hello Translucent Black Border",
|
|
|
|
style: 'border: 3px solid rgba(0, 0, 0, 0.4); '
|
|
|
|
+ 'background: white; ' }));
|
2009-09-20 20:21:47 +00:00
|
|
|
|
2010-12-09 12:20:09 +00:00
|
|
|
box.add(new St.Label({ text: "Hello Translucent Background",
|
|
|
|
style: 'background: rgba(255, 255, 255, 0.3);' }));
|
2010-01-15 23:32:48 +00:00
|
|
|
|
2010-12-09 12:20:09 +00:00
|
|
|
box.add(new St.Label({ text: "Border, Padding, Content: 20px" }));
|
2009-09-20 20:21:47 +00:00
|
|
|
|
|
|
|
let b1 = new St.BoxLayout({ vertical: true,
|
|
|
|
style: 'border: 20px solid black; '
|
|
|
|
+ 'background: white; '
|
|
|
|
+ 'padding: 20px;' });
|
2010-12-09 12:20:09 +00:00
|
|
|
box.add(b1);
|
2009-09-20 20:21:47 +00:00
|
|
|
|
|
|
|
b1.add(new St.BoxLayout({ width: 20, height: 20,
|
|
|
|
style: 'background: black' }));
|
|
|
|
|
2010-12-09 12:20:09 +00:00
|
|
|
box.add(new St.Label({ text: "Translucent big blue border, with rounding",
|
|
|
|
style: 'border: 20px solid rgba(0, 0, 255, 0.2); '
|
|
|
|
+ 'border-radius: 10px; '
|
|
|
|
+ 'background: white; '
|
|
|
|
+ 'padding: 10px;' }));
|
2009-09-20 22:03:18 +00:00
|
|
|
|
2010-12-09 12:20:09 +00:00
|
|
|
box.add(new St.Label({ text: "Transparent border",
|
|
|
|
style: 'border: 20px solid transparent; '
|
|
|
|
+ 'background: white; '
|
|
|
|
+ 'padding: 10px;' }));
|
2009-09-20 20:21:47 +00:00
|
|
|
|
2010-12-09 12:20:09 +00:00
|
|
|
box.add(new St.Label({ text: "Border Image",
|
|
|
|
style_class: "border-image",
|
|
|
|
style: "padding: 10px;" }));
|
2009-09-20 20:21:47 +00:00
|
|
|
|
2011-01-05 15:08:50 +00:00
|
|
|
box.add(new St.Label({ text: "Border Image with Gradient",
|
|
|
|
style_class: 'border-image-with-background-gradient',
|
|
|
|
style: "padding: 10px;"
|
|
|
|
+ 'background-gradient-direction: vertical;' }));
|
|
|
|
|
|
|
|
box.add(new St.Label({ text: "Rounded, framed, shadowed gradients" }));
|
|
|
|
|
|
|
|
let framedGradients = new St.BoxLayout({ vertical: false,
|
|
|
|
style: 'padding: 10px; spacing: 12px;' });
|
|
|
|
box.add(framedGradients);
|
|
|
|
|
|
|
|
function addGradientCase(direction, borderWidth, borderRadius, extra) {
|
|
|
|
let gradientBox = new St.BoxLayout({ style_class: 'background-gradient',
|
2011-01-24 21:11:40 +00:00
|
|
|
style: 'border: ' + borderWidth + 'px solid #8b0000;'
|
2011-01-05 15:08:50 +00:00
|
|
|
+ 'border-radius: ' + borderRadius + 'px;'
|
|
|
|
+ 'background-gradient-direction: ' + direction + ';'
|
|
|
|
+ 'width: 32px;'
|
|
|
|
+ 'height: 32px;'
|
|
|
|
+ extra });
|
|
|
|
framedGradients.add(gradientBox, { x_fill: false, y_fill: false } );
|
|
|
|
}
|
|
|
|
|
2011-01-13 23:27:24 +00:00
|
|
|
addGradientCase ('horizontal', 0, 5, 'box-shadow: 0px 0px 0px 0px rgba(0,0,0,0.5);');
|
|
|
|
addGradientCase ('horizontal', 2, 5, 'box-shadow: 0px 2px 0px 0px rgba(0,255,0,0.5);');
|
|
|
|
addGradientCase ('horizontal', 5, 2, 'box-shadow: 2px 0px 0px 0px rgba(0,0,255,0.5);');
|
|
|
|
addGradientCase ('horizontal', 5, 20, 'box-shadow: 0px 0px 4px 0px rgba(255,0,0,0.5);');
|
|
|
|
addGradientCase ('vertical', 0, 5, 'box-shadow: 0px 0px 0px 4px rgba(0,0,0,0.5);');
|
|
|
|
addGradientCase ('vertical', 2, 5, 'box-shadow: 0px 0px 4px 4px rgba(0,0,0,0.5);');
|
|
|
|
addGradientCase ('vertical', 5, 2, 'box-shadow: -2px -2px 6px 0px rgba(0,0,0,0.5);');
|
|
|
|
addGradientCase ('vertical', 5, 20, 'box-shadow: -2px -2px 0px 6px rgba(0,0,0,0.5);');
|
2011-01-05 15:08:50 +00:00
|
|
|
|
|
|
|
box.add(new St.Label({ text: "Rounded, framed, shadowed images" }));
|
|
|
|
|
|
|
|
let framedImages = new St.BoxLayout({ vertical: false,
|
|
|
|
style: 'padding: 10px; spacing: 6px;' });
|
|
|
|
box.add(framedImages);
|
|
|
|
|
|
|
|
function addBackgroundImageCase(borderWidth, borderRadius, width, height, extra) {
|
|
|
|
let imageBox = new St.BoxLayout({ style_class: 'background-image',
|
|
|
|
style: 'border: ' + borderWidth + 'px solid #8b8b8b;'
|
|
|
|
+ 'border-radius: ' + borderRadius + 'px;'
|
|
|
|
+ 'width: ' + width + 'px;'
|
|
|
|
+ 'height: ' + height + 'px;'
|
|
|
|
+ extra });
|
|
|
|
framedImages.add(imageBox, { x_fill: false, y_fill: false } );
|
|
|
|
}
|
|
|
|
|
|
|
|
addBackgroundImageCase (0, 0, 32, 32, 'background-position: 2px 5px');
|
2011-01-13 23:27:24 +00:00
|
|
|
addBackgroundImageCase (0, 0, 16, 16, '-st-background-image-shadow: 1px 1px 4px 0px rgba(0,0,0,0.5); background-color: rgba(0,0,0,0)');
|
|
|
|
addBackgroundImageCase (0, 5, 32, 32, '-st-background-image-shadow: 0px 0px 0px 0px rgba(0,0,0,0.5);');
|
|
|
|
addBackgroundImageCase (2, 5, 32, 32, '-st-background-image-shadow: 0px 2px 0px 0px rgba(0,255,0,0.5);');
|
|
|
|
addBackgroundImageCase (5, 2, 32, 32, '-st-background-image-shadow: 2px 0px 0px 0px rgba(0,0,255,0.5);');
|
|
|
|
addBackgroundImageCase (5, 20, 32, 32, '-st-background-image-shadow: 0px 0px 4px 0px rgba(255,0,0,0.5);');
|
|
|
|
addBackgroundImageCase (0, 5, 48, 48, '-st-background-image-shadow: 0px 0px 0px 4px rgba(0,0,0,0.5);');
|
|
|
|
addBackgroundImageCase (5, 5, 48, 48, '-st-background-image-shadow: 0px 0px 4px 4px rgba(0,0,0,0.5);');
|
|
|
|
addBackgroundImageCase (0, 5, 64, 64, '-st-background-image-shadow: -2px -2px 6px 0px rgba(0,0,0,0.5);');
|
|
|
|
addBackgroundImageCase (5, 5, 64, 64, '-st-background-image-shadow: -2px -2px 0px 6px rgba(0,0,0,0.5);');
|
2011-01-05 15:08:50 +00:00
|
|
|
addBackgroundImageCase (0, 5, 32, 32, 'background-position: 2px 5px');
|
|
|
|
|
2009-09-20 20:21:47 +00:00
|
|
|
stage.show();
|
|
|
|
Clutter.main();
|
|
|
|
stage.destroy();
|