@@ -41,7 +41,9 @@ use wry::webview::WebViewBuilderExtWindows;
4141
4242#[ cfg( target_os = "macos" ) ]
4343use tauri_utils:: TitleBarStyle ;
44- use tauri_utils:: { config:: WindowConfig , debug_eprintln, Theme } ;
44+ use tauri_utils:: {
45+ config:: WindowConfig , debug_eprintln, ProgressBarState , ProgressBarStatus , Theme ,
46+ } ;
4547use wry:: {
4648 application:: {
4749 dpi:: {
@@ -56,8 +58,9 @@ use wry::{
5658 } ,
5759 monitor:: MonitorHandle ,
5860 window:: {
59- CursorIcon as WryCursorIcon , Fullscreen , Icon as WryWindowIcon , Theme as WryTheme ,
60- UserAttentionType as WryUserAttentionType ,
61+ CursorIcon as WryCursorIcon , Fullscreen , Icon as WryWindowIcon ,
62+ ProgressBarState as WryProgressBarState , ProgressState as WryProgressState ,
63+ Theme as WryTheme , UserAttentionType as WryUserAttentionType ,
6164 } ,
6265 } ,
6366 webview:: { FileDropEvent as WryFileDropEvent , Url , WebContext , WebView , WebViewBuilder } ,
@@ -520,6 +523,35 @@ impl From<CursorIcon> for CursorIconWrapper {
520523 }
521524}
522525
526+ pub struct ProgressStateWrapper ( pub WryProgressState ) ;
527+
528+ impl From < ProgressBarStatus > for ProgressStateWrapper {
529+ fn from ( status : ProgressBarStatus ) -> Self {
530+ let state = match status {
531+ ProgressBarStatus :: None => WryProgressState :: None ,
532+ ProgressBarStatus :: Normal => WryProgressState :: Normal ,
533+ ProgressBarStatus :: Indeterminate => WryProgressState :: Indeterminate ,
534+ ProgressBarStatus :: Paused => WryProgressState :: Paused ,
535+ ProgressBarStatus :: Error => WryProgressState :: Error ,
536+ } ;
537+ Self ( state)
538+ }
539+ }
540+
541+ pub struct ProgressBarStateWrapper ( pub WryProgressBarState ) ;
542+
543+ impl From < ProgressBarState > for ProgressBarStateWrapper {
544+ fn from ( progress_state : ProgressBarState ) -> Self {
545+ Self ( WryProgressBarState {
546+ progress : progress_state. progress ,
547+ state : progress_state
548+ . status
549+ . map ( |state| ProgressStateWrapper :: from ( state) . 0 ) ,
550+ unity_uri : progress_state. unity_uri ,
551+ } )
552+ }
553+ }
554+
523555#[ derive( Clone , Default ) ]
524556pub struct WindowBuilderWrapper {
525557 inner : WryWindowBuilder ,
@@ -1006,6 +1038,7 @@ pub enum WindowMessage {
10061038 SetCursorIcon ( CursorIcon ) ,
10071039 SetCursorPosition ( Position ) ,
10081040 SetIgnoreCursorEvents ( bool ) ,
1041+ SetProgressBar ( ProgressBarState ) ,
10091042 DragWindow ,
10101043 RequestRedraw ,
10111044}
@@ -1520,6 +1553,16 @@ impl<T: UserEvent> Dispatch<T> for WryDispatcher<T> {
15201553 ) ,
15211554 )
15221555 }
1556+
1557+ fn set_progress_bar ( & self , progress_state : ProgressBarState ) -> Result < ( ) > {
1558+ send_user_message (
1559+ & self . context ,
1560+ Message :: Window (
1561+ self . window_id ,
1562+ WindowMessage :: SetProgressBar ( progress_state) ,
1563+ ) ,
1564+ )
1565+ }
15231566}
15241567
15251568#[ derive( Clone ) ]
@@ -2302,6 +2345,9 @@ fn handle_user_message<T: UserEvent>(
23022345 WindowMessage :: RequestRedraw => {
23032346 window. request_redraw ( ) ;
23042347 }
2348+ WindowMessage :: SetProgressBar ( progress_state) => {
2349+ window. set_progress_bar ( ProgressBarStateWrapper :: from ( progress_state) . 0 ) ;
2350+ }
23052351 }
23062352 }
23072353 }
0 commit comments