forked from Surrealism-All/SurrealismUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1edc41a
commit a28293c
Showing
17 changed files
with
556 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Menu,MenuData } from "./menu.slint"; | ||
|
||
export { Menu as SURMenu,MenuData } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/** | ||
* ============================================ | ||
* @author:syf20020816@outlook.com | ||
* @since:20230930 | ||
* @version:0.1.5 | ||
* @type:interface | ||
* @description: | ||
* # SURMenu | ||
* SURMenu is a menu bar located on the left side that you can quickly generate through the menu-data property | ||
* ## properties | ||
* - in-out property <length> icon-box-size : menu item size ⛔ | ||
* - in-out property <length> icon-size : menu item icon size ⛔; | ||
* - in property <[MenuData]> menu-data : menu item data (generate menus through it) | ||
* - in-out property <int> active : which item is active | ||
* - private property <brush> hover-icon-color : menu item icon color changed when hover | ||
* ## callbacks | ||
* - callback change(int,MenuData) : run if you click menu item | ||
* - callback clicked-account() : run if you click account icon | ||
* - callback clicked-setting() : run if you click setting icon | ||
* ============================================ | ||
*/ | ||
import { SURCard } from "../card/index.slint"; | ||
import { SURIcon } from "../icon/index.slint"; | ||
import {IconSources,ROOT-STYLES,Themes} from "../../themes/index.slint"; | ||
import { SURTip } from "../tip/index.slint"; | ||
|
||
export struct MenuData { | ||
id:int, | ||
icon : image, | ||
name : string, | ||
} | ||
|
||
component MenuItem inherits Rectangle { | ||
in property <brush> hover-icon-color; | ||
in property <image> icon; | ||
in property <length> icon-size; | ||
in property <Themes> theme; | ||
in property <bool> active; | ||
out property <bool> has-hover <=> area.has-hover; | ||
states [ | ||
hover when area.has-hover:{icon.icon-color : hover-icon-color;} | ||
] | ||
callback clicked(); | ||
|
||
area:=TouchArea { | ||
mouse-cursor: pointer; | ||
z: 116; | ||
clicked => { | ||
root.clicked(); | ||
} | ||
} | ||
if active:SURCard { | ||
x: 0; | ||
height: root.height; | ||
width: 2px; | ||
theme: root.theme; | ||
border: None; | ||
border-radius: 0; | ||
background: ROOT-STYLES.radio-active; | ||
drop-shadow-blur: 0; | ||
drop-shadow-color: ROOT-STYLES.radio-active; | ||
drop-shadow-offset-x: 0; | ||
drop-shadow-offset-y: 0; | ||
} | ||
icon:=SURIcon { | ||
theme: root.theme; | ||
height:root.icon-size; | ||
width: root.icon-size; | ||
icon: root.icon; | ||
} | ||
} | ||
|
||
export component Menu inherits SURCard { | ||
height: 100%; | ||
width: 60px; | ||
border-radius: 0; | ||
|
||
in-out property <length> icon-box-size : 60px; | ||
in-out property <length> icon-size : ROOT-STYLES.sur-font.font-size * 2 ; | ||
in property <[MenuData]> menu-data : [ | ||
{id:0,icon:@image-url("../../icons/file-code.svg"),name:"Code"}, | ||
{id:1,icon:@image-url("../../icons/search.svg"),name:"Search"}, | ||
{id:2,icon:@image-url("../../icons/bug.svg"),name:"Debug"}, | ||
]; | ||
in-out property <int> active : 0; | ||
private property <brush> hover-icon-color : empty.icon-color.brighter(1); | ||
// params : | ||
// 1. index | ||
// 2. menu item | ||
callback change(int,MenuData); | ||
callback clicked-account(); | ||
callback clicked-setting(); | ||
VerticalLayout { | ||
top-view:=VerticalLayout { | ||
height: parent.height - bottom-view.height; | ||
alignment: start; | ||
for item[index] in menu-data: SURTip { | ||
height: menu-item.height; | ||
width: icon-box-size; | ||
content: item.name; | ||
theme: root.theme; | ||
pos: Right; | ||
show-tip : menu-item.has-hover; | ||
menu-item:=MenuItem{ | ||
active: item.id == root.active; | ||
height: icon-box-size; | ||
icon: item.icon; | ||
icon-size: root.icon-size; | ||
theme: root.theme; | ||
clicked => { | ||
root.active = item.id; | ||
root.change(index,item); | ||
} | ||
} | ||
} | ||
} | ||
bottom-view:=VerticalLayout{ | ||
height:empty-box.height + 120px ; | ||
empty-box:=Rectangle{ | ||
height: icon-size * 2; | ||
empty:=SURIcon{ | ||
theme: root.theme; | ||
icon: IconSources.icons.Null; | ||
} | ||
} | ||
account-box:=MenuItem{ | ||
height: icon-box-size; | ||
icon: IconSources.icons.Avatar; | ||
icon-size: root.icon-size; | ||
theme: root.theme; | ||
clicked => { | ||
root.clicked-account(); | ||
} | ||
} | ||
setting-box:=MenuItem{ | ||
height: icon-box-size; | ||
icon: IconSources.icons.Setting-two; | ||
icon-size: root.icon-size; | ||
theme: root.theme; | ||
clicked => { | ||
root.clicked-setting(); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { Tip } from "./tip.slint"; | ||
import { Tip,TipPosition } from "./tip.slint"; | ||
|
||
export { Tip as SURTip } | ||
export { Tip as SURTip,TipPosition } |
Oops, something went wrong.