makepad_studio/
integration.rs

1
2use {
3    crate::{
4        //app::AppData,
5        makepad_widgets::*,
6    },
7    std::{
8        //fmt::Write,
9        env,
10    },
11};
12
13live_design!{
14    use makepad_draw::shader::std::*;
15    use makepad_widgets::base::*;
16    use makepad_widgets::theme_desktop_dark::*;
17    
18    Integration = {{Integration}}{
19        height: Fill, width: Fill
20        <View> {
21            width: Fill,
22            height: Fill,
23            flow: Down,
24            spacing: 10.0,
25    
26            github_token_input = <TextInput> {
27                width: Fill,
28                height: Fit,
29                margin: {left: 10.0, right: 10.0, top: 10.0},
30                empty_message: "Enter GitHub API Token",
31            }
32    
33            <View> {
34                width: Fill,
35                height: Fit,
36                flow: Right,
37                margin: {left: 10.0, right: 10.0},
38    
39                run_button = <Button> {
40                    text: "Run",
41                    width: Fit,
42                    height: Fit,
43                    margin: {right: 10.0},
44                }
45    
46                observe_checkbox = <CheckBox> {
47                    text: "Observe",
48                    width: Fit,
49                    height: Fit,
50                }
51            }
52    
53            output_log = <TextInput> {
54                width: Fill,
55                height: Fill,
56                margin: {left: 10.0, right: 10.0, bottom: 10.0},
57                empty_message: "Output Log",
58                multiline: true,
59                read_only: true,
60            }
61        }
62    }
63}
64
65
66#[derive(Live, LiveHook, Widget)]
67struct Integration{
68    #[deref] view:View,
69}
70
71impl WidgetMatchEvent for Integration {
72    fn handle_actions(&mut self, _cx: &mut Cx, actions: &Actions, _scope: &mut Scope){
73        if self.view.button(id!(run_button)).clicked(actions){
74            println!("run button clicked");
75            // Handle the run button click event
76            // You can add your custom code here to respond to the button click
77            // For example, you might initiate some process or update the UI
78        }
79    }
80}
81
82impl Widget for Integration {
83    fn draw_walk(&mut self, cx: &mut Cx2d, scope:&mut Scope, walk:Walk)->DrawStep{
84        self.view.draw_walk_all(cx, scope, walk);
85        DrawStep::done()
86    }
87    
88    fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope){
89        self.widget_match_event(cx, event, scope);
90        self.view.handle_event(cx, event, scope);
91    }
92}