aboutsummaryrefslogtreecommitdiff
path: root/docs/notes/ui.lh
blob: 0c788dfe380d561c23e0e7f46bec196583126b6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227


namespace Display {
    
    typedef = private;
    
    (Display*) connect();
    (Display*) init_with_hooks(const Hooks* hooks);
    
    () close(Display*? this);
    
    (Status) set_ui_definition(Display* this, const UIDefinition *keep ui_def);
    
    /*
         TODO Each task will need some state, and the format of the state
         depends on the task type. I'm not sure if this is possible with
         the current type system (maybe with constraints). In most OO languages
         we could just use a virtual function (which is type safe, because only
         the constructor can assign it's address).
         
         Maybe it can be done with union types and constraints? The problem is
         that we must force the this pointer to be of a given type, even in
         places where the base type is used.
         
         
            typedef A = (
                // Restricted this pointer
                ()(A* this constraint(value^.f == f))* f,
            );
            
            typedef B = (
                // How to create a union of these?
                union (
                    A original_type, // FIXME need sth like constraint(original_type is a type of B),
                    (
                        // Is this type compatible (for all valid values)?
                        ()(B* this constraint(value^.f == f))* f,
                    ) overridden_type,
                ) base,
                
                byte[10] specific_data,
            );
         
         
    */
    () add_task(Display* this, Task* task);
    () remove_task(Display* this, Task* task);
    
    () queue_repaint(Display* this, Task* task);
    
    
    namespace Hooks {
        
        typedef = (
            // TODO
        );
        
    }
    
}

/*
    Overall structure:
    
    Static:
        
        Target:
    
    
    Dynamic:
        
        Task:   For example a document or a web page. Might be presented as a
                tab in a window.
        

    Examples:
    
        Web browser:
            
            target:
                commands/parameters (back, address bar, title),
                document (web page)
            
                status:
                    download progress
            
            task:
                web page
            
        Terminal:
        
            target:
                commands/parameters (copy&paste, reset, )
                console
                
                status:
                    more output, command finished
            
            task:
                shell
        
        E-mail client:
            
            target:
                commands/parameters (settings)
                subtasks: folder
            
            target (folder):
                commands/parameters (new e-mail)
                list of e-mails
                subtask: e-mail
                
                status:
                    new e-mails
            
            target (e-mail):
                commands/parameters (reply [if incoming], send [if new])
                text
                attachments
            
            tasks:
                folder
                e-mail
            
        IRC chat client:
        
            target:
                commands/parameters (settings)
                subtasks: channels
            
            target (channel):
                commands/parameters (kick, op, key exchange)
                conversation text
                user list
                
                status:
                    new messages, highlight messages
            
            tasks:
                channel

        GIMP Plugin:
        
            target:
                command/parameters (ok, cancel, each parameter)
                
            tasks:
                image
        
        Dialog box:
            
            target:
                command/parameters (yes, no, etc...)
                text
                
                status:
                    user input needed
            
            tasks:
                Depends. Could be a web page if the dialog box is created by a
                browser plugin.
 */


namespace UIDefinition {
    
    typedef = (
        count target_count;
        Target[target_count]* targets;
        
        // TODO application statuses
        // TODO definition of how task statuses should be merged?
    );
    
}

namespace View {
    
    typedef = (
        count command_count,
        Command[command_count]* commands,
        
        count target_count,
        Target[target_count]* targets,
        
        // TODO definitions of task statuses?
    );
    
}

namespace NestedViewTarget {
    
    typedef = (
        Target base constraint(value.type = NestedView);
        View *view;
    );
}

namespace CanvasTarget {
    
    typedef = (
        Target base constraint(value.type = Canvas);
        
        // Hooks
        (CanvasRequest)(const Task*? task)* on_task_available;
        ()(const Task* task, const PaintRequest *req)* on_paint_request;
    );
}


namespace Target {
    
    typedef Type = enum (NestedView, Canvas);
    
    typedef = (
        Type type
    );
    
}


namespace Task {
    
    typedef = (
    );
    
}