File tree Expand file tree Collapse file tree 3 files changed +131
-2
lines changed
Expand file tree Collapse file tree 3 files changed +131
-2
lines changed Original file line number Diff line number Diff line change 55 .minimum_zig_version = "0.14.0" ,
66 .dependencies = .{
77 .webui = .{
8- .hash = "webui-2.5.0-beta.4-pxqD5WQONwB73V_0MKBVXgR7k6t6pb_B3KfAZqfbPf-7 " ,
9- .url = "https://github.com/webui-dev/webui/archive/3c03d4f45cf6e65e678b0ca87f8ec28d952b9d78 .tar.gz" ,
8+ .hash = "webui-2.5.0-beta.4-pxqD5YoPNwCJ9uGbFj8HOnmOUW6QgvHZtLqmpZN5kfmw " ,
9+ .url = "https://github.com/webui-dev/webui/archive/9dd20b5c98b53c1e03f94e80415ddfec5c37a1fa .tar.gz" ,
1010 },
1111 },
1212 .paths = .{
Original file line number Diff line number Diff line change 1+ < html >
2+ < head >
3+ < meta charset ="UTF-8 " />
4+ < script src ="webui.js "> </ script >
5+ < style >
6+ * {
7+ margin : 0 ;
8+ padding : 0 ;
9+ box-sizing : border-box;
10+ }
11+ html ,
12+ body {
13+ height : 100% ;
14+ width : 100% ;
15+ overflow : hidden;
16+ background : transparent;
17+ }
18+ # titlebar {
19+ height : 40px ;
20+ background : linear-gradient (to right, # 2c3e50, # 34495e );
21+ color : white;
22+ display : flex;
23+ align-items : center;
24+ justify-content : space-between;
25+ padding : 0 15px ;
26+ box-shadow : 0 2px 10px rgba (0 , 0 , 0 , 0.3 );
27+ -webkit-app-region : drag;
28+ font-family : Arial, sans-serif;
29+ }
30+ # title {
31+ font-size : 16px ;
32+ font-weight : bold;
33+ }
34+ # buttons {
35+ -webkit-app-region : no-drag;
36+ }
37+ .button {
38+ display : inline-block;
39+ width : 24px ;
40+ height : 24px ;
41+ margin-left : 8px ;
42+ border-radius : 50% ;
43+ text-align : center;
44+ line-height : 24px ;
45+ cursor : pointer;
46+ transition : all 0.2s ;
47+ }
48+ .minimize {
49+ background : # f1c40f ;
50+ }
51+ .maximize {
52+ background : # 2ecc71 ;
53+ }
54+ .close {
55+ background : # e74c3c ;
56+ }
57+ .button : hover {
58+ filter : brightness (120% );
59+ }
60+ # content {
61+ height : calc (100% - 40px );
62+ background : rgba (0 , 0 , 0 , 0.7 );
63+ display : flex;
64+ align-items : center;
65+ justify-content : center;
66+ }
67+ # message {
68+ color : white;
69+ font-size : 32px ;
70+ font-family : Arial, sans-serif;
71+ text-shadow : 2px 2px 4px rgba (0 , 0 , 0 , 0.3 );
72+ }
73+ </ style >
74+ </ head >
75+ < body >
76+ < div id ="titlebar ">
77+ < span id ="title "> WebUI Frameless Window</ span >
78+ < div id ="buttons ">
79+ < span class ="button minimize " onclick ="minimize() "> –</ span >
80+ < span class ="button close " onclick ="close_win() "> ✕</ span >
81+ </ div >
82+ </ div >
83+ < div id ="content ">
84+ < span id ="message "> This is a WebUI frameless example</ span >
85+ </ div >
86+ </ body >
87+ </ html >
Original file line number Diff line number Diff line change 1+ //! WebUI Zig - FrameLess Example
2+ //! Note: This example needs to be manually linked to webview_loader when running on Windows
3+ //! Without webview_loader, it will report that the window is not found and exit immediately
4+ const webui = @import ("webui" );
5+
6+ // we use @embedFile to embed html
7+ const html = @embedFile ("index.html" );
8+
9+ fn minimize (e : * webui.Event ) void {
10+ const win = e .getWindow ();
11+ win .minimize ();
12+ }
13+
14+ fn maximize (e : * webui.Event ) void {
15+ const win = e .getWindow ();
16+ win .maximize ();
17+ }
18+
19+ fn close (e : * webui.Event ) void {
20+ const win = e .getWindow ();
21+ win .close ();
22+ }
23+
24+ pub fn main () ! void {
25+ // create a new window
26+ var nwin = webui .newWindow ();
27+
28+ _ = nwin .bind ("minimize" , minimize );
29+ _ = nwin .bind ("maximize" , maximize );
30+ _ = nwin .bind ("close" , close );
31+
32+ nwin .setSize (800 , 600 );
33+ nwin .setFrameless (true );
34+ nwin .setTransparent (true );
35+ nwin .setResizable (true );
36+ nwin .setCenter ();
37+
38+ _ = nwin .showWv (html );
39+
40+ // wait the window exit
41+ webui .wait ();
42+ }
You can’t perform that action at this time.
0 commit comments