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 | |
7 | |
8 | use CFPlus; |
8 | use DC; |
9 | use CFPlus::Pod; |
9 | use DC::Pod; |
10 | use CFPlus::Texture; |
10 | use DC::Texture; |
11 | |
11 | |
12 | our ($FOCUS, $HOVER, $GRAB); # various widgets |
12 | our ($FOCUS, $HOVER, $GRAB); # various widgets |
13 | |
13 | |
14 | our $LAYOUT; |
14 | our $LAYOUT; |
15 | our $ROOT; |
15 | our $ROOT; |
… | |
… | |
111 | |
111 | |
112 | if ($GRAB) { |
112 | if ($GRAB) { |
113 | if ($ev->{button} == 4 || $ev->{button} == 5) { |
113 | if ($ev->{button} == 4 || $ev->{button} == 5) { |
114 | # mousewheel |
114 | # mousewheel |
115 | my $delta = $ev->{button} * 2 - 9; |
115 | my $delta = $ev->{button} * 2 - 9; |
116 | my $shift = $ev->{mod} & CFPlus::KMOD_SHIFT; |
116 | my $shift = $ev->{mod} & DC::KMOD_SHIFT; |
117 | |
117 | |
118 | $ev->{dx} = $shift ? $delta : 0; |
118 | $ev->{dx} = $shift ? $delta : 0; |
119 | $ev->{dy} = $shift ? 0 : $delta; |
119 | $ev->{dy} = $shift ? 0 : $delta; |
120 | |
120 | |
121 | $GRAB->emit (mouse_wheel => $ev); |
121 | $GRAB->emit (mouse_wheel => $ev); |
… | |
… | |
211 | reconfigure_widgets; |
211 | reconfigure_widgets; |
212 | } |
212 | } |
213 | |
213 | |
214 | ############################################################################# |
214 | ############################################################################# |
215 | |
215 | |
216 | package CFPlus::UI::Event; |
216 | package DC::UI::Event; |
217 | |
217 | |
218 | sub xy { |
218 | sub xy { |
219 | $_[1]->coord2local ($_[0]{x}, $_[0]{y}) |
219 | $_[1]->coord2local ($_[0]{x}, $_[0]{y}) |
220 | } |
220 | } |
221 | |
221 | |
222 | ############################################################################# |
222 | ############################################################################# |
223 | |
223 | |
224 | package CFPlus::UI::Base; |
224 | package DC::UI::Base; |
225 | |
225 | |
226 | use strict; |
226 | use strict; |
227 | |
227 | |
228 | use CFPlus::OpenGL; |
228 | use DC::OpenGL; |
229 | |
229 | |
230 | sub new { |
230 | sub new { |
231 | my $class = shift; |
231 | my $class = shift; |
232 | |
232 | |
233 | my $self = bless { |
233 | my $self = bless { |
… | |
… | |
238 | h => undef, |
238 | h => undef, |
239 | can_events => 1, |
239 | can_events => 1, |
240 | @_ |
240 | @_ |
241 | }, $class; |
241 | }, $class; |
242 | |
242 | |
243 | CFPlus::weaken ($CFPlus::UI::WIDGET{$self+0} = $self); |
243 | DC::weaken ($DC::UI::WIDGET{$self+0} = $self); |
244 | |
244 | |
245 | for (keys %$self) { |
245 | for (keys %$self) { |
246 | if (/^on_(.*)$/) { |
246 | if (/^on_(.*)$/) { |
247 | $self->connect ($1 => delete $self->{$_}); |
247 | $self->connect ($1 => delete $self->{$_}); |
248 | } |
248 | } |
249 | } |
249 | } |
250 | |
250 | |
251 | if (my $layout = $CFPlus::UI::LAYOUT->{$self->{name}}) { |
251 | if (my $layout = $DC::UI::LAYOUT->{$self->{name}}) { |
252 | $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}; |
253 | $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}; |
254 | $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}; |
255 | $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}; |
256 | |
256 | |
257 | $self->{x} -= $self->{force_w} * 0.5 if exists $layout->{x}; |
257 | $self->{x} -= $self->{force_w} * 0.5 if exists $layout->{x}; |
258 | $self->{y} -= $self->{force_h} * 0.5 if exists $layout->{y}; |
258 | $self->{y} -= $self->{force_h} * 0.5 if exists $layout->{y}; |
259 | |
259 | |
260 | $self->show if $layout->{show}; |
260 | $self->show if $layout->{show}; |
… | |
… | |
278 | sub show { |
278 | sub show { |
279 | my ($self) = @_; |
279 | my ($self) = @_; |
280 | |
280 | |
281 | return if $self->{parent}; |
281 | return if $self->{parent}; |
282 | |
282 | |
283 | $CFPlus::UI::ROOT->add ($self); |
283 | $DC::UI::ROOT->add ($self); |
284 | } |
284 | } |
285 | |
285 | |
286 | sub set_visible { |
286 | sub set_visible { |
287 | my ($self) = @_; |
287 | my ($self) = @_; |
288 | |
288 | |
… | |
… | |
309 | delete $self->{root}; |
309 | delete $self->{root}; |
310 | |
310 | |
311 | undef $GRAB if $GRAB == $self; |
311 | undef $GRAB if $GRAB == $self; |
312 | undef $HOVER if $HOVER == $self; |
312 | undef $HOVER if $HOVER == $self; |
313 | |
313 | |
314 | $CFPlus::UI::TOOLTIP_WATCHER->invoke |
314 | $DC::UI::TOOLTIP_WATCHER->invoke |
315 | if $TOOLTIP->{owner} == $self; |
315 | if $TOOLTIP->{owner} == $self; |
316 | |
316 | |
317 | $self->emit ("focus_out"); |
317 | $self->emit ("focus_out"); |
318 | $self->emit (visibility_change => 0); |
318 | $self->emit (visibility_change => 0); |
319 | } |
319 | } |
… | |
… | |
338 | sub hide { |
338 | sub hide { |
339 | my ($self) = @_; |
339 | my ($self) = @_; |
340 | |
340 | |
341 | $self->set_invisible; |
341 | $self->set_invisible; |
342 | |
342 | |
|
|
343 | # extra $parent copy for 5.8.8+ bug workaround |
|
|
344 | # (otherwise $_[0] in remove gets freed |
|
|
345 | if (my $parent = $self->{parent}) { |
343 | $self->{parent}->remove ($self) |
346 | $parent->remove ($self); |
344 | if $self->{parent}; |
347 | } |
345 | } |
348 | } |
346 | |
349 | |
347 | sub move_abs { |
350 | sub move_abs { |
348 | my ($self, $x, $y, $z) = @_; |
351 | my ($self, $x, $y, $z) = @_; |
349 | |
352 | |
… | |
… | |
386 | my ($self, $x, $y, $w, $h) = @_; |
389 | my ($self, $x, $y, $w, $h) = @_; |
387 | |
390 | |
388 | if ($self->{aspect}) { |
391 | if ($self->{aspect}) { |
389 | my ($ow, $oh) = ($w, $h); |
392 | my ($ow, $oh) = ($w, $h); |
390 | |
393 | |
391 | $w = List::Util::min $w, CFPlus::ceil $h * $self->{aspect}; |
394 | $w = List::Util::min $w, DC::ceil $h * $self->{aspect}; |
392 | $h = List::Util::min $h, CFPlus::ceil $w / $self->{aspect}; |
395 | $h = List::Util::min $h, DC::ceil $w / $self->{aspect}; |
393 | |
396 | |
394 | # use alignment to adjust x, y |
397 | # use alignment to adjust x, y |
395 | |
398 | |
396 | $x += int 0.5 * ($ow - $w); |
399 | $x += int 0.5 * ($ow - $w); |
397 | $y += int 0.5 * ($oh - $h); |
400 | $y += int 0.5 * ($oh - $h); |
… | |
… | |
438 | |
441 | |
439 | return if $self->{tooltip} eq $tooltip; |
442 | return if $self->{tooltip} eq $tooltip; |
440 | |
443 | |
441 | $self->{tooltip} = $tooltip; |
444 | $self->{tooltip} = $tooltip; |
442 | |
445 | |
443 | if ($CFPlus::UI::TOOLTIP->{owner} == $self) { |
446 | if ($DC::UI::TOOLTIP->{owner} == $self) { |
444 | delete $CFPlus::UI::TOOLTIP->{owner}; |
447 | delete $DC::UI::TOOLTIP->{owner}; |
445 | $CFPlus::UI::TOOLTIP_WATCHER->invoke; |
448 | $DC::UI::TOOLTIP_WATCHER->invoke; |
446 | } |
449 | } |
447 | } |
450 | } |
448 | |
451 | |
449 | # translate global coordinates to local coordinate system |
452 | # translate global coordinates to local coordinate system |
450 | sub coord2local { |
453 | sub coord2local { |
… | |
… | |
516 | sub connect { |
519 | sub connect { |
517 | my ($self, $signal, $cb) = @_; |
520 | my ($self, $signal, $cb) = @_; |
518 | |
521 | |
519 | push @{ $self->{signal_cb}{$signal} }, $cb; |
522 | push @{ $self->{signal_cb}{$signal} }, $cb; |
520 | |
523 | |
521 | defined wantarray and CFPlus::guard { |
524 | defined wantarray and DC::guard { |
522 | @{ $self->{signal_cb}{$signal} } = grep $_ != $cb, |
525 | @{ $self->{signal_cb}{$signal} } = grep $_ != $cb, |
523 | @{ $self->{signal_cb}{$signal} }; |
526 | @{ $self->{signal_cb}{$signal} }; |
524 | } |
527 | } |
525 | } |
528 | } |
526 | |
529 | |
… | |
… | |
564 | # in .xs |
567 | # in .xs |
565 | |
568 | |
566 | sub set_parent { |
569 | sub set_parent { |
567 | my ($self, $parent) = @_; |
570 | my ($self, $parent) = @_; |
568 | |
571 | |
569 | CFPlus::weaken ($self->{parent} = $parent); |
572 | DC::weaken ($self->{parent} = $parent); |
570 | $self->set_visible if $parent->{visible}; |
573 | $self->set_visible if $parent->{visible}; |
571 | } |
574 | } |
572 | |
575 | |
573 | sub realloc { |
576 | sub realloc { |
574 | my ($self) = @_; |
577 | my ($self) = @_; |
… | |
… | |
612 | } |
615 | } |
613 | |
616 | |
614 | sub DESTROY { |
617 | sub DESTROY { |
615 | my ($self) = @_; |
618 | my ($self) = @_; |
616 | |
619 | |
617 | return if CFPlus::in_destruct; |
620 | return if DC::in_destruct; |
618 | |
621 | |
619 | local $@; |
622 | local $@; |
620 | eval { $self->destroy }; |
623 | eval { $self->destroy }; |
621 | warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; |
624 | warn "exception during widget destruction: $@" if $@ & $@ != /during global destruction/; |
622 | |
625 | |
623 | delete $WIDGET{$self+0}; |
626 | delete $WIDGET{$self+0}; |
624 | } |
627 | } |
625 | |
628 | |
626 | ############################################################################# |
629 | ############################################################################# |
627 | |
630 | |
628 | package CFPlus::UI::DrawBG; |
631 | package DC::UI::DrawBG; |
629 | |
632 | |
630 | our @ISA = CFPlus::UI::Base::; |
633 | our @ISA = DC::UI::Base::; |
631 | |
634 | |
632 | use strict; |
635 | use strict; |
633 | use CFPlus::OpenGL; |
636 | use DC::OpenGL; |
634 | |
637 | |
635 | sub new { |
638 | sub new { |
636 | my $class = shift; |
639 | my $class = shift; |
637 | |
640 | |
638 | $class->SUPER::new ( |
641 | $class->SUPER::new ( |
… | |
… | |
660 | } |
663 | } |
661 | } |
664 | } |
662 | |
665 | |
663 | ############################################################################# |
666 | ############################################################################# |
664 | |
667 | |
665 | package CFPlus::UI::Empty; |
668 | package DC::UI::Empty; |
666 | |
669 | |
667 | our @ISA = CFPlus::UI::Base::; |
670 | our @ISA = DC::UI::Base::; |
668 | |
671 | |
669 | sub new { |
672 | sub new { |
670 | my ($class, %arg) = @_; |
673 | my ($class, %arg) = @_; |
671 | $class->SUPER::new (can_events => 0, %arg); |
674 | $class->SUPER::new (can_events => 0, %arg); |
672 | } |
675 | } |
… | |
… | |
679 | |
682 | |
680 | sub draw { } |
683 | sub draw { } |
681 | |
684 | |
682 | ############################################################################# |
685 | ############################################################################# |
683 | |
686 | |
684 | package CFPlus::UI::Container; |
687 | package DC::UI::Container; |
685 | |
688 | |
686 | our @ISA = CFPlus::UI::Base::; |
689 | our @ISA = DC::UI::Base::; |
687 | |
690 | |
688 | sub new { |
691 | sub new { |
689 | my ($class, %arg) = @_; |
692 | my ($class, %arg) = @_; |
690 | |
693 | |
691 | my $children = delete $arg{children}; |
694 | my $children = delete $arg{children}; |
… | |
… | |
785 | $_->draw for $self->visible_children; |
788 | $_->draw for $self->visible_children; |
786 | } |
789 | } |
787 | |
790 | |
788 | ############################################################################# |
791 | ############################################################################# |
789 | |
792 | |
790 | package CFPlus::UI::Bin; |
793 | package DC::UI::Bin; |
791 | |
794 | |
792 | our @ISA = CFPlus::UI::Container::; |
795 | our @ISA = DC::UI::Container::; |
793 | |
796 | |
794 | sub new { |
797 | sub new { |
795 | my ($class, %arg) = @_; |
798 | my ($class, %arg) = @_; |
796 | |
799 | |
797 | my $child = (delete $arg{child}) || new CFPlus::UI::Empty::; |
800 | my $child = (delete $arg{child}) || new DC::UI::Empty::; |
798 | |
801 | |
799 | $class->SUPER::new (children => [$child], %arg) |
802 | $class->SUPER::new (children => [$child], %arg) |
800 | } |
803 | } |
801 | |
804 | |
802 | sub add { |
805 | sub add { |
… | |
… | |
809 | sub remove { |
812 | sub remove { |
810 | my ($self, $widget) = @_; |
813 | my ($self, $widget) = @_; |
811 | |
814 | |
812 | $self->SUPER::remove ($widget); |
815 | $self->SUPER::remove ($widget); |
813 | |
816 | |
814 | $self->{children} = [new CFPlus::UI::Empty] |
817 | $self->{children} = [new DC::UI::Empty] |
815 | unless @{$self->{children}}; |
818 | unless @{$self->{children}}; |
816 | } |
819 | } |
817 | |
820 | |
818 | sub child { $_[0]->{children}[0] } |
821 | sub child { $_[0]->{children}[0] } |
819 | |
822 | |
… | |
… | |
830 | } |
833 | } |
831 | |
834 | |
832 | ############################################################################# |
835 | ############################################################################# |
833 | # back-buffered drawing area |
836 | # back-buffered drawing area |
834 | |
837 | |
835 | package CFPlus::UI::Window; |
838 | package DC::UI::Window; |
836 | |
839 | |
837 | our @ISA = CFPlus::UI::Bin::; |
840 | our @ISA = DC::UI::Bin::; |
838 | |
841 | |
839 | use CFPlus::OpenGL; |
842 | use DC::OpenGL; |
840 | |
843 | |
841 | sub new { |
844 | sub new { |
842 | my ($class, %arg) = @_; |
845 | my ($class, %arg) = @_; |
843 | |
846 | |
844 | my $self = $class->SUPER::new (%arg); |
847 | my $self = $class->SUPER::new (%arg); |
… | |
… | |
866 | } |
869 | } |
867 | |
870 | |
868 | sub render_child { |
871 | sub render_child { |
869 | my ($self) = @_; |
872 | my ($self) = @_; |
870 | |
873 | |
871 | $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 { |
872 | glClearColor 0, 0, 0, 0; |
875 | glClearColor 0, 0, 0, 0; |
873 | glClear GL_COLOR_BUFFER_BIT; |
876 | glClear GL_COLOR_BUFFER_BIT; |
874 | |
877 | |
875 | { |
878 | { |
876 | package CFPlus::UI::Base; |
879 | package DC::UI::Base; |
877 | |
880 | |
878 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
881 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
879 | (0, 0, $self->{w}, $self->{h}); |
882 | (0, 0, $self->{w}, $self->{h}); |
880 | |
883 | |
881 | $self->_render; |
884 | $self->_render; |
… | |
… | |
898 | glDisable GL_TEXTURE_2D; |
901 | glDisable GL_TEXTURE_2D; |
899 | } |
902 | } |
900 | |
903 | |
901 | ############################################################################# |
904 | ############################################################################# |
902 | |
905 | |
903 | package CFPlus::UI::ViewPort; |
906 | package DC::UI::ViewPort; |
904 | |
907 | |
905 | use List::Util qw(min max); |
908 | use List::Util qw(min max); |
906 | |
909 | |
907 | our @ISA = CFPlus::UI::Window::; |
910 | our @ISA = DC::UI::Window::; |
908 | |
911 | |
909 | sub new { |
912 | sub new { |
910 | my $class = shift; |
913 | my $class = shift; |
911 | |
914 | |
912 | $class->SUPER::new ( |
915 | $class->SUPER::new ( |
… | |
… | |
996 | if ( $x >= $self->{x} && $x < $self->{x} + $self->{w} |
999 | if ( $x >= $self->{x} && $x < $self->{x} + $self->{w} |
997 | && $y >= $self->{y} && $y < $self->{y} + $self->{h} |
1000 | && $y >= $self->{y} && $y < $self->{y} + $self->{h} |
998 | ) { |
1001 | ) { |
999 | $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}) |
1000 | } else { |
1003 | } else { |
1001 | $self->CFPlus::UI::Base::find_widget ($x, $y) |
1004 | $self->DC::UI::Base::find_widget ($x, $y) |
1002 | } |
1005 | } |
1003 | } |
1006 | } |
1004 | |
1007 | |
1005 | sub _render { |
1008 | sub _render { |
1006 | my ($self) = @_; |
1009 | my ($self) = @_; |
1007 | |
1010 | |
1008 | 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}; |
1009 | 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}; |
1010 | |
1013 | |
1011 | CFPlus::OpenGL::glTranslate -$self->{view_x}, -$self->{view_y}; |
1014 | DC::OpenGL::glTranslate -$self->{view_x}, -$self->{view_y}; |
1012 | |
1015 | |
1013 | $self->SUPER::_render; |
1016 | $self->SUPER::_render; |
1014 | } |
1017 | } |
1015 | |
1018 | |
1016 | ############################################################################# |
1019 | ############################################################################# |
1017 | |
1020 | |
1018 | package CFPlus::UI::ScrolledWindow; |
1021 | package DC::UI::ScrolledWindow; |
1019 | |
1022 | |
1020 | our @ISA = CFPlus::UI::Table::; |
1023 | our @ISA = DC::UI::Table::; |
1021 | |
1024 | |
1022 | sub new { |
1025 | sub new { |
1023 | my ($class, %arg) = @_; |
1026 | my ($class, %arg) = @_; |
1024 | |
1027 | |
1025 | my $child = delete $arg{child}; |
1028 | my $child = delete $arg{child}; |
1026 | |
1029 | |
1027 | my $self; |
1030 | my $self; |
1028 | |
1031 | |
1029 | my $hslider = new CFPlus::UI::Slider |
1032 | my $hslider = new DC::UI::Slider |
1030 | c_col => 0, |
1033 | c_col => 0, |
1031 | c_row => 1, |
1034 | c_row => 1, |
1032 | vertical => 0, |
1035 | vertical => 0, |
1033 | range => [0, 0, 1, 0.01], # HACK fix |
1036 | range => [0, 0, 1, 0.01], # HACK fix |
1034 | on_changed => sub { |
1037 | on_changed => sub { |
1035 | $self->{hpos} = $_[1]; |
1038 | $self->{hpos} = $_[1]; |
1036 | $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); |
1039 | $self->{vp}->set_offset ($self->{hpos}, $self->{vpos}); |
1037 | }, |
1040 | }, |
1038 | ; |
1041 | ; |
1039 | |
1042 | |
1040 | my $vslider = new CFPlus::UI::Slider |
1043 | my $vslider = new DC::UI::Slider |
1041 | c_col => 1, |
1044 | c_col => 1, |
1042 | c_row => 0, |
1045 | c_row => 0, |
1043 | vertical => 1, |
1046 | vertical => 1, |
1044 | range => [0, 0, 1, 0.01], # HACK fix |
1047 | range => [0, 0, 1, 0.01], # HACK fix |
1045 | on_changed => sub { |
1048 | on_changed => sub { |
… | |
… | |
1057 | col_expand => [1, 0], |
1060 | col_expand => [1, 0], |
1058 | row_expand => [1, 0], |
1061 | row_expand => [1, 0], |
1059 | %arg, |
1062 | %arg, |
1060 | ); |
1063 | ); |
1061 | |
1064 | |
1062 | $self->{vp} = new CFPlus::UI::ViewPort |
1065 | $self->{vp} = new DC::UI::ViewPort |
1063 | c_col => 0, |
1066 | c_col => 0, |
1064 | c_row => 0, |
1067 | c_row => 0, |
1065 | expand => 1, |
1068 | expand => 1, |
1066 | scroll_x => $self->{scroll_x}, |
1069 | scroll_x => $self->{scroll_x}, |
1067 | scroll_y => $self->{scroll_y}, |
1070 | scroll_y => $self->{scroll_y}, |
… | |
… | |
1193 | $self->SUPER::invoke_size_allocate ($w, $h) |
1196 | $self->SUPER::invoke_size_allocate ($w, $h) |
1194 | } |
1197 | } |
1195 | |
1198 | |
1196 | ############################################################################# |
1199 | ############################################################################# |
1197 | |
1200 | |
1198 | package CFPlus::UI::Frame; |
1201 | package DC::UI::Frame; |
1199 | |
1202 | |
1200 | our @ISA = CFPlus::UI::Bin::; |
1203 | our @ISA = DC::UI::Bin::; |
1201 | |
1204 | |
1202 | use CFPlus::OpenGL; |
1205 | use DC::OpenGL; |
1203 | |
1206 | |
1204 | sub new { |
1207 | sub new { |
1205 | my $class = shift; |
1208 | my $class = shift; |
1206 | |
1209 | |
1207 | $class->SUPER::new ( |
1210 | $class->SUPER::new ( |
… | |
… | |
1226 | $self->SUPER::_draw; |
1229 | $self->SUPER::_draw; |
1227 | } |
1230 | } |
1228 | |
1231 | |
1229 | ############################################################################# |
1232 | ############################################################################# |
1230 | |
1233 | |
1231 | package CFPlus::UI::FancyFrame; |
1234 | package DC::UI::FancyFrame; |
1232 | |
1235 | |
1233 | our @ISA = CFPlus::UI::Bin::; |
1236 | our @ISA = DC::UI::Bin::; |
1234 | |
1237 | |
1235 | use CFPlus::OpenGL; |
1238 | use DC::OpenGL; |
1236 | |
1239 | |
1237 | sub new { |
1240 | sub new { |
1238 | my ($class, %arg) = @_; |
1241 | my ($class, %arg) = @_; |
1239 | |
1242 | |
1240 | if ((exists $arg{label}) && !ref $arg{label}) { |
1243 | if ((exists $arg{label}) && !ref $arg{label}) { |
1241 | $arg{label} = new CFPlus::UI::Label |
1244 | $arg{label} = new DC::UI::Label |
1242 | align => 1, |
1245 | align => 1, |
1243 | valign => 0, |
1246 | valign => 0, |
1244 | text => $arg{label}, |
1247 | text => $arg{label}, |
1245 | fontsize => ($arg{border} || 0.8) * 0.75; |
1248 | fontsize => ($arg{border} || 0.8) * 0.75; |
1246 | } |
1249 | } |
… | |
… | |
1258 | |
1261 | |
1259 | sub add { |
1262 | sub add { |
1260 | my ($self, @widgets) = @_; |
1263 | my ($self, @widgets) = @_; |
1261 | |
1264 | |
1262 | $self->SUPER::add (@widgets); |
1265 | $self->SUPER::add (@widgets); |
1263 | $self->CFPlus::UI::Container::add ($self->{label}) if $self->{label}; |
1266 | $self->DC::UI::Container::add ($self->{label}) if $self->{label}; |
1264 | } |
1267 | } |
1265 | |
1268 | |
1266 | sub border { |
1269 | sub border { |
1267 | int $_[0]{border} * $::FONTSIZE |
1270 | int $_[0]{border} * $::FONTSIZE |
1268 | } |
1271 | } |
… | |
… | |
1326 | } |
1329 | } |
1327 | } |
1330 | } |
1328 | |
1331 | |
1329 | ############################################################################# |
1332 | ############################################################################# |
1330 | |
1333 | |
1331 | package CFPlus::UI::Toplevel; |
1334 | package DC::UI::Toplevel; |
1332 | |
1335 | |
1333 | our @ISA = CFPlus::UI::Bin::; |
1336 | our @ISA = DC::UI::Bin::; |
1334 | |
1337 | |
1335 | use CFPlus::OpenGL; |
1338 | use DC::OpenGL; |
1336 | |
1339 | |
1337 | my $bg = |
1340 | my $bg = |
1338 | new_from_file CFPlus::Texture CFPlus::find_rcfile "d1_bg.png", |
1341 | new_from_file DC::Texture DC::find_rcfile "d1_bg.png", |
1339 | mipmap => 1, wrap => 1; |
1342 | mipmap => 1, wrap => 1; |
1340 | |
1343 | |
1341 | my @border = |
1344 | my @border = |
1342 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
1345 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
1343 | 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); |
1344 | |
1347 | |
1345 | my @icon = |
1348 | my @icon = |
1346 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
1349 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
1347 | qw(x1_move.png x1_resize.png); |
1350 | qw(x1_move.png x1_resize.png); |
1348 | |
1351 | |
1349 | sub new { |
1352 | sub new { |
1350 | my ($class, %arg) = @_; |
1353 | my ($class, %arg) = @_; |
1351 | |
1354 | |
… | |
… | |
1357 | min_w => 64, |
1360 | min_w => 64, |
1358 | min_h => 32, |
1361 | min_h => 32, |
1359 | %arg, |
1362 | %arg, |
1360 | ); |
1363 | ); |
1361 | |
1364 | |
1362 | $self->{title_widget} = new CFPlus::UI::Label |
1365 | $self->{title_widget} = new DC::UI::Label |
1363 | align => 0, |
1366 | align => 0, |
1364 | valign => 1, |
1367 | valign => 1, |
1365 | text => $self->{title}, |
1368 | text => $self->{title}, |
1366 | fontsize => $self->{border}, |
1369 | fontsize => $self->{border}, |
1367 | if exists $self->{title}; |
1370 | if exists $self->{title}; |
1368 | |
1371 | |
1369 | if ($self->{has_close_button}) { |
1372 | if ($self->{has_close_button}) { |
1370 | $self->{close_button} = |
1373 | $self->{close_button} = |
1371 | new CFPlus::UI::ImageButton |
1374 | new DC::UI::ImageButton |
1372 | path => 'x1_close.png', |
1375 | path => 'x1_close.png', |
1373 | on_activate => sub { $self->emit ("delete") }; |
1376 | on_activate => sub { $self->emit ("delete") }; |
1374 | |
1377 | |
1375 | $self->CFPlus::UI::Container::add ($self->{close_button}); |
1378 | $self->DC::UI::Container::add ($self->{close_button}); |
1376 | } |
1379 | } |
1377 | |
1380 | |
1378 | $self |
1381 | $self |
1379 | } |
1382 | } |
1380 | |
1383 | |
1381 | sub add { |
1384 | sub add { |
1382 | my ($self, @widgets) = @_; |
1385 | my ($self, @widgets) = @_; |
1383 | |
1386 | |
1384 | $self->SUPER::add (@widgets); |
1387 | $self->SUPER::add (@widgets); |
1385 | $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}; |
1386 | $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}; |
1387 | } |
1390 | } |
1388 | |
1391 | |
1389 | sub border { |
1392 | sub border { |
1390 | int $_[0]{border} * $::FONTSIZE |
1393 | int $_[0]{border} * $::FONTSIZE |
1391 | } |
1394 | } |
… | |
… | |
1576 | if $self->{close_button}; |
1579 | if $self->{close_button}; |
1577 | } |
1580 | } |
1578 | |
1581 | |
1579 | ############################################################################# |
1582 | ############################################################################# |
1580 | |
1583 | |
1581 | package CFPlus::UI::Table; |
1584 | package DC::UI::Table; |
1582 | |
1585 | |
1583 | our @ISA = CFPlus::UI::Container::; |
1586 | our @ISA = DC::UI::Container::; |
1584 | |
1587 | |
1585 | use List::Util qw(max sum); |
1588 | use List::Util qw(max sum); |
1586 | |
1589 | |
1587 | use CFPlus::OpenGL; |
1590 | use DC::OpenGL; |
1588 | |
1591 | |
1589 | sub new { |
1592 | sub new { |
1590 | my $class = shift; |
1593 | my $class = shift; |
1591 | |
1594 | |
1592 | $class->SUPER::new ( |
1595 | $class->SUPER::new ( |
… | |
… | |
1636 | 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)}; |
1637 | |
1640 | |
1638 | my $sw = sum @w[$c .. $c + $cs - 1]; |
1641 | my $sw = sum @w[$c .. $c + $cs - 1]; |
1639 | |
1642 | |
1640 | if ($w > $sw) { |
1643 | if ($w > $sw) { |
1641 | $_ += ($w - $sw) / ($sw ? $sw / $_ : $cs) for @w[$c .. $c + $cs - 1]; |
1644 | $_ += ($w - $sw) / ($_ ? $sw / $_ : $cs) for @w[$c .. $c + $cs - 1]; |
1642 | } |
1645 | } |
1643 | } |
1646 | } |
1644 | |
1647 | |
1645 | # second pass, rows |
1648 | # second pass, rows |
1646 | for my $widget (sort { $a->{c_rowspan} <=> $b->{c_rowspan} } @children) { |
1649 | for my $widget (sort { $a->{c_rowspan} <=> $b->{c_rowspan} } @children) { |
1647 | 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)}; |
1648 | |
1651 | |
1649 | my $sh = sum @h[$r .. $r + $rs - 1]; |
1652 | my $sh = sum @h[$r .. $r + $rs - 1]; |
1650 | |
1653 | |
1651 | if ($h > $sh) { |
1654 | if ($h > $sh) { |
1652 | $_ += ($h - $sh) / ($sh ? $sh / $_ : $rs) for @h[$r .. $r + $rs - 1]; |
1655 | $_ += ($h - $sh) / ($_ ? $sh / $_ : $rs) for @h[$r .. $r + $rs - 1]; |
1653 | } |
1656 | } |
1654 | } |
1657 | } |
1655 | |
1658 | |
1656 | (\@w, \@h) |
1659 | (\@w, \@h) |
1657 | } |
1660 | } |
… | |
… | |
1680 | @col_expand = (1) x @$ws unless @col_expand; |
1683 | @col_expand = (1) x @$ws unless @col_expand; |
1681 | my $col_expand = (sum @col_expand) || 1; |
1684 | my $col_expand = (sum @col_expand) || 1; |
1682 | |
1685 | |
1683 | $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; |
1686 | $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; |
1684 | |
1687 | |
1685 | CFPlus::UI::harmonize $ws; |
1688 | DC::UI::harmonize $ws; |
1686 | |
1689 | |
1687 | my @row_expand = @{$self->{row_expand}}; |
1690 | my @row_expand = @{$self->{row_expand}}; |
1688 | @row_expand = (1) x @$ws unless @row_expand; |
1691 | @row_expand = (1) x @$ws unless @row_expand; |
1689 | my $row_expand = (sum @row_expand) || 1; |
1692 | my $row_expand = (sum @row_expand) || 1; |
1690 | |
1693 | |
1691 | $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs; |
1694 | $hs->[$_] += $row_expand[$_] / $row_expand * ($h - $req_h) for 0 .. $#$hs; |
1692 | |
1695 | |
1693 | CFPlus::UI::harmonize $hs; |
1696 | DC::UI::harmonize $hs; |
1694 | |
1697 | |
1695 | my @x; for (0 .. $#$ws) { $x[$_ + 1] = $x[$_] + $ws->[$_] } |
1698 | my @x; for (0 .. $#$ws) { $x[$_ + 1] = $x[$_] + $ws->[$_] } |
1696 | my @y; for (0 .. $#$hs) { $y[$_ + 1] = $y[$_] + $hs->[$_] } |
1699 | my @y; for (0 .. $#$hs) { $y[$_ + 1] = $y[$_] + $hs->[$_] } |
1697 | |
1700 | |
1698 | for my $widget ($self->children) { |
1701 | for my $widget ($self->children) { |
… | |
… | |
1707 | 1 |
1710 | 1 |
1708 | } |
1711 | } |
1709 | |
1712 | |
1710 | ############################################################################# |
1713 | ############################################################################# |
1711 | |
1714 | |
1712 | package CFPlus::UI::Fixed; |
1715 | package DC::UI::Fixed; |
1713 | |
1716 | |
1714 | use List::Util qw(min max); |
1717 | use List::Util qw(min max); |
1715 | |
1718 | |
1716 | our @ISA = CFPlus::UI::Container::; |
1719 | our @ISA = DC::UI::Container::; |
1717 | |
1720 | |
1718 | sub _scale($$$) { |
1721 | sub _scale($$$) { |
1719 | my ($rel, $val, $max) = @_; |
1722 | my ($rel, $val, $max) = @_; |
1720 | |
1723 | |
1721 | $rel ? $val * $max : $val |
1724 | $rel ? $val * $max : $val |
… | |
… | |
1773 | 1 |
1776 | 1 |
1774 | } |
1777 | } |
1775 | |
1778 | |
1776 | ############################################################################# |
1779 | ############################################################################# |
1777 | |
1780 | |
1778 | package CFPlus::UI::Box; |
1781 | package DC::UI::Box; |
1779 | |
1782 | |
1780 | our @ISA = CFPlus::UI::Container::; |
1783 | our @ISA = DC::UI::Container::; |
1781 | |
1784 | |
1782 | sub size_request { |
1785 | sub size_request { |
1783 | my ($self) = @_; |
1786 | my ($self) = @_; |
1784 | |
1787 | |
1785 | my @children = $self->visible_children; |
1788 | my @children = $self->visible_children; |
… | |
… | |
1820 | $req[$_] += $space * $children[$_]{expand} |
1823 | $req[$_] += $space * $children[$_]{expand} |
1821 | for 0 .. $#children; |
1824 | for 0 .. $#children; |
1822 | } |
1825 | } |
1823 | } |
1826 | } |
1824 | |
1827 | |
1825 | CFPlus::UI::harmonize \@req; |
1828 | DC::UI::harmonize \@req; |
1826 | |
1829 | |
1827 | my $pos = 0; |
1830 | my $pos = 0; |
1828 | for (0 .. $#children) { |
1831 | for (0 .. $#children) { |
1829 | my $alloc = $req[$_]; |
1832 | my $alloc = $req[$_]; |
1830 | $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)); |
… | |
… | |
1835 | 1 |
1838 | 1 |
1836 | } |
1839 | } |
1837 | |
1840 | |
1838 | ############################################################################# |
1841 | ############################################################################# |
1839 | |
1842 | |
1840 | package CFPlus::UI::HBox; |
1843 | package DC::UI::HBox; |
1841 | |
1844 | |
1842 | our @ISA = CFPlus::UI::Box::; |
1845 | our @ISA = DC::UI::Box::; |
1843 | |
1846 | |
1844 | sub new { |
1847 | sub new { |
1845 | my $class = shift; |
1848 | my $class = shift; |
1846 | |
1849 | |
1847 | $class->SUPER::new ( |
1850 | $class->SUPER::new ( |
… | |
… | |
1850 | ) |
1853 | ) |
1851 | } |
1854 | } |
1852 | |
1855 | |
1853 | ############################################################################# |
1856 | ############################################################################# |
1854 | |
1857 | |
1855 | package CFPlus::UI::VBox; |
1858 | package DC::UI::VBox; |
1856 | |
1859 | |
1857 | our @ISA = CFPlus::UI::Box::; |
1860 | our @ISA = DC::UI::Box::; |
1858 | |
1861 | |
1859 | sub new { |
1862 | sub new { |
1860 | my $class = shift; |
1863 | my $class = shift; |
1861 | |
1864 | |
1862 | $class->SUPER::new ( |
1865 | $class->SUPER::new ( |
… | |
… | |
1865 | ) |
1868 | ) |
1866 | } |
1869 | } |
1867 | |
1870 | |
1868 | ############################################################################# |
1871 | ############################################################################# |
1869 | |
1872 | |
1870 | package CFPlus::UI::Label; |
1873 | package DC::UI::Label; |
1871 | |
1874 | |
1872 | our @ISA = CFPlus::UI::DrawBG::; |
1875 | our @ISA = DC::UI::DrawBG::; |
1873 | |
1876 | |
1874 | use CFPlus::OpenGL; |
1877 | use DC::OpenGL; |
1875 | |
1878 | |
1876 | sub new { |
1879 | sub new { |
1877 | my ($class, %arg) = @_; |
1880 | my ($class, %arg) = @_; |
1878 | |
1881 | |
1879 | my $self = $class->SUPER::new ( |
1882 | my $self = $class->SUPER::new ( |
… | |
… | |
1884 | #text => initial text |
1887 | #text => initial text |
1885 | #markup => initial narkup |
1888 | #markup => initial narkup |
1886 | #max_w => maximum pixel width |
1889 | #max_w => maximum pixel width |
1887 | #style => 0, # render flags |
1890 | #style => 0, # render flags |
1888 | ellipsise => 3, # end |
1891 | ellipsise => 3, # end |
1889 | layout => (new CFPlus::Layout), |
1892 | layout => (new DC::Layout), |
1890 | fontsize => 1, |
1893 | fontsize => 1, |
1891 | align => -1, |
1894 | align => -1, |
1892 | valign => -1, |
1895 | valign => -1, |
1893 | padding_x => 2, |
1896 | padding_x => 2, |
1894 | padding_y => 2, |
1897 | padding_y => 2, |
1895 | can_events => 0, |
1898 | can_events => 0, |
1896 | %arg |
1899 | %arg |
1897 | ); |
1900 | ); |
1898 | |
1901 | |
1899 | if (exists $self->{template}) { |
1902 | if (exists $self->{template}) { |
1900 | my $layout = new CFPlus::Layout; |
1903 | my $layout = new DC::Layout; |
1901 | $layout->set_text (delete $self->{template}); |
1904 | $layout->set_text (delete $self->{template}); |
1902 | $self->{template} = $layout; |
1905 | $self->{template} = $layout; |
1903 | } |
1906 | } |
1904 | |
1907 | |
1905 | if (exists $self->{markup}) { |
1908 | if (exists $self->{markup}) { |
… | |
… | |
2051 | |
2054 | |
2052 | $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2055 | $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2053 | }; |
2056 | }; |
2054 | |
2057 | |
2055 | # unless ($self->{list}) { |
2058 | # unless ($self->{list}) { |
2056 | # $self->{list} = CFPlus::OpenGL::glGenList; |
2059 | # $self->{list} = DC::OpenGL::glGenList; |
2057 | # CFPlus::OpenGL::glNewList $self->{list}; |
2060 | # DC::OpenGL::glNewList $self->{list}; |
2058 | # $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2061 | # $self->{layout}->render ($self->{ox}, $self->{oy}, $self->{style}); |
2059 | # CFPlus::OpenGL::glEndList; |
2062 | # DC::OpenGL::glEndList; |
2060 | # } |
2063 | # } |
2061 | # |
2064 | # |
2062 | # CFPlus::OpenGL::glCallList $self->{list}; |
2065 | # DC::OpenGL::glCallList $self->{list}; |
2063 | |
2066 | |
2064 | $self->{layout}->draw; |
2067 | $self->{layout}->draw; |
2065 | } |
2068 | } |
2066 | |
2069 | |
2067 | #sub destroy { |
2070 | #sub destroy { |
2068 | # my ($self) = @_; |
2071 | # my ($self) = @_; |
2069 | # |
2072 | # |
2070 | # CFPlus::OpenGL::glDeleteList delete $self->{list} if $self->{list}; |
2073 | # DC::OpenGL::glDeleteList delete $self->{list} if $self->{list}; |
2071 | # |
2074 | # |
2072 | # $self->SUPER::destroy; |
2075 | # $self->SUPER::destroy; |
2073 | #} |
2076 | #} |
2074 | |
2077 | |
2075 | ############################################################################# |
2078 | ############################################################################# |
2076 | |
2079 | |
2077 | package CFPlus::UI::EntryBase; |
2080 | package DC::UI::EntryBase; |
2078 | |
2081 | |
2079 | our @ISA = CFPlus::UI::Label::; |
2082 | our @ISA = DC::UI::Label::; |
2080 | |
2083 | |
2081 | use CFPlus::OpenGL; |
2084 | use DC::OpenGL; |
2082 | |
2085 | |
2083 | sub new { |
2086 | sub new { |
2084 | my $class = shift; |
2087 | my $class = shift; |
2085 | |
2088 | |
2086 | $class->SUPER::new ( |
2089 | $class->SUPER::new ( |
… | |
… | |
2093 | can_hover => 1, |
2096 | can_hover => 1, |
2094 | can_focus => 1, |
2097 | can_focus => 1, |
2095 | valign => 0, |
2098 | valign => 0, |
2096 | can_events => 1, |
2099 | can_events => 1, |
2097 | ellipsise => 0, |
2100 | ellipsise => 0, |
|
|
2101 | padding_x => 4, |
|
|
2102 | padding_y => 2, |
2098 | #text => ... |
2103 | #text => ... |
2099 | #hidden => "*", |
2104 | #hidden => "*", |
2100 | @_ |
2105 | @_ |
2101 | ) |
2106 | ) |
2102 | } |
2107 | } |
… | |
… | |
2153 | |
2158 | |
2154 | if ($uni == 8) { |
2159 | if ($uni == 8) { |
2155 | substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; |
2160 | substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; |
2156 | } elsif ($uni == 127) { |
2161 | } elsif ($uni == 127) { |
2157 | substr $text, $self->{cursor}, 1, ""; |
2162 | substr $text, $self->{cursor}, 1, ""; |
2158 | } elsif ($sym == CFPlus::SDLK_LEFT) { |
2163 | } elsif ($sym == DC::SDLK_LEFT) { |
2159 | --$self->{cursor} if $self->{cursor}; |
2164 | --$self->{cursor} if $self->{cursor}; |
2160 | } elsif ($sym == CFPlus::SDLK_RIGHT) { |
2165 | } elsif ($sym == DC::SDLK_RIGHT) { |
2161 | ++$self->{cursor} if $self->{cursor} < length $self->{text}; |
2166 | ++$self->{cursor} if $self->{cursor} < length $self->{text}; |
2162 | } elsif ($sym == CFPlus::SDLK_HOME) { |
2167 | } elsif ($sym == DC::SDLK_HOME) { |
2163 | # what a hack |
2168 | # what a hack |
2164 | $self->{cursor} = |
2169 | $self->{cursor} = |
2165 | (substr $self->{text}, 0, $self->{cursor}) =~ /^(.*\012)/ |
2170 | (substr $self->{text}, 0, $self->{cursor}) =~ /^(.*\012)/ |
2166 | ? length $1 |
2171 | ? length $1 |
2167 | : 0; |
2172 | : 0; |
2168 | } elsif ($sym == CFPlus::SDLK_END) { |
2173 | } elsif ($sym == DC::SDLK_END) { |
2169 | # uh, again |
2174 | # uh, again |
2170 | $self->{cursor} = |
2175 | $self->{cursor} = |
2171 | (substr $self->{text}, $self->{cursor}) =~ /^([^\012]*)\012/ |
2176 | (substr $self->{text}, $self->{cursor}) =~ /^([^\012]*)\012/ |
2172 | ? $self->{cursor} + length $1 |
2177 | ? $self->{cursor} + length $1 |
2173 | : length $self->{text}; |
2178 | : length $self->{text}; |
… | |
… | |
2276 | } |
2281 | } |
2277 | } |
2282 | } |
2278 | |
2283 | |
2279 | ############################################################################# |
2284 | ############################################################################# |
2280 | |
2285 | |
2281 | package CFPlus::UI::Entry; |
2286 | package DC::UI::Entry; |
2282 | |
2287 | |
2283 | our @ISA = CFPlus::UI::EntryBase::; |
2288 | our @ISA = DC::UI::EntryBase::; |
2284 | |
2289 | |
2285 | use CFPlus::OpenGL; |
2290 | use DC::OpenGL; |
2286 | |
2291 | |
2287 | sub invoke_key_down { |
2292 | sub invoke_key_down { |
2288 | my ($self, $ev) = @_; |
2293 | my ($self, $ev) = @_; |
2289 | |
2294 | |
2290 | my $sym = $ev->{sym}; |
2295 | my $sym = $ev->{sym}; |
… | |
… | |
2296 | $self->{history_pointer} = -1; |
2301 | $self->{history_pointer} = -1; |
2297 | $self->{history_saveback} = ''; |
2302 | $self->{history_saveback} = ''; |
2298 | $self->emit (activate => $txt); |
2303 | $self->emit (activate => $txt); |
2299 | $self->update; |
2304 | $self->update; |
2300 | |
2305 | |
2301 | } elsif ($sym == CFPlus::SDLK_UP) { |
2306 | } elsif ($sym == DC::SDLK_UP) { |
2302 | if ($self->{history_pointer} < 0) { |
2307 | if ($self->{history_pointer} < 0) { |
2303 | $self->{history_saveback} = $self->get_text; |
2308 | $self->{history_saveback} = $self->get_text; |
2304 | } |
2309 | } |
2305 | if (@{$self->{history} || []} > 0) { |
2310 | if (@{$self->{history} || []} > 0) { |
2306 | $self->{history_pointer}++; |
2311 | $self->{history_pointer}++; |
… | |
… | |
2308 | $self->{history_pointer} = @{$self->{history} || []} - 1; |
2313 | $self->{history_pointer} = @{$self->{history} || []} - 1; |
2309 | } |
2314 | } |
2310 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
2315 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
2311 | } |
2316 | } |
2312 | |
2317 | |
2313 | } elsif ($sym == CFPlus::SDLK_DOWN) { |
2318 | } elsif ($sym == DC::SDLK_DOWN) { |
2314 | $self->{history_pointer}--; |
2319 | $self->{history_pointer}--; |
2315 | $self->{history_pointer} = -1 if $self->{history_pointer} < 0; |
2320 | $self->{history_pointer} = -1 if $self->{history_pointer} < 0; |
2316 | |
2321 | |
2317 | if ($self->{history_pointer} >= 0) { |
2322 | if ($self->{history_pointer} >= 0) { |
2318 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
2323 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
… | |
… | |
2327 | 1 |
2332 | 1 |
2328 | } |
2333 | } |
2329 | |
2334 | |
2330 | ############################################################################# |
2335 | ############################################################################# |
2331 | |
2336 | |
2332 | package CFPlus::UI::TextEdit; |
2337 | package DC::UI::TextEdit; |
2333 | |
2338 | |
2334 | our @ISA = CFPlus::UI::EntryBase::; |
2339 | our @ISA = DC::UI::EntryBase::; |
2335 | |
2340 | |
2336 | 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 | } |
2337 | |
2352 | |
2338 | sub move_cursor_ver { |
2353 | sub move_cursor_ver { |
2339 | my ($self, $dy) = @_; |
2354 | my ($self, $dy) = @_; |
2340 | |
2355 | |
2341 | my ($y, $x) = $self->{layout}->index_to_line_x ($self->{cursor}); |
2356 | my ($line, $x) = $self->{layout}->index_to_line_x ($self->{cursor}); |
|
|
2357 | warn "cursor $self->{cursor} => $x $line\n";#d# |
2342 | |
2358 | |
2343 | $y += $dy; |
2359 | $line += $dy; |
2344 | |
2360 | |
2345 | if (defined (my $index = $self->{layout}->line_x_to_index ($y, $x))) { |
2361 | if (defined (my $index = $self->{layout}->line_x_to_index ($line, $x))) { |
|
|
2362 | warn "index $x $line => $index\n";#d# |
2346 | $self->{cursor} = $index; |
2363 | $self->{cursor} = $index; |
2347 | delete $self->{cur_h}; |
2364 | delete $self->{cur_h}; |
2348 | $self->update; |
2365 | $self->update; |
2349 | return; |
2366 | return; |
2350 | } |
2367 | } |
… | |
… | |
2353 | sub invoke_key_down { |
2370 | sub invoke_key_down { |
2354 | my ($self, $ev) = @_; |
2371 | my ($self, $ev) = @_; |
2355 | |
2372 | |
2356 | my $sym = $ev->{sym}; |
2373 | my $sym = $ev->{sym}; |
2357 | |
2374 | |
2358 | if ($sym == CFPlus::SDLK_UP) { |
2375 | if ($sym == DC::SDLK_UP) { |
2359 | $self->move_cursor_ver (-1); |
2376 | $self->move_cursor_ver (-1); |
2360 | } elsif ($sym == CFPlus::SDLK_DOWN) { |
2377 | } elsif ($sym == DC::SDLK_DOWN) { |
2361 | $self->move_cursor_ver (+1); |
2378 | $self->move_cursor_ver (+1); |
2362 | } else { |
2379 | } else { |
2363 | return $self->SUPER::invoke_key_down ($ev) |
2380 | return $self->SUPER::invoke_key_down ($ev) |
2364 | } |
2381 | } |
2365 | |
2382 | |
2366 | 1 |
2383 | 1 |
2367 | } |
2384 | } |
2368 | |
2385 | |
2369 | ############################################################################# |
2386 | ############################################################################# |
2370 | |
2387 | |
2371 | package CFPlus::UI::ButtonBin; |
2388 | package DC::UI::ButtonBin; |
2372 | |
2389 | |
2373 | our @ISA = CFPlus::UI::Bin::; |
2390 | our @ISA = DC::UI::Bin::; |
2374 | |
2391 | |
2375 | use CFPlus::OpenGL; |
2392 | use DC::OpenGL; |
2376 | |
2393 | |
2377 | my @tex = |
2394 | my @tex = |
2378 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2395 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2379 | qw(b1_button_inactive.png b1_button_active.png); |
2396 | qw(b1_button_inactive.png b1_button_active.png); |
2380 | |
2397 | |
2381 | sub new { |
2398 | sub new { |
2382 | my $class = shift; |
2399 | my $class = shift; |
2383 | |
2400 | |
… | |
… | |
2415 | $self->SUPER::_draw; |
2432 | $self->SUPER::_draw; |
2416 | } |
2433 | } |
2417 | |
2434 | |
2418 | ############################################################################# |
2435 | ############################################################################# |
2419 | |
2436 | |
2420 | package CFPlus::UI::Button; |
2437 | package DC::UI::Button; |
2421 | |
2438 | |
2422 | our @ISA = CFPlus::UI::Label::; |
2439 | our @ISA = DC::UI::Label::; |
2423 | |
2440 | |
2424 | use CFPlus::OpenGL; |
2441 | use DC::OpenGL; |
2425 | |
2442 | |
2426 | my @tex = |
2443 | my @tex = |
2427 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2444 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2428 | qw(b1_button_inactive.png b1_button_active.png); |
2445 | qw(b1_button_inactive.png b1_button_active.png); |
2429 | |
2446 | |
2430 | sub new { |
2447 | sub new { |
2431 | my $class = shift; |
2448 | my $class = shift; |
2432 | |
2449 | |
2433 | $class->SUPER::new ( |
2450 | $class->SUPER::new ( |
2434 | padding_x => 4, |
2451 | padding_x => 8, |
2435 | padding_y => 4, |
2452 | padding_y => 4, |
2436 | fg => [1.0, 1.0, 1.0], |
2453 | fg => [1.0, 1.0, 1.0], |
2437 | active_fg => [0.8, 0.8, 0.8], |
2454 | active_fg => [0.8, 0.8, 0.8], |
2438 | can_hover => 1, |
2455 | can_hover => 1, |
2439 | align => 0, |
2456 | align => 0, |
… | |
… | |
2470 | $self->SUPER::_draw; |
2487 | $self->SUPER::_draw; |
2471 | } |
2488 | } |
2472 | |
2489 | |
2473 | ############################################################################# |
2490 | ############################################################################# |
2474 | |
2491 | |
2475 | package CFPlus::UI::CheckBox; |
2492 | package DC::UI::CheckBox; |
2476 | |
2493 | |
2477 | our @ISA = CFPlus::UI::DrawBG::; |
2494 | our @ISA = DC::UI::DrawBG::; |
2478 | |
2495 | |
2479 | my @tex = |
2496 | my @tex = |
2480 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2497 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2481 | qw(c1_checkbox_bg.png c1_checkbox_active.png); |
2498 | qw(c1_checkbox_bg.png c1_checkbox_active.png); |
2482 | |
2499 | |
2483 | use CFPlus::OpenGL; |
2500 | use DC::OpenGL; |
2484 | |
2501 | |
2485 | sub new { |
2502 | sub new { |
2486 | my $class = shift; |
2503 | my $class = shift; |
2487 | |
2504 | |
2488 | $class->SUPER::new ( |
2505 | $class->SUPER::new ( |
… | |
… | |
2545 | glDisable GL_TEXTURE_2D; |
2562 | glDisable GL_TEXTURE_2D; |
2546 | } |
2563 | } |
2547 | |
2564 | |
2548 | ############################################################################# |
2565 | ############################################################################# |
2549 | |
2566 | |
2550 | package CFPlus::UI::Image; |
2567 | package DC::UI::Image; |
2551 | |
2568 | |
2552 | our @ISA = CFPlus::UI::Base::; |
2569 | our @ISA = DC::UI::Base::; |
2553 | |
2570 | |
2554 | use CFPlus::OpenGL; |
2571 | use DC::OpenGL; |
2555 | |
2572 | |
2556 | our %texture_cache; |
2573 | our %texture_cache; |
2557 | |
2574 | |
2558 | sub new { |
2575 | sub new { |
2559 | my $class = shift; |
2576 | my $class = shift; |
… | |
… | |
2566 | |
2583 | |
2567 | $self->{path} || $self->{tex} |
2584 | $self->{path} || $self->{tex} |
2568 | or Carp::croak "'path' or 'tex' attributes required"; |
2585 | or Carp::croak "'path' or 'tex' attributes required"; |
2569 | |
2586 | |
2570 | $self->{tex} ||= $texture_cache{$self->{path}} ||= |
2587 | $self->{tex} ||= $texture_cache{$self->{path}} ||= |
2571 | new_from_file CFPlus::Texture CFPlus::find_rcfile $self->{path}, mipmap => 1; |
2588 | new_from_file DC::Texture DC::find_rcfile $self->{path}, mipmap => 1; |
2572 | |
2589 | |
2573 | CFPlus::weaken $texture_cache{$self->{path}}; |
2590 | DC::weaken $texture_cache{$self->{path}}; |
2574 | |
2591 | |
2575 | $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h}; |
2592 | $self->{aspect} ||= $self->{tex}{w} / $self->{tex}{h}; |
2576 | |
2593 | |
2577 | $self |
2594 | $self |
2578 | } |
2595 | } |
2579 | |
2596 | |
2580 | sub STORABLE_freeze { |
2597 | sub STORABLE_freeze { |
2581 | my ($self, $cloning) = @_; |
2598 | my ($self, $cloning) = @_; |
2582 | |
2599 | |
2583 | $self->{path} |
2600 | $self->{path} |
2584 | or die "cannot serialise CFPlus::UI::Image on non-loadable images\n"; |
2601 | or die "cannot serialise DC::UI::Image on non-loadable images\n"; |
2585 | |
2602 | |
2586 | $self->{path} |
2603 | $self->{path} |
2587 | } |
2604 | } |
2588 | |
2605 | |
2589 | sub STORABLE_attach { |
2606 | sub STORABLE_attach { |
… | |
… | |
2620 | glDisable GL_TEXTURE_2D; |
2637 | glDisable GL_TEXTURE_2D; |
2621 | } |
2638 | } |
2622 | |
2639 | |
2623 | ############################################################################# |
2640 | ############################################################################# |
2624 | |
2641 | |
2625 | package CFPlus::UI::ImageButton; |
2642 | package DC::UI::ImageButton; |
2626 | |
2643 | |
2627 | our @ISA = CFPlus::UI::Image::; |
2644 | our @ISA = DC::UI::Image::; |
2628 | |
2645 | |
2629 | use CFPlus::OpenGL; |
2646 | use DC::OpenGL; |
2630 | |
2647 | |
2631 | my %textures; |
2648 | my %textures; |
2632 | |
2649 | |
2633 | sub new { |
2650 | sub new { |
2634 | my $class = shift; |
2651 | my $class = shift; |
… | |
… | |
2662 | 1 |
2679 | 1 |
2663 | } |
2680 | } |
2664 | |
2681 | |
2665 | ############################################################################# |
2682 | ############################################################################# |
2666 | |
2683 | |
2667 | package CFPlus::UI::VGauge; |
2684 | package DC::UI::VGauge; |
2668 | |
2685 | |
2669 | our @ISA = CFPlus::UI::Base::; |
2686 | our @ISA = DC::UI::Base::; |
2670 | |
2687 | |
2671 | use List::Util qw(min max); |
2688 | use List::Util qw(min max); |
2672 | |
2689 | |
2673 | use CFPlus::OpenGL; |
2690 | use DC::OpenGL; |
2674 | |
2691 | |
2675 | my %tex = ( |
2692 | my %tex = ( |
2676 | food => [ |
2693 | food => [ |
2677 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2694 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2678 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
2695 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
2679 | ], |
2696 | ], |
2680 | grace => [ |
2697 | grace => [ |
2681 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2698 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2682 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png g1_grace_gauge_overflow.png/ |
2699 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png g1_grace_gauge_overflow.png/ |
2683 | ], |
2700 | ], |
2684 | hp => [ |
2701 | hp => [ |
2685 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2702 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2686 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
2703 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
2687 | ], |
2704 | ], |
2688 | mana => [ |
2705 | mana => [ |
2689 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_, mipmap => 1 } |
2706 | map { new_from_file DC::Texture DC::find_rcfile $_, mipmap => 1 } |
2690 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png g1_mana_gauge_overflow.png/ |
2707 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png g1_mana_gauge_overflow.png/ |
2691 | ], |
2708 | ], |
2692 | ); |
2709 | ); |
2693 | |
2710 | |
2694 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
2711 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
… | |
… | |
2797 | glDisable GL_TEXTURE_2D; |
2814 | glDisable GL_TEXTURE_2D; |
2798 | } |
2815 | } |
2799 | |
2816 | |
2800 | ############################################################################# |
2817 | ############################################################################# |
2801 | |
2818 | |
2802 | package CFPlus::UI::Progress; |
2819 | package DC::UI::Progress; |
2803 | |
2820 | |
2804 | our @ISA = CFPlus::UI::Label::; |
2821 | our @ISA = DC::UI::Label::; |
2805 | |
2822 | |
2806 | use CFPlus::OpenGL; |
2823 | use DC::OpenGL; |
2807 | |
2824 | |
2808 | sub new { |
2825 | sub new { |
2809 | my ($class, %arg) = @_; |
2826 | my ($class, %arg) = @_; |
2810 | |
2827 | |
2811 | my $self = $class->SUPER::new ( |
2828 | my $self = $class->SUPER::new ( |
… | |
… | |
2831 | my ($self, $label) = @_; |
2848 | my ($self, $label) = @_; |
2832 | |
2849 | |
2833 | return if $self->{label} eq $label; |
2850 | return if $self->{label} eq $label; |
2834 | $self->{label} = $label; |
2851 | $self->{label} = $label; |
2835 | |
2852 | |
2836 | $self->CFPlus::UI::Progress::set_value (0 + delete $self->{value}); |
2853 | $self->DC::UI::Progress::set_value (0 + delete $self->{value}); |
2837 | } |
2854 | } |
2838 | |
2855 | |
2839 | sub set_value { |
2856 | sub set_value { |
2840 | my ($self, $value) = @_; |
2857 | my ($self, $value) = @_; |
2841 | |
2858 | |
… | |
… | |
2878 | } |
2895 | } |
2879 | } |
2896 | } |
2880 | |
2897 | |
2881 | ############################################################################# |
2898 | ############################################################################# |
2882 | |
2899 | |
2883 | package CFPlus::UI::ExperienceProgress; |
2900 | package DC::UI::ExperienceProgress; |
2884 | |
2901 | |
2885 | our @ISA = CFPlus::UI::Progress::; |
2902 | our @ISA = DC::UI::Progress::; |
2886 | |
2903 | |
2887 | sub new { |
2904 | sub new { |
2888 | my ($class, %arg) = @_; |
2905 | my ($class, %arg) = @_; |
2889 | |
2906 | |
2890 | my $self = $class->SUPER::new ( |
2907 | my $self = $class->SUPER::new ( |
… | |
… | |
2935 | $self->SUPER::set_value ($v); |
2952 | $self->SUPER::set_value ($v); |
2936 | } |
2953 | } |
2937 | |
2954 | |
2938 | ############################################################################# |
2955 | ############################################################################# |
2939 | |
2956 | |
2940 | package CFPlus::UI::Gauge; |
2957 | package DC::UI::Gauge; |
2941 | |
2958 | |
2942 | our @ISA = CFPlus::UI::VBox::; |
2959 | our @ISA = DC::UI::VBox::; |
2943 | |
2960 | |
2944 | sub new { |
2961 | sub new { |
2945 | my ($class, %arg) = @_; |
2962 | my ($class, %arg) = @_; |
2946 | |
2963 | |
2947 | my $self = $class->SUPER::new ( |
2964 | my $self = $class->SUPER::new ( |
… | |
… | |
2949 | can_hover => 1, |
2966 | can_hover => 1, |
2950 | can_events => 1, |
2967 | can_events => 1, |
2951 | %arg, |
2968 | %arg, |
2952 | ); |
2969 | ); |
2953 | |
2970 | |
2954 | $self->add ($self->{value} = new CFPlus::UI::Label valign => +1, align => 0, template => "999"); |
2971 | $self->add ($self->{value} = new DC::UI::Label valign => +1, align => 0, template => "999"); |
2955 | $self->add ($self->{gauge} = new CFPlus::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); |
2972 | $self->add ($self->{gauge} = new DC::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); |
2956 | $self->add ($self->{max} = new CFPlus::UI::Label valign => -1, align => 0, template => "999"); |
2973 | $self->add ($self->{max} = new DC::UI::Label valign => -1, align => 0, template => "999"); |
2957 | |
2974 | |
2958 | $self |
2975 | $self |
2959 | } |
2976 | } |
2960 | |
2977 | |
2961 | sub set_fontsize { |
2978 | sub set_fontsize { |
… | |
… | |
2982 | $self->{value}->set_text ($val); |
2999 | $self->{value}->set_text ($val); |
2983 | } |
3000 | } |
2984 | |
3001 | |
2985 | ############################################################################# |
3002 | ############################################################################# |
2986 | |
3003 | |
2987 | package CFPlus::UI::Slider; |
3004 | package DC::UI::Slider; |
2988 | |
3005 | |
2989 | use strict; |
3006 | use strict; |
2990 | |
3007 | |
2991 | use CFPlus::OpenGL; |
3008 | use DC::OpenGL; |
2992 | |
3009 | |
2993 | our @ISA = CFPlus::UI::DrawBG::; |
3010 | our @ISA = DC::UI::DrawBG::; |
2994 | |
3011 | |
2995 | my @tex = |
3012 | my @tex = |
2996 | map { new_from_file CFPlus::Texture CFPlus::find_rcfile $_ } |
3013 | map { new_from_file DC::Texture DC::find_rcfile $_ } |
2997 | qw(s1_slider.png s1_slider_bg.png); |
3014 | qw(s1_slider.png s1_slider_bg.png); |
2998 | |
3015 | |
2999 | sub new { |
3016 | sub new { |
3000 | my $class = shift; |
3017 | my $class = shift; |
3001 | |
3018 | |
… | |
… | |
3097 | sub invoke_mouse_wheel { |
3114 | sub invoke_mouse_wheel { |
3098 | my ($self, $ev) = @_; |
3115 | my ($self, $ev) = @_; |
3099 | |
3116 | |
3100 | my $delta = $self->{vertical} ? $ev->{dy} : $ev->{dx}; |
3117 | my $delta = $self->{vertical} ? $ev->{dy} : $ev->{dx}; |
3101 | |
3118 | |
3102 | my $pagepart = $ev->{mod} & CFPlus::KMOD_SHIFT ? 1 : 0.2; |
3119 | my $pagepart = $ev->{mod} & DC::KMOD_SHIFT ? 1 : 0.2; |
3103 | |
3120 | |
3104 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); |
3121 | $self->set_value ($self->{range}[0] + $delta * $self->{range}[3] * $pagepart); |
3105 | |
3122 | |
3106 | 1 |
3123 | 1 |
3107 | } |
3124 | } |
… | |
… | |
3160 | glDisable GL_TEXTURE_2D; |
3177 | glDisable GL_TEXTURE_2D; |
3161 | } |
3178 | } |
3162 | |
3179 | |
3163 | ############################################################################# |
3180 | ############################################################################# |
3164 | |
3181 | |
3165 | package CFPlus::UI::ValSlider; |
3182 | package DC::UI::ValSlider; |
3166 | |
3183 | |
3167 | our @ISA = CFPlus::UI::HBox::; |
3184 | our @ISA = DC::UI::HBox::; |
3168 | |
3185 | |
3169 | sub new { |
3186 | sub new { |
3170 | my ($class, %arg) = @_; |
3187 | my ($class, %arg) = @_; |
3171 | |
3188 | |
3172 | my $range = delete $arg{range}; |
3189 | my $range = delete $arg{range}; |
3173 | |
3190 | |
3174 | my $self = $class->SUPER::new ( |
3191 | my $self = $class->SUPER::new ( |
3175 | slider => (new CFPlus::UI::Slider expand => 1, range => $range), |
3192 | slider => (new DC::UI::Slider expand => 1, range => $range), |
3176 | entry => (new CFPlus::UI::Label text => "", template => delete $arg{template}), |
3193 | entry => (new DC::UI::Label text => "", template => delete $arg{template}), |
3177 | to_value => sub { shift }, |
3194 | to_value => sub { shift }, |
3178 | from_value => sub { shift }, |
3195 | from_value => sub { shift }, |
3179 | %arg, |
3196 | %arg, |
3180 | ); |
3197 | ); |
3181 | |
3198 | |
… | |
… | |
3201 | sub set_range { shift->{slider}->set_range (@_) } |
3218 | sub set_range { shift->{slider}->set_range (@_) } |
3202 | sub set_value { shift->{slider}->set_value (@_) } |
3219 | sub set_value { shift->{slider}->set_value (@_) } |
3203 | |
3220 | |
3204 | ############################################################################# |
3221 | ############################################################################# |
3205 | |
3222 | |
3206 | package CFPlus::UI::TextScroller; |
3223 | package DC::UI::TextScroller; |
3207 | |
3224 | |
3208 | our @ISA = CFPlus::UI::HBox::; |
3225 | our @ISA = DC::UI::HBox::; |
3209 | |
3226 | |
3210 | use CFPlus::OpenGL; |
3227 | use DC::OpenGL; |
3211 | |
3228 | |
3212 | sub new { |
3229 | sub new { |
3213 | my $class = shift; |
3230 | my $class = shift; |
3214 | |
3231 | |
3215 | my $self = $class->SUPER::new ( |
3232 | my $self = $class->SUPER::new ( |
… | |
… | |
3217 | can_events => 1, |
3234 | can_events => 1, |
3218 | indent => 0, |
3235 | indent => 0, |
3219 | #font => default_font |
3236 | #font => default_font |
3220 | @_, |
3237 | @_, |
3221 | |
3238 | |
3222 | layout => (new CFPlus::Layout), |
3239 | layout => (new DC::Layout), |
3223 | par => [], |
3240 | par => [], |
3224 | max_par => 0, |
3241 | max_par => 0, |
3225 | height => 0, |
3242 | height => 0, |
3226 | children => [ |
3243 | children => [ |
3227 | (new CFPlus::UI::Empty expand => 1), |
3244 | (new DC::UI::Empty expand => 1), |
3228 | (new CFPlus::UI::Slider vertical => 1), |
3245 | (new DC::UI::Slider vertical => 1), |
3229 | ], |
3246 | ], |
3230 | ); |
3247 | ); |
3231 | |
3248 | |
3232 | $self->{children}[1]->connect (changed => sub { $self->update }); |
3249 | $self->{children}[1]->connect (changed => sub { $self->update }); |
3233 | |
3250 | |
… | |
… | |
3416 | $ROOT->on_post_alloc ($self => sub { |
3433 | $ROOT->on_post_alloc ($self => sub { |
3417 | $self->force_uptodate; |
3434 | $self->force_uptodate; |
3418 | |
3435 | |
3419 | my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; |
3436 | my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; |
3420 | |
3437 | |
3421 | $self->{texture} ||= new_from_opengl CFPlus::Texture $W, $H, sub { |
3438 | $self->{texture} ||= new_from_opengl DC::Texture $W, $H, sub { |
3422 | glClearColor 0, 0, 0, 0; |
3439 | glClearColor 0, 0, 0, 0; |
3423 | glClear GL_COLOR_BUFFER_BIT; |
3440 | glClear GL_COLOR_BUFFER_BIT; |
3424 | |
3441 | |
3425 | package CFPlus::UI::Base; |
3442 | package DC::UI::Base; |
3426 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
3443 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
3427 | (0, 0, $self->{w}, $self->{h}); |
3444 | (0, 0, $self->{w}, $self->{h}); |
3428 | |
3445 | |
3429 | my $top = int $self->{children}[1]{range}[0]; |
3446 | my $top = int $self->{children}[1]{range}[0]; |
3430 | |
3447 | |
… | |
… | |
3489 | $self->{children}[1]->draw; |
3506 | $self->{children}[1]->draw; |
3490 | } |
3507 | } |
3491 | |
3508 | |
3492 | ############################################################################# |
3509 | ############################################################################# |
3493 | |
3510 | |
3494 | package CFPlus::UI::Animator; |
3511 | package DC::UI::Animator; |
3495 | |
3512 | |
3496 | use CFPlus::OpenGL; |
3513 | use DC::OpenGL; |
3497 | |
3514 | |
3498 | our @ISA = CFPlus::UI::Bin::; |
3515 | our @ISA = DC::UI::Bin::; |
3499 | |
3516 | |
3500 | sub moveto { |
3517 | sub moveto { |
3501 | my ($self, $x, $y) = @_; |
3518 | my ($self, $x, $y) = @_; |
3502 | |
3519 | |
3503 | $self->{moveto} = [$self->{x}, $self->{y}, $x, $y]; |
3520 | $self->{moveto} = [$self->{x}, $self->{y}, $x, $y]; |
… | |
… | |
3531 | glPopMatrix; |
3548 | glPopMatrix; |
3532 | } |
3549 | } |
3533 | |
3550 | |
3534 | ############################################################################# |
3551 | ############################################################################# |
3535 | |
3552 | |
3536 | package CFPlus::UI::Flopper; |
3553 | package DC::UI::Flopper; |
3537 | |
3554 | |
3538 | our @ISA = CFPlus::UI::Button::; |
3555 | our @ISA = DC::UI::Button::; |
3539 | |
3556 | |
3540 | sub new { |
3557 | sub new { |
3541 | my $class = shift; |
3558 | my $class = shift; |
3542 | |
3559 | |
3543 | my $self = $class->SUPER::new ( |
3560 | my $self = $class->SUPER::new ( |
… | |
… | |
3555 | $self->{other}->toggle_visibility; |
3572 | $self->{other}->toggle_visibility; |
3556 | } |
3573 | } |
3557 | |
3574 | |
3558 | ############################################################################# |
3575 | ############################################################################# |
3559 | |
3576 | |
3560 | package CFPlus::UI::Tooltip; |
3577 | package DC::UI::Tooltip; |
3561 | |
3578 | |
3562 | our @ISA = CFPlus::UI::Bin::; |
3579 | our @ISA = DC::UI::Bin::; |
3563 | |
3580 | |
3564 | use CFPlus::OpenGL; |
3581 | use DC::OpenGL; |
3565 | |
3582 | |
3566 | sub new { |
3583 | sub new { |
3567 | my $class = shift; |
3584 | my $class = shift; |
3568 | |
3585 | |
3569 | $class->SUPER::new ( |
3586 | $class->SUPER::new ( |
… | |
… | |
3576 | my ($self, $widget) = @_; |
3593 | my ($self, $widget) = @_; |
3577 | |
3594 | |
3578 | my $tip = $widget->{tooltip}; |
3595 | my $tip = $widget->{tooltip}; |
3579 | $tip = $tip->($widget) if "CODE" eq ref $tip; |
3596 | $tip = $tip->($widget) if "CODE" eq ref $tip; |
3580 | |
3597 | |
3581 | $tip = CFPlus::Pod::section_label tooltip => $1 |
3598 | $tip = DC::Pod::section_label tooltip => $1 |
3582 | if $tip =~ /^#(.*)$/; |
3599 | if $tip =~ /^#(.*)$/; |
3583 | |
3600 | |
3584 | if ($ENV{CFPLUS_DEBUG} & 2) { |
3601 | if ($ENV{CFPLUS_DEBUG} & 2) { |
3585 | $tip .= "\n\n" . (ref $widget) . "\n" |
3602 | $tip .= "\n\n" . (ref $widget) . "\n" |
3586 | . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n" |
3603 | . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n" |
… | |
… | |
3589 | } |
3606 | } |
3590 | |
3607 | |
3591 | $tip =~ s/^\n+//; |
3608 | $tip =~ s/^\n+//; |
3592 | $tip =~ s/\n+$//; |
3609 | $tip =~ s/\n+$//; |
3593 | |
3610 | |
3594 | $self->add (new CFPlus::UI::Label |
3611 | $self->add (new DC::UI::Label |
3595 | markup => $tip, |
3612 | markup => $tip, |
3596 | max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, |
3613 | max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, |
3597 | fontsize => 0.8, |
3614 | fontsize => 0.8, |
3598 | style => 1, # FLAG_INVERSE |
3615 | style => 1, # FLAG_INVERSE |
3599 | ellipsise => 0, |
3616 | ellipsise => 0, |
… | |
… | |
3653 | $self->SUPER::_draw; |
3670 | $self->SUPER::_draw; |
3654 | } |
3671 | } |
3655 | |
3672 | |
3656 | ############################################################################# |
3673 | ############################################################################# |
3657 | |
3674 | |
3658 | package CFPlus::UI::Face; |
3675 | package DC::UI::Face; |
3659 | |
3676 | |
3660 | our @ISA = CFPlus::UI::DrawBG::; |
3677 | our @ISA = DC::UI::DrawBG::; |
3661 | |
3678 | |
3662 | use CFPlus::OpenGL; |
3679 | use DC::OpenGL; |
3663 | |
3680 | |
3664 | sub new { |
3681 | sub new { |
3665 | my $class = shift; |
3682 | my $class = shift; |
3666 | |
3683 | |
3667 | my $self = $class->SUPER::new ( |
3684 | my $self = $class->SUPER::new ( |
… | |
… | |
3671 | can_events => 0, |
3688 | can_events => 0, |
3672 | @_, |
3689 | @_, |
3673 | ); |
3690 | ); |
3674 | |
3691 | |
3675 | if ($self->{anim} && $self->{animspeed}) { |
3692 | if ($self->{anim} && $self->{animspeed}) { |
3676 | CFPlus::weaken (my $widget = $self); |
3693 | DC::weaken (my $widget = $self); |
3677 | |
3694 | |
3678 | $self->{animspeed} = List::Util::max 0.05, $self->{animspeed}; |
3695 | $self->{animspeed} = List::Util::max 0.05, $self->{animspeed}; |
3679 | $self->{timer} = EV::periodic_ns 0, $self->{animspeed}, undef, sub { |
3696 | $self->{timer} = EV::periodic_ns 0, $self->{animspeed}, undef, sub { |
3680 | return unless $::CONN; |
3697 | return unless $::CONN; |
3681 | |
3698 | |
… | |
… | |
3787 | $self->SUPER::destroy; |
3804 | $self->SUPER::destroy; |
3788 | } |
3805 | } |
3789 | |
3806 | |
3790 | ############################################################################# |
3807 | ############################################################################# |
3791 | |
3808 | |
3792 | package CFPlus::UI::Buttonbar; |
3809 | package DC::UI::Buttonbar; |
3793 | |
3810 | |
3794 | our @ISA = CFPlus::UI::HBox::; |
3811 | our @ISA = DC::UI::HBox::; |
3795 | |
3812 | |
3796 | # TODO: should actually wrap buttons and other goodies. |
3813 | # TODO: should actually wrap buttons and other goodies. |
3797 | |
3814 | |
3798 | ############################################################################# |
3815 | ############################################################################# |
3799 | |
3816 | |
3800 | package CFPlus::UI::Menu; |
3817 | package DC::UI::Menu; |
3801 | |
3818 | |
3802 | our @ISA = CFPlus::UI::Toplevel::; |
3819 | our @ISA = DC::UI::Toplevel::; |
3803 | |
3820 | |
3804 | use CFPlus::OpenGL; |
3821 | use DC::OpenGL; |
3805 | |
3822 | |
3806 | sub new { |
3823 | sub new { |
3807 | my $class = shift; |
3824 | my $class = shift; |
3808 | |
3825 | |
3809 | my $self = $class->SUPER::new ( |
3826 | my $self = $class->SUPER::new ( |
3810 | items => [], |
3827 | items => [], |
3811 | z => 100, |
3828 | z => 100, |
3812 | @_, |
3829 | @_, |
3813 | ); |
3830 | ); |
3814 | |
3831 | |
3815 | $self->add ($self->{vbox} = new CFPlus::UI::VBox); |
3832 | $self->add ($self->{vbox} = new DC::UI::VBox); |
3816 | |
3833 | |
3817 | for my $item (@{ $self->{items} }) { |
3834 | for my $item (@{ $self->{items} }) { |
3818 | my ($widget, $cb, $tooltip) = @$item; |
3835 | my ($widget, $cb, $tooltip) = @$item; |
3819 | |
3836 | |
3820 | # handle various types of items, only text for now |
3837 | # handle various types of items, only text for now |
3821 | if (!ref $widget) { |
3838 | if (!ref $widget) { |
3822 | if ($widget =~ /\t/) { |
3839 | if ($widget =~ /\t/) { |
3823 | my ($left, $right) = split /\t/, $widget, 2; |
3840 | my ($left, $right) = split /\t/, $widget, 2; |
3824 | |
3841 | |
3825 | $widget = new CFPlus::UI::HBox |
3842 | $widget = new DC::UI::HBox |
3826 | can_hover => 1, |
3843 | can_hover => 1, |
3827 | can_events => 1, |
3844 | can_events => 1, |
3828 | tooltip => $tooltip, |
3845 | tooltip => $tooltip, |
3829 | children => [ |
3846 | children => [ |
3830 | (new CFPlus::UI::Label markup => $left, expand => 1), |
3847 | (new DC::UI::Label markup => $left, expand => 1), |
3831 | (new CFPlus::UI::Label markup => $right, align => +1), |
3848 | (new DC::UI::Label markup => $right, align => +1), |
3832 | ], |
3849 | ], |
3833 | ; |
3850 | ; |
3834 | |
3851 | |
3835 | } else { |
3852 | } else { |
3836 | $widget = new CFPlus::UI::Label |
3853 | $widget = new DC::UI::Label |
3837 | can_hover => 1, |
3854 | can_hover => 1, |
3838 | can_events => 1, |
3855 | can_events => 1, |
3839 | markup => $widget, |
3856 | markup => $widget, |
3840 | tooltip => $tooltip; |
3857 | tooltip => $tooltip; |
3841 | } |
3858 | } |
… | |
… | |
3889 | 1 |
3906 | 1 |
3890 | } |
3907 | } |
3891 | |
3908 | |
3892 | ############################################################################# |
3909 | ############################################################################# |
3893 | |
3910 | |
3894 | package CFPlus::UI::Multiplexer; |
3911 | package DC::UI::Multiplexer; |
3895 | |
3912 | |
3896 | our @ISA = CFPlus::UI::Container::; |
3913 | our @ISA = DC::UI::Container::; |
3897 | |
3914 | |
3898 | sub new { |
3915 | sub new { |
3899 | my $class = shift; |
3916 | my $class = shift; |
3900 | |
3917 | |
3901 | my $self = $class->SUPER::new ( |
3918 | my $self = $class->SUPER::new ( |
… | |
… | |
3962 | $self->{current}->draw; |
3979 | $self->{current}->draw; |
3963 | } |
3980 | } |
3964 | |
3981 | |
3965 | ############################################################################# |
3982 | ############################################################################# |
3966 | |
3983 | |
3967 | package CFPlus::UI::Notebook; |
3984 | package DC::UI::Notebook; |
3968 | |
3985 | |
3969 | use CFPlus::OpenGL; |
3986 | use DC::OpenGL; |
3970 | |
3987 | |
3971 | our @ISA = CFPlus::UI::VBox::; |
3988 | our @ISA = DC::UI::VBox::; |
3972 | |
3989 | |
3973 | sub new { |
3990 | sub new { |
3974 | my $class = shift; |
3991 | my $class = shift; |
3975 | |
3992 | |
3976 | my $self = $class->SUPER::new ( |
3993 | my $self = $class->SUPER::new ( |
3977 | buttonbar => (new CFPlus::UI::Buttonbar), |
3994 | buttonbar => (new DC::UI::Buttonbar), |
3978 | multiplexer => (new CFPlus::UI::Multiplexer expand => 1), |
3995 | multiplexer => (new DC::UI::Multiplexer expand => 1), |
3979 | active_outline => [.7, .7, 0.2], |
3996 | active_outline => [.7, .7, 0.2], |
3980 | # filter => # will be put between multiplexer and $self |
3997 | # filter => # will be put between multiplexer and $self |
3981 | @_, |
3998 | @_, |
3982 | ); |
3999 | ); |
3983 | |
4000 | |
… | |
… | |
3992 | |
4009 | |
3993 | for my $child (@$widgets) { |
4010 | for my $child (@$widgets) { |
3994 | Scalar::Util::weaken $child; |
4011 | Scalar::Util::weaken $child; |
3995 | $child->{c_tab_} ||= do { |
4012 | $child->{c_tab_} ||= do { |
3996 | my $tab = |
4013 | my $tab = |
3997 | (UNIVERSAL::isa $child->{c_tab}, "CFPlus::UI::Base") |
4014 | (UNIVERSAL::isa $child->{c_tab}, "DC::UI::Base") |
3998 | ? $child->{c_tab} |
4015 | ? $child->{c_tab} |
3999 | : new CFPlus::UI::Button markup => $child->{c_tab}[0], tooltip => $child->{c_tab}[1]; |
4016 | : new DC::UI::Button markup => $child->{c_tab}[0], tooltip => $child->{c_tab}[1]; |
4000 | |
4017 | |
4001 | $tab->connect (activate => sub { |
4018 | $tab->connect (activate => sub { |
4002 | $wself->set_current_page ($child); |
4019 | $wself->set_current_page ($child); |
4003 | }); |
4020 | }); |
4004 | |
4021 | |
… | |
… | |
4080 | } |
4097 | } |
4081 | } |
4098 | } |
4082 | |
4099 | |
4083 | ############################################################################# |
4100 | ############################################################################# |
4084 | |
4101 | |
4085 | package CFPlus::UI::Selector; |
4102 | package DC::UI::Selector; |
4086 | |
4103 | |
4087 | use utf8; |
4104 | use utf8; |
4088 | |
4105 | |
4089 | our @ISA = CFPlus::UI::Button::; |
4106 | our @ISA = DC::UI::Button::; |
4090 | |
4107 | |
4091 | sub new { |
4108 | sub new { |
4092 | my $class = shift; |
4109 | my $class = shift; |
4093 | |
4110 | |
4094 | my $self = $class->SUPER::new ( |
4111 | my $self = $class->SUPER::new ( |
… | |
… | |
4111 | my ($value, $title, $tooltip) = @$_; |
4128 | my ($value, $title, $tooltip) = @$_; |
4112 | |
4129 | |
4113 | push @menu_items, [$tooltip || $title, sub { $self->set_value ($value) }]; |
4130 | push @menu_items, [$tooltip || $title, sub { $self->set_value ($value) }]; |
4114 | } |
4131 | } |
4115 | |
4132 | |
4116 | CFPlus::UI::Menu->new (items => \@menu_items)->popup ($ev); |
4133 | DC::UI::Menu->new (items => \@menu_items)->popup ($ev); |
4117 | } |
4134 | } |
4118 | |
4135 | |
4119 | sub _set_value { |
4136 | sub _set_value { |
4120 | my ($self, $value) = @_; |
4137 | my ($self, $value) = @_; |
4121 | |
4138 | |
… | |
… | |
4144 | $self->_set_value ($self->{value}); |
4161 | $self->_set_value ($self->{value}); |
4145 | } |
4162 | } |
4146 | |
4163 | |
4147 | ############################################################################# |
4164 | ############################################################################# |
4148 | |
4165 | |
4149 | package CFPlus::UI::Statusbox; |
4166 | package DC::UI::Statusbox; |
4150 | |
4167 | |
4151 | our @ISA = CFPlus::UI::VBox::; |
4168 | our @ISA = DC::UI::VBox::; |
4152 | |
4169 | |
4153 | sub new { |
4170 | sub new { |
4154 | my $class = shift; |
4171 | my $class = shift; |
4155 | |
4172 | |
4156 | my $self = $class->SUPER::new ( |
4173 | my $self = $class->SUPER::new ( |
4157 | fontsize => 0.8, |
4174 | fontsize => 0.8, |
4158 | @_, |
4175 | @_, |
4159 | ); |
4176 | ); |
4160 | |
4177 | |
4161 | CFPlus::weaken (my $this = $self); |
4178 | DC::weaken (my $this = $self); |
4162 | |
4179 | |
4163 | $self->{timer} = EV::timer 1, 1, sub { $this->reorder }; |
4180 | $self->{timer} = EV::timer 1, 1, sub { $this->reorder }; |
4164 | |
4181 | |
4165 | $self |
4182 | $self |
4166 | } |
4183 | } |
… | |
… | |
4168 | sub reorder { |
4185 | sub reorder { |
4169 | my ($self) = @_; |
4186 | my ($self) = @_; |
4170 | my $NOW = Time::HiRes::time; |
4187 | my $NOW = Time::HiRes::time; |
4171 | |
4188 | |
4172 | # freeze display when hovering over any label |
4189 | # freeze display when hovering over any label |
4173 | return if $CFPlus::UI::TOOLTIP->{owner} |
4190 | return if $DC::UI::TOOLTIP->{owner} |
4174 | && grep $CFPlus::UI::TOOLTIP->{owner} == $_->{label}, |
4191 | && grep $DC::UI::TOOLTIP->{owner} == $_->{label}, |
4175 | values %{ $self->{item} }; |
4192 | values %{ $self->{item} }; |
4176 | |
4193 | |
4177 | while (my ($k, $v) = each %{ $self->{item} }) { |
4194 | while (my ($k, $v) = each %{ $self->{item} }) { |
4178 | delete $self->{item}{$k} if $v->{timeout} < $NOW; |
4195 | delete $self->{item}{$k} if $v->{timeout} < $NOW; |
4179 | } |
4196 | } |
… | |
… | |
4200 | for ($short) { |
4217 | for ($short) { |
4201 | s/^\s+//; |
4218 | s/^\s+//; |
4202 | s/\s+/ /g; |
4219 | s/\s+/ /g; |
4203 | } |
4220 | } |
4204 | |
4221 | |
4205 | new CFPlus::UI::Label |
4222 | new DC::UI::Label |
4206 | markup => $short, |
4223 | markup => $short, |
4207 | tooltip => $item->{tooltip}, |
4224 | tooltip => $item->{tooltip}, |
4208 | tooltip_font => $::FONT_PROP, |
4225 | tooltip_font => $::FONT_PROP, |
4209 | tooltip_width => 0.67, |
4226 | tooltip_width => 0.67, |
4210 | fontsize => $item->{fontsize} || $self->{fontsize}, |
4227 | fontsize => $item->{fontsize} || $self->{fontsize}, |
… | |
… | |
4289 | $self->SUPER::destroy; |
4306 | $self->SUPER::destroy; |
4290 | } |
4307 | } |
4291 | |
4308 | |
4292 | ############################################################################# |
4309 | ############################################################################# |
4293 | |
4310 | |
4294 | package CFPlus::UI::Root; |
4311 | package DC::UI::Root; |
4295 | |
4312 | |
4296 | our @ISA = CFPlus::UI::Container::; |
4313 | our @ISA = DC::UI::Container::; |
4297 | |
4314 | |
4298 | use List::Util qw(min max); |
4315 | use List::Util qw(min max); |
4299 | |
4316 | |
4300 | use CFPlus::OpenGL; |
4317 | use DC::OpenGL; |
4301 | |
4318 | |
4302 | sub new { |
4319 | sub new { |
4303 | my $class = shift; |
4320 | my $class = shift; |
4304 | |
4321 | |
4305 | my $self = $class->SUPER::new ( |
4322 | my $self = $class->SUPER::new ( |
4306 | visible => 1, |
4323 | visible => 1, |
4307 | @_, |
4324 | @_, |
4308 | ); |
4325 | ); |
4309 | |
4326 | |
4310 | CFPlus::weaken ($self->{root} = $self); |
4327 | DC::weaken ($self->{root} = $self); |
4311 | |
4328 | |
4312 | $self |
4329 | $self |
4313 | } |
4330 | } |
4314 | |
4331 | |
4315 | sub size_request { |
4332 | sub size_request { |
… | |
… | |
4363 | } |
4380 | } |
4364 | |
4381 | |
4365 | sub update { |
4382 | sub update { |
4366 | my ($self) = @_; |
4383 | my ($self) = @_; |
4367 | |
4384 | |
4368 | $::WANT_REFRESH->start; |
4385 | $::WANT_REFRESH = 1; |
4369 | } |
4386 | } |
4370 | |
4387 | |
4371 | sub add { |
4388 | sub add { |
4372 | my ($self, @children) = @_; |
4389 | my ($self, @children) = @_; |
4373 | |
4390 | |
… | |
… | |
4518 | glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000, 10000; |
4535 | glOrtho 0, $::WIDTH, $::HEIGHT, 0, -10000, 10000; |
4519 | glMatrixMode GL_MODELVIEW; |
4536 | glMatrixMode GL_MODELVIEW; |
4520 | glLoadIdentity; |
4537 | glLoadIdentity; |
4521 | |
4538 | |
4522 | { |
4539 | { |
4523 | package CFPlus::UI::Base; |
4540 | package DC::UI::Base; |
4524 | |
4541 | |
4525 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
4542 | local ($draw_x, $draw_y, $draw_w, $draw_h) = |
4526 | (0, 0, $self->{w}, $self->{h}); |
4543 | (0, 0, $self->{w}, $self->{h}); |
4527 | |
4544 | |
4528 | $self->_draw; |
4545 | $self->_draw; |
4529 | } |
4546 | } |
4530 | } |
4547 | } |
4531 | |
4548 | |
4532 | ############################################################################# |
4549 | ############################################################################# |
4533 | |
4550 | |
4534 | package CFPlus::UI; |
4551 | package DC::UI; |
4535 | |
4552 | |
4536 | $ROOT = new CFPlus::UI::Root; |
4553 | $ROOT = new DC::UI::Root; |
4537 | $TOOLTIP = new CFPlus::UI::Tooltip z => 900; |
4554 | $TOOLTIP = new DC::UI::Tooltip z => 900; |
4538 | |
4555 | |
4539 | 1 |
4556 | 1 |
4540 | |
4557 | |