… | |
… | |
96 | }, |
96 | }, |
97 | ] |
97 | ] |
98 | EOF |
98 | EOF |
99 | die if $@; |
99 | die if $@; |
100 | |
100 | |
101 | sub demo_start { |
|
|
102 | my ($ns) = @_; |
|
|
103 | |
|
|
104 | my $ws = $ns->{csc} = $ns->new_widgetset; |
|
|
105 | |
|
|
106 | my ($tl, $entry) = $ws->template (inline => $cg_template, |
|
|
107 | [ |
|
|
108 | toplevel => {}, |
|
|
109 | entry => { |
|
|
110 | text => "xyz", |
|
|
111 | on_changed => sub { |
|
|
112 | warn "changed<@_>\n";#d# |
|
|
113 | }, |
|
|
114 | }, |
|
|
115 | ], |
|
|
116 | ); |
|
|
117 | |
|
|
118 | $tl->show; |
|
|
119 | |
|
|
120 | $ns->{xxxw} = [$tl, $entry];#d# |
|
|
121 | |
|
|
122 | # $ws->find ("setup_notebook")->add ($ws->{tab}); |
|
|
123 | # $ws->find ("setup_dialog")->toggle_visibility; |
|
|
124 | } |
|
|
125 | |
|
|
126 | sub csc_start { |
101 | sub csc_start { |
127 | my ($ns) = @_; |
102 | my ($ns) = @_; |
128 | |
103 | |
129 | my $ws = $ns->{csc} = $ns->new_widgetset; |
104 | my $ws = $ns->{csc} = $ns->new_widgetset; |
130 | |
105 | |
… | |
… | |
169 | |
144 | |
170 | csc_update_stats $ns; |
145 | csc_update_stats $ns; |
171 | |
146 | |
172 | $ws->{tl} = $w; |
147 | $ws->{tl} = $w; |
173 | $w->show; |
148 | $w->show; |
|
|
149 | |
|
|
150 | # my ($tl, $entry) = $ws->template (inline => $cg_template, |
|
|
151 | # [ |
|
|
152 | # toplevel => {}, |
|
|
153 | # entry => { |
|
|
154 | # text => "xyz", |
|
|
155 | # on_changed => sub { |
|
|
156 | # warn "changed<@_>\n";#d# |
|
|
157 | # }, |
|
|
158 | # }, |
|
|
159 | # ], |
|
|
160 | # ); |
|
|
161 | # |
|
|
162 | # $tl->show; |
|
|
163 | # |
|
|
164 | # $ns->{xxxw} = [$tl, $entry];#d# |
|
|
165 | # |
|
|
166 | # $ws->find ("setup_notebook")->add ($ws->{tab}); |
|
|
167 | # $ws->find ("setup_dialog")->toggle_visibility; |
174 | } |
168 | } |
175 | |
169 | |
176 | cf::player->attach ( |
170 | cf::player->attach ( |
177 | on_login => sub { |
171 | on_login => sub { |
178 | my ($pl) = @_; |
172 | my ($pl) = @_; |
179 | |
173 | |
|
|
174 | my $ns = $pl->ns; |
|
|
175 | return unless $ns->{can_widget}; |
|
|
176 | |
180 | return unless $cf::CFG{devel}; |
177 | return unless $cf::CFG{devel}; |
181 | |
178 | |
182 | my $ns = $pl->ns; |
|
|
183 | |
|
|
184 | return unless $ns->{can_widget}; |
|
|
185 | #csc_start $ns; |
179 | #csc_start $ns; |
186 | demo_start $ns; |
|
|
187 | }, |
180 | }, |
188 | ); |
181 | ); |
189 | |
182 | |
190 | cf::register_exticmd w_e => sub { |
183 | cf::register_exticmd w_e => sub { |
191 | my ($ns, $id, @args) = @_; |
184 | my ($ns, $id, @args) = @_; |
… | |
… | |
287 | |
280 | |
288 | sub template { |
281 | sub template { |
289 | my ($self, $type, $template, $args, $done_cb) = @_; |
282 | my ($self, $type, $template, $args, $done_cb) = @_; |
290 | |
283 | |
291 | my %cfg; |
284 | my %cfg; |
292 | my @res; |
|
|
293 | |
285 | |
294 | while (@$args) { |
286 | while (@$args) { |
295 | my ($name, $args) = splice @$args, 0, 2, (); |
287 | my ($name, $args) = splice @$args, 0, 2, (); |
296 | |
288 | |
297 | my $proxy = $self->alloc; |
289 | my $proxy = $self->alloc; |
|
|
290 | |
|
|
291 | $self->{delete $args->{alias} or $name} = $proxy; |
298 | |
292 | |
299 | Scalar::Util::weaken ($self->{_w}{$proxy->{id}} = $proxy); |
293 | Scalar::Util::weaken ($self->{_w}{$proxy->{id}} = $proxy); |
300 | Scalar::Util::weaken ($proxy->{ws} = $self); |
294 | Scalar::Util::weaken ($proxy->{ws} = $self); |
301 | |
295 | |
302 | for my $ev (grep /^on_/, keys %$args) { |
296 | for my $ev (grep /^on_/, keys %$args) { |
… | |
… | |
305 | |
299 | |
306 | $cfg{$name} = { |
300 | $cfg{$name} = { |
307 | %$args, |
301 | %$args, |
308 | id => $proxy->{id}, |
302 | id => $proxy->{id}, |
309 | }; |
303 | }; |
310 | |
|
|
311 | push @res, $proxy; |
|
|
312 | } |
304 | } |
313 | |
305 | |
314 | if ($done_cb) { |
306 | if ($done_cb) { |
315 | my $proxy = $self->alloc; |
307 | my $proxy = $self->alloc; |
316 | my $ocb = $done_cb; |
308 | my $ocb = $done_cb; |
… | |
… | |
319 | undef $done_cb; |
311 | undef $done_cb; |
320 | &$ocb |
312 | &$ocb |
321 | }); |
313 | }); |
322 | } |
314 | } |
323 | |
315 | |
|
|
316 | if ($type eq "face") { |
|
|
317 | $self->{ns}->send_face ($template, 100); |
|
|
318 | $self->{ns}->flush_fx; |
|
|
319 | } |
|
|
320 | |
324 | $self->msg (ws_ct => |
321 | $self->msg (ws_ct => |
325 | $self->{id}, |
322 | $self->{id}, |
326 | $type => $template, |
323 | $type => $template, |
327 | $done_cb, |
324 | $done_cb, |
328 | \%cfg, |
325 | \%cfg, |
329 | ); |
326 | ); |
330 | |
|
|
331 | @res |
|
|
332 | } |
327 | } |
333 | |
328 | |
334 | sub find { |
329 | sub find { |
335 | my ($self, @names) = @_; |
330 | my ($self, @names) = @_; |
336 | |
331 | |