Skip to content

Commit

Permalink
[*] update normally
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed Aug 29, 2024
1 parent bd993f4 commit 4b722c0
Show file tree
Hide file tree
Showing 10 changed files with 417 additions and 26 deletions.
6 changes: 4 additions & 2 deletions ui/base/drawer.slint
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export component Drawer inherits Rectangle {
in-out property <bool> is-show;
in property <length> drawer-size: 200px;
in property <DrawerPosition> position: DrawerPosition.Bottom;
in property <color> blanket-background: Theme.secondary-background;

public function show() {
root.is-show = true;
Expand Down Expand Up @@ -95,14 +96,15 @@ export component Drawer inherits Rectangle {
}

if root.is-show: Blanket {
background: root.blanket-background;
clicked => {
root.is-show = false;
}
}

VerticalLayout {
x: root.position == DrawerPosition.Right ? root.width - self.width : 0px;
y: root.position == DrawerPosition.Bottom ? root.height - self.height : 0px;
x: root.position == DrawerPosition.Right ? root.width -self.width : 0px;
y: root.position == DrawerPosition.Bottom ? root.height - self.height: 0px;
width: root.position == DrawerPosition.Right || root.position == DrawerPosition.Left ? drawer-size : root.width;
height: root.position == DrawerPosition.Top || root.position == DrawerPosition.Bottom ? drawer-size : root.height;

Expand Down
47 changes: 29 additions & 18 deletions ui/base/slide-card.slint
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,35 @@ import { Label } from "./label.slint";


// Example:
// SlideCard {
// background: blue;
// icons-background: white;
// icons: [
// {
// icon: Icons.delete,
// text: "Delete",
// colorize: Colors.red,
// },
// {
// icon: Icons.edit,
// text: "Edit",
// colorize: Colors.red,
// },
// ];
// Rectangle {
// height: 80px;
// background: pink;
// Rectangle {
// width: parent.width * 0.5;
// height: 80px;
// border-radius: Theme.border-radius;
// clip: true;

// SlideCard {
// icons-background: Theme.secondary-background;
// icons: [
// {
// icon: Icons.delete,
// text: "Delete",
// colorize: Colors.red,
// },
// {
// icon: Icons.edit,
// text: "Edit",
// colorize: Colors.blue,
// },
// ];

// Rectangle {
// height: 80px;
// background: pink;

// Label {
// text: Store.is-cn ? "向左侧滑动" : "Slide left to show icons";
// }
// }
// }
// }

Expand Down
3 changes: 3 additions & 0 deletions ui/base/slider.slint
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export component Slider inherits Rectangle {
}

ta := TouchArea {
mouse-cursor: root.indicator-size > 0 ? MouseCursor.default : MouseCursor.pointer;
clicked => {
fs.focus();

Expand Down Expand Up @@ -96,6 +97,8 @@ export component Slider inherits Rectangle {

indicator-ta := TouchArea {
enabled: root.enabled;
mouse-cursor: MouseCursor.pointer;

moved => {
if (root.orientation == Orientation.horizontal) {
parent.x = Math.clamp(parent.x + self.mouse-x - self.pressed-x, -parent.width / 2, root.width - parent.width / 2);
Expand Down
37 changes: 37 additions & 0 deletions ui/panel/desktop/examples/center-layout.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Util, Theme, Icons } from "../../def.slint";
import { CenterLayout, Avatar, ExampleComponent } from "../../../base/widgets.slint";

export component CenterLayoutExample inherits Flickable {
viewport-height: vbox.preferred-height;
viewport-width: vbox.preferred-width;

vbox := VerticalLayout {
spacing: Theme.spacing * 20;
padding-top: Theme.padding * 5;
padding-bottom: Theme.padding * 5;
alignment: LayoutAlignment.center;

HorizontalLayout {
width: root.width;
alignment: LayoutAlignment.center;

ExampleComponent {
width: Math.max(1000px, root.width * 0.8);

CenterLayout {
Avatar {
width: 200px;
background: Theme.secondary-background;
icon: Icons.account;
icon-size-rate: 0.6;

clicked => {
}
}
}

code: "CenterLayout {\n Avatar {\n width: 200px;\n background: Theme.secondary-background;\n icon: Icons.account;\n icon-size-rate: 0.6;\n\n clicked => {\n }\n }\n}";
}
}
}
}
181 changes: 181 additions & 0 deletions ui/panel/desktop/examples/drawer.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import { Util, Theme, Icons } from "../../def.slint";
import { Drawer, TextBtn, DrawerPosition, ExampleComponent } from "../../../base/widgets.slint";

export component DrawerExample inherits Flickable {
viewport-height: vbox.preferred-height;
viewport-width: vbox.preferred-width;

vbox := VerticalLayout {
spacing: Theme.spacing * 20;
padding-top: Theme.padding * 5;
padding-bottom: Theme.padding * 5;
alignment: LayoutAlignment.center;

HorizontalLayout {
width: root.width;
alignment: LayoutAlignment.center;

ExampleComponent {
width: Math.max(1000px, root.width * 0.8);

Rectangle {
clip: true;
background: Theme.secondary-background;
width: 800px;
height: 500px;
border-radius: Theme.border-radius;

drawer-top := Drawer {
width: 800px;
height: 500px;
drawer-size: 300px;
position: DrawerPosition.Top;
blanket-background: Colors.white;
Rectangle {
background: blue;
}
}

drawer-bottom := Drawer {
is-show: false;
drawer-size: 300px;
position: DrawerPosition.Bottom;
blanket-background: Colors.white;
Rectangle {
background: red;
}
}

drawer-left := Drawer {
is-show: false;
drawer-size: 300px;
position: DrawerPosition.Left;
blanket-background: Colors.white;
Rectangle {
background: yellow;
}
}

drawer-right := Drawer {
is-show: false;
drawer-size: 300px;
position: DrawerPosition.Right;
blanket-background: Colors.white;
Rectangle {
background: steelblue;
}
}

HorizontalLayout {
y: 0;
height: 50px;
spacing: 30px;
TextBtn {
text: "Show";
background: pink;
clicked => {
drawer-top.position = DrawerPosition.Top;
drawer-top.show();
}
}

TextBtn {
text: "Hide";
background: pink;
clicked => {
drawer-top.hide();
}
}
}

VerticalLayout {
alignment: LayoutAlignment.end;
HorizontalLayout {
height: 50px;
spacing: 30px;
TextBtn {
text: "Show";
background: pink;
clicked => {
drawer-bottom.position = DrawerPosition.Bottom;
drawer-bottom.show();
}
}

TextBtn {
text: "Hide";
background: pink;
clicked => {
drawer-bottom.hide();
}
}
}
}

HorizontalLayout {
alignment: start;
VerticalLayout {
width: 200px;
height: 500px;
padding-top: Theme.padding * 10;
padding-bottom: Theme.padding * 10;
alignment: LayoutAlignment.space-between;

TextBtn {
text: "Show";
text-color: white;
background: blue;
clicked => {
drawer-left.position = DrawerPosition.Left;
drawer-left.show();
}
}

TextBtn {
text: "Hide";
text-color: white;
background: blue;
clicked => {
drawer-left.hide();
}
}
}
}

HorizontalLayout {
alignment: end;

VerticalLayout {
width: 200px;
height: 500px;
padding-top: Theme.padding * 10;
padding-bottom: Theme.padding * 10;
alignment: LayoutAlignment.space-between;

TextBtn {
text: "Show";
text-color: white;
background: blue;
clicked => {
drawer-right.position = DrawerPosition.Right;
drawer-right.show();
}
}

TextBtn {
text: "Hide";
text-color: white;
background: blue;
clicked => {
drawer-right.hide();
}
}
}
}
}

code: "Rectangle {\n clip: true;\n background: Theme.secondary-background;\n width: 800px;\n height: 500px;\n border-radius: Theme.border-radius;\n\n drawer-top := Drawer {\n width: 800px;\n height: 500px;\n drawer-size: 300px;\n position: DrawerPosition.Top;\n blanket-background: Colors.white;\n Rectangle {\n background: blue;\n }\n }\n\n drawer-bottom := Drawer {\n is-show: false;\n drawer-size: 300px;\n position: DrawerPosition.Bottom;\n blanket-background: Colors.white;\n Rectangle {\n background: red;\n }\n }\n\n drawer-left := Drawer {\n is-show: false;\n drawer-size: 300px;\n position: DrawerPosition.Left;\n blanket-background: Colors.white;\n Rectangle {\n background: yellow;\n }\n }\n\n drawer-right := Drawer {\n is-show: false;\n drawer-size: 300px;\n position: DrawerPosition.Right;\n blanket-background: Colors.white;\n Rectangle {\n background: steelblue;\n }\n }\n\n HorizontalLayout {\n y: 0;\n height: 50px;\n spacing: 30px;\n TextBtn {\n text: \"Show\";\n background: pink;\n clicked => {\n drawer-top.position = DrawerPosition.Top;\n drawer-top.show();\n }\n }\n\n TextBtn {\n text: \"Hide\";\n background: pink;\n clicked => {\n drawer-top.hide();\n }\n }\n }\n\n VerticalLayout {\n alignment: LayoutAlignment.end;\n HorizontalLayout {\n height: 50px;\n spacing: 30px;\n TextBtn {\n text: \"Show\";\n background: pink;\n clicked => {\n drawer-bottom.position = DrawerPosition.Bottom;\n drawer-bottom.show();\n }\n }\n\n TextBtn {\n text: \"Hide\";\n background: pink;\n clicked => {\n drawer-bottom.hide();\n }\n }\n }\n }\n\n HorizontalLayout {\n alignment: start;\n VerticalLayout {\n width: 200px;\n height: 500px;\n padding-top: Theme.padding * 10;\n padding-bottom: Theme.padding * 10;\n alignment: LayoutAlignment.space-between;\n\n TextBtn {\n text: \"Show\";\n text-color: white;\n background: blue;\n clicked => {\n drawer-left.position = DrawerPosition.Left;\n drawer-left.show();\n }\n }\n\n TextBtn {\n text: \"Hide\";\n text-color: white;\n background: blue;\n clicked => {\n drawer-left.hide();\n }\n }\n }\n }\n\n HorizontalLayout {\n alignment: end;\n\n VerticalLayout {\n width: 200px;\n height: 500px;\n padding-top: Theme.padding * 10;\n padding-bottom: Theme.padding * 10;\n alignment: LayoutAlignment.space-between;\n\n TextBtn {\n text: \"Show\";\n text-color: white;\n background: blue;\n clicked => {\n drawer-right.position = DrawerPosition.Right;\n drawer-right.show();\n }\n }\n\n TextBtn {\n text: \"Hide\";\n text-color: white;\n background: blue;\n clicked => {\n drawer-right.hide();\n }\n }\n }\n }\n}";
}
}
}
}
42 changes: 42 additions & 0 deletions ui/panel/desktop/examples/list-tile.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Util, Theme, Icons } from "../../def.slint";
import { ListTile, ExampleComponent } from "../../../base/widgets.slint";

export component ListTileExample inherits Flickable {
viewport-height: vbox.preferred-height;
viewport-width: vbox.preferred-width;

vbox := VerticalLayout {
spacing: Theme.spacing * 20;
padding-top: Theme.padding * 5;
padding-bottom: Theme.padding * 5;
alignment: LayoutAlignment.center;

HorizontalLayout {
width: root.width;
alignment: LayoutAlignment.center;

ExampleComponent {
width: Math.max(1000px, root.width * 0.8);

ListTile {
width: parent.width * 0.5;
background: Theme.secondary-background;
border-radius: Theme.border-radius;
is-show-left-icon: true;
left-icon-size: 100px;
left-icon-background: Colors.transparent;
left-icon: Icons.account;

title-text: "IPhone Price";
subtitle-text: "$100";
middle-mouse-cursor: MouseCursor.pointer;

is-show-right-icon: true;
right-icon: Icons.delete;
}

code: "ListTile {\n width: parent.width * 0.5;\n background: Theme.secondary-background;\n border-radius: Theme.border-radius;\n is-show-left-icon: true;\n left-icon-size: 100px;\n left-icon-background: Colors.transparent;\n left-icon: Icons.account;\n\n title-text: \"IPhone Price\";\n subtitle-text: \"$100\";\n middle-mouse-cursor: MouseCursor.pointer;\n\n is-show-right-icon: true;\n right-icon: Icons.delete;\n}";
}
}
}
}
Loading

0 comments on commit 4b722c0

Please sign in to comment.