slint/examples/cpptest/hello.60
Simon Hausmann 251ef7fc97 Add support for SVG commands in Path elements
Using the commands property we can just paste SVG paths. This makes it
much easier to write examples/demos. A good online path designer is
for example https://codepen.io/anthonydugois/pen/mewdyZ
2020-07-09 13:41:57 +02:00

136 lines
2.7 KiB
Text

component TwoRectangle := Rectangle {
signal clicked;
Rectangle {
x: 50;
y: 50.;
width: 25;
height: 25;
color: red;
my_area := TouchArea {
width: 25;
height: 25;
clicked => { root.clicked() }
}
}
}
component ButtonRectangle := Rectangle {
property<string> button_text;
property<color> button_color;
signal clicked;
width: 100;
height: 75;
color: button_area.pressed ? red : button_color;
animate color { duration: 200; }
button_area := TouchArea {
width: root.width;
height: root.height;
clicked => { root.clicked() }
}
Text {
x: 50;
y: 10;
text: button_text;
color: black;
}
}
Hello := Rectangle {
signal foobar;
signal plus_clicked;
signal minus_clicked;
color: white;
property<color> top_color: #00f5;
for hello[idx] in [
{a: 3, color: #a55},
{a: 0, color: #aa5},
{a: 1, color: #a5a},
{a: 4, color: #55a}
]: Rectangle {
color: hello.color;
x: idx * 100;
y: hello.a * 100;
width: 75;
height: 75;
if (counter > 3) : Rectangle {
color: top_color;
width: 25;
height: 25;
x: 25;
y: 25;
}
}
TwoRectangle {
width: 100;
height: 100;
color: blue;
clicked => { foobar() }
}
Rectangle {
x: 100;
y: 100;
width: (100);
height: {100}
color: green;
Rectangle {
x: 50;
y: 50.;
width: 25;
height: 25;
color: yellow;
}
}
Image {
x: 200;
y: 200;
source: img!"../graphicstest/logo.png";
}
property<int32> counter;
Rectangle {
x: 50;
y: 225;
width: 100;
height: 225;
GridLayout {
Row {
ButtonRectangle {
button_color: #888;
clicked => { counter += 1 }
button_text: "+";
}
}
Row {
counter_label := Text { text: counter; color: black; }
}
Row {
ButtonRectangle {
button_color: #888;
clicked => { minus_clicked() }
button_text: "-";
}
}
}
}
Path {
commands: "M 100 300 Q 150 50 250 150 C 250 300 300 300 300 450 A 50 50 0 1 0 450 450 L 550 300";
x: 100;
y: 500;
stroke_color: black;
stroke_width: 2.0;
}
}