mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-03 15:14:35 +00:00
Get signals and toucharea working on the rust example
This commit is contained in:
parent
905f6c7b15
commit
e34ac8c3f4
3 changed files with 104 additions and 30 deletions
|
@ -1,35 +1,102 @@
|
|||
// Using a macro for now. But there could be others ways to do that
|
||||
sixtyfps::sixtyfps! {
|
||||
SuperSimple := Rectangle {
|
||||
color: white;
|
||||
|
||||
Rectangle {
|
||||
width: 100;
|
||||
height: 100;
|
||||
color: blue;
|
||||
}
|
||||
Rectangle {
|
||||
x: 100;
|
||||
y: 100;
|
||||
width: (100);
|
||||
height: {100}
|
||||
color: green;
|
||||
}
|
||||
Image {
|
||||
x: 200;
|
||||
y: 200;
|
||||
source: img!"../graphicstest/logo.png";
|
||||
component TwoRectangle := Rectangle {
|
||||
|
||||
signal clicked;
|
||||
|
||||
Rectangle {
|
||||
x: 50;
|
||||
y: 50.;
|
||||
width: 25;
|
||||
height: 25;
|
||||
color: red;
|
||||
|
||||
my_area := TouchArea {
|
||||
width: 25;
|
||||
height: 25;
|
||||
clicked => { clicked }
|
||||
}
|
||||
|
||||
Text {
|
||||
x: 200;
|
||||
y: 400;
|
||||
text: "Hello World";
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
SuperSimple::default().run();
|
||||
|
||||
component ButtonRectangle := Rectangle {
|
||||
signal clicked;
|
||||
width: 100;
|
||||
height: 75;
|
||||
TouchArea {
|
||||
width: 100;
|
||||
height: 75;
|
||||
clicked => { clicked }
|
||||
}
|
||||
}
|
||||
|
||||
Hello := Rectangle {
|
||||
|
||||
signal foobar;
|
||||
signal plus_clicked;
|
||||
signal minus_clicked;
|
||||
|
||||
color: white;
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
ButtonRectangle {
|
||||
color: 4289374890;
|
||||
x: 50;
|
||||
y: 225;
|
||||
clicked => { plus_clicked }
|
||||
Text {
|
||||
x: 50;
|
||||
y: 10;
|
||||
text: "+";
|
||||
color: black;
|
||||
}
|
||||
}
|
||||
counter := Text { x: 100; y: 300; text: "0"; color: black; }
|
||||
ButtonRectangle {
|
||||
color: 4289374890;
|
||||
x: 50;
|
||||
y: 350;
|
||||
clicked => { minus_clicked }
|
||||
Text {
|
||||
x: 50;
|
||||
y: 10;
|
||||
text: "-";
|
||||
color: black;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn main() {
|
||||
Hello::default().run();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue