… | |
… | |
192 | 0 |
192 | 0 |
193 | }, |
193 | }, |
194 | ); |
194 | ); |
195 | |
195 | |
196 | $list->add (new CFPlus::UI::FancyFrame |
196 | $list->add (new CFPlus::UI::FancyFrame |
197 | label => "Bindings", |
197 | label => "Macros", |
198 | child => (my $macros = new CFPlus::UI::Table), |
198 | child => (my $macros = new CFPlus::UI::VBox), |
199 | ); |
199 | ); |
200 | |
200 | |
201 | my $refresh; |
201 | my $refresh; |
202 | |
202 | |
203 | my $tooltip_common = "\n\n<small>Left click - edit macro\nMiddle click - invoke macro\nRight click - further options</small>"; |
203 | my $tooltip_common = "\n\n<small>Left click - edit macro\nMiddle click - invoke macro\nRight click - further options</small>"; |
… | |
… | |
282 | } |
282 | } |
283 | }, |
283 | }, |
284 | ); |
284 | ); |
285 | }; |
285 | }; |
286 | |
286 | |
|
|
287 | $macros->add (new CFPlus::UI::Button |
|
|
288 | text => "New Macro", |
|
|
289 | tooltip => "Creates a new, empty, macro you can edit.", |
|
|
290 | on_activate => sub { |
|
|
291 | my $macro = { }; |
|
|
292 | push @{ $::PROFILE->{macro} }, $macro; |
|
|
293 | $edit_macro->($macro); |
|
|
294 | }, |
|
|
295 | ); |
|
|
296 | |
|
|
297 | $macros->add (my $macrolist = new CFPlus::UI::Table col_expand => [0, 1]); |
|
|
298 | |
287 | $REFRESH_MACRO_LIST = $refresh = sub { |
299 | $REFRESH_MACRO_LIST = $refresh = sub { |
288 | $macros->clear; |
300 | $macrolist->clear; |
289 | |
301 | |
290 | $macros->add (0, 0, new CFPlus::UI::Label |
302 | $macrolist->add (0, 1, new CFPlus::UI::Label |
291 | text => "Trigger", |
303 | text => "Trigger", |
292 | align => 0, |
304 | align => 0, |
293 | tooltip => $tooltip_trigger . $tooltip_common, |
305 | tooltip => $tooltip_trigger . $tooltip_common, |
294 | ); |
306 | ); |
295 | $macros->add (1, 0, new CFPlus::UI::Label |
307 | $macrolist->add (1, 1, new CFPlus::UI::Label |
296 | text => "Commands", |
308 | text => "Commands", |
297 | tooltip => $tooltip_commands . $tooltip_common, |
309 | tooltip => $tooltip_commands . $tooltip_common, |
298 | ); |
310 | ); |
299 | |
311 | |
300 | for my $idx (0 .. $#{$::PROFILE->{macro} || []}) { |
312 | for my $idx (0 .. $#{$::PROFILE->{macro} || []}) { |
301 | my $macro = $::PROFILE->{macro}[$idx]; |
313 | my $macro = $::PROFILE->{macro}[$idx]; |
302 | my $y = $idx + 1; |
314 | my $y = $idx + 2; |
303 | |
315 | |
304 | my $macro_cb = sub { |
316 | my $macro_cb = sub { |
305 | my ($widget, $ev) = @_; |
317 | my ($widget, $ev) = @_; |
306 | |
318 | |
307 | if ($ev->{button} == 1) { |
319 | if ($ev->{button} == 1) { |
… | |
… | |
325 | } |
337 | } |
326 | |
338 | |
327 | 1 |
339 | 1 |
328 | }; |
340 | }; |
329 | |
341 | |
330 | $macros->add (0, $y, new CFPlus::UI::Label |
342 | $macrolist->add (0, $y, new CFPlus::UI::Label |
331 | text => trigger_to_string $macro, |
343 | text => trigger_to_string $macro, |
332 | tooltip => $tooltip_trigger . $tooltip_common, |
344 | tooltip => $tooltip_trigger . $tooltip_common, |
333 | align => 0, |
345 | align => 0, |
334 | can_hover => 1, |
346 | can_hover => 1, |
335 | can_events => 1, |
347 | can_events => 1, |
336 | on_button_down => $macro_cb, |
348 | on_button_down => $macro_cb, |
337 | ); |
349 | ); |
338 | |
350 | |
339 | $macros->add (1, $y, new CFPlus::UI::Label |
351 | $macrolist->add (1, $y, new CFPlus::UI::Label |
340 | text => (join "; ", @{ $macro->{action} || [] }), |
352 | text => (join "; ", @{ $macro->{action} || [] }), |
341 | tooltip => $tooltip_commands . $tooltip_common, |
353 | tooltip => $tooltip_commands . $tooltip_common, |
342 | expand => 1, |
354 | expand => 1, |
343 | ellipsise => 3, |
355 | ellipsise => 3, |
344 | can_hover => 1, |
356 | can_hover => 1, |