makepad_widgets/
widget_match_event.rs

1
2use crate::*;
3
4pub trait WidgetMatchEvent{
5    fn handle_next_frame(&mut self, _cx: &mut Cx, _e:&NextFrameEvent, _scope: &mut Scope){}
6    fn handle_actions(&mut self, _cx: &mut Cx, _e:&Actions, _scope: &mut Scope){}
7    fn handle_signal(&mut self, _cx: &mut Cx, _scope: &mut Scope){}
8    fn handle_audio_devices(&mut self, _cx: &mut Cx, _e:&AudioDevicesEvent, _scope: &mut Scope){}
9    fn handle_midi_ports(&mut self, _cx: &mut Cx, _e:&MidiPortsEvent, _scope: &mut Scope){}
10    fn handle_video_inputs(&mut self, _cx: &mut Cx, _e:&VideoInputsEvent, _scope: &mut Scope){}
11    
12    fn handle_http_response(&mut self, _cx:&mut Cx, _request_id:LiveId, _response:&HttpResponse, _scope: &mut Scope){}
13    fn handle_http_request_error(&mut self, _cx:&mut Cx, _request_id:LiveId, _err:&HttpError, _scope: &mut Scope){}
14    fn handle_http_progress(&mut self, _cx:&mut Cx, _request_id:LiveId, _progress:&HttpProgress, _scope: &mut Scope){}
15    fn handle_http_stream(&mut self, _cx:&mut Cx, _request_id:LiveId, _data:&HttpResponse, _scope: &mut Scope){}
16    fn handle_http_stream_complete(&mut self, _cx:&mut Cx, _request_id:LiveId, _data:&HttpResponse, _scope: &mut Scope){}
17        
18    fn handle_network_responses(&mut self, cx: &mut Cx, e:&NetworkResponsesEvent, scope: &mut Scope){
19        for e in e{
20            match &e.response{
21                NetworkResponse::HttpRequestError(err)=>{
22                    self.handle_http_request_error(cx, e.request_id, err, scope);
23                }
24                NetworkResponse::HttpResponse(res)=>{
25                    self.handle_http_response(cx, e.request_id, res, scope);
26                }
27                NetworkResponse::HttpProgress(progress)=>{
28                    self.handle_http_progress(cx, e.request_id, progress, scope);
29                }
30                NetworkResponse::HttpStreamResponse(data)=>{
31                    self.handle_http_stream(cx, e.request_id, data, scope);
32                }
33                NetworkResponse::HttpStreamComplete(res)=>{
34                    self.handle_http_stream_complete(cx, e.request_id, res, scope);
35                }
36            }
37        }
38    }
39    
40    fn widget_match_event(&mut self, cx:&mut Cx, event:&Event, scope: &mut Scope){
41        match event{
42            Event::NextFrame(e)=>self.handle_next_frame(cx, e, scope),
43            Event::Actions(e)=>self.handle_actions(cx,e, scope),
44            Event::AudioDevices(e)=>self.handle_audio_devices(cx, e, scope),
45            Event::MidiPorts(e)=>self.handle_midi_ports(cx, e, scope),
46            Event::VideoInputs(e)=>self.handle_video_inputs(cx, e, scope),
47            Event::NetworkResponses(e)=>self.handle_network_responses(cx, e, scope),
48            _=>()
49        }
50    }
51}