1 | package CFPlus::UI; |
1 | package DC::UI; |
2 | |
2 | |
3 | use utf8; |
3 | use utf8; |
4 | use strict; |
4 | use strict; |
5 | |
5 | |
6 | use List::Util (); |
6 | use List::Util (); |
7 | use Event; |
|
|
8 | |
7 | |
9 | use CFPlus; |
8 | use DC; |
10 | use CFPlus::Pod; |
9 | use DC::Pod; |
11 | use CFPlus::Texture; |
10 | use DC::Texture; |
12 | |
11 | |
13 | our ($FOCUS, $HOVER, $GRAB); # various widgets |
12 | our ($FOCUS, $HOVER, $GRAB); # various widgets |
14 | |
13 | |
15 | our $LAYOUT; |
14 | our $LAYOUT; |
16 | our $ROOT; |
15 | our $ROOT; |
17 | our $TOOLTIP; |
16 | our $TOOLTIP; |
18 | our $BUTTON_STATE; |
17 | our $BUTTON_STATE; |
19 | |
18 | |
20 | our %WIDGET; # all widgets, weak-referenced |
19 | our %WIDGET; # all widgets, weak-referenced |
21 | |
20 | |
22 | our $TOOLTIP_WATCHER = Event->idle (min => 1/60, cb => sub { |
21 | our $TOOLTIP_WATCHER = EV::timer_ns 0, 0.03, sub { |
|
|
22 | $_[0]->stop; |
|
|
23 | |
23 | if (!$GRAB) { |
24 | if (!$GRAB) { |
24 | for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { |
25 | for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { |
25 | if (length $widget->{tooltip}) { |
26 | if (length $widget->{tooltip}) { |
26 | if ($TOOLTIP->{owner} != $widget) { |
27 | if ($TOOLTIP->{owner} != $widget) { |
27 | $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner}; |
28 | $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner}; |
… | |
… | |
30 | $TOOLTIP->{owner} = $widget; |
31 | $TOOLTIP->{owner} = $widget; |
31 | $TOOLTIP->{owner}->emit ("tooltip_show") if $TOOLTIP->{owner}; |
32 | $TOOLTIP->{owner}->emit ("tooltip_show") if $TOOLTIP->{owner}; |
32 | |
33 | |
33 | return if $ENV{CFPLUS_DEBUG} & 8; |
34 | return if $ENV{CFPLUS_DEBUG} & 8; |
34 | |
35 | |
35 | my $tip = $widget->{tooltip}; |
|
|
36 | |
|
|
37 | $tip = $tip->($widget) if CODE:: eq ref $tip; |
|
|
38 | |
|
|
39 | $TOOLTIP->set_tooltip_from ($widget); |
36 | $TOOLTIP->set_tooltip_from ($widget); |
40 | $TOOLTIP->show; |
37 | $TOOLTIP->show; |
41 | } |
38 | } |
42 | |
39 | |
43 | return; |
40 | return; |
… | |
… | |
46 | } |
43 | } |
47 | |
44 | |
48 | $TOOLTIP->hide; |
45 | $TOOLTIP->hide; |
49 | $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner}; |
46 | $TOOLTIP->{owner}->emit ("tooltip_hide") if $TOOLTIP->{owner}; |
50 | delete $TOOLTIP->{owner}; |
47 | delete $TOOLTIP->{owner}; |
51 | }); |
48 | }; |
52 | |
49 | |
53 | sub get_layout { |
50 | sub get_layout { |
54 | my $layout; |
51 | my $layout; |
55 | |
52 | |
56 | for (grep { $_->{name} } values %WIDGET) { |
53 | for (grep { $_->{name} } values %WIDGET) { |
… | |
… | |
91 | my $hover = $HOVER; $HOVER = $widget; |
88 | my $hover = $HOVER; $HOVER = $widget; |
92 | |
89 | |
93 | $hover->update if $hover && $hover->{can_hover}; |
90 | $hover->update if $hover && $hover->{can_hover}; |
94 | $HOVER->update if $HOVER && $HOVER->{can_hover}; |
91 | $HOVER->update if $HOVER && $HOVER->{can_hover}; |
95 | |
92 | |
96 | $TOOLTIP_WATCHER->start; |
93 | $TOOLTIP_WATCHER->again; |
97 | } |
94 | } |
98 | } |
95 | } |
99 | |
96 | |
100 | sub feed_sdl_button_down_event { |
97 | sub feed_sdl_button_down_event { |
101 | my ($ev) = @_; |
98 | my ($ev) = @_; |
… | |
… | |
107 | my $widget = $ROOT->find_widget ($x, $y); |
104 | my $widget = $ROOT->find_widget ($x, $y); |
108 | |
105 | |
109 | $GRAB = $widget; |
106 | $GRAB = $widget; |
110 | $GRAB->update if $GRAB; |
107 | $GRAB->update if $GRAB; |
111 | |
108 | |
112 | $TOOLTIP_WATCHER->cb->(); |
109 | $TOOLTIP_WATCHER->invoke; |
113 | } |
110 | } |
114 | |
111 | |
115 | if ($GRAB) { |
112 | if ($GRAB) { |
116 | if ($ev->{button} == 4 || $ev->{button} == 5) { |
113 | if ($ev->{button} == 4 || $ev->{button} == 5) { |
117 | # mousewheel |
114 | # mousewheel |
118 | my $delta = $ev->{button} * 2 - 9; |
115 | my $delta = $ev->{button} * 2 - 9; |
119 | my $shift = $ev->{mod} & CFPlus::KMOD_SHIFT; |
116 | my $shift = $ev->{mod} & DC::KMOD_SHIFT; |
120 | |
117 | |
121 | $ev->{dx} = $shift ? $delta : 0; |
118 | $ev->{dx} = $shift ? $delta : 0; |
122 | $ev->{dy} = $shift ? 0 : $delta; |
119 | $ev->{dy} = $shift ? 0 : $delta; |
123 | |
120 | |
124 | $GRAB->emit (mouse_wheel => $ev); |
121 | $GRAB->emit (mouse_wheel => $ev); |
… | |
… | |
142 | my $grab = $GRAB; undef $GRAB; |
139 | my $grab = $GRAB; undef $GRAB; |
143 | $grab->update if $grab; |
140 | $grab->update if $grab; |
144 | $GRAB->update if $GRAB; |
141 | $GRAB->update if $GRAB; |
145 | |
142 | |
146 | check_hover $widget; |
143 | check_hover $widget; |
147 | $TOOLTIP_WATCHER->cb->(); |
144 | $TOOLTIP_WATCHER->invoke; |
148 | } |
145 | } |
149 | } |
146 | } |
150 | |
147 | |
151 | sub feed_sdl_motion_event { |
148 | sub feed_sdl_motion_event { |
152 | my ($ev) = @_; |
149 | my ($ev) = @_; |
… | |
… | |
214 | reconfigure_widgets; |
211 | reconfigure_widgets; |
215 | } |
212 | } |
216 | |
213 | |
217 | ############################################################################# |
214 | ############################################################################# |
218 | |
215 | |
219 | package CFPlus::UI::Event; |
216 | package DC::UI::Event; |
220 | |
217 | |
221 | sub xy { |
218 | sub xy { |
222 | $_[1]->coord2local ($_[0]{x}, $_[0]{y}) |
219 | $_[1]->coord2local ($_[0]{x}, $_[0]{y}) |
223 | } |
220 | } |
224 | |
221 | |
225 | ############################################################################# |
222 | ############################################################################# |
226 | |
223 | |
227 | package CFPlus::UI::Base; |
224 | package DC::UI::Base; |
228 | |
225 | |
229 | use strict; |
226 | use strict; |
230 | |
227 | |
231 | use CFPlus::OpenGL; |
228 | use DC::OpenGL; |
232 | |
229 | |
233 | sub new { |
230 | sub new { |
234 | my $class = shift; |
231 | my $class = shift; |
235 | |
232 | |
236 | my $self = bless { |
233 | my $self = bless { |
… | |
… | |
241 | h => undef, |
238 | h => undef, |
242 | can_events => 1, |
239 | can_events => 1, |
243 | @_ |
240 | @_ |
244 | }, $class; |
241 | }, $class; |
245 | |
242 | |
246 | CFPlus::weaken ($CFPlus::UI::WIDGET{$self+0} = $self); |
243 | DC::weaken ($DC::UI::WIDGET{$self+0} = $self); |
247 | |
244 | |
248 | for (keys %$self) { |
245 | for (keys %$self) { |
249 | if (/^on_(.*)$/) { |
246 | if (/^on_(.*)$/) { |
250 | $self->connect ($1 => delete $self->{$_}); |
247 | $self->connect ($1 => delete $self->{$_}); |
251 | } |
248 | } |
252 | } |
249 | } |
253 | |
250 | |
254 | if (my $layout = $CFPlus::UI::LAYOUT->{$self->{name}}) { |
251 | if (my $layout = $DC::UI::LAYOUT->{$self->{name}}) { |
255 | $self->{x} = $layout->{x} * $CFPlus::UI::ROOT->{alloc_w} if exists $layout->{x}; |
252 | $self->{x} = $layout->{x} * $DC::UI::ROOT->{alloc_w} if exists $layout->{x}; |
256 | $self->{y} = $layout->{y} * $CFPlus::UI::ROOT->{alloc_h} if exists $layout->{y}; |
253 | $self->{y} = $layout->{y} * $DC::UI::ROOT->{alloc_h} if exists $layout->{y}; |
257 | $self->{force_w} = $layout->{w} * $CFPlus::UI::ROOT->{alloc_w} if exists $layout->{w}; |
254 | $self->{force_w} = $layout->{w} * $DC::UI::ROOT->{alloc_w} if exists $layout->{w}; |
258 | $self->{force_h} = $layout->{h} * $CFPlus::UI::ROOT->{alloc_h} if exists $layout->{h}; |
255 | $self->{force_h} = $layout->{h} * $DC::UI::ROOT->{alloc_h} if exists $layout->{h}; |
259 | |
256 | |
260 | $self->{x} -= $self->{force_w} * 0.5 if exists $layout->{x}; |
257 | $self->{x} -= $self->{force_w} * 0.5 if exists $layout->{x}; |
261 | $self->{y} -= $self->{force_h} * 0.5 if exists $layout->{y}; |
258 | $self->{y} -= $self->{force_h} * 0.5 if exists $layout->{y}; |
262 | |
259 | |
263 | $self->show if $layout->{show}; |
260 | $self->show if $layout->{show}; |
… | |
… | |
273 | $self->emit ("destroy"); |
270 | $self->emit ("destroy"); |
274 | %$self = (); |
271 | %$self = (); |
275 | } |
272 | } |
276 | |
273 | |
277 | sub TO_JSON { |
274 | sub TO_JSON { |
278 | { __w_ => $_[0]{s_id} } |
275 | { "\fw" => $_[0]{s_id} } |
279 | } |
276 | } |
280 | |
277 | |
281 | sub show { |
278 | sub show { |
282 | my ($self) = @_; |
279 | my ($self) = @_; |
283 | |
280 | |
284 | return if $self->{parent}; |
281 | return if $self->{parent}; |
285 | |
282 | |
286 | $CFPlus::UI::ROOT->add ($self); |
283 | $DC::UI::ROOT->add ($self); |
287 | } |
284 | } |
288 | |
285 | |
289 | sub set_visible { |
286 | sub set_visible { |
290 | my ($self) = @_; |
287 | my ($self) = @_; |
291 | |
288 | |
… | |
… | |
312 | delete $self->{root}; |
309 | delete $self->{root}; |
313 | |
310 | |
314 | undef $GRAB if $GRAB == $self; |
311 | undef $GRAB if $GRAB == $self; |
315 | undef $HOVER if $HOVER == $self; |
312 | undef $HOVER if $HOVER == $self; |
316 | |
313 | |
317 | $CFPlus::UI::TOOLTIP_WATCHER->cb->() |
314 | $DC::UI::TOOLTIP_WATCHER->invoke |
318 | if $TOOLTIP->{owner} == $self; |
315 | if $TOOLTIP->{owner} == $self; |
319 | |
316 | |
320 | $self->emit ("focus_out"); |
317 | $self->emit ("focus_out"); |
321 | $self->emit (visibility_change => 0); |
318 | $self->emit (visibility_change => 0); |
322 | } |
319 | } |
… | |
… | |
341 | sub hide { |
338 | sub hide { |
342 | my ($self) = @_; |
339 | my ($self) = @_; |
343 | |
340 | |
344 | $self->set_invisible; |
341 | $self->set_invisible; |
345 | |
342 | |
|
|
343 | # extra $parent copy for 5.8.8+ bug workaround |
|
|
344 | # (otherwise $_[0] in remove gets freed |
|
|
345 | if (my $parent = $self->{parent}) { |
346 | $self->{parent}->remove ($self) |
346 | $parent->remove ($self); |
347 | if $self->{parent}; |
347 | } |
348 | } |
348 | } |
349 | |
349 | |
350 | sub move_abs { |
350 | sub move_abs { |
351 | my ($self, $x, $y, $z) = @_; |
351 | my ($self, $x, $y, $z) = @_; |
352 | |
352 | |
… | |
… | |
364 | $self->{force_h} = $h; |
364 | $self->{force_h} = $h; |
365 | |
365 | |
366 | $self->realloc; |
366 | $self->realloc; |
367 | } |
367 | } |
368 | |
368 | |
|
|
369 | # traverse the widget chain up to find the maximum "physical" size constraints |
|
|
370 | sub get_max_wh { |
|
|
371 | my ($self) = @_; |
|
|
372 | |
|
|
373 | return $self->{parent}->get_max_wh |
|
|
374 | if $self->{parent}; |
|
|
375 | |
|
|
376 | ($::WIDTH, $::HEIGHT) |
|
|
377 | } |
|
|
378 | |
369 | sub size_request { |
379 | sub size_request { |
370 | require Carp; |
380 | require Carp; |
371 | Carp::confess "size_request is abstract"; |
381 | Carp::confess "size_request is abstract"; |
372 | } |
382 | } |
373 | |
383 | |
… | |
… | |
379 | my ($self, $x, $y, $w, $h) = @_; |
389 | my ($self, $x, $y, $w, $h) = @_; |
380 | |
390 | |
381 | if ($self->{aspect}) { |
391 | if ($self->{aspect}) { |
382 | my ($ow, $oh) = ($w, $h); |
392 | my ($ow, $oh) = ($w, $h); |
383 | |
393 | |
384 | $w = List::Util::min $w, CFPlus::ceil $h * $self->{aspect}; |
394 | $w = List::Util::min $w, DC::ceil $h * $self->{aspect}; |
385 | $h = List::Util::min $h, CFPlus::ceil $w / $self->{aspect}; |
395 | $h = List::Util::min $h, DC::ceil $w / $self->{aspect}; |
386 | |
396 | |
387 | # use alignment to adjust x, y |
397 | # use alignment to adjust x, y |
388 | |
398 | |
389 | $x += int 0.5 * ($ow - $w); |
399 | $x += int 0.5 * ($ow - $w); |
390 | $y += int 0.5 * ($oh - $h); |
400 | $y += int 0.5 * ($oh - $h); |
… | |
… | |
431 | |
441 | |
432 | return if $self->{tooltip} eq $tooltip; |
442 | return if $self->{tooltip} eq $tooltip; |
433 | |
443 | |
434 | $self->{tooltip} = $tooltip; |
444 | $self->{tooltip} = $tooltip; |
435 | |
445 | |
436 | if ($CFPlus::UI::TOOLTIP->{owner} == $self) { |
446 | if ($DC::UI::TOOLTIP->{owner} == $self) { |
437 | delete $CFPlus::UI::TOOLTIP->{owner}; |
447 | delete $DC::UI::TOOLTIP->{owner}; |
438 | $CFPlus::UI::TOOLTIP_WATCHER->cb->(); |
448 | $DC::UI::TOOLTIP_WATCHER->invoke; |
439 | } |
449 | } |
440 | } |
450 | } |
441 | |
451 | |
442 | # translate global coordinates to local coordinate system |
452 | # translate global coordinates to local coordinate system |
443 | sub coord2local { |
453 | sub coord2local { |
444 | my ($self, $x, $y) = @_; |
454 | my ($self, $x, $y) = @_; |
445 | |
455 | |
446 | Carp::confess unless $self->{parent};#d# |
456 | return (undef, undef) unless $self->{parent}; |
447 | |
457 | |
448 | $self->{parent}->coord2local ($x - $self->{x}, $y - $self->{y}) |
458 | $self->{parent}->coord2local ($x - $self->{x}, $y - $self->{y}) |
449 | } |
459 | } |
450 | |
460 | |
451 | # translate local coordinates to global coordinate system |
461 | # translate local coordinates to global coordinate system |
452 | sub coord2global { |
462 | sub coord2global { |
453 | my ($self, $x, $y) = @_; |
463 | my ($self, $x, $y) = @_; |
454 | |
464 | |
455 | Carp::confess unless $self->{parent};#d# |
465 | return (undef, undef) unless $self->{parent}; |
456 | |
466 | |
457 | $self->{parent}->coord2global ($x + $self->{x}, $y + $self->{y}) |
467 | $self->{parent}->coord2global ($x + $self->{x}, $y + $self->{y}) |
458 | } |
468 | } |
459 | |
469 | |
460 | sub invoke_focus_in { |
470 | sub invoke_focus_in { |
… | |
… | |
509 | sub connect { |
519 | sub connect { |
510 | my ($self, $signal, $cb) = @_; |
520 | my ($self, $signal, $cb) = @_; |
511 | |
521 | |
512 | push @{ $self->{signal_cb}{$signal} }, $cb; |
522 | push @{ $self->{signal_cb}{$signal} }, $cb; |
513 | |
523 | |
514 | defined wantarray and CFPlus::guard { |
524 | defined wantarray and DC::guard { |
515 | @{ $self->{signal_cb}{$signal} } = grep $_ != $cb, |
525 | @{ $self->{signal_cb}{$signal} } = grep $_ != $cb, |
516 | @{ $self->{signal_cb}{$signal} }; |
526 | @{ $self->{signal_cb}{$signal} }; |
517 | } |
527 | } |
518 | } |
528 | } |
519 | |
529 | |
… | |
… | |
557 | # in .xs |
567 | # in .xs |
558 | |
568 | |
559 | sub set_parent { |
569 | sub set_parent { |
560 | my ($self, $parent) = @_; |
570 | my ($self, $parent) = @_; |
561 | |
571 | |
562 | CFPlus::weaken ($self->{parent} = $parent); |
572 | DC::weaken ($self->{parent} = $parent); |
563 | $self->set_visible if $parent->{visible}; |
573 | $self->set_visible if $parent->{visible}; |
564 | } |
574 | } |
565 | |
575 | |
566 | sub realloc { |
576 | sub realloc { |
567 | my ($self) = @_; |
577 | my ($self) = @_; |
… | |
… | |
605 | } |
615 | } |
606 | |
616 | |
607 | sub DESTROY { |
617 | sub DESTROY { |
608 | my ($self) = @_; |
618 | my ($self) = @_; |
609 | |
619 | |
610 | return if CFPlus::in_destruct; |
620 | return if DC::in_destruct; |
611 | |
621 | |
612 | local $@; |
622 | local $@; |
613 | eval { $self->destroy }; |
623 | eval { $self->destroy }; |
614 | warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; |
624 | warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; |
615 | |
625 | |
616 | delete $WIDGET{$self+0}; |
626 | delete $WIDGET{$self+0}; |
617 | } |
627 | } |
618 | |
628 | |
619 | ############################################################################# |
629 | ############################################################################# |
620 | |
630 | |
621 | package CFPlus::UI::DrawBG; |
631 | package DC::UI::DrawBG; |
622 | |
632 | |
623 | our @ISA = CFPlus::UI::Base::; |
633 | our @ISA = DC::UI::Base::; |
624 | |
634 | |
625 | use strict; |
635 | use strict; |
626 | use CFPlus::OpenGL; |
636 | use DC::OpenGL; |
627 | |
637 | |
628 | sub new { |
638 | sub new { |
629 | my $class = shift; |
639 | my $class = shift; |
630 | |
640 | |
631 | $class->SUPER::new ( |
641 | $class->SUPER::new ( |
… | |
… | |
653 | } |
663 | } |
654 | } |
664 | } |
655 | |
665 | |
656 | ############################################################################# |
666 | ############################################################################# |
657 | |
667 | |
658 | package CFPlus::UI::Empty; |
668 | package DC::UI::Empty; |
659 | |
669 | |
660 | our @ISA = CFPlus::UI::Base::; |
670 | our @ISA = DC::UI::Base::; |
661 | |
671 | |
662 | sub new { |
672 | sub new { |
663 | my ($class, %arg) = @_; |
673 | my ($class, %arg) = @_; |
664 | $class->SUPER::new (can_events => 0, %arg); |
674 | $class->SUPER::new (can_events => 0, %arg); |
665 | } |
675 | } |
… | |
… | |
672 | |
682 | |
673 | sub draw { } |
683 | sub draw { } |
674 | |
684 | |
675 | ############################################################################# |
685 | ############################################################################# |
676 | |
686 | |
677 | package CFPlus::UI::Container; |
687 | package DC::UI::Container; |
678 | |
688 | |
679 | our @ISA = CFPlus::UI::Base::; |
689 | our @ISA = DC::UI::Base::; |
680 | |
690 | |
681 | sub new { |
691 | sub new { |
682 | my ($class, %arg) = @_; |
692 | my ($class, %arg) = @_; |
683 | |
693 | |
684 | my $children = delete $arg{children}; |
694 | my $children = delete $arg{children}; |
… | |
… | |
778 | $_->draw for $self->visible_children; |
788 | $_->draw for $self->visible_children; |
779 | } |
789 | } |
780 | |
790 | |
781 | ############################################################################# |
791 | ############################################################################# |
782 | |
792 | |
783 | package CFPlus::UI::Bin; |
793 | package DC::UI::Bin; |
784 | |
794 | |
785 | our @ISA = CFPlus::UI::Container::; |
795 | our @ISA = DC::UI::Container::; |
786 | |
796 | |
787 | sub new { |
797 | sub new { |
788 | my ($class, %arg) = @_; |
798 | my ($class, %arg) = @_; |
789 | |
799 | |
790 | my $child = (delete $arg{child}) || new CFPlus::UI::Empty::; |
800 | my $child = (delete $arg{child}) || new DC::UI::Empty::; |
791 | |
801 | |
792 | $class->SUPER::new (children => [$child], %arg) |
802 | $class->SUPER::new (children => [$child], %arg) |
793 | } |
803 | } |
794 | |
804 | |
795 | sub add { |
805 | sub add { |
… | |
… | |
802 | sub remove { |
812 | sub remove { |
803 | my ($self, $widget) = @_; |
813 | my ($self, $widget) = @_; |
804 | |
814 | |
805 | $self->SUPER::remove ($widget); |
815 | $self->SUPER::remove ($widget); |
806 | |
816 | |
807 | $self->{children} = [new CFPlus::UI::Empty] |
817 | $self->{children} = [new DC::UI::Empty] |
808 | unless @{$self->{children}}; |
818 | unless @{$self->{children}}; |
809 | } |
819 | } |
810 | |
820 | |
811 | sub child { $_[0]->{children}[0] } |
821 | sub child { $_[0]->{children}[0] } |
812 | |
822 | |
… | |
… | |
821 | |
831 | |
822 | 1 |
832 | 1 |
823 | } |
833 | } |
824 | |
834 | |
825 | ############################################################################# |
835 | ############################################################################# |
826 | |
|
|
827 | # back-buffered drawing area |
836 | # back-buffered drawing area |
828 | |
837 | |
829 | package CFPlus::UI::Window; |
838 | package DC::UI::Window; |
830 | |
839 | |
831 | our @ISA = CFPlus::UI::Bin::; |
840 | our @ISA = DC::UI::Bin::; |
832 | |
841 | |
833 | use CFPlus::OpenGL; |
842 | use DC::OpenGL; |
834 | |
843 | |
835 | sub new { |
844 | sub new { |
836 | my ($class, %arg) = @_; |
845 | my ($class, %arg) = @_; |
837 | |
846 | |
838 | my $self = $class->SUPER::new (%arg); |
847 | my $self = $class->SUPER::new (%arg); |
… | |
… | |
860 | } |
869 | } |
861 | |
870 | |
862 | sub render_child { |
871 | sub render_child { |
863 | my ($self) = @_; |
872 | my ($self) = @_; |
864 | |
873 | |
865 | $self->{texture} = new_from_opengl CFPlus::Texture $self->{w}, $self->{h}, sub { |
874 | $self->{texture} = new_from_opengl DC::Texture $self->{w}, $self->{h}, sub { |
866 | glClearColor 0, 0, 0, 0; |
875 | glClearColor 0, 0, 0, 0; |
867 | glClear GL_COLOR_BUFFER_BIT; |
876 | glClear GL_COLOR_BUFFER_BIT; |
868 | |
877 | |
869 | { |
878 | { |
870 | package CFPlus::UI::Base; |
879 | package DC::UI::Base; |
871 | |
880 | |
872 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
881 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
873 | (0, 0, $self->{w}, $self->{h}); |
882 | (0, 0, $self->{w}, $self->{h}); |
874 | |
883 | |
875 | $self->_render; |
884 | $self->_render; |
… | |
… | |
892 | glDisable GL_TEXTURE_2D; |
901 | glDisable GL_TEXTURE_2D; |
893 | } |
902 | } |
894 | |
903 | |
895 | ############################################################################# |
904 | ############################################################################# |
896 | |
905 | |
897 | package CFPlus::UI::ViewPort; |
906 | package DC::UI::ViewPort; |
898 | |
907 | |
899 | use List::Util qw(min max); |
908 | use List::Util qw(min max); |
900 | |
909 | |
901 | our @ISA = CFPlus::UI::Window::; |
910 | our @ISA = DC::UI::Window::; |
902 | |
911 | |
903 | sub new { |
912 | sub new { |
904 | my $class = shift; |
913 | my $class = shift; |
905 | |
914 | |
906 | $class->SUPER::new ( |
915 | $class->SUPER::new ( |
… | |
… | |
990 | if ( $x >= $self->{x} && $x < $self->{x} + $self->{w} |
999 | if ( $x >= $self->{x} && $x < $self->{x} + $self->{w} |
991 | && $y >= $self->{y} && $y < $self->{y} + $self->{h} |
1000 | && $y >= $self->{y} && $y < $self->{y} + $self->{h} |
992 | ) { |
1001 | ) { |
993 | $self->child->find_widget ($x + $self->{view_x}, $y + $self->{view_y}) |
1002 | $self->child->find_widget ($x + $self->{view_x}, $y + $self->{view_y}) |
994 | } else { |
1003 | } else { |
995 | $self->CFPlus::UI::Base::find_widget ($x, $y) |
1004 | $self->DC::UI::Base::find_widget ($x, $y) |
996 | } |
1005 | } |
997 | } |
1006 | } |
998 | |
1007 | |
999 | sub _render { |
1008 | sub _render { |
1000 | my ($self) = @_; |
1009 | my ($self) = @_; |
1001 | |
1010 | |
1002 | local $CFPlus::UI::Base::draw_x = $CFPlus::UI::Base::draw_x - $self->{view_x}; |
1011 | local $DC::UI::Base::draw_x = $DC::UI::Base::draw_x - $self->{view_x}; |
1003 | local $CFPlus::UI::Base::draw_y = $CFPlus::UI::Base::draw_y - $self->{view_y}; |
1012 | local $DC::UI::Base::draw_y = $DC::UI::Base::draw_y - $self->{view_y}; |
1004 | |
1013 | |
1005 | CFPlus::OpenGL::glTranslate -$self->{view_x}, -$self->{view_y}; |
1014 | DC::OpenGL::glTranslate -$self->{view_x}, -$self->{view_y}; |
1006 | |
1015 | |
1007 | $self->SUPER::_render; |
1016 | $self->SUPER::_render; |
1008 | } |
1017 | } |
1009 | |
1018 | |
1010 | ############################################################################# |
1019 | ############################################################################# |
1011 | |
1020 | |
1012 | package CFPlus::UI::ScrolledWindow; |
1021 | package DC::UI::ScrolledWindow; |
1013 | |
1022 | |
1014 | our @ISA = CFPlus::UI::Table::; |
1023 | our @ISA = DC::UI::Table::; |
1015 | |
1024 | |
1016 | sub new { |
1025 | sub new { |
1017 | my ($class, %arg) = @_; |
1026 | my ($class, %arg) = @_; |
1018 | |
1027 | |
1019 | my $child = delete $arg{child}; |
1028 | my $child = delete $arg{child}; |
1020 | |
1029 | |
1021 | my $self; |
1030 | my $self; |
1022 | |
1031 | |
1023 | my $hslider = new CFPlus::UI::Slider |
1032 | my $hslider = new DC::UI::Slider |
1024 | c_col => 0, |
1033 | c_col => 0, |
1025 | c_row => 1, |
1034 | c_row => 1, |
1026 | vertical => 0, |
1035 | vertical => 0, |
1027 | range => [0, 0, 1, 0.01], # HACK fix |
1036 | range => [0, 0, 1, 0.01], # HACK fix |
1028 | on_changed => sub { |
1037 | on_changed => sub { |
1029 | $self->{hpos} = $_[1]; |
1038 | $self->{hpos} = $_[1]; |
1030 | $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); |
1039 | $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); |
1031 | }, |
1040 | }, |
1032 | ; |
1041 | ; |
1033 | |
1042 | |
1034 | my $vslider = new CFPlus::UI::Slider |
1043 | my $vslider = new DC::UI::Slider |
1035 | c_col => 1, |
1044 | c_col => 1, |
1036 | c_row => 0, |
1045 | c_row => 0, |
1037 | vertical => 1, |
1046 | vertical => 1, |
1038 | range => [0, 0, 1, 0.01], # HACK fix |
1047 | range => [0, 0, 1, 0.01], # HACK fix |
1039 | on_changed => sub { |
1048 | on_changed => sub { |
… | |
… | |
1051 | col_expand => [1, 0], |
1060 | col_expand => [1, 0], |
1052 | row_expand => [1, 0], |
1061 | row_expand => [1, 0], |
1053 | %arg, |
1062 | %arg, |
1054 | ); |
1063 | ); |
1055 | |
1064 | |
1056 | $self->{vp} = new CFPlus::UI::ViewPort |
1065 | $self->{vp} = new DC::UI::ViewPort |
1057 | c_col => 0, |
1066 | c_col => 0, |
1058 | c_row => 0, |
1067 | c_row => 0, |
1059 | expand => 1, |
1068 | expand => 1, |
1060 | scroll_x => $self->{scroll_x}, |
1069 | scroll_x => $self->{scroll_x}, |
1061 | scroll_y => $self->{scroll_y}, |
1070 | scroll_y => $self->{scroll_y}, |
… | |
… | |
1187 | $self->SUPER::invoke_size_allocate ($w, $h) |
1196 | $self->SUPER::invoke_size_allocate ($w, $h) |
1188 | } |
1197 | } |
1189 | |
1198 | |
1190 | ############################################################################# |
1199 | ############################################################################# |
1191 | |
1200 | |
1192 | package CFPlus::UI::Frame; |
1201 | package DC::UI::Frame; |
1193 | |
1202 | |
1194 | our @ISA = CFPlus::UI::Bin::; |
1203 | our @ISA = DC::UI::Bin::; |
1195 | |
1204 | |
1196 | use CFPlus::OpenGL; |
1205 | use DC::OpenGL; |
1197 | |
1206 | |
1198 | sub new { |
1207 | sub new { |
1199 | my $class = shift; |
1208 | my $class = shift; |
1200 | |
1209 | |
1201 | $class->SUPER::new ( |
1210 | $class->SUPER::new ( |
… | |
… | |
1220 | $self->SUPER::_draw; |
1229 | $self->SUPER::_draw; |
1221 | } |
1230 | } |
1222 | |
1231 | |
1223 | ############################################################################# |
1232 | ############################################################################# |
1224 | |
1233 | |
1225 | package CFPlus::UI::FancyFrame; |
1234 | package DC::UI::FancyFrame; |
1226 | |
1235 | |
1227 | our @ISA = CFPlus::UI::Bin::; |
1236 | our @ISA = DC::UI::Bin::; |
1228 | |
1237 | |
1229 | use CFPlus::OpenGL; |
1238 | use DC::OpenGL; |
1230 | |
1239 | |
1231 | sub new { |
1240 | sub new { |
1232 | my ($class, %arg) = @_; |
1241 | my ($class, %arg) = @_; |
1233 | |
1242 | |
1234 | if ((exists $arg{label}) && !ref $arg{label}) { |
1243 | if ((exists $arg{label}) && !ref $arg{label}) { |
1235 | $arg{label} = new CFPlus::UI::Label |
1244 | $arg{label} = new DC::UI::Label |
1236 | align => 1, |
1245 | align => 1, |
1237 | valign => 0, |
1246 | valign => 0, |
1238 | text => $arg{label}, |
1247 | text => $arg{label}, |
1239 | fontsize => ($arg{border} || 0.8) * 0.75; |
1248 | fontsize => ($arg{border} || 0.8) * 0.75; |
1240 | } |
1249 | } |
… | |
… | |
1252 | |
1261 | |
1253 | sub add { |
1262 | sub add { |
1254 | my ($self, @widgets) = @_; |
1263 | my ($self, @widgets) = @_; |
1255 | |
1264 | |
1256 | $self->SUPER::add (@widgets); |
1265 | $self->SUPER::add (@widgets); |
1257 | $self->CFPlus::UI::Container::add ($self->{label}) if $self->{label}; |
1266 | $self->DC::UI::Container::add ($self->{label}) if $self->{label}; |
1258 | } |
1267 | } |
1259 | |
1268 | |
1260 | sub border { |
1269 | sub border { |
1261 | int $_[0]{border} * $::FONTSIZE |
1270 | int $_[0]{border} * $::FONTSIZE |
1262 | } |
1271 | } |
… | |
… | |
1320 | } |
1329 | } |
1321 | } |
1330 | } |
1322 | |
1331 | |
1323 | ############################################################################# |
1332 | ############################################################################# |
1324 | |
1333 | |
1325 | package CFPlus::UI::Toplevel; |
1334 | package DC::UI::Toplevel; |
1326 | |
1335 | |
1327 | our @ISA = CFPlus::UI::Bin::; |
1336 | our @ISA = DC::UI::Bin::; |
1328 | |
1337 | |
1329 | use CFPlus::OpenGL; |
1338 | use DC::OpenGL; |
1330 | |
1339 | |
1331 | my $bg = |
1340 | my $bg = |
1332 | new_from_file CFPlus::Texture CFPlus::find_rcfile "d1_bg.png", |
1341 | new_from_file DC::Texture DC::find_rcfile "d1_bg.png", |
1333 | mipmap => 1, wrap => 1; |
1342 | mipmap => 1, wrap => 1; |
1334 | |
1343 | |
1335 | my @border = |
1344 | my @border = |
1336 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
1345 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
1337 | qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
1346 | qw(d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
1338 | |
1347 | |
1339 | my @icon = |
1348 | my @icon = |
1340 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
1349 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
1341 | qw(x1_move.png x1_resize.png); |
1350 | qw(x1_move.png x1_resize.png); |
1342 | |
1351 | |
1343 | sub new { |
1352 | sub new { |
1344 | my ($class, %arg) = @_; |
1353 | my ($class, %arg) = @_; |
1345 | |
1354 | |
… | |
… | |
1351 | min_w => 64, |
1360 | min_w => 64, |
1352 | min_h => 32, |
1361 | min_h => 32, |
1353 | %arg, |
1362 | %arg, |
1354 | ); |
1363 | ); |
1355 | |
1364 | |
1356 | $self->{title_widget} = new CFPlus::UI::Label |
1365 | $self->{title_widget} = new DC::UI::Label |
1357 | align => 0, |
1366 | align => 0, |
1358 | valign => 1, |
1367 | valign => 1, |
1359 | text => $self->{title}, |
1368 | text => $self->{title}, |
1360 | fontsize => $self->{border}, |
1369 | fontsize => $self->{border}, |
1361 | if exists $self->{title}; |
1370 | if exists $self->{title}; |
1362 | |
1371 | |
1363 | if ($self->{has_close_button}) { |
1372 | if ($self->{has_close_button}) { |
1364 | $self->{close_button} = |
1373 | $self->{close_button} = |
1365 | new CFPlus::UI::ImageButton |
1374 | new DC::UI::ImageButton |
1366 | path => 'x1_close.png', |
1375 | path => 'x1_close.png', |
1367 | on_activate => sub { $self->emit ("delete") }; |
1376 | on_activate => sub { $self->emit ("delete") }; |
1368 | |
1377 | |
1369 | $self->CFPlus::UI::Container::add ($self->{close_button}); |
1378 | $self->DC::UI::Container::add ($self->{close_button}); |
1370 | } |
1379 | } |
1371 | |
1380 | |
1372 | $self |
1381 | $self |
1373 | } |
1382 | } |
1374 | |
1383 | |
1375 | sub add { |
1384 | sub add { |
1376 | my ($self, @widgets) = @_; |
1385 | my ($self, @widgets) = @_; |
1377 | |
1386 | |
1378 | $self->SUPER::add (@widgets); |
1387 | $self->SUPER::add (@widgets); |
1379 | $self->CFPlus::UI::Container::add ($self->{close_button}) if $self->{close_button}; |
1388 | $self->DC::UI::Container::add ($self->{close_button}) if $self->{close_button}; |
1380 | $self->CFPlus::UI::Container::add ($self->{title_widget}) if $self->{title_widget}; |
1389 | $self->DC::UI::Container::add ($self->{title_widget}) if $self->{title_widget}; |
1381 | } |
1390 | } |
1382 | |
1391 | |
1383 | sub border { |
1392 | sub border { |
1384 | int $_[0]{border} * $::FONTSIZE |
1393 | int $_[0]{border} * $::FONTSIZE |
|
|
1394 | } |
|
|
1395 | |
|
|
1396 | sub get_max_wh { |
|
|
1397 | my ($self) = @_; |
|
|
1398 | |
|
|
1399 | return ($self->{w}, $self->{h}) |
|
|
1400 | if $self->{visible} && $self->{w}; |
|
|
1401 | |
|
|
1402 | $self->SUPER::get_max_wh |
1385 | } |
1403 | } |
1386 | |
1404 | |
1387 | sub size_request { |
1405 | sub size_request { |
1388 | my ($self) = @_; |
1406 | my ($self) = @_; |
1389 | |
1407 | |
… | |
… | |
1561 | if $self->{close_button}; |
1579 | if $self->{close_button}; |
1562 | } |
1580 | } |
1563 | |
1581 | |
1564 | ############################################################################# |
1582 | ############################################################################# |
1565 | |
1583 | |
1566 | package CFPlus::UI::Table; |
1584 | package DC::UI::Table; |
1567 | |
1585 | |
1568 | our @ISA = CFPlus::UI::Container::; |
1586 | our @ISA = DC::UI::Container::; |
1569 | |
1587 | |
1570 | use List::Util qw(max sum); |
1588 | use List::Util qw(max sum); |
1571 | |
1589 | |
1572 | use CFPlus::OpenGL; |
1590 | use DC::OpenGL; |
1573 | |
1591 | |
1574 | sub new { |
1592 | sub new { |
1575 | my $class = shift; |
1593 | my $class = shift; |
1576 | |
1594 | |
1577 | $class->SUPER::new ( |
1595 | $class->SUPER::new ( |
… | |
… | |
1621 | my ($c, $w, $cs) = @$widget{qw(c_col req_w c_colspan)}; |
1639 | my ($c, $w, $cs) = @$widget{qw(c_col req_w c_colspan)}; |
1622 | |
1640 | |
1623 | my $sw = sum @w[$c .. $c + $cs - 1]; |
1641 | my $sw = sum @w[$c .. $c + $cs - 1]; |
1624 | |
1642 | |
1625 | if ($w > $sw) { |
1643 | if ($w > $sw) { |
1626 | $_ += ($w - $sw) / ($sw ? $sw / $_ : $cs) for @w[$c .. $c + $cs - 1]; |
1644 | $_ += ($w - $sw) / ($_ ? $sw / $_ : $cs) for @w[$c .. $c + $cs - 1]; |
1627 | } |
1645 | } |
1628 | } |
1646 | } |
1629 | |
1647 | |
1630 | # second pass, rows |
1648 | # second pass, rows |
1631 | for my $widget (sort { $a->{c_rowspan} <=> $b->{c_rowspan} } @children) { |
1649 | for my $widget (sort { $a->{c_rowspan} <=> $b->{c_rowspan} } @children) { |
1632 | my ($r, $h, $rs) = @$widget{qw(c_row req_h c_rowspan)}; |
1650 | my ($r, $h, $rs) = @$widget{qw(c_row req_h c_rowspan)}; |
1633 | |
1651 | |
1634 | my $sh = sum @h[$r .. $r + $rs - 1]; |
1652 | my $sh = sum @h[$r .. $r + $rs - 1]; |
1635 | |
1653 | |
1636 | if ($h > $sh) { |
1654 | if ($h > $sh) { |
1637 | $_ += ($h - $sh) / ($sh ? $sh / $_ : $rs) for @h[$r .. $r + $rs - 1]; |
1655 | $_ += ($h - $sh) / ($_ ? $sh / $_ : $rs) for @h[$r .. $r + $rs - 1]; |
1638 | } |
1656 | } |
1639 | } |
1657 | } |
1640 | |
1658 | |
1641 | (\@w, \@h) |
1659 | (\@w, \@h) |
1642 | } |
1660 | } |
… | |
… | |
1665 | @col_expand = (1) x @$ws unless @col_expand; |
1683 | @col_expand = (1) x @$ws unless @col_expand; |
1666 | my $col_expand = (sum @col_expand) || 1; |
1684 | my $col_expand = (sum @col_expand) || 1; |
1667 | |
1685 | |
1668 | $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; |
1686 | $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; |
1669 | |
1687 | |
1670 | CFPlus::UI::harmonize $ws; |
1688 | DC::UI::harmonize $ws; |
1671 | |
1689 | |
1672 | my @row_expand = @{$self->{row_expand}}; |
1690 | my @row_expand = @{$self->{row_expand}}; |
1673 | @row_expand = (1) x @$ws unless @row_expand; |
1691 | @row_expand = (1) x @$ws unless @row_expand; |
1674 | my $row_expand = (sum @row_expand) || 1; |
1692 | my $row_expand = (sum @row_expand) || 1; |
1675 | |
1693 | |
1676 | $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs; |
1694 | $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs; |
1677 | |
1695 | |
1678 | CFPlus::UI::harmonize $hs; |
1696 | DC::UI::harmonize $hs; |
1679 | |
1697 | |
1680 | my @x; for (0 .. $#$ws) { $x[$_ + 1] = $x[$_] + $ws->[$_] } |
1698 | my @x; for (0 .. $#$ws) { $x[$_ + 1] = $x[$_] + $ws->[$_] } |
1681 | my @y; for (0 .. $#$hs) { $y[$_ + 1] = $y[$_] + $hs->[$_] } |
1699 | my @y; for (0 .. $#$hs) { $y[$_ + 1] = $y[$_] + $hs->[$_] } |
1682 | |
1700 | |
1683 | for my $widget ($self->children) { |
1701 | for my $widget ($self->children) { |
… | |
… | |
1692 | 1 |
1710 | 1 |
1693 | } |
1711 | } |
1694 | |
1712 | |
1695 | ############################################################################# |
1713 | ############################################################################# |
1696 | |
1714 | |
1697 | package CFPlus::UI::Fixed; |
1715 | package DC::UI::Fixed; |
1698 | |
1716 | |
1699 | use List::Util qw(min max); |
1717 | use List::Util qw(min max); |
1700 | |
1718 | |
1701 | our @ISA = CFPlus::UI::Container::; |
1719 | our @ISA = DC::UI::Container::; |
1702 | |
1720 | |
1703 | sub _scale($$$) { |
1721 | sub _scale($$$) { |
1704 | my ($rel, $val, $max) = @_; |
1722 | my ($rel, $val, $max) = @_; |
1705 | |
1723 | |
1706 | $rel ? $val * $max : $val |
1724 | $rel ? $val * $max : $val |
… | |
… | |
1758 | 1 |
1776 | 1 |
1759 | } |
1777 | } |
1760 | |
1778 | |
1761 | ############################################################################# |
1779 | ############################################################################# |
1762 | |
1780 | |
1763 | package CFPlus::UI::Box; |
1781 | package DC::UI::Box; |
1764 | |
1782 | |
1765 | our @ISA = CFPlus::UI::Container::; |
1783 | our @ISA = DC::UI::Container::; |
1766 | |
1784 | |
1767 | sub size_request { |
1785 | sub size_request { |
1768 | my ($self) = @_; |
1786 | my ($self) = @_; |
1769 | |
1787 | |
1770 | my @children = $self->visible_children; |
1788 | my @children = $self->visible_children; |
… | |
… | |
1805 | $req[$_] += $space * $children[$_]{expand} |
1823 | $req[$_] += $space * $children[$_]{expand} |
1806 | for 0 .. $#children; |
1824 | for 0 .. $#children; |
1807 | } |
1825 | } |
1808 | } |
1826 | } |
1809 | |
1827 | |
1810 | CFPlus::UI::harmonize \@req; |
1828 | DC::UI::harmonize \@req; |
1811 | |
1829 | |
1812 | my $pos = 0; |
1830 | my $pos = 0; |
1813 | for (0 .. $#children) { |
1831 | for (0 .. $#children) { |
1814 | my $alloc = $req[$_]; |
1832 | my $alloc = $req[$_]; |
1815 | $children[$_]->configure ($self->{vertical} ? (0, $pos, $w, $alloc) : ($pos, 0, $alloc, $h)); |
1833 | $children[$_]->configure ($self->{vertical} ? (0, $pos, $w, $alloc) : ($pos, 0, $alloc, $h)); |
… | |
… | |
1820 | 1 |
1838 | 1 |
1821 | } |
1839 | } |
1822 | |
1840 | |
1823 | ############################################################################# |
1841 | ############################################################################# |
1824 | |
1842 | |
1825 | package CFPlus::UI::HBox; |
1843 | package DC::UI::HBox; |
1826 | |
1844 | |
1827 | our @ISA = CFPlus::UI::Box::; |
1845 | our @ISA = DC::UI::Box::; |
1828 | |
1846 | |
1829 | sub new { |
1847 | sub new { |
1830 | my $class = shift; |
1848 | my $class = shift; |
1831 | |
1849 | |
1832 | $class->SUPER::new ( |
1850 | $class->SUPER::new ( |
… | |
… | |
1835 | ) |
1853 | ) |
1836 | } |
1854 | } |
1837 | |
1855 | |
1838 | ############################################################################# |
1856 | ############################################################################# |
1839 | |
1857 | |
1840 | package CFPlus::UI::VBox; |
1858 | package DC::UI::VBox; |
1841 | |
1859 | |
1842 | our @ISA = CFPlus::UI::Box::; |
1860 | our @ISA = DC::UI::Box::; |
1843 | |
1861 | |
1844 | sub new { |
1862 | sub new { |
1845 | my $class = shift; |
1863 | my $class = shift; |
1846 | |
1864 | |
1847 | $class->SUPER::new ( |
1865 | $class->SUPER::new ( |
… | |
… | |
1850 | ) |
1868 | ) |
1851 | } |
1869 | } |
1852 | |
1870 | |
1853 | ############################################################################# |
1871 | ############################################################################# |
1854 | |
1872 | |
1855 | package CFPlus::UI::Label; |
1873 | package DC::UI::Label; |
1856 | |
1874 | |
1857 | our @ISA = CFPlus::UI::DrawBG::; |
1875 | our @ISA = DC::UI::DrawBG::; |
1858 | |
1876 | |
1859 | use CFPlus::OpenGL; |
1877 | use DC::OpenGL; |
1860 | |
1878 | |
1861 | sub new { |
1879 | sub new { |
1862 | my ($class, %arg) = @_; |
1880 | my ($class, %arg) = @_; |
1863 | |
1881 | |
1864 | my $self = $class->SUPER::new ( |
1882 | my $self = $class->SUPER::new ( |
… | |
… | |
1869 | #text => initial text |
1887 | #text => initial text |
1870 | #markup => initial narkup |
1888 | #markup => initial narkup |
1871 | #max_w => maximum pixel width |
1889 | #max_w => maximum pixel width |
1872 | #style => 0, # render flags |
1890 | #style => 0, # render flags |
1873 | ellipsise => 3, # end |
1891 | ellipsise => 3, # end |
1874 | layout => (new CFPlus::Layout), |
1892 | layout => (new DC::Layout), |
1875 | fontsize => 1, |
1893 | fontsize => 1, |
1876 | align => -1, |
1894 | align => -1, |
1877 | valign => -1, |
1895 | valign => -1, |
1878 | padding_x => 2, |
1896 | padding_x => 2, |
1879 | padding_y => 2, |
1897 | padding_y => 2, |
1880 | can_events => 0, |
1898 | can_events => 0, |
1881 | %arg |
1899 | %arg |
1882 | ); |
1900 | ); |
1883 | |
1901 | |
1884 | if (exists $self->{template}) { |
1902 | if (exists $self->{template}) { |
1885 | my $layout = new CFPlus::Layout; |
1903 | my $layout = new DC::Layout; |
1886 | $layout->set_text (delete $self->{template}); |
1904 | $layout->set_text (delete $self->{template}); |
1887 | $self->{template} = $layout; |
1905 | $self->{template} = $layout; |
1888 | } |
1906 | } |
1889 | |
1907 | |
1890 | if (exists $self->{markup}) { |
1908 | if (exists $self->{markup}) { |
… | |
… | |
1946 | |
1964 | |
1947 | sub size_request { |
1965 | sub size_request { |
1948 | my ($self) = @_; |
1966 | my ($self) = @_; |
1949 | |
1967 | |
1950 | $self->{size_req} ||= do { |
1968 | $self->{size_req} ||= do { |
|
|
1969 | my ($max_w, $max_h) = $self->get_max_wh; |
|
|
1970 | |
1951 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1971 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1952 | $self->{layout}->set_width ($self->{max_w} || -1); |
1972 | $self->{layout}->set_width ($self->{max_w} || $max_w || -1); |
1953 | $self->{layout}->set_ellipsise ($self->{ellipsise}); |
1973 | $self->{layout}->set_ellipsise ($self->{ellipsise}); |
1954 | $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); |
1974 | $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); |
1955 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1975 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1956 | |
1976 | |
1957 | my ($w, $h) = $self->{layout}->size; |
1977 | my ($w, $h) = $self->{layout}->size; |
… | |
… | |
2034 | |
2054 | |
2035 | $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2055 | $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2036 | }; |
2056 | }; |
2037 | |
2057 | |
2038 | # unless ($self->{list}) { |
2058 | # unless ($self->{list}) { |
2039 | # $self->{list} = CFPlus::OpenGL::glGenList; |
2059 | # $self->{list} = DC::OpenGL::glGenList; |
2040 | # CFPlus::OpenGL::glNewList $self->{list}; |
2060 | # DC::OpenGL::glNewList $self->{list}; |
2041 | # $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2061 | # $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2042 | # CFPlus::OpenGL::glEndList; |
2062 | # DC::OpenGL::glEndList; |
2043 | # } |
2063 | # } |
2044 | # |
2064 | # |
2045 | # CFPlus::OpenGL::glCallList $self->{list}; |
2065 | # DC::OpenGL::glCallList $self->{list}; |
2046 | |
2066 | |
2047 | $self->{layout}->draw; |
2067 | $self->{layout}->draw; |
2048 | } |
2068 | } |
2049 | |
2069 | |
2050 | #sub destroy { |
2070 | #sub destroy { |
2051 | # my ($self) = @_; |
2071 | # my ($self) = @_; |
2052 | # |
2072 | # |
2053 | # CFPlus::OpenGL::glDeleteList delete $self->{list} if $self->{list}; |
2073 | # DC::OpenGL::glDeleteList delete $self->{list} if $self->{list}; |
2054 | # |
2074 | # |
2055 | # $self->SUPER::destroy; |
2075 | # $self->SUPER::destroy; |
2056 | #} |
2076 | #} |
2057 | |
2077 | |
2058 | ############################################################################# |
2078 | ############################################################################# |
2059 | |
2079 | |
2060 | package CFPlus::UI::EntryBase; |
2080 | package DC::UI::EntryBase; |
2061 | |
2081 | |
2062 | our @ISA = CFPlus::UI::Label::; |
2082 | our @ISA = DC::UI::Label::; |
2063 | |
2083 | |
2064 | use CFPlus::OpenGL; |
2084 | use DC::OpenGL; |
2065 | |
2085 | |
2066 | sub new { |
2086 | sub new { |
2067 | my $class = shift; |
2087 | my $class = shift; |
2068 | |
2088 | |
2069 | $class->SUPER::new ( |
2089 | $class->SUPER::new ( |
… | |
… | |
2076 | can_hover => 1, |
2096 | can_hover => 1, |
2077 | can_focus => 1, |
2097 | can_focus => 1, |
2078 | valign => 0, |
2098 | valign => 0, |
2079 | can_events => 1, |
2099 | can_events => 1, |
2080 | ellipsise => 0, |
2100 | ellipsise => 0, |
|
|
2101 | padding_x => 4, |
|
|
2102 | padding_y => 2, |
2081 | #text => ... |
2103 | #text => ... |
2082 | #hidden => "*", |
2104 | #hidden => "*", |
2083 | @_ |
2105 | @_ |
2084 | ) |
2106 | ) |
2085 | } |
2107 | } |
… | |
… | |
2136 | |
2158 | |
2137 | if ($uni == 8) { |
2159 | if ($uni == 8) { |
2138 | substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; |
2160 | substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; |
2139 | } elsif ($uni == 127) { |
2161 | } elsif ($uni == 127) { |
2140 | substr $text, $self->{cursor}, 1, ""; |
2162 | substr $text, $self->{cursor}, 1, ""; |
2141 | } elsif ($sym == CFPlus::SDLK_LEFT) { |
2163 | } elsif ($sym == DC::SDLK_LEFT) { |
2142 | --$self->{cursor} if $self->{cursor}; |
2164 | --$self->{cursor} if $self->{cursor}; |
2143 | } elsif ($sym == CFPlus::SDLK_RIGHT) { |
2165 | } elsif ($sym == DC::SDLK_RIGHT) { |
2144 | ++$self->{cursor} if $self->{cursor} < length $self->{text}; |
2166 | ++$self->{cursor} if $self->{cursor} < length $self->{text}; |
2145 | } elsif ($sym == CFPlus::SDLK_HOME) { |
2167 | } elsif ($sym == DC::SDLK_HOME) { |
2146 | # what a hack |
2168 | # what a hack |
2147 | $self->{cursor} = |
2169 | $self->{cursor} = |
2148 | (substr $self->{text}, 0, $self->{cursor}) =~ /^(.*\012)/ |
2170 | (substr $self->{text}, 0, $self->{cursor}) =~ /^(.*\012)/ |
2149 | ? length $1 |
2171 | ? length $1 |
2150 | : 0; |
2172 | : 0; |
2151 | } elsif ($sym == CFPlus::SDLK_END) { |
2173 | } elsif ($sym == DC::SDLK_END) { |
2152 | # uh, again |
2174 | # uh, again |
2153 | $self->{cursor} = |
2175 | $self->{cursor} = |
2154 | (substr $self->{text}, $self->{cursor}) =~ /^([^\012]*)\012/ |
2176 | (substr $self->{text}, $self->{cursor}) =~ /^([^\012]*)\012/ |
2155 | ? $self->{cursor} + length $1 |
2177 | ? $self->{cursor} + length $1 |
2156 | : length $self->{text}; |
2178 | : length $self->{text}; |
… | |
… | |
2237 | @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); |
2259 | @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); |
2238 | } |
2260 | } |
2239 | |
2261 | |
2240 | glColor_premultiply @{$self->{active_fg}}; |
2262 | glColor_premultiply @{$self->{active_fg}}; |
2241 | glBegin GL_LINES; |
2263 | glBegin GL_LINES; |
2242 | glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; |
2264 | glVertex $self->{cur_x} + $self->{ox} + .5, $self->{cur_y} + $self->{oy}; |
2243 | glVertex 0.5 + $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h}; |
2265 | glVertex $self->{cur_x} + $self->{ox} + .5, $self->{cur_y} + $self->{oy} + $self->{cur_h}; |
2244 | glEnd; |
2266 | glEnd; |
2245 | |
2267 | |
2246 | glLineWidth 3; |
2268 | glLineWidth 3; |
2247 | glColor @{$self->{active_outline}}; |
2269 | glColor @{$self->{active_outline}}; |
2248 | glRect_lineloop 0, 0, $self->{w} - 1, $self->{h} - 1; |
2270 | glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5; |
2249 | glLineWidth 1; |
2271 | glLineWidth 1; |
2250 | |
2272 | |
2251 | } else { |
2273 | } else { |
2252 | glColor @{$self->{outline}}; |
2274 | glColor @{$self->{outline}}; |
2253 | glTranslate .375, .375; |
|
|
2254 | glBegin GL_LINE_STRIP; |
2275 | glBegin GL_LINE_STRIP; |
2255 | glVertex 0, $self->{h} * .5; |
2276 | glVertex .5, $self->{h} * .5; |
2256 | glVertex 0, $self->{h} - 3; |
2277 | glVertex .5, $self->{h} - 2.5; |
2257 | glVertex $self->{w} - 1, $self->{h} - 3; |
2278 | glVertex $self->{w} - .5, $self->{h} - 2.5; |
2258 | glVertex $self->{w} - 1, $self->{h} * .5; |
2279 | glVertex $self->{w} - .5, $self->{h} * .5; |
2259 | glEnd; |
2280 | glEnd; |
2260 | } |
2281 | } |
2261 | } |
2282 | } |
2262 | |
2283 | |
2263 | ############################################################################# |
2284 | ############################################################################# |
2264 | |
2285 | |
2265 | package CFPlus::UI::Entry; |
2286 | package DC::UI::Entry; |
2266 | |
2287 | |
2267 | our @ISA = CFPlus::UI::EntryBase::; |
2288 | our @ISA = DC::UI::EntryBase::; |
2268 | |
2289 | |
2269 | use CFPlus::OpenGL; |
2290 | use DC::OpenGL; |
2270 | |
2291 | |
2271 | sub invoke_key_down { |
2292 | sub invoke_key_down { |
2272 | my ($self, $ev) = @_; |
2293 | my ($self, $ev) = @_; |
2273 | |
2294 | |
2274 | my $sym = $ev->{sym}; |
2295 | my $sym = $ev->{sym}; |
… | |
… | |
2280 | $self->{history_pointer} = -1; |
2301 | $self->{history_pointer} = -1; |
2281 | $self->{history_saveback} = ''; |
2302 | $self->{history_saveback} = ''; |
2282 | $self->emit (activate => $txt); |
2303 | $self->emit (activate => $txt); |
2283 | $self->update; |
2304 | $self->update; |
2284 | |
2305 | |
2285 | } elsif ($sym == CFPlus::SDLK_UP) { |
2306 | } elsif ($sym == DC::SDLK_UP) { |
2286 | if ($self->{history_pointer} < 0) { |
2307 | if ($self->{history_pointer} < 0) { |
2287 | $self->{history_saveback} = $self->get_text; |
2308 | $self->{history_saveback} = $self->get_text; |
2288 | } |
2309 | } |
2289 | if (@{$self->{history} || []} > 0) { |
2310 | if (@{$self->{history} || []} > 0) { |
2290 | $self->{history_pointer}++; |
2311 | $self->{history_pointer}++; |
… | |
… | |
2292 | $self->{history_pointer} = @{$self->{history} || []} - 1; |
2313 | $self->{history_pointer} = @{$self->{history} || []} - 1; |
2293 | } |
2314 | } |
2294 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
2315 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
2295 | } |
2316 | } |
2296 | |
2317 | |
2297 | } elsif ($sym == CFPlus::SDLK_DOWN) { |
2318 | } elsif ($sym == DC::SDLK_DOWN) { |
2298 | $self->{history_pointer}--; |
2319 | $self->{history_pointer}--; |
2299 | $self->{history_pointer} = -1 if $self->{history_pointer} < 0; |
2320 | $self->{history_pointer} = -1 if $self->{history_pointer} < 0; |
2300 | |
2321 | |
2301 | if ($self->{history_pointer} >= 0) { |
2322 | if ($self->{history_pointer} >= 0) { |
2302 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
2323 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
… | |
… | |
2311 | 1 |
2332 | 1 |
2312 | } |
2333 | } |
2313 | |
2334 | |
2314 | ############################################################################# |
2335 | ############################################################################# |
2315 | |
2336 | |
2316 | package CFPlus::UI::TextEdit; |
2337 | package DC::UI::TextEdit; |
2317 | |
2338 | |
2318 | our @ISA = CFPlus::UI::EntryBase::; |
2339 | our @ISA = DC::UI::EntryBase::; |
2319 | |
2340 | |
2320 | use CFPlus::OpenGL; |
2341 | use DC::OpenGL; |
|
|
2342 | |
|
|
2343 | sub new { |
|
|
2344 | my $class = shift; |
|
|
2345 | |
|
|
2346 | $class->SUPER::new ( |
|
|
2347 | padding_y => 4, |
|
|
2348 | |
|
|
2349 | @_ |
|
|
2350 | ) |
|
|
2351 | } |
2321 | |
2352 | |
2322 | sub move_cursor_ver { |
2353 | sub move_cursor_ver { |
2323 | my ($self, $dy) = @_; |
2354 | my ($self, $dy) = @_; |
2324 | |
2355 | |
2325 | my ($y, $x) = $self->{layout}->index_to_line_x ($self->{cursor}); |
2356 | my ($y, $x) = $self->{layout}->index_to_line_x ($self->{cursor}); |
… | |
… | |
2337 | sub invoke_key_down { |
2368 | sub invoke_key_down { |
2338 | my ($self, $ev) = @_; |
2369 | my ($self, $ev) = @_; |
2339 | |
2370 | |
2340 | my $sym = $ev->{sym}; |
2371 | my $sym = $ev->{sym}; |
2341 | |
2372 | |
2342 | if ($sym == CFPlus::SDLK_UP) { |
2373 | if ($sym == DC::SDLK_UP) { |
2343 | $self->move_cursor_ver (-1); |
2374 | $self->move_cursor_ver (-1); |
2344 | } elsif ($sym == CFPlus::SDLK_DOWN) { |
2375 | } elsif ($sym == DC::SDLK_DOWN) { |
2345 | $self->move_cursor_ver (+1); |
2376 | $self->move_cursor_ver (+1); |
2346 | } else { |
2377 | } else { |
2347 | return $self->SUPER::invoke_key_down ($ev) |
2378 | return $self->SUPER::invoke_key_down ($ev) |
2348 | } |
2379 | } |
2349 | |
2380 | |
2350 | 1 |
2381 | 1 |
2351 | } |
2382 | } |
2352 | |
2383 | |
2353 | ############################################################################# |
2384 | ############################################################################# |
2354 | |
2385 | |
2355 | package CFPlus::UI::ButtonBin; |
2386 | package DC::UI::ButtonBin; |
2356 | |
2387 | |
2357 | our @ISA = CFPlus::UI::Bin::; |
2388 | our @ISA = DC::UI::Bin::; |
2358 | |
2389 | |
2359 | use CFPlus::OpenGL; |
2390 | use DC::OpenGL; |
2360 | |
2391 | |
2361 | my @tex = |
2392 | my @tex = |
2362 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2393 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2363 | qw(b1_button_inactive.png b1_button_active.png); |
2394 | qw(b1_button_inactive.png b1_button_active.png); |
2364 | |
2395 | |
2365 | sub new { |
2396 | sub new { |
2366 | my $class = shift; |
2397 | my $class = shift; |
2367 | |
2398 | |
… | |
… | |
2399 | $self->SUPER::_draw; |
2430 | $self->SUPER::_draw; |
2400 | } |
2431 | } |
2401 | |
2432 | |
2402 | ############################################################################# |
2433 | ############################################################################# |
2403 | |
2434 | |
2404 | package CFPlus::UI::Button; |
2435 | package DC::UI::Button; |
2405 | |
2436 | |
2406 | our @ISA = CFPlus::UI::Label::; |
2437 | our @ISA = DC::UI::Label::; |
2407 | |
2438 | |
2408 | use CFPlus::OpenGL; |
2439 | use DC::OpenGL; |
2409 | |
2440 | |
2410 | my @tex = |
2441 | my @tex = |
2411 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2442 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2412 | qw(b1_button_inactive.png b1_button_active.png); |
2443 | qw(b1_button_inactive.png b1_button_active.png); |
2413 | |
2444 | |
2414 | sub new { |
2445 | sub new { |
2415 | my $class = shift; |
2446 | my $class = shift; |
2416 | |
2447 | |
2417 | $class->SUPER::new ( |
2448 | $class->SUPER::new ( |
2418 | padding_x => 4, |
2449 | padding_x => 8, |
2419 | padding_y => 4, |
2450 | padding_y => 4, |
2420 | fg => [1.0, 1.0, 1.0], |
2451 | fg => [1.0, 1.0, 1.0], |
2421 | active_fg => [0.8, 0.8, 0.8], |
2452 | active_fg => [0.8, 0.8, 0.8], |
2422 | can_hover => 1, |
2453 | can_hover => 1, |
2423 | align => 0, |
2454 | align => 0, |
… | |
… | |
2454 | $self->SUPER::_draw; |
2485 | $self->SUPER::_draw; |
2455 | } |
2486 | } |
2456 | |
2487 | |
2457 | ############################################################################# |
2488 | ############################################################################# |
2458 | |
2489 | |
2459 | package CFPlus::UI::CheckBox; |
2490 | package DC::UI::CheckBox; |
2460 | |
2491 | |
2461 | our @ISA = CFPlus::UI::DrawBG::; |
2492 | our @ISA = DC::UI::DrawBG::; |
2462 | |
2493 | |
2463 | my @tex = |
2494 | my @tex = |
2464 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2495 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2465 | qw(c1_checkbox_bg.png c1_checkbox_active.png); |
2496 | qw(c1_checkbox_bg.png c1_checkbox_active.png); |
2466 | |
2497 | |
2467 | use CFPlus::OpenGL; |
2498 | use DC::OpenGL; |
2468 | |
2499 | |
2469 | sub new { |
2500 | sub new { |
2470 | my $class = shift; |
2501 | my $class = shift; |
2471 | |
2502 | |
2472 | $class->SUPER::new ( |
2503 | $class->SUPER::new ( |
… | |
… | |
2512 | sub _draw { |
2543 | sub _draw { |
2513 | my ($self) = @_; |
2544 | my ($self) = @_; |
2514 | |
2545 | |
2515 | $self->SUPER::_draw; |
2546 | $self->SUPER::_draw; |
2516 | |
2547 | |
2517 | glTranslate $self->{padding_x} + 0.375, $self->{padding_y} + 0.375, 0; |
2548 | glTranslate $self->{padding_x}, $self->{padding_y}, 0; |
2518 | |
2549 | |
2519 | my ($w, $h) = @$self{qw(w h)}; |
2550 | my ($w, $h) = @$self{qw(w h)}; |
2520 | |
2551 | |
2521 | my $s = List::Util::min $w - $self->{padding_x} * 2, $h - $self->{padding_y} * 2; |
2552 | my $s = List::Util::min $w - $self->{padding_x} * 2, $h - $self->{padding_y} * 2; |
2522 | |
2553 | |
… | |
… | |
2529 | glDisable GL_TEXTURE_2D; |
2560 | glDisable GL_TEXTURE_2D; |
2530 | } |
2561 | } |
2531 | |
2562 | |
2532 | ############################################################################# |
2563 | ############################################################################# |
2533 | |
2564 | |
2534 | package CFPlus::UI::Image; |
2565 | package DC::UI::Image; |
2535 | |
2566 | |
2536 | our @ISA = CFPlus::UI::Base::; |
2567 | our @ISA = DC::UI::Base::; |
2537 | |
2568 | |
2538 | use CFPlus::OpenGL; |
2569 | use DC::OpenGL; |
2539 | |
2570 | |
2540 | our %texture_cache; |
2571 | our %texture_cache; |
2541 | |
2572 | |
2542 | sub new { |
2573 | sub new { |
2543 | my $class = shift; |
2574 | my $class = shift; |
… | |
… | |
2550 | |
2581 | |
2551 | $self->{path} || $self->{tex} |
2582 | $self->{path} || $self->{tex} |
2552 | or Carp::croak "'path' or 'tex' attributes required"; |
2583 | or Carp::croak "'path' or 'tex' attributes required"; |
2553 | |
2584 | |
2554 | $self->{tex} ||= $texture_cache{$self->{path}} ||= |
2585 | $self->{tex} ||= $texture_cache{$self->{path}} ||= |
2555 | new_from_file CFPlus::Texture CFPlus::find_rcfile $self->{path}, mipmap => 1; |
2586 | new_from_file DC::Texture DC::find_rcfile $self->{path}, mipmap => 1; |
2556 | |
2587 | |
2557 | CFPlus::weaken $texture_cache{$self->{path}}; |
2588 | DC::weaken $texture_cache{$self->{path}}; |
2558 | |
2589 | |
2559 | $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h}; |
2590 | $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h}; |
2560 | |
2591 | |
2561 | $self |
2592 | $self |
2562 | } |
2593 | } |
2563 | |
2594 | |
2564 | sub STORABLE_freeze { |
2595 | sub STORABLE_freeze { |
2565 | my ($self, $cloning) = @_; |
2596 | my ($self, $cloning) = @_; |
2566 | |
2597 | |
2567 | $self->{path} |
2598 | $self->{path} |
2568 | or die "cannot serialise CFPlus::UI::Image on non-loadable images\n"; |
2599 | or die "cannot serialise DC::UI::Image on non-loadable images\n"; |
2569 | |
2600 | |
2570 | $self->{path} |
2601 | $self->{path} |
2571 | } |
2602 | } |
2572 | |
2603 | |
2573 | sub STORABLE_attach { |
2604 | sub STORABLE_attach { |
… | |
… | |
2604 | glDisable GL_TEXTURE_2D; |
2635 | glDisable GL_TEXTURE_2D; |
2605 | } |
2636 | } |
2606 | |
2637 | |
2607 | ############################################################################# |
2638 | ############################################################################# |
2608 | |
2639 | |
2609 | package CFPlus::UI::ImageButton; |
2640 | package DC::UI::ImageButton; |
2610 | |
2641 | |
2611 | our @ISA = CFPlus::UI::Image::; |
2642 | our @ISA = DC::UI::Image::; |
2612 | |
2643 | |
2613 | use CFPlus::OpenGL; |
2644 | use DC::OpenGL; |
2614 | |
2645 | |
2615 | my %textures; |
2646 | my %textures; |
2616 | |
2647 | |
2617 | sub new { |
2648 | sub new { |
2618 | my $class = shift; |
2649 | my $class = shift; |
… | |
… | |
2646 | 1 |
2677 | 1 |
2647 | } |
2678 | } |
2648 | |
2679 | |
2649 | ############################################################################# |
2680 | ############################################################################# |
2650 | |
2681 | |
2651 | package CFPlus::UI::VGauge; |
2682 | package DC::UI::VGauge; |
2652 | |
2683 | |
2653 | our @ISA = CFPlus::UI::Base::; |
2684 | our @ISA = DC::UI::Base::; |
2654 | |
2685 | |
2655 | use List::Util qw(min max); |
2686 | use List::Util qw(min max); |
2656 | |
2687 | |
2657 | use CFPlus::OpenGL; |
2688 | use DC::OpenGL; |
2658 | |
2689 | |
2659 | my %tex = ( |
2690 | my %tex = ( |
2660 | food => [ |
2691 | food => [ |
2661 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2692 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2662 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
2693 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
2663 | ], |
2694 | ], |
2664 | grace => [ |
2695 | grace => [ |
2665 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2696 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2666 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png g1_grace_gauge_overflow.png/ |
2697 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png g1_grace_gauge_overflow.png/ |
2667 | ], |
2698 | ], |
2668 | hp => [ |
2699 | hp => [ |
2669 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2700 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2670 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
2701 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
2671 | ], |
2702 | ], |
2672 | mana => [ |
2703 | mana => [ |
2673 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2704 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2674 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png g1_mana_gauge_overflow.png/ |
2705 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png g1_mana_gauge_overflow.png/ |
2675 | ], |
2706 | ], |
2676 | ); |
2707 | ); |
2677 | |
2708 | |
2678 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
2709 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
… | |
… | |
2781 | glDisable GL_TEXTURE_2D; |
2812 | glDisable GL_TEXTURE_2D; |
2782 | } |
2813 | } |
2783 | |
2814 | |
2784 | ############################################################################# |
2815 | ############################################################################# |
2785 | |
2816 | |
2786 | package CFPlus::UI::Progress; |
2817 | package DC::UI::Progress; |
2787 | |
2818 | |
2788 | our @ISA = CFPlus::UI::Label::; |
2819 | our @ISA = DC::UI::Label::; |
2789 | |
2820 | |
2790 | use CFPlus::OpenGL; |
2821 | use DC::OpenGL; |
2791 | |
2822 | |
2792 | sub new { |
2823 | sub new { |
2793 | my ($class, %arg) = @_; |
2824 | my ($class, %arg) = @_; |
2794 | |
2825 | |
2795 | my $self = $class->SUPER::new ( |
2826 | my $self = $class->SUPER::new ( |
… | |
… | |
2815 | my ($self, $label) = @_; |
2846 | my ($self, $label) = @_; |
2816 | |
2847 | |
2817 | return if $self->{label} eq $label; |
2848 | return if $self->{label} eq $label; |
2818 | $self->{label} = $label; |
2849 | $self->{label} = $label; |
2819 | |
2850 | |
2820 | $self->CFPlus::UI::Progress::set_value (0 + delete $self->{value}); |
2851 | $self->DC::UI::Progress::set_value (0 + delete $self->{value}); |
2821 | } |
2852 | } |
2822 | |
2853 | |
2823 | sub set_value { |
2854 | sub set_value { |
2824 | my ($self, $value) = @_; |
2855 | my ($self, $value) = @_; |
2825 | |
2856 | |
… | |
… | |
2841 | |
2872 | |
2842 | glEnable GL_BLEND; |
2873 | glEnable GL_BLEND; |
2843 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
2874 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
2844 | |
2875 | |
2845 | if ($self->{value} >= 0) { |
2876 | if ($self->{value} >= 0) { |
2846 | my $s = 3 + ($self->{w} - 6) * $self->{value}; |
2877 | my $s = int 2 + ($self->{w} - 4) * $self->{value}; |
2847 | |
2878 | |
2848 | glColor_premultiply @{$self->{bar}}; |
2879 | glColor_premultiply @{$self->{bar}}; |
2849 | glRect 2, 2, $s, $self->{h} - 2; |
2880 | glRect 2, 2, $s, $self->{h} - 2; |
2850 | glColor_premultiply @{$self->{bg}}; |
2881 | glColor_premultiply @{$self->{bg}}; |
2851 | glRect $s + 1, 0, $self->{w} - 2, $self->{h} - 2; |
2882 | glRect $s, 2, $self->{w} - 2, $self->{h} - 2; |
2852 | } |
2883 | } |
2853 | |
2884 | |
2854 | glColor_premultiply @{$self->{outline}}; |
2885 | glColor_premultiply @{$self->{outline}}; |
2855 | glRect_lineloop 1, 1, $self->{w} - 2, $self->{h} - 2; |
2886 | glRect_lineloop 1.5, 1.5, $self->{w} - 1.5, $self->{h} - 1.5; |
2856 | |
2887 | |
2857 | glDisable GL_BLEND; |
2888 | glDisable GL_BLEND; |
2858 | |
2889 | |
2859 | { |
2890 | { |
2860 | local $self->{bg}; # do not draw background |
2891 | local $self->{bg}; # do not draw background |
… | |
… | |
2862 | } |
2893 | } |
2863 | } |
2894 | } |
2864 | |
2895 | |
2865 | ############################################################################# |
2896 | ############################################################################# |
2866 | |
2897 | |
2867 | package CFPlus::UI::ExperienceProgress; |
2898 | package DC::UI::ExperienceProgress; |
2868 | |
2899 | |
2869 | our @ISA = CFPlus::UI::Progress::; |
2900 | our @ISA = DC::UI::Progress::; |
2870 | |
2901 | |
2871 | sub new { |
2902 | sub new { |
2872 | my ($class, %arg) = @_; |
2903 | my ($class, %arg) = @_; |
2873 | |
2904 | |
2874 | my $self = $class->SUPER::new ( |
2905 | my $self = $class->SUPER::new ( |
2875 | tooltip => sub { |
2906 | tooltip => sub { |
2876 | my ($self) = @_; |
2907 | my ($self) = @_; |
2877 | |
2908 | |
2878 | sprintf "%s points experience (level %d).\n%s points to next level %s.", |
2909 | sprintf "level %d\n%s points\n%s next level\n%s to go", |
2879 | ::formsep $self->{exp}, |
|
|
2880 | $self->{lvl}, |
2910 | $self->{lvl}, |
|
|
2911 | ::formsep ($self->{exp}), |
2881 | ::formsep $self->{nxt} |
2912 | ::formsep ($self->{nxt}), |
|
|
2913 | ::formsep ($self->{nxt} - $self->{exp}), |
2882 | }, |
2914 | }, |
2883 | %arg |
2915 | %arg |
2884 | ); |
2916 | ); |
2885 | |
2917 | |
2886 | $::CONN->{on_exp_update}{$self+0} = sub { $self->set_value ($self->{value}) } |
2918 | $::CONN->{on_exp_update}{$self+0} = sub { $self->set_value ($self->{value}) } |
… | |
… | |
2899 | } |
2931 | } |
2900 | |
2932 | |
2901 | sub set_value { |
2933 | sub set_value { |
2902 | my ($self, $lvl, $exp) = @_; |
2934 | my ($self, $lvl, $exp) = @_; |
2903 | |
2935 | |
2904 | $self->{lvl} = $exp; |
2936 | $self->{lvl} = $lvl; |
2905 | $self->{exp} = $exp; |
2937 | $self->{exp} = $exp; |
2906 | |
2938 | |
2907 | my $v = -1; |
2939 | my $v = -1; |
2908 | |
2940 | |
2909 | if ($::CONN && (my $table = $::CONN->{exp_table})) { |
2941 | if ($::CONN && (my $table = $::CONN->{exp_table})) { |
… | |
… | |
2918 | $self->SUPER::set_value ($v); |
2950 | $self->SUPER::set_value ($v); |
2919 | } |
2951 | } |
2920 | |
2952 | |
2921 | ############################################################################# |
2953 | ############################################################################# |
2922 | |
2954 | |
2923 | package CFPlus::UI::Gauge; |
2955 | package DC::UI::Gauge; |
2924 | |
2956 | |
2925 | our @ISA = CFPlus::UI::VBox::; |
2957 | our @ISA = DC::UI::VBox::; |
2926 | |
2958 | |
2927 | sub new { |
2959 | sub new { |
2928 | my ($class, %arg) = @_; |
2960 | my ($class, %arg) = @_; |
2929 | |
2961 | |
2930 | my $self = $class->SUPER::new ( |
2962 | my $self = $class->SUPER::new ( |
… | |
… | |
2932 | can_hover => 1, |
2964 | can_hover => 1, |
2933 | can_events => 1, |
2965 | can_events => 1, |
2934 | %arg, |
2966 | %arg, |
2935 | ); |
2967 | ); |
2936 | |
2968 | |
2937 | $self->add ($self->{value} = new CFPlus::UI::Label valign => +1, align => 0, template => "999"); |
2969 | $self->add ($self->{value} = new DC::UI::Label valign => +1, align => 0, template => "999"); |
2938 | $self->add ($self->{gauge} = new CFPlus::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); |
2970 | $self->add ($self->{gauge} = new DC::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); |
2939 | $self->add ($self->{max} = new CFPlus::UI::Label valign => -1, align => 0, template => "999"); |
2971 | $self->add ($self->{max} = new DC::UI::Label valign => -1, align => 0, template => "999"); |
2940 | |
2972 | |
2941 | $self |
2973 | $self |
2942 | } |
2974 | } |
2943 | |
2975 | |
2944 | sub set_fontsize { |
2976 | sub set_fontsize { |
… | |
… | |
2965 | $self->{value}->set_text ($val); |
2997 | $self->{value}->set_text ($val); |
2966 | } |
2998 | } |
2967 | |
2999 | |
2968 | ############################################################################# |
3000 | ############################################################################# |
2969 | |
3001 | |
2970 | package CFPlus::UI::Slider; |
3002 | package DC::UI::Slider; |
2971 | |
3003 | |
2972 | use strict; |
3004 | use strict; |
2973 | |
3005 | |
2974 | use CFPlus::OpenGL; |
3006 | use DC::OpenGL; |
2975 | |
3007 | |
2976 | our @ISA = CFPlus::UI::DrawBG::; |
3008 | our @ISA = DC::UI::DrawBG::; |
2977 | |
3009 | |
2978 | my @tex = |
3010 | my @tex = |
2979 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_ } |
3011 | map { new_from_file DC::Texture DC::find_rcfile $_ } |
2980 | qw(s1_slider.png s1_slider_bg.png); |
3012 | qw(s1_slider.png s1_slider_bg.png); |
2981 | |
3013 | |
2982 | sub new { |
3014 | sub new { |
2983 | my $class = shift; |
3015 | my $class = shift; |
2984 | |
3016 | |
… | |
… | |
3080 | sub invoke_mouse_wheel { |
3112 | sub invoke_mouse_wheel { |
3081 | my ($self, $ev) = @_; |
3113 | my ($self, $ev) = @_; |
3082 | |
3114 | |
3083 | my $delta = $self->{vertical} ? $ev->{dy} : $ev->{dx}; |
3115 | my $delta = $self->{vertical} ? $ev->{dy} : $ev->{dx}; |
3084 | |
3116 | |
3085 | my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; |
3117 | my $pagepart = $ev->{mod} & DC::KMOD_SHIFT ? 1 : 0.2; |
3086 | |
3118 | |
3087 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); |
3119 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); |
3088 | |
3120 | |
3089 | 1 |
3121 | 1 |
3090 | } |
3122 | } |
… | |
… | |
3143 | glDisable GL_TEXTURE_2D; |
3175 | glDisable GL_TEXTURE_2D; |
3144 | } |
3176 | } |
3145 | |
3177 | |
3146 | ############################################################################# |
3178 | ############################################################################# |
3147 | |
3179 | |
3148 | package CFPlus::UI::ValSlider; |
3180 | package DC::UI::ValSlider; |
3149 | |
3181 | |
3150 | our @ISA = CFPlus::UI::HBox::; |
3182 | our @ISA = DC::UI::HBox::; |
3151 | |
3183 | |
3152 | sub new { |
3184 | sub new { |
3153 | my ($class, %arg) = @_; |
3185 | my ($class, %arg) = @_; |
3154 | |
3186 | |
3155 | my $range = delete $arg{range}; |
3187 | my $range = delete $arg{range}; |
3156 | |
3188 | |
3157 | my $self = $class->SUPER::new ( |
3189 | my $self = $class->SUPER::new ( |
3158 | slider => (new CFPlus::UI::Slider expand => 1, range => $range), |
3190 | slider => (new DC::UI::Slider expand => 1, range => $range), |
3159 | entry => (new CFPlus::UI::Label text => "", template => delete $arg{template}), |
3191 | entry => (new DC::UI::Label text => "", template => delete $arg{template}), |
3160 | to_value => sub { shift }, |
3192 | to_value => sub { shift }, |
3161 | from_value => sub { shift }, |
3193 | from_value => sub { shift }, |
3162 | %arg, |
3194 | %arg, |
3163 | ); |
3195 | ); |
3164 | |
3196 | |
… | |
… | |
3184 | sub set_range { shift->{slider}->set_range (@_) } |
3216 | sub set_range { shift->{slider}->set_range (@_) } |
3185 | sub set_value { shift->{slider}->set_value (@_) } |
3217 | sub set_value { shift->{slider}->set_value (@_) } |
3186 | |
3218 | |
3187 | ############################################################################# |
3219 | ############################################################################# |
3188 | |
3220 | |
3189 | package CFPlus::UI::TextScroller; |
3221 | package DC::UI::TextScroller; |
3190 | |
3222 | |
3191 | our @ISA = CFPlus::UI::HBox::; |
3223 | our @ISA = DC::UI::HBox::; |
3192 | |
3224 | |
3193 | use CFPlus::OpenGL; |
3225 | use DC::OpenGL; |
3194 | |
3226 | |
3195 | sub new { |
3227 | sub new { |
3196 | my $class = shift; |
3228 | my $class = shift; |
3197 | |
3229 | |
3198 | my $self = $class->SUPER::new ( |
3230 | my $self = $class->SUPER::new ( |
… | |
… | |
3200 | can_events => 1, |
3232 | can_events => 1, |
3201 | indent => 0, |
3233 | indent => 0, |
3202 | #font => default_font |
3234 | #font => default_font |
3203 | @_, |
3235 | @_, |
3204 | |
3236 | |
3205 | layout => (new CFPlus::Layout), |
3237 | layout => (new DC::Layout), |
3206 | par => [], |
3238 | par => [], |
3207 | max_par => 0, |
3239 | max_par => 0, |
3208 | height => 0, |
3240 | height => 0, |
3209 | children => [ |
3241 | children => [ |
3210 | (new CFPlus::UI::Empty expand => 1), |
3242 | (new DC::UI::Empty expand => 1), |
3211 | (new CFPlus::UI::Slider vertical => 1), |
3243 | (new DC::UI::Slider vertical => 1), |
3212 | ], |
3244 | ], |
3213 | ); |
3245 | ); |
3214 | |
3246 | |
3215 | $self->{children}[1]->connect (changed => sub { $self->update }); |
3247 | $self->{children}[1]->connect (changed => sub { $self->update }); |
3216 | |
3248 | |
… | |
… | |
3399 | $ROOT->on_post_alloc ($self => sub { |
3431 | $ROOT->on_post_alloc ($self => sub { |
3400 | $self->force_uptodate; |
3432 | $self->force_uptodate; |
3401 | |
3433 | |
3402 | my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; |
3434 | my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; |
3403 | |
3435 | |
3404 | $self->{texture} ||= new_from_opengl CFPlus::Texture $W, $H, sub { |
3436 | $self->{texture} ||= new_from_opengl DC::Texture $W, $H, sub { |
3405 | glClearColor 0, 0, 0, 0; |
3437 | glClearColor 0, 0, 0, 0; |
3406 | glClear GL_COLOR_BUFFER_BIT; |
3438 | glClear GL_COLOR_BUFFER_BIT; |
3407 | |
3439 | |
3408 | package CFPlus::UI::Base; |
3440 | package DC::UI::Base; |
3409 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
3441 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
3410 | (0, 0, $self->{w}, $self->{h}); |
3442 | (0, 0, $self->{w}, $self->{h}); |
3411 | |
3443 | |
3412 | my $top = int $self->{children}[1]{range}[0]; |
3444 | my $top = int $self->{children}[1]{range}[0]; |
3413 | |
3445 | |
… | |
… | |
3472 | $self->{children}[1]->draw; |
3504 | $self->{children}[1]->draw; |
3473 | } |
3505 | } |
3474 | |
3506 | |
3475 | ############################################################################# |
3507 | ############################################################################# |
3476 | |
3508 | |
3477 | package CFPlus::UI::Animator; |
3509 | package DC::UI::Animator; |
3478 | |
3510 | |
3479 | use CFPlus::OpenGL; |
3511 | use DC::OpenGL; |
3480 | |
3512 | |
3481 | our @ISA = CFPlus::UI::Bin::; |
3513 | our @ISA = DC::UI::Bin::; |
3482 | |
3514 | |
3483 | sub moveto { |
3515 | sub moveto { |
3484 | my ($self, $x, $y) = @_; |
3516 | my ($self, $x, $y) = @_; |
3485 | |
3517 | |
3486 | $self->{moveto} = [$self->{x}, $self->{y}, $x, $y]; |
3518 | $self->{moveto} = [$self->{x}, $self->{y}, $x, $y]; |
… | |
… | |
3514 | glPopMatrix; |
3546 | glPopMatrix; |
3515 | } |
3547 | } |
3516 | |
3548 | |
3517 | ############################################################################# |
3549 | ############################################################################# |
3518 | |
3550 | |
3519 | package CFPlus::UI::Flopper; |
3551 | package DC::UI::Flopper; |
3520 | |
3552 | |
3521 | our @ISA = CFPlus::UI::Button::; |
3553 | our @ISA = DC::UI::Button::; |
3522 | |
3554 | |
3523 | sub new { |
3555 | sub new { |
3524 | my $class = shift; |
3556 | my $class = shift; |
3525 | |
3557 | |
3526 | my $self = $class->SUPER::new ( |
3558 | my $self = $class->SUPER::new ( |
… | |
… | |
3538 | $self->{other}->toggle_visibility; |
3570 | $self->{other}->toggle_visibility; |
3539 | } |
3571 | } |
3540 | |
3572 | |
3541 | ############################################################################# |
3573 | ############################################################################# |
3542 | |
3574 | |
3543 | package CFPlus::UI::Tooltip; |
3575 | package DC::UI::Tooltip; |
3544 | |
3576 | |
3545 | our @ISA = CFPlus::UI::Bin::; |
3577 | our @ISA = DC::UI::Bin::; |
3546 | |
3578 | |
3547 | use CFPlus::OpenGL; |
3579 | use DC::OpenGL; |
3548 | |
3580 | |
3549 | sub new { |
3581 | sub new { |
3550 | my $class = shift; |
3582 | my $class = shift; |
3551 | |
3583 | |
3552 | $class->SUPER::new ( |
3584 | $class->SUPER::new ( |
… | |
… | |
3556 | } |
3588 | } |
3557 | |
3589 | |
3558 | sub set_tooltip_from { |
3590 | sub set_tooltip_from { |
3559 | my ($self, $widget) = @_; |
3591 | my ($self, $widget) = @_; |
3560 | |
3592 | |
3561 | $widget->{tooltip} = CFPlus::Pod::section_label tooltip => $1 |
|
|
3562 | if $widget->{tooltip} =~ /^#(.*)$/; |
|
|
3563 | |
|
|
3564 | my $tooltip = $widget->{tooltip}; |
3593 | my $tip = $widget->{tooltip}; |
|
|
3594 | $tip = $tip->($widget) if "CODE" eq ref $tip; |
|
|
3595 | |
|
|
3596 | $tip = DC::Pod::section_label tooltip => $1 |
|
|
3597 | if $tip =~ /^#(.*)$/; |
3565 | |
3598 | |
3566 | if ($ENV{CFPLUS_DEBUG} & 2) { |
3599 | if ($ENV{CFPLUS_DEBUG} & 2) { |
3567 | $tooltip .= "\n\n" . (ref $widget) . "\n" |
3600 | $tip .= "\n\n" . (ref $widget) . "\n" |
3568 | . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n" |
3601 | . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n" |
3569 | . "req $widget->{req_w} $widget->{req_h}\n" |
3602 | . "req $widget->{req_w} $widget->{req_h}\n" |
3570 | . "visible $widget->{visible}"; |
3603 | . "visible $widget->{visible}"; |
3571 | } |
3604 | } |
3572 | |
3605 | |
3573 | $tooltip =~ s/^\n+//; |
3606 | $tip =~ s/^\n+//; |
3574 | $tooltip =~ s/\n+$//; |
3607 | $tip =~ s/\n+$//; |
3575 | |
3608 | |
3576 | $self->add (new CFPlus::UI::Label |
3609 | $self->add (new DC::UI::Label |
3577 | markup => $tooltip, |
3610 | markup => $tip, |
3578 | max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, |
3611 | max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, |
3579 | fontsize => 0.8, |
3612 | fontsize => 0.8, |
3580 | style => 1, # FLAG_INVERSE |
3613 | style => 1, # FLAG_INVERSE |
3581 | ellipsise => 0, |
3614 | ellipsise => 0, |
3582 | font => ($widget->{tooltip_font} || $::FONT_PROP), |
3615 | font => ($widget->{tooltip_font} || $::FONT_PROP), |
… | |
… | |
3620 | } |
3653 | } |
3621 | |
3654 | |
3622 | sub _draw { |
3655 | sub _draw { |
3623 | my ($self) = @_; |
3656 | my ($self) = @_; |
3624 | |
3657 | |
3625 | glTranslate 0.375, 0.375; |
|
|
3626 | |
|
|
3627 | my ($w, $h) = @$self{qw(w h)}; |
3658 | my ($w, $h) = @$self{qw(w h)}; |
3628 | |
3659 | |
3629 | glColor 1, 0.8, 0.4; |
3660 | glColor 1, 0.8, 0.4; |
3630 | glRect 0, 0, $w, $h; |
3661 | glRect 0, 0, $w, $h; |
3631 | |
3662 | |
3632 | glColor 0, 0, 0; |
3663 | glColor 0, 0, 0; |
3633 | glRect_lineloop 0, 0, $w, $h; |
3664 | glRect_lineloop .5, .5, $w + .5, $h + .5; |
3634 | |
3665 | |
3635 | glTranslate 2 - 0.375, 2 - 0.375; |
3666 | glTranslate 2, 2; |
3636 | |
3667 | |
3637 | $self->SUPER::_draw; |
3668 | $self->SUPER::_draw; |
3638 | } |
3669 | } |
3639 | |
3670 | |
3640 | ############################################################################# |
3671 | ############################################################################# |
3641 | |
3672 | |
3642 | package CFPlus::UI::Face; |
3673 | package DC::UI::Face; |
3643 | |
3674 | |
3644 | our @ISA = CFPlus::UI::DrawBG::; |
3675 | our @ISA = DC::UI::DrawBG::; |
3645 | |
3676 | |
3646 | use CFPlus::OpenGL; |
3677 | use DC::OpenGL; |
3647 | |
3678 | |
3648 | sub new { |
3679 | sub new { |
3649 | my $class = shift; |
3680 | my $class = shift; |
3650 | |
3681 | |
3651 | my $self = $class->SUPER::new ( |
3682 | my $self = $class->SUPER::new ( |
… | |
… | |
3655 | can_events => 0, |
3686 | can_events => 0, |
3656 | @_, |
3687 | @_, |
3657 | ); |
3688 | ); |
3658 | |
3689 | |
3659 | if ($self->{anim} && $self->{animspeed}) { |
3690 | if ($self->{anim} && $self->{animspeed}) { |
3660 | CFPlus::weaken (my $widget = $self); |
3691 | DC::weaken (my $widget = $self); |
3661 | |
3692 | |
3662 | $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; |
3693 | $self->{animspeed} = List::Util::max 0.05, $self->{animspeed}; |
3663 | $widget->{anim_start} = $self->{animspeed} * int Event::time / $self->{animspeed}; |
3694 | $self->{timer} = EV::periodic_ns 0, $self->{animspeed}, undef, sub { |
3664 | $self->{timer} = Event->timer ( |
|
|
3665 | parked => 1, |
|
|
3666 | cb => sub { |
|
|
3667 | return unless $::CONN; |
3695 | return unless $::CONN; |
3668 | |
3696 | |
3669 | my $w = $widget |
3697 | my $w = $widget |
3670 | or return; |
3698 | or return; |
3671 | |
3699 | |
3672 | ++$w->{frame}; |
3700 | ++$w->{frame}; |
3673 | $w->update_face; |
3701 | $w->update_face; |
3674 | |
3702 | |
3675 | # somehow, $widget can go away |
3703 | # somehow, $widget can go away |
3676 | $w->update; |
3704 | $w->update; |
3677 | $w->update_timer; |
3705 | $w->update_timer; |
3678 | }, |
|
|
3679 | ); |
3706 | }; |
3680 | |
3707 | |
3681 | $self->update_face; |
3708 | $self->update_face; |
3682 | $self->update_timer; |
3709 | $self->update_timer; |
3683 | } |
3710 | } |
3684 | |
3711 | |
… | |
… | |
3689 | my ($self) = @_; |
3716 | my ($self) = @_; |
3690 | |
3717 | |
3691 | return unless $self->{timer}; |
3718 | return unless $self->{timer}; |
3692 | |
3719 | |
3693 | if ($self->{visible}) { |
3720 | if ($self->{visible}) { |
3694 | $self->{timer}->at ( |
|
|
3695 | $self->{anim_start} |
|
|
3696 | + $self->{animspeed} |
|
|
3697 | * int 1.5 + (Event::time - $self->{anim_start}) / $self->{animspeed} |
|
|
3698 | ); |
|
|
3699 | $self->{timer}->start; |
3721 | $self->{timer}->start; |
3700 | } else { |
3722 | } else { |
3701 | $self->{timer}->stop; |
3723 | $self->{timer}->stop; |
3702 | } |
3724 | } |
3703 | } |
3725 | } |
… | |
… | |
3780 | $self->SUPER::destroy; |
3802 | $self->SUPER::destroy; |
3781 | } |
3803 | } |
3782 | |
3804 | |
3783 | ############################################################################# |
3805 | ############################################################################# |
3784 | |
3806 | |
3785 | package CFPlus::UI::Buttonbar; |
3807 | package DC::UI::Buttonbar; |
3786 | |
3808 | |
3787 | our @ISA = CFPlus::UI::HBox::; |
3809 | our @ISA = DC::UI::HBox::; |
3788 | |
3810 | |
3789 | # TODO: should actually wrap buttons and other goodies. |
3811 | # TODO: should actually wrap buttons and other goodies. |
3790 | |
3812 | |
3791 | ############################################################################# |
3813 | ############################################################################# |
3792 | |
3814 | |
3793 | package CFPlus::UI::Menu; |
3815 | package DC::UI::Menu; |
3794 | |
3816 | |
3795 | our @ISA = CFPlus::UI::Toplevel::; |
3817 | our @ISA = DC::UI::Toplevel::; |
3796 | |
3818 | |
3797 | use CFPlus::OpenGL; |
3819 | use DC::OpenGL; |
3798 | |
3820 | |
3799 | sub new { |
3821 | sub new { |
3800 | my $class = shift; |
3822 | my $class = shift; |
3801 | |
3823 | |
3802 | my $self = $class->SUPER::new ( |
3824 | my $self = $class->SUPER::new ( |
3803 | items => [], |
3825 | items => [], |
3804 | z => 100, |
3826 | z => 100, |
3805 | @_, |
3827 | @_, |
3806 | ); |
3828 | ); |
3807 | |
3829 | |
3808 | $self->add ($self->{vbox} = new CFPlus::UI::VBox); |
3830 | $self->add ($self->{vbox} = new DC::UI::VBox); |
3809 | |
3831 | |
3810 | for my $item (@{ $self->{items} }) { |
3832 | for my $item (@{ $self->{items} }) { |
3811 | my ($widget, $cb, $tooltip) = @$item; |
3833 | my ($widget, $cb, $tooltip) = @$item; |
3812 | |
3834 | |
3813 | # handle various types of items, only text for now |
3835 | # handle various types of items, only text for now |
3814 | if (!ref $widget) { |
3836 | if (!ref $widget) { |
3815 | if ($widget =~ /\t/) { |
3837 | if ($widget =~ /\t/) { |
3816 | my ($left, $right) = split /\t/, $widget, 2; |
3838 | my ($left, $right) = split /\t/, $widget, 2; |
3817 | |
3839 | |
3818 | $widget = new CFPlus::UI::HBox |
3840 | $widget = new DC::UI::HBox |
3819 | can_hover => 1, |
3841 | can_hover => 1, |
3820 | can_events => 1, |
3842 | can_events => 1, |
3821 | tooltip => $tooltip, |
3843 | tooltip => $tooltip, |
3822 | children => [ |
3844 | children => [ |
3823 | (new CFPlus::UI::Label markup => $left, expand => 1), |
3845 | (new DC::UI::Label markup => $left, expand => 1), |
3824 | (new CFPlus::UI::Label markup => $right, align => +1), |
3846 | (new DC::UI::Label markup => $right, align => +1), |
3825 | ], |
3847 | ], |
3826 | ; |
3848 | ; |
3827 | |
3849 | |
3828 | } else { |
3850 | } else { |
3829 | $widget = new CFPlus::UI::Label |
3851 | $widget = new DC::UI::Label |
3830 | can_hover => 1, |
3852 | can_hover => 1, |
3831 | can_events => 1, |
3853 | can_events => 1, |
3832 | markup => $widget, |
3854 | markup => $widget, |
3833 | tooltip => $tooltip; |
3855 | tooltip => $tooltip; |
3834 | } |
3856 | } |
… | |
… | |
3882 | 1 |
3904 | 1 |
3883 | } |
3905 | } |
3884 | |
3906 | |
3885 | ############################################################################# |
3907 | ############################################################################# |
3886 | |
3908 | |
3887 | package CFPlus::UI::Multiplexer; |
3909 | package DC::UI::Multiplexer; |
3888 | |
3910 | |
3889 | our @ISA = CFPlus::UI::Container::; |
3911 | our @ISA = DC::UI::Container::; |
3890 | |
3912 | |
3891 | sub new { |
3913 | sub new { |
3892 | my $class = shift; |
3914 | my $class = shift; |
3893 | |
3915 | |
3894 | my $self = $class->SUPER::new ( |
3916 | my $self = $class->SUPER::new ( |
… | |
… | |
3955 | $self->{current}->draw; |
3977 | $self->{current}->draw; |
3956 | } |
3978 | } |
3957 | |
3979 | |
3958 | ############################################################################# |
3980 | ############################################################################# |
3959 | |
3981 | |
3960 | package CFPlus::UI::Notebook; |
3982 | package DC::UI::Notebook; |
3961 | |
3983 | |
3962 | use CFPlus::OpenGL; |
3984 | use DC::OpenGL; |
3963 | |
3985 | |
3964 | our @ISA = CFPlus::UI::VBox::; |
3986 | our @ISA = DC::UI::VBox::; |
3965 | |
3987 | |
3966 | sub new { |
3988 | sub new { |
3967 | my $class = shift; |
3989 | my $class = shift; |
3968 | |
3990 | |
3969 | my $self = $class->SUPER::new ( |
3991 | my $self = $class->SUPER::new ( |
3970 | buttonbar => (new CFPlus::UI::Buttonbar), |
3992 | buttonbar => (new DC::UI::Buttonbar), |
3971 | multiplexer => (new CFPlus::UI::Multiplexer expand => 1), |
3993 | multiplexer => (new DC::UI::Multiplexer expand => 1), |
3972 | active_outline => [1, 1, 0], |
3994 | active_outline => [.7, .7, 0.2], |
3973 | # filter => # will be put between multiplexer and $self |
3995 | # filter => # will be put between multiplexer and $self |
3974 | @_, |
3996 | @_, |
3975 | ); |
3997 | ); |
3976 | |
3998 | |
3977 | $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; |
3999 | $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; |
… | |
… | |
3985 | |
4007 | |
3986 | for my $child (@$widgets) { |
4008 | for my $child (@$widgets) { |
3987 | Scalar::Util::weaken $child; |
4009 | Scalar::Util::weaken $child; |
3988 | $child->{c_tab_} ||= do { |
4010 | $child->{c_tab_} ||= do { |
3989 | my $tab = |
4011 | my $tab = |
3990 | (UNIVERSAL::isa $child->{c_tab}, "CFPlus::UI::Base") |
4012 | (UNIVERSAL::isa $child->{c_tab}, "DC::UI::Base") |
3991 | ? $child->{c_tab} |
4013 | ? $child->{c_tab} |
3992 | : new CFPlus::UI::Button markup => $child->{c_tab}[0], tooltip => $child->{c_tab}[1]; |
4014 | : new DC::UI::Button markup => $child->{c_tab}[0], tooltip => $child->{c_tab}[1]; |
3993 | |
4015 | |
3994 | $tab->connect (activate => sub { |
4016 | $tab->connect (activate => sub { |
3995 | $wself->set_current_page ($child); |
4017 | $wself->set_current_page ($child); |
3996 | }); |
4018 | }); |
3997 | |
4019 | |
… | |
… | |
4058 | |
4080 | |
4059 | $self->SUPER::_draw (); |
4081 | $self->SUPER::_draw (); |
4060 | |
4082 | |
4061 | if (my $cur = $self->{multiplexer}{current}) { |
4083 | if (my $cur = $self->{multiplexer}{current}) { |
4062 | if ($cur = $cur->{c_tab_}) { |
4084 | if ($cur = $cur->{c_tab_}) { |
4063 | glTranslate $cur->{x}, $cur->{y}; |
4085 | glTranslate $self->{buttonbar}{x} + $cur->{x}, |
|
|
4086 | $self->{buttonbar}{y} + $cur->{y}; |
4064 | glLineWidth 3; |
4087 | glLineWidth 3; |
|
|
4088 | #glEnable GL_BLEND; |
|
|
4089 | #glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
4065 | glColor @{$self->{active_outline}}; |
4090 | glColor @{$self->{active_outline}}; |
4066 | glRect_lineloop 1, 1, $cur->{w} - 2, $cur->{h} - 2; |
4091 | glRect_lineloop 1.5, 1.5, $cur->{w} - 1.5, $cur->{h} - 1.5; |
4067 | glLineWidth 1; |
4092 | glLineWidth 1; |
|
|
4093 | #glDisable GL_BLEND; |
4068 | } |
4094 | } |
4069 | } |
4095 | } |
4070 | } |
4096 | } |
4071 | |
4097 | |
4072 | ############################################################################# |
4098 | ############################################################################# |
4073 | |
4099 | |
4074 | package CFPlus::UI::Selector; |
4100 | package DC::UI::Selector; |
4075 | |
4101 | |
4076 | use utf8; |
4102 | use utf8; |
4077 | |
4103 | |
4078 | our @ISA = CFPlus::UI::Button::; |
4104 | our @ISA = DC::UI::Button::; |
4079 | |
4105 | |
4080 | sub new { |
4106 | sub new { |
4081 | my $class = shift; |
4107 | my $class = shift; |
4082 | |
4108 | |
4083 | my $self = $class->SUPER::new ( |
4109 | my $self = $class->SUPER::new ( |
… | |
… | |
4100 | my ($value, $title, $tooltip) = @$_; |
4126 | my ($value, $title, $tooltip) = @$_; |
4101 | |
4127 | |
4102 | push @menu_items, [$tooltip || $title, sub { $self->set_value ($value) }]; |
4128 | push @menu_items, [$tooltip || $title, sub { $self->set_value ($value) }]; |
4103 | } |
4129 | } |
4104 | |
4130 | |
4105 | CFPlus::UI::Menu->new (items => \@menu_items)->popup ($ev); |
4131 | DC::UI::Menu->new (items => \@menu_items)->popup ($ev); |
4106 | } |
4132 | } |
4107 | |
4133 | |
4108 | sub _set_value { |
4134 | sub _set_value { |
4109 | my ($self, $value) = @_; |
4135 | my ($self, $value) = @_; |
4110 | |
4136 | |
4111 | my ($item) = grep $_->[0] eq $value, @{ $self->{options} } |
4137 | my ($item) = grep $_->[0] eq $value, @{ $self->{options} }; |
|
|
4138 | $item ||= $self->{options}[0] |
4112 | or return; |
4139 | or return; |
4113 | |
4140 | |
4114 | $self->{value} = $item->[0]; |
4141 | $self->{value} = $item->[0]; |
4115 | $self->set_markup ("$item->[1] ⇓"); |
4142 | $self->set_markup ("$item->[1] ⇓"); |
4116 | $self->set_tooltip ($item->[2]); |
4143 | # $self->set_tooltip ($item->[2]); |
4117 | } |
4144 | } |
4118 | |
4145 | |
4119 | sub set_value { |
4146 | sub set_value { |
4120 | my ($self, $value) = @_; |
4147 | my ($self, $value) = @_; |
4121 | |
4148 | |
… | |
… | |
4123 | |
4150 | |
4124 | $self->_set_value ($value); |
4151 | $self->_set_value ($value); |
4125 | $self->emit (changed => $value); |
4152 | $self->emit (changed => $value); |
4126 | } |
4153 | } |
4127 | |
4154 | |
|
|
4155 | sub set_options { |
|
|
4156 | my ($self, $options) = @_; |
|
|
4157 | |
|
|
4158 | $self->{options} = $options; |
|
|
4159 | $self->_set_value ($self->{value}); |
|
|
4160 | } |
|
|
4161 | |
4128 | ############################################################################# |
4162 | ############################################################################# |
4129 | |
4163 | |
4130 | package CFPlus::UI::Statusbox; |
4164 | package DC::UI::Statusbox; |
4131 | |
4165 | |
4132 | our @ISA = CFPlus::UI::VBox::; |
4166 | our @ISA = DC::UI::VBox::; |
4133 | |
4167 | |
4134 | sub new { |
4168 | sub new { |
4135 | my $class = shift; |
4169 | my $class = shift; |
4136 | |
4170 | |
4137 | my $self = $class->SUPER::new ( |
4171 | my $self = $class->SUPER::new ( |
4138 | fontsize => 0.8, |
4172 | fontsize => 0.8, |
4139 | @_, |
4173 | @_, |
4140 | ); |
4174 | ); |
4141 | |
4175 | |
4142 | CFPlus::weaken (my $this = $self); |
4176 | DC::weaken (my $this = $self); |
4143 | |
4177 | |
4144 | $self->{timer} = Event->timer (after => 1, interval => 1, cb => sub { $this->reorder }); |
4178 | $self->{timer} = EV::timer 1, 1, sub { $this->reorder }; |
4145 | |
4179 | |
4146 | $self |
4180 | $self |
4147 | } |
4181 | } |
4148 | |
4182 | |
4149 | sub reorder { |
4183 | sub reorder { |
4150 | my ($self) = @_; |
4184 | my ($self) = @_; |
4151 | my $NOW = Time::HiRes::time; |
4185 | my $NOW = Time::HiRes::time; |
4152 | |
4186 | |
4153 | # freeze display when hovering over any label |
4187 | # freeze display when hovering over any label |
4154 | return if $CFPlus::UI::TOOLTIP->{owner} |
4188 | return if $DC::UI::TOOLTIP->{owner} |
4155 | && grep $CFPlus::UI::TOOLTIP->{owner} == $_->{label}, |
4189 | && grep $DC::UI::TOOLTIP->{owner} == $_->{label}, |
4156 | values %{ $self->{item} }; |
4190 | values %{ $self->{item} }; |
4157 | |
4191 | |
4158 | while (my ($k, $v) = each %{ $self->{item} }) { |
4192 | while (my ($k, $v) = each %{ $self->{item} }) { |
4159 | delete $self->{item}{$k} if $v->{timeout} < $NOW; |
4193 | delete $self->{item}{$k} if $v->{timeout} < $NOW; |
4160 | } |
4194 | } |
|
|
4195 | |
|
|
4196 | $self->{timer}->set (1, 1); |
4161 | |
4197 | |
4162 | my @widgets; |
4198 | my @widgets; |
4163 | |
4199 | |
4164 | my @items = sort { |
4200 | my @items = sort { |
4165 | $a->{pri} <=> $b->{pri} |
4201 | $a->{pri} <=> $b->{pri} |
4166 | or $b->{id} <=> $a->{id} |
4202 | or $b->{id} <=> $a->{id} |
4167 | } values %{ $self->{item} }; |
4203 | } values %{ $self->{item} }; |
4168 | |
|
|
4169 | $self->{timer}->interval (1); |
|
|
4170 | |
4204 | |
4171 | my $count = 10 + 1; |
4205 | my $count = 10 + 1; |
4172 | for my $item (@items) { |
4206 | for my $item (@items) { |
4173 | last unless --$count; |
4207 | last unless --$count; |
4174 | |
4208 | |
… | |
… | |
4181 | for ($short) { |
4215 | for ($short) { |
4182 | s/^\s+//; |
4216 | s/^\s+//; |
4183 | s/\s+/ /g; |
4217 | s/\s+/ /g; |
4184 | } |
4218 | } |
4185 | |
4219 | |
4186 | new CFPlus::UI::Label |
4220 | new DC::UI::Label |
4187 | markup => $short, |
4221 | markup => $short, |
4188 | tooltip => $item->{tooltip}, |
4222 | tooltip => $item->{tooltip}, |
4189 | tooltip_font => $::FONT_PROP, |
4223 | tooltip_font => $::FONT_PROP, |
4190 | tooltip_width => 0.67, |
4224 | tooltip_width => 0.67, |
4191 | fontsize => $item->{fontsize} || $self->{fontsize}, |
4225 | fontsize => $item->{fontsize} || $self->{fontsize}, |
… | |
… | |
4198 | if ((my $diff = $item->{timeout} - $NOW) < 2) { |
4232 | if ((my $diff = $item->{timeout} - $NOW) < 2) { |
4199 | $label->{fg}[3] = ($item->{fg}[3] || 1) * $diff / 2; |
4233 | $label->{fg}[3] = ($item->{fg}[3] || 1) * $diff / 2; |
4200 | $label->update; |
4234 | $label->update; |
4201 | $label->set_max_size (undef, $label->{req_h} * $diff) |
4235 | $label->set_max_size (undef, $label->{req_h} * $diff) |
4202 | if $diff < 1; |
4236 | if $diff < 1; |
4203 | $self->{timer}->interval (1/30); |
4237 | $self->{timer}->set (1/30, 1/30); |
4204 | } else { |
4238 | } else { |
4205 | $label->{fg}[3] = $item->{fg}[3] || 1; |
4239 | $label->{fg}[3] = $item->{fg}[3] || 1; |
4206 | } |
4240 | } |
4207 | |
4241 | |
4208 | push @widgets, $label; |
4242 | push @widgets, $label; |
… | |
… | |
4270 | $self->SUPER::destroy; |
4304 | $self->SUPER::destroy; |
4271 | } |
4305 | } |
4272 | |
4306 | |
4273 | ############################################################################# |
4307 | ############################################################################# |
4274 | |
4308 | |
4275 | package CFPlus::UI::Root; |
4309 | package DC::UI::Root; |
4276 | |
4310 | |
4277 | our @ISA = CFPlus::UI::Container::; |
4311 | our @ISA = DC::UI::Container::; |
4278 | |
4312 | |
4279 | use List::Util qw(min max); |
4313 | use List::Util qw(min max); |
4280 | |
4314 | |
4281 | use CFPlus::OpenGL; |
4315 | use DC::OpenGL; |
4282 | |
4316 | |
4283 | sub new { |
4317 | sub new { |
4284 | my $class = shift; |
4318 | my $class = shift; |
4285 | |
4319 | |
4286 | my $self = $class->SUPER::new ( |
4320 | my $self = $class->SUPER::new ( |
4287 | visible => 1, |
4321 | visible => 1, |
4288 | @_, |
4322 | @_, |
4289 | ); |
4323 | ); |
4290 | |
4324 | |
4291 | CFPlus::weaken ($self->{root} = $self); |
4325 | DC::weaken ($self->{root} = $self); |
4292 | |
4326 | |
4293 | $self |
4327 | $self |
4294 | } |
4328 | } |
4295 | |
4329 | |
4296 | sub size_request { |
4330 | sub size_request { |
… | |
… | |
4344 | } |
4378 | } |
4345 | |
4379 | |
4346 | sub update { |
4380 | sub update { |
4347 | my ($self) = @_; |
4381 | my ($self) = @_; |
4348 | |
4382 | |
4349 | $::WANT_REFRESH->start; |
4383 | $::WANT_REFRESH = 1; |
4350 | } |
4384 | } |
4351 | |
4385 | |
4352 | sub add { |
4386 | sub add { |
4353 | my ($self, @children) = @_; |
4387 | my ($self, @children) = @_; |
4354 | |
4388 | |
… | |
… | |
4499 | glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000, 10000; |
4533 | glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000, 10000; |
4500 | glMatrixMode GL_MODELVIEW; |
4534 | glMatrixMode GL_MODELVIEW; |
4501 | glLoadIdentity; |
4535 | glLoadIdentity; |
4502 | |
4536 | |
4503 | { |
4537 | { |
4504 | package CFPlus::UI::Base; |
4538 | package DC::UI::Base; |
4505 | |
4539 | |
4506 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
4540 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
4507 | (0, 0, $self->{w}, $self->{h}); |
4541 | (0, 0, $self->{w}, $self->{h}); |
4508 | |
4542 | |
4509 | $self->_draw; |
4543 | $self->_draw; |
4510 | } |
4544 | } |
4511 | } |
4545 | } |
4512 | |
4546 | |
4513 | ############################################################################# |
4547 | ############################################################################# |
4514 | |
4548 | |
4515 | package CFPlus::UI; |
4549 | package DC::UI; |
4516 | |
4550 | |
4517 | $ROOT = new CFPlus::UI::Root; |
4551 | $ROOT = new DC::UI::Root; |
4518 | $TOOLTIP = new CFPlus::UI::Tooltip z => 900; |
4552 | $TOOLTIP = new DC::UI::Tooltip z => 900; |
4519 | |
4553 | |
4520 | 1 |
4554 | 1 |
4521 | |
4555 | |